Contract Field Reference

July 5, 2026 · View on GitHub

A single-page field reference for every Weaver contract type — both Core (9) and Extended (24).

For narrative and adoption guidance, read ARCHITECTURE.md, BOUNDARIES.md, and GLOSSARY.md. For a runnable code path, use QUICKSTART.md.


Source of truth and authority

If this document ever disagrees with a schema or dataclass, the schema or dataclass wins. Open an issue.


Conventions

  • Required means listed in the JSON Schema's required array (Core) or has no default in the Python dataclass (Extended).
  • Type uses JSON Schema vocabulary for Core (string, object, array<X>, string | null, enum{…}, date-time for ISO 8601) and Python typing vocabulary for Extended (str, Optional[X], List[X], Dict[str, str]).
  • Required ID fields (e.g., SelectableItem.id, ChoiceCard.id, RoutingDecision.id, Capability.id, CapabilityToken.token_id, PolicyDecision.decision_id, Frame.frame_id, Handle.handle_id, TraceEvent.event_id) carry minLength: 1. Optional ID-like fields (e.g., SelectableItem.capability_id, RoutingDecision.selected_item_id, TraceEvent.capability_id) are plain string or string | null without minLength. IDs are not required to be UUIDs; slug-style identifiers are common in sample payloads.
  • All Core schemas set additionalProperties: true, so adopters may add namespaced fields (e.g., x_myorg_*) without breaking validation.

Core types (9)

SelectableItem

Purpose: A single option presented to the LLM within a ChoiceCard.

Source of truth: contracts/json/selectable_item.schema.json · core.py SelectableItem

FieldTypeRequiredDescription
idstring (minLength 1)YesUnique identifier within its ChoiceCard.
labelstring (minLength 1)YesShort human-readable label. Safe to include in an LLM prompt.
descriptionstring (minLength 1)YesConcise description. Must not include raw tool-schema details (see I-03).
capability_idstringNoReference to the Capability this item maps to (used by agent-kernel).
metadataobjectNoImplementation-specific metadata. additionalProperties: true.

ChoiceCard

Purpose: A curated, bounded menu of SelectableItem objects presented to the LLM.

Source of truth: contracts/json/choice_card.schema.json · core.py ChoiceCard

FieldTypeRequiredDescription
idstring (minLength 1)YesUnique identifier for this ChoiceCard.
itemsarray<SelectableItem> (minItems 1, maxItems 20)YesOrdered options. 3–7 is the practical range for LLM selection.
context_hintstringNoOptional guidance for the LLM about how to interpret this card.
metadataobjectNoImplementation-specific metadata.

RoutingDecision

Purpose: The output of the contextweaver routing phase. Wraps one or more ChoiceCard objects with selection state and a timestamp.

Source of truth: contracts/json/routing_decision.schema.json · core.py RoutingDecision

FieldTypeRequiredDescription
idstring (minLength 1)YesUnique identifier for this routing decision.
choice_cardsarray<ChoiceCard> (minItems 1)YesOne or more cards presented during this cycle.
timestampstring (date-time)YesISO 8601 creation time.
selected_item_idstring | nullNoItem the LLM chose; null while awaiting response.
selected_card_idstring | nullNoCard containing the selected item.
context_summarystringNoBrief diagnostic summary for audit.
metadataobjectNoImplementation-specific metadata.

Capability

Purpose: A named, versioned unit of executable functionality registered in agent-kernel.

Source of truth: contracts/json/capability.schema.json · core.py Capability

FieldTypeRequiredDescription
idstring (minLength 1)YesStable, namespaced identifier (e.g., org.myapp.search_docs).
namestring (minLength 1)YesHuman-readable name.
versionstring (minLength 1)YesSemantic version of this capability.
descriptionstring (minLength 1)YesWhat the capability does and when to use it.
input_schema_refstringNoURI to the JSON Schema describing valid inputs.
output_schema_refstringNoURI to the JSON Schema describing the Frame content.
tagsarray<string>NoOptional tags for categorization.
metadataobjectNoImplementation-specific metadata.

