Skip to content

refactor(setup-apply): read convention files with yaml-subset.mjs instead of awk - #11248

Merged
kyle-sexton merged 7 commits into
mainfrom
host-run/10131-setup-apply-yaml-subset
Oct 30, 2026
Merged

kyle-sexton merged 7 commits into
mainfrom
host-run/10131-setup-apply-yaml-subset

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Closes #10131

Summary

lib/setup-apply.mjs now reads convention files in process through lib/yaml-subset.mjs instead of spawning yaml-subset.awk. This is part 4 of 4 of #8677. Parts 1 to 3 (#10128, #10129, #10130) made the two grammars match and pinned the leaf display this switch must keep.

Fix

  • lib/yaml-subset.mjs: new parse(text, { source: true }). It uses the same grammar, but every scalar comes back as its source text, the way yaml-subset.awk prints it (1.0, 075, True, ~ and 9007199254740993 kept as written, quotes removed, \n kept as written). Mappings come back as Maps in document order. A key that cannot sit in a dotted record path (empty, holding . or a tab) is refused, as awk refuses it. Default parse() is unchanged for its existing callers.
  • lib/setup-apply.mjs: flatten(text) walks that tree into the same { path, top, nested, value } records awk produced. validate() and run() no longer take a parser.
  • scripts/shared-copies.txt: 8 new lines copy yaml-subset.mjs into the lib/ of each plugin that carries setup-apply.mjs (discipline, discovery, docs-hygiene, education, planning, review, session-flow, verification). The copies come from scripts/sync-shared-copies.sh. The 4 existing yaml-subset.mjs copies were regenerated too.
  • The 8 skills/setup/scripts/setup-apply.mjs entry points no longer pass parser:. Their comments now name only the reader.
  • New lib/yaml-subset-parity.test.mjs, with a .test.sh wrapper. It runs flatten() and yaml-subset.awk over 20 accepted and 26 rejected block-style fixtures. For each fixture it asserts the same verdict, the same error line on a refusal, and identical path<TAB>value records when both accept.
  • Test expectations: parse errors now use yaml-subset.mjs wording, so 13 assertions across lib/setup-apply.test.sh and the discipline, planning, review, session-flow and verification suites now expect the new message. For example, duplicate key `a` (first at line 1) became line 2: duplicate key "a". The session-flow symlink-swap race test hooked the awk spawn, which no longer happens. It now swaps docs/ for a symlink right after the run creates it, as the planning suite does. Deleting the in-loop checkFile in writeFile makes it fail, on this branch and on the base.
  • 12 changelog fragments, one per carrying plugin.

Verification

  • bash lib/yaml-subset-parity.test.sh: 46 of 46 pass.
  • node --test lib/yaml-subset.test.mjs: 48 of 48 pass (default mode unchanged).
  • bash lib/setup-apply.test.sh: 537 of 537. The 8 plugin setup-apply.test.sh suites all pass (review 384, verification 615, the others report all passed).
  • Each of the 8 entry points was run with --check on this repository before and after the change, and the output was byte-identical.
  • scripts/sync-shared-copies.sh --check: all 545 copies match. --check-bump origin/main passes, and so does scripts/check-changelog-fragments.sh --check.
  • scripts/check-affected.sh --tests on the committed head: 14 passed, 2 skipped (ruff: no Python changed; tests: left to CI lanes). Then the selected suites ran directly: affected-tests.sh --run passed all 64 shell suites, node --test over the 59 selected Node suites passed 4557 tests with 0 failures, and the code-metrics yaml-subset Python suites pass.

Left out: the babysit-prs Python suites the selector picked (no pytest on this host; the change does not touch their code), left to CI.

Related

Refs: #8677

🤖 Generated with Claude Code

kyle-sexton and others added 3 commits October 30, 2026 07:51
…tead of awk

lib/setup-apply.mjs now builds its records in process from
yaml-subset.mjs, whose new source option keeps each scalar's source text
and mapping order the way yaml-subset.awk prints them. The 8 setup entry
points stop passing parser:, and scripts/shared-copies.txt copies
yaml-subset.mjs into each plugin's lib/ beside setup-apply.mjs. A parity
test runs the adapter and yaml-subset.awk over block-style fixtures and
asserts the same verdict, the same error line, and the same records.

Closes #10131

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 30, 2026 11:59
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T12:02:42.792332Z fc6cf2d Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed ca1a750f0fb131ca212af38f3394f87ca9233c1b: 0 finding(s), 0 as inline comments.

No security issues found in the incremental change (ca1a750).

