Reference

The JSON Schemas, the conformance kit and the TypeScript API of draft 0.1. All three are read from the protocol package when the site is built, so this page cannot drift from the code.

JSON Schemas

Draft 2020-12. Each schema’s $id is the address it is published at below. The protocol package resolves those addresses from its own files, so validating never fetches anything.

  • Authority binding

    Describes and binds the authority an agent holds for one contract revision. JSON cannot grant authority: enforcement happens at the real policy or provider boundary. Every extension here counts as critical. Revisable.

    authority-binding.schema.json

  • Enna 0.1 shared definitions

    common.schema.json

  • Scoped context manifest

    The context a contract revision may use, by reference, with purpose, provenance, freshness and disclosure. Provenance is not proof of truth. Revisable.

    context-manifest.schema.json

  • Enna discovery document

    Served at /.well-known/enna.json, a proposed draft convention not registered with IANA. Publication follows the Personal Agent Protocol 0.1 rules. Nothing sensitive belongs here.

    discovery.schema.json

  • Envelope

    Carries one or more Enna objects between parties. Each object is validated on its own; references to objects not in the envelope are allowed.

    envelope.schema.json

  • Error

    An OAuth-style error with JSON Pointer details. Detail codes come from one catalog, stable within 0.x.

    error.schema.json

  • Evaluation result

    Criterion-by-criterion evidence for a contract revision, kept apart from whether execution finished and from whether the accountable owner accepted the outcome. A passing test suite is not evidence of customer value. Acceptance is recorded as a new revision.

    evaluation-result.schema.json

  • Execution receipt

    An immutable record of one proposed or performed action: who, under which authority and context, the decision, the outcome and every change made. A digest shows the record is unchanged only against a digest the reader already trusts, and an edited record can be resealed; it does not show that the action was authorized or that the producer was honest.

    execution-receipt.schema.json

  • Profile software-delivery/0.1

    Applies, on top of the core schema, to any object whose profile is software-delivery/0.1. The profile owns the repo, ci, preview, production and feature_flag action namespaces, and the plain (not domain-prefixed) artifact and evidence kinds. A production.deploy action also needs its own grant and an approval whose method is not standing, which validateBundle checks.

    profiles/software-delivery-0.1.schema.json

  • Work contract

    What is to be done for an organization, who is accountable, how done is judged and within which limits. Revisable.

    work-contract.schema.json

Conformance kit

The fixtures, test vectors and catalogs that test an implementation in any language, published under /spec/v0.1/ byte for byte as the protocol package holds them, under the Apache License 2.0. The manifest, which the build writes, gives the SHA-256 of every other file there but the pages. The conformance kit page says what each file holds and how to run the fixtures.

  • Valid fixtures

    22 documents that pass, and index.json, which says how to check each.

    fixtures/valid/

  • Invalid fixtures

    296 cases, each with the exact (code, path) pairs a check reports.

    fixtures/invalid/

  • Canonicalization vectors

    JSON texts with their RFC 8785 canonical forms and digests, and texts that have none (section 2.15).

    fixtures/vectors/canonicalization.json

  • Digest vectors

    The canonical form and digest of each distinct execution receipt and authority binding in the valid fixtures (sections 6.6 and 5.3).

    fixtures/vectors/digests.json

  • Error codes

    Every detail code, with its area and meaning (section 8.4).

    catalogs/error-codes.json

  • Core extensions

    Each extension this draft defines, with the object it belongs to (section 2.12).

    catalogs/extensions.json

  • Identifier prefixes

    The prefix of each kind of identifier (section 2.3).

    catalogs/identifiers.json

  • Lifecycle

    The states, events, transitions and block reasons, and the mappings to A2A and PAP states (section 10).

    catalogs/lifecycle.json

  • Profiles

    Each profile of this draft, with its schema (section 2.14).

    catalogs/profiles.json

  • Manifest

    Every file under /spec/v0.1/ but the pages and the manifest itself, with its media type, SHA-256 and license.

    manifest.json

