Skip to content

repair: opt-in ForeignPolicy::Hold keeps a fold on a foreign incarnation - #55

Merged
jaredLunde merged 5 commits into
mainfrom
cp-b-slip-hold
Nov 29, 2026
Merged

jaredLunde merged 5 commits into
mainfrom
cp-b-slip-hold

Conversation

@jaredLunde

@jaredLunde jaredLunde commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

A consumer whose fold is the only full copy loses it when its bucket is deleted and recreated: the foreign-cursor repair deletes every key the new stream lacks.

  • BatchConfig::on_foreign: ForeignPolicy::{Repair (default, unchanged), Hold}.
  • Under Hold the watch ends with KvError::Foreign { old_incarnation, new_incarnation }; no key is deleted or overwritten, and the fold stays complete at its old cursor.
  • WatchCursor::adopt_incarnation(new) is the resume cursor that re-anchors the fold on the new stream. From then on it folds normally, and keys the new stream deletes are deleted. Keys it never wrote stay: removing them is the caller's job.
  • The decision is the pure kernel protocol::foreign_action, called by repair::run_watch. Proven in Verus in protocol.rs and hold_proofs.rs. Mutants: mut_hold_repairs, mut_repair_holds, mut_adopt_unrecorded.
  • Live tests in tests/recreated_stream.rs run against a real nats-server.
  • ARCHITECTURE.md is updated. No release is cut.

🤖 Generated with Claude Code

Note: the no-write-before-return half of Hold is a capability-style structure pin (tests/hold_structure.rs: a source check with fixture mutants), not a Verus property.

jaredLunde and others added 5 commits November 29, 2026 07:06
…ion; adopt_incarnation re-anchors it

A fold that is the only full copy (its consumer is the bucket's only writer) is
destroyed by the foreign-cursor repair: the new stream starts empty and the
key-listing diff deletes every key it lacks. BatchConfig::on_foreign chooses:
Repair (default, unchanged) or Hold, under which the watch ends with the typed
KvError::Foreign { old_incarnation, new_incarnation } and never touches the fold.
WatchCursor::adopt_incarnation(new) resumes on the new stream afterwards.

The decision is protocol::foreign_action, proven in Verus with hold_proofs.rs;
mutants mut_hold_repairs, mut_repair_holds, mut_adopt_unrecorded go red.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… a structure pin; drop circular proofs

- adopt_incarnation is an order: run_watch repairs the fold to the new stream's listing (the repair Hold deferred) before following it, so the fold is the new stream and exports no phantom key.
- Delete hold_proofs.rs (its lemmas restated their premise); the no-write half is tests/hold_structure.rs with fixture mutants.
- Live tests: export after adoption, second recreate, stale adoption. Document known limits.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…aking; default unchanged)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@jaredLunde
jaredLunde merged commit 4edadab into main Nov 29, 2026
2 checks passed
@jaredLunde
jaredLunde deleted the cp-b-slip-hold branch November 29, 2026 16:19
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