fix(cli): R10 — resolver respects HTML comment bounds (issue #102)#103
Merged
fix(cli): R10 — resolver respects HTML comment bounds (issue #102)#103
Conversation
Sentinel reported in issue #102 that running `devtrail charter audit CHARTER-07 --prepare` produced an `auditor-primary.prompt.md` of 1300 lines (vs ~700 expected) because the global `String::replace` in the template resolver expanded `{{placeholder}}` occurrences inside the template's HTML documentation header — duplicating ~30k tokens of payload (Charter content + AILOG + git diff) once inside the comment block and once in the prompt body proper. Fix in cli/src/commands/charter/audit.rs (`resolve_audit_template`): scan for `<!-- ... -->` ranges before replacement and process the template as alternating segments — non-comment segments get the existing global-replace treatment, comment segments are appended verbatim. Unclosed comments terminate the scan early and treat the tail as comment-region (conservative, mirrors typical markdown rendering). Tests: - 5 new unit tests in audit.rs covering: placeholder inside single HTML comment, multi-placeholder documentation header (the exact R10 trigger), multiple comment blocks in one template, unclosed comment graceful handling, and backwards-compatibility check that a comment-free template still behaves like global replace. - Updated audit_prepare_writes_resolved_prompts integration test in charter_audit_test.rs: replaces the previous assertions that required `{{charter_id}}` and `{{git_diff}}` to be entirely absent from the resolved prompt with assertions that distinguish header (preserved literal) from body (replaced) — matching the corrected behavior and explicitly exercising the R10 fix end-to-end. Test plan: - cargo test → 276 unit + 11 charter_audit + all integration green - cargo build → 2.84s - No version bump (lands together with PR 2-8 in the integrated v1 release per Propuesta/devtrail-audit-cli-flow.md v0.2 §5) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 5, 2026
montfort
added a commit
that referenced
this pull request
May 5, 2026
Closes the integrated v1 audit-skills iteration described in Propuesta/devtrail-audit-cli-flow.md v0.2. Tags the previously- merged PRs (#103-#109) into a coherent shipped release. Bumps: - cli/Cargo.toml: 3.9.0 → 3.10.0 (minor — new --prepare and --merge-reports flags, canonical path migration, deprecation shims for --calibrate / --finalize, R10 + R11(A) fixes; v0 schemas evolve in place per their experimental $comment). - dist/dist-manifest.yml: 4.8.0 → 4.9.0 (minor — new devtrail-audit-execute skill, unified prompt template replacing 3 v0 templates, AGENT-RULES §12 wording aligned to 3-skill sequence). Version refs updated in 22 docs (README + adopter docs + governance footers, all 3 langs). CHANGELOG.md gains a combined Framework 4.9.0 / CLI 3.10.0 section with Added (Framework, CLI), Changed, Removed, Fixed (R10), Deprecated (--calibrate, --finalize), BREAKING (deliberate within experimental v0.x — paths migration), Tests, and explicit Credit to José Villaseñor Montfort for the audit skills lifted from Sentinel via issue #102. Test plan: - cargo test → all suites green (276 unit + 17 charter_audit + 12 audit_skill + 9 audit_template + 4 checkpoint_guidance + all others). - cargo check → version bumps propagate to Cargo.lock cleanly. 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
First of 8 PRs implementing the integrated v1 audit-skills iteration described in
Propuesta/devtrail-audit-cli-flow.mdv0.2. Closes R10 of issue #102 — the resolver duplicated content by ignoring HTML comment boundaries.What was wrong
auditor-primary.mdtemplate had a documentation header (lines 1-32) listing each placeholder with literal{{placeholder}} — descriptionsyntax for human reference. The resolver's globalString::replaceexpanded those documentation lines, inflating ~32 lines into ~605 and duplicating ~30k tokens of payload (Charter content + AILOG + git diff) once inside the comment and once in the body proper. Sentinel observed a 1300-line resolved prompt where ~700 was expected.What changed
In
cli/src/commands/charter/audit.rsresolve_audit_template:<!-- ... -->ranges before replacement.-->) terminate the scan early and the tail is treated as comment-region (conservative, mirrors typical markdown rendering).The fix is internal to the resolver and does not change the template format or the schema. Templates that don't use HTML comments behave identically to before.
Tests
audit.rscovering: placeholder inside single HTML comment, multi-placeholder documentation header (the exact R10 trigger), multiple comment blocks, unclosed comment graceful handling, comment-free template backwards-compat.audit_prepare_writes_resolved_prompts): replaces the previous "no{{...}}anywhere" assertions with header-vs-body distinction. Explicitly verifies that{{charter_id}}and{{git_diff}}are preserved in the documentation header but replaced in the body, and thatREAL_CHARTER_BODY/REAL_DIFFappear exactly once (the R10 dedup invariant).Test plan
cargo test→ 276 unit + 11 charter_audit (5 R10 new) + all integration suites greencargo build→ 2.84sPhase v1 progress
git_rangedefault →origin/main..HEADwith fallbackaudit-prompt.mdtemplate based on Sentinel skill--prepare/--merge-reports) + canonical paths.devtrail/audits/devtrail-audit-execute(3 platforms)audit-promptandaudit-reviewskills (review.md consolidated)fw-4.9.0/cli-3.10.0+ CHANGELOG + tag release🤖 Generated with Claude Code