TypeScript API

Everything @enna/protocol exports at run time, with signatures read from its source by the TypeScript checker. The package is private in this draft and is not published to npm.

Validation

  • validateObject(object: unknown, options?: ValidateOptions): ValidationResult

    Checks one object against its schema, the shared conventions and its profile.

  • validateEnvelope(envelope: unknown, options?: ValidateOptions): ValidationResult

    Checks an envelope and each object in it; referenced objects may live elsewhere.

  • validateBundle(objects: unknown, options: BundleOptions): Promise<BundleResult>

    Checks the complete record of one contract revision against every invariant and the rules its level adds; it stops at the record's shape when an object is malformed.

  • validateDiscovery(document: unknown, options: DiscoveryOptions): ValidationResult

    Checks an enna.json document, with the domain, issuer and poppy.json cross-checks.

  • parseJson(input: string | Uint8Array): ParseResult

    Decodes JSON strictly: UTF-8 only, and a byte order mark, a lone surrogate or a duplicate member name is rejected.

  • CORE_EXTENSIONS: Readonly<Partial<Record<ObjectType, readonly string[]>>>

    The core extensions each object type accepts without being told about them.

  • PROFILES: readonly string[]

    The profiles the package knows; an Enforcement point refuses to act under any other.

Errors

  • ERROR_CODES: { 39 members }

    Every code in the error catalog, with its area and description.

    Full type of ERROR_CODES ERROR_CODES: { readonly invalid_json: { readonly area: "Shape and versions"; readonly description: "The document is not well-formed UTF-8 JSON, or a string in it holds a lone surrogate."; }; readonly duplicate_member: { readonly area: "Shape and versions"; readonly description: "An object has two members with the same name."; }; readonly schema_violation: { readonly area: "Shape and versions"; readonly description: "A value does not match its schema: a missing member, a wrong type, format, pattern or enum value, a null, or a duplicate ID."; }; readonly unknown_member: { readonly area: "Shape and versions"; readonly description: "A closed object carries a member its schema does not define."; }; readonly unsupported_version: { readonly area: "Shape and versions"; readonly description: "The protocol_version is not one this consumer supports."; }; readonly unsupported_profile: { readonly area: "Shape and versions"; readonly description: "The object follows a profile this Enforcement point does not know, so it cannot enforce the profile's rules."; }; readonly timestamp_in_future: { readonly area: "Shape and versions"; readonly description: "A record states that something happened later than the injected current time."; }; readonly reference_unresolved: { readonly area: "References and scope"; readonly description: "A reference names an object or link that is not present."; }; readonly revision_mismatch: { readonly area: "References and scope"; readonly description: "A reference names a revision other than the one present, or revisions that must match differ."; }; readonly tenant_mismatch: { readonly area: "References and scope"; readonly description: "A scope lies outside the contract's organization and workspace, and no approved grant names that workspace."; }; readonly currency_mismatch: { readonly area: "Money and limits"; readonly description: "Two amounts that must be compared or added are in different currencies."; }; readonly limit_exceeded: { readonly area: "Money and limits"; readonly description: "A cost or a count exceeds its limit."; }; readonly approval_missing: { readonly area: "Approvals"; readonly description: "No valid approval covers the action."; }; readonly approval_expired: { readonly area: "Approvals"; readonly description: "The approval had expired when the action started."; }; readonly approval_revoked: { readonly area: "Approvals"; readonly description: "The approval was revoked before the action started."; }; readonly approval_stale: { readonly area: "Approvals"; readonly description: "The approval covers another contract revision or another version of the binding."; }; readonly approval_denied: { readonly area: "Approvals"; readonly description: "An approver in scope denied the authority."; }; readonly approver_out_of_scope: { readonly area: "Approvals"; readonly description: "The approver may not approve this contract, or does not hold, by the contract's assignment, the role the grant requires."; }; readonly separation_of_duties: { readonly area: "Approvals"; readonly description: "At the Controlled level and above, an action over the declared threshold has no approval from someone other than the requester."; }; readonly quorum_not_met: { readonly area: "Approvals"; readonly description: "Fewer distinct people gave a valid approval for the action than its grant's min_approvals requires."; }; readonly authority_expired: { readonly area: "Authority"; readonly description: "The action falls outside the authority's valid_from to expires_at window."; }; readonly authority_revoked: { readonly area: "Authority"; readonly description: "The authority, or a binding it was delegated from, was revoked before the action started."; }; readonly authority_insufficient: { readonly area: "Authority"; readonly description: "No grant covers the action and its resource, or the agent that acted is not the binding's grantee."; }; readonly subdelegation_forbidden: { readonly area: "Authority"; readonly description: "The parent authority forbids further delegation, or the delegation is deeper than its parent allows."; }; readonly attenuation_violated: { readonly area: "Authority"; readonly description: "Delegated authority is broader than its parent: another action, a wider resource, higher limits, fewer conditions or a lower quorum, a higher separation-of-duties threshold, a longer window or a wrong depth."; }; readonly context_stale: { readonly area: "Context"; readonly description: "A context item was stale, or of unknown age, when an action that used it started."; }; readonly context_out_of_scope: { readonly area: "Context"; readonly description: "A context item lies outside the tenant boundary, or an action cites context that neither the contract nor its own binding reaches."; }; readonly idempotency_conflict: { readonly area: "Execution and integrity"; readonly description: "An idempotency key was reused for another action, resource or payload, or an action took effect twice under one key."; }; readonly illegal_transition: { readonly area: "Execution and integrity"; readonly description: "The lifecycle does not allow this event in this state."; }; readonly digest_mismatch: { readonly area: "Execution and integrity"; readonly description: "A digest does not match the content it covers."; }; readonly chain_broken: { readonly area: "Execution and integrity"; readonly description: "The receipt chain is missing a link, forks, or runs backwards in time."; }; readonly evidence_missing: { readonly area: "Evaluation and acceptance"; readonly description: "A required criterion is not evaluated, or a pass or a fail carries no evidence."; }; readonly criterion_unknown: { readonly area: "Evaluation and acceptance"; readonly description: "The evaluation names a criterion the contract does not define."; }; readonly technical_result_mismatch: { readonly area: "Evaluation and acceptance"; readonly description: "technical_result differs from the result derived from the required criteria."; }; readonly acceptance_premature: { readonly area: "Evaluation and acceptance"; readonly description: "Acceptance was decided before execution and evaluation finished (while an action's final outcome was unknown, cited or not, before an effect ended, or before the evaluation existed), for work with no effect, or in the evaluation's first revision."; }; readonly acceptance_not_owner: { readonly area: "Evaluation and acceptance"; readonly description: "Acceptance came from someone other than the contract owner, an acceptor the contract names, or the owner's delegate."; }; readonly unsupported_critical_extension: { readonly area: "Extensions"; readonly description: "The object, envelope or discovery document carries a critical extension this consumer does not support. In an authority binding every extension counts as critical."; }; readonly domain_mismatch: { readonly area: "Discovery"; readonly description: "organization.domain is not the requested host, ignoring a leading www., or a linked document names another domain."; }; readonly issuer_mismatch: { readonly area: "Discovery"; readonly description: "The issuer metadata does not name auth.issuer exactly, or its enna_domains omits the domain."; }; }
  • toErrorResponse(kind: ErrorKind, details: ErrorDetail[]): { error: ErrorKind; error_description: string; details: ErrorDetail[]; }

    Builds the error format from a kind and a list of details.

  • class ProtocolError extends Error

    Thrown by helpers such as the money functions, carrying a catalog code.

