Skip to content

fix(codex-review): scope untracked-file inlining to the current run - #14

Open
josix wants to merge 5 commits into
mainfrom
worktree-fix-untracked-diff-scope
Open

josix wants to merge 5 commits into
mainfrom
worktree-fix-untracked-diff-scope

Conversation

@josix

@josix josix commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Summary

dispatch-codex-review.sh inlined every untracked file in the working tree into the diff sent to Codex. In a real /orchestrate run the task's tracked diff was ~32 KB, but the review diff reached ~270 KB because ~240 KB of pre-existing scratch files (an aider chat/cache, complexipy-results.json, a doc-site HTML export, another ticket's tmp/ drafts, a stray .patch) were inlined too. That both buries the real change and sends unrelated repo content to an external vendor. The dispatcher also had no secret-filename guard.

Changes

  • scripts/snapshot-untracked.sh (new): records the untracked-file set (NUL-safe, idempotent) before Phase 3, stamped with the run's started_at, to .claude/review-baseline-untracked.local.txt (already gitignored).
  • scripts/dispatch-codex-review.sh: inlines only untracked files that are not in the snapshot, or were modified after it. A missing/stale snapshot falls back to the old behavior with a warn: line. Adds the extended artifact exclusions (tmp/, .aider*, *-results.json, patch/diff leftovers, _site/, _build/, htmlcov/, .senku/, logs, DBs) and a secret-basename guard (same set as validate-changes.sh). New codex_untracked: stdout key with counts; existing codex_* keys unchanged. AGENT_FLOW_CODEX_INLINE_UNTRACKED=0 disables untracked inlining in the fallback path.
  • workflows/implement-review-verify.js: runs the snapshot task before the first Loid dispatch when Codex is on (non-blocking on failure); the test mock now distinguishes the snapshot task from Codex.
  • commands/orchestrate.md: manual Phase 3 runs the snapshot in the same Bash block as REVIEW_BASE.
  • Docs: using-codex-review.md, codex-co-review.md, state-files.md, commands.md.
  • Version: 1.11.1.

Tests

  • bash scripts/test-dispatch-codex-review.sh — 11/11 (Tests 7–11 new: baseline hit / pre-existing skipped / stale & missing fallback / kill switch / extended exclusions / secret guard), also run under /bin/bash 3.2 with BSD tools.
  • node scripts/test-implement-review-verify.js — 21/21 (4 new snapshot scenarios).
  • bash scripts/validate-plugin.sh — all suites pass; claude plugin validate --strict passes; mkdocs build --strict passes.

Reviewed by Lawliet (APPROVED, 3 INFO nits) and verified by Alphonse; the Codex co-review did not run (workspace out of credits).

Follow-up

The JEV branch (worktree-feat-jev-integration) copies the same diff-building logic in dispatch-jev-review.sh; it will rebase onto this fix and adopt the shared guards.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XtkZ8b2yn9FPXZtzwsQYaR

josix and others added 5 commits September 30, 2026 11:45
Records the set of untracked files that exist before an orchestrate run
starts (NUL-safe, tied to the state file's started_at), so a later
dispatch-codex-review.sh run can tell pre-existing clutter apart from
this run's new files.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XtkZ8b2yn9FPXZtzwsQYaR
dispatch-codex-review.sh now reads the untracked-file baseline written by
snapshot-untracked.sh and skips files that already existed before this run
(counted, not listed), falling back to today's behavior with a warn: line
when no baseline exists or it is stale. Also extends the artifact exclusion
list (tmp/, .aider*, *-results.json, patch/diff leftovers, doc-site/coverage
build output, .senku/, logs, DBs) and adds a secret-basename guard using the
same set as hooks/scripts/validate-changes.sh. Adds a new informational
codex_untracked stdout key and an AGENT_FLOW_CODEX_INLINE_UNTRACKED=0 kill
switch for the no-baseline fallback. No existing codex_* key changes.

Adds dispatcher Tests 7-11 covering the baseline hit/miss/stale paths, the
extended exclusions, and the secret guard.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XtkZ8b2yn9FPXZtzwsQYaR
Dispatches a small snapshot-untracked.sh task before the first Loid pass
whenever Codex co-review is enabled and this isn't a start_round>0 relaunch,
so the baseline reflects the tree before this run's edits. The snapshot
never blocks: a failure only logs a fallback notice. Also plumbs the new
codex_untracked value through CODEX_SCHEMA for logging.

Fixes the workflow test mock, which classified every agent call without
agentType as Codex, to recognize the new Snapshot task by its label. Adds
4 scenarios covering the snapshot dispatch, its absence when Codex is off,
non-blocking failure, and relaunch skipping a second snapshot.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XtkZ8b2yn9FPXZtzwsQYaR
Documents scripts/snapshot-untracked.sh, the untracked-file precedence
order, the new codex_untracked stdout key, and the
AGENT_FLOW_CODEX_INLINE_UNTRACKED kill switch across commands/orchestrate.md
(manual Phase 3), the codex-co-review skill reference, the Codex co-review
guide (data boundary, prompt/scope guards, context list), the commands
reference (sequence diagram + env var table), and a new state-files.md
section for review-baseline-untracked.local.txt.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XtkZ8b2yn9FPXZtzwsQYaR
Curates the generated CHANGELOG section (Fixed: the untracked-diff-scope
incident and its baseline/exclusion/secret-guard fix; Added: the new
script, output key, and kill switch) and keeps [Unreleased] at the top.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XtkZ8b2yn9FPXZtzwsQYaR

This branch has not been deployed

No deployments
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

Sponsor
SponsoredKunjungi sekarang
Promo