Skip to content

fix(#279): replace existing version marker instead of appending - #280

Merged
yvonnedevlinrh merged 8 commits into
mainfrom
agent/279-fix-duplicate-marker
Oct 27, 2026
Merged

yvonnedevlinrh merged 8 commits into
mainfrom
agent/279-fix-duplicate-marker

Conversation

@fullsend-ai-coder

@fullsend-ai-coder fullsend-ai-coder Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • insertMarkerAfterFrontmatter unconditionally inserted a new <!-- scaffolded by gaze ... --> marker without checking for an existing one, causing duplicate markers when gaze init ran again with a different version
  • Added removeExistingMarker helper that strips existing marker lines before insertion, making the function idempotent
  • Removed the stale hardcoded v1.8.0 marker from all seven scaffold assets (root-cause provenance data), mirrored to .opencode/ and the aireport embedded prompt copy
  • Excluded internal/scaffold/assets/ and internal/aireport/assets/ from markdownlint (.mega-linter.yml): embedded copies are byte-identical mirrors of .opencode/ sources and must never be reformatted independently — the linter had drifted three pairs, breaking TestEmbeddedAssetsMatchSource
  • Added regression tests: unit tests for removeExistingMarker, table-driven tests for marker replacement scenarios, and end-to-end re-scaffold tests (force and non-force)
    • internal/crap/report.go: whitespace-only gofmt tag alignment from the org MegaLinter auto-commit (semantic no-op; documented in the OpenSpec proposal)

Testing

  • go test -race -count=1 -short ./... passes
  • go vet ./... passes
  • golangci-lint run passes
  • New tests cover: single marker replacement, duplicate marker removal, no-frontmatter files, preserving non-marker HTML comments, and full end-to-end re-scaffold scenarios

Closes #279

Post-script verification

  • Branch is not main/master (agent/279-fix-duplicate-marker)
  • Secret scan passed (gitleaks — 60758771eefb203b1d610d6032a85ec83fbca8fd..HEAD)
  • PR body secret scan passed (gitleaks — no-git)

@fullsend-ai-coder fullsend-ai-coder Bot added the ready-for-review Triggers review agent dispatch label Sep 23, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 8:32 PM UTC · Completed 8:44 PM UTC

Commit: af26c54 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $5.06

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

✅⚠️MegaLinter analysis: Success with warnings

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ GO golangci-lint yes yes no no 35.68s
⚠️ MARKDOWN markdownlint 4 0 3 0 1.47s
✅ REPOSITORY gitleaks yes no no 4.25s
✅ REPOSITORY git_diff yes no no 0.36s
✅ YAML yamllint 1 0 0 0.8s

Detailed Issues

⚠️ MARKDOWN / markdownlint - 3 errors
openspec/changes/fix-duplicate-scaffold-marker/design.md:1 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "## Context"]
openspec/changes/fix-duplicate-scaffold-marker/proposal.md:1 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "## Why"]
openspec/changes/fix-duplicate-scaffold-marker/tasks.md:6 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "## 1. Idempotent Marker Insert..."]

See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

@fullsend-ai-review fullsend-ai-review Bot added the risk/low PR risk: low label Sep 23, 2026
@fullsend-ai-review

Copy link
Copy Markdown

Risk Assessment: low (1/5)

Details

Minimal-risk bug fix: 2 files changed (176 lines, half tests), bot author, no protected paths, no security-sensitive files, no CI or dependency changes. Excellent test ratio (0.50). Linked issue is well-scoped with clear repro steps. Rollback is trivial.

@fullsend-ai-review

Copy link
Copy Markdown

Looks good to me

@fullsend-ai-review fullsend-ai-review Bot added the ready-for-merge All reviewers approved — ready to merge label Sep 23, 2026
@jflowers jflowers removed their assignment Oct 1, 2026
insertMarkerAfterFrontmatter unconditionally inserted a new
<!-- scaffolded by gaze ... --> marker without checking for an
existing one. When gaze init ran again with a different version,
both markers ended up in the file.