Canonical JSON and digests

  • canonicalize(value: unknown): string

    Serializes a value as RFC 8785 canonical JSON.

  • digest(value: unknown): Promise<string>

    SHA-256 over the canonical JSON of a value, as sha256:<hex>, with Web Crypto.

  • receiptDigest(receipt: ExecutionReceipt): Promise<string>

    A receipt's digest, computed without integrity.digest, as receipts are sealed.

  • bindingDigest(binding: AuthorityBinding): Promise<string>

    The digest an approval covers: the whole binding, except its approvals and the bookkeeping of its revisions.

Conventions

  • parseMoney(value: unknown): ParsedMoney

    Parses a money object into currency, integer units and scale.

  • compareMoney(a: Money, b: Money): -1 | 0 | 1

    Compares two amounts exactly; different currencies are an error.

  • addMoney(a: Money, b: Money): Money

    Adds two amounts of one currency exactly.

  • isUtcTimestamp(value: unknown): value is string

    Tells whether a value is an RFC 3339 timestamp in UTC with a Z.

  • compareTimestamps(a: string, b: string): -1 | 0 | 1

    Orders two UTC timestamps.

  • addSeconds(timestamp: string, seconds: number): string

    Adds whole seconds to a UTC timestamp.

  • toUtcTimestamp(value: string): string

    Converts an RFC 3339 timestamp with any offset to UTC with a Z.

  • ID_PREFIXES: { readonly work_contract: "wc_"; readonly context_manifest: "ctx_"; readonly authority_binding: "auth_"; readonly execution_receipt: "rcpt_"; readonly evaluation_result: "eval_"; readonly envelope: "env_"; readonly approval: "apr_"; readonly artifact: "art_"; readonly context_item: "item_"; }

    The prefix each kind of identifier starts with.

  • isId(kind: IdKind, value: unknown): value is string

    Tells whether a value is a well-formed identifier of the given kind.

