fix(cli): cli-3.15.0 — idempotent injection + host marker-health validation#162
Merged
Conversation
…dation Fixes the duplicated `<!-- straymark:end -->` accumulation in `.cursorrules` and other host files. Root cause: STRAYMARK.md's own marker-convention docs contain the literal marker strings inside a fenced code block, so the old `find(MARKER_END)` stopped at the in-docs literal and dropped the real END outside the canonical block as an orphan on every update-framework run. - `find_canonical_block` switches to first-BEGIN/last-END (`rfind`) so the canonical span survives marker literals embedded in the payload - `sanitize_orphan_markers` auto-repairs files with orphan markers or pathological double-block corruption on the next re-injection - `inject::MarkerHealth` + `inject::inspect_marker_health` diagnostic API - `straymark validate` emits `host-marker-health` warnings for malformed host files (rule walks `manifest.injections`) - 10 new tests in `inject.rs::tests` cover orphan-end-before-begin, two complete blocks, orphan-begin-no-end, idempotency, end-to-end repair, healthy-with-marker-literals-in-embed, and Sentinel-style extra END - `doc_count == 0` no longer suppresses host-marker warnings Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
<!-- straymark:end -->accumulation in.cursorrules(and other host files) reported in Sentinel afterstraymark update-framework. Root cause:STRAYMARK.mddocuments the marker convention by embedding the literal strings<!-- straymark:begin -->and<!-- straymark:end -->inside a fenced code block; the oldreplace_between_markerscalledfind(MARKER_END)and stopped at that in-docs literal, truncating the canonical block mid-embed and dropping the real END as an orphan one extraendmarker per update.inject::find_canonical_blockswitches to first-BEGIN/last-END semantics (rfind(MARKER_END)) so the canonical span survives marker literals embedded in the payload.inject_directivenow auto-sanitizes orphan markers and pathological double-block corruption on the next re-injection via a newsanitize_orphan_markershelper.inject::MarkerHealth+inject::inspect_marker_healthand a newhost-marker-healthrule tostraymark validatethat walksmanifest.injectionsand warns about malformed host files before the operator re-runs an update.Why minor (3.15.0)
validategains a new observable signal (host-marker-healthwarnings), so per the project convention this is a minor bump rather than a patch.Test plan
cargo test— 320 unit tests + 21 integration binaries pass (10 new tests cover Sentinel reproductions: orphan-end-before-begin, two complete blocks, orphan-begin-no-end, idempotency, end-to-end.cursorrulesrepair via the public API, healthy-with-marker-literals-in-embed).straymark init, corrupt.cursorrulesby appending an extra<!-- straymark:end -->, runstraymark validate→ warns underhost-marker-health(2 begin / 3 end marker(s)); runstraymark update-framework(with the local checksums version downgraded to force the update path) → file restored to a single canonical pair;straymark validateafterwards is clean.update-frameworkruns produce byte-identical.cursorrules(diffexit 0)..cursorrules(which contains 2 BEGINS and 2 ENDS because STRAYMARK.md describes the markers in its own docs) is not flagged as malformed.cli-3.15.0(no framework bump;fw-4.17.0stays current).Adopter guidance
Run
straymark update-cliafter release to installcli-3.15.0. The nextstraymark update-frameworkauto-repairs any host file that drifted into a malformed-marker state. Adopters who want a heads-up before re-running the update can callstraymark validatenow; malformed host files appear under thehost-marker-healthrule.🤖 Generated with Claude Code