Skip to content

refactor(scripts): unify render-*.cjs behind shared compose + manifest - #421

Merged
kyle-sexton merged 4 commits into
mainfrom
cursor/issue-200-render-compose-9b36
Aug 12, 2026
Merged

kyle-sexton merged 4 commits into
mainfrom
cursor/issue-200-render-compose-9b36

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Summary

Lands #200 item 1c only: reconcile and unify the remaining render-*.cjs family behind a shared compose engine + data-driven manifest. No composition/include of shared bash primitives (1a/1b deferred). Generated workflow output is byte-identical.

  • Add .github/scripts/render-compose.cjs — exactly-one ordered block splice, indent, --check/write loop (pulumi-era contract).
  • Add .github/scripts/render.cjs — manifest of {source, workflows, markers, bundle} for osv-scan-guard, find-tracking-issue, select-runner-workflow.
  • Thin wrappers keep stable CLI paths used by tests / docs / muscle memory.
  • Wire new paths into selector-conformance.yml.
  • Tests in render-compose.test.cjs pin wrapper↔manifest coverage and --check green.

Not in this PR (deferred, no new issues):

Reusable workflows remain standalone-shippable (inline generated blocks only; no repo-relative source at runtime).

Test plan

  • node .github/scripts/render.cjs --check (and each thin wrapper --check)
  • Workflow SHA-256 unchanged after render.cjs rewrite
  • node --test .github/scripts/*.test.cjs (589 pass)
  • CI green on this PR

Related

Addresses #200 (1c). Does not close #200 — 1b remains the open architecture gap; 1a obsolete.

Extract render-compose.cjs (exactly-one ordered block splice, indent,
--check/write loop) and a data-driven render.cjs manifest for the three
remaining render targets. Thin wrappers keep stable CLI paths and
byte-identical generated workflow output.

Lands issue #200 item 1c only; 1a is obsolete and 1b (gh-bounded-read /
composition-vs-duplication) stays deferred — no new issues.

Co-authored-by: Kyle Sexton <kyle-sexton@users.noreply.github.com>
@cursor

cursor Bot commented Aug 12, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@claude

claude Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 3m 45s —— View job


Review: refactor(scripts): unify render-*.cjs behind shared compose + manifest

  • Gather context (CLAUDE.md, REVIEW.md, diff)
  • Review render-compose.cjs
  • Review render.cjs
  • Review thin wrappers (find-tracking-issue, osv-scan-guard, select-runner-workflow)
  • Review tests (render-compose.test.cjs)
  • Review workflow wiring (selector-conformance.yml)
  • Post findings

This repo's claude-security-review.yml workflow exists, so per REVIEW.md this review is scoped to correctness/design/tests and excludes security — none of these files touch untrusted input paths anyway (pure local codegen over repo-tracked source files).

Summary: clean extraction. render-compose.cjs owns the mechanics (marker-splice, indent, --check/write loop), render.cjs's TARGETS manifest owns the three per-target declarations, and the three render-*.cjs files are now thin re-exports that preserve their original CLI entrypoints and module APIs (bundledScript(source) / render(workflow, source[, name])) — so nothing consuming those wrappers (docs, muscle memory, or select-runner.test.cjs / osv-scanner-pin.test.cjs / find-tracking-issue-render.test.cjs, which spawn each wrapper directly and only assert on exit status/content, not internal error text) breaks. I traced the byte-for-byte splice logic (shellLines/indentLines/marker handling) against each original wrapper and it's equivalent, modulo the intentionally stricter findExactlyOneOrderedBlock (now also rejects duplicate begin/end markers, not just missing/reversed ones — covered by its own test). I could not execute node --test / node render.cjs --check myself in this sandbox (tool approval for node invocations was denied), so the PR's "589 pass" / SHA-256-unchanged / --check claims in the Test plan are author-claimed and unverified by me — worth confirming CI is actually green before merge, per the PR's own unchecked "CI green on this PR" box.

Two minor, non-blocking suggestions posted inline:

  • render.cjs#L247 — prepareFindTrackingLines/bundleSelectRunner are exported but currently unused outside the manifest itself.
  • render-compose.test.cjs#L137 — writeOrCheck's actual-write (check: false) branch, now shared machinery across all three targets, has no direct unit test.

One thing I considered under REVIEW.md's atomicity check and am not flagging as a finding: runAll() (no-target render.cjs invocation) now writes multiple workflow files in one process where previously each target's own script only ever touched its own file(s). filesForTarget() reads and computes expected for every target before any write happens, so a malformed-marker error still fails closed with zero writes — the only new exposure is a low-probability mid-loop I/O failure leaving some workflows updated and others stale, which --check in CI would still catch on the next run. Given this is local/CI-only codegen (not user-facing state) and every prior renderer already used a bare fs.writeFileSync with no atomic-rename step, this doesn't meet the bar for a blocking finding — noting it here in case the author disagrees.

Scope check: wrapper stability, manifest completeness (all three targets + all their workflow consumers, including queue-monitor-liveness.yml/tool-version-drift-check.yml for find-tracking-issue), and selector-conformance.yml's trigger paths (now includes render-compose.cjs, render-compose.test.cjs, render.cjs) all check out.
· Branch

@claude

claude Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 1m 7s —— View job


Security Review

  • Gather context (PR diff, changed files)
  • Review render-compose.cjs (new shared compose engine)
  • Review render.cjs (new manifest-driven renderer)
  • Review thin wrappers (render-find-tracking-issue.cjs, render-osv-scan-guard.cjs, render-select-runner-workflow.cjs)
  • Review render-compose.test.cjs
  • Review selector-conformance.yml changes
  • Post final findings

No security issues found.

This PR is a pure refactor of local, offline codegen tooling (render-*.cjs) — it doesn't touch runtime workflow trust boundaries in a way that introduces new risk:

  • No new trust boundary crossed. render-compose.cjs / render.cjs read/write only local, repo-tracked files (.github/scripts/*.sh, .github/scripts/select-runner.cjs, .github/workflows/*.yml) at CI/dev-check time. There's no network access, no handling of github.event.*/PR-supplied content, no secrets or tokens touched anywhere in the diff.
  • Marker-matching got stricter, not looser. The old per-wrapper render() used start < 0 || end < start, which silently accepted duplicate begin/end markers (last occurrence would win under naive indexOf). The new shared findExactlyOneOrderedBlock in render-compose.cjs explicitly rejects missing, reversed, and duplicated markers before splicing — closing a (low-severity, pre-existing) class of generated-block confusion rather than opening one.
  • select-runner.cjs source content is unchanged. bundleSelectRunner in render.cjs only changes how the existing selector source is wrapped/spliced into select-runner.yml; the selector logic itself (which runs inside actions/github-script at workflow execution time) is untouched by this PR, so no new script-injection surface is introduced there.
  • selector-conformance.yml changes are additive path filters only (diff) — permissions: (top-level {}, job-level contents: read on selector-unit) and triggers (pull_request/push: [main]/workflow_dispatch) are unchanged, so no permission-widening or trigger-risk concern.
  • Supply-chain/unpinned-action and other statically-detectable patterns are deferred to zizmor's advisory lane per review scope, and I didn't observe anything in this diff (no new uses: pins) that lane would need to flag anyway.

