Skip to main content

Proposal: This page presents the draft API and profile model. Send feedback on GitHub.

Reservation, live checking and enforcement

function reserve(packet, state) {
strictParseSchemaAndCanonicalBytes(packet);
const {intent, attempt, proof, request, grantChain, policies, appraisal} = packet;
verifyChainAndAppraisal(grantChain, policies, appraisal, configuredTrust);
require(rawHash(unhex(packet.input)) === intent.inputHash);
require(attempt.intentRef === H("intent", intent));
require(attempt.grantRef === ref(last(grantChain)));
require(attempt.policyRef === H("policy", last(policies)));
verifyProof(proof, H("attempt", attempt), "request", attempt.keyId);
verifySignedRoleAndKind(request, attempt.keyId, "request");
require(request.payload.attemptRef === H("attempt", attempt));
require(request.payload.proofRef === H("proof", proof));
require(matchesEveryInheritedPolicy(intent, policies));
return state.serializableTransaction(tx => {
tx.requireCurrentLineageEpochAndFence(grantChain, attempt.epoch);
tx.consumeFreshRecord(attempt.keyId, attempt.gen, attempt.record);
const old = tx.findOperation(service, intent.tenant, intent.audience, attempt.op);
if (old) return tx.reconcileOrConflict(old, intent, attempt.holder);
tx.requirePoolAndAncestorAvailability(intent.units, policies);
const permit = tx.reserveAndSignPermit(packet, boundedExpiry(attempt));
return permit;
});
}

An implementation must validate signatures, freshness, appraisal, record and policy before letting an unauthenticated request consume a record position or reservation. Concurrency requires one ordering point per shared allowance. For example, two concurrent six-credit requests on ten remaining credits produce at most one six-credit reservation, regardless of which worker wins.

Resource boundary​

The resource verifies the packet and permit independently using its own trust configuration. It validates the actual request method and target, exact input and all action arguments, then checks its current policy. A live state check alone does not consume the permit. The designated custodian signs a ledger-control redemption with fresh nonce and stable idempotency key; the state authority returns a signed ledger-decision binding the control reference, caller, nonce, permit, epoch, fence and deadline.

async function executeAtResource(packet, permit, actualRoute) {
verifyPacketAndPermit(packet, permit, actualRoute, resourceTrust);
require(await resourcePolicy.permits(packet.intent));
const redemption = await ledger.redeem(await custodian.signControl({
action: "redeem", requestRef: ref(packet.request), permitRef: ref(permit),
presentationRef: H("request-packet", packet), caller: "reports-db",
nonce: random256(), idempotencyKey: stableRedemptionId(),
iat: clock.now(), exp: boundedDeadline()
}));
verifyStateDecision(redemption, "redeemed", permit, packet);
return resource.transaction(async tx => {
await tx.recheckPolicyFenceAndDeadline(packet, permit, redemption);
const existing = await tx.findOperation(operationKey(packet));
if (existing) return existing.requireMatchingIntent(packet.intent);
const result = await tx.performAllowedOperation(packet.intent, unhex(packet.input));
return tx.insertUniqueObservation(operationKey(packet), result, permit);
});
}

The same transaction must protect the effect and unique journal row where possible. If the downstream sink supplies only idempotency and authoritative lookup, bind and persist its idempotency key and reconcile with it. A network or process effect without those guarantees may remain uncertain. Issuance of a permit and redemption of it are not proof of resource commitment.

Control calls can have their own fresh native proof when the deployment requires it. The control context is H("ledger-control", ledgerControlPayload), and its proof challenge uses purpose ledger-control, direction control, and the custodian's authorized policy. The ledger checks it locally against configured control authority. This draft still needs a closed control-packet schema and proof transport; the synthetic control example includes a signature and signed decision, not a native control proof.