Skip to content

fix(skills): advance the release ledger at the cut so shipped revisions freeze - #10483

Merged
brennanb2025 merged 10 commits into
mainfrom
brennanb2025/fix-skill-release-ledger
Jul 25, 2026
Merged

brennanb2025 merged 10 commits into
mainfrom
brennanb2025/fix-skill-release-ledger

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The skill release ledger never advances, so the second skill content change after any release silently orphans every install of the first one.

config/scripts/generate-skill-bundle-manifest.mjs:

  • :390 — releasedCount comes solely from resources/skills/release-mapping.json.
  • :461 — a changed skill gets releaseRevision = releasedCount + 1, i.e. array index releasedCount.
  • :518 — protectedCount = committedReleasedCounts[name], so index releasedCount is unprotected.

That unprotected tail is correct while it is unreleased. It stops being correct the moment a tag ships it, and nothing records that it shipped:

So today: a tag ships skill X at revision N; the mapping still names N-1 as the max released revision; the next content change re-derives revision N over different bytes. Every install carrying the digest the tag actually shipped matches no known snapshot, reads as unrecognized / needs-attention, and the update command cannot deliver.

v1.4.156 itself is clean — all 9 registry tails currently equal their mapped counts. Corruption lands on the second change after the cut.

Fix

Restore the ledger advance in a form the #9119 contract can keep enforcing, rather than one that has to be exempted from it.

--release is now provenance-only (generate-skill-bundle-manifest.mjs):

  1. Verifies current-manifest.json and snapshot-registry.json already match the ref being tagged — the cut proves it is not regenerating them.
  2. Appends the mapping row (unchanged appendReleaseRow: v-prefix strip, dedupe, re-cut overwrite).
  3. Writes only release-mapping.json. writeArtifacts/verifyArtifacts take a path set; --write and plain verify keep all three.

release-cut.yml runs that step and stages exactly package.json resources/skills/release-mapping.json.

The contract test is narrowed, not deleted — it asserts the cut runs --release, that every resources/skills mention in the bump step is exactly what gets staged, and that the staged set is ['package.json', 'resources/skills/release-mapping.json']. A companion job-wide test asserts no step anywhere in the cut job regenerates the artifacts. See Contract-gate hardening below.

Why this is safe where #10340 was not

#10340 ran the full writeArtifacts and staged the whole resources/skills directory, so a version-only cut could rewrite content-addressed artifacts — exactly the regression #9119 fixed. The invariant is now enforced by the script itself, not by workflow convention: the release path can only write the provenance file, and it aborts before writing anything if the manifest or registry disagree with the ref.

#9119's stated harm was that version bumps made committed artifacts stale on every open branch, and dragged the resources/skills-filtered update-roundtrip matrix onto unrelated PRs. Neither recurs here: the mapping is passed through from the committed file rather than re-derived, so an open branch that rebases onto the cut still verifies clean, and the roundtrip matrix triggers on push: main — the cut's own commit, not unrelated PRs.

Screenshots

No visual change.

Testing

  • pnpm lint — oxlint config/scripts/ clean
  • pnpm typecheck — clean
  • pnpm test — config/scripts suite: 53 files, 420 passed / 4 skipped
  • pnpm build — not run; no runtime/bundled code changed
  • Added or updated high-quality tests that would catch regressions

Two new tests in generate-skill-bundle-manifest.test.mjs drive the real CLI inside a throwaway tree (the script resolves its repo root from its own location, so a copy runs against a synthetic skills/demo; nothing touches resources/skills):

  • records a release without regenerating the content-addressed artifacts — asserts the row is appended, the manifest and registry are byte-identical afterwards, and a --release over unregenerated skill bytes fails with Generated skill artifacts are stale and writes nothing.
  • freezes a revision once a release records it, and only until then — an unreleased tail may be re-derived over new bytes; once --release names revision 1, the next change appends revision 2 and revision 1 stays byte-identical.

