refactor(install): merge-safe doctrine distribution (single marker-spliced block)#14
Merged
Merged
Conversation
…Doctrine Replace the present-with-sentinel skip path with an in-place block splice: absent -> append below user content; present -> replace between markers, preserving everything outside. Splice safety: LF-normalized canonical body (no perpetual diff), newline style taken from the destination file, abort without writing on ambiguous (>1 begin/end) or corrupt (begin without end) markers. Idempotent: identical doctrine is a no-op. Makes install.cjs the single merge source of truth so a synced repo refreshes doctrine without clobbering user-owned AGENTS.md content. Tests 14-18.
…tem clobber sync-maestro.ps1 no longer overwrites whole AGENTS.md files. It now invokes `node scripts/install.cjs --project <repo> --doctrine-only` per downstream repo, making the marker-splice the single merge path: stale doctrine is refreshed in place while user content outside the block survives. Adds a --doctrine-only mode to install.cjs (splices AGENTS.md only — no engine/adapter/wrapper/skills) and a -ListFile param to the sync for testability. Tests: install test 19 (--doctrine-only splices AGENTS.md, writes nothing else, idempotent); new sync-maestro smoke (real PowerShell: dry-run writes nothing, content outside the block survives a sync, re-run byte-idempotent, missing dir non-fatal; skips if no PowerShell on PATH).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Maestro had two doctrine-distribution channels that disagreed, and neither let a user own their repo
AGENTS.md:install.cjspreserved user content but, once its marker block was present, never refreshed it (skip-forever staleness).sync-maestro.ps1usedCopy-Item -Force, clobbering the whole file — stripping the markers and any user content on every sync.Change
Make
scripts/install.cjsthe single merge source of truth, and route the sync through it.appendOnlyDoctrinenow block-REPLACES in place. Absent block -> appended below existing user content; present block -> replaced between the<!-- maestro:begin -->/<!-- maestro:end -->markers, preserving everything outside. Idempotent: identical doctrine is a no-op.sync-maestro.ps1no longer overwrites files. It invokesnode scripts/install.cjs --project <repo> --doctrine-onlyper downstream repo, so the marker-splice is the one merge path. Added--doctrine-only(splicesAGENTS.mdonly -- no engine/adapter/wrapper/skills) and a-ListFileparam for testability.Audit findings addressed
-->does not break matching.Tests
install.test.cjstests 14-18 (block-replace, idempotency, abort-on-ambiguous, abort-on-corrupt, CRLF) and 19 (--doctrine-onlysplicesAGENTS.mdand writes nothing else).sync-maestro.test.cjssmoke (real PowerShell): dry-run writes nothing, content outside the block survives a sync, re-run is byte-idempotent, missing downstream dir is non-fatal. Skips gracefully if no PowerShell is on PATH.npm test(all suites),bench-verify,compress.test, and markdownlint all green locally.A fresh-context Staff-Engineer review and an independent success verifier both returned PASS against the requirements and audit findings above.
Note: installer and doctrine are harness surfaces; this PR touches distribution logic and its tests.