Skip to content

feat: wire up drift scanner with GitHub API comparison#3

Open
jmanhype wants to merge 1 commit intoagentjido:mainfrom
jmanhype:feat/drift-scanner-wiring
Open

feat: wire up drift scanner with GitHub API comparison#3
jmanhype wants to merge 1 commit intoagentjido:mainfrom
jmanhype:feat/drift-scanner-wiring

Conversation

@jmanhype
Copy link

Summary

  • Replace the has_drift?/3 stub in ScanDrift with a real implementation
  • Uses gh api repos/{owner}/{repo}/compare/{sha}...HEAD to detect whether source files have changed since a Livebook was last grounded
  • Adds parse_repo_spec/1 to handle owner/repo:alias format

Context

This completes the Drift Scanner (Pillar 5 of the Autonomous Documentation Engine). The scan task can now detect when upstream source code changes invalidate existing generated Livebooks.

Test plan

  • Run mix jido_lib.github.docs.scan_drift priv/pages/docs against a repo with generated Livebooks
  • Verify files with stale grounded_sha are flagged as drifted
  • Verify files without grounded_sha are skipped gracefully

🤖 Generated with Claude Code

Replace the has_drift? stub with a real implementation that uses
`gh api repos/{owner}/{repo}/compare/{sha}...HEAD` to detect
whether source files have changed since a Livebook was last grounded.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3183d84ad5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

{owner, repo} = parse_repo_spec(repo_spec)

Enum.any?(source_files, fn file ->
case System.cmd("gh", ["api", "repos/#{owner}/#{repo}/compare/#{last_sha}...HEAD",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Handle missing gh CLI before running drift checks

This System.cmd/3 call will raise :enoent if gh is not installed or not on PATH, so the task crashes before it can reach the non-zero fallback branch. In environments that run docs tooling without GitHub CLI, mix jido_lib.github.docs.scan_drift aborts instead of reporting an unverifiable repo as potential drift. Add an executable check or rescue around the command invocation so this failure mode is handled.

Useful? React with 👍 / 👎.

Comment on lines +62 to +64
Enum.any?(source_files, fn file ->
case System.cmd("gh", ["api", "repos/#{owner}/#{repo}/compare/#{last_sha}...HEAD",
"--jq", ".files[].filename"], stderr_to_stdout: true) do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fetch compare results once per repo, not per source file

The compare API request does not depend on file, but it is executed inside the source_files loop, creating redundant repos × source_files calls. This significantly increases latency and the chance of throttling/transient failures, and any single failure returns true, which marks drift even when no tracked files changed. Move the compare call outside the inner loop and reuse the changed-file list for membership checks.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant