Relationships
#215 Adversarial UAT test: missing cached bundle with intact catalog should self-recover
Opened by keeb · 5/2/2026
Problem
After PR systeminit/swamp#1288 (fix for swamp-club#212), swamp now self-heals when a cached bundle file under .swamp/bundles/<hash>/<name>.js is deleted while the catalog row in .swamp/_extension_catalog.db still references it. The fix is verified by unit and integration tests inside the swamp repo, but there is no end-to-end coverage in systeminit/swamp-uat exercising the recovery from a real CLI invocation.
The natural home for this test is systeminit/swamp-uat/tests/cli/adversarial/state_corruption_test.ts — that file already covers other "broken on-disk state" scenarios (datastore lock state, partial writes, etc.), and a missing-bundle row is exactly that genre.
Proposed solution
Add an adversarial UAT test that:
- Initializes a swamp repo and writes a small user model under
extensions/models/<x>.ts. - Runs
swamp model type describe @user/<x>to populate the catalog and write the bundle. - Asserts the bundle file exists at the expected
.swamp/bundles/<hash>/<x>.jspath. rms the bundle file with the catalog DB intact.- Runs the same
swamp model type describeagain. - Asserts:
- Exit code 0 (was previously non-zero with
NotFound: No such file or directory). - Stderr contains the recovery warn line (
Rebundling "<x>.ts": cached bundle missing from disk) emitted bybundle_freshness. - The bundle file is back on disk.
- The describe output still surfaces the type/version/methods correctly.
- Exit code 0 (was previously non-zero with
Optionally pair with a sibling-loader variant once swamp-club#214 lands (the import-site fallback for datastore/driver/vault/report).
Alternatives
- Leave coverage at the unit/integration layer in the swamp repo. Rejected: this is exactly the kind of "filesystem state that diverges from catalog state" scenario the adversarial suite exists to catch end-to-end. The unit tests inside swamp can't verify the full CLI path including the warn log routing or the user-visible exit behavior.
- File against a different test file. Rejected:
state_corruption_test.tsis the right home — closer to the existing concurrency/state-corruption neighbors than to the per-command CLI tests.
Context
- Fixes in swamp-club#212 / systeminit/swamp PR #1288.
- Related: future swamp-club#214 (sibling-loader port).
- Convention reference:
systeminit/swamp/agent-constraints/planning-conventions.md§UAT — assesses each fix for end-to-end coverage gaps and recommends filing inswamp-uat.
Closed
No activity in this phase yet.
stack72 commented 5/6/2026, 10:38:04 PM
Handled as part of the refactor of extensions
stack72 commented 5/7/2026, 10:31:17 PM
Closing — moved to swamp-uat as the test target.
The UAT scenario this issue requested ("missing cached bundle with intact catalog should self-recover across all 5 extension kinds") now lives at systeminit/swamp-uat#200.
W4 (swamp-club#269 — KindAdapter + unified loader) will verify against the swamp-uat scenario as part of its soak gates. Pre-W4, the scenario passes for model only (per PR #1288 / swamp-club#212). Post-W4, it must pass for all 5 kinds (model, vault, driver, datastore, report) — that's the structural fix W4's unified importBundleByPath ENOENT fallback provides.
Pattern going forward: Lab issues that request UAT tests get moved to swamp-uat (where the tests live) and closed here. The Lab tracks swamp itself; swamp-uat tracks user-journey verification.
Thanks for surfacing this — it's the test that closes the structural-fix verification loop for the rebundle-loop bug class.
Sign in to post a ripple.