Skip to content

feat(2c-D): C2 — the realization and fence-release cutover - #856

Merged
cryptskii merged 2 commits into
mainfrom
feat/2c-d-realization-cutover
Sep 11, 2026
Merged

feat(2c-D): C2 — the realization and fence-release cutover#856
cryptskii merged 2 commits into
mainfrom
feat/2c-d-realization-cutover

Conversation

@cryptskii

Copy link
Copy Markdown
Collaborator

2c-D C2 — the realization and fence-release cutover

C2 is the realization / fence-release cutover. Implements amendment 2c-D §14 (owner rulings C2-R1 and C2-R2, frozen verbatim in the first commit). A market settlement is now realized end to end on the live route, and nothing short of the complete certification predicate opens a market boundary.

bind (QuorumBind COMMIT — authoritative throughout)
  -> trader advance, admitted; TA_B + locator published
  -> compose with the locally built V1 as Req 21.16 EVIDENCE
  -> a fold that may_certify() for exactly b
       correspondence (CORR.1-5, CORR.4 typed) + §7 BundleAcceptanceWitness
       + Tier-1 intent satisfaction (2c-E SAT.1-6) + Req 21.16 under R_T^+
  -> freeze V1 for the vault's set, sweep, require QUORUM publication
  -> SuccessorAccepted at the fence the binding placed

dlv.unlockRouted answers realized:<b> or bound-unrealized:<b>. Missing, unavailable, or below-quorum evidence leaves the settlement bound and unrealized with the fence held; present-and-failing evidence is INVALID. There is no timeout release, no fallback realization path, no receipt-as-authority shortcut, and no second way to build a BundleAcceptanceWitness.

What changed

  • Walk — certifies market folds and folds nothing that fails may_certify(). The 5-c-1 MarketRealization path is deleted.
  • Owner applydlv.reconcile and unapplied_settlements_for_vault act only on the exact certified fold (C2-R1 point 6); the request names (vault, x) and every applied fact comes from the fold.
  • Receipt codec — transport only: fetch_receipt -> Absent / Unavailable / Malformed / Decoded (point 8).
  • DeletedPartialPendingRealization + may_fold() (their only constructor was 5-c-1; class() is now total), verify_trader_settlement_receipt + the two ReceiptError variants only it produced, the legacy fetch_verified_receipt, and the bind-only settle fixture that bypassed completion.
  • LocatorTraderAcceptanceLocatorV1 (proto) locates TA_B by b; non-authoritative (D-c).

Required controls (PR C ruling) -> named tests

Control Test(s)
happy path: bound -> accepted -> TA_B -> receipt -> realized -> released a_settled_market_publishes_its_acceptance_and_realizes, a_routed_settle_clears_every_gate_and_realizes, a_foreign_trader_clears_every_gate_and_realizes_its_settlement
missing TA_B a_legacy_receipt_alone_does_not_realize_a_market_bundle
altered / malformed TA_B a_present_but_malformed_acceptance_locator_is_invalid_not_absent; truncated_or_trailing_bytes_are_not_an_acceptance, a_nested_leaf_of_another_class_is_refused, decoded_bytes_meet_the_frozen_rejections
wrong b an_acceptance_for_another_bundle_is_refused
wrong acceptance path a_path_that_folds_elsewhere_is_refused
wrong economic_operation_id an_acceptance_naming_another_economic_operation_is_refused (new: the leaf sits where this operation's leaf belongs, so only §7 step 5's identity equality can refuse it)
correct TA_B, wrong receipt path an_altered_path_is_refused, the_receipts_own_device_path_is_not_evidence
receipt path folding to the wrong root a_path_checked_against_another_validated_root_is_refused, a_self_rooted_receipt_is_refused_though_its_own_device_path_proves_it
ordinary DSM advancement cannot release the fence a_settlement_whose_receipt_misses_quorum_stays_bound_and_keeps_its_fence
realization before witness unreachable compile_fail doctests on CompleteValidity; the_acceptance_witness_has_exactly_one_construction_site
duplicate/conflicting binding finality quarantine unchanged duplicate_binding_finality_quarantines_the_lineage_with_all_five_effects
owner-apply boundary (C2-R2 note) an_owner_apply_applies_only_the_exact_certified_fold
rival on a committed, unrealized parent a_rival_settle_on_a_committed_parent_is_excluded_and_changes_nothing

Mutation controls

