Skip to content

refactor(lib): simplify view-builder, view-registry, view-settings and write-snapshot - #14571

Merged
kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-14342-42612647547-1
Nov 9, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-14342-42612647547-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #14342

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Simplified four of the five listed shared lib sources without changing behavior, then regenerated their shared copies and added a patch fragment to each of the 18 plugins that carries them. view-runtime.js is deliberately unchanged: view-builder inlines it into every interactive page and pins it in the page's CSP by SHA-256, so any edit, even a whitespace one, changes the bytes of every built page, which the issue's 'same outputs' rule forbids. The edits: view-builder.mjs turns own/textOf into arrow expressions, uses stack.at(-1), builds buildReport's slot-in-tag failures with filter/map, chains the text-stripping replaces and makes the http-equiv count an if. view-registry.mjs fallBack throws on an unknown medium before building the chain, and walks FALLBACK_CHAIN from the wanted step instead of building a separate candidates list. That list re-checked the medium that had just failed. view-settings.mjs drops a retired-notice caveat branch that could never run, since the destination is always the team or personal file, and computes the invalid-layer prefix and display name once per layer. write-snapshot.mjs writes the regress/floor guard in De Morgan form.

Not verified

  • lib/view-runtime.js left unchanged: view-builder pins it by SHA-256 in every interactive page's CSP, so any edit changes every built page's output, which the issue's behavior rule forbids
  • lib/view-builder.test.sh, view-settings.test.{sh,mjs}, write-snapshot.test.{sh,mjs}, view-runtime.test.*, scripts/check-view-medium-lists.test.mjs: not run here because the lane's Bash allows only the named wrappers; left to the PR's CI
  • tidy skipped: the change is under lib/ (a listed shared path) and over the 10-file cutoff
  • verify step (build and tests) not run beyond check-affected; behavior equivalence rests on the review and the CI suites
  • ci-status green: left to the PR's CI

