Skip to content

refactor(lib): simplify check-retirements, config-cascade and confirm-verdict shared libs - #15412

Merged
kyle-sexton merged 4 commits into
mainfrom
refactor/simplify-config-libs
Nov 11, 2026
Merged

kyle-sexton merged 4 commits into
mainfrom
refactor/simplify-config-libs

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #14327

Summary

Simplifies three of #14327's six shared lib sources without changing their behavior: lib/check-retirements.sh, lib/config-cascade.mjs and lib/confirm-verdict.sh. The other three are unchanged:

  • lib/config-root.sh: a simplification nets about zero lines while touching its 33 copies and about 19 fragments.
  • lib/check-convention-facts.mjs: already minimal; its read-all-then-print order is part of its behavior.
  • lib/context-zone.fixtures.mjs: test data that two resolvers share.

Built by hand rather than by the issue lane: the lane's patch was refused at the 262144-byte scan cap because these sources have regenerated copies under plugins/ (config-cascade.mjs about 20, check-retirements.sh 8). The hand build was agreed with the hub session.

session: Simplify Planning

Fix

  • 167 hand-changed lines in 3 source files (cap 400 lines, 15 files), one commit per source file.
  • check-retirements.sh: record errors go through one bad_record/invalid helper, the blank and comment skips are one test, and if/die blocks are cmd || die. Bash 3.2-safe; printed text byte-identical.
  • config-cascade.mjs: resolve and readLayers share the plugin check, home and stem setup, the escaped-home layer and the error-prefix recorder. fileState's repo flag, which was never false, and the branch it guarded are gone; hasConfigBlock reads through readText. Exports, error text and error order unchanged.
  • confirm-verdict.sh: the record is written with one printf; file bytes and exit codes unchanged.
  • scripts/sync-shared-copies.sh regenerated the copies; each carrier plugin has one bump: patch fragment. One fragment was renamed in a last commit because its random suffix tripped the typos check.

Verification

  • Before/after pins: 17 check-retirements cases (detect, clean, migrate, home-root; stdout, stderr, exit and resulting tree) and 48 config-cascade calls (full JSON across symlinks, escaped home, legacy, FIFO, bad YAML, bad plugin): all identical; a deliberate one-character break made each pin report a difference.
  • Shell suites (check-retirements 230/8/9/12, confirm-verdict, ready-flip, config-cascade, view-settings, registry-dir 83, codify-settings 37) and 322 node tests: pass. lib/setup-apply.test.sh has 6 of 694 checks failing that also fail at base 42517b5.
  • sync-shared-copies.sh --check and --check-bump, sync-config-cascade-semantics.py --check (up to date, 82 surfaces), fragment --check and --check-required, validate-plugin-contracts, shellcheck: clean.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01VQb9Q3tnh28AzDYZ8AUjhH

kyle-sexton and others added 4 commits November 11, 2026 10:09
Route the parser's record errors through one bad_record helper, fold the
blank and comment line skips into one test, and turn if/die blocks into
`cmd || die`. Output, exit codes and cleanup are unchanged.

Refs: #14327

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VQb9Q3tnh28AzDYZ8AUjhH
resolve() and readLayers() now share the plugin-name check, the
convention-home and file-layer setup, the escaped-home layer and the
layer-prefixed error recorder. fileState() loses its never-false repo
flag and the symlink-following branch it guarded, and hasConfigBlock()
reads through readText(). Values, provenance, layers, errors and
legacy reports are unchanged.

Refs: #14327

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VQb9Q3tnh28AzDYZ8AUjhH
Write the verdict record with one printf over the verdict line and the
item lines. The record file, exit codes and printed text are unchanged.

Refs: #14327

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VQb9Q3tnh28AzDYZ8AUjhH
The random suffix cb5f6caf contains "caf", which typos flags. Same
fragment content under a new suffix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VQb9Q3tnh28AzDYZ8AUjhH
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 11, 2026 18:15
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T18:17:15.917926Z 18abd6d 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

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 18abd6ddc9802eb5c17ff1dda94bd85e298dea6e: read 56 of 56 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15412, refactor of three shared lib sources

I found no security issues in this pull request.

Scope. I read every hunk of the three changed sources: lib/check-retirements.sh, lib/config-cascade.mjs and lib/confirm-verdict.sh. For each group of identical regenerated copies I read the first copy in full: plugins/adhd/lib/config-cascade.mjs, plugins/attribution/lib/check-retirements.sh and plugins/source-control/skills/pull-request/scripts/confirm-verdict.sh. Each of those makes the same change as its source. I also read the first of the 25 identical .changes/ fragments; each is a bump: patch changelog entry. No changed file matches a trusted-path glob, and the diff touches no plugin manifest, workflow, trust control, merge hold or standing instruction.