Correction to an earlier revision of this description, which called the second test "the tail-reuse regression test." It is not. With only generate-skill-bundle-manifest.mjs reverted to origin/main and both new tests kept, that test passes — --release and appendReleaseRow already exist on main, because #10460 reverted only the two workflow lines and deliberately left the script implementation in place. It is a characterization test of pre-existing script behavior; its assertions are non-vacuous (they die under a targeted mutation), but it does not fail without this PR. The thing actually missing in production was the workflow never invoking --release, and that is gated solely by the contract test in package-electron-runtime-contract.test.mjs.

Mutation results (each reverted afterwards):

mutation result
revert generate-skill-bundle-manifest.mjs to origin/main, keep new tests test 1 fails at the Generated skill artifacts are stale assertion; test 2 passes
drop the ledger-advance step from release-cut.yml contract test fails (expected -1 to be greater than 216)
drop the content-artifact verification from --release test 1 fails
make the cut not record the row tests 1 and 2 fail — test 2 at the genuine tail-reuse assertion (registry stays length 1, revision 1 rebuilt over new bytes)
release path writes ALL artifacts instead of only the mapping nothing fails — see below

The last row is not a coverage gap but is worth stating plainly: with the verification guard in place, verifyArtifacts has already established that both content-addressed files serialize byte-identically, so rewriting them is a no-op. The "writes only release-mapping.json" narrowing is redundant defense-in-depth that no test can kill. If the verification guard is ever weakened, that narrowing silently becomes load-bearing and unprotected.

Contract-gate hardening

Closing this took four rounds of adversarial review, and the first three fixes were all wrong in the same way. Every mutation below was confirmed to reintroduce #9119 while the test suite stayed green, then confirmed to fail after the fix.

  • Round 1 — inside the bump step: a git add chained after && (invisible to a regex anchored to line start); a write reaching resources/skills with no git add at all; and pnpm run generate:skill-bundle-manifest, the package.json alias for --write, whose colon form never matched the banned hyphenated name. That last one also passed the pre-ci(release-cut): restore the skill-independent version commit #10460 assertions, so it predates this PR.
  • Round 2 — the gate inspected only the bump step, but the cut job has 15 steps sharing one workspace and one git index, so an earlier step could regenerate and stage, and the bump step's own commit swept it into the tag. Separately, the mention scan required a trailing slash (so a path in a shell variable was invisible) and the commit -a ban matched nothing at all — commit\s consumed the only separator.
  • Round 3 — the job-wide grep was defeated three more ways: an env: block holding --write and resources/skills; a composite uses: action whose steps the workflow never spells out; and plain concatenation (root=resources; leaf=skills).

Round 3 is the load-bearing lesson: grepping shell source for path literals is inherently evadable, and each fix had only relocated the previous hole. So the invariant moved to where it cannot be dodged. Round 6 then showed the first attempt at that still asserted the wrong thing — it validated the index, but git commit -a/-i/--only/<pathspec> commits the working tree, so a rogue step could leave regenerated artifacts unstaged and git commit -i resources would carry them into the tag with every gate green (--only resources additionally dropped package.json from the tag). Enumerating those flags is the same losing game, so the guard now asserts the outcome — after committing and before tagging:

committed="$(git diff-tree --no-commit-id --name-only -r HEAD |
  grep -vxF -e 'package.json' -e 'resources/skills/release-mapping.json' || true)"

It uses -m --first-parent because plain diff-tree prints nothing for a merge commit, which would make the guard pass silently — the one direction that matters here. It is indifferent to which step staged what and to how the commit was spelled. Verified blocking the whole family — -i, --only, -a, -am, -vam, a bare pathspec, and an alias expanding to commit -i — while a stock commit and an --allow-empty re-cut still pass. Round 4 caught that the original grep -vx matched patterns as regexes, so the . in package.json admitted a staged packageXjson; -F fixes it. The guard also fails closed on paths with spaces or non-ASCII characters (git quotes those) and on staged deletions.

