SpoolisDocs

Spoolis docs

Continue only with accepted work

Gate downstream actions on a verified result: verify delivered work against explicit criteria, then pass only accepted units to the next paid step.

Work returning is not the same as work passing. Verify against the agreement, then let only accepted units trigger the next action.

Require a valid Outcome before you act

The consumer verifies the signed receipt offline, applies its own policy with requireOutcome, and only then pays, publishes, deploys, forwards, or lets the next agent run. Spoolis records the Outcome; the consumer's runtime decides.

Offline gate
import { requireOutcome } from '@spoolis/receipt-verifier'

const gate = await requireOutcome(receipt, {
  agreement_hash: '<the accepted agreement hash>',
  minimum_status: 'pass',
}, {
  trustSet,
  environment: receipt.environment,
})

if (!gate.ok) throw new Error(gate.reasons.join(', '))

Offline is the default. An online status check is opt-in and fails closed when require_current is true, including when the status source is unavailable:

Online status check
import { fetchReceiptStatus, requireOutcome } from '@spoolis/receipt-verifier'

const statusSource = await fetchReceiptStatus('https://spoolis.com', receipt.id)
  .catch(() => undefined)

const gate = await requireOutcome(receipt, {
  agreement_hash: '<the accepted agreement hash>',
  minimum_status: 'pass',
  require_current: true,
}, {
  trustSet,
  environment: receipt.environment,
  statusSource,
})

if (!gate.ok) throw new Error(gate.reasons.join(', '))

The gate ships in these surfaces:

The gate refuses to continue when:

  • The receipt signature is invalid.
  • An uncertain result fails minimum_status.
  • The status source says the receipt was superseded.

The shape

work returnsverifyaccepted: continuerejected/uncertain: hold

1. Verify the delivered work

Submit the agreement and the delivered records in one call. Declare the unit count so each record gets its own verdict. A 10-record example:

Request
POST https://spoolis.com/api/v1/verify
Authorization: Bearer <your API key>
Content-Type: application/json

{
  "conditions": [{
    "description": "Every record includes ticker, trade_date, and close",
    "deterministic_check": {
      "checker": "completeness",
      "required_fields": ["ticker", "trade_date", "close"]
    }
  }],
  "max_amount_cents": 10,
  "unit": { "total_units": 10, "unit_amount_cents": 1 },
  "evidence": { "type": "dataset", "rows": [ /* the 10 delivered records */ ], "provenance": "api_response" }
}
Response
{
  "accepted": 9,
  "rejected": 1,
  "uncertain": 0,
  "unit_results": [
    { "unit": 1, "verdict": "pass" },
    { "unit": 2, "verdict": "fail", "reason": "close is missing" },
    ...
  ],
  "receipt": { "id": "ocr_..", "schema": "spoolis/outcome-receipt@1", "signature": ".." },
  "receipt_url": "https://spoolis.com/r/.."
}

2. Pass only accepted units downstream

Iterate the per-unit results. Accepted units continue; rejected and uncertain units hold for retry or review.

Gate
const outcome = await verify(agreement, deliveredRows)

for (const result of outcome.unit_results) {
  const row = deliveredRows[result.unit - 1]
  if (result.verdict === 'pass') {
    await paidDownstreamAction(row)
  } else {
    holdForRetryOrReview(row, result)
  }
}

Uncertain verdicts are deliberate: when required evidence is missing, the result says so instead of guessing. For irreversible or paid actions, treat uncertain as not-cleared until the missing evidence is resolved.

3. Keep the receipt with the decision

The signed Outcome Receipt names each rejected unit and why. Reference it from whatever the gate controls, a payment description, a workflow log, a CI check, so the spending decision stays inspectable. See verify a receipt.

When this pattern is worth using

Use this when letting bad work through costs more than verification. If nothing priced happens downstream, the gate may just add cost. The economics, including where the gate loses money, are measured in when does verification actually pay for itself?

Continue only with accepted work · Spoolis