CapabilityToken

Purpose: A scoped authorization credential for capability invocation. Issued by agent-kernel.

Source of truth: contracts/json/capability_token.schema.json · core.py CapabilityToken

FieldTypeRequiredDescription
token_idstring (minLength 1)YesUnique identifier for this token.
principalstring (minLength 1)YesIdentity (user, agent, or service) this token was issued to.
scopearray<string> (minItems 1)YesCapability IDs this token authorizes. Unbounded scope is not permitted (I-06).
issued_atstring (date-time)YesISO 8601 issuance timestamp.
expires_atstring | null (date-time)ConditionalRequired unless single_use=true. Enforced by an anyOf constraint in the schema and by __post_init__ in Python.
single_useboolean (default false)NoWhen true, the token is invalidated after one successful authorization.
issuerstringNoOptional identifier of the issuing agent-kernel instance.
metadataobjectNoImplementation-specific metadata.

The token must either be single-use or carry an expiry. This is invariant I-06 and is enforced structurally by the anyOf clause in the schema and at construction time in Python. The word "signed" used in the Glossary is aspirational — the current contract does not encode cryptographic verification.

PolicyDecision

Purpose: The authorization verdict produced by agent-kernel's policy engine.

Source of truth: contracts/json/policy_decision.schema.json · core.py PolicyDecision

FieldTypeRequiredDescription
decision_idstring (minLength 1)YesUsed to correlate with TraceEvent entries.
decisionenum{"allow","deny"}YesThe verdict.
capability_idstring (minLength 1)YesThe capability evaluated.
principalstring (minLength 1)YesPrincipal whose authorization was evaluated.
timestampstring (date-time)YesISO 8601 decision time.
token_idstring | nullNoCapabilityToken ID used, if any.
reasonstringNoHuman-readable explanation. Recommended for deny.
metadataobjectNoImplementation-specific metadata.

Frame

Purpose: Safe, filtered view of a tool execution result. Produced by the agent-kernel firewall.

Source of truth: contracts/json/frame.schema.json · core.py Frame

FieldTypeRequiredDescription
frame_idstring (minLength 1)YesUnique identifier for this Frame.
capability_idstring (minLength 1)YesCapability that produced this Frame.
summarystring (minLength 1)YesLLM-safe summary. Never contains raw output (I-01, I-05).
created_atstring (date-time)YesISO 8601 creation timestamp.
structured_dataobject | nullNoFirewall-filtered structured subset approved for LLM consumption.
handle_refsarray<string> (each minLength 1)NoHandle IDs referencing raw artifacts. Resolution requires authorization.
redaction_notesstringNoDescription of what was redacted or filtered.
metadataobjectNoImplementation-specific metadata.

Handle

Purpose: Opaque, access-controlled reference to a raw artifact. The artifact lives in the HandleStore; the Handle carries only the reference plus access metadata.

Source of truth: contracts/json/handle.schema.json · core.py Handle

FieldTypeRequiredDescription
handle_idstring (minLength 1)YesReference identifier. Must not be sufficient for unauthorized access.
capability_idstring (minLength 1)YesCapability that produced the referenced artifact.
artifact_typestring (minLength 1)YesMIME or semantic type (e.g., application/json, image/png).
created_atstring (date-time)YesISO 8601 creation timestamp.
expires_atstring | null (date-time)NoOptional artifact expiry.
access_policystringNoReference to the policy governing who can resolve this Handle.
byte_sizeinteger | null (minimum 0)NoOptional artifact size for capacity planning.
metadataobjectNoImplementation-specific metadata.

TraceEvent

Purpose: Immutable audit log entry for a single significant lifecycle event. Append-only.

Source of truth: contracts/json/trace_event.schema.json · core.py TraceEvent

