Repository navigation
fix(agents-md-budget): sum every tracked AGENTS.md against Codex's shared budget - #300
Conversation
…ared budget and say to prune
…eep non-ASCII paths, record the upstream sync
| else | ||
| [ -f "$REPO/AGENTS.md" ] || die "no root AGENTS.md in $REPO" 2 | ||
| # quotePath=false keeps non-ASCII paths literal so each one is found on disk. | ||
| tracked=$(git -C "$REPO" -c core.quotePath=false ls-files -- AGENTS.md '*/AGENTS.md') \ |
There was a problem hiding this comment.
A new nested AGENTS.md that has not been staged yet is not counted, so the local check passes while CI fails once the file is committed. The chain comes from git ls-files, which lists only indexed paths. Codex itself reads any AGENTS.md on disk in the chain, whether or not git tracks it. Fix: also list untracked files that are not ignored (git ls-files --cached --others --exclude-standard -- AGENTS.md '*/AGENTS.md'). That keeps projects/ out and counts a file a worker just created.
Failure scenario: A worker creates docs/AGENTS.md (3 KB) in a worktree whose root AGENTS.md is 28,234 bytes. It runs bin/fm-test-run.sh --near before git add, and the budget test reports ok at bytes=28234. The worker commits and opens the PR, and CI fails at 31,234 bytes, over the 30,720 limit. The local check missed what it exists to catch.
|
Failure scenario: An agent reads this guideline, puts conditional detail into a new subdirectory AGENTS.md to keep the root small, and expects the budget to be unaffected. The summed check then fails, or nearly fails, and the guidance the agent followed did not warn about it. |
…the coding guidelines
|
Code review: Claude Code |
Summary
Codex's
project_doc_max_bytes(32 KiB) is one budget shared by every AGENTS.md from the repo root down to the working folder, and Codex cuts it off with no warning.bin/fm-agents-md-budget.shalready guarded the root file at 30,720 bytes. It now sums the root plus every nested AGENTS.md that git does not ignore (git ls-files --cached --others --exclude-standard), staged or not, so ignored paths such asprojects/stay out. When the sum is over the limit, the message points at AGENTS.md "Maintaining this file" and says to prune, not to raise the limit. AGENTS.md itself is untouched.Evidence
bin/fm-agents-md-budget.sh→ok bytes=28234 limit=30720 budget=32768 margin=2048 headroom=2486.--margin 6000→ exit 1,the AGENTS.md chain (1 tracked files ...) is 28234 bytes, 1466 over the 26768-byte limit ...; prune it as AGENTS.md "Maintaining this file" says ...; do not raise the limit.bin/fm-test-run.sh --near: 2/2 pass.bin/fm-lint.shclean.bin/fm-fork-decisions.sh checkok.Merge Danger
Door: two-way
Blast Radius: one fork-only check script and its test, plus a
docs/scripts.mdrow and a fork-patch record. From now on, any nested tracked AGENTS.md counts toward the limit.Reviewed with sol-loop: 3 rounds, gpt-6.2-sol; 5 fixed (nested-path test selection twice, sync baseline, non-ASCII paths, ls-files exit status); declined as nits: untracked root, --repo caller, full-suite fallback for an unmapped nested AGENTS.md (over-selects, still runs the budget test), escaped control-character paths.