Lifecycle and mappings

  • STATES: readonly ["proposed", "awaiting_approval", "authorized", "executing", "execution_complete", "evaluating", "awaiting_acceptance", "accepted", "rejected", "cancelled", "blocked"]

    The business states of a work contract.

  • TERMINAL_STATES: readonly State[]

    The states a contract never leaves.

  • EVENTS: readonly ["request_approval", "approve", "reject", "start", "complete_execution", "start_evaluation", "complete_evaluation", "accept", "revise", "cancel", "block", "resume"]

    The events that move a contract between states.

  • TRANSITIONS: readonly { from: State; event: LifecycleEvent; to: State }[]

    The normative transition table, as data.

  • BLOCK_REASONS: readonly ErrorCode[]

    The reason codes a block may carry.

  • transition(state: State, event: LifecycleEvent, reason?: ErrorCode): { ok: boolean; state: State; errors: ErrorDetail[]; }

    Applies an event to a state and returns the next state, or why it is not allowed.

  • A2A_TASK_STATES: readonly ["TASK_STATE_UNSPECIFIED", "TASK_STATE_SUBMITTED", "TASK_STATE_WORKING", "TASK_STATE_COMPLETED", "TASK_STATE_FAILED", "TASK_STATE_CANCELED", "TASK_STATE_INPUT_REQUIRED", "TASK_STATE_REJECTED", "TASK_STATE_AUTH_REQUIRED"]

    The A2A 1.0 task states, by their protocol names.

  • A2A_STATE_TABLE: Record<State, { a2a: A2aTaskState; match: Match; note: string }>

    The A2A task state for each business state, and how close the match is.

  • A2A_UNMAPPED: Partial<Record<A2aTaskState, string>>

    A2A task states with no business counterpart, and why.

  • toA2aTaskState(state: State): A2aTaskState

    Maps a business state to its A2A task state.

  • fromA2aTaskState(task: A2aTaskState): State[]

    Lists the business states an A2A task state can stand for.

  • PAP_STATE_TABLE: Record< State, { pap: PapOperationState | "from_receipts"; match: Match | "derived"; note: string } >

    The PAP operation state for each business state.

  • PAP_UNMAPPED: Partial<Record<PapOperationState, string>>

    PAP operation states with no business counterpart, and why.

  • toPapOperationState(state: State, ...operation: [] | [receipts: readonly ExecutionReceipt[], operationId: string]): PapOperationState

    Maps a business state to a PAP operation state, using the receipts after execution.