FieldTypeRequiredDescription
event_idstring (minLength 1)YesUnique event identifier.
event_typeenum{…}YesOne of the values listed below.
timestampstring (date-time)YesISO 8601 event time.
capability_idstring | nullNoCapability involved, if applicable.
principalstring | nullNoPrincipal involved, if applicable.
decision_idstring | nullNoAssociated PolicyDecision, if applicable.
frame_idstring | nullNoAssociated Frame, if applicable.
handle_idstring | nullNoAssociated Handle, if applicable.
outcomeenum{"success","failure","partial"}NoHigh-level outcome.
error_messagestring | nullNoError message for failure events.
metadataobjectNoImplementation-specific metadata.

Allowed event_type values: capability_authorized, capability_denied, capability_executed, firewall_applied, handle_created, handle_resolved, token_issued, token_invalidated, flow_started, flow_step_started, flow_step_completed, flow_completed, flow_failed. Adding a new value requires a spec update (see CONTRIBUTING.md).


Extended types (23)

Extended types are optional. None is required for spec compliance. Each has a JSON Schema in contracts/json/extended/ (the source of truth) mirrored by a dataclass in contracts/python/src/weaver_contracts/extended.py. Per VERSIONING.md, Extended contracts may have breaking changes in MINOR versions.

Adopters typically attach Extended objects to their own payloads via the metadata field of a Core contract (Core schemas set additionalProperties: true), or by composing them into Extended wrappers like ExtendedFrameMetadata.

TelemetryHint

Purpose: Observability metadata attachable to any event or contract.

Source of truth: extended.py TelemetryHint

FieldTypeRequiredDescription
trace_idOptional[str] (default None)NoDistributed-trace identifier.
span_idOptional[str] (default None)NoSpan identifier within the trace.
baggageDict[str, str] (default {})NoFree-form trace baggage.

Relationship to Core: Carried as metadata alongside any Core contract — most commonly on Frame or TraceEvent payloads.

Example:

{
  "trace_id": "trace-20260308-001",
  "span_id": "span-20260308-001",
  "baggage": {"tenant": "acme", "request_id": "req-20260308-001"}
}

SchemaFingerprint

Purpose: Records the schema version and content hash for a contract payload, supporting schema evolution and drift detection.

Source of truth: extended.py SchemaFingerprint

FieldTypeRequiredDescription
schema_idstr (non-empty)YesThe schema's $id (or another stable identifier).
schema_versionstr (non-empty)YesVersion of the schema referenced.
content_hashOptional[str] (default None)NoHex digest of the payload (length depends on hash_algorithm).
hash_algorithmstr (default "sha256")NoHash algorithm; default produces a 64-character hex digest.

Relationship to Core: Pairs with any Core payload to declare "this object validates against schema X version Y". Useful when receiver and sender may have different schema generations.

Example:

{
  "schema_id": "https://weaver-spec.dev/contracts/v0/frame.schema.json",
  "schema_version": "0.2.0",
  "content_hash": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
  "hash_algorithm": "sha256"
}

RedactionPolicy

Purpose: Describes the redaction rules applied by the firewall when producing a Frame.

Source of truth: extended.py RedactionPolicy

FieldTypeRequiredDescription
policy_idstr (non-empty)YesIdentifier of the policy applied.
redacted_fieldsList[str] (default [])NoField paths that were redacted.
truncated_fieldsList[str] (default [])NoField paths that were truncated.
redaction_reasonOptional[str] (default None)NoHuman-readable reason.
pii_detectedbool (default False)NoWhether PII was found in raw output.
pii_typesList[str] (default [])NoCategories of PII detected.

Relationship to Core: Documents the firewall transformation that produced a Frame. Composed into ExtendedFrameMetadata.redaction_policy.

Example:

{
  "policy_id": "policy-default-2026Q1",
  "redacted_fields": ["headers.authorization"],
  "truncated_fields": ["body.text"],
  "redaction_reason": "Detected secret in upstream response.",
  "pii_detected": true,
  "pii_types": ["email"]
}

UIHint

Purpose: Display guidance for UI layers that render ChoiceCard items.

Source of truth: extended.py UIHint