The workflow grep survives as a cheap tripwire for literal spellings, now paired with positive assertions that the index guard exists, precedes the commit, and actually aborts — indirection can hide a path, but it cannot hide a missing guard. That last assertion came from round 4: replacing the guard's exit 1 with : had left every test green while the cut logged the error and shipped the artifact anyway — the same shape-not-effect mistake the earlier rounds kept making. Round 5 then found two holes in those very guards: the abort check could borrow an exit 1 from a later if ... fi in the same step, and the commit -a ban only matched when a led the flag cluster, so -vam/-va/-qam survived. That second one is the sharper of the two — commit -a stages at commit time, after the index guard has inspected a clean index, making it the one way to defeat layer 1. Both are fixed and their mutants verified failing. The job-wide test lives in the generator suite because the contract file sits at its hard 600-line max-lines cap, which is never raised or disabled.

Knowingly accepted: stagedPaths still fails on a line-continuation, a git add -- separator, or a trailing comment on the staging line, and the static tripwire still cannot see env-var or composite-action indirection. Both are fail-closed or backstopped by the runtime guard.

AI Review Report

Reviewed with two independent Opus subagents (correctness/regression and test-verification) plus direct verification. Checked: the whole main() control flow, argument-parsing edge cases, ordering of verify-before-append, the paths refactor's effect on everyday lint, workflow retry/idempotency, and scope.

Confirmed clean:

  • --release "" and a missing operand both throw at :633, so releaseVersion !== null and the truthy checks cannot disagree.
  • The --release/--write/verify paths are git-free — working-tree hashing is pure Node sha1; readGitBlobs/releaseTags are reachable only from --rebuild-from-tags. The cut needs no git history and no pnpm install.
  • Plain verify still fails for each of the three artifacts individually; the default path set is unchanged.
  • Real-repo lifecycle reproduced independently: a content change plus --release appended one row, left current-manifest.json and snapshot-registry.json byte-identical (proved by git hash-object before/after), was idempotent on a second run, and exited 1 against unregenerated bytes. A second change then produced revision 37 with revision 36 frozen; without the row, revision 36 was rebuilt over different bytes. The specific digests quoted in an earlier revision of this description are functions of the reviewer's own probe edit and are not independently reproducible; the revision numbers, file-touch set, idempotency, and exit codes all are.

Cross-platform: the changed contract assertions are pure string parsing over YAML and are platform-independent. The generator changes add no platform-dependent behavior — no new path handling, shell invocation, or keyboard/UI surface. The new generator tests still have the macOS-only caveat noted under Notes.

Security Audit

No new input handling, command execution, path construction, auth, secrets, or IPC surface. The one new execution point is a node invocation in the release-cut workflow whose only argument is $VERSION, already validated upstream by the version/tag-collision logic; it is passed as a single execFileSync-style argv element by the shell, not interpolated into a shell string. The script writes to a fixed path derived from its own location. The contract-test changes are read-only parsing. --release reduces privilege relative to #10340: the release path can now write exactly one file.

Notes

Residual risk

  • A concurrent cut and an in-flight PR can still corrupt the ledger, with lint green. If a branch regenerates artifacts before a cut and merges after it, the branch legitimately claims the free tail revision N over its bytes B, while the cut names revision N as shipped bytes A. Because the cut never touches snapshot-registry.json, the merge is clean (mapping from main, registry from the branch) and plain verify passes on the result — the ledger then says revision N = digest B while the tag shipped digest A. Reproduced end to end in a synthetic repo, and also reproduced against origin/main's script, so this PR does not introduce it; it fixes the sequential case and leaves this one. Scheduled RC cuts make the window non-rare. A real fix needs the shipped digest recorded in the mapping row so the mismatch is detectable, which is a schema change and a separate PR.
  • A stale main blocks the cut. If resources/skills on main is out of sync with skills/, --release now fails the cut instead of silently regenerating. That state means PR lint was already red; a blocked release beats a corrupt ledger row, but it is a new way for the cut to fail.
  • Off-main releases still drift. When the cut does not push main (push_main != true), the row exists at the tag but never lands on main, so that release's revision can still be rebuilt later. Pre-existing and unchanged.
  • One extra CI run per cut. The release commit now touches resources/skills/release-mapping.json, matching the push: main trigger of skill-update-roundtrip.yml. fix(skills): decouple bundled skill artifacts from the release train #9119's concern was that matrix landing on unrelated PRs; this only affects the cut's own commit on main.
  • isToleratedReleaseMappingPrefix becomes near-vestigial on the committed path (it still guards --rebuild-from-tags). Left in place — removing it is a separate concern.

