Repository navigation
feat(adf): record vendor file modes in manifest.adf (#318 1/6) - #350
Conversation
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 #350 (#318 PR 1 of 6). I built origin/auto/feature/issue-318-vendor-record and origin/main side by side and ran the same command sequences in temp repos on both builds. I also ran each consumer against the same repo with and without the VENDORS block. Most of the PR holds up. Two consumers change behaviour because of the VENDORS block, which INV-1 does not allow, and one case-insensitive filesystem path writes a contradictory record.
Required changes
-
charter scorechanges because of VENDORS (INV-1 lists score).packages/cli/src/commands/score.ts:415-422.- Cause. The grounding check runs
extractPathCandidatesover the whole text ofmanifest.adf. Each- CLAUDE.md: pointeritem becomes a path reference that resolves relative to.ai/(for example.ai/CLAUDE.md). - Plain bootstrap repo. The summary changes from
37/47 referenced paths resolveto41/51. - Repo where a vendor basename is not unique. I used
adf init --emit-pointerspluspackages/a/CLAUDE.mdandpackages/a/AGENTS.md, which is any monorepo with per-package agent files. The score total drops from 61 to 60, grounding drops from 9 to 8, andrecommendationsgainsFix or remove 4 broken path reference(s): ..., .ai/CLAUDE.md, .ai/AGENTS.md. Score is telling users to delete the record. - Recorded but absent file. The same thing happens to a file that is recorded but not on disk, for example after
vendor set GEMINI.md compiledahead of the file, which the contract explicitly endorses. - Fix. Leave the VENDORS section out of the grounding scan for the manifest. Add
scoreto the "consumers ignore the record (INV-1)" suite (adf-vendor.test.ts:694), which today covers compile, tidy and doctor only.
- Cause. The grounding check runs
-
Any writer-created VENDORS block makes
adf fmt --checkfail.packages/adf/src/formatter.ts:22, together with the parser dropping U+FE0F.- Cause. The writer emits
🏷️(U+1F3F7 U+FE0F).parseAdfstores only U+1F3F7, andformatAdfemitssection.decoration. So the canonical form is🏷 VENDORS:, which differs from the bytes the writer wrote. - Repro. Take a manifest where
fmt --checkprints[ok] ... is canonical. Runvendor set CLAUDE.md pointer, or any implicit writer.fmt --checkthen prints[warn] .ai/manifest.adf is not in canonical formatand exits 1. The VENDORS block is in a canonical position (last, after DEFAULT_LOAD). - Second effect.
fmt --writethen rewrites the header to the text-presentation🏷. - Fix. Keep the contract's locked header. Have the formatter emit
STANDARD_DECORATIONS[key]when the parsed decoration equals it minus VS16, or have the parser keep the FE0F. - Test. A canonical manifest plus
recordVendorModesshould satisfyformatAdf(parseAdf(text)) === text.
- Cause. The writer emits
-
Case-insensitive filesystems: one physical file gets two contradictory records.
packages/cli/src/commands/adf-vendor.ts:570-571(vendorSet),:251(readVendorFile),:261(vendorFilesOnDisk).- Repro (Windows). Start with only a legacy
agents.md, then:vendor initrecordsAGENTS.md: unmanaged. The inode dedupe works.vendor set agents.md pointerprintsagents.md does not exist yet(false), and appendsagents.md: pointer.vendor statusnow showsAGENTS.md unmanaged (recorded)andagents.md pointer (recorded; file absent)for the same file.adf migrate --source agents.mdgoes throughrecordWrittenVendorModesand splits the record the same way.
- Fix. When
<file>has the same file identity as another vendor name on disk, refuse it or map it to the spelling the record already uses, and name that spelling in the message. Check existence invendor setwith the real path, not the deduped set, sofileAbsentSetis only printed when it is true. Scope test 5 owns this dedupe, so it belongs in PR1.
- Repro (Windows). Start with only a legacy
Verified, no change needed
- P1, no other hidden consumer changes. I ran bootstrap,
adf sync --write,adf compile --target all --write(text and json),adf sync --checkandadf compile --checkon both builds. Outputs are identical apart from the VENDORS edit and therecord keptwarning lines.adf synchashes only SYNC sources, and bootstrap's lock covers only core and state, so there is no stale lock.adf evidence,adf bundle --format json,doctor --format jsonandcontext-refreshare identical with and without VENDORS, on both the main and PR builds.- Compile output never contains VENDORS. It renders only DEFAULT_LOAD modules,
MANIFEST_PLUMBING_KEYSalso covers it, andvendors.test.tschecks every target.
- P2, writer edge cases (run directly against dist):
- Handled and byte-exact: LF, CRLF, no trailing newline, BOM, empty file, an empty VENDORS header at EOF and mid-file, duplicate VENDORS sections (inserts into the last), duplicate sections where the last one is empty, and a header without decoration.
- Upsert: with odd spacing, CRLF, or duplicate entries, upsert changes exactly one line (the winning last entry).
- Refused with the right skip reason, nothing written: a lone CR (reparse-guard), a malformed entry for the file (entry-malformed), a non-list or map body (section-not-list), and a multi-line item or comment line (section-not-list).
- INV-11.
adf-manifest-register.test.tsis untouched and passes. The new defaultdecoration = SECTION_DECORATION[key]produces exactly the old header for DEFAULT_LOAD and ON_DEMAND. - P3, the stripping regex is exact. It removes
\n🏷️ VENDORS:\nplus the two-space-lines that follow, once, which is exactly what the writer appends at EOF. - P4, contract conformance.
- Inference matches
analyzeVendorFile: banner, thenPOINTER_MARKERS, else unmanaged. A banner on a pointer-only name gives unmanaged. ALLOWED_MODESis checked before any manifest state.- Exit codes, checked by hand:
statusexits 0, including with the manifest missing.set copilot-instructions.md compiledexits 1.setwith an unknown file, bad usage or a missing manifest exits 2.initexits 2 with the manifest missing, and a secondinitis a no-op.
--dry-runand--ai-dirwork.statushas no write path.- The extra messages are acceptable additions, not drift. The contract templates would be false in those cases:
manifestUnparseableStatusandsectionNotListStatus: a read-only command cannot say "were not recorded".entryProblemNoFile: an unknown file has no{file}to fall back.entryDuplicate: last-wins, so "falls back to inferred" would be wrong.initDisagrees: fine.
- Init reporting
file-absentonly for recorded-but-absent files matches the contract.
- Inference matches
- P5, CP-7. Bootstrap JSON is identical to main except that the phase-3 step's
warningsarray gains therecord keptline, with nothing on stderr. compile and migrate send warnings to stderr in JSON mode, and stdout stays valid JSON. Bootstrap--format jsonprinting two JSON documents is pre-existing on main. - P7, path separators. Entries come only from the
VENDOR_FILESconstants, andrecordWrittenVendorModesnormalizes to/and filters throughisVendorFile. No backslash can be written. Backslashes appear only in the displayedmanifestPath. - P8, LOC ceilings.
adf_commands_locis 1026 of 1041 andadf_migrate_locis 750 of 792. Evidence passes and no ceilings were raised. - Tests. The full suite on the PR has 5 failures, and the same 5 fail on main on this Windows host. They are bootstrap #307, context-refresh, serve-context and two precommit-hook tests, so they are environmental and pre-existing.
adf-vendor,adf-migrate-register,adf-manifest-registerandvendorsall pass (122 tests).
Non-blocking
- P3, test strength. The strip deletes whatever two-space
-lines follow the VENDORS header. In the INV-5 and "already registered" tests, run 1 creates VENDORS as the last section before run 2 registers. A #348 regression that misroutes a module bullet into the trailing section would therefore be stripped away and pass. Assert the VENDORS block's exact content instead, for exampletoBe(MANIFEST + '\n🏷️ VENDORS:\n - CLAUDE.md: pointer\n'). - P6, noise. After bootstrap, every
adf compile --target all --writewarns four lines (CLAUDE.md is recorded as pointer but adf compile --write wrote it as compiled; record kept. To change it: charter adf vendor set CLAUDE.md compiled, and the same for AGENTS.md, .cursorrules and GEMINI.md). It repeats on every run untilvendor set. The wording gives the exact per-file fix, and PR2 removes the cause. If it stays for a release, consider collapsing it into one line that lists the files. - Text-mode warning channel. compile sends warnings to stderr, but
init --emit-pointersandmigrateuseconsole.log(stdout). INV-9 says stderr in text mode. Using each command's existingwarnconvention is defensible, but say so in the PR body. - Duplicate VENDORS sections whose last one is empty.
@stackbilt/adfparseManifest().vendorsreturns the earlier section's entries, while the CLI'sreadVendorRecordtreats the record as empty. Align them before PR2 consumes the library field. - Comment lines. A comment line inside VENDORS makes the parser treat the section as text, so the
is not a listmessage is misleading there. - Placement. Writers append VENDORS at EOF regardless of canonical order. This follows the #348 precedent, but it can also trip
fmt --check, for example when the manifest ends with a key that sorts after VENDORS. - Headroom.
adf.tshas 15 lines left under its ceiling for five more PRs. - Cosmetic. In bootstrap's VENDORS block, CLAUDE.md comes last (the migrate phase records it).
…ntity (refs #318) Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Round 1 review addressed in 5f58ef3:
🤖 Generated with Claude Code |
…352) adf compile --check reported every deliberate thin pointer as stale forever, and the remedy it printed (compile --write) silently turned the pointer into compiled output; tidy guarded compiled files only by the presence of the banner (#318). Both now read the vendor mode record from #350, falling back to the same marker inference when a file has no entry. --check gains pointer-ok, pointer-bloated, mode-drift and skipped-unmanaged and never suggests --write for a pointer; tidy only ever processes pointers and walks each physical file once. compile --write converts a pointer or unmanaged file only under the new --mode compiled, recording the switch first and reverting it if the write fails, and remedies that could discard content now list the content-preserving path first. Also fixes NTFS file identity (bigint inodes) so two vendor files can no longer collide. BREAKING CHANGE: adf compile --write no longer converts pointer files without --mode compiled. Use `charter adf compile --target all --write --mode compiled`, or `charter adf vendor set <file> compiled`. Closes #318 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs #318
PR 1 of 6 from the #318 blueprint. It adds a record of each vendor file's mode, the API to read it, and
charter adf vendor status|set|init. No command acts on the record yet.What it adds
.ai/manifest.adfcan carry a🏷️ VENDORS:list of<file>: <pointer|compiled|unmanaged>items.parseManifestgains a permissivevendors: {raw, file, mode}[]field that never throws.VENDORSgets a decoration, sorts afterSYNCinCANONICAL_KEY_ORDER, and is added toMANIFEST_PLUMBING_KEYS.packages/cli/src/commands/adf-vendor.ts):inferVendorModeworks the wayadf tidyclassifies files: banner first, thenPOINTER_MARKERS, elseunmanaged. A pointer-only name is nevercompiled.resolveVendorMode(s)returns{mode, source: recorded|inferred, evidence, disagrees}.malformed,unknown-file,mode-not-allowedandduplicate. For duplicates, the last valid entry wins.recordVendorModes(manifestPath, entries, 'add-if-absent'|'upsert')uses the adf migrate: new modules not registered in manifest or CLAUDE.md module index #239 text-level helpers inadf-manifest-register.ts:insertManifestBulletnow takes the section key and decoration.replaceManifestBulletdoes the one-line upsert.ALLOWED_MODESis checked on every path.charter adf vendor status [--all],set <file> <mode> [--dry-run]andinit [--dry-run], all with--ai-dirand--format json. Exit codes follow the contract:statusalways exits 0.setexits 1 for a mode that is not allowed or a skipped write. It exits 2 for usage errors, an unknown file or mode, or a missing manifest.initexits 2 for a missing manifest, and 1 for any skip other than already-recorded or file-absent.--dry-run:bootstrap's pointer phase recordspointer. Under CP-7, its warnings go into the phase-3 step'swarnings.adf init --emit-pointersrecordspointer.adf migraterecordspointerafter the pointer is written.adf compile --writerecordscompiled.What is NOT changed yet (later PRs in the series)
compile --checkstill compares bytes.compile --write, tidy, bootstrap and migrate skip logic, doctor, score, context, sync and both pre-commit hooks still decide from the markers in each file.--modeflag. Nocharter:modesentinel, so the pointer template bytes are unchanged.--source, retained-section preservation (adf compile: preserve retained sections instead of only refusing on them #303) oragents.mdrename (AGENTS.md migration gaps for repos bootstrapped before #297 #302).vendor init.Because implicit writers are add-if-absent,
compile --writeover a file bootstrap recorded aspointerkeeps the record and warns.vendor statusthen shows(recorded; file looks compiled). PR2 makes that flip need--mode compiled.Invariants and where they are tested
adf-vendor.test.ts› "consumers ignore the record". It covers compile--check/--write/stdout, tidy and doctor. Each runs in two repos that differ only by a VENDORS section, and the stdout, filtered stderr, exit codes and resulting vendor bytes must be identical. The precommit-hook and hook parity tests are unchanged.recordVendorModestests. They cover insert, a new section at EOF, CRLF, no trailing newline, the one-line upsert, this repo's own manifest fixture, the lone-CR guard refusal, and re-parse equality.statusleaves bytes and mtime unchanged, and compile--checkand stdout leave the manifest unchanged.packages/adfvendors.test.tschecks every target, including a module that declares VENDORS. There is also a CLI stdout check.adf tidy --dry-run --format jsonas the oracle. The cases are banner, each pointer template, banner plus a quoted marker, hand-written, and absent.ALLOWED_MODESon every path: writer tests for both policies and with the manifest missing, plusvendor set copilot-instructions.md compiledexiting 1.--emit-pointers, compile, migrate (--dry-runversus real) and bootstrap.--writeJSON is identical with a broken VENDORS section, and the bootstrap warning lands in the step'swarnings.--ai-dir: tested for bothsetandstatus.adf-manifest-register.test.tsis untouched and passes, andinsertManifestBulletstill gives DEFAULT_LOAD and ON_DEMAND their default decorations.vendors.test.ts).adf-migrate-register.test.tshad byte-equality assertions on the manifest after migrate or bootstrap. They now compare with the VENDORS block removed, which is the exception INV-1 allows. The missing-manifest case now expects the extravendor modes cannot be recordedwarning.LOC:
adf.tsis at 1026 of 1041 andadf-migrate.tsat 750 of 792. No ceilings were raised.Implemented via constellation-loop against a locked blueprint.
🤖 Generated with Claude Code