FieldTypeRequiredDescription
iconOptional[str] (default None)NoIcon identifier or URI.
colorOptional[str] (default None)NoDisplay color (CSS, theme token, etc.).
priorityOptional[int] (default None)NoDisplay priority.
groupOptional[str] (default None)NoLogical grouping label.
disabledbool (default False)NoWhether the item should be rendered as disabled.
tooltipOptional[str] (default None)NoHover tooltip text.

Relationship to Core: Pairs with a SelectableItem or ChoiceCard for clients that render the menu. Composed into ExtendedSelectableItemMetadata.ui_hint.

Example:

{
  "icon": "search",
  "color": "#1f6feb",
  "priority": 1,
  "group": "retrieval",
  "tooltip": "Full-text search across docs."
}

RiskAssessment

Purpose: Optional risk metadata for a capability invocation.

Source of truth: extended.py RiskAssessment

FieldTypeRequiredDescription
risk_levelenum{"low","medium","high","critical"} (default "low")NoRisk classification. Validated in __post_init__.
risk_reasonsList[str] (default [])NoFree-form rationale entries.
requires_human_approvalbool (default False)NoWhether the invocation requires a human approver.
approval_principalOptional[str] (default None)NoIdentity required to approve.
mitigationsList[str] (default [])NoMitigations already applied.

Relationship to Core: Pairs with a RoutingDecision, PolicyDecision, or SelectableItem to convey risk. Composed into ExtendedSelectableItemMetadata.risk_assessment.

Example:

{
  "risk_level": "high",
  "risk_reasons": ["destructive_action"],
  "requires_human_approval": true,
  "approval_principal": "user:operator-on-call",
  "mitigations": ["dry_run_preview"]
}

ExtendedFrameMetadata

Purpose: Wrapper that bundles common Extended metadata for a Frame.

Source of truth: extended.py ExtendedFrameMetadata

FieldTypeRequiredDescription
redaction_policyOptional[RedactionPolicy] (default None)NoPolicy applied by the firewall.
telemetryOptional[TelemetryHint] (default None)NoObservability metadata.
schema_fingerprintOptional[SchemaFingerprint] (default None)NoSchema version and content hash.
confidence_scoreOptional[float] (default None)NoOptional confidence value attached by the firewall.
source_capability_versionOptional[str] (default None)NoVersion of the capability that produced the underlying artifact.
extraDict[str, Any] (default {})NoFree-form additional metadata.

Relationship to Core: Attach to a Frame (typically inside Frame.metadata) to enrich it without modifying the Core schema.

Example:

{
  "redaction_policy": {
    "policy_id": "policy-default-2026Q1",
    "redacted_fields": ["headers.authorization"]
  },
  "telemetry": {"trace_id": "trace-20260308-001"},
  "confidence_score": 0.93,
  "source_capability_version": "1.4.0"
}

ExtendedSelectableItemMetadata

Purpose: Wrapper that bundles UI and risk metadata for a SelectableItem.

Source of truth: extended.py ExtendedSelectableItemMetadata

FieldTypeRequiredDescription
ui_hintOptional[UIHint] (default None)NoDisplay metadata.
risk_assessmentOptional[RiskAssessment] (default None)NoRisk metadata.
estimated_duration_msOptional[int] (default None)NoEstimated time to complete the action.
requires_confirmationbool (default False)NoWhether the UI should require a confirmation step.
extraDict[str, Any] (default {})NoFree-form additional metadata.

Relationship to Core: Attach to a SelectableItem (typically inside SelectableItem.metadata) to provide UI and risk hints without modifying the Core schema.

Example:

{
  "ui_hint": {"icon": "delete", "color": "#cf222e"},
  "risk_assessment": {"risk_level": "high", "requires_human_approval": true},
  "estimated_duration_ms": 800,
  "requires_confirmation": true
}

Updating this reference

This file mirrors the JSON Schemas in contracts/json/ and the Python dataclasses in extended.py. When either source changes, update the corresponding row(s) in the same PR. Treat the schema or dataclass as authoritative; this document is derived.