Skip to content

fix(ci): stop the bot silently discarding its own _WIT_VERSION bump - #287

Merged
robcohen merged 2 commits into
mainfrom
fix/bot-add-paths-component-engine
Aug 21, 2026
Merged

robcohen merged 2 commits into
mainfrom
fix/bot-add-paths-component-engine

Conversation

@robcohen

Copy link
Copy Markdown
Member

The bug

When the component's WIT package version changes, the gate step in update-rustledger.yml pre-applies the mechanical part of the upgrade for the human reviewer (line 100):

sed -i "s/_WIT_VERSION = \"${CUR_WIT}\"/_WIT_VERSION = \"${NEW_WIT}\"/" \
  src/rustfava/rustledger/component_engine.py

but create-pull-request was scoped to an allowlist naming only engine.py:

add-paths: |
  src/rustfava/rustledger/engine.py

component_engine.py isn't listed, so the edit is discarded. The PR body still announces it:

  • Bumped _WIT_VERSION to 3.11.0 (if it changed)

so the change reads as applied, and the reviewer's checklist item looks pre-satisfied.

Why it went unnoticed

The constant sat at 3.4.0 against a component exporting rustledger:ledger/*@3.11.0 and nothing failed, because wasmtime matches component imports on semver compatibility — a host defined at 3.4.0 satisfies an import of 3.11.0, both being major 3. Verified by substitution:

_WIT_VERSION result
3.11.0 OK
3.4.0 (what shipped) OK
4.0.0 FAIL — a matching implementation was not found
2.0.0 FAIL

So the drift is silent until a major WIT bump — which is precisely the moment the bot's pre-applied fix would be dropped again. Fixed by hand in #284.

The fix

Add component_engine.py to the allowlist.

The allowlist itself is correct and worth keeping: it exists because create-pull-request otherwise committed the workflow's working files (component.wasm, .sha256, pr-body.md), adding ~6 MB of unconsumed sdist weight per release that also went stale on manual bumps (#243). The failure mode is inherent to narrowing — every later edit becomes opt-in, and omission is silent rather than loud.

So I audited the whole workflow rather than just patching the one case. It performs exactly two in-place edits under src/:

  • line 100 → src/rustfava/rustledger/component_engine.py
  • line 125 → src/rustfava/rustledger/engine.py (via $FILE)

Both are now listed, and there are no other writes under src/. Added a comment recording that every step-edited file must be listed, since the next step to touch a new file will hit this again.

Risk

No behaviour change until the next upgrade run. YAML validated.

Not fixed here

Two further defects in the same workflow, reported in #284 and deliberately left out to keep this reviewable:

  1. ${{ steps.gate.outputs.reasons }} is interpolated into an unquoted heredoc (line 136), so backticks in the reason string are executed as command substitution — which is why the current chore: upgrade rustledger to v0.22.0 #284 body reads "WIT package version changed: -> (host bindings in likely need changes)" with both versions and the filename blanked. Fix is <<'EOF' plus injection through env:, which also closes the shell-injection surface.
  2. The body claims it "refreshed the vendored component (sha256-verified)", but nothing is vendored — src/rustfava/rustledger/*.wasm is gitignored and the component is downloaded at runtime (see Component wasm cache is version-agnostic, so a rustledger version bump silently tests against the old component #286).

Happy to fold either in if preferred.

robcohen and others added 2 commits August 21, 2026 17:58
The gate step edits component_engine.py when the component's WIT package
version changes:

    sed -i "s/_WIT_VERSION = \"${CUR_WIT}\"/.../" \
      src/rustfava/rustledger/component_engine.py

but create-pull-request's add-paths allowlist named only engine.py, so
that edit was dropped. The PR body meanwhile reports "Bumped
`_WIT_VERSION` to <new> (if it changed)", so the change looks applied.

The result was a constant pinned at 3.4.0 against a component exporting
rustledger:ledger/*@3.11.0, unnoticed across several releases because
wasmtime matches component imports on semver compatibility — a host at
3.4.0 satisfies an import of 3.11.0, both being major 3. It would first
fail at a major WIT bump, which is exactly when the bot's pre-applied
fix would have been dropped again. Fixed by hand in #284.

The allowlist itself is right: it exists because create-pull-request
otherwise committed the workflow's working files, adding ~6 MB of sdist
weight per release (#243). The failure mode is that narrowing to an
allowlist makes every later edit opt-in, and omission is silent. Audited
the whole workflow: it edits exactly two files under src/ (engine.py at
line 125, component_engine.py at line 100) and both are now listed.
Added a comment saying so, since the next step to edit a new file will
hit this again.

No behaviour change until the next upgrade run.
@robcohen
robcohen merged commit cd0ee38 into main Aug 21, 2026
32 checks passed
@robcohen
robcohen deleted the fix/bot-add-paths-component-engine branch August 21, 2026 18:24
robcohen added a commit that referenced this pull request Aug 21, 2026
Two independent silent failures found while reviewing #284/#287/#289.

1. sync-pre-commit could not parse bun.lock, and hid it.

`JSON.parse` rejected the lockfile with "Property name must be a string
literal": bun writes JSONC with trailing commas (the first is after
"web-tree-sitter" on line 34). `Bun.file().json()` is equally strict, so
there was no drop-in.

The script then swallowed the failure — `main().catch()` logged the
error and left the exit code at 0 — so `just sync-pre-commit` and the
`sync-pre-commit` package script both reported success while doing
nothing at all.

Fixed by stripping trailing commas before parsing, skipping string
literals so a comma inside a package name or version range can never be
mistaken for a structural one, and by setting `process.exitCode = 1` in
the catch. Verified: the lockfile now parses to 385 package entries
(previously it threw), a deliberately corrupted lockfile exits 1, and
the restored one exits 0.

Worth knowing: the script has nothing to rewrite today regardless. It
looks for `"name@version"` strings, and .pre-commit-config.yaml no
longer contains any — the biome hook pins a `rev:` and the only
additional_dependencies entry is unversioned. The format it targets did
exist historically. Someone should decide whether the script is still
wanted; this change at least means it will say so when it breaks.

2. The bot's "Get version" step interpolated a dispatch payload into bash.

`${{ github.event.client_payload.version }}` was pasted into the script
text before bash parsed it, which is the standard script-injection shape
— the same class as the PR-body bug fixed in #289, and here the value
arrives from a repository_dispatch payload. Moved to `env:`.

Also quotes $GITHUB_OUTPUT (the SC2086 actionlint has been reporting on
this workflow), adds `set -euo pipefail`, and fails loudly when neither
input supplies a version instead of continuing with an empty one. Reads
use `${VAR:-}` because only one of the two is populated for any given
event and `set -u` would otherwise abort on the unused one.

actionlint on this workflow now exits 0, from one finding before.
Simulated all three paths: workflow_dispatch and repository_dispatch
each resolve their version and write it to $GITHUB_OUTPUT, and the
neither-supplied case exits 1 with a message.
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