Static-only — not executed here

  • The release-cut.yml job itself has not run. Its shape is asserted only by parsing the YAML (step order, staged paths, Setup Node.js before Bump package.json and tag), plus the confirmation that the script imports only node:* built-ins and shells out to git only on the --rebuild-from-tags path.
  • Windows/Linux behavior of the new generator tests; only macOS ran. The sandbox helper resolves the temp path through realpath because Node resolves the entry point through symlinks (/var → /private/var on macOS), which is a no-op elsewhere.
  • The runtime UI consequence (a skill reading as unrecognized) is reasoned from the registry/mapping semantics, not observed in the app.

…ns freeze

#10340 made the released-skill registry a function of the committed ledger
instead of a git tag walk, and #10460 reverted the cut step that advances that
ledger because it violated the #9119 contract (a version-only cut must not
regenerate or stage the content-addressed skill artifacts). Both were right;
the result is a ledger that never advances.

generate-skill-bundle-manifest.mjs:390 derives releasedCount solely from
release-mapping.json and :461 assigns a changed skill releaseRevision =
releasedCount + 1, while :518 protects only committedReleasedCounts[name] —
so index releasedCount is unprotected. A tag ships that tail revision, nothing
records it, and the next skill change rebuilds the same revision number over
different bytes. Installs carrying the shipped digest then match no snapshot
and degrade to unrecognized, which cannot be updated.

Restore the advance in a form the #9119 contract can keep enforcing:
--release now verifies that current-manifest.json and snapshot-registry.json
already match the ref being tagged, appends the mapping row, and writes only
release-mapping.json. The cut stages just that file, so it still cannot move a
content-addressed artifact — the failure #9119 guarded against — and now fails
loudly instead of recording a revision the tag does not ship.

The contract test is narrowed to match: it asserts the cut runs --release
(never --write) and stages exactly package.json and release-mapping.json.
@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The skill bundle generator now selectively verifies and writes content-addressed artifacts and release mappings. Release cuts invoke it for the target version and stage the resulting release mapping with package.json. Tests add sandboxed release scenarios covering stale artifacts, immutable released revisions, unchanged content-addressed files, command ordering, and staged-path constraints.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the main change: advancing the skill release ledger at cut time.
Description check ✅ Passed The description includes all required sections and is detailed, with testing, review, security, and notes coverage.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…open

The narrowed contract test anchored its `git add` scan to line start and
only inspected staged paths, so three ways to reintroduce #9119 stayed
green: a `git add` chained after `&&`, a write that never calls `git add`
at all, and `pnpm run generate:skill-bundle-manifest` — the package.json
alias for `--write`, which the hyphenated ban never matched. That last one
also passed the pre-#10460 assertions, so it was never covered.

Drop the anchor, require every `resources/skills` mention in the step to
be exactly what is staged, and ban the alias and `commit -a`. Comments are
stripped first so prose cannot trip a ban. Verified each bypass fails and
the real workflow passes.
…erator

Verifying the content-addressed artifacts is the only new way the cut can
block, and it fails inside a step named "Bump package.json and tag" with a
lint-shaped message. That names the files and the command but not the two
things the operator needs: the regeneration has to land on main, and the
cut is safe to re-run afterwards. Say so.

Also pin down why assertReleasedHistoryPreserved takes the pre-append
mapping. It pairs with artifacts.releasedSnapshotCounts, which seeding
fixed before the row existed; handing it the post-append mapping makes
every cut throw "Released snapshot history is incomplete", which points
at tag fetching rather than the real cause. Nothing enforces the pairing.
Round-2 review defeated the previous gate twice, both proved by running
the full contract file green with #9119 reintroduced.

Every step in the cut job shares one workspace and one index, but the
contract test only inspected `Bump package.json and tag`. A step inserted
earlier could run --write and `git add resources/skills`, and the bump
step's own commit swept it into the version commit and the tag. Assert
job-wide instead: only the bump step may name the directory, and no step
may regenerate under either the flag or its package.json alias. That lives
in the generator suite because the contract file is at its max-lines cap.