What changed: splitKey in lib/yaml-subset.mjs and its 12 per-plugin copies had two checks swapped. In source mode, a plain key outside [A-Za-z0-9_-] now returns null before the "plain key may not hold a space, $ or ." error can fire. lib/yaml-subset-parity.test.mjs gains three accepted cases for sequence items such as - Steps to run:, - a.b: and - $x:.

Why this isn't a finding:

  • The change only narrows when a parse error is thrown, bringing the JS parser in line with awk's behaviour. It adds no new input path, code execution, or file, network or credential access.
  • I read the diff and did not open the full awk reader or the consumers of the parsed output. So I did not check whether any consumer reads these files for a trust decision, such as docs/conventions/pr-pipeline.yaml, which would make a parse difference between awk and JS matter.
  • None of the changed files is a trust control. The only trusted-path match is .claude-lane/**, which is untracked and not part of this diff.
  • The 12 plugin copies are identical to each other and to lib/yaml-subset.mjs. The parity test exists to keep them that way.
  • No manifest, workflow, token-scope, kill-switch, merge-hold or instruction-surface file is touched.
  • No settled-threads file was supplied for this review.

critical-findings: 0

…creates it

The race hook fired on the awk spawn, which setup-apply no longer makes.
Moved to the bash spawn it fired before the target read, so the in-loop
path check was no longer exercised. It now swaps on the mkdir of docs/,
as the planning suite does; removing that check fails the test again.

Refs: #10131

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@github-actions github-actions Bot 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.

claude-review: 1 inline finding(s) on fc6cf2dd793d160e42eeea897d09b085c7f6b956; the summary is in this lane's pull request comment.

claude-lane: claude-review

Comment thread lib/setup-apply.mjs Resolved
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed ca1a750f0fb131ca212af38f3394f87ca9233c1b: 0 finding(s), 0 as inline comments.

Incremental review of ca1a750 since 12abe29 found nothing to flag.

What changed: In splitKey, the source-mode "awk reads no other plain key" return-null check now runs before the throw for a plain key holding a space, $ or .. The same edit is in lib/yaml-subset.mjs and in the 13 plugin copies, and the parity test gains three accepted cases.

What I checked by reading the code (I ran no tests):

  • - Steps to run:, - a.b: and - $x: in source mode now return null from splitKey, so the sequence item becomes a scalar. In lib/yaml-subset.awk, keyat matches ^[A-Za-z0-9_-]+ and then needs [ \t]*:, so these items fail the key match and value() emits them as scalars. The two parsers agree.
  • - a b: c is still rejected in both. The JS scalar() throws on : at lib/yaml-subset.mjs:105, and awk fails the same way at lib/yaml-subset.awk:184.
  • a b: c, $schema: x and a.b: c at mapping level in source mode now return null from splitKey and throw "expected a mapping entry" (from block() at line 233 or mapping() at line 245). The reject cases at lib/yaml-subset-parity.test.mjs:55-57 still expect rejection, and awk errors on the same line with "expected key: value".
  • Non-source mode still throws the "quote it" error, so the strict parse is unchanged.
  • The 13 plugin copies carry the same hunk as lib/yaml-subset.mjs.

No userConfig or manifest items are hit. There is no spend to report and no hold.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc6cf2dd79

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/yaml-subset.mjs Resolved
Comment thread lib/yaml-subset.mjs Resolved
kyle-sexton and others added 2 commits October 30, 2026 08:14
check-cross-plugin-source-drift.sh failed check-plugins because the eight
plugins/*/lib/yaml-subset.mjs copies were unregistered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Source mode now rejects text after a quoted value, a root sequence, a
sequence nested on one line and a plain key outside [A-Za-z0-9_-], and
accepts blanks before a quoted key's colon, as lib/yaml-subset.awk does.
Default mode keeps the yaml_subset.py grammar. Ten parity fixtures cover
the cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton kyle-sexton removed the do-not-merge Hard merge gate: do not merge while applied. label Oct 30, 2026

@github-actions github-actions Bot 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.

claude-review: 1 inline finding(s) on 12abe29c77181e93ba35355e87e4e8b0546efe14; the summary is in this lane's pull request comment.

claude-lane: claude-review

Comment thread lib/yaml-subset.mjs Resolved
… scalar through

splitKey threw on a would-be plain key holding a space, `$` or `.` before
source mode could return null, so `- Steps to run:` errored where
lib/yaml-subset.awk emits the scalar. The source-mode check now runs first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit 847f0f6 Oct 30, 2026
50 checks passed
@kyle-sexton
kyle-sexton deleted the host-run/10131-setup-apply-yaml-subset branch October 30, 2026 12:34
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.

Converge the awk and mjs YAML grammars before setup-apply uses yaml-subset.mjs - part 4 of 4

1 participant