Personal Agent Protocol 0.1

  • ENNA_PAP_EXTENSION: "businessagentprotocol.org/enna"

    The extension key a business uses to list Enna in its poppy.json.

  • contractFromPapOperation(operation: PapOperation, context: PapContractContext): WorkContract

    Turns a PAP operation into an Enna work contract.

  • papOperationFromContract(contract: WorkContract): PapOperation

    Proposes a work contract to the personal agent as the PAP operation revision its pap extension names.

  • approvalFromPapConfirmation(operation: PapOperation, context: { id: ApprovalId; contract: WorkContract; approver_role?: string; expires_at?: string; } & ({ binding: AuthorityBinding; } | { binding_digest: Approval["covers"]["binding_digest"]; })): Promise<Approval>

    Records a PAP confirmation as an asserted approval covering an authority binding's digest, with the expiry the business sets.

  • papResultFromReceipts(receipts: readonly ExecutionReceipt[], operationId: string): { state: PapOperationState; result: PapOperation["result"]; }

    Selects the receipts that name a PAP operation's ID and rolls them up into its state and result by each key's final receipt; a settled denial no longer counts.

Bundle helpers

  • contextFreshness(item: ContextItem, at: string): "fresh" | "stale" | "unknown"

    Tells whether a context item is fresh, stale or unknown at a given time.

  • deriveTechnicalResult(contract: WorkContract, evaluation: EvaluationResult): CriterionResult

    Derives an evaluation's technical result from its required criteria.

  • scopeWithin(inner: Scope, outer: Scope): boolean

    Tells whether one scope lies inside another.

  • samePrincipal(a: Principal, b: Principal): boolean

    Tells whether two principal references name the same principal.

  • ACCEPT_ACTION: "acceptance.decide"

    The action a binding grants so that someone may accept on the owner's behalf.

  • namedAcceptor(contract: WorkContract, principal: Principal): boolean

    Tells whether the contract itself names someone to accept: its owner or an acceptor.

  • finalReceipts(receipts: readonly ExecutionReceipt[]): ExecutionReceipt[]

    Picks each idempotency key's final receipt, the one that settles its outcome.

  • idempotencyMismatch(earlier: ExecutionReceipt["action"], later: ExecutionReceipt["action"]): "name" | "resource" | "payload_digest" | undefined

    Tells which of name, resource or payload makes a later attempt under a key another action.

Examples

Each example is a TypeScript file in the site’s source, and the site’s type check compiles it against @enna/protocol.

Validate an object

import { readFile } from "node:fs/promises";
import { parseJson, validateObject } from "@enna/protocol";

const parsed = parseJson(await readFile("work-contract.json"));
const result = parsed.ok ? validateObject(parsed.value) : parsed;

for (const { code, path, message } of result.errors) {
  console.log(code, path, message);
}

Validate a complete record

import { readFile } from "node:fs/promises";
import { validateBundle } from "@enna/protocol";

const objects: unknown = JSON.parse(await readFile("bundle.json", "utf8"));
const result = await validateBundle(objects, { now: "2026-10-12T09:00:00Z", level: "controlled" });

console.log(result.ok ? "Every invariant holds." : result.errors);

Compute a digest

import { canonicalize, digest } from "@enna/protocol";

const limit = { currency: "USD", amount: "400.00" };

console.log(canonicalize(limit));
console.log(await digest(limit));

Follow the lifecycle

import { toA2aTaskState, transition } from "@enna/protocol";

const step = transition("proposed", "request_approval");

console.log(step.ok ? [step.state, toA2aTaskState(step.state)] : step.errors);

Check a discovery document

import { validateDiscovery } from "@enna/protocol";

const response = await fetch("https://harborpine.example/.well-known/enna.json");
const result = validateDiscovery(await response.json(), { requestedHost: "harborpine.example" });

console.log(result.ok ? "The document speaks for harborpine.example." : result.errors);