Skip to content

fix(#1100): finish #1071 — keep JSONC comments on the run.agent update, test the blank-file branch, drop two non-discriminating assertions - #1102

Merged
admarble merged 4 commits into
mainfrom
feature/1100-chore-init-finish-1071-keep-jsonc-comments-on-the-
Sep 19, 2026
Merged

admarble merged 4 commits into
mainfrom
feature/1100-chore-init-finish-1071-keep-jsonc-comments-on-the-

Conversation

@admarble

@admarble admarble commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

AC Verification

AC Description Status Evidence
AC-1 init --agent codex over existing JSONC preserves comments, records run.agent ✅ Implemented 1100 AC-1 test passes; mutation-verified below
AC-2 Update touches only the run.agent line ✅ Implemented 1100 AC-2 test passes (LCS-based line diff = 1 changed/inserted line)
AC-3 Blank settings file gets defaults + recorded agent, action created ✅ Implemented 1100 AC-3 test passes; mutation-verified below
AC-4 Two non-discriminating onDisk assertions removed ✅ Implemented sed -n '960,975p' src/commands/init.test.ts | grep -c "onDisk" prints 0
AC-5 Written file round-trips through settings loader ✅ Implemented Covered by the AC-1 case (strip + JSON.parse yields run.agent === "codex", run.timeout === 5400)
AC-6 Manual e2e repro prints the preserved-comments result ✅ Implemented See output below

Manual end-to-end repro (AC-6)

RESULT: COMMENTS PRESERVED (25 comment lines before and after, agent recorded)

Mutation verification

Mutation-verified: AC-1 — reverted the write to JSON.stringify(merged, null, 2); 1100 AC-1: preserves JSONC comments on the run.agent update failed; restored.

Mutation-verified: AC-3 — deleted the !content.trim() blank-file branch; 1100 AC-3: a blank settings file gets defaults with run.agent set, action created failed; restored.

Test plan

  • npx vitest run src/commands/init.test.ts -t "1100" — 3 passed
  • npx vitest run src/commands/init.test.ts — 49 passed (full file, no regressions)
  • npm run build — passes
  • npm run lint — passes
  • Manual e2e repro — comments preserved (see AC-6 output above)
  • Mutation verification for AC-1 and AC-3 (see above)
  • Full suite deferred per runner note (resumed after a 30-min-wall kill) — runner runs it once before merge.

Closes #1100

Runner fix after the second AC_NOT_MET (82574ea, 2026-09-19)

QA twice reproduced three run-block shapes for which updateAgentInRawContent wrote a file stripJsoncComments + JSON.parse rejects, and the second exec pass made no commit against that finding, so the runner applied the fix directly:

  • run and agent are located by a string- and comment-aware scan at the correct object depth (findValueStartOfKey), replacing the bare regexes. A // comment quoting "run": {, a string value equal to the key, or a nested object with a run key can no longer capture the edit.
  • The insert path emits no trailing comma when the block has no members (comments are not members); an empty "run": {} is edited on its one line so AC-2's single-changed-line property holds.
  • The 1100 AC-1 case now strips via the exported stripJsoncComments, as AC-5's evidence clause states, and four new 1100 AC-5 cases cover the empty, whitespace-only, comment-only and comment-quoting shapes, each asserting the written content re-parses and that exactly one line changed.

End-to-end against this worktree's dist/bin/cli.js, init --agent codex --yes over each shape, then the written file through the loader's comment stripper + JSON.parse:

Input Result
empty "run": {} PARSE OK, run.agent = codex
whitespace-only "run": { } PARSE OK, run.agent = codex
comment-only run block PARSE OK, run.agent = codex
// comment quoting "run": { before the real block PARSE OK, run.agent = codex, comment line untouched

npx vitest run src/commands/init.test.ts -t "1100" → Tests 7 passed; whole file 53 passed; npm run build and npm run lint --max-warnings 0 clean.

Full suite — runner result (2026-09-19, 82574eae)

Run once in this worktree, foreground, from a shell with no SEQUANT_* variables: Test Files 321 passed (321), Tests 6515 passed | 1 expected fail | 3 skipped, 349s, exit 0. The 8 failures QA saw earlier were the SEQUANT_* env-leak class (#1086) from running under the orchestrator, not this diff.

…omment-only run blocks

QA reproduced three inputs for which updateAgentInRawContent wrote a file the settings loader rejects: an empty run block, a whitespace-only run block and a comment-only run block all got a trailing comma after the inserted agent line, and a // comment quoting "run": { could capture the bare-regex key lookup. The run and agent keys are now located by a string- and comment-aware scan at the right object depth, the insert path omits the comma when the block has no members, and an empty block is edited on its one line. The AC-1 case now strips via the exported stripJsoncComments as AC-5's evidence clause states, and the four shapes are cases of their own.

Entire-Checkpoint: e434964affc8
@admarble admarble changed the title fix(#1100): preserve JSONC comments on the run.agent update fix(#1100): finish #1071 — keep JSONC comments on the run.agent update, test the blank-file branch, drop two non-discriminating assertions Sep 19, 2026
@admarble
admarble merged commit 006b141 into main Sep 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(init): finish #1071 — keep JSONC comments on the run.agent update, test the blank-file branch, drop two non-discriminating assertions

1 participant