feat(economic): the DlvOwnerApplyV2 write set and the 0x0027 settlement-payment arm — 3.6 PR4 - #744
Merged
Conversation
…nt-payment arm — 3.6 PR4 The owner's apply: a reserve-only write set (input leg gains, output leg pays out, both parent -> parent+1; no balance movement — the fee accrues inside the reserves as LP yield) mirroring the device-state ApplySettlement rules exactly: the output leg must EXIST at the consumed parent and cover the payout, the input leg may be first-time or must share the parent generation, a zero reserve stays PRESENT. Non-reuse is the reserve-sequence Merkle CAS — after the first apply the pre-state at the parent no longer exists in the owner's validated lineage — so there is no consumed-source leaf. The 0x0027 arm, conjunctive: the verified operation (derived inside advance_validated, never caller-supplied) must be the DlvOwnerApplyV2; descriptor coordinates equal the operation's; the TRADER's economic root VALIDATED at the descriptor's untrusted locator position; the evidence bundle (SettlementPaymentEvidenceV1 — the trader's receipt leaf + its 256-sibling witness, transport proto, no CCB class) re-hashes to the descriptor's address; the receipt states THIS apply's exact settlement field for field (x, sequences, assets, amounts) and proves INCLUDED under the trader's validated root at the trader's own leaf key. Funded = the receipt-keyed source id over the input asset/amount. Tests (economic_dlv_owner_apply_provenance, 8): the honest path over the REAL builder; the second-apply reserve-CAS refusal at build; trader root lacking the receipt (arm-mutation-verified); field-by-field op<->receipt cross-checks (arm-mutation-verified); balances-moving witness refused; non-unit generation step refused at derivation; tampered evidence bytes refused by address; an unresolvable trader lineage fails closed as Incomplete. The write-set deferred-honestly tripwire fired on schedule and is re-cut in-PR: the_dlv_value_write_sets_demand_their_facts. Boards on the final tree (pinned 1.98.0): workspace 3896/0 across 71 suites exit 0; node 270/0 exit 0; make lint exit 0; production_safety_checks exit 0; repo-root clippy exit 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
3.6 PR4 — the DlvOwnerApplyV2 write set and the 0x0027 settlement-payment arm
Fourth PR of the 3.6 series: the owner's apply now has its complete economic story — the reserve-only write set, and the provenance arm sourcing the input-reserve credit from the trader's ALREADY-ADMITTED settlement payment. With this, all four DLV value operations have foreign-verifiable write sets; PR5/PR6 wire the routes through admission.
The
DlvOwnerApplyV2write setSemanticWriteSet::DlvOwnerApply: reserve[input] gainsinput_amount, reserve[output] losesoutput_amount, both advancingparent → parent+1; no balance movement (the fee accrues inside the reserves as LP yield). Builder rules mirror the device-stateApplySettlementarm exactly: the output leg must EXIST at the consumed parent generation and cover the payout; the input leg may be first-time or must share the parent generation; a zero output reserve stays PRESENT. Non-reuse is the reserve-sequence Merkle CAS — after the first apply, the pre-state atparentno longer exists in the owner's validated lineage — so there is no consumed-source leaf andrequires_consumed_source_recordis unchanged.CreditSourceFacts::DlvSettlementPayment { trader_genesis, trader_devid, trader_economic_position, payment_evidence_addr }— every other coordinate is read from the operation.The evidence bundle (
SettlementPaymentEvidenceV1, transport proto — no CCB class)The trader's settlement-receipt leaf plus its 256-sibling inclusion witness. Strict decode (canonical re-encode equality, exact arity/widths); the receipt state decodes through the validating constructor, which re-derives
receipt_idfrom(vault, x)and enforces the sequence/amount/asset rules before the arm sees it.The 0x0027 arm (
verify_credit_source), conjunctivectx.verified_operation(derived insideadvance_validated, never caller-supplied) must be theDlvOwnerApplyV2; descriptor coordinates(vault, receipt_id, parent)equal the operation's.x == pending_pointer_x, both sequences, both assets, both amounts.FundedCredit { source_id = H(vault ‖ receipt_id), input asset, input amount }— the common tail then enforces exact equality against the funded input-reserve credit.Registry (from PR1's schema-2 burn): 0x0027 carries
trader_economic_position— untrusted locator, never authority. New domain tags: the 0x0027 SourceId and the evidence namespace.Tests (
economic_dlv_owner_apply_provenance.rs, 8)a_real_owner_apply_funds_from_the_traders_admitted_payment— the honest path, write set built by the REAL builder over a real reserve pre-state.a_second_apply_of_the_same_receipt_is_refused_by_the_reserve_cas(MC-APPLY-1) — the same apply against the post-state pre-map fails its own generation precondition at build.a_trader_root_lacking_the_receipt_is_refused(MC-APPLY-2, arm-mutation-verified: neutralizing the inclusion equality turns it red).x, receipt id — arm-mutation-verified: neutralizing the receipt-equality conjunct turns them red).a_witness_moving_balances_is_not_an_apply(MC-APPLY-4);a_non_unit_generation_step_is_refused_at_derivation(MC-APPLY-5); tampered evidence bytes refused by address; an unresolvable trader lineage fails closed asIncomplete(an outage is never an attack).the_dlv_value_write_sets_demand_their_facts— both heavy ops now demand their facts; nothing is deferred.Boards (exact CI commands, final tree, pinned 1.98.0)
cargo test --locked --workspace --exclude dsm_storage_node -- --nocapture --test-threads=1— 3896 passed / 0 failed across 71 suites (dsm lib 1675/0, dsm_sdk lib 1792/0 + 7 ignored), exit 0cargo test --locked -p dsm_storage_node --no-default-features --features local-dev,strict -- --nocapture— 270 passed / 0 failed, exit 0make lint(repo root) — exit 0; pinned repo-rootcargo clippy --all-targets— exit 0bash ci/production_safety_checks.sh— exit 0Next (PR5):
feat/dlv-create-close-admission-cutover— the create/close routes wired throughAdmissionPlan, then PR6 (settle/apply cutover with the pre-slot/post-slot split and the q-durable foreign closure), then the live 2-of-3 frontier walk completes the sovereign-finance track (per the 2026-08-29 scope ruling).