Each control deletes or bypasses ONE gate, runs the named test that must go red by performing the forbidden action, then restores the file from a byte copy and verifies the restore with cmp. All observed RED, all restored.

# Gate removed Named test observed RED
MC1 CORR.4 amount equality (leg_delta_out == output_amount) effects_that_are_not_the_routes_economics_do_not_correspond
MC2 CORR.4 fee equality effects_that_are_not_the_routes_economics_do_not_correspond
MC3 market orientation (foreign / same-side assets reach derivation) only_the_vaults_own_pair_in_a_permitted_orientation_is_tradable
MC4 SAT.2 RouteCommit signer == independently proven trader key a_route_commit_signed_by_anyone_else_is_not_the_traders_intent
MC5 SAT.4 selected route leg == signed hop a_route_that_is_not_the_signed_hop_is_refused
MA6 §7 three-way economic_operation_id equality an_acceptance_naming_another_economic_operation_is_refused
MS1 receipt publication at quorum before fence release (completion) a_settlement_whose_receipt_misses_quorum_stays_bound_and_keeps_its_fence
MD1 receipt publication before fence release (D-f resume) a_completion_that_missed_quorum_is_finished_by_resuming_the_same_settlement
MS2 owner apply consumes only the exact certified fold an_owner_apply_applies_only_the_exact_certified_fold
MG1 reserve-provenance preflight before bind_settlement a_deterministic_provenance_failure_is_refused_before_binding
MG2 composed history must end at exactly the parent a_successor_missing_from_the_certified_history_authorizes_nothing
MG3 composed history advances one generation at a time a_skipped_generation_is_refused
MG4 each composed state names its predecessor as parent a_wrong_parent_state_commitment_is_refused
MG5 the baseline's reserves equal the owner's backing altered_reserves_are_refused

MS1 and MD1 exercise the one shared requirement in complete_settlement from its two callers.

D-f — completion resumes, it never retries

resume_settlement_completion finishes the SAME bound, advanced settlement whose receipt missed quorum: it re-reads the fence at exactly (chain, parent, tx_id), fetches the bound bundle by b and re-hashes it, requires the bundle's own parent and successor to be the fence's, takes the trade from the bound operation, and runs the one completion path (recover the exact frozen V1 or build it once → re-certify → quorum → exact release). No binding round, transition, admission or new settlement; never a cached-status or timeout release. Run from storage sync beside the close-intent resume.

D-f test Proves
a_completion_that_missed_quorum_is_finished_by_resuming_the_same_settlement (a) below quorum: bound, fence held, a resume releases nothing, a rival is excluded; (b) healed: resume re-certifies, the exact receipt reaches quorum, the exact fence releases; no bind round, no transition/admission, every PUT is the receipt; a second pass is a no-op
a_receipt_published_before_the_release_is_verified_and_the_same_fence_released (c) crash after publication, before release: the durable receipt is verified, not re-sent, and the exact fence releases
a_resume_at_altered_coordinates_refuses_and_holds_the_fence (d) altered b/tx_id, parent, chain, bundle address, successor (and so operation id), or receipt facts: refused, fence held, nothing published
an_uncertified_settlement_cannot_be_resumed_into_a_release (e) a genuine settlement whose acceptance is not discoverable: resume is pending, fence held, no receipt frozen, owner has nothing to apply
a_bypass_settlement_cannot_realize_owner_apply_or_release_its_fence the explicit uncertified bypass path (bind + raw advance + signed legacy receipt) cannot realize, owner-apply or release

D-g — later generations draw reserve provenance from the composed frontier (conformance repair)

lp_offline exposed that DlvReserveConsumption provenance accepted only owner reserve leaves at exactly the consumed generation — produced only by the owner's own admitted apply — so no delegated market could pass generation 0 with its LP away, contrary to the SoFi composed-state model. The deleted bypass fixture had hidden it. The same rule now holds at every generation (dsm::dlv::composed_history::check_composed_reserve_provenance): the owner's proof backs ONE baseline generation g; at g the parent states exactly those reserves; past g the parent must be exactly the composed state at its commitment, reached from that baseline through certified, linked, consecutive successors. No wire change, no new witness; owner catch-up stays optional synchronization.

Non-circularity. Composition for provenance stops AT the requested state and never reads its binding (FrontierBinding::NotObserved). Certifying settlement n establishes V_{n+1}; admitting settlement n+1 consumes it by composing up to c_{n+1}, which certifies only settlements < n+1. The recursion runs strictly down the generations.

