Skip to content

symfonic.agent.receipt_activation

receipt_activation

Private host-authenticated PG v1 reconciliation data, with no public wiring.

Activation independently reads the persisted handle through CORE-338. Caller transcripts, local SQLite rows and caller-created CompletedTurn values cannot enter this path. Returned data is not an authorization capability and is forgeable in-process. A future publisher must independently revalidate the persisted handle and exact context against PG at consumption, and obtain its separate authenticated Voice final receipt. Neither publisher nor Voice receipt is implemented here; these values never authorize publication, cycles or replay.

ReconciledCompletionSnapshot dataclass

ReconciledCompletionSnapshot(invocation_id: str, scope_path: str, request_digest: str, run_id: str, root_run_id: str, terminal_digest: str, revision: int, acceptance_sequence: int)

Data-only reconciliation snapshot, freely constructible and copyable.

Frozen fields are a convenience, not a trust boundary: object.new and object.setattr can forge or mutate them. Never authorize an operation from this value, its type, or its fields; revalidate PG handle/context instead.

reconcile_completion_snapshot async

reconcile_completion_snapshot(handle: str, authority: Any, *, invocation_id: str, run_id: str, root_run_id: str, text: str, stop_reason: str | None) -> ReconciledCompletionSnapshot

Return data after exact authenticated accepted-completion reconciliation.

The host supplies its authenticated CORE-338 authority and the context of the turn being activated. UNKNOWN, pending, stale/mismatched contexts and refused principals fail closed. No receipt, completion or returned evidence may be supplied as proof. This read does not grant activation authority.

Source code in src/symfonic/agent/receipt_activation.py
async def reconcile_completion_snapshot(
    handle: str, authority: Any, *, invocation_id: str, run_id: str,
    root_run_id: str, text: str, stop_reason: str | None,
) -> ReconciledCompletionSnapshot:
    """Return data after exact authenticated accepted-completion reconciliation.

    The host supplies its authenticated CORE-338 authority and the context of
    the turn being activated. UNKNOWN, pending, stale/mismatched contexts and
    refused principals fail closed. No receipt, completion or returned evidence
    may be supplied as proof. This read does not grant activation authority.
    """
    if (not all(_identifier(value) for value in (invocation_id, run_id, root_run_id))
            or type(text) is not str
            or (stop_reason is not None and type(stop_reason) is not str)):
        _refuse()
    outcome = await postgres_receipt_reconciliation.reconcile_postgres_receipt(handle, authority)
    if type(outcome) is not ReceiptReconciliation or outcome.state != "COMPLETED":
        _refuse()
    completion = outcome.completion
    if (type(completion) is not CompletedTurn
            or completion.full_scope.identity_version != 1
            or type(completion.acceptance_sequence) is not int
            or completion.acceptance_sequence < 1
            or completion.invocation_id != invocation_id or completion.run_id != run_id
            or completion.root_run_id != root_run_id
            or completion.terminal_digest != terminal_digest(text, stop_reason)):
        _refuse()
    return ReconciledCompletionSnapshot(
        completion.invocation_id, completion.full_scope.path, completion.request_digest,
        completion.run_id, completion.root_run_id, completion.terminal_digest,
        completion.revision, completion.acceptance_sequence,
    )