Two regexes were also evadable. The mention scan required a trailing
slash, so a path held in a variable was invisible; it now matches the
directory itself. The `commit -a` ban matched nothing at all — `commit\s`
ate the only separator, so `-a`, `-am`, and `--all` all survived while
only a trailing `-a` was caught. `--allow-empty` stays allowed.
…mitting

Round-3 review defeated the job-wide grep three ways, each proved by
running both test files green with #9119 reintroduced into the tagged
commit: an `env:` block holding `--write` and `resources/skills`, a
composite action whose steps the workflow never spells out, and plain
shell concatenation (`root=resources; leaf=skills`).

Grepping shell source for path literals is inherently evadable, and the
previous fix only relocated round-2's variable-indirection hole one step
over. Move the invariant to where it cannot be dodged: immediately before
committing, the cut diffs its own index and refuses anything that is not
package.json or the release-mapping row. That does not care which step
staged what, or how the path was spelled.

The workflow grep stays as a cheap tripwire for literal spellings, now
paired with a positive assertion that the index guard exists and precedes
the commit — indirection cannot hide a missing guard. Mention matching
dedupes and trims quotes, since the guard names the row a second time.
`grep -vx` treats its patterns as regexes, so the `.` in `package.json`
matched any character: a staged `packageXjson` or a
`resources/skills/release-mappingXjson` was silently accepted by the
index guard. Verified both slip through `-vx` and are caught by `-vxF`.

Exercised the guard against a legitimate cut, an empty index, a staged
content-addressed artifact, paths containing a space and a non-ASCII
character (git quotes the latter, so it fails closed), and a staged
deletion. Only the two allowed paths pass.
…ists

The positive assertion pinned the guard's shape and its position before
the commit, but not its effect: replacing `exit 1` with `:` left both
test files green while the cut logged the error and shipped the artifact
anyway. That is the same failure this whole gate keeps having — asserting
the shape of a defense rather than what it does.

Pin the abort too. Verified the neutered guard now fails the suite.
…lags

Two holes in the guards this PR added, both in the same shape-not-effect
class the previous commit was meant to close.

The abort assertion's lazy match was not scoped to the guard's own block,
so it could borrow an `exit 1` from any later `if ... fi` in the step.
Degrading the guard to a warning while adding a plausible HEAD
precondition left every test green. Stop the match at the guard's `fi`.

The `commit -a` ban only matched when `a` led the flag cluster, so `-vam`,
`-va`, `-qam` and `-sam` all survived. That matters more than it looks:
`commit -a` stages at commit time, after the index guard has already
inspected a clean index, so it is the one way to defeat that guard. Match
`a` anywhere in a short-flag cluster; `--allow-empty` and `--amend` stay
allowed. Verified both mutants now fail.
The index guard asserted the wrong thing. `git commit` has a family of
forms that commit the working tree rather than the index — `-a`, `-i`,
`--only`, and a bare pathspec — so a rogue earlier step could leave
regenerated artifacts unstaged and any of those forms would carry them
into the tagged commit while the guard saw a clean index and passed.
Reproduced end to end: `git commit -i resources` put current-manifest.json
and snapshot-registry.json in the tag with all gates green, and
`--only resources` additionally dropped package.json from the tag.

Banning those flags one by one is the same enumeration game the earlier
rounds kept losing. Assert the outcome instead: after committing and
before tagging, diff-tree HEAD and refuse anything that is not
package.json or the release-mapping row. That is indifferent to which
step staged what and to how the commit was spelled.

Verified the whole family is now blocked (-i, --only, -a, -am, -vam,
pathspec, and an alias expanding to `commit -i`), that a stock commit and
an --allow-empty re-cut still pass, and that deleting, neutering,
un-anchoring, or relocating the guard each fails the suite.
Plain `git diff-tree` prints nothing for a merge commit, so the guard
would have passed silently instead of failing closed — the one direction
that matters on a release path. `-m --first-parent` reports the diff
against the first parent; verified byte-identical output for an ordinary
commit and still empty for the `--allow-empty` re-cut, so nothing else
changes. Not reachable today (nothing in the cut job creates a merge, and
npm version has no lifecycle hooks defined), but the failure mode is a
guard that looks like it ran.

