Building the Accumulated Context Graph: The Five Governed State Domains, Temporal Validity Controls, and Postgres Implementation Architecture
The Architectural Deficit: Beyond Semantic Similarity and Naive RAG
The prevailing architecture for enterprise agentic software relies on a dangerous assumption: that retrieval of similar text is equivalent to understanding institutional reality.
When engineering teams build autonomous systems using basic Retrieval-Augmented Generation (RAG) or vector memory buffers, they optimize primarily for semantic relevance. A query is embedded, cosine distance is computed across a vector index, and the top-$k$ text fragments are injected into the agent's prompt window.
In high-consequence enterprise environments—commercial underwriting, clinical healthcare workflows, regulatory compliance, and infrastructure management—semantic retrieval alone is structurally insufficient.
| Retrieval Dimension | Basic Semantic RAG | Accumulated Context Graph (ACG) |
|---|---|---|
| Operational Goal | Maximize semantic similarity ($k$-NN vector match) | Enforce deterministic institutional admissibility |
| Evaluation Query | "Does this text chunk look similar to the prompt?" | "Is this precedent authorized, active, unrevoked, and in scope?" |
| Temporal Awareness | Blind to timestamp expiration and policy revisions | Hard TTLs, review intervals, and supersession gates |
| Authority Boundary | Ingests all indexed text equally regardless of author role | Verifies authorizer role tier against structural hierarchy |
| Failure Mode | Hallucinated compliance via outdated or unverified text | Deterministic rejection of inadmissible context before prompt assembly |
RAG and ACG are not mutually exclusive. In a governed architecture, semantic search serves a specific, bounded discovery role:
RAG discovers candidate context. The Accumulated Context Graph determines what is admissible. Policy and authority determine what is permitted. Execution and outcome records determine what the organization learns next.
Unverified material may be used as a discovery or hypothesis signal, but it must never be treated as governing precedent or authorize a consequential state transition. An ACG does not guarantee recall; it guarantees admissibility.
The Five Governed State Domains
An enterprise is not a flat collection of documents or a single hierarchical tree. It is a dynamic network of reporting authorities, operating policies, execution logs, approved exceptions, and real-world outcomes.
To govern agent autonomy, an ACG structures persistent institutional context across five governed state domains:
flowchart TD
subgraph ACG["ACCUMULATED CONTEXT GRAPH (Governed State Domains)"]
direction TB
subgraph S1["1. STRUCTURAL STATE (Topology & IAM)"]
A1["Entities, Account Hierarchies, Roles & Effective Authority Context"]
end
subgraph S2["2. EPISODIC & OUTCOME STATE (Execution Ledger)"]
A2["Append-Only Inferences, Tool Calls, Rollback Logs & Observed Results"]
end
subgraph S3["3. PRECEDENT STATE (The Compounding Asset)"]
A3["Authorized Overrides, Scoped Exceptions & Revalidation Triggers"]
end
subgraph S4["4. POLICY STATE (Machine-Executable Rules)"]
A4["Policy-as-Code Declarations, Hard Limit Invariants & Versioned ASTs"]
end
subgraph S5["5. ADJUDICATION STATE (Dispute Workflow)"]
A5["Escalation Records, Contested Judgments & Committee Workflows"]
end
S1 <--> S4
S2 --> S3
S4 --> S3
S3 <--> S5
S2 -. "Observed Outcomes Validate Precedents" .-> S3
end
style ACG fill:#09090b,stroke:#10b981,stroke-width:2px,color:#ffffff
style S1 fill:#18181b,stroke:#3b82f6,stroke-width:1.5px,color:#ffffff
style S2 fill:#18181b,stroke:#64748b,stroke-width:1.5px,color:#ffffff
style S3 fill:#064e3b,stroke:#10b981,stroke-width:2px,color:#ffffff
style S4 fill:#1e1b4b,stroke:#8b5cf6,stroke-width:1.5px,color:#ffffff
style S5 fill:#451a03,stroke:#f97316,stroke-width:1.5px,color:#ffffff
1. Structural State (Organizational Topology & Identity)
- What It Stores: The baseline relational model of the enterprise—entities, account hierarchies, customer risk tiers, department structures, and role-based authority ceilings.
- Governance Function: Informs the agent who is who and what effective authority context applies. It prevents a junior analyst from being treated as an authorized policy signer.
- Storage Pattern: Relational tables with foreign-key bindings to enterprise IAM and identity providers.
2. Episodic & Outcome State (Execution & Verification Ledger)
- What It Stores: An append-only log of every inference call, tool mutation, agent proposal, user override, and subsequent observed real-world outcome (e.g., loan repayment history, audit findings, or downstream system errors), alongside rollback and compensating action status.
- Governance Function: Provides forensic traceability and closes the feedback loop by recording whether past decisions succeeded or failed in production.
- Storage Pattern: Append-only event tables with immutable timestamps, run IDs, and mutation snapshots.
3. Precedent State (Governed Overrides & Scoped Exceptions)
- What It Stores: The structured repository of human-authorized exceptions and overrides that have passed through the Classification Gate.
- Governance Function: This is the primary compounding asset of the product. When an authorized supervisor overrides an agent and classifies the correction as a scoped precedent, the system records:
- The exact applicability condition envelope (e.g., "ARR > $500k AND Tenure > 3 years").
- The authorizing role and user ID at the time of creation.
- The temporal validity interval and dynamic revalidation triggers.
- Cohort-controlled outcome metrics across reuses.
- Storage Pattern: Versioned relational tables bound to parent policy revisions and entity scopes.
4. Policy State (Machine-Executable Constraints)
- What It Stores: The formal, machine-readable rules of the enterprise (Policy as Code).
- Governance Function: Defines non-negotiable boundaries, deterministic calculation rules, and statutory regulatory requirements that probabilistic LLMs are forbidden to violate.
- Storage Pattern: Versioned policy registry containing declarative schemas and immutable revision records.
5. Adjudication State (Active Disputes & Committee Resolutions)
- What It Stores: The state of active escalations where an agent's proposal is disputed, where two organizational policies conflict, or where a human override represents an unresolved judgment.
- Governance Function: Manages the lifecycle of decisions requiring multi-stakeholder human sign-off (e.g., Credit Committee reviews, Ethics Board deliberations). Once resolved, the adjudication outcome compiles into a Precedent State node.
- Storage Pattern: State-machine workflow records with audit timestamps and sign-off chains.
The PostgreSQL Blueprint: A Governed System of Record
An ACG can begin in PostgreSQL as the governed transactional system of record, with specialized stores (object stores, event streams, search indexes) added only where telemetry scale or specialized workflows justify them.
| Relational Table | State Domain | Immutability & Lifecycle | Core System Role & Access Pattern |
|---|---|---|---|
entities |
Layer 1: Structural | Mutable (IAM Sync) | Entity topology, risk ratings, and organizational authority boundaries. |
policies |
Layer 4: Policy | Mutable Metadata | Root policy registry, ownership metadata, and functional domains. |
policy_revisions |
Layer 4: Policy | Immutable AST | Versioned Policy-as-Code definitions; enforced via UNIQUE(policy_id, version). |
precedents |
Layer 3: Precedent | Governed Mutation | Human-authorized overrides, applicability scope, and review triggers. |
precedent_revocations |
Layer 3: Precedent | Append-Only | Immutable audit trail for instant global exception invalidation. |
precedent_evidence |
Layer 3: Precedent | Immutable Ledger | Cryptographic content hashes (SHA-256) and source URI citations. |
execution_events |
Layer 2: Episodic | Append-Only | Run-level tool mutations, structured proposals, and rollback payloads. |
decision_outcomes |
Layer 2: Outcome | Governed Append | Cohort tracking, empirical performance metrics, and audit verification. |
Production Relational Schema (PostgreSQL DDL)
-- ============================================================================
-- 1. POLICY STATE: Machine-Executable Rules & Versioned ASTs (Layer 4)
-- ============================================================================
CREATE TABLE policies (
policy_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name VARCHAR(255) NOT NULL,
domain VARCHAR(128) NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE policy_revisions (
policy_revision_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
policy_id UUID NOT NULL REFERENCES policies(policy_id) ON DELETE RESTRICT,
version VARCHAR(32) NOT NULL,
rules_schema JSONB NOT NULL,
is_active BOOLEAN NOT NULL DEFAULT TRUE,
effective_from TIMESTAMPTZ NOT NULL,
effective_until TIMESTAMPTZ,
approved_by UUID NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT uq_policy_version UNIQUE (policy_id, version)
);
CREATE INDEX idx_policy_revisions_active
ON policy_revisions (policy_id, is_active)
WHERE is_active = TRUE;
-- ============================================================================
-- 2. PRECEDENT STATE: Governed Overrides & Scoped Exceptions (Layer 3)
-- ============================================================================
CREATE TABLE precedents (
precedent_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
parent_policy_revision_id UUID NOT NULL REFERENCES policy_revisions(policy_revision_id),
authorizer_id UUID NOT NULL,
authorizer_role VARCHAR(128) NOT NULL,
authorization_tier VARCHAR(64) NOT NULL,
scope_conditions JSONB NOT NULL, -- e.g., {"tier": "commercial", "min_dscr": 1.15}
rule_mutation JSONB NOT NULL, -- Parameter override permitted by human supervisor
valid_from TIMESTAMPTZ NOT NULL,
valid_until TIMESTAMPTZ, -- Nullable if strictly governed by review triggers
next_review_at TIMESTAMPTZ,
revalidation_trigger VARCHAR(128), -- e.g., "quarterly_macro_review", "policy_revision_change"
superseded_by UUID REFERENCES precedents(precedent_id),
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_precedents_temporal
ON precedents (valid_from, valid_until, parent_policy_revision_id);
-- ============================================================================
-- 3. REVOCATION AUDIT & EVIDENCE BINDINGS (Layer 3 Integrity)
-- ============================================================================
CREATE TABLE precedent_revocations (
revocation_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
precedent_id UUID NOT NULL REFERENCES precedents(precedent_id) ON DELETE RESTRICT,
revoked_by UUID NOT NULL,
revoked_by_role VARCHAR(128) NOT NULL,
revoked_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
reason TEXT NOT NULL,
evidence_ref VARCHAR(512)
);
CREATE INDEX idx_revocations_lookup
ON precedent_revocations (precedent_id);
CREATE TABLE precedent_evidence (
evidence_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
precedent_id UUID NOT NULL REFERENCES precedents(precedent_id) ON DELETE CASCADE,
evidence_type VARCHAR(64) NOT NULL,
source_uri VARCHAR(512) NOT NULL,
content_hash VARCHAR(128) NOT NULL, -- SHA-256 cryptographic digest of source doc
retrieved_at TIMESTAMPTZ NOT NULL
);
-- ============================================================================
-- 4. EPISODIC & OUTCOME STATE: Execution Ledger & Verifications (Layer 2)
-- ============================================================================
CREATE TABLE execution_events (
event_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
workflow_id VARCHAR(128) NOT NULL,
agent_id VARCHAR(128) NOT NULL,
entity_id UUID NOT NULL,
applied_precedent_id UUID REFERENCES precedents(precedent_id),
applied_policy_revision_id UUID REFERENCES policy_revisions(policy_revision_id),
proposal JSONB NOT NULL,
mutation_payload JSONB NOT NULL,
rollback_payload JSONB,
status VARCHAR(64) NOT NULL, -- "executed", "compensated", "rolled_back"
executed_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_execution_events_entity
ON execution_events (entity_id, executed_at DESC);
CREATE TABLE decision_outcomes (
outcome_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
event_id UUID NOT NULL REFERENCES execution_events(event_id) ON DELETE RESTRICT,
observed_at TIMESTAMPTZ NOT NULL,
outcome_status VARCHAR(64) NOT NULL, -- "performing", "defaulted", "covenant_breached"
metrics_snapshot JSONB NOT NULL,
verification_type VARCHAR(64) NOT NULL, -- "automated_pipeline", "human_audit", "external_feed"
verified_by_id VARCHAR(128) NOT NULL,
verification_timestamp TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_decision_outcomes_event
ON decision_outcomes (event_id, observed_at);
How Do You Prevent State Decay? The Temporal Validity Engine
State is not permanently true merely because an authorized human once approved it.
In real-world enterprises, state decays along multiple vectors: * Fixed Time Windows: A temporary emergency pandemic exception expires. * Policy Version Supersession: The Risk Committee publishes Policy Rev 5.0, invalidating exceptions granted under Rev 4.2. * Authority Shifts: The executive who approved a local exception is replaced, or authority delegations narrow. * Dynamic Revalidation Triggers: A customer's risk tier changes, or source financial statements are withdrawn.
flowchart TD
A["Agent Query Triggered"] --> B["Semantic Discovery via pgvector"]
B --> C["Candidate Precedent Nodes Identified"]
C --> D{"Deterministic Admissibility Filter"}
D -- "Check 1: Temporal Window" --> E{"valid_from <= NOW() <= valid_until?"}
E -- "Expired" --> F["Node INADMISSIBLE (Pruned)"]
E -- "Valid" --> G{"Check 2: Active Policy Revision"}
G -- "Policy Revision Active?" --> H{"Parent Policy Revision Active?"}
H -- "Superseded" --> F
H -- "Active" --> I{"Check 3: Append-Only Revocation"}
I -- "Revocation Record Exists?" --> J{"precedent_revocations exists?"}
J -- "Yes (Revoked)" --> F
J -- "No" --> K{"Check 4: Applicability Predicate"}
K -- "Scope & Context Match?" --> L{"Applies(N, E, C, t) = True?"}
L -- "False" --> F
L -- "True" --> M["Node ADMISSIBLE"]
M --> N["Inject into Agent Context Window with Provenance Metadata"]
style A fill:#18181b,stroke:#64748b,stroke-width:1.5px,color:#ffffff
style B fill:#18181b,stroke:#3b82f6,stroke-width:1.5px,color:#ffffff
style C fill:#18181b,stroke:#3b82f6,stroke-width:1.5px,color:#ffffff
style D fill:#1e1b4b,stroke:#8b5cf6,stroke-width:2px,color:#ffffff
style E fill:#18181b,stroke:#f59e0b,stroke-width:1.5px,color:#ffffff
style F fill:#450a0a,stroke:#ef4444,stroke-width:2px,color:#ffffff
style G fill:#18181b,stroke:#f59e0b,stroke-width:1.5px,color:#ffffff
style H fill:#18181b,stroke:#f59e0b,stroke-width:1.5px,color:#ffffff
style I fill:#18181b,stroke:#f59e0b,stroke-width:1.5px,color:#ffffff
style J fill:#18181b,stroke:#f59e0b,stroke-width:1.5px,color:#ffffff
style K fill:#18181b,stroke:#f59e0b,stroke-width:1.5px,color:#ffffff
style L fill:#18181b,stroke:#f59e0b,stroke-width:1.5px,color:#ffffff
style M fill:#064e3b,stroke:#10b981,stroke-width:2px,color:#ffffff
style N fill:#064e3b,stroke:#10b981,stroke-width:2px,color:#ffffff
The Expressive Applicability Formulation
A candidate precedent node $N$ is evaluated as admissible for target entity $E$ in current context $C$ at time $t$ under active policy revisions $\mathcal{P}_t$ using deterministic logic:
$$ \text{Admissible}(N, E, C, t, \mathcal{P}_t) \iff \begin{cases} \text{TemporalValid}(N, t) & \iff t_{\text{from}} \le t \le t_{\text{until}} \land t \le t_{\text{review}} \\ \text{Applies}(N, E, C, t) & \iff \text{Scope}(N) \sqsubseteq (E, C) \\ \text{PolicyActive}(N, \mathcal{P}_t) & \iff \text{ParentPolicyRevision}(N) \in \mathcal{P}_t \\ \text{AuthorityValid}(N, t) & \iff \text{RoleTier}(N.\text{authorizer}) \ge \text{ReqTier}(N) \\ \neg\text{Revoked}(N) & \iff \text{COUNT}(\text{precedent_revocations}) = 0 \\ \text{EvidenceSufficient}(N) & \iff \forall e \in N.\text{evidence}: \text{Available}(e) \end{cases} $$
This check runs in deterministic application code or SQL before context assembly. The system prevents inadmissible organizational state from ever governing an agent action.
The Classification Gate: Governing Human Overrides
When a human supervisor overrides an agent's proposal, naive systems simply write the correction into a vector store or append it to a few-shot prompt. This pollutes the system with personal idiosyncrasies, political overrides, and unrepeatable exceptions.
The system should not learn from every correction. It should learn from corrections that have been classified, scoped, authorized, and validated.
The Classification Gate forces every human intervention through an explicit categorization schema:
flowchart TD
A["Human Override Event"] --> B["Classification Gate"]
B --> C1["1. Case-Specific Adjustment"]
B --> C2["2. Reusable Precedent"]
B --> C3["3. Policy Change"]
B --> C4["4. Data Correction"]
B --> C5["5. Contested Judgment"]
C1 --> D1["Layer 2: Episodic Ledger<br/>(Local run only; zero propagation)"]
C2 --> D2["Layer 3: Precedents<br/>(Scoped entity envelope + TTL)"]
C3 --> D3["Layer 4: Policy Revisions<br/>(Governance review & unit tests)"]
C4 --> D4["Layer 1: Structural State<br/>(Entity record mutation)"]
C5 --> D5["Layer 5: Adjudication State<br/>(Quorum & committee review)"]
style A fill:#18181b,stroke:#f59e0b,stroke-width:1.5px,color:#ffffff
style B fill:#1e1b4b,stroke:#8b5cf6,stroke-width:2px,color:#ffffff
style C1 fill:#18181b,stroke:#64748b,stroke-width:1.5px,color:#ffffff
style C2 fill:#064e3b,stroke:#10b981,stroke-width:2px,color:#ffffff
style C3 fill:#1e1b4b,stroke:#8b5cf6,stroke-width:1.5px,color:#ffffff
style C4 fill:#18181b,stroke:#3b82f6,stroke-width:1.5px,color:#ffffff
style C5 fill:#451a03,stroke:#f97316,stroke-width:1.5px,color:#ffffff
style D1 fill:#09090b,stroke:#64748b,stroke-width:1px,color:#cbd5e1
style D2 fill:#09090b,stroke:#10b981,stroke-width:1.5px,color:#cbd5e1
style D3 fill:#09090b,stroke:#8b5cf6,stroke-width:1.5px,color:#cbd5e1
style D4 fill:#09090b,stroke:#3b82f6,stroke-width:1px,color:#cbd5e1
style D5 fill:#09090b,stroke:#f97316,stroke-width:1.5px,color:#cbd5e1
The Gate Authority Matrix: Who Governs the Gate?
| Action | Permitted Role | Verification Required | Propagation Scope |
|---|---|---|---|
| Case-Specific Override | Line Operator / Underwriter | IAM Identity + Run ID | Local run only; zero global propagation |
| Create Scoped Precedent | Senior Officer / Lead Architect | Authority Tier $\ge 3$ + Evidence Hash | Scoped entity category with mandatory TTL |
| Extend Precedent TTL | Risk Committee / Department Head | Revalidation Trigger Review + Outcome Audit | Extends valid_until by fixed review window |
| Promote Precedent $\rightarrow$ Policy | Policy Committee / Head of Function | Formal Governance Sign-Off & AST Unit Test | Replaces baseline policy across all runs |
| Revoke Precedent | Compliance Officer / Auditor | Append to precedent_revocations |
Immediate global invalidation |
| Adjudicate Contested Override | Oversight Board / Multi-Sig Review | Quorum Approval + Adjudication Record | Resolves into Precedent or Policy Revision |
The Compounding Flywheel: Connecting Precedents to Observed Outcomes
The true defensibility of the ACG is that it turns static exception tracking into a compounding intelligence flywheel.
flowchart LR
A["1. Policy Revision Active"] --> B["2. Agent Proposal"]
B --> C["3. Supervisor Override & Classification"]
C --> D["4. Governed Precedent in ACG"]
D --> E["5. Autonomous Future Executions"]
E --> F["6. Observed Real-World Outcomes"]
F -. "Empirical Evidence Validates Precedent" .-> D
F -. "Automated Promotion Recommendation" .-> A
style A fill:#1e1b4b,stroke:#8b5cf6,stroke-width:1.5px,color:#ffffff
style B fill:#18181b,stroke:#64748b,stroke-width:1.5px,color:#ffffff
style C fill:#18181b,stroke:#f59e0b,stroke-width:1.5px,color:#ffffff
style D fill:#064e3b,stroke:#10b981,stroke-width:2px,color:#ffffff
style E fill:#18181b,stroke:#3b82f6,stroke-width:1.5px,color:#ffffff
style F fill:#09090b,stroke:#10b981,stroke-width:2px,color:#ffffff
Causality and Cohort Controls in Outcome Tracking:
Tracking outcomes is powerful, but engineering teams must guard against naive causal assumptions: * Cohort Comparability: Fifty successful loans under an exception may reflect a benign macroeconomic window or borrower selection bias rather than the safety of the exception rule itself. * Outcome Lag: In credit, healthcare, and engineering, catastrophic failures often take months or years to materialize. * Automated Promotion Recommendations (Not Automated Rewrites): Empirical outcome evidence can prioritize a precedent for formal committee review, but the system must never autonomously rewrite baseline policy without human governance sign-off.
The State-Transition Contract & DTBS Integration
Before an autonomous agent executes a consequential state mutation, the ACG control plane enforces an explicit 7-Point State-Transition Contract:
| # | Contract Dimension | Invariant Verified | Governing Domain | Hard Enforcement Rule |
|---|---|---|---|---|
| 1 | Current Actor Authority | Actor identity, active session, and delegated authority | Structural State (L1) | RoleTier(Actor) >= RequiredTier(Action) |
| 2 | Target Entity Scope | Target entity exists and falls within tenant/account boundary | Structural State (L1) | Entity.status == 'ACTIVE' AND InScope(Entity) |
| 3 | Active Policy Revision | Governing Policy-as-Code revision is active and in effect | Policy State (L4) | PolicyRevision.is_active == TRUE |
| 4 | Precedent Admissibility | Applied override is within temporal validity and unrevoked | Precedent State (L3) | TemporalValid(N) AND NOT Revoked(N) |
| 5 | Evidence Sufficiency | Mandatory evidence hashes are available and verifiable | Precedent State (L3) | COUNT(Evidence) >= RequiredEvidenceCount |
| 6 | Authority Ceiling Check | Proposed financial/risk mutation within delegated ceiling | Policy State (L4) | Mutation.amount <= Role.authorized_limit |
| 7 | Reversibility & Rollback | Mutation payload contains defined compensating action | Episodic State (L2) | rollback_payload IS NOT NULL |
This directly implements the Delegations-to-be-Supervised (DTBS) lifecycle across the five state domains:
| DTBS Stage | ACG State Domain Mapping | Governance Capability |
|---|---|---|
| Bound | Structural State + Policy State | Enforces role authority limits, entity scope, and policy invariants. |
| Detect | Episodic State + Outcome State | Monitors runtime execution events, outcome metrics, and revalidation triggers. |
| Verify | Precedent State + Evidence Bindings | Executes deterministic pre-assembly admissibility and provenance checks. |
| Recover | Execution Events (Rollback) + Adjudication State | Executes compensating actions, reverts mutations, and routes contested states. |
A Complete Implementation Walkthrough: Commercial Underwriting
To see the five state domains, the Temporal Validity Engine, and the Classification Gate in action, trace an execution cycle:
sequenceDiagram
autonumber
participant Human as Senior Credit Officer
participant Gate as Classification Gate
participant Agent as Underwriting Agent
participant DB as PostgreSQL State Store
participant TVE as Temporal Validity Filter
Agent->>DB: Query Precedents for Borrower X
DB->>TVE: Run Admissibility Query (TTL, Scope, Policy Rev 4.2)
TVE-->>DB: Filter Expired and Revoked Records, Retain Active Precedent
DB-->>Agent: Ingest Admissible Precedent and Evidence Metadata
Agent->>Agent: Generate Compliant Proposal with Proof Dossier
Agent->>Human: Present Recommendation with Linked Evidence
alt Human Confirms Recommendation
Human->>Gate: Approve
Gate->>DB: Log Execution Event and Rollback Payload
else Human Refines Terms
Human->>Gate: Adjust Covenant - Require Monthly Cash Flow Audit
Gate->>Gate: Verify Senior Officer Authority Tier
Gate->>DB: Update Precedent Scope and Log Execution Event
else Human Disputes Exception Applicability
Human->>Gate: Reject Exception Precedent
Gate->>DB: Route to Adjudication State for Committee Hearing
end
The Execution Trace:
- The Ingestion Query: The Underwriting Agent queries PostgreSQL for applicable precedents matching
Borrower X($10M facility, DSCR 1.18x). - Admissibility Filtering: The database query filters candidate records through the Temporal Validity conditions (
valid_until > NOW() AND parent_policy_revision_id = 'pol_rev_4_2' AND NOT EXISTS (SELECT 1 FROM precedent_revocations WHERE precedent_id = p.precedent_id)). Stale pandemic exceptions and revoked precedents are excluded at the SQL layer. - Inference Under Proof: The agent receives the valid precedent and generates an approval recommendation that explicitly references the active policy waiver, linked evidence hashes, and required covenants.
- Supervised Human Review: The Senior Credit Officer reviews the structured proposal. Because the system presents the exact authorizer, policy dependency, and evidence chain together, supervisory verification friction is eliminated.
- Compounding Mutation: The officer confirms the override with a minor covenant refinement. The Classification Gate validates the officer's role tier, updates the precedent's scope in
precedents, and records the execution and rollback payload inexecution_events.
Five Pragmatic Architectural Anti-Patterns
When engineering teams implement persistent state for AI agents, they frequently fall into five predictable traps:
| # | Anti-Pattern | Root Architectural Flaw | Operational Consequence | Engineering Correction |
|---|---|---|---|---|
| 1 | The Vector Dumping Ground | Conflating similarity with legal admissibility | Hallucination compounding; outdated overrides leak into prompts | Isolate Layer 2 event logs from Layer 3 precedents with SQL filters |
| 2 | The Perpetual Precedent | Missing TTLs and dynamic review triggers | Emergency exceptions become immortal shadow operating policies | Mandatory valid_until timestamps and policy version foreign keys |
| 3 | Ambient Authority Leakage | Storing overrides without role verification | Junior analyst workarounds propagate company-wide | Classification Gate enforces IAM hierarchy before mutating state |
| 4 | The Graph Database Dogma | Over-engineering storage before validating workflows | Distributed transaction overhead and slowed engineering velocity | Build relational topology in PostgreSQL with JSONB and pgvector |
| 5 | Hardcoded Prompt Logic | Embedding business rules in natural language prompts | Fragile prompt rewrites on every policy update | Decouple Policy State (L4) from LLM prompts; execute rules as code |
1. The Vector Dumping Ground
- The Anti-Pattern: Storing every inference result and user comment in a vector index and querying it with top-$k$ semantic search.
- The Consequence: The agent retrieves conflicting, unverified, and outdated opinions, causing compounding hallucinations and policy violations.
- The Correction: Strictly separate unverified episodic logs (Layer 2) from governed precedents (Layer 3). Enforce deterministic SQL filters before context assembly.
2. The Perpetual Precedent
- The Anti-Pattern: Creating precedent records without
valid_untiltimestamps, review triggers, or parent policy version pointers. - The Consequence: Temporary crisis allowances and emergency exceptions become immortal operating policies that continue to fire years after their underlying rationale has ceased to exist.
- The Correction: Every precedent record must have an immutable validity interval, dynamic revalidation triggers, and a foreign-key dependency to an active policy revision.
3. Ambient Authority Leakage
- The Anti-Pattern: Recording a human supervisor's override into shared state without validating that the user's role possessed the institutional authority to grant that exception.
- The Consequence: A junior analyst's unauthorized workaround propagates as an enterprise-wide precedent.
- The Correction: The Classification Gate must verify the supervisor's role tier against the Structural State (Layer 1) hierarchy before persisting any precedent mutation.
4. The Graph Database Dogma
- The Anti-Pattern: Believing that building an ACG requires deploying a dedicated, complex graph database (e.g., Neo4j) before validating core workflows.
- The Consequence: Massive operational complexity, distributed transaction overhead, and slow engineering velocity.
- The Correction: "Graph" describes the topology of state, not the storage engine. Build the ACG in PostgreSQL using relational tables, JSONB columns, foreign keys, and
pgvector.
5. Hardcoded Prompt Logic
- The Anti-Pattern: Writing 15-page system prompts filled with complex domain if-then logic, exception lists, and organizational charts.
- The Consequence: Every time a company policy changes, prompts must be rewritten, evaluated, and re-tested across thousands of test cases.
- The Correction: Move rules into Layer 4 (Policy State) and precedents into Layer 3 (Precedent State). Keep the system prompt as a generic, lightweight traversal engine.
One-Line Synthesis
An AI agent’s autonomy is bounded by the quality of its state architecture: by structuring institutional knowledge across five governed state domains in PostgreSQL, gating human overrides through a 5-way Classification Gate, and validating precedents against observed real-world outcomes under a strict State-Transition Contract, engineering teams transform disposable LLM inferences into compounding enterprise defensibility.
This post is part of the systems architecture series on Architecture of Proof. The strategic thesis was established in State Is the Moat in the AI World. This post established the concrete architectural blueprints for building the state layer. The next post examines runtime enforcement: Policy as Code: The Infrastructure Layer Between AI Governance Documents and Enforcement.
Frequently Asked Questions
What is an Accumulated Context Graph (ACG)?
An Accumulated Context Graph is a permissioned, temporal data architecture that represents organizational entities, historical decisions, authorized exceptions, machine-executable policies, and execution outcomes. Connected by immutable provenance and updated through classified human corrections, the ACG ensures that an AI agent acts only on verified, admissible institutional precedents rather than ungoverned semantic memory.
How does an ACG differ from vector search or RAG?
A basic vector-retrieval pipeline optimizes primarily for semantic relevance—retrieving text chunks that look similar to a prompt regardless of whether the information is legally authorized, current, or scoped to the target entity. An ACG establishes admissibility: it verifies that candidate context is attached to an active policy version, authorized by proper institutional authority, within its temporal validity window, and supported by unrevoked evidence.
What are the five governed state domains in an ACG?
The five governed state domains are: (1) Structural State (organizational topology, entities, and effective authority context), (2) Episodic & Outcome State (immutable execution ledger, tool mutations, rollbacks, and observed real-world results), (3) Precedent State (authorized overrides, scoped exception rules, and revalidation triggers), (4) Policy State (machine-executable constraints and policy-as-code definitions), and (5) Adjudication State (active escalations, contested judgments, and committee workflows).
How does an ACG track real-world outcomes without false causality?
An ACG links decisions to observed real-world outcomes (e.g., loan repayment history, error rates) across controlled cohorts. Because correlation does not equal causation, empirical performance generates automated promotion recommendations for governance committees rather than silently rewriting baseline policy without human review.
What is the Classification Gate in human-in-the-loop workflows?
The Classification Gate is an architectural boundary that prevents unvetted human feedback from polluting shared state. When a human supervisor overrides an agent, the gate classifies the intervention into one of five destinations: an isolated case-specific adjustment, a reusable scoped precedent, a formal policy change, an underlying data fix, or a contested judgment routed to Adjudication State.
Does building an ACG require a dedicated graph database like Neo4j?
No. 'Graph' refers to the relational, temporal, and provenance topology of organizational knowledge, not a mandatory database engine. An ACG can begin in PostgreSQL as the governed transactional system of record, using relational tables, JSONB, foreign-key provenance pointers, pgvector for discovery, and recursive queries, with specialized stores added only as scale requires.
Download the Architecture of Proof Checklist
Ready to implement? Get the definitive checklist for building verifiable AI systems.