Primitive Contract
Primitive Contract (Normative)
Status: normative for OSS v1.x producers and consumers.
This document defines the four execution primitives that integrations must use and preserve:
IntentRequestGateResultTraceRecordRunpack
Within a major version, these contracts are backward-compatible.
Onboarding Surface Contract
These file locations and command roles are part of the public OSS onboarding contract:
.gait.yaml: additive repo-root policy file forgait initandgait check.gait/config.yaml: project defaults loaded bygait gate evalunless--no-configis setgait.yaml: regress fixture config written and consumed bygait regress init|add|bootstrap|rungait policy *: explicit policy authoring commands that remain supported for custom file paths, includinggait.policy.yamlgait regress *: deterministic regress workflow commands;regress addis a convenience path over the same fixture semantics asregress initgait trace: observe-only wrapper for integrations that already emit Gait trace referencesgait trace verify: shipped trace verification commandgait doctor --json: install-safe diagnostics for a clean writable directory; repo-only checks are additive and appear only in a Gait repo checkout
Onboarding JSON obligations:
gait doctor --jsonMUST remain truthful for the installed-binary lane and MAY add fields such asonboarding_modeor per-checkscopeonly additively.gait doctor --jsonMAY add machine-readable binary provenance fields only additively, includingbinary_path,binary_path_source,binary_version, andpath_binary_pathwhen the invoked executable differs from the PATH-resolvedgait.gait init --jsonandgait check --jsonnext_commandsMUST be executable in the environment they are emitted for, or MUST include an explicit repo/fetch step in the command text.
Canonical migration notes:
- Policy DSL stays on the shipped repo-root contract:
schema_id,schema_version,default_verdict, optionalfail_closed, optionalmcp_trust, andrules. - Draft proposal keys such as
version,name,boundaries,defaults,trust_sources, andunknown_serverare not alternate supported syntax; they return deterministic migration guidance instead. - The canonical CLI surface is
gait mcp verifyandgait capture --out ...; draft proposal spellings such asgait mcp-verifyandgait capture --save-as ...are not separate commands.
Intent + receipt continuity conformance profile:
docs/contracts/intent_receipt_conformance.md
Versioning and compatibility rules
- Producers MUST emit
schema_idandschema_versionfor every primitive. - Producers and consumers MUST treat
schema_idandschema_versionas contract selectors. - Required fields for a schema version MUST NOT be removed or renamed without a major version change.
- Semantic changes to required fields MUST NOT occur without a version bump.
- Optional fields MAY be added in minor/patch versions if consumers can ignore unknown fields safely.
Standard Relationship Envelope (`relationship`, optional)
Purpose: emit graph-ready topology without changing required primitive contracts.
Fields (all optional):
parent_ref(kind,id)entity_refs[](kind,id)policy_ref(policy_id,policy_version,policy_digest,matched_rule_ids[])agent_chain[](identity,role)edges[](kind,from,to)
Producer obligations when present:
- MUST keep
relationshipadditive-only withinv1.x. - MUST normalize digest identifiers to lowercase.
- MUST deduplicate and deterministically sort
entity_refsandedges. - MUST include relationship fields in canonical JSON hashing/signing naturally (no out-of-band exclusion).
Consumer obligations:
- MUST tolerate absence of
relationship. - MUST ignore unknown additive fields within
relationshipinv1.xreaders. - MUST NOT treat relationship presence as required for base primitive validity.
IntentRequest (`gait.gate.intent_request`, `1.0.0`)
Purpose: normalized tool-call intent at the execution boundary.
Required fields:
schema_idschema_versioncreated_atproducer_versiontool_nameargstargetscontext
Producer obligations:
- MUST normalize and canonicalize values before computing digests.
- MUST provide a non-empty
tool_name. - MUST provide
context.identity,context.workspace, andcontext.risk_class. - MAY include enterprise passthrough context when available:
context.auth_context(object)context.credential_scopes(string array)context.environment_fingerprint(string)
- MAY include context-proof linkage fields:
context.context_set_digest(sha256 hex)context.context_evidence_mode(best_effort|required)context.context_refs(string array of reference ids)
- SHOULD provide
args_digestandintent_digestwhen available. - MAY include script intent fields for compound workflows:
script.steps[](ordered step list with per-steptool_name,args, optionaltargets, optionalarg_provenance)script_hash(sha256 hex over canonical script payload)
- SHOULD provide
skill_provenancewhen execution originates from a packaged skill. - SHOULD provide
delegationwhen tool execution is delegated across agents:requester_identity- delegation
chainlinks scope_classtoken_refs
Delegation obligations:
- Producers MUST keep
delegation.chain[]contiguous: each link'sdelegator_identitymust equal the previous link'sdelegate_identity. - Producers MUST terminate
delegation.chain[]atdelegation.requester_identity. - Consumers MUST require signed token evidence for every claimed delegation hop before treating the chain as authorizing input.
- Consumers MUST enforce policy-required delegation scope against the delegation token's signed
scopeor signedscope_class, not against unsigned intent fields alone.
Consumer obligations:
- MUST fail closed for high-risk paths when intent cannot be evaluated.
- MUST NOT execute side effects on non-
allowoutcomes. - MUST treat incoming
context.context_set_digest,context.context_evidence_mode, andcontext.auth_context.context_age_secondsas transport claims only; context-required enforcement becomes authoritative only aftergait gate evalbinds a verified--context-envelopeat the boundary.
Script mode semantics:
- Producers MUST keep
script.steps[]order stable because evaluation and digesting are order-sensitive. - Producers MUST keep step payloads canonicalizable (objects/arrays only, no non-JSON values).
- Consumers MUST evaluate script mode deterministically and preserve stable reason-code ordering.
GateResult (`gait.gate.result`, `1.0.0`)
Purpose: deterministic policy decision output for one IntentRequest.
Required fields:
schema_idschema_versioncreated_atproducer_versionverdictreason_codesviolations
Verdicts:
allowblockdry_runrequire_approval
Producer obligations:
- MUST emit one of the allowed verdicts.
- MUST provide deterministic
reason_codesordering.
Consumer obligations:
- MUST execute tool call only when verdict is
allow. - MUST block execution on
block,require_approval,dry_run, or evaluation error.
TraceRecord (`gait.gate.trace`, `1.0.0`)
Purpose: signed, auditable decision trace linked to intent and policy digests.
Required fields:
schema_idschema_versioncreated_atproducer_versiontrace_idtool_nameargs_digestintent_digestpolicy_digestverdict
Producer obligations:
- MUST bind
verdicttointent_digestandpolicy_digest. - SHOULD include signature data for tamper-evident traces in production paths.
- SHOULD carry
skill_provenancethrough from intent when present. - SHOULD carry
delegation_refwhen delegated execution evidence is present. - SHOULD include
observed_atfor runtime wall-clock incident reconstruction. - SHOULD include
event_idas a per-emission runtime identity. - SHOULD include script-governance metadata when script mode is evaluated:
script,step_count,script_hashcomposite_risk_classstep_verdicts[]pre_approved,pattern_id,registry_reasoncontext_sourcewhen Wrkr enrichment is applied
- SHOULD include
mcp_trustwhen MCP trust preflight or runtime trust enforcement is active so audits can see the local decision source and fail-closed reason codes. - SHOULD carry context-proof linkage when present in intent:
context_set_digestcontext_evidence_modecontext_ref_count
- MAY carry standardized graph links in
relationshipfor topology queries.
Consumer obligations:
- MUST verify trace integrity when verification is required by policy/profile.
- MUST treat signature verification failure as non-passing.
Time-field semantics:
created_at: deterministic decision timestamp used in cryptographic binding.observed_at: operational runtime timestamp for timeline reconstruction only.event_id: emission identity for retained runtime events; multiple events may share one deterministictrace_id.
Runpack (`gait.runpack.*`, `1.0.0`)
Purpose: deterministic artifact for replay, diff, verify, and regress.
Manifest schema:
schema_id:gait.runpack.manifestschema_version:1.0.0- required fields:
schema_idschema_versioncreated_atproducer_versionrun_idcapture_modefilesmanifest_digest
Archive file contract:
- Runpack zip MUST contain:
manifest.jsonrun.jsonintents.jsonlresults.jsonlrefs.json
- Runpack refs MAY include context-proof summary:
context_set_digestcontext_evidence_modecontext_ref_count
Producer obligations:
- MUST generate byte-stable artifacts for identical inputs.
- MUST use RFC 8785 (JCS) canonicalization for digest-bearing JSON.
- MUST record
capture_mode(referencedefault,rawexplicit). - SDK or wrapper helper inputs MAY omit digest-bearing fields only when a Go-authoritative normalization path computes them before artifact emission.
Consumer obligations:
- MUST verify manifest and file digests before trust.
- MUST treat missing required files or digest mismatches as verification failure.
- MUST treat duplicate ZIP entry names in artifact archives as verification failure.
- MUST treat
context_evidence_mode=requiredwith missingcontext_set_digestas invalid input.
PackSpec (`gait.pack.*`, `1.0.0`)
Purpose: unified artifact envelope for run and job evidence types.
Manifest schema:
schema_id:gait.pack.manifestschema_version:1.0.0- required fields:
schema_idschema_versioncreated_atproducer_versionpack_idpack_type(run|job)source_refcontents
Producer obligations:
- MUST produce deterministic zip bytes for identical inputs.
- MUST include only declared files in
contents. - MUST use JCS canonicalization for digest/signature inputs.
- SHOULD include
context_envelope.jsonin run packs when context evidence is present.
Consumer obligations:
- MUST verify declared file hashes and reject undeclared files.
- MUST treat schema mismatch and hash mismatch as verification failure.
- MUST treat duplicate ZIP entry names as verification failure even when one duplicate would otherwise satisfy the declared hash.
- SHOULD support legacy runpack/evidence verification during v2.4 compatibility window.
- SHOULD expose deterministic context drift summary in diff outputs when context data exists.
Command Contract Additions (v2.5)
gait run record:--context-envelope--context-evidence-mode best_effort|required--unsafe-context-raw- additive normalization helpers may be used by thin SDK/wrapper lanes so Go computes digest-bearing record fields before runpack emission
gait regress run:--context-conformance--allow-context-runtime-drift
gait pack diff --json:- emits
context_drift_classification,context_changed,context_runtime_only_changeswhen applicable
- emits
Command Contract Additions (Script Governance)
gait gate eval:- supports script-intent evaluation with deterministic step rollup metadata in JSON output
- supports Wrkr enrichment via
--wrkr-inventory - supports signed pre-approved fast-path via:
--approved-script-registry--approved-script-public-keyor--approved-script-public-key-env
- missing approved-script verify keys disable fast-path in standard low-risk mode and fail closed in high-risk /
oss-prodpaths
gait approve-script:- creates signed approved-script entries bound to policy digest + script hash
gait list-scripts:- lists registry entries with expiry/active status
Session Chain Artifacts (`gait.runpack.session_*`, `1.0.0`)
Purpose: append-only, crash-tolerant long-running capture with verifiable checkpoints.
Artifacts:
SessionJournal(gait.runpack.session_journal)SessionCheckpoint(gait.runpack.session_checkpoint)SessionChain(gait.runpack.session_chain)
Producer obligations:
- MUST append session events with monotonic sequence IDs.
- MUST link checkpoints using
prev_checkpoint_digest. - MUST preserve deterministic checkpoint runpack emission for identical journal prefixes.
Consumer obligations:
- MUST verify linkage continuity and per-checkpoint runpack integrity for chain-level trust.
- MUST treat missing checkpoints or digest-link mismatch as verification failure.
Interop contract for wrappers and sidecars
- Python wrappers and non-Python sidecars are transport/adoption layers.
- Go core remains authoritative for:
- canonicalization
- hashing/signing
- policy evaluation
- artifact verification
- Integrations MUST pass through these primitive contracts unchanged in meaning.
Enterprise consumer compatibility guard
- Enterprise control-plane consumers are downstream readers of OSS artifacts.
- Enterprise consumers MUST treat OSS primitive contracts as append-only within major
v1.x. - Enterprise consumers MUST ignore additive unknown fields.
- OSS MUST remain executable without any enterprise control plane dependency.
CI proof point:
scripts/test_ent_consumer_contract.shgenerates live v1.7 artifacts (runpack,trace,regress_result,signal_report) and validates deterministic enterprise-style ingestion plus additive-field tolerance.