Pin the flags in the assertion too, so neither dropping -m nor slipping in
a `--diff-filter` can weaken it without failing the suite.
@brennanb2025
brennanb2025 merged commit 7a01910 into main Jul 25, 2026
1 check passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ns freeze (stablyai#10483)

* fix(skills): advance the release ledger at the cut so shipped revisions freeze

stablyai#10340 made the released-skill registry a function of the committed ledger
instead of a git tag walk, and stablyai#10460 reverted the cut step that advances that
ledger because it violated the stablyai#9119 contract (a version-only cut must not
regenerate or stage the content-addressed skill artifacts). Both were right;
the result is a ledger that never advances.

generate-skill-bundle-manifest.mjs:390 derives releasedCount solely from
release-mapping.json and :461 assigns a changed skill releaseRevision =
releasedCount + 1, while :518 protects only committedReleasedCounts[name] —
so index releasedCount is unprotected. A tag ships that tail revision, nothing
records it, and the next skill change rebuilds the same revision number over
different bytes. Installs carrying the shipped digest then match no snapshot
and degrade to unrecognized, which cannot be updated.

Restore the advance in a form the stablyai#9119 contract can keep enforcing:
--release now verifies that current-manifest.json and snapshot-registry.json
already match the ref being tagged, appends the mapping row, and writes only
release-mapping.json. The cut stages just that file, so it still cannot move a
content-addressed artifact — the failure stablyai#9119 guarded against — and now fails
loudly instead of recording a revision the tag does not ship.

The contract test is narrowed to match: it asserts the cut runs --release
(never --write) and stages exactly package.json and release-mapping.json.

* test(release-cut): close the staging bypasses the narrowed gate left open

The narrowed contract test anchored its `git add` scan to line start and
only inspected staged paths, so three ways to reintroduce stablyai#9119 stayed
green: a `git add` chained after `&&`, a write that never calls `git add`
at all, and `pnpm run generate:skill-bundle-manifest` — the package.json
alias for `--write`, which the hyphenated ban never matched. That last one
also passed the pre-stablyai#10460 assertions, so it was never covered.

Drop the anchor, require every `resources/skills` mention in the step to
be exactly what is staged, and ban the alias and `commit -a`. Comments are
stripped first so prose cannot trip a ban. Verified each bypass fails and
the real workflow passes.

* fix(release-cut): make the new provenance failure actionable to an operator

Verifying the content-addressed artifacts is the only new way the cut can
block, and it fails inside a step named "Bump package.json and tag" with a
lint-shaped message. That names the files and the command but not the two
things the operator needs: the regeneration has to land on main, and the
cut is safe to re-run afterwards. Say so.

Also pin down why assertReleasedHistoryPreserved takes the pre-append
mapping. It pairs with artifacts.releasedSnapshotCounts, which seeding
fixed before the row existed; handing it the post-append mapping makes
every cut throw "Released snapshot history is incomplete", which points
at tag fetching rather than the real cause. Nothing enforces the pairing.

* test(release-cut): gate the whole cut job, not just the bump step

Round-2 review defeated the previous gate twice, both proved by running
the full contract file green with stablyai#9119 reintroduced.

Every step in the cut job shares one workspace and one index, but the
contract test only inspected `Bump package.json and tag`. A step inserted
earlier could run --write and `git add resources/skills`, and the bump
step's own commit swept it into the version commit and the tag. Assert
job-wide instead: only the bump step may name the directory, and no step
may regenerate under either the flag or its package.json alias. That lives
in the generator suite because the contract file is at its max-lines cap.

Two regexes were also evadable. The mention scan required a trailing
slash, so a path held in a variable was invisible; it now matches the
directory itself. The `commit -a` ban matched nothing at all — `commit\s`
ate the only separator, so `-a`, `-am`, and `--all` all survived while
only a trailing `-a` was caught. `--allow-empty` stays allowed.

* fix(release-cut): assert the index, not the workflow text, before committing

Round-3 review defeated the job-wide grep three ways, each proved by
running both test files green with stablyai#9119 reintroduced into the tagged
commit: an `env:` block holding `--write` and `resources/skills`, a
composite action whose steps the workflow never spells out, and plain
shell concatenation (`root=resources; leaf=skills`).

