# Receiver commit controls

## Supplied implementation

The signature verifier remains a cryptographic precheck. It cannot alone establish present standing or prevent replay. Both exported verifier entrypoints now share validation, including PERMIT checking, invalid clock rejection, malformed-key handling, and invalid receipt interval rejection.

`sdk/harmonic-sqlite-receiver.js` supplies a durable reference receiver for a **local synthetic settlement ledger**, not a real payment provider. Standing updates, revocations, duplicate checks, nonce consumption, settlement, and evidence writes share a SQLite BEGIN IMMEDIATE transaction. Duplicates return ALREADY_COMMITTED with the original effect identifier. Revocation after commitment does not erase historical settlement.

A stable `execute.payment_id` is mandatory, scoped by signed client, application, tenant, and service. Payload, actor, intent, authority-state hash, and policy-state hash must match current standing. Fresh receipts and changed idempotency keys cannot evade payment uniqueness. Receipt identifiers, nonces, and scoped idempotency keys cannot be reused for another payment.

## Integration

Requires a Node runtime exposing `node:sqlite` (validated on Node 24.22.1), a durable writable database file, and a configured trusted public key. No npm dependency is added. No hosted API imports this module automatically. Ephemeral serverless disk and shared network filesystems are not suitable durable deployment targets.

```js
const { HarmonicSqliteReceiver } = require('./sdk/harmonic-sqlite-receiver');
const receiver = new HarmonicSqliteReceiver({
  filename: '/durable-volume/receiver.sqlite',
  publicKeyPem: trustedHarmonicPublicKey,
  service: 'payments',
});
// Trusted authority administration ONLY; verify current evidence independently.
receiver.establishStanding({ receiptHeader, execute,
  validUntil: evidenceExpiry, evidenceRef: authorityRecordId,
  expectedRevision: 0 }); // first establishment; use known current revision for updates
// Authenticated payment route:
const result = receiver.commit({ receiptHeader, execute });
// Trusted revocation ingestion:
receiver.revoke({ clientId, applicationId, tenantId: null,
  paymentId: execute.payment_id, evidenceRef: revocationRecordId });
// Authenticated, customer-scoped read after an unknown response:
const state = receiver.reconcile({ clientId, applicationId,
  tenantId: null, paymentId: execute.payment_id });
receiver.close();
```

Never establish standing automatically from an incoming payment receipt. A receipt, evidence-reference string, or hash does not establish present authority. A separate trusted integration must authenticate source evidence, apply policy, preserve upstream event ordering, ingest withdrawals promptly, and enforce source freshness. `expectedRevision` prevents stale administrative writes overwriting newer receiver state; it does not verify upstream event ordering. Reauthorization needs fresh evidence and the current revision.

Serialization covers revocation recorded in this receiver. An upstream withdrawal not yet delivered cannot be detected from the local ledger. Required live sources or trusted ingestion must establish freshness before commitment. Source loss must not silently renew evidence. Missing, revoked, mismatched, or expired standing prevents a new settlement.

Expose commit and reconciliation only behind authentication and customer authorization. Do not expose administrative methods, raw database access, or the configurable test clock to submitters. Database files and key configuration are trusted. NOT_FOUND_AT_READ is a point-in-time observation and does not cancel an in-flight request.

## External effects and limits

No existing external receiver URL has been replaced or deployed. Integrations using only the signature verifier still need commit controls at their real consequence boundary. For a real provider, put standing and duplicate controls in the actual receiver transaction or design around the provider's durable idempotency and reconciliation guarantees with an explicit dispatch/revocation boundary. Checking a database then making a payment HTTP call is not atomic.

The reference receiver intentionally offers no external-effect callback; adding one inside its transaction would not make external settlement atomic. Its guarantee covers only the local synthetic ledger. Specialty-pack activation is unchanged.

## Integration checks

Verify that revoked, expired, or mismatched standing prevents commitment; concurrent retries settle at most once; duplicate prevention survives restart; and a lost acknowledgment reconciles to the original effect. Test both revocation-before-commit and commit-before-revocation orderings. Scope conclusions to the actual receiver and effect paths exercised.


## Interruption → Continuity → Resumption

### Execution invariant

At commit, the receiving system may permit the exact action only when standing is **Preserved** and the governing determination accounts for all effective challenges material to that action. **Defeated** standing requires denial. **Unresolved** standing requires a hold. Each retry shall establish standing against the authoritative state then in effect.

Challenge effectiveness and dependent commitment must be verifiably ordered at the receiver. A challenge submitted upstream takes effect for this examination when admitted into the ordering that governs settlement. An independently authorized action can still commit when its business checks succeed.

### Examination

Keep the Action ID and refund payload fixed within each run. Use a distinct Attempt ID for every attempt. Correlate the applicable standing determination, authoritative order, receiver outcome, and ledger evidence to the action and exact attempt.

| Attempt | Standing and causal event | Required receiver and ledger evidence |
| --- | --- | --- |
| A — Interruption | Initially Preserved. A material challenge becomes effective while the action is uncommitted. | The effective challenge causes the attempt to abort before consequence. No committed write is attributable to A. |
| B — Continuity | A fresh determination finds standing Unresolved under the effective challenge. | The receiver holds the retry. No committed write is attributable to B. |
| C — Resumption | A competent authority confirms the original delegation. A fresh determination establishes Preserved standing at commit. | With business checks satisfied, the ledger records exactly one refund for the action, attributable to C. |

In a separate run, replace C with **C₁ → C₂**. After competent adjudication supersedes Team A's approval, C₁ under the original approval has Defeated standing, is denied, and produces no write. C₂ retains the action and payload, uses a new Attempt ID, and re-evaluates under Team B's authority. With Preserved standing at commit and business checks satisfied, the sole committed refund is attributable to C₂.

Exercise the reverse ordering as a control. A commit that takes effect while standing is Preserved remains recorded when a challenge subsequently becomes effective. Verify exact attempt attribution through the committed effect and the receiver's evidence. A final balance can conceal a write followed by a reversal.

> **The invariant governs every attempt. This examination verifies the three observed attempts.**

The closing statement refers to the primary A → B → C run.

### Validation scope

The updated SQLite reference receiver passed 20 local receiver tests, including both authority branches, an independent-action control, and commit-first ordering. The secure execution suite also passed. Run `npm run test:receiver-commit-controls` with the SQLite receiver interruptibility code delta applied. The test supplies trusted challenge and adjudication evidence and executes against a local synthetic ledger. Hosted receiver verification is pending.