Confidence: high — the diff is small, self-contained, and I traced both the compose/manifest mechanics and all three call sites end-to-end.

@kyle-sexton
kyle-sexton enabled auto-merge (squash) August 12, 2026 02:47
@github-actions

Copy link
Copy Markdown

Last security-reviewed head: 33890aef43e00a90986046a68084c181d2dbad51. On the next push, the relevance gate compares only the commits since this SHA; delete this comment to force a full re-review.

Co-authored-by: Kyle Sexton <kyle-sexton@users.noreply.github.com>
Comment thread .github/scripts/render.cjs Resolved
Comment thread .github/scripts/render-compose.test.cjs Resolved
@github-actions

Copy link
Copy Markdown

Claude has reviewed this PR 1 time. The lane skips further automatic reviews after 5; deleting this comment resets the count.

cursoragent and others added 2 commits August 12, 2026 03:06
Remove unused prepareFindTrackingLines/bundleSelectRunner re-exports and
cover writeOrCheck({ check: false }) so the shared write branch is unit-tested.

Co-authored-by: Kyle Sexton <kyle-sexton@users.noreply.github.com>
Biome was previously applied with a mis-resolved config path that
rewrote indents to tabs; reformat with the fixture space policy.

Co-authored-by: Kyle Sexton <kyle-sexton@users.noreply.github.com>
@kyle-sexton
kyle-sexton merged commit a65f459 into main Aug 12, 2026
1 check passed
@kyle-sexton
kyle-sexton deleted the cursor/issue-200-render-compose-9b36 branch August 12, 2026 03:12
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.

[architecture] Shared-bash-primitive library unfinished; render codegen lacks composition (SARIF annotator + gh-bounded-read + render.cjs clones)

2 participants