Grepping shell source for path literals is inherently evadable, and the
previous fix only relocated round-2's variable-indirection hole one step
over. Move the invariant to where it cannot be dodged: immediately before
committing, the cut diffs its own index and refuses anything that is not
package.json or the release-mapping row. That does not care which step
staged what, or how the path was spelled.

The workflow grep stays as a cheap tripwire for literal spellings, now
paired with a positive assertion that the index guard exists and precedes
the commit — indirection cannot hide a missing guard. Mention matching
dedupes and trims quotes, since the guard names the row a second time.

* fix(release-cut): match the staged-path allowlist literally

`grep -vx` treats its patterns as regexes, so the `.` in `package.json`
matched any character: a staged `packageXjson` or a
`resources/skills/release-mappingXjson` was silently accepted by the
index guard. Verified both slip through `-vx` and are caught by `-vxF`.

Exercised the guard against a legitimate cut, an empty index, a staged
content-addressed artifact, paths containing a space and a non-ASCII
character (git quotes the latter, so it fails closed), and a staged
deletion. Only the two allowed paths pass.

* test(release-cut): assert the index guard aborts, not just that it exists

The positive assertion pinned the guard's shape and its position before
the commit, but not its effect: replacing `exit 1` with `:` left both
test files green while the cut logged the error and shipped the artifact
anyway. That is the same failure this whole gate keeps having — asserting
the shape of a defense rather than what it does.

Pin the abort too. Verified the neutered guard now fails the suite.

* test(release-cut): scope the abort check and catch clustered commit flags

Two holes in the guards this PR added, both in the same shape-not-effect
class the previous commit was meant to close.

The abort assertion's lazy match was not scoped to the guard's own block,
so it could borrow an `exit 1` from any later `if ... fi` in the step.
Degrading the guard to a warning while adding a plausible HEAD
precondition left every test green. Stop the match at the guard's `fi`.

The `commit -a` ban only matched when `a` led the flag cluster, so `-vam`,
`-va`, `-qam` and `-sam` all survived. That matters more than it looks:
`commit -a` stages at commit time, after the index guard has already
inspected a clean index, so it is the one way to defeat that guard. Match
`a` anywhere in a short-flag cluster; `--allow-empty` and `--amend` stay
allowed. Verified both mutants now fail.

* fix(release-cut): validate the commit, not the index, before tagging

The index guard asserted the wrong thing. `git commit` has a family of
forms that commit the working tree rather than the index — `-a`, `-i`,
`--only`, and a bare pathspec — so a rogue earlier step could leave
regenerated artifacts unstaged and any of those forms would carry them
into the tagged commit while the guard saw a clean index and passed.
Reproduced end to end: `git commit -i resources` put current-manifest.json
and snapshot-registry.json in the tag with all gates green, and
`--only resources` additionally dropped package.json from the tag.

Banning those flags one by one is the same enumeration game the earlier
rounds kept losing. Assert the outcome instead: after committing and
before tagging, diff-tree HEAD and refuse anything that is not
package.json or the release-mapping row. That is indifferent to which
step staged what and to how the commit was spelled.

Verified the whole family is now blocked (-i, --only, -a, -am, -vam,
pathspec, and an alias expanding to `commit -i`), that a stock commit and
an --allow-empty re-cut still pass, and that deleting, neutering,
un-anchoring, or relocating the guard each fails the suite.

* fix(release-cut): make the commit guard fail closed on a merge commit

Plain `git diff-tree` prints nothing for a merge commit, so the guard
would have passed silently instead of failing closed — the one direction
that matters on a release path. `-m --first-parent` reports the diff
against the first parent; verified byte-identical output for an ordinary
commit and still empty for the `--allow-empty` re-cut, so nothing else
changes. Not reachable today (nothing in the cut job creates a merge, and
npm version has no lifecycle hooks defined), but the failure mode is a
guard that looks like it ran.

Pin the flags in the assertion too, so neither dropping -m nor slipping in
a `--diff-filter` can weaken it without failing the suite.
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.

1 participant