CMP-0.8 — Vault funding, verified settlement and payer-bound refunds¶
Status: PROTOCOL SPECIFICATION ONLY. No new executable ComputeMarket Vault adapter, deployment, funded CMP transaction, paid worker, settlement or dedicated contract tests are introduced. Authority: frozen ComputeMarket V1 architecture, CMP-0 overview, CMP-0.2 job schema, CMP-0.3 units, CMP-0.4 manifest, CMP-0.5 identities, CMP-0.6 matching, and CMP-0.7 lifecycle. CMP remains provider-neutral and registry-resolved after deployment, code-hash verification and authorized publication; it creates no fixed Genesis predeploy or new unrestricted escrow.
1. Verified source boundaries — what the existing Vault actually does¶
The checked-in AssetVault420.sol supports depositNative, createObligation, releaseObligation, cancelObligation, claim and withdraw, each with its own state, authorization and replay rules. VaultAccounting420.sol records aggregate recordedBalance, reserved, claimable, released and an immutable obligation (vaultId, asset, beneficiary, amount, obligationType, sourceRef) once created. depositNative() credits vault-wide accounting, not a caller-specific payer deposit ledger. createObligation takes an authorized caller and reserves against the vault-wide free balance: it does not prove which payer supplied that amount. releaseObligation changes a pending obligation into a claimable obligation for its already recorded beneficiary; it is not an external transfer. claim sends the entire claimable amount to that recorded beneficiary. cancelObligation returns a pending amount to vault-wide internal free balance, without crediting the original payer or transferring to the payer's wallet. withdraw draws against vault-wide free balance with self or asset/recipient/action route authorization; a generic withdrawal right cannot, by itself, prove ownership of a cancelled CMP job's balance.
Consequently a shared pooled Vault with the present accounting interface is not sufficient on its own for payer attribution and partial per-job earning/refund: it lacks a per-payer deposit balance, beneficiary change, obligation splitting and a payer-specific cancelled-obligation credit. Do not claim that a successful depositNative, cancelObligation, releaseObligation or withdraw proves the complete CMP economics. An approved CMP-specific adapter must establish segregated payer-backed credits and enforce every liability below with auditable state and atomic authorized routing, or use independently deployed, verified and registered payer-isolated Vault instances and still prove claim/refund isolation. Any needed Vault primitive or adapter extension is a future audited implementation decision, not a feature asserted to exist. Avoid using a single provider-beneficiary obligation to represent the entire deposit before correctness is established: its unconditional release would make unearned funds claimable.
2. Canonical payer and obligation model¶
Use native $420 (address(0)) at Genesis. At requester-authorized funding, bind chainId, verified Vault registry/vault/adapter version and code hash, jobId, requestId, immutable payer principal and approved refund destination rule, deposited amount, payer-owned funded-credit reference, maximum authorized spend, funding nonce, asset, and funding evidence. A delegate may fund or initiate withdrawal only under a separately validated object-, destination- and amount-bounded capability; a transaction sender, relayer, scheduler, administrator or provider does not become the payer merely by calling the adapter. The accepted provider beneficiary/reference is established solely by the canonical CMP-0.6 match and must not be replaceable by the funding caller or a later provider account rotation.
Track per-job deposited, committed, earnedVerified, paidOrClaimable, payerRefundClaimable, payerRefundPaid, disputedHeld, feeCommitted, and unusedUnallocated with clearly defined nonoverlapping units. Define an explicit versioned liability ledger: for any job, allocated provider claims + payer refund claims + pending/disputed holds + explicitly authorized protocol fees + unallocated payer-owned remainder must never exceed its real payer-backed funded credit. Independently enforce the matching/authorization ceiling: aggregate earned plus any other charged amount cannot exceed the accepted quote or maximumAuthorizedSpend; no transfer or withdrawal may use another job's/payer's backing. Vault-wide solvency and individual payer liability are distinct necessary checks. Any increase to the requester ceiling or deposit requires fresh payer authorization and a separately attributable deposit; it never edits already accepted provider prices or work-unit rights. Zero amounts, unsupported assets, stale policies or unverified vaults fail closed.
Every CMP operation needs a domain-separated unique operation/obligation ID containing chain, approved adapter/vault ID, job, action type and unique bounded sequence/unit or claim key, and an independent consumed-action ledger. An idempotent duplicate cannot create an additional Vault obligation, reserve, payment, claim, refund or fee. Never conflate a Vault operationId, CMP jobId, CMP unitId, obligationId, matchId or provider beneficiary.
3. Funding and reserve gate¶
CREATED -> FUNDED requires actual confirmed native deposit attributed to the payer and a CMP job-specific, nontransferable accounting credit in the approved adapter; a generic Vault NativeDeposited event or unscoped free balance alone is insufficient. Verify payer request/funding authorization, signature/nonce, vault active status and real custody within one authoritative sequence. A deposit accidentally made by an unrelated wallet cannot be allocated to an existing payer job through an untrusted argument. Payer-owned uncommitted credit is withdrawable only through its bound refund/withdrawal route, never by a provider or scheduler.
Before any paid ACCEPTED -> RUNNING transition, atomically verify the frozen match/manifest, payer credit, total bounded accepted quote (including every partition, replica, permitted retry, fee and hop), selected resource capacity, and exact backed reservation. Define a finite policy for tentative matching holds; on failed matching or expiry release the hold once back into the same payer's free credit, not the general market's pool. A FUNDED job lacking backed job-specific credit cannot be matched into paid execution. The immutable accepted provider-derived beneficiary is not yet an earned entitlement merely because reserve exists. Explicitly prevent concurrent jobs from consuming the same payer credit or provider capacity.
4. Earned entitlement and settlement¶
A worker's signature or completion claim is evidence of attribution only. After CMP-0.9 policy-bound receipt and correctness verification, and after prescribed challenge/dispute finality, compute the exact earned amount from accepted integer-only price/metering policy, fixed rounding, accepted maximum and unique CMP-0.3 unit IDs. Store a consumed entitlement key per unit and, if policy permits multiple distinct beneficiaries/hops, nonoverlapping preaccepted per-party shares; every retry of one payable unit shares its single entitlement. An invalid result earns zero unless a separately preaccepted objective partial-entitlement rule proves independently verified work and its fixed maximum. Do not release a provider obligation before this gate.
The approved adapter must construct provider claim obligation(s) only for actually verified earned amounts, with the beneficiary derived from the immutable accepted match, and route them via the Vault's applicable createObligation -> releaseObligation -> claim sequence under narrowly scoped authorizations. The current Vault releases the whole obligation, so split verified earnings into individually backed claims/obligations before release; do not partially release a whole-job provider obligation. A released obligation is claimable but not yet paid; claim succeeds only for its immutable beneficiary. Track claimable versus externally paid separately so retries, payout failures and vault winding-down do not fabricate transfers. Check Vault accounting and balance changes and enforce all liabilities atomically across adapter and Vault calls; perform effects/nonce checks before external calls and implement non-reentrancy across the combined execution route. The job may be SETTLED after all required verified entitlements have been irrevocably made claimable under its accepted settlement policy, while any later external claim remains a distinct auditable action, not a job reopening.
5. Cancellation, unused funds and real refunds¶
On lawful cancellation, expiry, failure, resolved dispute or successful under-budget settlement, calculate refundable = payer-backed funded credit - actual earned/fee liabilities - still contested/pending holds - prior refunds, using precise versioned policy and checked integer arithmetic. First resolve or explicitly preserve every earned/disputed claim; cancelling an unreleased pending Vault obligation via cancelObligation only restores vault-wide internal free balance. The CMP-specific adapter must atomically re-credit that exact amount to the correct original payer's job/refund liability, not a global withdrawable pool; the adapter must also rule out double-credit against an obligation subsequently released or claimed. Neither a cancelObligation event nor a changed freeBalance proves a payer refund.
For an approved refund, either (a) create and release an individually backed, immutable payer-beneficiary refund obligation and record the actual payer claimable amount, followed by claim to the payer, or (b) perform an asset- and recipient-route-authorized withdraw to the bound payer and prove the external transfer atomically. A refund destination migration is a separate authenticated payer-controlled operation; admin/scheduler/provider cannot choose a destination. Option (a) means REFUNDED may denote a genuinely payer-claimable amount under the bound refund policy, but distinguish refundClaimable from refundPaid and never report wallet transfer before claim succeeds. Option (b) requires successful external transfer before reporting refundPaid. Both routes must prove the payer's segregated credit before using any vault-wide free balance. Avoid unrestricted route authorizations that could sweep another payer's balance.
SETTLED is terminal for further execution and provider spending; returning an unused balance follows a separate payer-refund record without converting SETTLED to REFUNDED or reopening the job. For unsuccessful jobs, REFUNDED is entered only when the accepted policy's actual payer-claimable/paid evidence exists and all remaining provider/dispute liabilities are resolved or explicitly preserved. A provider's suspension, emergency pause, Vault winding-down or migration cannot confiscate earned entitlements or redirect payer money. If the Vault is CLOSED or otherwise cannot perform the required route, do not mark a transfer successful; retain reconstructable claims and follow a separately authorized nonconfiscatory recovery policy.
6. Authorization and audit boundaries¶
Restrict CMP adapter capabilities to the exact verified Vault ID, asset, per-action class and bounded amount; further enforce job ID, immutable payer, accepted beneficiary, obligation/operation ID and one-time entitlement in CMP logic. Existing AssetVault420.sol ACTION_RELEASE_OBLIGATION/ACTION_CANCEL_OBLIGATION checks are Vault/action-scoped, not automatically CMP job-, verified-unit- or payer-scoped. A broad Vault grant is insufficient without immutable adapter guards; no direct scheduler, verifier, provider node or ordinary admin obtains a general release/withdrawal/claim authority. An authorized verifier cannot choose a beneficiary or skip dispute finality; a capable release caller cannot invent correctness. A Vault operator must not redirect accepted claimants or reclaim payer deposits.
Publish reconstructable FundingBound, ReserveCommitted, EarnedVerified, ProviderClaimCreated, ProviderClaimReleased, ProviderClaimPaid, PayerRefundCredited, PayerRefundClaimable, PayerRefundPaid, ReserveReleased records with job, funding/settlement/obligation references, actor, action nonce, applicable policy and amount. Record only commitments; no private input, dataset, bearer token or unbounded execution metadata becomes canonical state. Distinguish events attesting to obligations, claimability and actual balance-changing transfers. Preserve pre/post custody proofs and replay-safe recovery across adapter downtime.
7. Source ownership and executable qualification gate¶
Before implementation, audit current VaultAuthorization420.sol, VaultRegistry420.sol, VaultAccounting420.sol, AssetVault420.sol, and Vault420.t.sol on the exact target branch. Proposed ComputeSettlement420.sol and an approved CMP Vault adapter are architecture targets, not asserted existing source files. Decide, design, implement and independently review the payer-segregated credit and obligation-splitting mechanism before enabling any live funding; check registry publication and privilege minimization. Do not deploy an isolated compute escrow, fabricate an active ComputeMarket service or assign a new frozen predeploy.
Required positive executable tests: two distinct payers fund simultaneously and cannot use/withdraw each other's credit; exact payer-bound native deposit and backed reserve; provider-derived immutable beneficiary; one verified unit creates one whole claimable provider obligation; partial verified earnings produce precisely bounded independent obligations; provider claim transfers only to beneficiary; cancellation returns pending reserve to the same payer's claimable/withdrawable credit; payer claim transfers externally; under-budget settled job returns unused funds without reopening; refund after a resolved dispute preserves independently earned claims; winding-down allows valid release/cancel/claims within actual Vault state rules. Assert detailed pre/post actual Vault balances, reserved, claimable, free balance, obligation state/count and CMP per-payer liabilities after each operation. Demonstrate real native-$420 funded -> matched -> accepted -> verified -> settled -> provider-claimed and separately cancelled/refunded paths.
Required negative tests: deposit from wrong payer attributed to job; global freeBalance used to double fund two jobs; unauthorized withdraw to provider/admin; overbroad route capability; premature release prior to verification or during dispute; failed verification paid; whole-obligation partial release; job/unit/receipt replay, multiple refund credit on repeated cancel, double claim, double payout across retries, mismatched beneficiary, unapproved asset, overquote or overflow, unbacked fee, reentrant callback, concurrent claim/refund/cancel, wrong chain/vault/adapter version, code-hash mismatch, emergency confiscation and Vault CLOSED transfer incorrectly reported as successful. On rejected operation assert no changed payer credit, Vault balance, obligation state, job transition, nonce or provider entitlement (apart from explicit permitted audit events). Provide exact invariant-to-test mapping for CMP-INV-006, 008–013, 016–022, 024–029 and run Foundry, adapter/client integration and full exact-head repository qualification after executable components exist.
Completion boundary: CMP-0.8 specifies source-verified Vault limitations, payer-segregated funding, bounded commitment, correctness-gated claims, actual transfer/refund and tests only. Existing Vault source supports generic accounting/obligations, not yet an operational CMP payer-isolated settlement system. This increment does not implement or verify a funded end-to-end CMP job. Keep PR #367 draft and unmerged pending CMP-0.9 receipts/verification, later phases, executable test evidence, current-main reconciliation and exact-head qualification.