Fix

  • lib/view-builder.mjs: own/textOf as arrow expressions; stack.at(-1); slot-in-tag failures via filter/map; destructured style capture; the text-stripping replaces chained; http-equiv count as an if
  • lib/view-registry.mjs: fallBack checks the wanted medium first, then walks FALLBACK_CHAIN from its step without a separate candidates list
  • lib/view-settings.mjs: retiredNotices caveat loses its unreachable third branch; resolveMedium computes each layer's error prefix and display name once, outside the per-error loop
  • lib/write-snapshot.mjs: !(has(body) && !has(current)) rewritten as !has(body) || has(current)
  • plugins/{review,education,planning,architecture,debugging,discovery,work-items,machine-health}/lib/view-builder.mjs: regenerated by sync-shared-copies
  • plugins/{review,visualization,work-items,harness-ops,source-control,planning,adhd,ai-briefing,architecture,debugging,discovery,education,prototype,codebase-health,overengineering}/lib/view-settings.mjs: regenerated by sync-shared-copies
  • plugins/{review,visualization,work-items,harness-ops,source-control,planning,machine-health,adhd,ai-briefing,architecture,debugging,discovery,education,prototype,codebase-health,overengineering}/lib/view-registry.mjs: regenerated by sync-shared-copies
  • plugins/{rate-limit-guard,context-guard}/lib/write-snapshot.mjs: regenerated by sync-shared-copies
  • .changes/<plugin>/work-resolve-issue-issue-14342-42612647547-1-*.md (18 plugins: review, education, planning, architecture, debugging, discovery, work-items, machine-health, visualization, harness-ops, source-control, adhd, ai-briefing, prototype, codebase-health, overengineering,…

Verification

The runner ran each check from the base copy against c0b1991:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • sync-shared-copies: regenerated 41 copies, exit 0
  • check-changelog-fragments: all 24 fragments under .changes/ valid
  • check-changed-skills: no changed skills; view-medium-lists passes against the edited view-registry.mjs
  • check-affected: 12 passed, 7 skipped over 63 changed files
  • fresh-context review subagent (read-only, given the diff and the full files): found no reachable input where old and new behavior differ; it named only contrived inputs that the real callers (readLayers, the legacy kinds, the frozen MEDIUMS) never produce. It confirmed that readRegistry in…
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42612647547

Left out: the items under Not verified.

Related

#14342

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Code review: PR #14571 (no findings)

I read every hunk of the four hand-edited sources (lib/view-builder.mjs, lib/view-registry.mjs, lib/view-settings.mjs, lib/write-snapshot.mjs). I also read the first path of each identical-copy group: the two changelog fragment groups, plugins/adhd/lib/view-registry.mjs, plugins/adhd/lib/view-settings.mjs, plugins/architecture/lib/view-builder.mjs and plugins/context-guard/lib/write-snapshot.mjs. Each regenerated copy has the same hunks as its lib/ source; only the line offsets differ, because of the generated header. None of the copy paths is a hook, workflow, settings or manifest path, so no copy behaves differently at its path.

Behavior-equivalence check (my own reading of the code; nothing was run)

  • view-registry.mjs fallBack:
    • When want === "hosted", the old list put hosted first, and the new code drops it. That hosted had just failed reachable, and reachable is the deterministic interactiveOnly function (view-registry.mjs#L14), so a second check could never pass.
    • Replacing mediumOf(id) with MEDIUMS[id] is safe because every id in FALLBACK_CHAIN is an own key of MEDIUMS.
    • The unknown medium throw still fires before any chain walk. Building the old candidates list had no side effects, so the new order changes nothing.
  • view-settings.mjs caveat: mediumOf returns undefined for any non-string or unknown value, so dropping the value && guard is safe. destination only maps to TEAM_FILE or PERSONAL_FILE (view-settings.mjs#L186), and ?? TEAM_FILE covers the rest, so the removed third branch could never run.
  • view-settings.mjs resolveMedium: prefix and where now get computed once per layer instead of once per error. They depend only on layer, so the notice text is the same.
  • write-snapshot.mjs: !(A && !B) becomes !A || B, which is a correct De Morgan rewrite.
  • view-builder.mjs:
    • own and textOf are now const arrow functions, which are not hoisted. They are only called from inside renderSlots at runtime (L512, L514), never while the module loads, so there is no temporal-dead-zone hazard.
    • The slot-in-tag failures are still pushed before slot-in-style, in the same order and number.
    • The http-equiv count, the chained .replace calls and stack.at(-1) all give the same results as before.

Closing issue #14342 acceptance criteria

  • Behavior unchanged: met by my reading above. The retired-notice caveat text is asserted in lib/view-settings.test.mjs and in plugins/review/tests/explain-change.test.mjs:661. I ran none of these suites.
  • Diff limited to the listed files, regenerated copies and fragments: met. lib/view-runtime.js was left unchanged. The PR gives a reason: view-builder pins that file by SHA-256 in each page's CSP, so any edit would change every built page.
  • Under 400 changed lines and 15 hand-edited files: met (4 hand-edited files).
  • sync-shared-copies.sh run and copies committed: met. Every copy's hunks match its source.
  • ci-status green: I cannot see CI from this lane, so this one is unverified. The PR's test-plan claims are the author's and I have not checked them.

No plugin manifest changed. Every fragment has bump: patch, which fits an internal change with no behavior change. I found no embedded instructions in the PR context. No change in this PR spends credits or usage, and no hold applies.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Security review: PR #14571 (refactor of shared view and snapshot helpers)

No security issues found.

Scope read. I read every hunk of the 10 distinct changes in .claude-lane/pr.diff. These are the four root sources (lib/view-builder.mjs, lib/view-registry.mjs, lib/view-settings.mjs, lib/write-snapshot.mjs), the first plugin copy of each identical group (plugins/architecture/lib/view-builder.mjs, plugins/adhd/lib/view-registry.mjs, plugins/adhd/lib/view-settings.mjs, plugins/context-guard/lib/write-snapshot.mjs), and the two distinct changelog fragment bodies (.changes/adhd/…, .changes/context-guard/…). The other copies are byte-identical changes at plugin lib/ paths of the same kind, and none of their paths changes what the content does. No changed file matches a TRUSTED PATHS: glob. No manifest, workflow, hook, or instruction file is touched.

What I checked:

  • validateInteractivePage (view-builder, a page validator). Counting http-equiv with if instead of += cond ? 1 : 0 gives the same count. The chained .replace calls run the same three regexes in the same order before the raw-lt check. The checks are no looser. buildReport's slot-in-tag and slot-in-style failures come out the same, in the same order. The own arrow keeps the null, object-type and Object.hasOwn guards, so prototype keys are still not read.
  • fallBack (view-registry, medium selection). The chain from the wanted step onward is unchanged (FALLBACK_CHAIN = ["artifact","file","terminal"], lib/view-registry.mjs#L29). The old code started the search for hosted by checking hosted again, though it had just failed. Leaving that out cannot pick a medium that publishes more. MEDIUMS[id] replaces mediumOf(id) only for chain ids, and all of them are own keys of the frozen MEDIUMS (L18). The unknown-medium throw still runs before any lookup.
  • view-settings. The changes only affect the text of notices: the retired-file caveat and the prefix for invalid layers. The function that resolves the medium and its trust-scope rules are unchanged.
  • write-snapshot. !(has(body) && !has(current)) and !has(body) || has(current) are equivalent by De Morgan's law, so the preserve, regress and floor guards behave as before.

Trust controls and instruction surfaces. This diff changes no trust control, token scope, kill switch, merge hold, or standing instruction.

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

critical-findings: 0

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 56195f8 Nov 9, 2026
51 checks passed
@kyle-sexton
kyle-sexton deleted the work-resolve-issue/issue-14342-42612647547-1 branch November 9, 2026 13:17
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.

Simplify the view-builder.mjs, view-registry.mjs, view-runtime.js and 2 more shared lib sources

1 participant