Repository navigation
feat(adf)!: compile and tidy read the vendor mode record (#318 2/6) - #352
Conversation
BREAKING CHANGE: adf compile --write no longer converts pointer files without --mode compiled. Co-Authored-By: Claude Opus 5.5 <[email protected]>
stackbilt-admin
left a comment
There was a problem hiding this comment.
CHANGES_REQUESTED
Adversarial review of #352 (PR 2/6 for #318), checked against the locked addendum pr2-compile-tidy.contract.ts and pr2-scope.md.
The behavior is right. Every decision-table row, exit code and invariant I checked holds end to end. The four required changes are in docs and tests: the npm-facing quickstart is still broken, the bigint regression test does not test the fix, and two docs items need fixing.
Required changes
-
packages/cli/README.md:19,:43,:79: the npm package README still has the old quickstart.- Each of these lines tells users to run
bootstrap --yesand thencharter adf compile --target all --write. After this PR that second command skips every file and writes nothing. - This README is the one published to npmjs for
@stackbilt/cli, so it is the quickstart most new users read. The operator ruling asked for README and docs to be updated, and only the rootREADME.mdwas. - Fix: apply the same
--mode compiledchange as rootREADME.md:40to lines 19 and 43. Reword line 79 the way rootREADME.md:291-292does.
- Each of these lines tells users to run
-
packages/cli/src/__tests__/adf-migrate-discovery.test.ts:94-104: the newfileIdentitytest passes on the old code.- I copied the test into a main worktree (number
ino). It passes there:6 passed. - The test only fails when the real temp-dir inodes exceed 2^53 and are not exactly representable. On this Windows machine, files in
os.tmpdir()get inodes around 2.5e15 to 3.6e15, below 2^53. Repo files reach 1.27e16 (README.md: number12666373958243488, bigint12666373958243487), so the bug is real. - CI runs on
ubuntu-latest, where inodes are small, so CI can never catch a revert. - Fix: make the test deterministic. Mock
statSync(for examplevi.mock('node:fs', …)) to return bigint stats for two different files whose inodes collapse to the same number, such as2n**53nand2n**53n + 1n. Assert thatfileIdentitytells them apart and thatdiscoverAgentConfigFiles()keeps both.
- I copied the test into a main worktree (number
-
CHANGELOG.md:9-11: the Breaking marker does not follow repo precedent.- The repo's only other breaking release,
## [1.0.0]atCHANGELOG.md:206, puts a standalone**Breaking:** …lead paragraph directly under the version heading, before the###subsections. - Here the marker is a
- **BREAKING: …**bullet buried in### Changed, and it runs to about 400 words. - Fix: add a one-to-two-sentence
**Breaking:**lead paragraph under## [Unreleased], with the migration line (charter adf compile --target all --write --mode compiled). Keep the detailed bullet where it is. I verified the migration text is correct. Both routes work:--mode compiled, andvendor set <f> compiledfollowed by a plain--write.
- The repo's only other breaking release,
-
docs/cli-reference.md:626: one statement is now false.- The line says "a failed record write is only a warning". Under
--mode compiled, a failed record write is nowrefused-record, exit 1, and nothing is written. Your own--mode compiledbullet at about line 488 says so. - Fix: qualify the line, for example "…only a warning, except under
adf compile --write --mode compiled, where the target is refused (refused-record)".
- The line says "a failed record write is only a warning". Under
Verified (temp worktrees of the PR head 1ff3ef0 and origin/main 555711a, Windows + Git Bash)
- Build, typecheck, verify:adf, CI.
- Build and typecheck are clean.
pnpm run verify:adfpasses.adf_commands_locis 1027/1041 andadf_sync_locis 219/250.- The full suite has 5 failures, and they are the same 5 on main: Windows path-separator tests in context-refresh, serve-context and bootstrap #307, plus
precommit-hook.test.ts×2. They are not caused by this PR, and CI on Linux is green.
- Hooks.
git diff origin/main -- .githooks packages/cli/src/commands/hook.tsis empty (INV-P2-12). - Decision table (E2E). All four shipped pointers (CLAUDE.md, AGENTS.md, .cursorrules, GEMINI.md), recorded or inferred:
--target all --write:[skip]×4 plusnothingCompiled, exit 0, md5 of every file unchanged.- Single
--target claude --write, with or without--force: refused, exit 1, file untouched. --mode pointer, a bare trailing--mode, and--modewith--check: exit 2 with the contract text.--mode compiled: record upserted, thenWritten CLAUDE.md (mode: pointer -> compiled).- Mixed
--target all(one compiled, three pointers): writes one, skips three, exit 0. JSONwritten,refused,skippedandtargetsare correct. - Unmanaged with
--mode compiled: refused hand-authored, record untouched. With--forceit is written asunmanaged -> compiled. - The #295 retained guard still refuses under
--mode compiledand records nothing. - "record kept" never appears. On main it is printed four times for the same scenario.
- refused-record. I made the CLAUDE.md entry malformed (
- CLAUDE.md pointer) and ran--write --mode compiled. Result: exit 1, both the file's and the manifest's md5 unchanged, and JSONstatus: refused-record,recordedMode: null. - No-VENDORS compiled-only regression (
adf init→compile --write→ strip VENDORS), diffed against main:- Text output of
--check(fresh and stale),--write(all and single) and tidy is identical to main. - The exceptions are intended or additive:
- tidy no longer double-walks
agents.md, which is the intended de-dup. - A
missingfile gains aRun:line. - The JSON output only gains keys.
- tidy no longer double-walks
- All-banner files with no VENDORS:
--target all --writewrites all four with no new notes and records them as compiled. - With no vendor files on disk, all four are written and recorded
compiled.
- Text output of
- Pre-commit hook
totalExtracted, main vs PR.- A bloated pointer repo gives 3 vs 3, recorded or not.
- Compiled repos give 0 vs 0.
- Whole-tree tidy on a hand-authored, unrecorded file prints the same text as main (quiet). The status is
unmanaged, and the warning appears only with--source.
- README.md quickstart, followed literally.
- On a fresh repo:
bootstrap --yes, thencompile --target all --write --mode compiled(four switched), thencompile --target all --check, which exits 0. copilot-instructions.mdstays recorded aspointer.
- On a fresh repo:
- tidy. The banner wins over a recorded pointer (
status: compiled,skipReason: banner). A recorded-compiled file with no banner is skipped. A recorded pointer with no marker is skipped with a warning. - bigint
fileIdentityis correct on every OS.${bigint}stringifies as plain decimal with non.if (st.ino)handles0n, so the realpath fallback still works.adf-migrate.ts:68is the only place that compares inodes, and identity strings are never persisted or mixed with number-based ones.- Only the test is a problem (required change 2).
Rulings on the implementation's judgement calls
- #295 retained guard kept for no-banner recorded-compiled files: accept. It protects user content, and PR5 replaces it.
- Render before upsert: accept. A compile error then leaves both the record and the file untouched.
- Inferred-unmanaged warns only with
--source: accept. Whole-tree output is byte-identical to main, as INV-P2-7 requires. checkMissingCompiledRun:line: accept. It is the contract literal and the only text change on compiled-only repos.- nextActions dedupe and fallback: accept. See the second non-blocking note.
- mode-drift
remedyholds the keep-the-file command, with the restore command only in nextActions: accept. - Rewritten PR1 tests: accept.
- The removed INV-1 compile and tidy compare tests are replaced by literal-text pins (INV-P2-7 and INV-P2-8).
- The INV-9 test was narrowed to legacy keys, which is fine because
targetsis new. adf-vendor.test.tsnow pins refusal with no "record kept".adf-compile.test.ts's--forcetest now also pins INV-P2-2.
Non-blocking notes
- A recorded-compiled pointer with bloat loses that content (follow-up for PR3/PR5).
- Setup: VENDORS says
compiled, and the file is a pointer with a## Architecturesection. - tidy skips it with "Regenerate it from .ai/: charter adf compile --target claude --write", and the mode-drift restore line says the same.
- Running that command overwrites the file, and the non-retained bloat is lost (
[ok] Written CLAUDE.md). On main, tidy and the hook would have extracted it first. - This follows the contract literally, but the remedy is destructive for exactly the post-
bootstrap --forcecaserecorded-compiledwas designed for.
- Setup: VENDORS says
- Check-JSON
nextActionson a compiled-only stale repo. It used to be["charter adf compile --target all --write"]. It is now four per-target lines. The contract allows it, but it is a visible change for legacy consumers. Consider collapsing to--target all --writewhen every remedy is a compile of a compiled target under--target all. - A write failure after the upsert aborts the run.
- Example: a read-only CLAUDE.md under
--mode compiledthrows EPERM and exits 2. The record is alreadycompiled, so the file now drifts. - Under
--target all, the remaining targets and the pending add-if-absent entries are never processed. - The ordering is mandated by the contract, but catching the write error per target (and reverting the upsert, or reporting a row) would be kinder.
- Example: a read-only CLAUDE.md under
- Two-step remedy for an existing unmanaged file.
refusedModeChangesuggests--write --mode compiled, which then refuses for lack of--force. Consider adding--forceto the suggestion when the state is unmanaged and the file exists. The JSONremedyforrefused-hand-authoredalready does this. adf-compile.ts:203-204: stdout-mode JSONnextActionsstill suggest--target X --writeand--target all --writewithout regard to mode. For a pointer target those are now refused or skipped. Out of scope for INV-P2-1, but it leads nowhere.- The docs/cli-reference
--writetable row "compiled, or absent | written" reads as if any absent file is written. A recorded-pointer file that is absent is skipped or refused. Say "absent and unrecorded". refused-recordprints the record writer's entry-malformed warning, a VENDORS entry problem (INV-P2-11, strictly). Acceptable, because it is the reason for the refusal.- On a case-insensitive filesystem with
agents.md: pointerrecorded,--target agents --write --mode compiledresolves toagents.md, hitsmode-not-allowed, and ends asrefused-recordwith a generic message. This belongs to PR6. - The bigint fix has no CHANGELOG line. The bug never shipped (#343 and PR1 are unreleased), so this is optional. A clause on the #343 entry would help.
- Stale marketing docs.
docs/launch/charter-announcement.md:42anddocs/launch-playbook.md:42still show the bare--target all --write. They are historical, so updating them is optional.
… README (refs #318) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes #318
Breaking:
charter adf compile --writeno longer converts pointer files to compiled output unless you pass--mode compiled.charter bootstrap,charter adf compile --target all --write(the README quickstart's step 3) replaced every thin pointer with compiled output, silently changing each file's mode. A single--target X --writedid the same, and--forceoverwrote hand-authored files.--target all, pointer and unmanaged targets are skipped and left untouched, and the exit code is 0. Each skipped target prints a[skip]line naming the exact command. When every target is skipped, compile says nothing was written, why, and how to switch. A single pointer or unmanaged--targetis refused with exit 1.--forcealone never changes a file's mode.charter adf compile --target all --write --mode compiled, or record the mode once withcharter adf vendor set <file> compiled. After that, a plain--writere-renders the file.Summary
PR 2 of 6 for #318.
adf compile(--checkand--write) andadf tidynow read theVENDORSmode record that #350 added. When a file has no entry, its mode is inferred from its markers.absent-unrecorded. The resolver's "absent means unmanaged" fallback is not reused, so a fresh repo still compiles.--mode compiled: this is the only accepted value, and it is valid only with--write. Misuse exits 2. The record is upserted before the file is written, after the content guards and after rendering. If the upsert is skipped, the result isrefused-recordand nothing is written.--check: each target is checked by its mode and gets one of seven statuses. No remedy suggests a mode-changingcompile --write.skipReason. Files are discovered throughdiscoverAgentConfigFiles, so theAGENTS.md/agents.mddouble walk on case-insensitive filesystems is gone (AGENTS.md migration gaps for repos bootstrapped before #297 #302 gap 3).charter adf vendor status.docs/cli-reference.mdgets compile mode and status tables, plus updated tidy, sync and vendor sections. The CHANGELOG has a### ChangedBREAKING: entry and a### Fixedentry.Also fixed (found during E2E; needed by this PR)
fileIdentity(adf-migrate.ts, used bydiscoverAgentConfigFilesand the PR1 vendor grouping) compared thenumberinode. NTFS file indexes exceed 2^53, so in a fresh bootstrap on Windows,CLAUDE.mdand.cursorrulesgot the same identity. Three things followed:.cursorrules--checkcompared.cursorrulesas if it wereCLAUDE.md.cursorrulesas a duplicateIt now uses
statSync(..., { bigint: true }).file-identity.test.tsmocksstatSyncwith inodes 2^53 and 2^53+1, which collapse to one JS number. It is deterministic on every OS and fails on the old code.Before → after
compile --check[stale], exit 1, suggests--writepointer-ok, exit 0compile --check[stale], exit 1pointer-bloated, exit 1, suggestsadf tidy --source Fcompile --check[stale], exit 1skipped-unmanaged, exit 0compile --check[ok]or[stale]mode-drift, exit 1, both remediescompile --checkRun:line)compile --write --target allskipped-mode, exit 0, file untouchedcompile --write --target Xrefused-mode-change, exit 1compile --write --mode compiledWritten F (mode: pointer -> compiled)compile --write --force--mode compiledcompile --writetidynot-foundunmanaged,inferred-unmanagedtidycompiled,recorded-compiled, skippedtidyJSON changes are additions only. Write output adds
skippedandtargets[]. Check output addsskippedandtargets[], and itsstalekey now also lists bloated and drifted files. Tidy rows addvendorFile,mode,sourceandskipReason, and theirstatuscan now also beunmanaged.Invariants and where they are tested
New tests are in
packages/cli/src/__tests__/adf-vendor-consumers.test.tsunless noted.INV-P2-1: no remedy suggests a mode-changing compile --write…. It also checks--writeremedies and nextActions.--forcealone never convertsINV-P2-2: --force alone never converts…, andadf-compile.test.ts--mode compiled --force overwrites…INV-P2-3: a skipped record upsert means no file write (refused-record), andINV-P2-3: the record is upserted before the file is written(a read-only target makes the write fail after the upsert)INV-P2-4: no write path prints…, andadf-vendor.test.tsadf compile --write refuses a recorded pointer…INV-P2-5: the banner wins over a recorded pointer…INV-P2-6: tidy --dry-run, compile --check and compile stdout never write manifest.adfINV-P2-7: …,INV-P2-8(tidy half), and E2E (e)INV-P2-8: --write, --check and tidy text match the pre-#318 output, and E2E (e)gives each of the seven statuses…and the decision-table tests; the existingadf-compile.test.tsJSON tests still passhandles a pointer-only name by mode (INV-P2-10)INV-P2-11: compile and tidy print no VENDORS entry-problem warningsgit diff origin/main -- .githooks packages/cli/src/commands/hook.tsis empty. Hook parity andprecommit-hook.test.tsare unchanged.The scope tests are also covered:
--checkstatuses--target all(exit 0), single pointer (exit 1) and--modemisuse (exit 2)refused-record--sourceand double-walk casesContract amendments (review round 1)
MSG.tidyRecordedCompiledand thecheckModeDriftkeep/restore lines). Take a file that is recordedcompiledbut has no banner and does carry pointer content. Both remedies now listcharter adf vendor set F pointer, then charter adf tidy --source Ffirst. Regenerating comes second and says how many items it would discard. A hand-authored file getsvendor set F unmanagedfirst. Tests follow the first-listed commands and assert that the content ends up in.ai/.refused-record. The write-target row gainswriteError, a new nullable field. A--mode compiledupsert that was already made is reverted with the same writer, to the state before the run. A file that had no entry is left recorded as its inferred mode. If the revert fails, a warning names the exactvendor setfix. The remaining targets and the pending add-if-absent entries are still processed, and the exit code is 1.refusedModeChangeandskippedModeadd--forcefor an existing hand-authored unmanaged file, so the remedy is one step.--target all, check-JSONnextActionscollapse to the legacy["charter adf compile --target all --write"]when every failing target is a stale or missing compiled file.nextActionsare mode-aware.Not changed yet
These stay out of PR2 by design:
--source; both hooks stay byte-identical herereplacedPointersagents.mdThe retained-section guard from #295 still refuses a pointer with user content, including under
--mode compiled. PR5 replaces it with preservation.Implemented via constellation-loop against a locked blueprint.
🤖 Generated with Claude Code