What I checked:

  • Symlink refusal in config-cascade.mjs. fileState no longer takes a repo flag. It now refuses a symlink every time (lib/config-cascade.mjs#L112). At base, every caller passed true: readLayer(name, stem, true) in both resolve and readLayers, and fileState(path, true) in hasConfigBlock. So the branch that followed symlinks never ran. The repository-layer guard against a symlink pointing outside the checkout is the same as before and now holds without a flag.
  • Home-escape guard. homeEscapes moved into fileLayersOf. It is still worked out the same way (!isAbsolute(home) && escapes(homeDir, projectRoot)) and still replaces both file layers with the invalid layer in resolve and readLayers.
  • hasConfigBlock. It now reads through readText (lib/config-cascade.mjs#L335-L341), which returns null on a read error. A failed read still gives false.
  • Rewritten conditions in check-retirements.sh.
    • The non-repository refusal [[ $ROOT_IS_REPO -eq 1 || "$kind" != "file" ]] || die is the logical inverse of the old check. ROOT_IS_REPO is only ever set to 0 or 1 (lib/check-retirements.sh#L201-L210), so the two are equivalent.
    • The same holds for the I_MIGRATED check, which is only set to 0 or 1 (L147, L170).
    • The checks that keep removals inside the root are unchanged. So are the rm error paths, which keep their meaning as cmd || die.
    • The merged blank/comment skip still rejects any other line with leading whitespace at the key: value regex.
  • confirm-verdict.sh. printf '%s\n' "verdict: $VERDICT" ${items[@]+"${items[@]}"} keeps $VERDICT as an argument, not as the format string, so a % in it cannot change the format. The empty-array expansion is quoted, so nothing is word-split. The write still goes through a temp file and mv.

PR context. It holds no embedded instructions aimed at this lane.

Spend. None.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 18abd6ddc9802eb5c17ff1dda94bd85e298dea6e: read 56 of 56 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

This PR simplifies three of #14327's shared lib sources: lib/check-retirements.sh, lib/config-cascade.mjs and lib/confirm-verdict.sh. It also commits their regenerated copies under plugins/ and adds one bump: patch fragment for each plugin that carries a copy. I read every hunk of the three sources, of the first file in each group of identical copies (plugins/adhd/lib/config-cascade.mjs, plugins/attribution/lib/check-retirements.sh, plugins/source-control/skills/pull-request/scripts/confirm-verdict.sh) and of the first fragment. Each copy's change is the same as its source's change. None of the copy paths is a hook, workflow, settings file or manifest, so none behaves differently where it sits.

Behavior checks (done by reading the code, nothing run)

check-retirements.sh

  • Flag checks: the rewritten guards behave the same as before. I_MIGRATED is only ever set to 0 or 1 (lib/check-retirements.sh:147,170), and ROOT_IS_REPO likewise (:201-209).
  • Error messages: bad_record and invalid print the same text as the old inline echo …; exit 2 blocks. That covers "is not 'key: value'", "is set twice (line N)" and "is not part of the schema (line N)". They exit 2 from the main shell as before, because a while … done <file loop does not start a subshell.
  • Blank and comment lines: the merged skip for lines that are empty or start with # matches the old two-step check. For a line with no leading whitespace, the trimmed text is the line itself. For a line that is all whitespace, it trims to an empty string.
  • Other rewrites: the rm … || die lines and the default-then-override for ends_with_newline act the same, also under set -e.

config-cascade.mjs

  • The removed repo flag: every caller of fileState and readLayer passed repo=true (resolve, readLayers, hasConfigBlock). So dropping the statSync branch and its import changes nothing. statSync has no other use in the file.
  • hasConfigBlock: it now reads through readText (lib/config-cascade.mjs:335-341), which already returns null when the read fails. That matches the old try/catch.
  • Shared helpers: recordOn, escapedLayer, checkPlugin and fileLayersOf produce the same message strings as before. They also run in the same order relative to flatNames and the projectRoot check, so errors come out in the same order.

confirm-verdict.sh

  • The single printf '%s\n' "verdict: $VERDICT" ${items[@]+"${items[@]}"} writes the same bytes as before. VERDICT is still passed as data, not as a format string. The empty-array form is safe under set -u on bash 3.2 and is the same form the file already uses at line 92.

Closing issue #14327

  • Behavior unchanged: met, as far as the code reading above shows.
  • Diff limited to the listed files, generated copies and fragments: met. The three unchanged sources (config-root.sh, check-convention-facts.mjs, context-zone.fixtures.mjs) are explained in the PR body.
  • Size cap (400 lines, 15 hand-edited files): met (167 hand-changed lines across 3 files).
  • sync-shared-copies.sh run and its copies committed: the copies match their sources in the diff.
  • ci-status green: not something this lane can see.
  • The before/after pins, test-suite results and --check runs in the PR body are the author's claims; I did not verify them.

Other checks

  • Plugin manifests: no plugin.json or marketplace.json changed. The fragments' bump: patch fits an internal refactor that changes no behavior.
  • Path-scoped rules: .claude/rules/skill-bodies-state-current-rules.md matches the source-control confirm-verdict.sh copy by path, but it governs skill and agent prose, and this change only touches script code. No other rule's paths match.
  • Paved paths, settled threads and prior findings: none apply. This lane has not reviewed an earlier head, so the review is not blocking only.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit 059e279 Nov 11, 2026
66 of 79 checks passed
@kyle-sexton
kyle-sexton deleted the refactor/simplify-config-libs branch November 11, 2026 18:53
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify the check-convention-facts.mjs, check-retirements.sh, config-cascade.mjs and 3 more shared lib sources

1 participant