Skip to content

test: promote the hand-rolled seam fault stubs into the testkit fakes - #1846

Merged
FSM1 merged 1 commit into
mainfrom
test/1297-promote-seam-fault-stubs
Sep 15, 2026
Merged

FSM1 merged 1 commit into
mainfrom
test/1297-promote-seam-fault-stubs

Conversation

@FSM1

@FSM1 FSM1 commented Sep 14, 2026

Copy link
Copy Markdown
Owner

What changed

The engine suites hand-rolled 16 seam-trait stubs across four files, for seams the testkit
already fakes. A fault mode written into one suite reached no other suite, so the set of faults
each seam is tested against was a per-file accident. This promotes every stub onto the kit's
fakes and deletes the hand-rolled copies.

New fault modes on the existing fakes:

  • InMemoryRecordStore::drop_puts — ack every PUT and retain nothing, so a confirm re-resolve
    reads no record.
  • InMemoryRecordStore::stall_gets — park every GET, the shape of a name no source answers for.
  • InMemoryFloorStore::fail_floor_commits — fail commit_floors before it touches a key, a
    transactional backing's all-or-nothing abort.
  • InMemoryFloorStore::fail_floor_raises_after — spend a raise budget, then fail every raise, so
    one leg of a multi-floor advance faults.
  • InMemoryFloorStore::skew_reported_raises — report a raise above the floor it settles on, the
    shape a non-monotonic counter would take.
  • InMemorySnapshotCache::stall_gets, serve_fixed_ciphertext and values.

New fakes:

  • SlotFillingRecordStore — one decorator for the two identical copies that filled a held-record
    slot before a delegated GET.
  • SplitWriteFloorStore — a backing with no commit_floors override, so an advance runs the
    seam's non-atomic default. This is the negative control the atomic-commit suite contrasts
    against, and it cannot be a fault mode on InMemoryFloorStore, which commits atomically.
  • ScriptedAdopter with AdoptVerdict — the scripted adoption-gate verdict plus the sequences it
    was handed.

No impl RecordTransport, impl FloorStore, impl SnapshotCache or impl Adopter remains in
crates/engine/tests/. Every assertion in the four suites stands exactly as written: the
promotion moves the fault, not the assertion.

Verification

  • cargo test -p cipherbox-engine — all suites pass, vault_settings 56, net 36, bin_index
    22, floor_atomic 3.
  • cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings.
  • cargo check -p cipherbox-wasm --target wasm32-unknown-unknown.
  • pnpm lint:tracker-refs.

Body checks / follow-ups filed

Closes #1297.

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for record adoption, floor updates, snapshot caching, and record storage.
    • Added reusable test scenarios for stalled reads, dropped writes, rejected records, simulated failures, and non-atomic updates.
    • Updated integration tests to use shared test utilities, improving consistency while preserving existing behavior and assertions.
  • Chores
    • Consolidated bespoke test implementations into common testing infrastructure, reducing duplication and simplifying future test maintenance.

Note

Promote hand-rolled test seam fault stubs into testkit fakes

  • Consolidates scattered local test fixtures into shared reusable fakes under testkit/fakes/: ScriptedAdopter, InMemoryFloorStore fault controls, InMemoryRecordStore fault controls, InMemorySnapshotCache fault controls, and SplitWriteFloorStore / SlotFillingRecordStore adapters
  • InMemoryFloorStore gains commit-failure injection, cross-key raise budgets, and reported-value skew; InMemoryRecordStore gains drop_puts (PUT succeeds but stores nothing) and stall_gets (GET parks forever); InMemorySnapshotCache gains fixed-ciphertext and GET-stalling modes
  • ScriptedAdopter provides scripted adoption verdicts (accepted, trust rejection, equal-sequence rejection) with shared sequence-observation state across cloned handles
  • Updates integration tests in bin_index.rs, floor_atomic.rs, net.rs, and vault_settings.rs to use the shared fakes, removing all local fake implementations
  • Risk: test-only change; no production behavior affected. Tests relying on local fault semantics must match the new shared controls' defaults (all faults disabled on construction)

Macroscope summarized 167e065.

…it fakes

The engine suites hand-rolled 16 seam-trait stubs across four files for
seams the testkit already fakes, so a fault mode reached one suite only
and coverage drifted per file.

The fault modes move onto the kit's fakes: a transport that acks and
discards a PUT or parks a GET, a floor store that faults a commit, spends
a raise budget or misreports a raise, and a snapshot cache that parks a
read or serves fixed ciphertext. Two decorators that filled a held-record
slot across a load become one fake, and the scripted Adopter and the
split-write floor backing join the kit. Every assertion stands unchanged.
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 920c2276-c799-4e4f-ac68-98224dab8964

📥 Commits

Reviewing files that changed from the base of the PR and between 5dcf963 and 167e065.

📒 Files selected for processing (9)
  • crates/engine/src/testkit/fakes/adopter.rs
  • crates/engine/src/testkit/fakes/floor_store.rs
  • crates/engine/src/testkit/fakes/mod.rs
  • crates/engine/src/testkit/fakes/record_store.rs
  • crates/engine/src/testkit/fakes/snapshot_cache.rs
  • crates/engine/tests/bin_index.rs
  • crates/engine/tests/floor_atomic.rs
  • crates/engine/tests/net.rs
  • crates/engine/tests/vault_settings.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

The testkit now provides shared fault-injection fakes for adopter, floor-store, record-store, and snapshot-cache seams. Engine tests replace local seam implementations with these fakes while preserving their existing assertions.

Changes

Shared engine test fakes

Layer / File(s) Summary
Scripted adopter and fake exports
crates/engine/src/testkit/fakes/adopter.rs, crates/engine/src/testkit/fakes/mod.rs
Adds ScriptedAdopter with accept, trust-violation, and equal-sequence verdicts. Exports the new adopter and store fakes.
Floor-store fault controls
crates/engine/src/testkit/fakes/floor_store.rs
Adds commit failures, bounded raise failures, skewed raise results, reset support, and SplitWriteFloorStore.
Record and snapshot fault controls
crates/engine/src/testkit/fakes/record_store.rs, crates/engine/src/testkit/fakes/snapshot_cache.rs
Adds dropped PUTs, stalled reads, slot filling, fixed ciphertext responses, stalled cache reads, and cache value inspection.
Engine test migration
crates/engine/tests/bin_index.rs, crates/engine/tests/floor_atomic.rs, crates/engine/tests/net.rs, crates/engine/tests/vault_settings.rs
Replaces local seam implementations with shared testkit fakes in engine tests.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 167e0

The shared test fakes preserve the intended fault-injection coverage without an identified behavioral regression. The change is ready to merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 81 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy #1297. Shared fakes now cover unreachable and PUT-discarding record transports, stalled GETs, unreadable and non-advancing floors, split and atomic floor writes, stalled and fixed-…
Out of Scope Changes check ✅ Passed The changes stay within #1297. The new public testkit APIs and fake implementations provide the fault modes required by the issue. The test-file edits replace duplicated seam stubs and preserve the ex…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: moving hand-rolled seam fault stubs into shared testkit fakes.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/1297-promote-seam-fault-stubs

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.

@FSM1

FSM1 commented Sep 15, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@FSM1
FSM1 marked this pull request as ready for review September 15, 2026 04:32
@FSM1
FSM1 merged commit 86177d9 into main Sep 15, 2026
32 checks passed
@FSM1
FSM1 deleted the test/1297-promote-seam-fault-stubs branch September 15, 2026 04:32
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.

test: promote the hand-rolled seam fault stubs in engine tests into the testkit fakes

1 participant