Bind-before-knowable-failure, fixed. The route used to bind first and only then learn that admission would refuse, stranding the generation. It now runs the same rule, over the same owner proof and composed history, BEFORE bind_settlement.

Composed-state control Test
gen 0 from the owner baseline the_baseline_generation_is_provenanced_by_the_owners_leaves_alone
gens 1 and 2 with the LP absent later_generations_are_provenanced_by_the_composed_history_with_the_lp_absent; lp_offline_market_advances_three_generations_and_lp_reconciles_each_once (route, three certified generations, no owner action between)
uncertified predecessor authorizes nothing a_successor_missing_from_the_certified_history_authorizes_nothing
wrong / skipped generation a_wrong_generation_is_refused, a_skipped_generation_is_refused; route probes in lp_offline
wrong parent_state_commitment a_wrong_parent_state_commitment_is_refused
altered reserves / owner backing altered_reserves_are_refused
stale parent after a later successor lp_offline probe-behind (refused at the composed frontier; the register's exclusivity is the authority)
deterministic failure before bind a_deterministic_provenance_failure_is_refused_before_binding

Known and recorded

  • The Def 14.2 receipt and Q publication remain separately owed (C2-R1 point 9); V1 does not satisfy them.
  • The frontend names the dlv.unlockRouted result vaultIdBase32; it has carried <status>:<b> since 5c-2 Step 4. Filed as a separate task, untouched here.

Verification

Toolchain pinned 1.98.0. Targeted, per edited module (the board runs in CI):

  • dsm lib, targeted modules (composed_history, provenance, peer_lineage, successor_validity, published_receipt, settlement_receipt_leaf, acceptance_verify): 75/0; dlv::composed_history after the gap-test strengthening: 9/0
  • dsm doctests (successor_validity, incl. the compile_fail guards): 6/0
  • dsm integration: economic_dlv_settle_provenance 16/0, economic_admission_lifecycle 18/0, economic_dlv_owner_apply_provenance 8/0, economic_peer_evidence 9/0, economic_provenance_semantics 9/0, trader_acceptance_producer 9/0, economic_provenance_wire 18/0
  • dsm_sdk lib: codec, walk, locator, fence table, economic registers and every settle-dependent route test, incl. lp_offline (three certified generations, LP offline) and all D-f / preflight / bypass controls: 58/0
  • mutation controls: 14/14 RED, restored, cmp-verified
  • cargo fmt --all -- --check: clean
  • make lint: exit 0 (fmt --check + clippy --all-targets, pinned 1.98.0)
  • ci/production_safety_checks.sh: exit 0 (clippy production safety checks + TLA+ formal verification passed)

…r determined

Adds 2c-D §14 before the live path changes: the survey of what the cutover
touches, owner ruling C2-R1 (post-certification receipt handling) and C2-R2
(CORR.4 typed, the orientation requirement, Tier-1 intent satisfaction)
verbatim, the owner-apply boundary, and the determinations made under them:

- D-a  Tier 1 is re-sourced as 2c-E §6 SAT.1-SAT.6; the 5-c-1 gate C2 deletes
       was its only enforcement point.
- D-b  "durably published" is quorum publication of a frozen artifact.
- D-c  TA_B is located through a non-authoritative locator keyed by b.
- D-d  PartialPendingRealization is deleted with its only constructor.
- D-e  the self-referential receipt verifier is deleted; Req 21.16 is the
       only receipt verifier.
- D-f  the completion resumes and never retries: the SAME bound, advanced
       settlement is re-certified, its exact receipt published at quorum, and
       its exact fence released — no bind round, transition or admission.
- D-g  conformance repair: later generations draw reserve provenance from the
       composed DLV frontier (owner baseline + certified successors), as the
       SoFi model requires, and the route preflights that rule before binding.
Implements 2c-D §14 (owner rulings C2-R1 and C2-R2, frozen in the preceding
docs commit). A market settlement is now realized end to end on the live route:

  preflight reserve provenance       (the same rule admission applies)
  -> bind -> trader advance, admitted; TA_B + locator published
  -> compose with the locally built V1 as Req 21.16 EVIDENCE
  -> a fold that may_certify() for exactly b
  -> freeze V1 for the vault's set, sweep, require quorum publication
  -> SuccessorAccepted at the fence the binding placed

The route answers `realized:<b>` or `bound-unrealized:<b>`. Anything short of a
certified fold plus quorum publication leaves the settlement bound and
unrealized with the fence held; the QuorumBind COMMIT stays authoritative.

Core (dsm):
- successor_validity: CORR.4 typed one equality per field; orientation before
  any derivation; the accepted market successor derived from the
  lineage-verified DlvSettle; Tier-1 intent satisfaction (2c-E SAT.1-SAT.6)
  re-sourced into the walk (D-a). IndependentRealization::from_parts takes
  correspondence, the §7 BundleAcceptanceWitness and IntentSatisfaction.
- PartialPendingRealization and may_fold() deleted with their only
  constructor; C3Verdict::class() is total (D-d).
- verify_trader_settlement_receipt deleted with the two ReceiptError variants
  only it produced (D-e). Req 21.16 is the only receipt verifier.
- dlv::composed_history: the SoFi composed-state rule as reserve provenance
  (D-g, conformance repair). DlvReserveConsumption provenance accepted only
  owner reserve leaves at exactly the consumed generation, which only the
  owner's own apply produces, so no delegated market could pass generation 0
  with its LP away. Now: owner leaves back ONE baseline generation; past it,
  V_n must be exactly the composed state at c_n, reached from that baseline
  through certified, linked, consecutive successors. The history comes from a
  resolver method that fails closed by default.
- decode_trader_acceptance; ValidatedPeerTransition carries embedded_parent.

SDK (dsm_sdk):
- the composition walk certifies market folds and folds nothing that fails
  may_certify(); the 5-c-1 MarketRealization path is deleted. It can compose
  UP TO a requested state without reading its binding (NotObserved), which
  keeps the provenance of settlement n from depending on settlement n.
- complete_settlement: the one completion path — recover the exact frozen V1
  or build it once, certify, publish at quorum, release exactly, idempotent.
- D-f: resume_settlement_completion finishes the SAME bound, advanced
  settlement from its fence row and re-hashed bundle; run from storage sync.
  No binding round, transition, admission or new settlement.
- the settle route preflights reserve provenance BEFORE bind_settlement with
  the same rule, so a trade admission would refuse never strands a generation.
- TA_B is located by b through a non-authoritative locator (D-c).
- settlement_receipt_codec is transport only (C2-R1 point 8).
- dlv.reconcile and unapplied_settlements_for_vault act only on the exact
  certified fold (C2-R1 point 6).
- the walk's local receipt candidate is used only for its own settlement.

Tests: settle-dependent route tests drive realization through the route; the
admission-skipping fixture is kept only as an explicit uncertified bypass for a
negative test; lp_offline proves three generations realize with the LP absent;
new controls for D-f (a)-(e), the owner-apply boundary, a receipt below quorum,
the pre-bind refusal, and the composed-state rule (b-h).
@cryptskii
cryptskii merged commit e58340c into main Sep 11, 2026
18 of 19 checks passed
@cryptskii
cryptskii deleted the feat/2c-d-realization-cutover branch September 11, 2026 06:34
cryptskii added a commit that referenced this pull request Sep 11, 2026
…venance, and a walk that folds only what certifies (#857)

C2 (#856) changed three things the Lean tree did not yet say. This brings the
models to the code, as the formal models are kept alongside it.

- DSMSettlementCompletion.lean (new, 17th module): the one completion pass the
  settle route and D-f's resume share. Proves the fence is released only after
  the exact receipt is at quorum and only in a certifiable pass; below quorum
  or uncertified it stays held; a receipt already at quorum is verified, not
  re-sent; a second pass changes nothing; a pass never changes b or the
  permitted successor.
- DSMComposedReserveProvenance.lean (new, 18th module): D-g's rule — owner
  backing at one baseline generation, and past it a parent that is exactly the
  last state of a linked, consecutive history from that baseline. Proves
  soundness, that each conjunct is necessary, and that composition for
  provenance stops AT its target, so provenance of generation n never reads
  the state the settlement consuming n produces.
- DSMAcceptedSuccessorWalk.lean: partialPendingRealization deleted (D-d). The
  walk folds exactly what certifies; a market successor without the 2c-D
  witness is not folded, and with it certifies.
- DSMBundleAcceptance.lean: the banner no longer says fence release and
  Req 21.16 are owed.
- CI: the Lean module pin moves 16 -> 18.
- 2c-D §14: D-f and D-g name the modules that machine-check them.

Mutation controls executed: seven, each with the kernel proving the named
sample theorem false, each reverted and cmp-verified.
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