Added removeExistingMarker helper that strips any existing
"<!-- scaffolded by gaze ... -->" lines before inserting the
new marker, making the function idempotent. Added unit tests
for removeExistingMarker, table-driven regression tests for
marker replacement scenarios (single, duplicate, no-frontmatter),
and an end-to-end TestRun_ReScaffoldSingleMarker that runs
gaze init twice with different versions and asserts exactly one
marker per file.

Closes #279
@yvonnedevlinrh
yvonnedevlinrh force-pushed the agent/279-fix-duplicate-marker branch from af26c54 to 73196a7 Compare October 23, 2026 08:29
yvonnedevlinrh and others added 7 commits October 23, 2026 11:56
The embedded assets still contained hardcoded
"<!-- scaffolded by gaze v1.8.0 -->" lines — root-cause data from
#279. The insertMarkerAfterFrontmatter fix strips these lines at
scaffold time, so they are inert at runtime, but they remain
misleading provenance in source: assets claim v1.8.0 regardless of
the actual build version.

Removed from all seven scaffold assets, mirrored to .opencode/
(TestEmbeddedAssetsMatchSource), and applied to the aireport
embedded prompt copy (TestEmbeddedPromptMatchesScaffold). Scaffold
output is byte-identical since the lines were already stripped at
scaffold time.

Assisted-by: Qwen3.8-27B-FP8
TestRun_ReScaffoldNonForceSingleMarker covers the non-force re-init
path from the issue repro: a second gaze init without --force
updates tool-owned files on diff (replacing the old marker) and
leaves user-owned files untouched, asserting exactly one marker in
both cases.

Assisted-by: Qwen3.8-27B-FP8
The MegaLinter auto-commit added 43 blank lines to the internal/
copies of three scaffold assets and the aireport prompt copy.
Because .opencode/ is in the exclude regex while internal/ is
linted, the byte-identical pairs drifted and
TestEmbeddedAssetsMatchSource failed on the PR head.

Embedded copies are generated mirrors of the .opencode/ source of
truth (AGENTS.md File Sync Invariants). Linting only one side of a
byte-identical pair means any future markdownlint rule change
would re-break the invariant, so:

- Add internal/scaffold/assets/ and internal/aireport/assets/ to
  MARKDOWN_MARKDOWNLINT_FILTER_REGEX_EXCLUDE in .mega-linter.yml
- Revert the 43 linter-added blank lines to restore byte-identity

TestEmbeddedAssetsMatchSource and
TestEmbeddedPromptMatchesScaffold pass; full short suite green
under -race -count=1.

Addresses review findings on PR #280.

Assisted-by: Qwen3.8-27B-FP8
Signed-off-by: Yvonne Devlin <[email protected]>
PR #280 modified production code and embedded assets without a spec
artifact (spec-first requirement). Record the change retroactively:
idempotent marker insertion, stale v1.8.0 marker removal, and the
embedded-asset markdownlint exclusion.

Assisted-by: Qwen3.8-27B-FP8
Signed-off-by: Yvonne Devlin <[email protected]>
The AGENTS.md Recent Changes entry for fix-duplicate-scaffold-marker claims "4 new test functions (19 subtests)", but the branch ships 4 test functions with 9 subtests (4 + 5 table-driven; the two e2e re-scaffold tests use no t.Run subtests).
Corrects the count to 9 so the changelog matches the shipped tests.

@yvonnedevlinrh yvonnedevlinrh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yvonnedevlinrh
yvonnedevlinrh merged commit 8bdfb59 into main Oct 27, 2026
6 checks passed
@yvonnedevlinrh
yvonnedevlinrh deleted the agent/279-fix-duplicate-marker branch October 27, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-merge All reviewers approved — ready to merge ready-for-review Triggers review agent dispatch risk/low PR risk: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gaze init appends a second version marker instead of replacing the existing one

2 participants