Enterprise Ontology Architecture & Building the Semantic Layer: How ACM Grounds Autonomous Agents in a 6-Layer Relational Graph
How we designed and built the Domain Ontology and Enterprise Semantic Layer in Agentic Contract Management (ACM) so autonomous agents, hybrid RAG pipelines, and compliance auditors operate over a governed, version-controlled relational graph rather than ungrounded prompts.
# Enterprise Ontology Architecture & Building the Semantic Layer: How ACM Grounds Autonomous Agents in a 6-Layer Relational Graph
When enterprise AI initiatives stall between impressive demos and production deployment, the root cause is almost always a missing Enterprise Semantic Layer.
Without an explicit domain ontology, every autonomous agent, RAG retrieval step, and compliance prompt has to guess what institutional terms mean. One prompt defines a *Master Services Agreement* liability cap one way; another agent in the same workflow evaluates it differently; and when General Counsel updates a corporate standard, engineers are forced to hunt down and rewrite dozens of brittle prompt strings.
At Effective Solutions, when we architected Agentic Contract Management (ACM), we set out to answer a fundamental platform architecture question:
Architectural Blueprint Goal: How do we design and build the Domain Ontology and Enterprise Semantic Layer in ACM so that autonomous agents, hybrid RAG pipelines, and compliance auditors operate over a governed, version-controlled relational graph of domain categories, contract taxonomies, clauses, validation rules, and entity graphs rather than ungrounded prompts?
In ACM, the Semantic Layer bridges raw unstructured contract text and deterministic LLM execution. Rather than hardcoding legal definitions inside isolated prompts, ACM models domain semantics as a 4-Tier Relational Ontology Graph (src/db/models.py & src/api/legal_infra.py), pairs top-down taxonomies with bottom-up folksonomy and adjacency graphs (GlobalTag, TagAssociation, ContentGraph), enforces a Two-Stage Staged Discovery Gate (src/services/staging_service.py), prevents silent semantic drift via an HTTP 409 Intelligent Audit Block, dynamically compiles taxonomy-bound clauses and rules into every Agent prompt at runtime via PipelineEngine._fetch_legal_context(), and renders live semantic execution traces in our dual-mode EntityGraphDashboard.tsx.
Here is our complete 6-layer engineering blueprint—starting with the fundamentals of what an ontology actually is in enterprise architecture—followed by the production SQLAlchemy, FastAPI, and React/TypeScript code running in ACM.
0. Enterprise Architecture Fundamentals: What Is an Ontology (and Why Database Schemas Alone Are Not Enough)?
In computer science and enterprise architecture, an Ontology is a formal, explicit specification of a shared domain conceptualization. While a traditional database schema defines how data is physically stored (tables, foreign keys, VARCHAR columns, JSONB blobs), an ontology defines what the domain actually means, how concepts relate, and what rules govern valid state transitions.
When enterprise architects design for autonomous AI agents, distinguishing an Ontology from adjacent data-modeling concepts—like a glossary, a folksonomy, or a taxonomy—is critical:
The 4 Structural Building Blocks of an Enterprise Ontology
In an enterprise architecture blueprint, a production ontology is composed of four formal primitives—each mapped 1:1 to executable constructs in ACM:
- 1.Classes / Concepts (The Domain Nouns): The canonical entity types that exist in the enterprise universe. In ACM, these are
RuleCategory,Taxonomy,Clause,ValidationRule,GovernanceVariable,Contract, andAgent. - 2.Typed Relations / Predicates (The Graph Edges): The directed and bidirectional edges that connect classes and carry semantic meaning:
- *Playbook Requirement Edge:*
Taxonomy$\leftrightarrow$Clauseviataxonomy_clause_association(*"An Enterprise MSA requires the Standard Limitation of Liability clause"*). - *Policy Enforcement Edge:*
Taxonomy$\leftrightarrow$ValidationRuleviataxonomy_validation_association(*"An Enterprise MSA must be verified against the Liability Cap Rule"*). - *Polymorphic Cross-Entity Edge:*
GlobalTag$\rightarrow$(entity_type, entity_id)viaTagAssociation. - *Directed Composition Edge:*
ContentBlock$\rightarrow$MediaAssetviaContentGraph.
- 1.Attributes & Bounded Properties (The Domain Tolerances): Quantitative or categorical boundaries attached to concepts—such as
ValidationRule.risk_level(Low,Medium,High,Critical) andGovernanceVariable(min_label <-> max_label, e.g.,Net 90 <-> Net 15). - 2.Axioms & Governance Invariants (The Executable Laws): Formal constraints that the platform enforces deterministically at runtime:
- *Upstream Grounding Axiom:* No AI agent may evaluate or draft a contract without first compiling its
Taxonomy's boundClause,ValidationRule, andGovernanceVariablenodes (_fetch_legal_context()). - *Quarantine Airlock Axiom:* Autonomous discovery agents cannot mutate active ontology classes; new proposals must enter
StagedRule,StagedClause, orStagedTaxonomywithstatus="Staged". - *Historical Immutability Axiom:* Any ontology node referenced by historical
ComplianceEvaluationfacts (func.count > 0) cannot be mutated in place without triggering anHTTP 409 Intelligent Audit Blockor cascadingstatus="Needs Review"across dependent contracts.
Why Autonomous Agents Need an Ontology Bridge: Large Language Models operate in probabilistic token space (high linguistic fluency, zero institutional memory or relational integrity), whereas enterprise systems of record operate in physical table space (foreign keys and row-level security, but opaque to an LLM without context compilation). The Enterprise Semantic Layer sits between them—compiling the relational ontology graph into token-budgeted instructions upstream before the LLM runs, and translating the LLM's verification outputs back into multi-dimensional Star Schema facts (ComplianceEvaluation) downstream.
Core Architectural Terms Explained: What They Basically Mean (Before Reading the Matrix)
Before inspecting ACM's 6-layer architecture matrix and production code, here is what the four core architectural patterns in this guide basically mean from first principles:
1. What Is an Entity Graph, Basically?
- The Basics: In a standard relational table, a record usually points to a single parent (for example, a contract belongs to one category). An Entity Graph models domain concepts as Nodes (a
Taxonomy, aClause, aValidationRule, aContract, or anAgent) connected by explicit Edges (many-to-many join tables or directed adjacency lists that define *how* two nodes relate). - Why It Matters in ACM: Because legal knowledge is interconnected—one
Liability Caprule might govern both anMSAand aSaaS Agreement, and oneEU-DORAtag might apply to a contract, a rule, and a prospect—ACM stores these relationships as graph edges inside PostgreSQL (taxonomy_clause_association,taxonomy_validation_association,TagAssociation, andContentGraph) and visualizes runtime agent execution as an interactive node graph (EntityGraphDashboard.tsx).
2. What Is a Semantic Layer Compiler, Basically?
- The Basics: A traditional software compiler translates high-level source code into machine instructions. A Semantic Layer Compiler (
PipelineEngine._fetch_legal_context()in ACM) queries the domain ontology graph at runtime, gathers the exact mandatory clauses, validation rules, and numerical tolerances linked to a document's classification, and compiles them into a structured, token-budgeted instruction block right before an AI agent executes. - Why It Matters in ACM: Instead of hardcoding legal rules inside static prompt templates (which immediately drift out of sync when policies change), ACM compiles the prompt context live from PostgreSQL on every single run.
3. What Is Hybrid Vector-Graph RAG, Basically?
- The Basics: Standard RAG (Retrieval-Augmented Generation) relies solely on Vector Search—converting paragraphs into numerical embeddings (
PGVector) to find text chunks that are *mathematically similar* to a user's question. However, vector similarity alone can miss mandatory corporate rules that use different wording. Hybrid Vector-Graph RAG fuses two retrieval paths simultaneously:
- 1.Deterministic Graph Traversal: Walking the ontology graph (
Taxonomy → Clause + ValidationRule + GovernanceVariable) to fetch 100% of the rules that govern the contract archetype. - 2.Semantic Vector + Cross-Encoder Retrieval: Querying
PGVectorembeddings (rag_engine.py) and re-ranking candidate paragraphs with a Cross-Encoder model to pinpoint the exact clauses inside the document where those ontology rules must be checked.
4. What Is a Kimball Star Schema, Basically?
- The Basics: Designed by data-warehousing pioneer Ralph Kimball, a Star Schema separates data into a single central Fact Table (which records atomic, measurable events—such as a pass/fail rule evaluation) linked by foreign keys to surrounding Dimension Tables (which describe the *who, what, where, and how* of the event). When drawn in a diagram, the central fact table surrounded by its dimensions looks like a star.
- Why It Matters in ACM: While the Ontology Graph (3NF) is optimized for curating rules upstream without duplication, the Star Schema (
ComplianceEvaluationfact table surrounded by 6 dimensions:Contract,Clause,ValidationRule,Agent,PipelineRun, andWorkspace) is optimized for downstream verification and instant blast-radius queries—answering *"Which active contracts failed Rule X under Agent Y?"* in a single join.
Concrete Walkthrough: The Star Schema Before vs. After LLM Verification
To see how the Ontology Bridge translates probabilistic LLM output into relational Star Schema facts, trace what happens in PostgreSQL when a new contract (ctr-882, *"Acme Cloud Master Services Agreement"*) is evaluated:
1. BEFORE LLM Execution (Upstream Dimension Tables Exist, Central Fact Table Has 0 Rows for ctr-882):
- Dimension 1 —
contracts(Contract):
- Dimension 2 —
clauses(Clause, linked to"MSA"viataxonomy_clause_association):
- Dimension 3 —
validation_rules(ValidationRule, linked to"MSA"viataxonomy_validation_association):
- Dimension 4 —
agents(Agent):{ id: "mike-n6", name: "Drafter QA Validator", role: "Validator" } - Central Star Schema Fact Table —
compliance_evaluations(ComplianceEvaluation): 0 rows forcontract_id = "ctr-882".
2. DURING Execution (The Ontology Bridge in Action):
- Upstream Subgraph Compilation (
_fetch_legal_context): Walkstaxonomy_clause_associationandtaxonomy_validation_associationfor"MSA"and injectscls-liab-01,cls-gov-02,rul-cap-12m, andrul-delawareinto the prompt. - Probabilistic LLM Output: The LLM inspects *"Acme Cloud MSA.pdf"* and returns JSON indicating that Section 8 has uncapped liability (violating
rul-cap-12m), while Section 14 specifies Delaware law (satisfyingrul-delaware).
3. AFTER Initial LLM Verification (Run trc-44a91b — Downstream Star Schema Fact Table Populated via record_compliance_evaluations_for_run):
Immediately upon verification completion, ACM translates that ephemeral LLM JSON into two immutable relational rows in compliance_evaluations joining all 6 dimensions, and transitions contracts.status from "Draft" to "Under Review":
*Immediate Downstream Effect of These Star Schema Rows:*
- 1.Blocks Unverified Finalization (
HTTP 409): CallingPUT /contracts/ctr-882/workflow-statewithstatus="Finalized"queriesSELECT * FROM compliance_evaluations WHERE contract_id='ctr-882' AND is_compliant=False, findseval-901, and blocks final sign-off unless an explicit override rationale comment is provided. - 2.Protects Historical Rule Integrity (
HTTP 409): Becauserul-cap-12mnow hasCOUNT(compliance_evaluations.id) > 0,PUT /legal-infra/validation-rules/rul-cap-12mblocks any silent edit to that rule (Intelligent Audit Block).
4. AFTER Human Redline & Re-Verification (Subsequent Pipeline Run trc-77c02e):
Once the human legal reviewer applies the redline capping liability at 12 months fees and re-runs verification (pipeline_run_id = "trc-77c02e"), new Star Schema fact rows are appended showing full compliance—unlocking the Downstream Verification Gate for independent human sign-off:
How Many Fact Tables Exist in a Platform Like ACM? (The 5-Table Fact Constellation)
In enterprise dimensional modeling, a platform with multiple operational lifecycles does not stop at a single fact table. Instead, it uses a Fact Constellation (or "Galaxy Schema")—typically 4 to 6 fact tables that share conformed dimensions (Contract, Agent, ValidationRule, Workspace). In ACM (apps/acm-backend/src/db/models.py), there are 5 distinct fact/event tables:
Is This What Practitioners Call "Constant Knowledge Graph Pruning Per LLM Call"?
Yes—with a critical architectural distinction between upstream read-only subgraph pruning and downstream fact recording:
- 1.Upstream = Per-LLM-Call Subgraph Pruning (Read-Only Context Slicing): An enterprise ontology graph may contain hundreds of
Taxonomies, thousands ofClauses, and tens of thousands ofValidationRules. Dumping the entire knowledge graph into every LLM call causes context rot (diluted attention, contradictory rules, and runaway token costs). Therefore, on every single LLM call,_fetch_legal_context(db, contract)prunes the global ontology graph down to the active local subgraph—selecting only theClauseandValidationRulenodes connected tocontract.taxonomyand pruning each clause body to a 300-character preview. Crucially, this is a read-only projection: it prunes what the LLM *sees* in its context window without deleting anything from PostgreSQL. - 2.Downstream = Append-Only Star Schema Fact Recording (Zero Destructive Graph Mutation): When the LLM finishes evaluating the contract against that pruned subgraph, ACM never allows the LLM to destructively prune or overwrite nodes in the production ontology graph. Instead, the LLM's conclusions are written as append-only fact rows into
compliance_evaluations(and any newly proposed rules are routed intostaged_rulesquarantine). - 3.Structural Graph Pruning Is Strictly Human-Gated: Actual structural pruning of the ontology graph itself (retiring an obsolete
ValidationRule, merging aGlobalTag, or deleting aClause) is a privileged human action onDELETE /legal-infra/...—and is protected by the Star Schema'sHTTP 409 Intelligent Audit Blockwhenever historical contracts depend on that node.
1. The 6-Layer Ontology & Semantic Build Matrix
To turn an abstract domain ontology into an executable platform capability, we decomposed ACM's Semantic Layer into six distinct engineering tiers:
Architect Speak
- Relational Graph in PostgreSQL vs. External Graph Silos: ACM implements its bipartite Ontology Graph (
taxonomy_clause_association,taxonomy_validation_association), polymorphic tag graph (TagAssociation), and weighted adjacency lists (ContentGraph) directly inside PostgreSQL alongsidePGVector. This guarantees single-database ACID transactions across ontology promotions, reactive contract invalidations, and vector embeddings without eventual-consistency drift between a separate Neo4j cluster and the relational store. - Compile-Time + Runtime Semantic Binding: Rather than treating an ontology as passive documentation,
_fetch_legal_context()acts as a Runtime Semantic Compiler—resolving the contract'sTaxonomynode, walking its M:N edges toClauseandValidationRulerecords, attaching boundedGovernanceVariabletolerances, and injecting the compiled semantic block into every downstream agent node.
CIO Speak
- Single Source of Institutional Truth: When General Counsel or Risk Leadership updates a corporate tolerance or clause standard in the Legal Playbook Infrastructure Manager, that change propagates deterministically across every AI agent, pipeline, and portfolio compliance check—zero prompt rewrites required.
- Audit-Grade Semantic Lineage: Because every ontology mutation is guarded by pre-flight blast-radius checks (
/dependencies/{entity_type}/{entity_id}) andHTTP 409immutability gates, enterprise auditors can verify the exact semantic rules that governed any historical contract evaluation down to the millisecond.
2. Layer 1 & Layer 2: The 4-Tier Relational Domain Ontology Graph & Hybrid Folksonomy (`models.py` & `legal_infra.py`)
Context, Action, Result (CAR Alignment)
- Challenge: Storing domain rules inside individual agent prompts causes contradictory evaluations and massive maintenance overhead whenever corporate legal standards change. At the same time, rigid top-down hierarchies alone cannot capture cross-cutting operational themes or document-level entity relationships.
- Action: In
apps/acm-backend/src/db/models.pyandapps/acm-backend/src/api/legal_infra.py, we architected a 4-Tier Relational Ontology Graph:
- 1.
RuleCategory(1:N Domain Grouping) - 2.
Taxonomy(Contract Archetype Node) - 3.Many-to-Many
Clause&ValidationRulenodes bound viataxonomy_clause_associationandtaxonomy_validation_association - 4.Bottom-up folksonomy and adjacency graphs (
GlobalTag,TagAssociation, andContentGraph)
- Result: Reusable clauses and validation rules are defined once and linked across multiple contract taxonomies with full workspace isolation, while
StagingService.list_global_tags()unions curatedGlobalTagentities with liveContract.tagsJSONB arrays for real-time cross-entity discovery.
3. Layer 3: Two-Stage Ontology Governance & Shadow Discovery Gate (`staging_service.py` & `staging.py`)
Context, Action, Result (CAR Alignment)
- Challenge: Allowing autonomous discovery agents or Demand-Driven Orchestrator (DDO) evaluations to write newly extracted clauses, tags, or validation rules directly into the active ontology risks polluting enterprise playbooks with unvetted or hallucinated rules.
- Action: We built dedicated shadow quarantine tables (
StagedTaxonomy,StagedClause,StagedRule,StagedTag) andStagingServiceinapps/acm-backend/src/services/staging_service.py. WheneverStagingService.evaluate_demand()detects a capability or methodology gap (phase != "direct_match"), it automatically stages candidateStagedRuleandStagedClauserows withstatus="Staged"andrequires_human_promotion=True. - Result: Zero unreviewed AI mutations ever reach the production semantic layer, while human legal architects can promote curated tags, clauses, and rules—or trigger retroactive category execution—with a single API call.
4. Layer 4: HTTP 409 Intelligent Ontology Audit Block & Blast-Radius Pre-Flight (`legal_infra.py` & `dependencies.py`)
Context, Action, Result (CAR Alignment)
- Challenge: Editing or deleting a live
ValidationRule,Clause, orTaxonomyafter it has already evaluated active contracts causes silent semantic drift across historical compliance traces—invalidating past audit sign-offs without warning. - Action: First, we built the Star Schema blast-radius pre-flight router (
GET /dependencies/{entity_type}/{entity_id}inapps/acm-backend/src/api/dependencies.py) so the UI can inspect every contract andComplianceEvaluationfact row that depends on a given ontology primitive. Second, inapps/acm-backend/src/api/legal_infra.py, everyPUTandDELETEchecksfunc.count(ComplianceEvaluation.id). Ifeval_count > 0andforce=False, ACM raises anHTTP 409 Conflict(Intelligent Audit Block). If an authorized architect passesforce=True, ACM traversestaxonomy_validation_associationand cascadesContract.status = "Needs Review"across all affected contracts. - Result: Guarantees immutable compliance history while automatically queuing impacted contracts for re-evaluation whenever forced ontology updates occur.
5. Layer 5: Runtime Semantic Layer Compiler & Hybrid Vector-Graph RAG (`pipeline_engine.py` & `rag_engine.py`)
First Principles: How the Semantic Compiler & Hybrid Vector-Graph RAG Work Together
Before an AI agent can evaluate a contract, two things must be assembled:
- 1.The Semantic Layer Compiler (
_fetch_legal_context): Walks the relational ontology graph forcontract.taxonomyand compiles the exact mandatory clauses, validation rules, and activeGovernanceVariablebounds into a deterministic prompt header. - 2.Hybrid Vector-Graph RAG (
rag_engine.py): Pairs that graph-compiled playbook context withPGVectorembedding search and Cross-Encoder precision re-ranking so the agent sees both the *institutional law* (from the Ontology Graph) and the *relevant document evidence* (from Vector Search).
Context, Action, Result (CAR Alignment)
- Challenge: Connecting the relational ontology graph to live topological DAG execution without blowing through LLM context budgets or losing point-in-time auditability.
- Action: We implemented
_fetch_legal_context(db, contract)inapps/acm-backend/src/services/pipeline_engine.pyas a Token-Budgeted Semantic Compiler. Before any agent node runs inrun_pipeline()orAIReviewService, it resolvescontract.taxonomyin the ontology graph, caps mandatoryClausepreviews at 300 characters for token efficiency, appendsValidationRuledefinitions and activeGovernanceVariablebounds, snapshots the active governance rules intoPipelineRun.governance_snapshot, and pairs the compiled ontology context with Cross-Encoder re-rankedPGVectorretrieval (apps/acm-backend/src/core/rag_engine.py). - Result: Every agent node executes with deterministic playbook grounding, and every pipeline run preserves a point-in-time
governance_snapshotalongside atomicComplianceEvaluationStar Schema facts.
6. Layer 6: Interactive Entity Graph Matrix & Dual-Mode Semantic UI (`EntityGraphDashboard.tsx`)
First Principles: What the Runtime Entity Graph Visualizes
While the database ontology graph connects static legal primitives (Taxonomy ↔ Clause ↔ ValidationRule), the Runtime Entity Graph (EntityGraphDashboard.tsx) turns every multi-agent pipeline execution trace (pipelineRuns[].trace) into an inspectable visual graph. Each execution node is classified into one of four canonical ontology capability swimlanes—Extraction, Analysis, Remediation, or Validation—so reviewers can inspect the AI's reasoning either as a 4-column capability matrix (Matrix View) or as a step-by-step dependency chain (Logical Flow View).
Context, Action, Result (CAR Alignment)
- Challenge: Legal reviewers and platform architects need to inspect how raw multi-agent execution traces map onto canonical ontology capabilities without digging through raw JSON logs.
- Action: In
apps/acm-frontend/components/EntityGraphDashboard.tsx, we built an interactive, dual-mode Entity Graph Matrix & Logical Flow Visualizer. It normalizes all nodes acrosspipelineRuns[].trace, classifies each execution step into 4 canonical semantic ontology swimlanes (Extraction,Analysis,Remediation, andValidation), and allows users to toggle between a categorized Matrix View and a sequential Logical Flow View with click-to-inspect payload drawers (setInspectorData). - Result: Gives legal engineers and auditors real-time semantic observability across every agent node, risk badge, and validation step.
7. Synthesis: The 6-Dimension Kimball Star Schema & 4 Complementary Entity Graphs in ACM
First Principles: Why Combine an Ontology Graph with a Star Schema?
In enterprise data architecture, Graphs and Star Schemas solve opposite halves of the governance lifecycle:
- An Entity Graph (Upstream OLTP) is built for relationship traversal—connecting reusable clauses, rules, tags, and taxonomies across many-to-many edges so policy is defined once and inherited everywhere.
- A Kimball Star Schema (Downstream OLAP) is built for high-speed audit aggregation—recording every individual pass/fail verification event in a central fact table (
ComplianceEvaluation) surrounded by foreign-key dimension tables so compliance dashboards andHTTP 409dependency checks execute in a single hop.
When enterprise architecture boards evaluate ACM, two questions frequently arise: *How does the Ontology Graph interact with your analytical Star Schema?* and *Why use PostgreSQL instead of a dedicated graph database?*
Part 1: The 6-Dimension Kimball Star Schema (`ComplianceEvaluation`)
Rather than burying pass/fail rule evaluations inside opaque JSON blobs, ACM models ComplianceEvaluation (apps/acm-backend/src/db/models.py) as a central Star Schema Fact Table with atomic measures (is_compliant, rationale, created_at) surrounded by 6 Foreign-Key Dimension Tables:
- 1.Dimension 1 — Document (
contract_id → contracts.id,CASCADE): Slices compliance facts by contract archetype, status, and renewal window. - 2.Dimension 2 — Clause (
clause_id → clauses.id,SET NULL): Powers clause dependency pre-flight (GET /dependencies/clause/{id}) andGET /clauses/{id}/contracts. - 3.Dimension 3 — Validation Rule (
rule_id → validation_rules.id,SET NULL): Powers rule impact rollups and triggers theHTTP 409 Intelligent Audit Blockwhenfunc.count(ComplianceEvaluation.id) > 0. - 4.Dimension 4 — Agent (
agent_id → agents.id,SET NULL): Tracks per-agent distinct contract utilization and agent audit history (GET /agents/{id}/contracts). - 5.Dimension 5 — Pipeline Execution Run (
pipeline_run_id → pipeline_runs.id,CASCADE): Links each atomic rule evaluation to its topological DAG run. - 6.Dimension 6 — Tenant Workspace (
workspace_id → workspaces.idviaTenantMixin): Enforces multi-tenant OLAP isolation across all Star Schema aggregations.
Part 2: The 4 Complementary Entity Graph Topologies
Alongside the Star Schema, ACM operates four complementary graph topologies inside the same PostgreSQL ACID boundary:
- 1.Runtime Execution Trace Entity Graph (
EntityGraphDashboard.tsx): ClassifiespipelineRuns[].tracenodes intoExtraction,Analysis,Remediation, andValidationswimlanes across Matrix and Logical Flow views. - 2.Bipartite Playbook Ontology Graph (
taxonomy_clause_association&taxonomy_validation_association): ConnectsRuleCategory → Taxonomy ↔ (Clause, ValidationRule)for upstream semantic compilation and reactive contract invalidation. - 3.Polymorphic Cross-Entity Tag Graph (
TagAssociation&GlobalTag): Composite 3-key edge table (tag_id,entity_type,entity_id) linking tags across"contract","prospect","content_block", and"rule". - 4.Directed Adjacency & Hierarchical Tree Graphs (
ContentGraph&Agent.parent_agent_id): Weighted adjacency lists (block_id → asset_idwithroleandorder) and self-referential Master-Worker agent trees.
Three Architectural Nuances for Enterprise RFP Defense
1. Relational Graph in PostgreSQL (vs. Neo4j): Implementing the Ontology Graph, Star Schema, and PGVector embeddings inside PostgreSQL guarantees single-database ACID transactions across ontology updates, contract invalidations, and vector indexing without cross-database synchronization lag.
2. ContextVar Application-Layer Tenant Isolation: Multi-tenant scoping is enforced via Python contextvars.ContextVar (workspace_id_ctx in src/db/context.py) and SQLAlchemy TenantMixin filters across every ontology table, Star Schema fact query, and PGVector collection.
3. Dual-Tier Audit Storage (2,000-Char Excerpts vs. Full Snapshots): PolicyAudit.input_excerpt stores sanitized excerpts for fast security dashboard indexing, while ContractTimelineEvent.content_snapshot preserves 100% lossless full-text snapshots for deterministic 1-click rollback.
Build with our
Architects
Bring your legacy silo data to life with autonomous reasoning swarms.
Book Review