Skip to content

Protocol Layers

The GRACE Protocol is organized into five specification layers, each addressing a distinct category of problems in agentic prompt architecture. These layers are implemented in STRATT packages and stacked vertically with strict dependency rules: lower layers have zero knowledge of higher layers.

Problem: Silent contract drift — units change their output shapes without detection, causing downstream cascades of failures.

Defines:

  • Five unit types: role, rule, task, chain, supply
  • Typed contracts: Input/output contracts with declared types (string, integer, float, boolean, document, array, object)
  • Failure modes: Four strategies per unit (gate, retry, abort, fallback)
  • Change classification: Breaking (major version bump), additive (minor), patch (bug fix only)
  • CI enforcement: Automatic version bump validation — if you change a contract, CI rejects it unless the version number reflects the breaking change

Implemented in:

ComponentPackagePath
Unit type validators@stratt/schemapackages/schema/src/types/
Contract schema@stratt/schemapackages/schema/src/types/contract.ts
Change classification@stratt/clipackages/cli/src/commands/diff.ts
CI enforcement (FM-06)@stratt/graphpackages/graph/src/protect.ts

Example contract:

unit:
type: task
inputs:
- name: document
type: document
required: true
- name: style_guide
type: document
required: false
outputs:
- name: formatted_document
type: document
- name: confidence
type: float
failure_modes:
- gate: EDITOR-04 # block until human approval
- retry: 3 # retry up to 3 times
- fallback: null # no fallback; fail hard

SPEC-02: Blake3 Fingerprint & Tamper Detection

Section titled “SPEC-02: Blake3 Fingerprint & Tamper Detection”

Problem: No way to verify that the prompt executing in production is the one that was authored, reviewed, and approved. A unit could be silently modified after publishing.

Defines:

  • Canonical serialization: A 5-stage pipeline that normalizes YAML into a deterministic byte sequence
  • Blake3 hashing: Hash the canonical sequence → 64-character hex digest
  • Fingerprint format: blake3:{64 hex chars} (lowercase)
  • Four verification states: unpublished, verified, drift (changed locally), tampered (changed in registry)
  • Chain fingerprints as Merkle trees: A chain’s fingerprint is the root hash of all its steps’ fingerprints
  • Atomic publishing: Fingerprint is committed to the registry; if the R2 write fails, the entire publish is rolled back

Implemented in:

ComponentPackagePath
Canonical serialization@stratt/fingerprintpackages/fingerprint/src/canonicalise.ts
Blake3 hashing@stratt/fingerprintpackages/fingerprint/src/hash.ts
Verification@stratt/fingerprintpackages/fingerprint/src/verify.ts
14 test vectors@stratt/fingerprintpackages/fingerprint/tests/vectors.ts
CI check (FM-01)@stratt/graphpackages/graph/src/ci.ts
SPUH binary encoding@stratt/schemapackages/schema/src/spuh.ts

Critical constraint: The blake3-wasm library is pinned to version 2.1.5 exactly. Version 3.0.0 introduced an async API break and is incompatible.

Failure mode FM-01: Fingerprint tamper detected (Blake3 digest mismatch).

Problem: Modifying a core unit without knowing it’s imported by dozens of other units causes cascade failures across the ecosystem.

Defines:

  • DAG (Directed Acyclic Graph) model: Every unit imports explicitly; no implicit references
  • Cycle detection (Kahn’s algorithm): The graph must be acyclic; any import cycle is rejected immediately
  • Blast radius computation: When you modify a unit, the system computes which other units (transitively) depend on it
  • Domain isolation: Cross-domain imports are only allowed via core/ and shared/ domains
  • Protected unit enforcement: Certain units cannot be changed without a version bump or gate approval

Implemented in:

ComponentPackagePath
DAG construction@stratt/graphpackages/graph/src/dag.ts
Blast radius computation@stratt/graphpackages/graph/src/blast.ts
Import resolution@stratt/graphpackages/graph/src/resolve.ts
Cycle detection (FM-03)@stratt/graphpackages/graph/src/dag.ts
Domain isolation (FM-07)@stratt/graphpackages/graph/src/protect.ts
Cross-namespace resolution@stratt/graphpackages/graph/src/namespace.ts
Choco bridge resolver@stratt/graphpackages/graph/src/choco-resolver.ts

Failure modes:

  • FM-03: Circular dependency detected (import cycle)
  • FM-07: Draft isolation failure (stable unit importing a draft unit)

Problem: Autonomous chains producing plausible-looking output that is subtly wrong, with no detection mechanism. A chain executes 100% autonomously and produces garbage — detected only after it breaks downstream systems.

Defines:

  • Hard synchronization primitives: Chain halts completely; human must approve before continuing
  • Four terminal states:
    • APPROVED — human approves, chain continues
    • REJECTED — human rejects, chain fails (no fallback)
    • TIMEOUT (24h default) — if no human response in 24 hours, escalate to superior council
    • ESCALATED — routed to higher authority
  • Gate authority agents (one per council): LEWIS-06 (Pathfinder), RETRO-04 (Hermes), EDITOR-04 (Athena), etc.
  • Protected agents (cannot be bypassed): BECK-02, EECOM-02, CURATOR-02, and others
  • Audit records: Every gate resolution is logged with timestamp, approver, reason, and affected unit
  • Veritas gate (for DSPy-optimized unit promotion): Automatic gate that triggers when regression score exceeds threshold

Implemented in:

ComponentPackagePath
Gate approval workflow@stratt/clipackages/cli/src/commands/gate.ts
Protected agent checks (FM-04)@stratt/graphpackages/graph/src/protect.ts
Gate removal detection (FM-05)@stratt/graphpackages/graph/src/protect.ts
Council configurationscouncils/{pathfinder,hermes,athena}/council.yaml

Failure modes:

  • FM-04: Protected agent missing (chain lacks required protected agent for domain)
  • FM-05: Gate removal (gate step removed without major version bump)

Example gate in a chain:

steps:
- name: draft-proposal
unit: stratt://docs/task/draft-proposal@1.0.0
- name: human-review-gate
unit: stratt://core/gate/editorial-review@1.0.0
config:
authority: EDITOR-04
timeout_hours: 24
escalate_to: CURATOR-02
- name: publish
unit: stratt://docs/task/publish@1.0.0

SPEC-05: Execution Trace & Audit Specification

Section titled “SPEC-05: Execution Trace & Audit Specification”

Problem: No way to answer which units improved, which degraded, which gates fired most often — after months of running chains in production.

Defines:

  • Mandatory trace creation: Every chain execution produces a structured trace (no opt-out)
  • Chain-level trace fields:
    • trace_id, chain_address, version, fingerprint
    • session_id, created_at, completed_at, status
    • quality_score, token_count_in, token_count_out
  • Step-level trace entries:
    • Unit address, agent assignment, input prompts, responses
    • Token counts per step, status transitions
    • Timing information (queued, started, completed)
  • Pluggable quality scorer:
    • Heuristic default: conformance + completeness + token efficiency
    • Custom scorers can be registered
  • DSPy JSONL export:
    • Export filtered traces for DSPy fine-tuning
    • Filtering: min score, date range, version range
  • Automated regression detection:
    • Quality score delta ≥ 0.05 triggers Veritas gate
    • Veritas evaluates units against last 3 successful runs

Implementation status: Implemented in Block I. Core components in @stratt/cli:

ComponentPackagePath
Trace reading@stratt/clilib/trace.ts
Run log merging@stratt/clilib/run-log-reader.ts
Regression detection@stratt/clilib/regression.ts
Veritas gate@stratt/clilib/veritas.ts
DSPy export@stratt/clicommands/export-dspy.ts
Regression command@stratt/clicommands/regression.ts
Gate integration@stratt/clicommands/gate.ts

Example trace output (JSONL format):

{
"trace_id": "tr_01aryz6s41tsqt0yp91qsydysq",
"chain_address": "stratt://ops/chain/incident-response@2.1.0",
"version": "2.1.0",
"fingerprint": "blake3:a1b2c3d4e5f6...",
"created_at": "2026-04-07T14:23:00Z",
"completed_at": "2026-04-07T14:28:15Z",
"status": "success",
"quality_score": 0.87,
"token_count_in": 2340,
"token_count_out": 1840,
"steps": [
{
"step_index": 0,
"unit_address": "stratt://ops/task/assess-severity@1.0.0",
"agent": "RETRO-04",
"status": "success",
"started_at": "2026-04-07T14:23:00Z",
"completed_at": "2026-04-07T14:24:10Z",
"token_in": 1200,
"token_out": 340
}
]
}
L6 MERIDIAN ← Astro documentation site (public-facing)
L5 @stratt/cli ← 24 commands, all orchestration
L4 @stratt/ir ← Execution IR, portable compilation (n8n, TypeScript, LangChain)
L3.5 @stratt/n8n-exporter ← Chain → n8n workflow compiler (FORGE pattern)
L3 @stratt/graph ← DAG, blast radius, CI pipeline (FM-01 through FM-08)
L2 @stratt/crdt ← Yjs-based CRDT, 7 merge strategies
L1 @stratt/schema ← Zod validators, URI parsing, SPUH binary encoding
L0 @stratt/fingerprint ← Canonical serialization → Blake3 hash

Dependency rule: Lower layers depend only on lower layers. Layer 5 can depend on Layers 0-4, but Layer 0 has zero dependencies on anything else.

SPECProvidesDepends onPrimary Package
SPEC-01ContractsL1 validators@stratt/schema + @stratt/cli
SPEC-02FingerprintsL0 hashing@stratt/fingerprint + @stratt/schema
SPEC-03DependenciesL1 URIs@stratt/graph
SPEC-04GatesL3 DAG@stratt/graph + @stratt/cli
SPEC-05TracesL5 commands@stratt/cli

Each SPEC defines one or more failure modes (FM), detectable during CI or runtime:

FM CodeSPECNameCondition
FM-01SPEC-02Fingerprint tamperBlake3 digest mismatch
FM-02SPEC-03Broken importsUnresolvable stratt:// or choco:// reference
FM-03SPEC-03DAG cyclesCircular dependency detected
FM-04SPEC-04Protected agent missingChain lacks required protected agent
FM-05SPEC-04Gate removalGate step removed without major version bump
FM-06SPEC-01Contract breaking changeRequired input removed or type changed without major bump
FM-07SPEC-03Draft isolationStable unit importing a draft unit
FM-08R2 infrastructure failureRegistry unavailable
FM-09SPEC-04Capability checkAgent assigned to step lacks required capability
GapSPECTarget
R2 atomic publish pipelineSPEC-02Production registry writes (currently local-only)
HTTP mode for ChocoBridgeResolverSPEC-03choco:// resolution via API endpoint
MIPROv2 optimization loopSPEC-05Automated prompt refinement via DSPy
Veritas auto-trigger automationSPEC-05Event-driven regression detection