Skip to content

feat(ipsec-xfrm): supervise cancellation-safe single-object installs#513

Merged
VerifiedOrganic merged 2 commits into
mainfrom
feat/409-supervised-installs
Jul 24, 2026
Merged

feat(ipsec-xfrm): supervise cancellation-safe single-object installs#513
VerifiedOrganic merged 2 commits into
mainfrom
feat/409-supervised-installs

Conversation

@VerifiedOrganic

@VerifiedOrganic VerifiedOrganic commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #409. Generalizes the #403 staged journal so single-object XFRM installs — SA-only (reusing a shared policy) and policy-only (an additional direction for one SA) — get the same cancellation-safe ownership supervision as the SA+policy composite, without inventing dummy companion mutations.

  • XfrmStagedObjectInstall: affine one-run staged value; on first poll spawns an owned Tokio worker, so dropping the caller's future at any await leaves the worker and claim live until the backend result is observed. Dropping an unpolled install performs no mutation (compile-fail doctest proves one-run affinity).
  • XfrmObjectInstallJournal (caller-cloned): NotStarted / InstallInFlight / Acquired / Recovering / Recovered / Committed / Indeterminate{op} / SupervisionLost{op}. Worker panic or runtime loss flips SupervisionLost and permanently blocks in-process commit/recovery — later quiescence of the detached mutation cannot forge supervised completion.
  • Exact identity, never broadened: removal candidates are derived field-for-field identically to the composite rollback helpers (SA: destination/protocol/SPI+mark; policy: selector/direction+mark). AlreadyExists — observed or unobserved-then-rejected — clears the candidate, so a pre-existing object is never authorized for deletion.
  • Generation-bound classified recovery: recovery removes only an exact object classified Owned; Absent and Foreign retire without any backend mutation; the classification goes stale on any journal state change (Arc generation rotation, ABA-immune); StateIndeterminate requires explicit classified readback first. Dropping a recovery observer keeps the claim while removal is live; concurrent recovery attempts converge to exactly one backend call.
  • Redaction-safe: manual label-only Debug on every identity-bearing type (34-surface canary probe: keys, addresses, selectors, SPIs — zero leaks).

Fully additive: no changes to staged.rs or any existing API.

Testing

26 new tests (281 crate total) with gated fake backends covering every acceptance bullet: unpolled-drop no-mutation, dropped-observer worker liveness, AlreadyExists non-removal (observed + unobserved), commit of acknowledged acquisition, classified-readback gating, exact-Owned-only removal, Absent/Foreign non-deletion, dropped-recovery claim retention, panicked-worker and runtime-shutdown supervision loss (install AND recovery), mark-carrying identity derivation, runtime-free typed failures, and full redaction.

Review

Two-lane adversarial review, both SHIP:

  • Spec lane: fix(ipsec-xfrm): make composite install cancellation ownership explicit #403 semantic parity verified line-by-line; all 15 journal mutation sites generation-touching; compile-fail doctest verified for the right reason (E0382); 34-surface redaction probe clean.
  • Runtime lane: 20 flake-free runs; abort storms at every reachable await point; runtime shutdown mid-install and worker termination mid-install and mid-recovery; 8-way recover races; commit/recover exclusivity; generation ABA immunity. No wedges, no silent mislabeling.
  • Post-review additions: mark-identity byte-exact fixtures and the runtime-unavailable test (second commit).

…409)

Add XfrmStagedObjectInstall, the single-object counterpart of the
composite staged install, for exact SA-only and policy-only installs
that cannot use the SA-plus-policy composite: an SA that intentionally
reuses an existing shared policy, or an additional policy direction for
one SA.

The typed XfrmObjectInstallRequest supervises one backend operation
without inventing a dummy companion mutation and preserves the staged
boundary properties: affine one-run execution with a caller-retained
XfrmObjectInstallJournal, an owned Tokio worker after first poll,
explicit issued, acknowledged, rejected, indeterminate, committed,
recovered, and supervision-lost ownership states, and generation-bound
classified recovery of the exact retained removal candidate under
caller-held writer exclusion. An observed AlreadyExists rejection
authorizes no removal of the pre-existing object, and runtime or worker
loss permanently disables in-process commit and recovery.

Signed-off-by: VerifiedOrganic <verifiedorganic@sent.com>
)

Assert the staged single-object removal identity preserves the Linux
XFRM lookup mark for SA-only and policy-only installs, byte-exact
against the expected removal request end to end through classified
recovery.

Exercise run and recover first polled outside a Tokio runtime: both
return the typed RuntimeUnavailable error and leave the journal
unpoisoned, with plan generation and ownership provably unchanged.

Signed-off-by: VerifiedOrganic <verifiedorganic@sent.com>
@VerifiedOrganic
VerifiedOrganic merged commit 883e21b into main Jul 24, 2026
22 checks passed
@VerifiedOrganic
VerifiedOrganic deleted the feat/409-supervised-installs branch July 24, 2026 03:20
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.

feat(ipsec-xfrm): supervise cancellation-safe single-object installs

1 participant