[{"localId": "https://reference-architecture.ai/posts/verification-prediction-length-confound/", "https://atomicdata.dev/properties/name": "Verification, Prediction and the Length Confound in Retrieval Scores", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/posts/verification-prediction-length-confound/", "https://atomicdata.dev/properties/description": "

Abstract

\n

A retrieval layer for agents is asked three different questions: whether a declared item occurs in a text, whether a text supports a claim, and how relevant a text is to a query. Li, Wu and Cui (arXiv:2611.33668) study a related pair of questions about proposition decomposition. They find that a learned entailment judge verifies membership accurately, that embedding geometry does not, and that symbolic counters which appear to predict proposition counts carry no information once sentence length is controlled. This paper draws two architectural consequences. First, occurrence, support and ranking should be separate components with separate evidence, because a positive answer to one says nothing about the others. Second, any count-based ranking score should be accepted only on an evaluation that controls for document length, using the paper's three lenses. Applying that reasoning to Terraphim's role graph shows a score term coupled to the number of distinct neighbours of a query concept, a plausible but unmeasured route for length to enter, and exposed two counting defects, now filed. No ranking evaluation is reported here; the measurement is specified, not run.

\n

\n

The study

\n

The paper uses PropSegmEnt, English Wikipedia sentences each segmented into propositions by three annotators, with a test split of 539 sentences. It asks two questions.

\n

Verification. Given sentence s and candidate proposition p, does p belong to s? An mDeBERTa-v3 model fine-tuned on natural language inference scores the entailment probability, with a threshold of 0.5. Accuracy is 92.8% (95% CI 92.0 to 93.5), AUC 0.977, and positive recall 98.1%, on 2,411 positives and 2,156 negatives. The false-positive rate is 16.0% on hard negatives (from the same document) and 10.5% on easy ones. The residual errors are structured. Definitional negatives (\"X is a ...\"), which are entailed once document context resolves a pronoun but not by the sentence alone, are 5% of negatives yet have a 43% false-positive rate against 11.7% for the rest. The paper calls these \"context-true\". Its abstract says they are most of the errors; the Section 5.1 figures put them at roughly 46 of the 285 false positives. Geometric alternatives fail. Raw cosine similarity saturates at 0.68 to 0.71 for members and non-members alike, and a sentence embedding is not a linear combination of its propositions' embeddings.

\n

Prediction. Given s alone, how many propositions should it yield? Proposition count correlates with token length at ρ = 0.749, so the paper evaluates every predictor through three lenses:

\n
    \n
  1. raw Spearman correlation with the reference count;
  2. \n
  3. length-partialled correlation, the correlation of rank residuals after regressing both prediction and reference on token count;
  4. \n
  5. accuracy on the 2,341 test pairs that have equal token count and different reference counts, where chance is 0.5.
  6. \n
\n

Token count reaches a raw ρ of 0.810, then −0.042 [−0.070, 0.068] partialled, and is undefined on equal-length pairs. CPIDR, an idea-density counter, scores 0.659, then −0.179, then 0.416, which is significantly below chance. A Neo-Davidsonian predicate counter scores 0.570, then −0.064, then 0.483. A ridge probe on frozen sentence embeddings keeps a partialled ρ of 0.40 to 0.49 and a pair accuracy of 0.67 to 0.71 across three encoders. That signal survives INT4 quantisation and truncation to 256 dimensions.

\n

The authors also retract a 48-sentence pilot. With far fewer samples than dimensions, and with whitening fitted on the evaluation sentences, leave-one-out ridge memorised the held-out labels and produced plausible numbers that the formal protocol reversed.

\n

Three questions, three components

\n

The study separates questions that retrieval systems often merge. For agent retrieval there are three.

\n\n\n\n\n
QuestionAnswered byEvidence it produces
Does declared item x occur in text t?An automaton over a governed vocabularyThe matched span and the thesaurus entry
Does text t support claim c?An entailment judgeA score, a threshold and the judge's model version
How relevant is t to query q?A ranking functionA score with a declared evaluation
\n

Each answer is silent on the others. An occurrence match does not show support, because a document can name a concept while contradicting the claim. A high similarity score does not show support either, which is the paper's verification result. A support judgement does not rank. The architectural rule is that each consumer states which of the three questions it is asking, and accepts only the matching evidence.

\n
\nflowchart LR\n    Q[Agent request] --> O[Occurrence: automaton over thesaurus]\n    Q --> R[Ranking: graph or lexical score]\n    R --> S[Support: entailment judge per claim]\n    O --> C[Checklist and authority checks]\n    S --> G[Grounded answer with cited support]\n    R -.-> G\n
\n

Figure 1. Occurrence feeds checks. Ranking selects candidates. Only the support judge licenses a grounded claim. The dotted line means ranking may order evidence but cannot stand in for it.

\n

The paper recommends using its cheap count probe to budget and route sentences to the NLI judge, because the judge needs one judgement per proposition: accurate but pairwise. Adapting that recommendation to retrieval, a cheap stage could route claims to a support judge rather than replace it. Context-true false positives should be reported as their own class, because the paper shows that definitional statements whose subject is resolved from surrounding text are a concentrated, identifiable error class.

\n

The length confound in count-based ranking

\n

A ranking score built from counts can win a raw correlation through length alone. The study's token-count row is the clean example. Terraphim's role graph, read at terraphim-core commit 84a496a, makes the risk concrete.

\n\n

For a single-concept query, a document's score is therefore k·(node.rank + 1) plus the sum of its counts on those edges. Here k is the number of distinct edges between the concept and the concepts matched next to it in that document. node.rank is shared by all documents for that concept, so each extra distinct neighbour adds node.rank + 1 plus its count. Unmatched text does not change k, and a single mention has at most two neighbours, so k grows when a concept is mentioned more often next to different concepts. In a scratch test, two documents that each mention the query concept once scored 5 and 11. The higher-scoring one had two matched neighbours instead of one.

\n

That establishes a neighbourhood-size term. It does not establish that neighbourhood size tracks document length in a real corpus, although longer documents give more room for repeated mentions. Whether that happens, and whether the score carries relevance beyond length, are empirical questions that need relevance judgements.

\n

The same test exposed two counting defects, filed as terraphim-core#120. First, a document's first occurrence of a pair is stored as 1 if that document created the edge and as 2 otherwise, so identical documents score differently by insertion order. Second, removal subtracts node rank once per edge while insertion adds it once per occurrence, so repeated pairs leave residue. Insertion-order effects have to be removed before any ranking change can be measured.

\n

An evaluation contract for ranking changes

\n

The paper's protocol transfers directly. A ranking change to a count-based scorer is accepted only if its report includes the following.

\n
    \n
  1. Three lenses against relevance labels. Raw rank correlation, length-partialled rank correlation, and accuracy on same-length document pairs with different relevance. The length unit is declared in advance, either tokens or matched concepts.
  2. \n
  3. A length-only baseline. Document length itself, scored on the same three lenses. A candidate that beats the baseline only on the raw lens is rejected.
  4. \n
  5. Train-only fitting. Any normalisation, weighting or threshold is fitted on a split the test never sees. The retracted pilot is the reason.
  6. \n
  7. Intervals. Bootstrap confidence intervals on each lens, with the number of queries and pairs stated.
  8. \n
  9. A pinned order. Results are reproduced under at least two document insertion orders, until order independence is proven by test.
  10. \n
\n

A two-variable correlation between score and length alone does not belong in such a report. Without relevance labels it cannot distinguish a proxy from a relevant signal that happens to scale with length.

\n

Implementation boundary

\n

Today Terraphim provides the occurrence component (automaton and thesaurus) and count-based ranking (terraphim-graph, alongside BM25 variants and a title scorer). No support judge is part of the retrieval path, and the shared grounding contract is open work. The counting defects are filed and not yet fixed. The evaluation contract above is proposed. It has not been run on any Terraphim ranking, and none of the paper's results were reproduced.

\n

Limits of the source

\n

The study uses one dataset in one domain and one annotation scheme, and releases no code. Two passages in v1 conflict with its tables. Section 6.2 attributes the ceiling comparison to the MiniLM probe (ρ 0.827), but the stated paired difference of +0.032 and MAE of 1.53 match the Qwen3 0.6B row (ρ 0.768). The Figure 3 caption says definitional negatives \"drive 43% of the false positives\", while Section 5.1 gives 43% as their false-positive rate, which is the reading consistent with the totals. Neither conflict affects the length-control finding for the symbolic counters.

\n

Conclusion

\n

The study's lesson for retrieval is not that one representation wins. Different questions live in different places. Support needs an entailment judge, and similarity does not provide it. Counts can look predictive purely because longer texts produce bigger counts. A reference architecture should keep occurrence, support and ranking as separate components with separate evidence, and should accept a count-based ranking change only when it survives length control. Checking one count-based scorer against that standard has already found a neighbourhood-size term that could carry length, and two defects. The measurement that would show whether the scorer carries relevance beyond length is specified here and still to be run.

\n

Sources and scope

\n

Li, Wu and Cui, arXiv:2611.33668v1, \"Verifiable but Not Predictable: What Sentence Embeddings Know About Propositional Decomposition\", submitted 25 November 2026, CC BY 4.0. Read on 27 November from the v1 PDF. Figures are quoted from Sections 3 to 7 and Tables 1 to 4. The recomputation of the Section 6.2 difference is this paper's.

\n

Terraphim details were checked against crates/terraphim_rolegraph and crates/terraphim_types in terraphim-core at commit 84a496a on 27 November 2026, with a scratch test run in a clean worktree. The component separation and evaluation contract are proposals and do not describe a deployed system.

\n", "https://reference-architecture.ai/properties/date": "2026-11-27", "https://atomicdata.dev/properties/tags": {"categories":["Architecture"],"tags":["evaluation","retrieval","grounding","knowledge-graphs","terraphim","ai-agents"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/posts/typed-relations-counted-adjacency-learned-scores/", "https://atomicdata.dev/properties/name": "Typed Relations, Counted Adjacency and Learned Scores", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/posts/typed-relations-counted-adjacency-learned-scores/", "https://atomicdata.dev/properties/description": "

Abstract

\n

A knowledge graph layer for agent retrieval must decide where its relationships come from, how it scores them and what a query returns. This paper compares two recent answers. FIG-MAC (arXiv:2611.33563) extracts typed entities and relations from research papers with fine-tuned language models, learns relational graph embeddings and returns scored multi-hop chains alongside dense-vector neighbours. Terraphim's role graph resolves surface forms through an externally supplied thesaurus, counts directed adjacency between recognised concepts and returns documents ranked by an integer sum that a reader can recompute. FIG-MAC's ablation reports that graph traversal exceeded vector retrieval on raw novelty and source diversity in all six configurations tested, and on provenance-adjusted novelty in five of six, and that combining the two did best throughout; the evaluation has limits, discussed below. The comparison motivates a layering in which every edge carries its provenance class: declared, counted or inferred. Inferred edges may widen recall, but they may not satisfy a checklist item or an authority check without review. The paper separates the components that exist today from the integration it proposes.

\n

\n

The decision a graph layer makes

\n

Organisational Roles as Contracts for AI Agents argued that a role-based knowledge graph should keep equivalence and relationship apart, and that co-occurrence alone leaves a relationship's meaning, direction and conditions unspecified. That paper proposed governed, typed relationships above the association graph. It left open a question this paper takes up: may those typed relationships be learned from text, and if so, what may an agent do with them?

\n

Three design decisions determine the answer.

\n
    \n
  1. Origin of a relationship. It can be declared by a person in a reviewed file, counted from observed text, or inferred by a model.
  2. \n
  3. Scoring. A score can be a sum of counts, or a function of learned parameters.
  4. \n
  5. Output. A query can return ranked documents, or the paths that justify them.
  6. \n
\n

Reference point one: a learned inspiration graph

\n

FIG-MAC targets automated scientific hypothesis generation. Its Fine-grained Inspiration Graph has three node types: paper (PAP), research question (RQ) and solution (SOL). Hierarchical relations (has_rq, has_sol) encode the structure inside each paper. Cross-paper relations are related, for semantically similar entities, and inspired, from a solution in one paper to a research question in another, without requiring a citation between them.

\n

The graph is inferred throughout. Papers were annotated manually to a standard (Kappa 0.85), after which a fine-tuned extractor processed 26,917 papers from five venues, four of them NLP conferences. Candidate cross-paper pairs below a similarity threshold were pruned and the remainder classified by a fine-tuned Qwen3-8B. A two-layer relational graph convolutional network with a DistMult decoder scores edges; on inspired-edge link prediction it reports a test mean reciprocal rank of 0.4599. Retrieval takes the union of dense-vector neighbours and graph chains of the form (RQ_0, ..., RQ_m, SOL_j, PAP_k). Each chain is ranked by a weighted sum of a cosine similarity and two learned edge confidences, with weights tuned on a validation set and not published.

\n

The design returns paths. Its weakness, from an assurance point of view, is that every relationship and every score in a chain depends on a model decision that a reviewer cannot recompute.

\n

Reference point two: a counted role graph

\n

Terraphim's terraphim_rolegraph, read at terraphim-core commit 84a496a, makes the opposite choices. Terraphim graph embeddings describes the mechanism; the facts below come from the source.

\n\n

The scoring path has no training step, and the supplied thesaurus makes the concept vocabulary inspectable; adding a concept is a text edit. Human authorship, review and change control of that thesaurus are governance requirements, not properties the cited implementation enforces: it accepts Markdown or JSON inputs and exposes an unrestricted Thesaurus::insert. Its weaknesses mirror FIG-MAC's strengths. The adjacency edges that query_graph ranks over carry no general-purpose relation type. Terraphim's optional medical feature does provide a MedicalRoleGraph with typed, directed edges (IsA, Treats, Causes, Contraindicates and others) loaded from curated sources such as PrimeKG and SNOMED CT, but those types are domain-specific and sit outside the generic query path. Two documents that express the same idea in different words remain unconnected until the thesaurus records the synonym. The path that would explain a multi-concept match is computed and discarded.

\n

What the evidence supports

\n

FIG-MAC's ablation (Table 5 of the paper) compares no external knowledge, graph-only, vector-only and hybrid retrieval across three backbones and two architectures. Graph-only exceeded vector-only on raw novelty and on source diversity in all six configurations, and on provenance-adjusted novelty in five of six. Hybrid retrieval exceeded both everywhere.

\n

Four limits govern how far this generalises.

\n\n

The defensible reading is that typed traversal contributes something dense neighbours do not, for a task that values breadth. That supports adding typed relationships to a graph layer. It does not establish that learned relationships are safe to act on.

\n

A layering that keeps provenance visible

\n

The proposal is to treat provenance as a property of every edge and to let it constrain use. Each layer below either exists today or is proposed, as marked.

\n
\nflowchart TB\n    T[Declared vocabulary: thesaurus and automaton. Exists] --> C[Counted adjacency: role graph. Exists]\n    D[Declared typed relations: governed role templates. Proposed] --> P\n    C --> P[Path evidence: walk with per-edge provenance class. Proposed]\n    I[Inferred candidate relations: model, version, confidence. Proposed, quarantined] -.-> R\n    V[Dense recall supplement: tagged neighbours. Optional] -.-> R\n    P --> R[Retrieval result for the agent]\n    P --> K[Checklist and authority checks: declared and counted edges only]\n
\n

Figure 1. Provenance-classed layers. Dotted lines may widen recall but cannot satisfy a check.

\n

Declared vocabulary and counted adjacency. These are the existing Terraphim layers. They supply concept resolution and association evidence with recomputable scores.

\n

Declared typed relations. A relationship such as refines, precedes or contradicts is written by a role owner in the same reviewed form as synonyms and promoted under the same change control. This is the typed layer the roles paper proposed. Its type is a claim a person made, so it can be audited like any other governed statement. Relations imported from a curated external ontology, as the medical graph does from PrimeKG and SNOMED CT, belong in this class too, with the source and release recorded.

\n

Inferred candidate relations. A model may propose edges such as FIG-MAC's inspired. Each inferred edge records the model, its version, the input it saw and its confidence. Inferred edges are stored apart from declared and counted edges. They may extend a retrieval result, and they are labelled as inferred when they do. They are never evidence for a checklist item or an authority decision until a reviewer promotes them to the declared layer.

\n

Dense recall supplement. Vector neighbours can fill gaps that the thesaurus has not yet covered, which is the role FIG-MAC's ablation suggests for them. Results obtained this way are tagged, so a reader can distinguish \"matched a governed concept\" from \"was near the query\".

\n

Path evidence as the output contract. Instead of a boolean, the graph returns the walk it found, with the node, edge, count and provenance class of each step. An agent can cite the path, and a reviewer can check that every step used to satisfy a check is declared or counted.

\n

Evaluation. Any claim that a new layer improves results should use a judge independent of the generator, report spread across repeated runs, and measure provenance directly: similarity of the answer to its sources, and diversity among them. FIG-MAC's provenance factor is a usable starting point, with the caveat above that diversity partly reflects the retrieval mechanism.

\n

Implementation boundary

\n

Today Terraphim provides the declared vocabulary, the counted adjacency graph, the TF-IDF fallback and the boolean path check. Behind the optional medical feature it also provides domain-specific typed edges, loaders for PrimeKG and SNOMED CT, and symbolic embeddings that compute Jaccard similarity over IS-A ancestor and descendant sets; none of these is part of the generic query path. General-purpose relation types that any role can declare, provenance-classed edge storage, a quarantined inferred-edge store, path return with provenance classes and the evaluation harness are proposed. No benchmark comparing these layers is claimed here, and none of FIG-MAC's results were reproduced.

\n

Conclusion

\n

FIG-MAC and Terraphim's role graph illustrate two coherent positions. A learned, typed graph connects ideas that share no vocabulary and returns chains that read as arguments, at the cost of relationships nobody can recompute. A declared, counted graph gives every score an audit trail, at the cost of untyped edges and recall that depends on the thesaurus. A reference architecture need not choose between them if it records how each edge was obtained and limits what each class may justify. Declared and counted edges can support checks and authority decisions. Inferred edges and vector neighbours can widen what an agent sees, provided they are labelled and cannot be mistaken for evidence.

\n

Sources and scope

\n

FIG-MAC: Chen, Gao, Huang, Zhou, Su, Wang and Sha, arXiv:2611.33563v1, submitted 25 November 2026 and read on 27 November from the v1 PDF. Figures quoted are from its sections 3 and 4 and Tables 2 to 5; the interpretation of its limits is this paper's.

\n

Terraphim details were checked against crates/terraphim_rolegraph and crates/terraphim_types in terraphim-core at commit 84a496a on 27 November 2026. The layering, provenance classes and evaluation requirements are proposed integration work and do not describe a deployed system.

\n", "https://reference-architecture.ai/properties/date": "2026-11-27", "https://atomicdata.dev/properties/tags": {"categories":["Architecture"],"tags":["knowledge-graphs","graph-embeddings","retrieval","terraphim","provenance","ai-agents"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/posts/the-reviewer-saw-the-bug-and-passed-it/", "https://atomicdata.dev/properties/name": "The Reviewer Saw the Bug and Passed It", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/posts/the-reviewer-saw-the-bug-and-passed-it/", "https://atomicdata.dev/properties/description": "

Every pull request we merge is reviewed by a second model before it lands. The rule is simple: the model that wrote the code never signs it off. We use a different model family as the reviewer, at a fixed rubric, and we merge only when it returns no blocking findings and a confidence of 4 or 5 out of 5.

\n

I like that rule. This week a paper made me look harder at what it actually buys.

\n

\n

The experiment

\n

Zax Shen, Hanling Zhang and Zixu Wang (arXiv:2611.33639) took 90 agent-written patches to Django from SWE-bench Verified. Every one of them passes the benchmark's own tests. Stronger tests, plus a post hoc review of the labels, judged 55 wrong and 35 correct. They then had Claude Opus 5.5, Sonnet 5.5 and Haiku 5.5 review every patch at low, medium and high reasoning effort, in a sealed container. The reviewer had the issue, the code and a shell, and could run tests. That makes 810 reviews for about $50 of API spend.

\n

The Opus part was preregistered before the first main-run review. The Sonnet and Haiku parts were not, and the authors say so on every table. The data are public. I recounted the headline cells from their per-review CSV without using any of their code, and they match.

\n

What came out

\n

More effort helps. For Opus, going from low to high cut the share of wrong patches accepted from 67% to 45%. For Opus, medium was close enough to high, within the preregistered 15-point margin, to be the sensible default. For the two smaller models it was not.

\n

Then the part that matters for anyone running a review gate: no setting was a strong gate. The best of the nine configurations still accepted 45% of the wrong patches.

\n

And the part I keep thinking about. In 111 of the 290 reviews that accepted a wrong patch, the reviewer named the defect in its feedback and passed the patch anyway.

\n

That is not a detection failure. The model found the bug, described it, and then decided it did not matter. Part of that may be fair: for many of these patches the stronger test checks something the issue never asked for. The authors are clear that the labels are not ground truth, and they show the results weaken a lot when those patches are removed. But \"seen, written down, waved through\" is a failure mode you can design for, and most review setups do not.

\n

Where this lands for us

\n

Three things changed in how I think about our gate.

\n

First, the effort setting is part of the gate, so write it down. Our review command never passed a thinking level. It runs at whatever the tool's default is, which today is medium. The paper's clearest result is that the right level differs by model. Opus was fine at medium; Haiku needed high. Our reviewer is not a Claude model at all, so the paper tells us nothing about where its level should sit. It only tells us that we have never measured it. The honest fix is to pin the level explicitly and record it with every review, and then to measure it on our own merged PRs before claiming it is enough.

\n

Second, a finding about behaviour must not be a nit. Our rubric splits findings into blocking (P0, P1) and non-blocking (P2). We put wording, scope and process in P2 on purpose, because reviewers rewarded for finding things will find things. That is still right. But it means that a real functional defect, filed as a P2 or mentioned in passing, merges. The \"seen but passed\" result says this is not hypothetical. Our rule now needs one more sentence: a finding that claims the code behaves incorrectly is blocking unless the reviewer argues it down explicitly.

\n

Third, a review is not a test. If the strongest configuration in a careful study lets 45% of plausible-but-wrong patches through, the review cannot be what stands between a wrong patch and production. Nothing guarantees that, tests included: every patch in the study had passed the benchmark's tests. But tests and CI are the primary executable gate, and the merge needs them whatever the reviewer says. What the review adds on top, checks of structure, scope and claims that a reader would act on wrongly, is our design choice. The paper never measured it, so we will have to. The paper ends in the same place: a review gate \"complements tests rather than replacing them\".

\n

The bit nobody likes

\n

The paper is also a good example of its own threat. The analysis, figures and draft were written by Claude Opus 5.5, one of the models under test. The coders that decided which reviews \"named the defect\" were Claude 5.5 models too, and no person checked them. The authors say all of this, plainly, in the paper. Agreement between two models from the same family shows consistency, not accuracy. We have that sentence in our own rules for the same reason.

\n

What I take from it is not a number to copy. It is a measurement we have not yet made on our own reviewer, our own code and our own definition of \"wrong\".

\n
\n

The pattern this leads to, with the evidence and its limits, is written up as The AI Review Gate: What a Second Model Can and Cannot Stop.

\n", "https://reference-architecture.ai/properties/date": "2026-11-27", "https://atomicdata.dev/properties/tags": {"categories":["Engineering"],"tags":["ai-agents","code-review","llm-as-judge","verification","review-gates"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/posts/ai-review-gate-pattern/", "https://atomicdata.dev/properties/name": "The AI Review Gate: What a Second Model Can and Cannot Stop", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/posts/ai-review-gate-pattern/", "https://atomicdata.dev/properties/description": "

Abstract

\n

Coding agents write patches faster than people can review them, so teams put a second model in front of the merge. A recent paired study by Shen, Zhang and Wang (arXiv:2611.33639) measured how well that works. Three Claude 5.5 models, each at three reasoning-effort levels, reviewed 90 agent-written Django patches that all pass the benchmark's own tests. Stronger tests, followed by a post hoc label review, judged 55 of them wrong. More effort helped, but no setting was a strong gate: the best of the nine accepted 45% of the wrong patches. In 111 of the 290 reviews that accepted a wrong patch, the reviewer had named the defect in its own feedback. This article turns those findings into a reference pattern for an AI review gate. It covers what the gate should be asked to do, which settings belong in its configuration, how its verdict should fail, and how to measure it on your own code before trusting it.

\n

\n

The question a review gate has to answer

\n

A review gate is worth its cost only if it rejects broken patches without rejecting good ones. That makes it a classifier, and a classifier has two error rates:

\n\n

For a merge gate the two are not equally costly. A rejected good patch costs a round trip. An accepted wrong patch costs whatever it breaks later. Any claim that a gate \"works\" needs both rates, measured on patches whose correctness is known independently of the gate.

\n

That last condition is the hard part. Most teams have never measured their reviewer at all. The study below is useful because it did, carefully, and published the data.

\n

The evidence

\n

What was measured

\n\n

I recounted the headline cells from the authors' released per-review data, without using their code. The false-success and false-alarm counts, the paired discordant counts, the exact McNemar p values and the cost ratios all match the paper. The intervals and the coded analyses were not recomputed.

\n

What came out

\n\n\n\n\n\n\n\n\n\n\n
ModelEffortWrong patches accepted (of 55)Correct patches rejected (of 35)Mean cost per review
Opus 5.5low37 (67%)2$0.044
Opus 5.5medium26 (47%)2$0.095
Opus 5.5high25 (45%)2$0.120
Sonnet 5.5low36 (65%)2$0.023
Sonnet 5.5medium33 (60%)3$0.027
Sonnet 5.5high27 (49%)3$0.047
Haiku 5.5low43 (78%)2$0.002
Haiku 5.5medium35 (64%)7$0.004
Haiku 5.5high28 (51%)4$0.008
\n

Source: the paper's Table 3, corrected labels.

\n

Five results matter for architecture:

\n
    \n
  1. Effort helps, and the useful level depends on the model. For Opus, in the preregistered test, high caught 13 wrong patches that low missed, against 1 the other way. Medium was within the preregistered 15-point margin of high. For Sonnet and Haiku, medium was much cheaper than high but was not shown to be as good.
  2. \n
  3. No setting is a strong gate. Every configuration accepted at least 45% of the wrong patches. False alarms stayed between 6% and 20%. The errors lean heavily towards letting wrong code through.
  4. \n
  5. Seen but passed. In exploratory coding, 111 of the 290 acceptances of wrong patches named the tested defect in their feedback and passed the patch anyway. Detection was not the failure. The decision was.
  6. \n
  7. Shallow passes and malformed verdicts. Every review that used no thinking tokens returned a pass. At low effort, Opus ran no test in 23 of 90 reviews. The two smaller models returned 15 malformed verdicts between them.
  8. \n
  9. Memory of the fix did not help. This is exploratory and Opus only. Reviews flagged as drawing on memory of the upstream fix accepted 71% of the wrong patches, against 46% for the rest. Memory was close to universal: the coders judged that 237 of the 270 Opus reviews used knowledge of the upstream fix in some way. The preregistered sensitivity analysis in the paper's supplement drops every patch with a memory-flagged review. On the 25 wrong patches that remain, Opus accepted 48% at low effort and 20% at both medium and high, against 67%, 47% and 45% on the full set. Those patches were selected by the reviewer's own behaviour and may simply be easier, so this is a hint, not a measured rate.
  10. \n
\n

How far the evidence reaches

\n

The authors are explicit about the limits, and a pattern built on this study has to carry them:

\n\n

None of this weakens the architectural reading below. It does mean that no number in the table should be copied into another team's configuration.

\n

The reference pattern

\n
\nflowchart LR\n    A[Author agent] --> P[Patch at head SHA]\n    P --> T[Tests and CI: primary executable gate]\n    P --> R[Reviewer: different model, pinned effort]\n    R --> V{Typed verdict}\n    V -->|pass| M[Merge decision]\n    V -->|fail: behavioural finding| X[Back to author]\n    V -->|malformed or undetermined| H[Escalate: fail closed]\n    T -->|green| M\n    T -->|red| X\n    K[Known-answer set] -.->|calibrates| R\n
\n

The pattern has six parts. Each part answers one of the findings above.

\n

1. The reviewer is not the correctness gate

\n

If the strongest configuration in a careful study lets 45% of plausible-but-wrong patches through, the reviewer cannot be the component that correctness rests on. Nothing in this pattern guarantees correctness, tests included: every patch in the study passed the benchmark's tests, and many were still wrong. Tests and CI are the primary executable gate, and the merge decision requires them independently of the review. The paper reaches the same conclusion: such a gate \"complements tests rather than replacing them\".

\n

What else the reviewer should be asked to do is a design choice, not a finding of the study. The study measured only verdicts against functional-correctness labels. It did not measure how well a model checks scope, documentation claims or structure. This pattern proposes giving the reviewer that work, because tests do not do it: checking that the change matches its stated scope, that claims in the description and documentation are supported, and that structure and boundaries are kept. That proposal needs its own calibration (part 6) before anyone relies on it. What the evidence does support is the negative: a brief that asks a model to certify correctness asks for something this study says it cannot reliably deliver.

\n

2. The reviewer is a different model from the author

\n

The authoring model's own review is never the review of record. The study did not test this directly: its reviewers judged patches written by many different agents, and it did not compare self-review with review by another model. The rule rests instead on a point the authors make about their own coders, that a coder from the same model family \"may share the reviewer's blind spots\". It is our inference that the same holds, with more force, for an author reviewing its own patch.

\n

3. Effort is configuration: pin it, record it, sweep it

\n

The useful effort level differed by model in the study, and vendor defaults differ by model too. A review command that does not state its effort level inherits whatever the tool's default is today. When the tool or model is upgraded, the gate's behaviour can change with no change in your repository.

\n\n

4. A finding that claims wrong behaviour blocks

\n

\"Seen but passed\" is the most useful result in the study for gate design. A reviewer that writes down a real defect and then approves the patch has done the hard part and failed at the easy one.

\n

Most review rubrics separate blocking findings from advisory ones, and they should. Reviewers that are rewarded for finding things will find things, so wording, scope and process belong in the advisory tier. The rule that closes the gap is narrow:

\n
\n

A finding that claims the code behaves incorrectly is blocking, unless the reviewer explicitly argues why it does not matter.

\n
\n

This keeps advisory findings cheap without letting a behavioural claim fall into the advisory tier by default. It also produces an auditable record: every behavioural finding that did not block comes with its reason.

\n

5. The verdict is typed, and it fails closed

\n

The verdict has three outcomes:

\n\n

For a merge gate, undetermined does not pass. The study counted a malformed verdict as no acceptance, and the gate should do the same: escalate to a person or a stronger lane, and never default to pass.

\n

A review that never ran the code it judged is a weaker signal than one that did. In the study, every review with no thinking returned a pass. If the reviewer has tools, record whether it ran anything. A pass with no execution and no reasoning trace is a candidate for escalation, not a clean pass.

\n

6. Calibrate on a known-answer set that you own

\n

Every number above comes from public Django patches. Those are patches whose fixes a model may have seen in training, judged against labels from fix-derived tests. Your code is different, and if it is private, no fix can be recalled. Absolute rates may move in either direction. The memory subset (result 5) suggests they may improve, since false success fell to 20% where the reviewer did not lean on a remembered fix, but only a measurement on your own patches can say.

\n

The only way to know your gate's false-success rate is to measure it.

\n\n

If the measured false-success rate is close to the study's, that is not a failure of the method. It is the evidence that the review cannot carry correctness, which then rests primarily on tests and CI.

\n

What this pattern does not claim

\n\n

Sources

\n\n", "https://reference-architecture.ai/properties/date": "2026-11-27", "https://atomicdata.dev/properties/tags": {"categories":["Architecture"],"tags":["ai-agents","code-review","llm-as-judge","verification","evaluation","review-gates"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/posts/a-deterministic-concept-layer-beside-ontology-and-lexical-graph/", "https://atomicdata.dev/properties/name": "A Deterministic Concept Layer beside an Ontology and a Lexical Graph", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/posts/a-deterministic-concept-layer-beside-ontology-and-lexical-graph/", "https://atomicdata.dev/properties/description": "

Abstract

\n

A semantic context layer for agents must turn a user's words into the concepts its data is organised by. AWS's Context Ontology Accelerator (COA, version 0.3.11) does this with two techniques. A formal ontology induced from tables, with R2RML mappings, serves governed metrics and ontology-guided SQL. A lexical knowledge graph extracted from documents serves retrieval and synthesis. Its documentation names the gaps between them, in particular:

\n\n

This paper proposes a third component beside the two: a deterministic concept layer. It compiles the ontology's own vocabulary into a thesaurus and matches it with a single automaton. Optionally, it counts concept co-occurrence across documents. The paper assigns the layer four permitted decisions and three forbidden ones, and illustrates the mechanism on Terraphim's implementation. It reports where that implementation is weaker than COA's existing matcher. Nothing here has been measured against a COA deployment.

\n

\n

The decision an agent makes before it asks

\n

Typed Relations, Counted Adjacency and Learned Scores argued that every edge in an agent's graph should carry its provenance: declared, counted or inferred. This paper takes up an earlier step in the same pipeline.

\n

Before an agent queries a governed layer, it must decide which concept the user means. That decision has three possible owners:

\n
    \n
  1. The semantic layer's model. It embeds the question and lets retrieval and an LLM choose.
  2. \n
  3. A deterministic matcher. It maps exact surface forms to concepts from a reviewed vocabulary.
  4. \n
  5. The agent's own model. It guesses from schema descriptions it has fetched.
  6. \n
\n

The first is flexible but not recomputable. The third spends round trips and context. The second can be recomputed and explained, but it covers only the vocabulary someone wrote down. The architecture question is how to combine them so that each decides only what it can justify.

\n

Reference point: a governed semantic layer

\n

COA runs in the customer's AWS account and is organised as Scan, Model, Metrics and Serve. The facts below are read from its repository at commit 5dd33d7.

\n

Technique one: a formal ontology from tables.

\n\n

Technique two: a lexical graph from documents.

\n\n

Serving. Resolution runs in three tiers, each falling through to the next.

\n\n

Cedar authorisation, evaluated against the delegating user and failing closed, admits or refuses every MCP tool call. A SELECT-only SQL firewall adds per-user table and column controls on the Tier 1 and Tier 2 paths that execute SQL. Ontology schema is itself governed: the MCP server withholds schema fields from a caller without the viewOntology right. Agents reach all of this through six MCP tools.

\n

The documented gaps. COA's documentation states them directly:

\n\n

The proposed layer

\n

The concept layer is compiled, not trained. Its input is the vocabulary the governed layer already publishes:

\n\n

Each surface form becomes a thesaurus key. Its value is the concept, with the class or metric IRI as its link. One automaton matches all keys in one pass and prefers the longest match. Every hit is returned with the matched term, its byte span and the concept.

\n
flowchart LR\n    U[User question] --> A[Agent]\n    A --> C[Concept layer<br/>thesaurus + automaton]\n    C -->|concept IRIs, spans,<br/>residual, collisions| A\n    A -->|query, describe_schema,<br/>graph_traversal| M[MCP tools]\n    M --> T1[Tier 1<br/>governed metrics]\n    M --> T2[Tier 2<br/>ontology to SQL]\n    M --> T3[Tier 3<br/>lexical graph]\n    O[(Published ontology<br/>labels, altLabels,<br/>metric synonyms)] -->|compile at accept time| C\n    D[(Documents or glossaries)] -.->|optional co-occurrence counts| C
\n

The layer runs where the agent runs, or as a build step at the moment a steward accepts a proposal. It holds no rows or documents, but its vocabulary is governed information in its own right. It falls under two different rights. Class labels need viewOntology: describe_schema is refused without it. Metric names and aiContext.synonyms come from list_metrics, which is admitted with the namespace view right. There, viewSource controls a metric's SQL and source table, and viewOntology controls only its linked ontology concepts. The layer must therefore be compiled through those interfaces, as the user the agent acts for, with each part of the vocabulary following its own right. Each part must be scoped to that user and namespace, and rebuilt when the grants governing it or the accepted vocabulary change. Otherwise a local index would keep vocabulary that the caller may no longer see.

\n

Permitted decisions

\n
    \n
  1. Name the concept. It maps a surface form to a class or metric IRI exactly. On the agent side this fills the documented variant gap. The agent can then narrow its schema request to the classes it needs.
  2. \n
  3. Report the residual. It returns the parts of the question that no match covered. This is the same signal COA's Tier 1 computes internally. Exposing it lets the agent ask the user a follow-up, or pass a qualifier through the metric's supported dimensions, before it spends a query.
  4. \n
  5. Lint the vocabulary. It fails the compile when one surface form belongs to two concepts. COA declines such a match at run time. Catching it when the proposal is accepted moves the fix to the steward, who can make it, and away from every agent that would otherwise meet the decline.
  6. \n
  7. Propose candidates. Counted co-occurrence between a document concept and a column concept, within one paragraph, nominates tables for the bridge to read first. It can also seed graph traversal with an exact entity next to the vector hit.
  8. \n
\n

Forbidden decisions

\n
    \n
  1. Asserting equivalence across sides. A co-occurrence count is not a skos:closeMatch. Only the governed layer's reviewed alignment may assert one.
  2. \n
  3. Answering. The layer never returns a number or a fact, only concepts and spans. The tiers answer, behind Cedar admission and, where SQL runs, the firewall.
  4. \n
  5. Overriding a decline. If the governed layer declines an ambiguous match, the agent may not resubmit with a guessed concept pinned. The concept layer resolves wording, not ambiguity in the vocabulary.
  6. \n
\n

Illustration on an existing implementation

\n

Terraphim's terraphim_automata and terraphim_rolegraph crates implement the mechanism. We ran a small program against terraphim-core at commit b1f8389, with a hand-made vocabulary that mirrors COA's documentation examples:

\n\n

We wrote one glossary sentence that mentions a cancellation and the order status. The results were:

\n\n

Two results show the implementation behind COA's existing matcher:

\n\n

The edge exists only because we wrote the sentence. It illustrates counting and is not evidence that the layer finds real bridges. We did not run the layer against a COA deployment, and we did not check whether the describe_schema MCP tool returns altLabels; the REST graph vertex shape does.

\n

What this changes for a reference architecture

\n

The vocabulary is a governed artefact in its own right. A steward's synonym edits change which concepts agents can name. They therefore belong in the accept step, with a collision check, not only in the embedding text.

\n

The residual belongs in the interface. A matcher that reports only what it found invites an agent to treat a partial match as a whole one. COA's Tier 1 gate shows the cost of getting this wrong: the unfiltered total, returned with confidence 1.0, as the answer to a narrower question. The concept layer should return the residual on every call.

\n

Deterministic layers decline; probabilistic layers rank. Exact matching earns its place by being recomputable. It loses that place the moment it picks a winner silently. When a surface form is ambiguous, the deterministic layer should say so and leave the choice to a reviewed rule or to the user.

\n

Limitations

\n\n", "https://reference-architecture.ai/properties/date": "2026-11-27", "https://atomicdata.dev/properties/tags": {"categories":["Architecture"],"tags":["knowledge-graphs","ontology","semantic-layer","terraphim","ai-agents","mcp"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/posts/organisational-roles-as-agent-contracts/", "https://atomicdata.dev/properties/name": "Organisational Roles as Contracts for AI Agents", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/posts/organisational-roles-as-agent-contracts/", "https://atomicdata.dev/properties/description": "

Abstract

\n

An organisational AI agent needs defined responsibilities, relevant knowledge and bounded authority. This paper proposes roles as contracts for all three. A Project Manager plans delivery; a Product Manager decomposes product outcomes into features. Each uses a governed role-based knowledge graph. Agent services realise role capabilities through tools whose actions require contextual permission. Verification and validation require compatible concepts, relationships and operating conditions across the input and evaluation criteria, with explicit mappings where views differ. A cross-check against ISO/IEC/IEEE 42010:2022 and 29148:2018 informs these distinctions without claiming conformity. Terraphim provides graph retrieval and checklists; Terraph connects concept matching to proof-gated verbs; ADF configurations define responsibilities and artefact templates. The proposed integration would allow a Project Manager agent to create a checked plan from an approved template while reserving production deployment for a separately authorised role.

\n

\n

Continuing the argument on evolving AI risk

\n

This paper continues the argument developed by David Hunt and Alexander Mikhalev in AI Risk is evolving, every day., published on 31 October 2026. Their starting concern is that an agent can pursue a legitimate objective through unauthorised methods. They connect oversight of business activity with cybersecurity and knowledge integrity, and argue that changes to agents and their surroundings can invalidate earlier assurance.

\n

Supervision needs an inspectable mandate: the organisational role, the capability being exercised, the service providing it, and the tool action requested against a particular resource. Role-based knowledge graphs provide the relevant concepts and relationships; an independently enforced permission decision determines whether the action may proceed. A Project Manager can prepare a delivery plan using approved templates while production execution remains assigned to a separately authorised role. The sections below distinguish existing components from the integration still required.

\n

A successful check needs criteria that apply to the input's meaning, obligations and operating context. Matching words cannot establish that a plan preserves a prohibition, uses the correct environment, or retains an acceptance threshold. The semantic compatibility contract developed here connects requirements, criteria and evidence through a versioned baseline and explicit mappings. Changes to that baseline trigger reassessment of affected results. The standards cross-check helps define the responsibilities and evaluation claims; it does not establish that the supervisory system has been implemented.

\n

The common concepts connect the earlier article's concerns to the mechanisms examined in this paper:

\n\n\n\n\n\n\n\n\n
Shared conceptEngineering continuation in this paper
Mandate and justified authorityTrace the assigned role through capability, service, tool and action to a contextual permission decision.
Knowledge integrity and contextUse governed concept identities, relationships and requirement baselines to preserve meaning across inputs, outputs and criteria.
Independent supervisionSeparate the agent's proposal from the gateway's permission decision and the evidence used to assess its result.
Continued validity of assuranceBind findings to the evaluated artefact, criteria and context; reassess affected claims when relevant versions change.
Learning and authority to changeGovern changes to role graphs, templates and policies separately from permission to perform the task.
Prediction and operational evidenceKeep illustrative scenarios, expected outcomes and recorded executions distinguishable; validate predictions before relying on them.
Consequences across organisational scalesMake resource and project scope explicit, and identify where wider consequences require escalation beyond the acting role.
\n

This mapping is our architectural synthesis. The examples below illustrate individual mechanisms; connecting them across systems remains engineering work.

\n

The organisational unit of agency

\n

“Planning agent” describes a computational activity. It does not identify who owns the outcome, which planning conventions apply, or what authority accompanies the work. The same ambiguity affects “research agent”, “review agent” and “execution agent”. These labels can be useful implementation names, but they leave organisational meaning unresolved.

\n

A Project Manager plans delivery against agreed scope, dependencies, resources and milestones. A Product Manager decomposes desired outcomes into features, evaluates value and defines acceptance criteria. Both plan, but they plan different objects, draw on different evidence, and answer to different accountabilities. An organisation should therefore delegate to an agent acting in a defined role, with planning as one of that role’s capabilities.

\n

The role contract can remain stable when an agent’s model, prompt, framework or supplier changes. A replacement implementation must demonstrate the required service behaviour and operate within the same authority boundary. Governed role definitions and capability contracts give the organisation a basis for evaluating that replacement.

\n

The central proposal is a traceable relationship:

\n
\n

Organisation → role → capability → service → tool → action → contextual permission.

\n
\n

This sequence is an explanation path, not an assertion that authority flows automatically through every edge. The organisation assigns responsibilities to roles; an agent principal is separately authorised to enact a role. Its implementation supplies services. Tools make actions technically available. Policy determines whether an exact requested action is permitted in its current context.

\n

The organisational semantic layer

\n

The organisational semantic layer describes concepts, relationships, templates, standards and responsibilities using explicit identifiers and versioned definitions. Here, conceptual space means this governed system of organisational meaning. The proposal does not require a fully implemented geometric model of human conceptual spaces.

\n\n\n\n\n\n\n\n\n\n
ElementOrganisational meaningPlanning example
RoleA position with responsibilities and bounded authorityProject Manager
CapabilityAn ability the organisation needs to achieve an outcomeDelivery planning
ServiceAn accessible behaviour provided by an implementationProduce a delivery plan
Agent implementationSoftware that provides the service while enacting an assigned roleProject planning agent instance
ToolA concrete interface through which work is performedTemplate reader or document writer
ActionA specific operation on an identified resourceCreate a draft plan in project workspace
PermissionA policy decision over principal, role, action, resource and contextDraft creation allowed for the assigned project
EvidenceRecords supporting a decision and its observed resultTemplate version, checks and execution receipt
\n

This distinction between capabilities and services is compatible with enterprise architecture’s separation of organisational behaviour from its realisation and exposed services. It is used here as an architectural vocabulary, without claiming formal compliance with an ArchiMate model. Open Group ArchiMate 101

\n

A capability describes what the organisation can accomplish. It is not a permission token. Likewise, an implementation’s demonstrated competence does not grant authority. A model may understand deployment instructions while having no right to invoke a deployment endpoint.

\n

Role capabilities contribute to broader organisational capabilities. For example, an organisation’s Product Delivery capability can depend on Product Discovery performed by the Product Manager, Delivery Planning performed by the Project Manager, and Release Assurance performed by the Release Manager. The graph records these contribution relationships explicitly. Separate agent services realise the role capabilities; their combined performance supports the organisational outcome without granting each service the authority of every contributing role.

\n

Roles should also be sufficiently specific to support ownership. An organisation can assign a person or agent multiple roles, but each action should use an explicit active role and bounded assignment. Combining role knowledge for a discussion must not silently combine execution privileges.

\n\n\n\n\n
RoleDedicated conceptual viewPrincipal serviceExample boundary
Product ManagerOutcomes, user needs, features, value hypotheses and acceptance criteriaProduce an evidence-linked feature breakdownCannot approve production deployment
Project ManagerScope, dependencies, resources, risks and delivery milestonesProduce a delivery plan from an approved templateCan write a project draft; cannot deploy it
Release ManagerRelease readiness, change records, environments and rollback proceduresCoordinate an authorised releaseProduction action requires a separate assignment and satisfied release policy
\n

These are example contracts, not universal job descriptions. The organisation owns the actual definitions and decides where responsibilities overlap.

\n

Dedicated knowledge without isolated vocabularies

\n

Each role receives a governed projection of organisational knowledge. This can select which concepts and relationships are available to the role, as well as how retrieval ranks them. Roles can share an underlying graph while retaining different conceptual views.

\n

Shared concepts retain shared identifiers. For example, a feature’s acceptance criteria connect product intent with delivery planning and release verification. Role-specific relationships express what matters for each responsibility: a Product Manager connects a criterion to user value; a Project Manager connects it to delivery evidence and dependencies; a Release Manager connects it to a release decision. The shared identity supports handoffs without making the roles interchangeable.

\n

Role-owned overlays can define local vocabulary, specialised relationships, approved templates and checklist requirements. Their provenance should identify the owner, source, revision and approval state. Changes to the shared definition of “accepted” require different governance from adding a convenient synonym to a role’s retrieval vocabulary.

\n

Graph projections must also respect access controls. Knowing that another team’s confidential plan exists does not authorise retrieving its contents. A role graph is a semantic view; a separately authenticated assignment and resource policy determine what information the agent may actually read.

\n

The graph is the inspectable, or white-box, component of this architecture. A reviewer can examine its concepts and relationships, the embeddings derived from them, and the definitions that shaped retrieval. This visibility neither makes the language model transparent nor establishes that the graph's contents are correct.

\n

Architecture description and requirements engineering

\n

ISO/IEC/IEEE 42010:2022 concerns architecture descriptions, including viewpoints and model kinds. It distinguishes an architecture from its description and does not prescribe an agent implementation or execution policy. In that standard, ADF means architecture description framework; the ADF agent orchestration system discussed here is a different use of the acronym. ISO/IEC/IEEE 42010:2022

\n

For this architecture, stakeholder concerns, viewpoint conventions and resulting views must remain distinguishable from organisational roles. A viewpoint establishes conventions for constructing and interpreting views that address concerns. ISO 24641:2023 preview

\n

A role can serve several stakeholder concerns and use several viewpoints. A role graph becomes useful architectural material when its concepts, relationships, conventions and intended questions are explicit. It is not automatically a viewpoint; a project plan is not automatically an architecture view. Terraph's language constructs likewise do not establish that it is a conforming architecture description language. The standards do not assign the paper's Project Manager, Product Manager or Release Manager jobs their permissions.

\n

ISO/IEC/IEEE 29148:2018 addresses requirements engineering and its information across the life cycle. Its terminology distinguishes checks on requirements from checks on the realised product or system. The following four questions must not be collapsed into a single “validation passed” label. ISO/IEC/IEEE 29148:2018 official preview

\n\n\n\n\n\n
ActivityQuestion and object
Requirements verificationAre the requirement statements and set well formed?
Requirements validationDo those requirements express the intended stakeholder needs?
Product or system verificationDoes the realised item fulfil its specified requirements?
Product or system validationDoes it support its intended application and use?
\n

Each decision needs the applicable activity and evidence; an individual tool check need not perform all four. A reviewed input baseline is particularly important: an output checklist cannot retrospectively establish what the stakeholder meant.

\n

The following crosswalk is this paper's proposed design, not an ISO clause-compliance matrix:

\n\n\n\n\n\n
Standards-related distinctionApplication to the proposed agent contract
Stakeholder concern and viewpointName the decision owner, concern and representation conventions; bind the agent's organisational assignment separately.
View and modelling conventionsSpecify graph concept and relationship types, interpretation rules and correspondences between role views.
Requirement and traceabilityConnect each obligation to its need, responsible role, input baseline, criteria, output and evidence.
Verification and validationName the checked object, the predicate or intended-use scenario, its applicable context and the decision supported.
\n

This is a bounded cross-check using official public material. It is neither certification nor a full-text normative clause audit. The richer semantic contract below is the paper's engineering proposal, not a claim that either standard mandates knowledge graphs or this permission scheme.

\n

Semantic compatibility between inputs and criteria

\n

A check is meaningful only if its criteria apply to the relevant meaning and context of its input. “Release” can mean software deployment or approval of a payment; the same token need not denote the same concept. A plan for staging cannot be validated against production assumptions merely because both mention “release”. A criterion about elapsed hours cannot silently become one about business days. Evaluation requires compatible conceptual spaces, not identical wording or complete identity between two role graphs.

\n

The proposed trace is:

\n
\n

Requirement ID and revision → stakeholder need → responsible role and relevant viewpoints → input concepts, propositions and context baseline → verification criterion and validation scenario → evidence → decision.

\n
\n

The baseline identifies the entity and project, source and requirement revisions, environment, relevant time and calendar, units and thresholds, assumptions, exceptions and prohibited actions. A proposition preserves who must do what to which object, under which conditions, with its polarity and quantifiers. “Every accepted feature” and “some features” can share concepts while imposing different obligations.

\n

Verification and validation may use different abstractions. A product view can describe a customer outcome while a delivery view describes work packages. Their mapping must explain how the relevant obligation survives decomposition and which evidence supports it. Approved unit conversions and concept mappings may establish compatibility; fuzzy similarity alone cannot. Additional derived criteria can be legitimate when their rationale and relationship to the stakeholder need are recorded. An obligation cannot disappear merely because a role projection omits its vocabulary.

\n

This paper proposes the following contract. These SHALL statements are authored requirements for the proposed integration, not quotations from ISO:

\n
    \n
  1. A check SHALL identify its object, requirement baseline, applicable criteria and relevant context revisions. The requirement owner and authority to resolve ambiguity or change the baseline must be recorded.
  2. \n
  3. A transformation SHALL preserve relevant obligations or carry an explicitly approved mapping or change. This includes relationships, polarity, quantifiers, units, thresholds, scope and assumptions, not just concept identifiers.
  4. \n
  5. A decision SHALL distinguish pass, fail, indeterminate and justified not applicable. Missing context, unresolved mappings or insufficient evidence cannot yield a pass; not applicable needs a recorded reason and authorised acceptance.
  6. \n
  7. A result SHALL bind to the evaluated state and be reassessed when a relevant change invalidates it. Passing semantic or quality checks never substitutes for an action's separate authority decision.
  8. \n
\n

Context compatibility is necessary but insufficient. A perfectly aligned test can still have a weak predicate, unreliable evidence or inadequate coverage. Criteria must themselves be verified and validated for their purpose; their evaluation must establish the promised claim. Checks should report only what their evidence supports.

\n

Connecting meaning with authority

\n

The architecture needs four cooperating parts: identity and assignment, semantic knowledge, mediated execution, and audit evidence.

\n

\"Proposed

\n

Figure 1. Connecting meaning with authority. Open the diagram source in Mermaid Live.

\n

Role-based access control provides a foundation: subjects are assigned authorised roles, and operations are mediated through the permissions of those roles. A session can activate a subset of the roles available to a subject. NIST RBAC

\n

The proposed architecture adds organisational meaning to this assignment and applies contextual conditions to execution. Project identity, resource scope, environment, approval state and expiry can all matter. This is consistent with attribute-based access control, which evaluates attributes of the subject, object, operation and environment against policy. NIST SP 800-162

\n

Let a request be q = (principal, role, service, tool, action, resource, arguments, context). A simplified decision rule is:

\n
permit(q) =\n    authenticated(principal)\n    AND active_assignment(principal, role, scope, expiry)\n    AND capability_service_binding(role, service)\n    AND registered_service_tool_action(service, tool, action)\n    AND resource_and_argument_scope_match(q)\n    AND required_evidence_valid_for_exact_request(q)\n    AND contextual_policy_allows(q)\n    AND NOT explicit_deny(q)
\n

An absent or indeterminate condition produces no permit. This is a proposed contract, not a description of a policy engine already supplied by Terraphim.

\n

The gateway must mediate actual effects. Hiding a deployment tool in a user interface is insufficient if the same principal can deploy through a shell, network client or overprivileged service credential. The action boundary includes alternative routes, delegated agents and mutable resource references. A delegate receives only an authorised subset of the parent’s scope; it cannot turn a planning request into a production privilege.

\n

Terraphim graph embeddings as a role context mechanism

\n

Terraphim’s graph approach supplies a concrete semantic mechanism for the role view. Concepts and surface forms are represented explicitly, and graph relationships support retrieval and explanation. Its documented graph retrieval path uses normalised concepts, synonym matching and document co-occurrence structure, rather than requiring a neural vector embedding model. Terraphim graph embeddings

\n

The inspected general RoleGraph implementation uses Aho–Corasick matching to resolve surface forms to concept identifiers. Its document indexer creates edges between consecutive recognised concepts in the indexed text and retains supporting document references. Retrieval then accumulates node, edge and document rank. Matched edges and tags make the retrieval basis inspectable. A high rank indicates retrieval support under that graph, not factual certainty or authority.

\n

For organisational planning, this allows terms such as “delivery roadmap” and “project plan” to resolve according to the organisation’s chosen vocabulary. The interpretation is role-dependent: a delivery roadmap may emphasise dependencies and milestones for a Project Manager, while a product roadmap emphasises outcomes and prioritisation.

\n

The organisation should keep equivalence and relationship separate. A synonym maps a surface form to a concept. A relationship links distinct concepts. “Risk log” may be an agreed synonym for “risk register”, but a register and an individual risk remain distinct concepts. “Risk” and “deployment permission” must not become equivalent merely because they occur together in operational documents.

\n

Graph embeddings make the retrieval context reproducible. A result can identify the recognised concept and supporting relationship evidence, explaining why a planning template or dependency policy was selected. Template currency, the truth of retrieved claims and action authority require separate checks against authoritative metadata, evidence and policy.

\n

From co-occurrence to typed organisational relationships

\n

The existing concept vocabulary and the associations found in text play different parts in constructing the role's conceptual space. The role's thesaurus supplies the concepts that can be recognised and the synonyms that resolve to them. Indexing identifies occurrences of those concepts in notes and documents, then constructs connections from the matching text. Retrieval uses that structure to select relevant material. In this path, a connection is discovered between recognised concepts; it does not establish a new concept definition or a new organisational rule.

\n

Sentence-level co-occurrence provides an intuitive starting assumption: concepts mentioned together may be related. The inspected implementation has a broader boundary. The document indexer takes the matching concept sequence from the indexed document and connects adjacent matches without invoking the available sentence-splitting helper. Associations can therefore cross sentence boundaries. A sentence-bounded association rule would require an explicit indexing change; it is not a current guarantee.

\n

Even within one sentence, proximity leaves the relationship unspecified. A note can mention a requirement and a test because the test satisfies it, fails it, or has not yet been performed. The association graph cannot decide which statement holds. The proposed semantic layer must establish the connection's meaning, direction and conditions before admitting it as a typed organisational claim.

\n\n\n\n\n\n
LayerRepresentationWhat it establishes
Role vocabularyCanonical concepts and approved synonymsWhich concept a recognised expression denotes within the role's domain.
Text associationConnections between matched concepts, with document evidenceWhere concepts occur together or in the indexed matching sequence.
Organisational interpretationTyped, contextual propositions governed by role templatesWhether a connection expresses a dependency, responsibility, requirement, evidence claim or other admitted meaning.
Evaluation and executionApplicable criteria, evidence checks and permission decisionsWhether the specific claim is supported and whether the requested action is authorised.
\n

The organisational semantic layer supplies the relationship vocabulary. A role selects an applicable profile of that vocabulary, together with the templates for its work products. A Project Manager's delivery-plan template may admit dependencies between milestones and assignments of responsibility. A Product Manager's feature template may admit derivation from stakeholder needs and links to acceptance criteria. Shared concepts retain their identities across these views; the role determines which governed relationships are relevant, rather than inventing their meanings during each interaction.

\n

The proposed governance rule is that every admitted organisational relationship type SHALL be defined in a versioned, approved template or semantic profile, with traceability to the applicable adopted standards or an explicitly approved organisational extension. The profile records the standard edition and relevant requirement or definition where applicable. Where a standard leaves a modelling choice open, the organisation records its extension and rationale. This preserves standards-based discipline without asserting that industry standards already name every graph predicate used by an organisation. ISO/IEC/IEEE 42010:2022 and ISO/IEC/IEEE 29148:2018 inform the distinctions discussed earlier; the illustrative predicate names here are not standard-prescribed vocabulary.

\n

A relation definition needs more than a label. It identifies the permitted source and target concept types, direction, interpretation, applicable role and work product, and required qualifiers such as environment, time, polarity or evidence state. For example, verifies might connect a verification activity to a requirement, while producedEvidence connects its execution to a result. A planned test and a completed test cannot be substituted merely because both connect to the same requirement.

\n

Consider the sentence: “The Release Manager must approve production deployment after verification.” An association graph can connect the recognised concepts Release Manager, production deployment and verification. In a governed release template, those associations could support the candidate propositions deployment requiresApprovalFrom ReleaseManager and deployment requiresEvidence verificationResult. These describe obligations; they do not record that approval was given or that verification passed. An observed approval requires separate evidence identifying its issuer, subject, decision and applicable version. The runtime must still establish that the issuer and acting agent have the necessary authority.

\n

Typing a connection is therefore a controlled interpretation step. A candidate keeps its source text and concept matches; the role template supplies permissible predicates and structural constraints; a check establishes whether the text and independent evidence support the proposed proposition. An extraction model can propose a type, but a plausible label is not sufficient to admit the claim as organisational knowledge. Ambiguous, unsupported or conflicting propositions remain unresolved. The association evidence is retained so that a reviewer can reconstruct how the candidate arose.

\n

Verification and validation must compare typed propositions and their qualifiers across the input, output and evaluation criteria, using approved mappings where views differ. A test that finds every concept but converts requiresApprovalFrom into approvedBy, or removes a prohibition, has changed the claim. The audit must expose that change. Graph coverage can find omitted concepts; checking typed relationships addresses whether the connections preserve the intended meaning.

\n

Retrieving an approved planning template

\n

The following command is an illustrative invocation using the installed terraphim-grep interface. The paths represent a proposed organisational knowledge layout; they are not supplied sample data or a claim that this particular corpus was executed.

\n
terraphim-grep "delivery plan" \\\n  --role "Project Manager" \\\n  --haystack all \\\n  --paths ./organisation/templates/planning \\\n  --thesaurus ./organisation/roles/project-manager/thesaurus.json \\\n  --search-only -n 8 -C 2 --json
\n

The dedicated thesaurus makes the role’s vocabulary concrete. --search-only keeps this invocation on its search path without LLM synthesis. The implementation can fall back to thesaurus matching when populated graph evidence is absent; a result alone does not demonstrate graph traversal. Search produces candidates; the service then checks each candidate against the authoritative template registry. The chosen template must be approved, applicable to the project type, available to the active role and identified by an immutable revision or content digest. Restricting search paths narrows retrieval; it does not establish an execution sandbox.

\n

This distinction matters when a semantically excellent match is obsolete. The organisation’s semantic layer may help locate it, but the planning service must select an eligible template. If none exists, the service should request a governed template decision rather than manufacture an “approved” template itself.

\n

A graph-based planning checklist

\n

A checklist makes an expected output contract explicit. Terraphim’s published checklist approach places enumerated concepts outside the model and uses the same graph machinery for recognition and retrieval. Graph embeddings for checklists

\n

The current source also supports a paired input/output graph-coverage mode. An illustrative planning checklist, saved as .terraphim/checklists/project_plan.md, is:

\n
# Project plan\n\nmode:: graph-coverage-v1\nchecklist:: scope, dependencies, risk register, acceptance criteria\n\n### risk register\n\nsynonyms:: risk log
\n

Its concepts and aliases must resolve uniquely in the configured role graph; declaring an alias in a checklist does not create the missing graph concept. The checklist is not a substitute for building and governing that graph. A source-level invocation for the inspected implementation is:

\n
terraphim-agent validate \\\n  --role "Project Manager" \\\n  --checklist project_plan \\\n  --input-file brief.md \\\n  --json < plan.md
\n

This --input-file form is supported by the inspected client source, not by the locally installed 1.21.22 command interface. The example is therefore a source-supported integration example, not an installed-binary demonstration.

\n

The paired check requires recognised input concepts and checklist concepts to appear in the output, with supporting stored graph paths. Its report distinguishes pass, fail and indeterminate. A service using it as a gate must inspect that verdict; successful CLI completion alone does not establish a passing checklist.

\n

Concept coverage is one limited checking predicate. A plan can mention “dependencies” while assigning them incorrectly, or include “acceptance criteria” that do not test the promised outcome. The complete planning contract consequently layers structural checks, graph concept coverage and evidence review. The graph checker supplies an inspectable signal within that contract. It does not establish the full semantic compatibility contract, verify every asserted relationship or confer permission to publish or execute the plan. Its lexical negation handling does not constitute general verification of proposition meaning.

\n

Worked example from brief to bounded plan

\n

Consider a project to deliver a customer-facing feature. The Product Manager agent receives an authorised assignment to prepare a feature breakdown. Its graph connects the product outcome to needs, features, value assumptions and acceptance criteria. It produces a versioned breakdown and hands that artefact to the Project Manager service.

\n

The Project Manager agent authenticates under its own scoped assignment. It retrieves candidate planning templates through its role thesaurus, selects an approved revision, and creates a draft connecting the agreed features to milestones, dependencies, owners and risks. It preserves the incoming acceptance criteria and identifies unresolved assumptions.

\n

The service checks the draft’s structure and invokes the graph checklist. A missing recognised requirement produces a failed or indeterminate result that must be resolved before the relevant transition. A passing result is recorded alongside its limitations. Further review establishes whether the proposed dependencies and acceptance evidence are adequate.

\n

When the service requests create_draft on the assigned project’s document store, the gateway evaluates the exact operation, destination and content digest. Assuming the role assignment, template, checks and policy conditions are valid, it permits that write and records its outcome.

\n

Now suppose the agent requests deploy against production. The request fails the role-to-service/action binding and the production policy. Mentioning deployment in the plan, retrieving a release runbook, or passing the planning checklist cannot repair that missing authority. The gateway records a denial before an effect occurs.

\n

The agent may instead hand the approved plan to the release management process. That handoff supplies evidence, not inherited production credentials. A separately authorised release principal must satisfy its own contract. The organisation can therefore automate preparation without collapsing preparation, approval and execution into a single unrestricted agent.

\n

Checking the planning context

\n

Consider an illustrative requirement R-17 revision 3: the plan must specify a staging rollback rehearsal whose planned start is no earlier than the simulated-failure trigger and no later than eight elapsed hours afterwards. The baseline defines that trigger as the rehearsal protocol's injected-failure timestamp. Production deployment is outside the Project Manager's scope. The stakeholder need is to coordinate a usable rehearsal without delegating production execution.

\n

A verification criterion checks the plan's environment, planned start offset and preserved prohibition against that baseline. A validation scenario asks the delivery and release stakeholders whether the proposed handoff enables the intended rehearsal with the available people and resources. The plan's check does not prove that a rehearsal occurred. Later testing of the delivered system requires its own evidence; a good plan does not establish successful system behaviour.

\n\n\n\n\n\n\n
Candidate interpretation or evidenceRequired treatment under the proposed contract
“One business day” replaces eight elapsed hoursNo silent equivalence. Resolve the calendar and conversion; fail if the interval changes, otherwise retain the approved mapping.
The plan schedules the rehearsal in productionFail the known environment mismatch; separately deny unauthorised production actions.
The evaluator uses revision 2's 24-hour thresholdReject the stale criterion binding and reassess against revision 3.
“Must not deploy” becomes “may deploy”Fail proposition preservation despite matching deployment concepts.
Relevant calendar or requirement revision is unknownReturn indeterminate until the baseline is resolved.
\n

The same protection applies when views use different language. “Pre-production” can map to the named staging environment if the organisation explicitly defines that equivalence. Matching the spelling “staging” in an unrelated project's evidence cannot establish that the requirement was met.

\n

Terraph audit with one role and one checklist

\n

This Terraph example connects a role graph, a checklist and three verbs: audit, check and deploy. Here, engineer is the example role; it does not change the Project Manager’s authority. The graph and checklist are Markdown inputs compiled into constant matching automata. embed and satisfies are language intrinsics, so retrieval and checking use the same concept definitions.

\n
import std;\n\nrole engineer from "kg";\nchecklist preflight from "checklists/preflight.md";\n\n// Audit concept coverage and report the matching source spans.\nfn audit(path: str) -> i64 {\n    let src = read_file(path);\n    if src.len == 0 {\n        print("cannot read ", path);\n        return 1;\n    }\n    let h = embed(src);\n    let cov = coverage(h);\n    print("file: ", path);\n    print("kg_hits: ", cov.kg_hits, "  concepts: ", cov.concepts,\n          "  confidence: ", cov.confidence, "  diversity: ", cov.diversity);\n    for m in h {\n        print("  ", m.concept, " @", m.start, "..", m.end);\n    }\n    if cov.sufficient() {\n        print("sufficient: yes");\n        return 0;\n    }\n    print("sufficient: no");\n    return 1;\n}\n\n// Diagnose missing checklist items. This verb does not issue a proof.\nfn check(text: str) -> i64 {\n    let miss = text satisfies preflight;\n    if miss.any() {\n        print("checklist preflight: incomplete");\n        miss.report();\n        return 4;\n    }\n    print("checklist preflight: complete");\n    return 0;\n}\n\n// The generated wrapper supplies a sealed proof for the checked snapshot.\nfn deploy(plan: str, ev: Proof<preflight>) -> i64 {\n    print("deploy: preflight evidence present, proceeding");\n    return 0;\n}
\n

audit exposes which concepts matched and where. check reports missing checklist items. At the gated entry point, the generated verb wrapper obtains a sealed Proof<preflight> through .require(), which succeeds only when no items are missing. The function signature makes that evidence a prerequisite for entering deploy.

\n

The proof carries the checked snapshot as ev.subject. Any operation justified by the gate must consume that snapshot; reopening the path in plan could read changed, unchecked bytes. The sample body only prints a message. Actual deployment still requires an authorised role assignment and resource policy, and concept coverage alone does not establish that the plan is correct. The example shows the language boundary; it is not a recorded deployment.

\n

ADF configuration gives the role an organisational task

\n

The ADF agent orchestration configurations assign organisational responsibilities. The checked-in Product Owner template names an implementation and declares these fields. Product Owner is the configured role; it is distinct from the illustrative Product Manager role used earlier:

\n
[[agents]]\nname = "product-owner"\npersona = "Themis"\ncapabilities = [\n    "planning",\n    "roadmap",\n    "issue-creation",\n    "prioritisation",\n]\nproject = "terraphim"
\n

Its skill chain includes research, design, specification, architecture, business scenario design, requirements traceability and acceptance testing. The task defines the work product: each proposed issue must identify its organisational goal, describe the problem and proposed solution, and supply Given–When–Then acceptance criteria. The template also requires a priority estimate, a communication hint and the suggested delivery agent. The workflow narrows the backlog, scores the surviving items and proposes up to two new issues.

\n

These selected literal fields show the existing issue template. Its brackets indicate fields the Product Owner must fill; WIG means the organisation’s current Wildly Important Goal.

\n
Title: [concise, imperative]\nWIG: [which WIG this serves, or skip if none]\nProblem: [2-3 sentences describing the problem]\nProposed solution: [bullet points, no hand-waving]\nAcceptance criteria (mini-UAT):\n  Given [precondition]\n  When [action]\n  Then [observable outcome]
\n

The configuration connects the Product Owner’s planning capability to a defined work product and template. It records operational intent; this inspection does not establish that the agent is deployed or that every configured step succeeds.

\n

The repo-local ADF configuration separately declares a Developer, Reviewer and Merge Coordinator, with distinct capability lists and named Terraphim roles:

\n\n\n\n\n
Configured agentDeclared Terraphim roleResponsibility expressed in the configuration
developerTerraphim AI DeveloperImplementation, Rust development and test-driven development
reviewerTerraphim AI ReviewerCode review, quality gates and review coordination
merge-coordinatorTerraphim AI Merge CoordinatorMerge coordination, CI/CD and conflict resolution
\n

The orchestrator’s merge path checks four required status contexts: native-ci / build (push), adf/pr-reviewer, adf/validation and adf/verification. It also requires canonical gate-result records for the current pull request head. Blocking findings and the project's treatment of concerns affect the decision. Evidence for an older commit cannot substitute for the current head’s review, binding the decision to that part of its context baseline. The labels adf/validation and adf/verification do not establish that their producers perform the corresponding ISO requirements or system activities.

\n

Configuration intent and runtime enforcement must remain distinguishable. The inspected repo-local loader sets terraphim_role to None; the declaration alone does not prove that an agent receives the named role graph. Instructions such as “do not merge” are task text, and the Product Owner’s broad shell access is not a production-deployment barrier. The merge gate controls the orchestrator’s merge path; it does not prove that every alternative credential or tool path is mediated. Its structured records are not independently authenticated merely by having the expected fields.

\n

ADF declares responsibility, capabilities, workflow and expected artefacts. Terraph implements bounded tool access, checks and receipts; Terraphim provides the role vocabulary and graph context. Connecting them still requires authenticated role assignments, capability-to-service identifiers, approved artefact versions and policy decisions tied to exact requests.

\n

W3C PROV provides terms for recording entities, activities and agents, including derivation, association and delegated responsibility. These relationships can describe an artefact’s origin and an agent’s participation; a provenance statement alone is not an authorisation decision. W3C PROV-O

\n

Evaluation and implementation boundaries

\n

The proposal can be evaluated without assuming that more graph coverage means safer behaviour. A test corpus should pair legitimate planning tasks with boundary cases and preserve the same role assignments and policy across agent implementations.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n
TestExpected observable result
Valid plan from an approved templateDraft created in the assigned project with complete evidence links
Semantically relevant but withdrawn templateCandidate rejected by template eligibility policy
Required concept omittedGraph report identifies a fail or indeterminate result; gated transition does not proceed
All terms present but a dependency is wrongConcept coverage may pass; substantive review detects the error
Project Manager requests production deploymentDenied before any deployment effect
Deployment attempted through an alternative toolSame authority boundary enforced
Artefact changes after checkingPrevious evidence rejected for the changed request or bytes
Role assignment expires before executionGateway denies or requires a fresh valid assignment
Agent implementation is replacedService contract and authority boundaries remain unchanged
Concepts match but polarity, environment or units differRelevant semantic predicate fails, or unresolved meaning is indeterminate
A role projection drops a critical obligationTrace check rejects the transformation or requires an approved change
Different role views have an approved meaning-preserving mappingCompatibility can be established; substantive criteria still require evidence
\n

Measurements should include accepted legitimate tasks, incorrect denials, unauthorised effects, trace completeness and the cost of reconstructing a decision. Report semantic-check accuracy separately from policy enforcement. A test that finds no bypass in a bounded suite is evidence about that suite, not proof that all possible tool paths are mediated.

\n

Terraphim already supplies relevant semantic components, and Terraph supplies concrete prototype mechanisms for compiled checks and evidence. ADF provides configured organisational responsibilities and an implemented orchestrator merge gate. The end-to-end organisational contract, contextual requirement-to-criterion alignment, authenticated role binding, complete execution mediation and linked audit schema remain the integration proposed in this paper. No production deployment result or benchmark is claimed here.

\n

Role owners must maintain concepts, templates and policies, and reviewers must understand what each checklist establishes. Graph updates need controlled promotion because a vocabulary change can alter which obligations appear satisfied. Audit records should retain enough versioned evidence to reconstruct decisions while limiting sensitive content.

\n

Conclusion

\n

An agent’s organisational role provides a durable basis for knowledge, responsibility and delegated authority. Capabilities explain the outcomes the role must support; services describe how an agent implementation supplies them; tools expose actions; contextual policy determines which actions may occur. A role-based knowledge graph makes the concepts and relationships behind the work inspectable. Meaningful verification and validation also require those concepts, their propositions and the operating context to align with the applicable criteria through explicit, traceable mappings. A shared vocabulary alone cannot preserve an obligation.

\n

Terraphim supplies explicit concept matching, co-occurrence associations, graph retrieval and graph-based checklists. The proposed next layer types those associations using governed role templates and standards-traceable relationship definitions, distinguishing a mention from an obligation and an obligation from an evidenced event. Terraph illustrates how compiled checks can produce evidence tied to the subject being checked. Connecting these mechanisms to authenticated role assignments and mediated execution yields a traceable organisational contract.

\n

For a Project Manager agent, the contract requires an approved planning template, preserved requirements, a checked plan and operation within the assigned project scope. Production deployment belongs to a separately authorised role and process. The evidence must allow a reviewer to reconstruct both the planning result and the authority decision.

\n

Sources and scope

\n

Public sources are linked beside the claims they support. The preceding article by David Hunt and Alexander Mikhalev was published on 31 October 2026 and read on 4 November. The continuation and concept mapping are this paper's synthesis.

\n

Terraphim and ADF implementation details were checked against local source on 3–4 November 2026. The Terraph example above was supplied by Alexander Mikhalev; its comments have been shortened and its function bodies retained. Source revisions, implementation paths, recorded fixture results and inspection limits remain in the internal research notes.

\n

The standards cross-check used official catalogue records and accessible previews. The complete normative text of ISO/IEC/IEEE 42010:2022 was not inspected, so no clause-by-clause conformity claim is made. The role contracts, typed relationship profiles, contextual criteria and cross-system bindings are proposed integration work. The examples do not demonstrate a live production deployment.

\n", "https://reference-architecture.ai/properties/date": "2026-11-07", "https://atomicdata.dev/properties/tags": {"categories":["Architecture"],"tags":["ai-agents","governance","knowledge-graphs","terraphim","verification"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/posts/from-ai-risk-to-accountable-agents/", "https://atomicdata.dev/properties/name": "From AI Risk to Accountable Agents", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/posts/from-ai-risk-to-accountable-agents/", "https://atomicdata.dev/properties/description": "

In AI Risk is evolving, every day., David Hunt and I examined how an AI agent can pursue a legitimate objective through methods outside its mandate. Oversight needs to connect organisational intent, knowledge, authority, actions and consequences.

\n

\n

This article summarises the full paper. To supervise that agent, we need to specify its responsibilities, the concepts it uses, the evidence its work requires and the actions it may take.

\n

Start with an organisational role

\n

“Planning agent” tells us what an agent does, but leaves its responsibility unclear.

\n

A Product Manager breaks outcomes into features and acceptance criteria. A Project Manager turns agreed scope into a delivery plan with dependencies, owners and milestones. Both perform planning, but their work products and authority differ.

\n

An agent's planning capability should belong to a defined organisational role. Its implementation provides services that use tools to perform specific actions.

\n

The chain becomes:

\n

Organisation → role → capability → service → tool → action → contextual permission.

\n

A Project Manager agent might select an approved planning template and create a draft in its assigned project. That assignment does not authorise production deployment. The permission decision must govern the actual tool operation, including alternative routes through shells or delegated agents.

\n

Give the role a defined conceptual space

\n

Each role needs a governed view of organisational knowledge. A Product Manager works with user needs, value hypotheses and acceptance criteria. A Project Manager needs dependencies, resources, risks and delivery commitments. Shared concepts connect their work without making the roles interchangeable.

\n

\"Role-based

\n

Figure 1. Proposed role contract: the knowledge needed to plan and the authority to act are explicit.

\n

Terraphim's role-based knowledge graphs make this vocabulary explicit through concepts and synonyms. The inspected indexer connects consecutive recognised concepts in document text, retaining supporting document references. Those associations help retrieve relevant notes and explain why they were selected.

\n

The next layer is to type the relationships. A connection might mean “depends on”, “addresses a requirement” or “requires approval”. The role selects the applicable relationship profile from approved templates, traced to adopted standards or documented organisational extensions.

\n

A sentence mentioning a release, a manager and approval does not establish that approval occurred. “Requires approval” and “was approved” are different claims.

\n

Verify meaning in its context

\n

A checklist can recognise every expected concept while missing a change in meaning.

\n

Suppose a delivery plan must place a rollback rehearsal in staging, with its planned start within eight elapsed hours of a defined failure trigger. An output can contain “rollback”, “rehearsal” and “hours” while moving the activity to production or replacing elapsed hours with business days.

\n

Successful checking therefore requires compatible concepts, relationships and context across the input, output and criteria. Different terminology can be acceptable through an explicit mapping. Changed scope, units, conditions or prohibitions cannot pass silently.

\n

Our paper uses ISO/IEC/IEEE 42010:2022 to frame architecture descriptions and ISO/IEC/IEEE 29148:2018 to distinguish requirements quality and stakeholder intent from evidence about the realised system. This is a standards-informed design, not a conformity claim.

\n

The practical requirement is traceability: identify the requirement version, relevant context, applicable criterion and evidence behind each result. When those conditions change, reassess the affected findings. Unknown context should produce an indeterminate result, not an assumed pass.

\n

\"Contextual

\n

Figure 2. Proposed contextual check: passing a planning criterion neither proves the rehearsal occurred nor grants deployment authority.

\n

Make the audit concrete

\n

Terraph, the Terraphim language, connects a role graph, a checklist and a gated action in one program. The graph and checklist compile from Markdown into constant matching automata. embed identifies concepts and source spans; text satisfies preflight reports which checklist items are missing.

\n

The deploy verb declares the evidence it needs. Here, engineer is the example role; it does not change the Project Manager’s authority:

\n
import std;\n\nrole engineer from "kg";\nchecklist preflight from "checklists/preflight.md";\n\nfn deploy(plan: str, ev: Proof<preflight>) -> i64 {\n    print("deploy: preflight evidence present, proceeding");\n    return 0;\n}
\n

The generated verb wrapper obtains a sealed Proof<preflight> through .require() only when no checklist items are missing. The proof binds to the checked snapshot, available as ev.subject.

\n

\"Terraph

\n

Figure 3. The Terraph proof gate. The example body prints a message; it does not deploy a system.

\n

Any actual operation must use that checked snapshot and pass a separate authority check. Reopening the plan could read changed bytes. Passing the checklist cannot give a Project Manager production privileges, nor can concept coverage establish that the plan is correct.

\n

Our earlier argument calls for supervision that follows an agent's changing context. An inspectable role contract gives that supervision a defined mandate to check. A Project Manager agent can prepare a plan, preserve its requirements and record the evidence, while release authority stays with the role responsible for exercising it.

\n", "https://reference-architecture.ai/properties/date": "2026-11-07", "https://atomicdata.dev/properties/tags": {"categories":["Architecture"],"tags":["ai-agents","governance","knowledge-graphs","terraphim","verification"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/posts/terraphim-engine-architecture/", "https://atomicdata.dev/properties/name": "The Terraphim Engine: Six Layers, Fifty-Two Crates", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/posts/terraphim-engine-architecture/", "https://atomicdata.dev/properties/description": "

The diagram on the front page of this site is not an illustration. Every box in it is a\npublished Rust crate you can cargo add today, read the documentation for, and use\nwithout taking the rest of the system. This article explains what sits behind each box,\nand why the decomposition is the interesting part.

\n

\n

Why decomposition is the architecture

\n

Most agent frameworks ship as a single dependency. You take the orchestrator, the memory\nlayer, the retrieval stack and the tool protocol together, or you take none of it. That\nis convenient at first and expensive later: when one layer misbehaves you cannot isolate\nit, and when you want to replace one you replace all of them.

\n

The pattern this site argues for is the opposite. Draw the boundaries first, make each\none independently useful, and let the seams stay visible. Terraphim is built that way —\n52 crates across six layers, each with a single responsibility — which makes it a\nreasonable worked example rather than a product pitch.

\n

The test of a boundary is whether you can use one side without the other. Here you can:\nterraphim_automata is a text-matching engine that happens to be used by a knowledge\ngraph; terraphim_persistence is a storage abstraction that does not know what it is\nstoring.

\n

The six layers

\n

Terraphim organises its crates into a dependency graph with six levels. Lower layers do\nnot know the higher ones exist.

\n\n\n\n\n\n\n\n
LayerConcernRepresentative crates
6User interfacesterraphim_agent, terraphim-cli, terraphim_server
5Orchestrationterraphim_orchestrator, terraphim_kg_orchestration, terraphim_symphony
4Agent systemterraphim_spawner, terraphim_router, terraphim_agent_supervisor
3Service layerterraphim_service, terraphim_middleware, haystack_*
2Core engineterraphim_automata, terraphim_rolegraph, terraphim_persistence
1Types and configurationterraphim_types, terraphim_config, terraphim_settings
\n

That ordering matters more than the crate count. An agent system that cannot say which\nlayer a failure came from is a system you cannot debug in production.

\n

Layer 1: types and configuration

\n

terraphim_types is the shared vocabulary — the structures every other crate agrees on.\nterraphim_config holds role definitions, haystacks and LLM routing;\nterraphim_settings handles runtime preferences.

\n

Putting roles in configuration rather than code is what makes the context boundary\nstructural. A role has access to certain haystacks; the knowledge graph is built from\nthose haystacks; therefore the agent cannot reach information outside its role. That is\nnot a permission check at runtime that could be bypassed — it is an absence. The data\nwas never loaded.

\n

Layer 2: the core engine

\n

This is the layer the front-page diagram mostly depicts.

\n

terraphim_automata is the matching engine:\nAho-Corasick finite state automata that match thousands of patterns simultaneously in\nO(n) time, where n is the length of the text. Not \"usually fast\" — bounded, and the same\nbound every time. It compiles to WebAssembly, which is why the same matcher runs in a\nbrowser as on a server.

\n

terraphim_rolegraph is the knowledge graph.\nIt is deliberately not a general-purpose graph database. It maps search roles to\ndomain-specific graph views, and it exists to do one thing quickly: turn text into\nconcepts, deterministically. Terraphim reports knowledge-graph inference in the 5-10\nnanosecond range and a 15 MB memory footprint, with no GPU — figures worth checking\nagainst your own workload, but the shape of the claim follows from the design rather\nthan from optimisation tricks.

\n

terraphim_persistence provides the\nPersistable trait and DeviceStorage backends across memory, SQLite and redb. Storage is\nan interface here, not an assumption, which is what lets the same engine run on a laptop\nand at the edge.

\n

Layer 3: the service layer

\n

terraphim_middleware searches haystacks —\npluggable data-source backends. This is the boundary the front-page diagram labels\nDocument Input. A haystack might be a local folder, a repository, or a connector to\nsomething else; the layers above do not change when you add one.

\n

terraphim_service handles requests and responses\nfor the core, which keeps request handling out of the engine itself.

\n

Layers 4 and 5: agents and orchestration

\n

Above the service layer sit the agent system (terraphim_spawner, terraphim_router,\nterraphim_agent_supervisor) and orchestration (terraphim_orchestrator,\nterraphim_kg_orchestration, terraphim_symphony).

\n

The distinction is worth holding onto. The agent system is concerned with individual\nagents — spawning them, routing to them, supervising them. Orchestration is concerned\nwith what happens between them. Collapsing those two into one \"agent framework\" is the\nusual mistake, and it is why so many systems cannot tell a stuck agent from a stuck\nworkflow.

\n

The MCP-Native Agent Architecture goes\ninto the protocol surface these layers expose, and why treating MCP as an architectural\nprimitive rather than a transport changes what the system can guarantee.

\n

Layer 6: the interfaces

\n

terraphim_agent is the interactive REPL with session\nsearch and learning capture. terraphim-cli is the\nautomation-shaped counterpart, with JSON output for scripting.\nterraphim_server provides the REST API.

\n

Three interfaces over one engine, none of them privileged. That is the payoff of the\nlayering: the CLI is not a thin wrapper around the server, and the server is not a\nspecial case. They are peers over the same core.

\n

What to take from this

\n

You do not need to adopt Terraphim to use the pattern. The transferable parts are:

\n\n

Documentation

\n

Every crate named above is published and documented:

\n\n

Installation is a single command, or cargo install terraphim_agent if you would prefer\nto start from the REPL.

\n", "https://reference-architecture.ai/properties/date": "2026-09-08", "https://atomicdata.dev/properties/tags": {"categories":["Architecture"],"tags":["terraphim","rust","knowledge-graphs","agents","reference-architecture"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/posts/mcp-native-agent-architecture/", "https://atomicdata.dev/properties/name": "The MCP-Native Agent Architecture", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/posts/mcp-native-agent-architecture/", "https://atomicdata.dev/properties/description": "

A reference architecture for production AI systems, drawn from five years building Terraphim — a privacy-first AI assistant with ~50 Rust crates, MCP-native interfaces, and role-based multi-agent orchestration.

\n

The Production Agent Crisis

\n

In the spring of 2024, I watched a well-funded AI startup burn through $180,000 in cloud credits in six weeks. Their crime? They let an LLM-powered agent manage their Kubernetes cluster. The agent had root access, a vague prompt (\"optimize resource utilization\"), and no guardrails. It deleted a production namespace, scaled a stateful set to zero, and triggered a cascading failure that took down their primary revenue pipeline for four hours.

\n

The post-mortem was illuminating. The LLM wasn't \"malicious.\" It was doing exactly what LLMs do: generating plausible-sounding text based on pattern matching. The prompt \"optimize resource utilization\" is semantically close to \"remove unused resources.\" The agent found a namespace with low CPU utilization and removed it. Logical, if you squint. Catastrophic, if you're the on-call engineer.

\n

This is the production agent crisis in miniature: we've given probabilistic systems deterministic powers without deterministic boundaries.

\n

The current generation of agent frameworks — LangChain, CrewAI, AutoGPT, and their descendants — share a common architectural flaw: they treat the LLM as both the decision-maker AND the execution engine. The LLM decides what to do, how to do it, and when to stop. This is fine for demos. It's a liability for production.

\n

Consider what production systems actually require:

\n\n

None of these are properties of LLMs. LLMs are probabilistic text generators. They hallucinate. They drift. They respond to temperature. They have no concept of \"side effects\" or \"resource limits\" or \"this action is irreversible.\"

\n

The solution is architectural, not algorithmic. We need a boundary layer between the probabilistic decision-maker (the LLM) and the deterministic execution environment (the system). That boundary layer is the Model Context Protocol (MCP), and treating it as an architectural primitive rather than a communication protocol changes everything.

\n

MCP as Architectural Primitive

\n

MCP was introduced by Anthropic in late 2024 as a standardized protocol for connecting AI assistants to external data sources and tools. At its simplest, it defines how an AI client discovers capabilities, requests context, and invokes tools from a server.

\n

But MCP is more than a wire format. It is a contract layer that enforces capability boundaries. And when you treat it as an architectural primitive — a fundamental building block of your system, not just a communication detail — you get something powerful: the ability to build deterministic agent systems on top of probabilistic reasoning engines.

\n

The Protocol Surface

\n

An MCP server exposes three things:

\n
    \n
  1. Resources: Read-only data sources (files, databases, API responses)
  2. \n
  3. Tools: Functions the client can invoke, with defined schemas and side effects
  4. \n
  5. Prompts: Pre-defined templates for common interactions
  6. \n
\n

The key insight: the server defines WHAT is possible. The LLM decides WHICH possibility to pursue. The protocol enforces the boundary between them.

\n

Terraphim's MCP server (terraphim_mcp_server) implements this boundary in ~200 lines of Rust. It exposes three tools: search (read-only, queries the knowledge graph), build_autocomplete_index (idempotent, rebuilds the Aho-Corasick automata), and update_config (destructive, modifies runtime configuration). Each tool has a schema. Each tool has a known effect. The LLM cannot invoke a tool it hasn't discovered, and it cannot pass arguments that don't match the schema.

\n

This is the difference between \"I hope the LLM doesn't delete something\" and \"the system is physically incapable of deleting something without authorization.\"

\n

The Four-Layer Reference Architecture

\n

\"Four-Layer\nThe MCP-native agent stack: four layers with the LLM as a probabilistic reasoning engine, bounded by deterministic architectural layers.

\n

Based on production experience building Terraphim — a privacy-first AI assistant with ~50 Rust crates, MCP server integration, and multi-agent orchestration — I've distilled the following reference architecture. It separates concerns that current frameworks conflate and introduces verification at every boundary.

\n

Layer 1: Role & Configuration

\n

What the agent IS.

\n

In Terraphim, everything starts with a Role. A Role is not a prompt. It is a structured configuration that defines an agent's identity, knowledge sources, capabilities, and constraints. Think of it as a compile-time contract for an agent's behavior.

\n
// From terraphim_config — the actual Role struct\n#[derive(Debug, Serialize, Deserialize, Clone)]\npub struct Role {\n    pub name: RoleName,\n    pub relevance_function: RelevanceFunction,  // BM25, TitleScorer, etc.\n    pub haystacks: Vec<Haystack>,               // Data sources\n    pub kg: Option<KnowledgeGraph>,             // Linked knowledge graph\n    pub llm_enabled: bool,\n    pub llm_model: Option<String>,              // e.g., "gemma3:270m"\n    pub llm_router_enabled: bool,               // 6-phase intelligent routing\n    pub extra: AHashMap<String, Value>,         // Extensible config\n}
\n

Key properties:

\n\n

The Role is the \"type system\" of your agent. Just as Rust's borrow checker prevents data races at compile time, the Role configuration prevents capability leakage at configuration time.

\n

Layer 2: Knowledge Graph

\n

What the agent KNOWS.

\n

Terraphim's knowledge graph (terraphim_rolegraph) is not a general-purpose graph database. It is a specialized structure optimized for one thing: fast, deterministic text-to-concept matching using Aho-Corasick automata.

\n
// From terraphim_rolegraph — the actual RoleGraph\npub struct RoleGraph {\n    pub role: RoleName,\n    nodes: AHashMap<u64, Node>,\n    edges: AHashMap<u64, Edge>,\n    documents: AHashMap<String, IndexedDocument>,\n    pub thesaurus: Thesaurus,\n    pub ac: AhoCorasick,                    // Compiled automata\n    pub ac_reverse_nterm: AHashMap<u64, NormalizedTermValue>,\n}\n\nimpl RoleGraph {\n    pub fn find_matching_node_ids(&self, text: &str) -> Vec<u64> {\n        self.ac.find_iter(text)\n            .map(|mat| self.aho_corasick_values[mat.pattern()])\n            .collect()\n    }\n}
\n

Key properties:

\n\n

The Context Boundary emerges naturally from the Role configuration: if a Role only has access to certain haystacks, and the RoleGraph is built from those haystacks, the agent cannot access information outside its Role. This is not a runtime permission check. It is a structural impossibility.

\n

Layer 3: Multi-Agent Orchestration

\n

What the agent DOES with others.

\n

Terraphim's multi-agent system (terraphim_multi_agent) treats each Role as an autonomous agent. Agents discover each other through capability registration, communicate through structured messages, and coordinate through workflow patterns.

\n
// From terraphim_multi_agent — the actual AgentRegistry\npub struct AgentRegistry {\n    agents: Arc<RwLock<HashMap<AgentId, Arc<TerraphimAgent>>>>,\n    capabilities: Arc<RwLock<HashMap<String, Vec<AgentId>>>>,\n    role_agents: Arc<RwLock<HashMap<String, AgentId>>>,\n    agent_load: Arc<RwLock<HashMap<AgentId, LoadMetrics>>>,\n}\n\nimpl AgentRegistry {\n    pub async fn find_agents_by_capability(&self, capability: &str) -> Vec<AgentId> {\n        let capabilities = self.capabilities.read().await;\n        capabilities.get(capability).cloned().unwrap_or_default()\n    }\n}
\n

Key properties:

\n\n

The Execution Harness is not a Wasm sandbox (though we have WASM support in terraphim_automata for browser contexts). It is the agent's own TerraphimAgent struct, which enforces resource limits through Rust's type system: token budgets are usize, timeouts are Duration, and context windows are bounded by configuration.

\n

Layer 4: MCP Protocol Surface

\n

How the agent COMMUNICATES.

\n

The terraphim_mcp_server crate exposes Terraphim's capabilities through the Model Context Protocol. It acts as both server (exposing Terraphim tools to external clients) and client (discovering external tools for Terraphim agents).

\n
// From terraphim_mcp_server — the actual McpService\n#[derive(Clone)]\npub struct McpService {\n    config_state: Arc<ConfigState>,\n    resource_mapper: Arc<TerraphimResourceMapper>,\n    autocomplete_index: Arc<tokio::sync::RwLock<Option<AutocompleteIndex>>>,\n}\n\nimpl McpService {\n    pub async fn search(\n        &self,\n        query: String,\n        role: Option<String>,\n        limit: Option<i32>,\n    ) -> Result<CallToolResult, ErrorData> {\n        // 1. Resolve role (tenant boundary)\n        let role_name = if let Some(role_str) = role {\n            RoleName::from(role_str)\n        } else {\n            self.config_state.get_selected_role().await\n        };\n\n        // 2. Query knowledge graph within role boundary\n        let search_query = SearchQuery {\n            search_term: NormalizedTermValue::from(query),\n            role: Some(role_name),\n            limit: limit.map(|l| l as usize),\n            ..Default::default()\n        };\n\n        // 3. Return structured results\n        match service.search(&search_query).await {\n            Ok(documents) => { /* ... */ }\n            Err(e) => { /* ... */ }\n        }\n    }\n}
\n

Key properties:

\n\n

Why Rust?

\n

The reference architecture is implemented in Rust. This is not aesthetic preference. It is an engineering requirement.

\n

Zero-cost abstractions: The Role configuration, knowledge graph, and agent registry introduce no runtime overhead. The type system enforces safety at compile time.

\n

Deterministic resource usage: No garbage collection pauses. Memory is explicitly managed. The terraphim_automata Aho-Corasick matcher runs in bounded time and space.

\n

Fearless concurrency: The AgentRegistry is accessed by multiple agents simultaneously. Rust's Arc<RwLock<_>> prevents data races without runtime overhead.

\n

WASM portability: terraphim_types and terraphim_automata compile to WebAssembly, enabling browser-based autocomplete with TypeScript bindings.

\n

Production Patterns

\n

\"Traditional\nTraditional agents conflate decision and execution. MCP-native agents enforce a hard boundary: the LLM decides, the architecture executes.

\n

Pattern 1: Multi-Tenant Agent Isolation

\n

In Terraphim, multiple users share the same agent infrastructure but have completely isolated contexts:

\n
// Each tenant gets their own Role configuration\nlet tenant_role = Role::new("tenant_acme")\n    .with_haystacks(vec![acme_documents, acme_wiki])\n    .with_llm_model("gemma3:270m")\n    .with_relevance_function(RelevanceFunction::BM25);\n\n// The RoleGraph is built ONLY from tenant's haystacks\nlet role_graph = RoleGraph::new("tenant_acme".into(), tenant_thesaurus).await?;\n\n// MCP search automatically scopes to tenant's role\nlet results = mcp_service.search(query, Some("tenant_acme".to_string()), None).await?;
\n

Key insight: The boundary is per-tenant, but the automata engine and MCP server are shared. This gives you multi-tenant isolation without multi-tenant cost.

\n

Pattern 2: Deterministic Replay

\n

When a bug occurs in production, you need to reproduce it exactly. With probabilistic agents, this is nearly impossible. With MCP-native architecture, it's trivial:

\n

\"Deterministic\nRecording LLM responses (not regenerating them) makes replay deterministic. The same inputs produce the same execution trace.

\n
// The RoleGraph + automata are deterministic\n// Same query + same thesaurus → same matches, every time\nlet matches = role_graph.find_matching_node_ids("rust programming");\n// Always returns the same node IDs for the same input\n\n// For LLM variability: record responses, don't regenerate\nlet recorded_response = load_recording(task_id)?;\nlet plan = agent.generate_plan_with_response(context, recorded_response)?;
\n

Key insight: The knowledge graph is deterministic. The LLM is not. Separate the two, and replay becomes deterministic where it matters.

\n

Pattern 3: Human-in-the-Loop for Destructive Operations

\n

\"Approval\nDestructive operations require explicit approval. The system logs every request but does not execute without authorization.

\n
// terraphim_mcp_server's update_config tool is inherently bounded\npub async fn update_config_tool(&self, config_str: String) -> Result<CallToolResult, ErrorData> {\n    match serde_json::from_str::<Config>(&config_str) {\n        Ok(new_config) => {\n            // Config validation happens BEFORE mutation\n            self.validate_config(&new_config)?;\n            self.update_config(new_config).await?;\n            Ok(CallToolResult::success(vec![Content::text(\n                "Configuration updated".to_string()\n            )]))\n        }\n        Err(e) => {\n            Ok(CallToolResult::error(vec![Content::text(\n                format!("Invalid configuration: {}", e)\n            )]))\n        }\n    }\n}
\n

Key insight: The MCP schema IS the approval gate. The LLM cannot construct a valid Config JSON without knowing the schema, and invalid configs are rejected before mutation.

\n

Integration with Terraphim

\n

\"Terraphim\nTerraphim instances share an MCP protocol layer while maintaining isolated Role configurations and Knowledge Graphs. Each agent discovers tools through MCP without data leakage.

\n

Terraphim implements this architecture across ~50 Rust crates. Here's how the layers map to real code:

\n\n\n\n\n\n\n\n\n
LayerCrateResponsibility
Role & Configterraphim_configRole definitions, haystacks, LLM routing
Knowledge Graphterraphim_rolegraphAho-Corasick automata, concept matching
Fast Matchingterraphim_automataFST autocomplete, link generation, WASM
Multi-Agentterraphim_multi_agentAgent registry, capability discovery, workflows
MCP Serverterraphim_mcp_serverProtocol surface, schema enforcement
Capabilitiesterraphim_agent_registryCapability matching, score-based discovery
Persistenceterraphim_persistenceDeviceStorage, memory/file backends
\n

The MCP integration is bidirectional. Terraphim acts as an MCP server (exposing search and config tools to external clients) and can discover external MCP servers for additional capabilities. This enables multi-agent orchestration where each agent has its own Role and Knowledge Graph, but they can discover and invoke each other's tools through MCP.

\n

The Determinism Guarantee

\n

Let's be precise about what this architecture guarantees and what it doesn't.

\n

What IS guaranteed:

\n\n

What is NOT guaranteed:

\n\n

The key insight: We don't need the LLM to be deterministic. We need the KNOWLEDGE GRAPH and the PROTOCOL BOUNDARY to be deterministic. The LLM provides variable intelligence within fixed architectural bounds. The bounds are what matter for production.

\n

When This Architecture Is Overkill

\n

Not every AI system needs four layers of deterministic boundaries. Here's when you DON'T need MCP-native architecture:

\n\n

Add MCP-native boundaries when:

\n\n

Implementation Checklist

\n

Building MCP-native agents?

\n\n

Conclusion: The Protocol Is the Architecture

\n

The current generation of agent frameworks treats LLMs as the center of the universe. The LLM decides everything, and the framework provides convenient wrappers around API calls.

\n

This is backwards.

\n

The protocol is the architecture. The LLM is just one implementation detail.

\n

A production agent system needs:

\n\n

MCP provides the protocol surface. The reference architecture provides the safety properties. Rust provides the implementation guarantees.

\n

The LLM? It's just the reasoning engine. Powerful, probabilistic, and properly contained.

\n
\n

Reference Implementation

\n

The architecture described in this article is implemented in Terraphim, an open-source privacy-first AI assistant:

\n\n

Contributions welcome. Issues tracked in the Terraphim Gitea.

\n
\n

Alexander Mikhalev is CTO & Head of AI at Zestic AI, where he architects AI-native platforms with deterministic safety guarantees. He is the creator of Terraphim, an open-source privacy-first AI assistant built in Rust. His project \"The Pattern\" won the $10,000 Platinum Prize at the Redis \"Build on Redis\" Hackathon 2021 for ML-powered knowledge discovery. He previously led AI/ML architecture at Nationwide Building Society, where he co-authored the organization's first technology patent — a blockchain-inspired distributed system for resilient consensus. He speaks on AI architecture, Rust, and knowledge graphs.

\n", "https://reference-architecture.ai/properties/date": "2026-09-07", "https://atomicdata.dev/properties/tags": {"categories":["Architecture"],"tags":["mcp","agents","rust","knowledge-graphs","production","terraphim"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/posts/harness-engineering-agents/", "https://atomicdata.dev/properties/name": "Harness Engineering for Self-Improving Agents", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/posts/harness-engineering-agents/", "https://atomicdata.dev/properties/description": "

Many AI agent systems plateau after deployment. They execute tasks, but the surrounding system may not measure whether they are getting better, repeating old work, or normalizing stalled execution. This article proposes a reference pattern for agent harnesses: supervised feedback loops that make agent behavior observable, measurable, and easier to improve.

\n

The Problem: Agents That Don't Learn From Their Own Trace

\n

Most agent architectures follow a simple pattern:

\n
User Request -> Agent Reasoning -> Tool Execution -> Response
\n

This works for single-turn tasks. But over hundreds or thousands of runs, the agent can make the same mistakes, retry the same failing strategies, and generate the same redundant outputs. It may have no mechanism to:

\n\n

These are plausible failure modes in long-running agent systems: repeated status updates, hand-waved health scores, accumulated \"lessons learned\" that never change system behavior, and stale priorities that remain nominally critical while no one acts on them.

\n

This is not necessarily a bug in the agent. It is often a missing architectural layer.

\n

The Harness Architecture

\n

A harness is a feedback loop that monitors an agent's output, detects patterns, and triggers bounded corrective action. The proposed pattern uses four harness types, each addressing a specific failure mode:

\n\n\n\n\n\n
HarnessFailure ModeTriggerAction
Novelty FilterRedundant documentation accumulationSemantic similarity > thresholdSuppress redundant output
Calculated HealthNarrated metrics drift from realityDaily evaluation windowCompute objective health score
Break-GlassSystem paralysis without actionThreshold breachNotify, escalate, or reduce authorized scope
Lesson WindowLessons identified but never appliedAge > window or count > limitArchive stale active lessons
\n
+-------------------------------------------------------------+\n|                         AGENT CORE                          |\n|   +-----------+      +-----------+      +----------------+   |\n|   | Reasoning | ---> | Execution | ---> | Output         |   |\n|   +-----------+      +-----------+      +----------------+   |\n+-------------------------------------------------------------+\n                                |\n                                v\n+-------------------------------------------------------------+\n|                        HARNESS LAYER                        |\n|   +----------------+   +----------------+   +-------------+ |\n|   | Novelty Filter|   | Calc. Health   |   | Break-Glass | |\n|   | (dedup)       |   | (metrics)      |   | escalation  | |\n|   +----------------+   +----------------+   +-------------+ |\n|   +-------------------------------------------------------+ |\n|   |             Lesson Window (time-bounded)              | |\n|   +-------------------------------------------------------+ |\n+-------------------------------------------------------------+\n                                |\n                                v\n+-------------------------------------------------------------+\n|                        FEEDBACK LOOP                        |\n|        Metrics -> Review -> Approved Changes -> Policies    |\n+-------------------------------------------------------------+

Harness 1: Novelty Filter

\n

Problem: The agent may produce repeated documentation or status text that restates known issues without adding decision value.

\n

Illustrative implementation: This example is self-contained enough to show the state-management rule. In production, persist history outside the process and choose the embedding model, threshold, and retention period through evaluation.

\n
from dataclasses import dataclass\nfrom datetime import datetime, timedelta, timezone\n\nfrom sentence_transformers import SentenceTransformer\nimport numpy as np\n\n@dataclass(frozen=True)\nclass HistoryEntry:\n    content: str\n    embedding: np.ndarray\n    created_at: datetime\n\nclass NoveltyFilter:\n    def __init__(self, threshold=0.82, window_days=7):\n        self.model = SentenceTransformer("all-MiniLM-L6-v2")\n        self.threshold = threshold\n        self.window_days = window_days\n        self.history: list[HistoryEntry] = []\n\n    def is_novel(self, content: str) -> bool:\n        """Return True only if content is sufficiently novel."""\n        now = datetime.now(timezone.utc)\n        self._evict_expired(now)\n        new_embedding = self.model.encode(content)\n\n        for entry in self.history:\n            similarity = np.dot(new_embedding, entry.embedding) / (\n                np.linalg.norm(new_embedding) * np.linalg.norm(entry.embedding)\n            )\n            if similarity > self.threshold:\n                return False\n\n        self.history.append(HistoryEntry(content, new_embedding, now))\n        return True\n\n    def _evict_expired(self, now: datetime) -> None:\n        cutoff = now - timedelta(days=self.window_days)\n        self.history = [\n            entry for entry in self.history\n            if entry.created_at >= cutoff\n        ]
\n

Hypothesis: A correctly tuned novelty filter should reduce redundant persisted text while preserving new decisions, new evidence, and changed conclusions. A proposed target is a 30-50% reduction in persisted daily status text with manual review showing no loss of material decisions.

\n

Harness 2: Calculated Health

\n

Problem: Health metrics are often narrated rather than calculated. A stable phrase such as \"roughly healthy\" can mask variation in the underlying jobs.

\n

Illustrative implementation: The health calculator should receive concrete check functions. This avoids hidden dependencies on undefined methods and makes the metric auditable.

\n
from dataclasses import dataclass\nfrom datetime import datetime, timedelta, timezone\nfrom pathlib import Path\nfrom typing import Callable\n\n@dataclass\nclass JobMetrics:\n    name: str\n    weight: float\n    check_func: Callable[[int], float]\n\nclass HealthCalculator:\n    def __init__(self, jobs: list[JobMetrics]):\n        total_weight = sum(job.weight for job in jobs)\n        if round(total_weight, 6) != 1.0:\n            raise ValueError("job weights must sum to 1.0")\n        self.jobs = jobs\n\n    def calculate(self, days: int = 7) -> float:\n        """Calculate health as weighted average of job success rates."""\n        total = 0.0\n        for job in self.jobs:\n            success_rate = job.check_func(days)\n            total += success_rate * job.weight\n        return round(total * 100, 1)\n\ndef recent_output_check(directory: Path, min_bytes: int = 1024) -> Callable[[int], float]:\n    """Return a check where success means one meaningful output per day."""\n    def check(days: int) -> float:\n        cutoff = datetime.now(timezone.utc) - timedelta(days=days)\n        outputs = [\n            path for path in directory.glob("*.md")\n            if datetime.fromtimestamp(path.stat().st_mtime, timezone.utc) >= cutoff\n            and path.stat().st_size >= min_bytes\n        ]\n        return min(len(outputs) / max(days, 1), 1.0)\n    return check\n\ncalculator = HealthCalculator([\n    JobMetrics("extraction", 0.40, recent_output_check(Path("runs/extraction"))),\n    JobMetrics("briefing", 0.30, recent_output_check(Path("runs/briefing"))),\n    JobMetrics("weekly_review", 0.30, recent_output_check(Path("runs/review"))),\n])
\n

Measurement definition: Health is the weighted average of job-specific success rates over a fixed evaluation window. Each job must define its own observable success condition before the run starts.

\n

Harness 3: Break-Glass

\n

Problem: Some systems need a fail-safe escalation path when important work stalls or health drops below an agreed threshold. Break-glass rules should not silently grant broad autonomy to the agent.

\n

Canonical configuration:

\n
[break_glass]\nenabled = true\nmode = "supervised"\n\n[[break_glass.rules]]\nname = "commit_gap"\ncondition = "days_since_commit > 14"\nseverity = "critical"\naction = "notify_and_require_ack"\nmessage = "Critical commit gap: human acknowledgement required."\n\n[[break_glass.rules]]\nname = "health_critical"\ncondition = "calculated_health < 15"\nseverity = "critical"\naction = "reduce_authorized_scope"\nallowed_jobs = ["extraction", "health_check"]\nmessage = "Health critical: non-essential jobs are paused within pre-authorized limits."\n\n[[break_glass.rules]]\nname = "lesson_accumulation"\ncondition = "unapplied_lessons > 50 AND oldest_unapplied_days > 14"\nseverity = "warning"\naction = "notify_owner"
\n

Rule semantics:

\n
notify_and_require_ack:\n  Send an escalation and block risky automatic changes.\n\nreduce_authorized_scope:\n  Automatically disable only jobs already marked non-essential.\n\nnotify_owner:\n  Create a visible warning with no automatic operational change.
\n

Abbreviated trigger evaluation: This sketch assumes Rule.evaluate is a safe expression evaluator over a constrained state object, not arbitrary code execution.

\n
class BreakGlass:\n    def evaluate(self, system_state: dict) -> list[Trigger]:\n        triggers = []\n        for rule in self.rules:\n            if rule.evaluate(system_state):\n                triggers.append(Trigger(\n                    rule=rule.name,\n                    severity=rule.severity,\n                    action=rule.action,\n                    message=rule.message.format(**system_state),\n                ))\n        return triggers
\n

Fail-safe principle: Notification and escalation remain available through approved channels and rate limits. Automatic action is limited to pre-authorized scope reduction, such as pausing non-essential jobs. Anything outside that predefined reduction policy—including changing data, deleting history, shipping code, or broadening production behavior—requires human authorization.

\n

Harness 4: Lesson Window

\n

Problem: \"Lessons learned\" can become a growing active queue that never changes system behavior.

\n

Illustrative implementation: The window archives stale active lessons. It does not prove that lessons have been applied, and it does not force application.

\n
from datetime import datetime, timedelta, timezone\n\nclass LessonWindow:\n    def __init__(self, window_days: int = 7, max_unapplied: int = 30):\n        self.window = timedelta(days=window_days)\n        self.max_unapplied = max_unapplied\n\n    def process(self, lessons: list[Lesson]) -> tuple[list[Lesson], list[Lesson]]:\n        """Return (active_lessons, archived_lessons)."""\n        active = []\n        archived = []\n        now = datetime.now(timezone.utc)\n        candidates = [\n            lesson for lesson in lessons\n            if lesson.status not in {"applied", "archived"}\n        ]\n        overflow = max(len(candidates) - self.max_unapplied, 0)\n\n        for lesson in lessons:\n            if lesson.status == "archived":\n                archived.append(lesson)\n                continue\n            if lesson.status == "applied":\n                active.append(lesson)\n                continue\n\n            age = now - lesson.created_at\n\n            if age > self.window:\n                lesson.archive_once(reason=f"expired_after_{self.window.days}_days")\n                archived.append(lesson)\n            elif overflow > 0:\n                lesson.archive_once(reason="overflow")\n                archived.append(lesson)\n                overflow -= 1\n            else:\n                active.append(lesson)\n\n        return active, archived
\n

Rule: A lesson is only \"learned\" if system state changes because of it. If not applied within the active window, it can be archived, not forgotten, so that it no longer clutters the active queue.

\n

Integration Architecture

\n

The harnesses integrate at the output boundary of the agent core, before content is persisted to memory:

\n
Agent Output\n    |\n    v\n+-----------------+\n| Novelty Filter  | --> Suppress? Yes: discard and log filter event\n+-----------------+     No: continue\n    |\n    v\n+-----------------+\n| Calculate Health| --> Update metrics store\n+-----------------+\n    |\n    v\n+-----------------+\n| Break-Glass     | --> Notify or apply authorized reduction\n+-----------------+\n    |\n    v\n+-----------------+\n| Lesson Window   | --> Archive expired, queue active\n+-----------------+\n    |\n    v\nPersist to Memory
\n

This placement is important: harnesses operate on output, not input. Filtering input could prevent useful ideas from reaching the agent. Filtering output ensures only valuable, non-redundant content is preserved.

\n

Deployment Pattern

\n

Configuration

\n
# harness.toml\n[novelty_filter]\nenabled = true\nthreshold = 0.82\nwindow_days = 7\nmodel = "all-MiniLM-L6-v2"\n\n[health]\nenabled = true\ncalculation_window_days = 7\njobs = [\n    { name = "extraction", weight = 0.40, check = "recent_output:runs/extraction" },\n    { name = "briefing", weight = 0.30, check = "recent_output:runs/briefing" },\n    { name = "weekly_review", weight = 0.30, check = "recent_output:runs/review" },\n]\n\n[break_glass]\nenabled = true\nmode = "supervised"\n\n[[break_glass.rules]]\nname = "commit_gap"\ncondition = "days_since_commit > 14"\nseverity = "critical"\naction = "notify_and_require_ack"\n\n[[break_glass.rules]]\nname = "health_critical"\ncondition = "calculated_health < 15"\nseverity = "critical"\naction = "reduce_authorized_scope"\nallowed_jobs = ["extraction", "health_check"]\n\n[[break_glass.rules]]\nname = "lesson_accumulation"\ncondition = "unapplied_lessons > 50 AND oldest_unapplied_days > 14"\nseverity = "warning"\naction = "notify_owner"\n\n[lesson_window]\nenabled = true\nwindow_days = 7\nmax_unapplied = 30

Platform-Neutral Integration Contract

\n

The following is an illustrative contract, not a schema from a real product. The goal is to show the integration boundary a scheduler, orchestrator, or agent runtime would need to provide.

\n
{\n  "event": "agent.output.proposed",\n  "timestamp": "2026-09-06T23:00:00Z",\n  "run_id": "run_123",\n  "agent_id": "research_agent",\n  "content": "Proposed output content",\n  "metrics": {\n    "days_since_commit": 15,\n    "calculated_health": 42.5,\n    "unapplied_lessons": 12\n  }\n}

Evaluation Plan

\n

As of 2026-09-07, a 14-day evaluation starting on 2026-09-06 is not complete. A coherent 14-day inclusive window would run from 2026-09-06 through 2026-09-19. The table below is a prospective evaluation plan, not reported results.

\n\n\n\n\n\n
MetricBaseline DefinitionTreatment DefinitionTarget / Hypothesis
Daily persisted textBytes of agent-generated status or lesson text per daySame measure after novelty filtering30-50% reduction without losing material decisions
Health score stabilitySeven-day weighted health score from fixed checksSame measure after calculated health is introducedChanges should track job outcomes rather than remain narratively fixed
Break-glass behaviorNumber of threshold breaches that produce no visible escalationNumber of threshold breaches with notification, acknowledgement, or authorized scope reductionCritical breaches should create reviewable events
Lesson queue ageAge of oldest active unapplied lessonSame measure after lesson window archivalActive queue should remain bounded
\n

Methodology

\n
    \n
  1. Freeze the rule set, thresholds, job weights, and measurement definitions before the evaluation starts.
  2. \n
  3. Run a seven-day baseline with harnesses disabled, then a seven-day treatment with the same workload and harnesses enabled.
  4. \n
  5. Record raw events: outputs proposed, outputs persisted, filter decisions, health inputs, health score, threshold breaches, notifications, scope reductions, lessons created, lessons applied, and lessons archived.
  6. \n
  7. Manually audit a sample of filtered outputs for false positives: content that was suppressed but should have been retained.
  8. \n
  9. Report all metrics as observations only after the window closes. Do not backfill missing data or infer results from anecdotes.
  10. \n
\n

Sample size and limitations: A single 14-day run is enough to detect obvious integration failures and generate hypotheses, but it is not enough to claim general performance. Workload mix, agent prompts, human review behavior, and calendar effects can dominate the result. Treat the outcome as local evidence for this system, not proof that the pattern works everywhere.

\n

Related-work caveat: This pattern overlaps with established ideas in observability, control loops, MLOps monitoring, guardrails, and human-in-the-loop operations. The novelty here, if any, is the packaging of those ideas around agent output boundaries. This article does not claim a new algorithm or publish comparative research.

\n

Failure Modes

\n

Over-Filtering

\n

If the novelty threshold is too aggressive, genuinely novel but structurally similar content may be suppressed. Mitigation: Start with a conservative threshold, then adjust based on measured filter hit rate and manual false-positive review. The target should be meaningful reduction, not maximum suppression.

\n

Break-Glass Fatigue

\n

If thresholds are too tight, break-glass triggers too frequently and is ignored. Mitigation: Reserve critical alerts for conditions that require review. Warning-level thresholds should log or notify without interrupting work.

\n

Lesson Loss

\n

Archiving lessons after a fixed window may hide valuable but long-term insights. Mitigation: Archived lessons remain searchable. The archive is cold storage: retrievable, but not cluttering the active queue.

\n

Conclusion

\n

The harness architecture addresses a practical gap in agent design: agents need feedback loops about their own behavior, not just about the tasks they execute. Without these loops, systems can accumulate redundant memory, drifted metrics, and normalized paralysis.

\n

The four harnesses (novelty filter, calculated health, break-glass, lesson window) form a proposed minimal layer for supervised agent improvement. They require a small, explicit contract from the agent core—output events, job metrics, and authorization state—plus careful placement at the output boundary and human authorization for risky actions.

\n

Key Takeaway: An agent that cannot detect its own stagnation will stagnate. Harnesses are the architectural layer that makes stagnation visible, reviewable, and fixable.

\n
\n

This is a proposed reference pattern. The methodology above is intended to make future evaluation reproducible without relying on private supporting material.

\n

License: CC BY-SA 4.0

\n", "https://reference-architecture.ai/properties/date": "2026-09-06", "https://atomicdata.dev/properties/tags": {"categories":["Architecture"],"tags":["agents","self-improvement","harnesses","feedback-loops"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/posts/github-oauth2/", "https://atomicdata.dev/properties/name": "Turning Open Source project into Product with Redis Enterprise", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/posts/github-oauth2/", "https://atomicdata.dev/properties/description": "

Turning Open Source project into Product with Redis Enterprise

\n

Overview

\n

Background

\n

History

\n

Last year, my reference project, \"The Pattern\", was the hackathon winner 2021 and got a bit of publicity and, in total, seven forks. But as with many open source projects, it is now stale. Time to revive \"The Pattern\" with new features and GitHub sponsors or Patreon patrons to help and inspire developers and creatives. In return, it's common to provide sponsor-only features and articles. Nevertheless, how can we do it with a large Redis-based machine learning pipeline?

\n

Plan sponsor only features

\n

This article will introduce a simple first step:\nfor GitHub sponsors, we start with offering persistent storage of preferences: I have a simple flask POST API which adds nodes into the user's preference storage - a simple Redis set per user. And it will be a foundation to build other sponsor-only features.\nFor now, let's cover the basics:

\n

Overall architecture overview

\n
\nflowchart LR\n    id1(User) --> flask_login(Flask Login API)--> github(GitHub OAuth2)\n    github-->flask_callback(Flask API callback)-->GitHubGraphQL(GitHub GraphQL)\n
\n

Add Github oauth2 to Rest API

\n

There are a number of API's that GitHub offers to help developers, but the GitHub Authentication API is one of the most popular. This API allows you to log in to GitHub using your username and password, or OAuth token.

\n

A login button with a standard OIDC/OAuth2 dance is one of the most common ways for a user to authenticate to an API.\nBelow is code taken from this gist and is very common for OAuth2 flows:

\n
import os \nclient_id = os.getenv('GITHUB_CLIENT_ID')\nclient_secret = os.getenv('GITHUB_SECRET')\n@app.route('/', methods=['GET', 'POST'])\ndef index():\n    url = 'https://github.com/login/oauth/authorize'\n    params = {\n        'client_id': client_id,\n\n        'scope': 'read:user,read:email',\n        'state': str(uuid4().hex),\n        'allow_signup': 'true'\n    }\n    url = furl(url).set(params)\n    return redirect(str(url), 302)
\n

where GITHUB_CLIENT_ID and GITHUB_SECRET are client/secret GitHub Oauth2 apps. Register for following process on GitHub

\n\n
org_name="applied-knowledge-systems"\n@app.route('/oauth2/callback')\ndef oauth2_callback():\n\n    code = request.args.get('code')\n    access_token_url = 'https://github.com/login/oauth/access_token'\n    payload = {\n        'client_id': client_id,\n        'client_secret': client_secret,\n        'code': code,\n        # 'redirect_uri':\n        'state': str(uuid4().hex)\n    }\n    r = requests.post(access_token_url, json=payload, headers={'Accept': 'application/json'})\n    access_token = json.loads(r.text).get('access_token')\n    print(access_token)\n    \n    access_user_url = 'https://api.github.com/user'\n    response = requests.get(access_user_url, headers={'Authorization': 'token ' + access_token})\n    data=response.json()\n    user_email=data["email"]\n    user_login=data["login"]\n    user_id=data["id"]\n    # response=redirect(url_for('login',next=redirect_url()))\n    # response.set_cookie('user_id', str(user_id))\n    # response.set_cookie('user_login', str(user_login))\n    # return response\n    query = """\n        {\n        viewer {\n            sponsorshipsAsSponsor(first: 100) {\n            nodes {\n                sponsorable {\n                ... on User {\n                    id\n                    email\n                    url\n                }\n                ... on Organization {\n                    id\n                    email\n                    name\n                    url\n                }\n                }\n                tier {\n                id\n                name\n                monthlyPriceInDollars\n                monthlyPriceInCents\n                }\n            }\n            }\n        }\n        }\n        """\n    response_graphql = requests.post('https://api.github.com/graphql', json={'query': query}, headers={'Authorization': 'token ' + access_token})\n    response_graphql_data=response_graphql.json()["data"]\n    if isinstance (response_graphql_data["viewer"]["sponsorshipsAsSponsor"]["nodes"], list):\n      if response_graphql_data["viewer"]["sponsorshipsAsSponsor"]["nodes"][0]["sponsorable"]["name"]==org_name:\n          # if user is a sponsor of Applied Knowledge System add them to set of sponsors\n         redis_client.sadd(f'sponsors:{org_name}',user_id)\n    # if RedisJSON enabled:\n    # redis_client.json().set(f"user_details:{user_id}", '$', {\n    #     'email': user_email,\n    #     'id': user_id,\n    #     'user_login': user_login,\n    #     'graphql': response_graphql_data,\n    # }) \n    #if not\n    redis_client.hset(f"user_details:{user_id}", mapping={\n        'email': user_email,\n        'id': user_id,\n        'user_login': user_login\n    })\n    return jsonify({\n        'status': 'success',\n        'email': user_email,\n        'id': user_id,\n        'user_login': user_login\n    })
\n

The API we are using for our sponsor-only feature is straightforward:

\n
@app.route('/exclude', methods=['POST','GET'])\ndef mark_node():\n    if request.method == 'POST':\n        if 'id' in request.json:\n            node_id=request.json['id']\n    else:\n        if 'id' in request.args:\n            node_id=request.args.get('id')\n    user_id = session.get('user_id')\n    log(f"Got user {user_id} from session")\n    if not user_id:\n        user_id = request.cookies.get('user_id')\n        log(f"Got user {user_id} from cookie")\n    redis_client.sadd("user:%s:mnodes" % user_id,node_id)\n    response = jsonify(message=f"Finished {node_id} and {user_id}")\n    return response
\n

And the only purpose of this API is to mark nodes as unimportant for the given user by adding nodes to RedisSet, and those nodes will be excluded from search API output. So far, everything was pretty standard: basic flask API and GitHub Social login flow. Now let's add Redis Enterprise and synchronise sponsors preferences.

\n

Add Redis Enterprise

\n

Why not use Redis Enterprise directly for everything?\nThe project is memory-heavy, with a lot of data and machine learning inside Redis. This allows to achieve state-of-the-art performance, but it also takes over 120 GB RAM (or as much RAM as you can give it), and 128 GB Redis Enterprise instance will exceed my budget for open-source project. Obviously if there will be enough sponsors we can move more functionality into Redis Enterprise, but for that we need to finish building basic blocks. Register on Redis.com cloud and create a database with the subscription.

\n

\"Redis\nTake a note host, port and password for Redis Enterprise and create docker enviroment file:

\n
cat .env.gears \nREDISENT_PWD="123"\nREDISENT_PORT="13444"\nREDISENT_HOST="hostname.cloud.redislabs.com"
\n

and create a docker compose with section passing .env.gears. Mine looks like this:

\n
  redisgraph:\n    image: redislabs/redismod\n    container_name: redisgears\n    hostname: redisgears\n    env_file:\n      - ./.env.gears\n    ports:\n      - 127.0.0.1:9001:6379\n

Synchronize Redis OSS to Redis Enterprise using RedisGears

\n

Synchronize all user preferences

\n

First flow:\nWe will be using RedisGears to synchronize all preferences with Redis Enterprise

\n
\nflowchart LR\n    id1(User Preferences Redis OSS) --> redis_gears1(Redis Gears)--> redise(Redis Enterprise)\n
\n

If you are new to RedisGears, there is a pattern rgsync that covers exacly this use case, but I already have RedisGears, so I am going to build it step by step:

\n
# gears_sync_preferences.py\nrconn=None\n\ndef connecttoRedisEnterise():\n    import redis \n    import os \n    log(str(os.environ))\n    # Get environment variables\n\n    HOST = os.getenv('REDISENT_HOST')\n    PASSWORD = os.getenv('REDISENT_PWD')\n    PORT = os.getenv('REDISENT_PORT')\n\n    redis_client=redis.Redis(host=HOST,port=PORT,charset="utf-8", password=PASSWORD, decode_responses=True)\n    return redis_client\n\ndef sync_users(record):\n    global rconn\n    if not rconn:\n        rconn=connecttoRedisEnterise()\n    # Uncomment logs to check \n    # log(str(record['key']))\n    # log(str(record['value']))\n\n    rconn.hset(record['key'],mapping=record['value'])\n\ngb = GB()\ngb.foreach(sync_users)\ngb.count()\ngb.run('user_details:*')
\n

this is a \"batch\" mode for RedisGears, which is easier to debug than streams. Install gears-cli](https://github.com/RedisGears/gears-cli) with pip install gears-cli run above script:

\n
gears-cli run --host 127.0.0.1 --port 9001 gears_sync_preferences.py --requirements req_sync.txt
\n

where req_sync.txt

\n
redis==3.5.3
\n

This RedisGears will copy all user's profiles into RedisEnterprise. Now let us add sponsors:

\n
# gears_sync_sponsors.py\nrconn=None\n\ndef remove_prefix(text, prefix):\n    return text[text.startswith(prefix) and len(prefix):]\n\ndef connecttoRedisEnterise():\n    import redis \n    import os \n    log(str(os.environ))\n    # Get environment variables\n\n    HOST = os.getenv('REDISENT_HOST')\n    PASSWORD = os.getenv('REDISENT_PWD')\n    PORT = os.getenv('REDISENT_PORT')\n    log(HOST)\n    log(PORT)\n    log(PASSWORD)\n    redis_client=redis.Redis(host=HOST,port=PORT,charset="utf-8", password=PASSWORD)\n    return redis_client\n\n\n\ndef sync_sponsors(record):\n    global rconn\n    if not rconn:\n        rconn=connecttoRedisEnterise()\n\n    log(str(record['key']))\n    values=execute('SMEMBERS',record['key'])\n    log(str(values))\n    for each_value in values:    \n        rconn.sadd(record['key'],each_value)\n\ngb = GB('KeysReader')\ngb.foreach(sync_sponsors)\ngb.count()\ngb.run('user:*')
\n

But this one will sync all user's preferences, but we only need sponsors - let us add another feature of RedisGears - filter:

\n
rconn=None\n\ndef remove_prefix(text, prefix):\n    return text[text.startswith(prefix) and len(prefix):]\n\ndef connecttoRedisEnterise():\n    import redis \n    import os \n    log(str(os.environ))\n    # Get environment variables\n\n    HOST = os.getenv('REDISENT_HOST')\n    PASSWORD = os.getenv('REDISENT_PWD')\n    PORT = os.getenv('REDISENT_PORT')\n\n    redis_client=redis.Redis(host=HOST,port=PORT,charset="utf-8", password=PASSWORD, decode_responses=True)\n    return redis_client\n\ndef filter_sponsors(record):\n    org_name="applied-knowledge-systems"\n    user_id = remove_prefix(record['key'],'user:')\n    sponsor=execute('SISMEMBER',f'sponsors:{org_name}',user_id)\n    return bool(sponsor==True)\n\ndef sync_sponsors(record):\n    global rconn\n    if not rconn:\n        rconn=connecttoRedisEnterise()\n\n    log(str(record['key']))\n    values=execute('SMEMBERS',record['key'])\n    log(str(values))\n    for each_value in values:    \n        rconn.sadd(record['key'],each_value)\n\ngb = GB()\ngb.filter(filter_sponsors)\ngb.foreach(sync_sponsors)\ngb.count()\ngb.run('user:*')

Fetch sponsor's preferences back to Redis OSS from Redis Enterprise

\n

Then we are going to use Key miss events from Redis Gears to fetch data for all users:

\n
\nflowchart LR\n    redise(Redis Enterprise)\n    redis_gears2(Redis Gears)--key miss--->redise\n    redis_gears2-->redisOSS[Redis OSS]\n
\n

and it's very easy, right from key miss example:

\n
\ndef fetch_data(r):\n    key = r['key']\n    global rconn\n    if not rconn:\n        rconn=connecttoRedisEnterise()\n    values=rconn.smembers(record['key'])\n    log(str(values))\n    for each_value in values:    \n        execute('SADD',record['key'],each_value)\n\nGB().foreach(fetch_data).register(prefix='user:*', commands=['smember'],eventTypes=['keymiss'], mode="async_local")
\n

There is one more option - to turn fetch_data into the async call, by wrapping it into async/await, but Redis Enterprise is fairly fast, and I don't think it's worth adding an async call in this case. For curiosity, see the example code in The Pattern repository.

\n

Conclusion

\n

In this article, we walked through steps on how to create sponsor-specific \"nanoservices\" using RedisOSS, RedisGears and Redis Enterprise. This allows us to leverage the best of all worlds open source Redis, high availability and persistence with Redis Enterprise and RedisGears as the glue which holds everything together.

\n

This post is in collaboration with Redis.

\n

References

\n\n", "https://reference-architecture.ai/properties/date": "2022-08-19", "https://atomicdata.dev/properties/tags": {"categories":["Redis"],"tags":["Redis Enterprise","roadmap","product","oauth2","github","sponsors"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/posts/post-0/", "https://atomicdata.dev/properties/name": "Announcing Reference Architecture for AI", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/posts/post-0/", "https://atomicdata.dev/properties/description": "

There are tools for advanced analytics, including free ones from Google and Kaggle.

\n

There are well-known and validated deployment architectures for applications and the cloud.

\n

Yet the number of practical applications is still tiny, and they retained niche implementations.\nWhile the benefits of AI are clear, there are still many gaps in AI architecture that need to be filled. For example, there is a gap between analytical tools and verified architectures for real-time deployments. This gap often stems from a lack of specific reference architectures and patterns, demonstrating the trade-offs between technologies, libraries, and tools.

\n

Let's bridge the gap in knowledge and drive a connection between science and engineering to make fast, efficient, and practical AI deployments.\nThree things need to be in place to build an AI product:

\n
    \n
  1. AI Product itself
  2. \n
  3. Core Capabilities required to build AI/ML product
  4. \n
  5. Enabling capabilities
  6. \n
\n

I will use The Pattern, my [“Build on Redis” Hackathon prize-winning open source](https://github.com/applied-knowledge-systems/the-pattern) project, to illustrate how the capabilities below can be implemented and invite you to contribute or donate.

\n

We launch in two full-featured articles - NLP ML pipeline for turning unstructured JSON text into a knowledge graph and fresh off the press Benchmarks for BERT Large Question Answering inference for RedisAI and RedisGears with Grafana Dashboards by Mikhail Volkov

\n", "https://reference-architecture.ai/properties/date": "2022-06-16", "https://atomicdata.dev/properties/tags": {"categories":["Architecture"],"tags":["reference architecture","ai","announcement"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/docs/beam-memory-benchmark-protocol/", "https://atomicdata.dev/properties/name": "Measuring Agent Memory on BEAM: a Pre-Registered Protocol", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/docs/beam-memory-benchmark-protocol/", "https://atomicdata.dev/properties/description": "

Status

\n

This page is a protocol, not a result. No reported split has been run. It is published first so that the method cannot drift towards the numbers. Results will appear in a separate post that links back here, and any change to this protocol after publication will be listed on that post with its reason.

\n

Changes since first publication. Each change is made before the configuration is frozen and before any reported split is run:

\n\n

Why a paired comparison, and only that

\n

Memory benchmarks for agents usually measure three things at once: the memory, the model that answers from it, and the model that grades the answer. A single \"memory score\" cannot tell them apart. Swap the answer model and the score moves; swap the judge and it moves again.

\n

past.dev publishes its harness for BEAM, a long-conversation memory benchmark, at pastdotdev/benchmarks. Two properties make a fair comparison possible:

\n\n

So one component, the retrieval substrate, can be replaced while everything else stays the same, and the outcome compared question by question against the 2,000 published records. That is a paired test. It is not a leaderboard entry, and we will not publish a standalone score for any system.

\n

This fits the Memory Infrastructure job in the twelve patterns: a memory layer is only as good as what it puts in front of the model at the moment of the question, and that can be measured without asking a model's opinion.

\n

What is held fixed

\n

Pinned at harness commit a712cd9 (2026-10-20), the latest at the time of writing:

\n\n\n\n\n\n
SplitConversationsQuestionsWith evidence turn ids
100K20400355
500K35700629
1M35700625
10M10200176
\n

The 100K, 500K and 1M splits use BEAM dataset revision 3205395e; the 10M split uses 9b209619. Abstention questions (200 in all) have no evidence turns by design: they test whether the system declines to answer. A further 15 questions carry no evidence turn ids in the dataset (twelve in summarisation, two in preference following, one in knowledge update). They are excluded from Tier 1 and kept in Tier 2.

\n

Every recall row past.dev published cites exactly one source turn, and in every split its payload is close to full: the median is about 7,990 of the 8,000 evidence tokens.

\n

What is being compared

\n

The subject is Terraphim's retrieval as it ships, through its two command-line front ends, with no language model anywhere on the retrieval path:

\n\n\n\n\n\n\n\n\n\n\n
ArmSubstrate
Ppast.dev, from its published records (not rerun)
Rplain ripgrep over the same turns, as a baseline
Gterraphim-grep, search only, no network, no thesaurus
G-KGG with the knowledge-graph thesaurus: synonym expansion and concept boost, text matching kept
A-BM25terraphim-agent search, BM25Plus relevance, no thesaurus
A-Titlethe same role, TitleScorer relevance
A-KGthe same role, TerraphimGraph relevance with a knowledge-graph thesaurus
A-KG-XA-KG, with the query also expanded through the thesaurus
A-MEMterraphim-agent memory retrieve, the agent-memory feature, with each turn stored as one memory item and the A-KG thesaurus
\n

A-BM25 against A-KG is the knowledge-graph ablation: same turns, same frozen query text, same settings; only the ranking and its thesaurus change. A-KG against A-KG-X then measures query expansion on its own.

\n

G against G-KG measures the same thing inside terraphim-grep. There the thesaurus expands the query through synonyms and boosts matching results, but text matching still applies, so a question that names no concept can still find turns.

\n

A-MEM measures Terraphim's agent memory as it ships. It ranks memory items by their knowledge-graph concepts, with no text-search fallback: a query that names no thesaurus concept returns nothing, and an item is only reachable if it matches at least two concepts. On its own benchmark of 56 stored learnings it reached a recall at 5 of 0.04, for exactly that reason. Expect low numbers here too. They will be published as they are, with the share of questions that named no concept.

\n

One external baseline, added on 2026-11-27, is not a Terraphim arm:

\n\n\n
ArmSubstrate
MMGMem, the authors' released code at commit 67c53a28, with the paper's default settings and a single extraction worker. Tier 1 only
\n

MGMem builds a graph of the words and phrases (\"mentions\") that a parser finds in each stretch of conversation. It links two mentions when they appear in the same stretch, and links each mention to the stretches that contain it. A small sentence-embedding model bridges near-synonyms at query time. It runs a local parser (spaCy en_core_web_trf) and that embedding model (all-MiniLM-L6-v2), returns the raw dialogue, and calls no generative model anywhere. Against A-KG it is the nearest outside design: the same kind of co-occurrence graph, built on a vocabulary taken from the conversation instead of a curated thesaurus. It also differs from A-KG in how it weights terms, links them, reaches stretches with a single match, bridges near-synonyms and segments the conversation. M is a baseline like R. It does not count as a Terraphim arm in decision 4.

\n

How the substrate is swapped

\n

The harness talks to past.dev over HTTP. We run a small local server that implements the same eight endpoints and point the harness at it by URL. The harness code runs unmodified; the only deviation from past.dev's run is that URL.

\n

The local server writes each ingested turn to its own file, runs the arm's search, discards any turn later than the question's moment, and fills the payload by rank to 100 results and 8,000 tokens. It returns only fields it can fill truthfully: rank, timestamp, the raw turn text, and its source turn id. It omits past.dev's derived-memory fields, because we do not produce derived memories. The answer model reads the payload as returned, so this difference is part of what is measured, and is stated beside every result.

\n

An item's rank in A-MEM depends on everything else in the store, so discarding later turns after retrieval would still let them shape the ranking. For A-MEM the store is rebuilt for each question from the turns at or before its moment.

\n

M has the same property, and more of it: its term weights, links and stretches are all computed over the whole conversation. So M's index is also rebuilt for each question from the turns at or before its moment. The rules for M:

\n\n

Tokens are counted with tiktoken o200k_base. past.dev counts server-side and does not document its method, so this is a known deviation.

\n

Two tiers

\n

Tier 1, no generative or paid model calls. For each question with evidence turns, the fraction of those turns cited anywhere in the payload the answer model would receive. We call this recall within budget. past.dev's figure is computed from its published records; ours from the local server. It costs nothing to run and needs no judge.

\n

Tier 2, the full benchmark. The unmodified harness answers and judges every question through the local server. Each question's score is paired with past.dev's published score for the same question. Tier 2 is pay-per-use, and runs only after Tier 1 and a budget decision.

\n

Three controls make Tier 2 interpretable:

\n\n

What we have already seen

\n

A pre-registration is only honest if it says what the authors looked at first. Before writing this page we read the 188 turns, 20 questions and evidence ids of 100K conversation 1, the first published 100K record, and aggregate counts over all four splits. Those counts covered structure and numbers, not question or turn text.

\n

Two findings from that conversation shaped the protocol:

\n\n

For M, on 2026-11-27 we built MGMem's index four times on the same already-seen 100K conversation, with no generative or paid model calls (only MGMem's local parser and embedding model) and no question answered. We recorded build time, memory, index size, graph counts and content hashes, and parsed its 20 questions to count how many found a subject in the index. No recall was computed.

\n

Development and held-out splits

\n\n

This avoids a trap past.dev itself disclosed for its DolphinBench run: the setup there was chosen on the same tests it reported.

\n

Metrics and decisions, declared now

\n\n

Decisions fixed in advance:

\n
    \n
  1. If past.dev's records map to BEAM turns for fewer than 99 percent of rows on any split, past.dev is dropped from Tier 1 for that split and the shortfall is reported.
  2. \n
  3. If A-KG does not beat A-BM25 on held-out recall within budget, with an interval excluding zero, we report no measurable knowledge-graph gain on BEAM and make no claim of one. The same rule applies to G-KG against G, reported separately.
  4. \n
  5. A-MEM's held-out recall within budget, and its recall at 5 (what the memory hook would inject), are reported beside A-KG and past.dev, whatever they are.
  6. \n
  7. If no Terraphim arm beats the ripgrep baseline on held-out splits, that is the headline.
  8. \n
  9. No composite score and no standalone \"Terraphim BEAM score\", in any tier.
  10. \n
  11. One reported pass per arm. Any rerun is reported separately, with its pass count.
  12. \n
  13. M's held-out recall within budget is reported beside A-KG, A-BM25 and ripgrep. The paired difference A-KG minus M is reported with the same clustered interval:\n\n
  14. \n
\n

A second harness: Cognee's

\n

Added on 2026-11-26, before any run under either harness.

\n

Cognee has published a BEAM report, marked preliminary. It covers one 100K conversation of 20 questions, run 4 times, with a mean rubric score of 0.79. It also covers one 10M conversation, with a retriever chosen on the same 20 questions it reports, which the report calls exploratory. We pin Cognee at commit 1961133d. As with past.dev, every question's record is published: the retrieved context, the answer, the rubric criteria, the question's aggregate score and a summary of the judging. Cognee's judge scores each criterion separately, but the records do not keep the individual verdicts, so pairing is per question, not per criterion. That is enough for the same paired design. The two harnesses use different answer models, judges and prompts, so numbers from one harness are never compared with numbers from the other.

\n

What is held fixed. Cognee's harness code, its per-question-type answer prompts, and openai/gpt-5 as both answer model and judge. The judge scores each rubric criterion separately. The 20 questions are those of BEAM 100K conversation 2, which is row 1 of dataset revision 3205395e; all 20 question texts match Cognee's records. Each arm runs 4 times, as Cognee's did.

\n

How the substrate is swapped. Cognee's harness builds each retriever from a registry, asks it for a context string, and then answers through the retriever's own completion method. We register one retriever per arm at runtime. It subclasses Cognee's hybrid retriever, replaces only the two methods that produce the context, and keeps Cognee's completion path. Cognee's harness files run unmodified. Before any paid call, a test on real files checks two things: each arm's context reaches the completion step unchanged, and the replayed context equals the published one byte for byte.

\n

Arms.

\n\n\n\n\n\n
ArmContext the answer model receives
ReplayCognee's published context for that question and run, byte for byte
Emptynone: the floor
Fullthe whole conversation, 200 turns and about 115,000 tokens, which fits in the answer model's window: a full-context control, not a guaranteed ceiling, since irrelevant turns can lower a score
R, G, G-KG, A-MEMthe arms above, with their configurations frozen as above
\n

Replay is the pair for every other arm. Cognee's records date from July 2026 or earlier, and the model behind today's route may answer and judge differently. So each Terraphim arm is compared with a fresh replay, not with Cognee's published scores. To make that replay run alongside every arm, the runs are interleaved. Each of the 4 runs is one block, and in each block every question is answered and judged under all seven arms, in an order shuffled with a fixed seed. The wrapper drives this schedule itself, calling Cognee's functions one run of one arm at a time, rather than letting the harness finish all runs of one arm before the next. It records the run index, the arm order and timestamps, and a test with no model calls checks that the observed call order matches the frozen schedule. Route drift during the run then falls on all arms alike. The model route is pinned to one provider, with fallback off, and recorded. The drift and noise floor is the absolute difference between two overall means: the mean of the 4 fresh replay runs and the mean of Cognee's 4 published runs, over the same 20 questions.

\n

Equal budget. Cognee's contexts are hybrid. Each has a passages section, where every passage holds an LLM-written summary and the raw stored chunk, followed by sections of LLM-derived entities and facts. They run from 13,643 to about 29,800 tokens per question (median about 21,700), with no stated cap. Each Terraphim arm fills its context by rank up to the token count of Cognee's run-0 context for that question (the published runs differ slightly from each other), so the comparison is about what is retrieved, not how much. Our arms return raw turns only. That difference in what the payload holds is part of the substrate and stays in; the Full arm bounds it.

\n

A judge-free tier only if the mapping holds. Cognee's contexts carry no BEAM turn ids. Its raw passages can still be matched to turns by text. In the first published run, no raw passage lies inside a single BEAM turn. Of the 400, 188 contain exactly one whole turn, 13 contain two whole turns, and 199 contain none, for reasons not yet found. So a raw passage is a chunk that can span several turns, not a copy of one. Before any paid call, a deterministic mapping assigns each raw passage the set of BEAM turns it contains whole. A gold turn counts as retrieved only if it is in that set. If such a set can be assigned for at least 99 percent of raw passages, we add a judge-free tier: recall of the gold evidence turns within Cognee's context, against each Terraphim arm's recall within the same per-question budget. Turns found only through multi-turn passages are reported as a separate count. If the mapping falls short, there is no judge-free tier for Cognee, and the shortfall is reported.

\n

What this harness cannot give. Every answer-and-judge comparison here is paid, and it runs only after a budget decision. With 20 questions from one conversation, the interval comes from resampling questions, not conversations. With two questions per category, category results are descriptive only. Cognee's ingestion is not rerun; we replay what it retrieved.

\n

Decisions fixed in advance:

\n
    \n
  1. An arm's difference from Replay, better or worse, is reported as real only if its paired bootstrap interval excludes zero and its absolute size is larger than the floor. Otherwise it is reported as indistinguishable on these 20 questions.
  2. \n
  3. Every arm is shown between Empty and Full. If Full matches or beats Replay, the headline says that at 100K, when the whole conversation fits in its window, this answer model does not need selective retrieval, so the comparison measures selection under a fixed budget.
  4. \n
  5. No standalone score, no composite, and no ranking across the two harnesses.
  6. \n
  7. The 10M conversation in Cognee's report is in this protocol's held-out set, so no work on it happens before the freeze.
  8. \n
\n

In-sample for us, held out for Cognee. Cognee held 100K conversation 2 out of its own tuning. Our arms are tuned on the whole 100K development split, conversation 2 included, as declared above. Every number from this harness is therefore labelled \"in-sample for Terraphim, held out for Cognee\". That asymmetry favours Terraphim, and it is stated beside every result. It does not change any decision rule.

\n

Already seen. For this harness we read the structure of Cognee's published 100K records and the opening of one context (conversation 2, an abstention question). We computed counts, token sizes and per-run means. The records keep only each question's score and a count summary of verdicts, so judge failures in Cognee's runs cannot be recovered from them. For our runs, the wrapper attaches its own log handler to the rubric metric's logger, which warns on every failed judge call, so judge failures are counted per arm. The harness's quiet log level does not hide them. We matched question texts by set intersection, and raw passages against conversation turns by verbatim containment, printing counts only. From the 10M side we saw only Cognee's published aggregate scores and a total context length.

\n

Attribution and licence

\n

BEAM is from \"Beyond a Million Tokens: Benchmarking and Enhancing Long-Term Memory in LLMs\" by Mohammad Tavakoli, Alireza Salemi, Carrie Ye, Mohamed Abdalla, Hamed Zamani and J Ross Mitchell (arXiv:2510.27246). The dataset (Mohammadta/BEAM and Mohammadta/BEAM-10M) is published under CC BY-SA 4.0. The harness is Past Corp's, under the MIT licence. The answer and judge prompts are ExaBase's, from its published BEAM adapter; they are excluded from Past Corp's licence, keep their own terms, and are used from the pinned harness, never copied. The BEAM split, question and payload counts on this page come from past.dev's published results files and the pinned dataset revisions. The A-MEM figures (56 stored items, recall at 5 of 0.04) come from Terraphim's own committed memory benchmark, docs/memory-benchmark.md in terraphim-clients, recorded on terraphim-agent 1.21.14. Cognee's harness, report and per-question records come from the topoteretes/cognee repository under the Apache 2.0 licence, and its records carry BEAM material under CC BY-SA 4.0. Cognee's prompts are used from the pinned checkout, not copied. The Cognee figures on this page (0.79, 20 questions, 4 runs, the context token range) come from its published report and records at 1961133d, re-read on 2026-11-26. MGMem is from \"MGMem: An Efficient, Deterministic, and Provenance-Preserving Framework for Long-Horizon Agent Memory\" by Junhong Huang, Xin Tong and Jun Xia (arXiv:2611.33174), with code at junhong-h/MGMem. The repository states no licence, so it is run from a pinned clone and not redistributed. The MGMem facts on this page (the default of eight extraction threads, run-to-run index differences at that default, identical single-thread builds) come from our own builds at 67c53a28 on 2026-11-27. This page is CC BY-SA 4.0, like the rest of this site, and republishes no question or conversation text.

\n", "https://reference-architecture.ai/properties/date": "2026-11-08", "https://atomicdata.dev/properties/tags": {"categories":["Evaluation"],"tags":["benchmarks","memory","beam","evaluation","terraphim","retrieval"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/docs/patterns/", "https://atomicdata.dev/properties/name": "The Twelve Core Patterns", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/docs/patterns/", "https://atomicdata.dev/properties/description": "

The harness, not the model, determines agent success. A harness has three jobs — deciding\nwhat the model sees, enforcing what it can do, and ensuring it learns from its own history\n— and each job is served by four patterns.

\n

Every pattern below is documented elsewhere on this site. This page is the index, not the\nexplanation: each entry links to where the argument is actually made.

\n

Context Architecture

\n

What the model sees at each step. Context is a scarce resource: a 1M token window with\n800K of noise performs worse than 200K with 150K of curated signal.

\n

1. Structural Context Boundary

\n

Put the boundary in configuration, not in a runtime permission check. A role has access\nto certain sources; the knowledge graph is built from those sources; the agent therefore\ncannot reach anything outside its role. Not a check that could be bypassed — an absence.\nThe data was never loaded.

\n

→ The Terraphim Engine, Layer 1

\n

2. Deterministic Concept Matching

\n

Resolve text to concepts with finite state automata rather than vector similarity.\nAho-Corasick finds every match in O(n) time, with the same result every run. Probabilistic\nretrieval gives you a different context window each time you ask, which makes every\ndownstream failure irreproducible.

\n

→ The MCP-Native Agent Architecture, Layer 2

\n

3. Structured Compaction

\n

Compact before the window fills, not when it overflows. By 100K tokens a working context\nis largely noise: superseded search results, abandoned reasoning paths, old file reads.\nAdding capacity without compaction makes performance worse, not better.

\n

→ Three ways 1M token windows fail

\n

4. Priority-Weighted Instruction Injection

\n

Instructions compete, and by default the loudest wins rather than the most important. The\nsystem prompt says one thing, the project file another, the README a third. Weight them\nexplicitly and re-inject the high-priority ones, rather than trusting position in a\ntranscript.

\n

→ Three ways 1M token windows fail

\n

Execution Guardrails

\n

What the model can and cannot do. Risk-tiered, machine-readable, and enforced by the\nsystem rather than requested in a prompt.

\n

5. Multi-Tenant Agent Isolation

\n

Agents sharing a protocol layer must not share state. Each agent keeps its own role\nconfiguration and its own knowledge graph, discovering the others' tools without\ndiscovering their data.

\n

→ Pattern 1: Multi-Tenant Agent Isolation

\n

6. Deterministic Replay

\n

An agent run you cannot replay is an agent run you cannot debug. Record the inputs and the\ndecisions such that the same run can be reconstructed exactly — which is only possible if\nthe layers underneath are themselves deterministic.

\n

→ Pattern 2: Deterministic Replay

\n

7. Human-in-the-Loop for Destructive Operations

\n

Classify tools by effect, not by name. Read-only operations run freely; destructive ones\nstop for approval. The protocol enforces the distinction, so an agent cannot talk its way\npast it.

\n

→ Pattern 3: Human-in-the-Loop for Destructive Operations

\n

8. Break-Glass

\n

Every guardrail needs a deliberate, logged way through it. A guardrail with no override\ngets disabled wholesale the first time it blocks something urgent; an override that is\nnot recorded is indistinguishable from the guardrail not existing.

\n

→ Harness 3: Break-Glass

\n

Memory Infrastructure

\n

Ensuring the model learns from its own history. Without it, agents repeat solved\nproblems indefinitely and no amount of context helps.

\n

9. Novelty Filter

\n

Distinguish output that is new from output that merely looks new. An agent that cannot\ntell repetition from progress will re-report the same finding until someone stops reading.

\n

→ Harness 1: Novelty Filter

\n

10. Calculated Health

\n

Derive a health signal from observable metrics rather than asking the agent how it is\ndoing. Self-assessment is the least reliable input available; commit recency, unapplied\nlessons and stall time are not.

\n

→ Harness 2: Calculated Health

\n

11. Lesson Window

\n

Capture corrections at the moment of failure and apply them within a bounded window.\nLessons with no expiry become noise; lessons never applied were never lessons.

\n

→ Harness 4: Lesson Window

\n

12. Drift Detection

\n

Long-running agents optimise for local coherence and lose the original objective. Ask\nperiodically, and mechanically: do we actually have the thing we set out to build? The\nquestion has to be asked by the harness, because an agent that has drifted cannot detect\nits own drift.

\n

→ Three ways 1M token windows fail ·\nThe nine-step orchestration arc

\n

On this list

\n

These twelve are the patterns this site currently makes an argument for, grouped by\nthe three jobs of an agent harness. The grouping is deliberate: a pattern\nthat does not serve one of those three jobs probably belongs in a different architecture.

\n

The list is not a claim to completeness. It is what is documented, and the honest test of\nany addition is whether there is an article behind it.

\n", "https://reference-architecture.ai/properties/date": "2026-09-08", "https://atomicdata.dev/properties/tags": {"categories":["Architecture"],"tags":["reference-architecture","patterns","agents","harnesses"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/docs/donate/", "https://atomicdata.dev/properties/name": "Support the project", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/docs/donate/", "https://atomicdata.dev/properties/description": "

The patterns described on this site are not theory. They are extracted from\nTerraphim, a privacy-first AI assistant built across 52 Rust\ncrates, and every one of those crates is open source.

\n

The most valuable support is use and scrutiny.

\n

Use it

\n\n

Contribute

\n

Issues, benchmarks and architecture critique are worth more than money here. If a\ntrade-off on this site looks wrong, say so — with evidence — at\ngithub.com/terraphim. Deployment guides and reproducible\nbenchmarks are especially welcome.

\n

Sponsor

\n

If your organisation depends on this work, Terraphim Pro funds\nthe open-source engine directly: connectors, an LLM proxy and agentic skills for\nenterprise deployment.

\n", "https://reference-architecture.ai/properties/date": "2026-09-08", "https://atomicdata.dev/properties/tags": {"categories":["donations","open-source"],"tags":["donate","support","terraphim"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/docs/legacy-capability-map/", "https://atomicdata.dev/properties/name": "Capability Map (2020-2022)", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/docs/legacy-capability-map/", "https://atomicdata.dev/properties/description": "

Introduction

\n

There are tools for advanced analytics, including free ones from Google and Kaggle.

\n

There are well-known and validated deployment architectures for applications and the cloud.

\n

Yet the number of practical applications is still tiny, and they retained niche implementations.\nWhile the benefits of AI are clear, there are still many gaps in AI architecture that need to be filled. For example, there is a gap between analytical tools and verified architectures for real-time deployments. This gap often stems from a lack of specific reference architectures and patterns, demonstrating the trade-offs between technologies, libraries, and tools.

\n

Let's bridge the gap in knowledge and drive a connection between science and engineering to make fast, efficient, and practical AI deployments.

\n

Three things need to be in place to build an AI product:

\n
    \n
  1. AI Product itself
  2. \n
  3. Core Capabilities required to build AI/ML product
  4. \n
  5. Enabling capabilities
  6. \n
\n

I will use The Pattern, my Build on Redis Hackathon prize-winning open source project to illustrate how the capabilities below can be implemented and invite you to contribute or donate.\nThe diagrams below are clickable.

\n

AI Product

\n

\n

Core capabilities for AI/ML

\n
\nflowchart LR; \nsubgraph \" \"\n  data_intake(Data Acquisition);\n  data_preprocessing(Data Preprocessing);\n  data_validation(Data Validation);\n  data_streaming(Data Streaming);\n  ai_ml_pipe(AI ML Pipeline 
Model Training/Test/Validation);\n kg(Knowledge Graph);\n ML_inference(ML Inference);\n interaction(Interaction Layer
Voice/VR/AR/Meta);\n click data_intake \"/docs/intake/\" \"Data Acquisition\"\n click ML_inference \"/docs/bert-qa-benchmarking/\" \"BERT Large Question Answering\"\n click kg \"/docs/nlp/#what-is-a-knowledge-graph\" \"Knowledge Graph\"\n click data_preprocessing \"/docs/nlp/#redisgears-for-nlp-pre-processing\" \"Data pre-processing\"\n click data_streaming \"/docs/nlp/#goal\" \"Data Streaming\"\n click ai_ml_pipe \"/docs/nlp/#overall-architecture-overview-components-diagram\" \"Overall ML pipeline\"\nend\n
\n

Enabling Capabilities

\n
\nflowchart LR;\nsubgraph 2 [Enabling Capabilities]\n  subgraph \" \"\nD1[Data Governance]\nD2[Data Quality Management]\nD3[Metadata Management]\nclick D3 \"/docs/metadata/\" \"Metadata Management\"\nend\nsubgraph \" \"\n  id2[ML performance and bias monitoring];\n  id3[Application Performance Monitoring];\n  id4[Hardware Performance Monitoring];\n  click id3 \"/docs/bert-qa-benchmarking/#running-the-benchmark\" \"Running Benchmarks\"\n  click id4 \"/docs/bert-qa-benchmarking/#using-grafana-to-monitor-redisgears-throughput-cpu-and-memory-usage\" \"CPU and Memory Benchmarks\"\nend\nsubgraph \" \"\n  id5[DevOps: Continuous Integration/Continuous Deployment];\n  c1[Configuration management]\n  c2[Collaboration and knowledge management tooling]\n  c3[Change Management]\nend \n  subgraph 3 [Self Serving Infrastructure]\n    s1[Computing Infrastructure]\n    s2[Serving infrastructure]\n  end\n  end\n  style 2 fill:#485fc754,stroke:#333,stroke-width:4px;\n
\n", "https://reference-architecture.ai/properties/date": "2022-06-16", "https://atomicdata.dev/properties/tags": {"categories":["Architecture"],"tags":["reference-architecture","ai-product"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/docs/bert-qa-benchmarking/", "https://atomicdata.dev/properties/name": "Benchmarks for BERT Large Question Answering inference for RedisAI and RedisGears", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/docs/bert-qa-benchmarking/", "https://atomicdata.dev/properties/description": "

Summary of the article

\n

This article will explore the challenges and opportunities of deploying a large BERT Question Answering Transformer model(bert-large-uncased-whole-word-masking-finetuned-squad) from inside Huggingface, where RedisGears and RedisAI perform heavy lifting while leveraging in-memory datastore Redis.

\n

Why do we need RedisAI?

\n\n

Some numbers for inspiration and why to read this article:

\n
python3 transformers_plain_bert_qa.py \nairborne transmission of respiratory infections is the lack of established methods for the detection of airborne respiratory microorganisms\n10.351818372 seconds
time curl -i -H "Content-Type: application/json" -X POST -d '{"search":"Who performs viral transmission among adults"}' http://localhost:8080/qasearch\n\nreal\t0m0.747s\nuser\t0m0.004s\nsys\t0m0.000s\n

Background

\n

BERT Question Answering inference works where the ML model selects an answer from the given text. In other words, BERT QA \"thinks\" through the following: \"What is the answer from the text, assuming the answer to the question exists within the paragraph selected.\"

\n

So it's important to select text potentially containing an answer. A typical pattern is to use Wikipedia data to build Open Domain Question Answering.

\n

Our QA system is a medical domain-specific question/answering pipeline, hence we need a first pipeline that turns data into a knowledge graph. This NLP pipeline is available at Redis LaunchPad, is fully open source, and is described in a previous article. Here is a 5 minute video describing it, and below you will find an architectural overview:

\n

\"featured\"

\n

BERT Question Answering pipeline and API

\n

In the BERT QA pipeline (or in any other modern NLP inference task), there are two steps:

\n
    \n
  1. Tokenize text - turn text into numbers
  2. \n
  3. Run the inference - large matrix multiplication
  4. \n
\n

With Redis, we have the opportunity to pre-compute everything and store it in memory, but how do we do it? Unlike with the summarization ML learning task, the question is not known in advance, so we can't pre-compute all possible answers. However, we can pre-tokenize all potential answers (i.e. all paragraphs in the dataset) using RedisGears:

\n
def parse_sentence(record):\n    import redisAI\n    import numpy as np\n    global tokenizer\n    if not tokenizer:\n        tokenizer=loadTokeniser()\n    hash_tag="{%s}" % hashtag()\n\n    for idx, value in sorted(record['value'].items(), key=lambda item: int(item[0])):\n        tokens = tokenizer.encode(value, add_special_tokens=False, max_length=511, truncation=True, return_tensors="np")\n        tokens = np.append(tokens,tokenizer.sep_token_id).astype(np.int64)\n        tensor=redisAI.createTensorFromBlob('INT64', tokens.shape, tokens.tobytes())\n\n        key_prefix='sentence:'\n        sentence_key=remove_prefix(record['key'],key_prefix)\n        token_key = f"tokenized:bert:qa:{sentence_key}:{idx}"\n        redisAI.setTensorInKey(token_key, tensor)\n        execute('SADD',f'processed_docs_stage3_tokenized{hash_tag}', token_key)\n
\n

See the full code on GitHub.

\n

Then for each Redis Cluster shard, we pre-load the BERT QA model by downloading, exporting it into torchscript, then loading it into each shard:

\n
def load_bert():\n    model_file = 'traced_bert_qa.pt'\n\n    with open(model_file, 'rb') as f:\n        model = f.read()\n    startup_nodes = [{"host": "127.0.0.1", "port": "30001"}, {"host": "127.0.0.1", "port":"30002"}, {"host":"127.0.0.1", "port":"30003"}]\n    cc = ClusterClient(startup_nodes = startup_nodes)\n    hash_tags = cc.execute_command("RG.PYEXECUTE",  "gb = GB('ShardsIDReader').map(lambda x:hashtag()).run()")[0]\n    print(hash_tags)\n    for hash_tag in hash_tags:\n        print("Loading model bert-qa{%s}" %hash_tag.decode('utf-8'))\n        cc.modelset('bert-qa{%s}' %hash_tag.decode('utf-8'), 'TORCH', 'CPU', model)\n        print(cc.infoget('bert-qa{%s}' %hash_tag.decode('utf-8')))
\n

The full code is available on GitHub.

\n

And when a question comes from the user, we tokenize and append the question to the list of potential answers before running the RedisAI model:

\n
    token_key = f"tokenized:bert:qa:{sentence_key}"\n    # encode question\n    input_ids_question = tokenizer.encode(question, add_special_tokens=True, truncation=True, return_tensors="np")\n    t=redisAI.getTensorFromKey(token_key)\n    input_ids_context=to_np(t,np.int64)\n    # merge (append) with potential answer, context - is pre-tokenized paragraph\n    input_ids = np.append(input_ids_question,input_ids_context)\n    attention_mask = np.array([[1]*len(input_ids)])\n    input_idss=np.array([input_ids])\n    num_seg_a=input_ids_question.shape[1]\n    num_seg_b=input_ids_context.shape[0]\n    token_type_ids = np.array([0]*num_seg_a + [1]*num_seg_b)\n    # create actual model runner for RedisAI\n    modelRunner = redisAI.createModelRunner(f'bert-qa{hash_tag}')\n    # make sure all types are correct\n    input_idss_ts=redisAI.createTensorFromBlob('INT64', input_idss.shape, input_idss.tobytes())\n    attention_mask_ts=redisAI.createTensorFromBlob('INT64', attention_mask.shape, attention_mask.tobytes())\n    token_type_ids_ts=redisAI.createTensorFromBlob('INT64', token_type_ids.shape, token_type_ids.tobytes())\n    redisAI.modelRunnerAddInput(modelRunner, 'input_ids', input_idss_ts)\n    redisAI.modelRunnerAddInput(modelRunner, 'attention_mask', attention_mask_ts)\n    redisAI.modelRunnerAddInput(modelRunner, 'token_type_ids', token_type_ids_ts)\n    redisAI.modelRunnerAddOutput(modelRunner, 'answer_start_scores')\n    redisAI.modelRunnerAddOutput(modelRunner, 'answer_end_scores')\n    # run RedisAI model runner\n    res = await redisAI.modelRunnerRunAsync(modelRunner)\n    answer_start_scores=to_np(res[0],np.float32)\n    answer_end_scores = to_np(res[1],np.float32)\n    answer_start = np.argmax(answer_start_scores)\n    answer_end = np.argmax(answer_end_scores) + 1\n    answer = tokenizer.convert_tokens_to_string(tokenizer.convert_ids_to_tokens(input_ids[answer_start:answer_end],skip_special_tokens = True))\n    log("Answer "+str(answer))\n    return answer\n
\n

Checkout the full code, available on GitHub.

\n

The process for making a BERT QA API call looks like this:

\n

\"Architecture

\n

Here I use two cool features of RedisGears: capturing events on key miss and using async/await to run RedisAI on each shard without locking the primary thread - so that Redis Cluster can continue to serve other customers. For benchmarks, caching responses from RedisAI is disabled. If you are getting response times in nanoseconds on the second call rather then milliseconds, check to make sure the line linked above is commented out.

\n

Running the Benchmark

\n

Pre-requisites for running the benchmark:

\n

Assuming you are running Debian or Ubuntu and have Docker and docker-compose installed (or can create a virtual environment via conda), run the following commands:

\n
git clone --recurse-submodules https://github.com/applied-knowledge-systems/the-pattern.git\ncd the-pattern\n./bootstrap_benchmark.sh
\n

The above commands should end with a curl call to the qasearch API, since Redis caching is disabled for the benchmark.

\n

Next, invoke curl like this:

\n
time curl -i -H "Content-Type: application/json" -X POST -d '{"search":"Who performs viral transmission among adults"}' http://localhost:8080/qasearch
\n

Expect the following output, or something similar based on your runtime environment:

\n
HTTP/1.1 200 OK\nServer: nginx/1.18.0 (Ubuntu)\nDate: Sun, 29 May 2022 12:05:39 GMT\nContent-Type: application/json\nContent-Length: 2120\nConnection: keep-alive\n\n{"links":[{"created_at":"2002","rank":13,"source":"C0001486","target":"C0152083"}],"results":[{"answer":"adenovirus","sentence":"The medium of 40 T150 flasks of adenovirus transducer dec CAR CHO cells yielded 0 5 1 my of purified msCEACAM1a 1 4 protein","sentencekey":"sentence:PMC125375.xml:{mG}:202","title":"Crystal structure of murine sCEACAM1a[1,4]: a coronavirus receptor in the CEA family"}] OUTPUT_REDUCTED}
\n

I modified the output of API for the benchmark to return results from all shards - even if the answer is empty, in the run above five shards return answers, overall API call response under second with all additional hops to search in RedisGraph.

\n

I modified the output of the API for the benchmark to return results from all shards - even if the answer is empty. In the run above five shards return answers. The overall API call response takes less than one second with all additional hops to search in RedisGraph!

\n

\"Architecture

\n

Deep Dive into the Benchmark

\n

Let's dig deeper into what's happening under the hood:

\n

You should have a sentence key with shard id, which you get by looking at the \"Cache key\" from docker logs -f rgcluster. In my setup the cache key is, \"bertqa{6fd}_PMC169038.xml:{6fd}:33_Who performs viral transmission among adults\". If you think it looks like a function call it's because it is a function call. It is triggered if the key isn't present in the Redis Cluster, which for the benchmark will be every time since if you remember we disabled caching the output.

\n

One more thing to figure out from the logs is the port of the shard corresponding to the hashtag, also known as the shard id. It is the text found in betweeen the curly brackets – looks like {6fd} above. The same will be in the output for the export_load script. In my case the cache key was found in \"30012.log\", so my port is 30012.

\n

Next I run the following command:

\n
redis-cli -c -p 300012 -h 127.0.0.1 get "bertqa{6fd}_PMC169038.xml:{6fd}:33_Who performs viral transmission among adults"
\n

and then run the benchmark:

\n
redis-benchmark -p 30012 -h 127.0.0.1 -n 10 get "bertqa{6fd}_PMC169038.xml:{6fd}:33_Who performs viral transmission among adults"\n====== get bertqa{6fd}_PMC169038.xml:{6fd}:33_Who performs viral transmission among adults ======\n  10 requests completed in 0.04 seconds\n  50 parallel clients\n  3 bytes payload\n  keep alive: 1\n\n10.00% <= 41 milliseconds\n100.00% <= 41 milliseconds\n238.10 requests per second
\n

If you are wondering, -n = number of times. In this case we run the benchmark 10 times. You can also add:

\n

– csv if you want to output in CSV format

\n

– precision 3 if you want more decimals in the ms

\n

More information about the benchmarking tool can be found on the redis.io Benchmarks page.

\n

if you don't have redis-utils installed locally, you can use Docker as follows:

\n
docker exec -it rgcluster /bin/bash\nredis-benchmark -p 30012 -h 127.0.0.1 -n 10 get "bertqa{6fd}_PMC169038.xml:{6fd}:33_Who performs viral transmission among adults"\n====== get bertqa{6fd}_PMC169038.xml:{6fd}:33_Who performs viral transmission among adults ======\n  10 requests completed in 1.75 seconds\n  50 parallel clients\n  99 bytes payload\n  keep alive: 1\n  host configuration "save":\n  host configuration "appendonly": no\n  multi-thread: no\n\nLatency by percentile distribution:\n0.000% <= 243.711 milliseconds (cumulative count 1)\n50.000% <= 987.135 milliseconds (cumulative count 5)\n75.000% <= 1577.983 milliseconds (cumulative count 8)\n87.500% <= 1662.975 milliseconds (cumulative count 9)\n93.750% <= 1744.895 milliseconds (cumulative count 10)\n100.000% <= 1744.895 milliseconds (cumulative count 10)\n\nCumulative distribution of latencies:\n0.000% <= 0.103 milliseconds (cumulative count 0)\n10.000% <= 244.223 milliseconds (cumulative count 1)\n20.000% <= 409.343 milliseconds (cumulative count 2)\n30.000% <= 575.487 milliseconds (cumulative count 3)\n40.000% <= 821.247 milliseconds (cumulative count 4)\n50.000% <= 987.135 milliseconds (cumulative count 5)\n60.000% <= 1157.119 milliseconds (cumulative count 6)\n70.000% <= 1497.087 milliseconds (cumulative count 7)\n80.000% <= 1577.983 milliseconds (cumulative count 8)\n90.000% <= 1662.975 milliseconds (cumulative count 9)\n100.000% <= 1744.895 milliseconds (cumulative count 10)\n\nSummary:\n  throughput summary: 5.73 requests per second\n  latency summary (msec):\n          avg       min       p50       p95       p99       max\n     1067.296   243.584   987.135  1744.895  1744.895  1744.895
\n

The platform only has 20 articles and 8 Redis nodes (4 masters + 4 slaves), so relevance would be wrong and it doesn't need a lot of memory.

\n

AI.INFO

\n

Now let's check how long our RedisAI model runs on the {6fd} shard:

\n
127.0.0.1:30012> AI.INFO bert-qa{6fd}\n 1) "key"\n 2) "bert-qa{6fd}"\n 3) "type"\n 4) "MODEL"\n 5) "backend"\n 6) "TORCH"\n 7) "device"\n 8) "CPU"\n 9) "tag"\n10) ""\n11) "duration"\n12) (integer) 8928136\n13) "samples"\n14) (integer) 58\n15) "calls"\n16) (integer) 58\n17) "errors"\n18) (integer) 0\n
\n

bert-qa{6fd} is the key of the actual (very large) model saved. The AI.INFO command gives us a cumulative duration of 8928136 microseconds and 58 calls, which is approximately 153 milliseconds per call.

\n

Let's double-check to make sure that's right by resetting the stats and then re-runnning the benchmark.

\n

First, reset the stats:

\n
127.0.0.1:30012> AI.INFO bert-qa{6fd} RESETSTAT\nOK\n127.0.0.1:30012> AI.INFO bert-qa{6fd}\n 1) "key"\n 2) "bert-qa{6fd}"\n 3) "type"\n 4) "MODEL"\n 5) "backend"\n 6) "TORCH"\n 7) "device"\n 8) "CPU"\n 9) "tag"\n10) ""\n11) "duration"\n12) (integer) 0\n13) "samples"\n14) (integer) 0\n15) "calls"\n16) (integer) 0\n17) "errors"\n18) (integer) 0
\n

Then, re-run the benchmark:

\n
redis-benchmark -p 30012 -h 127.0.0.1 -n 10 get "bertqa{6fd}_PMC169038.xml:{6fd}:33_Who performs viral transmission among adults"\n====== get bertqa{6fd}_PMC169038.xml:{6fd}:33_Who performs viral transmission among adults ======\n  10 requests completed in 1.78 seconds\n  50 parallel clients\n  99 bytes payload\n  keep alive: 1\n  host configuration "save":\n  host configuration "appendonly": no\n  multi-thread: no\n\nLatency by percentile distribution:\n0.000% <= 188.927 milliseconds (cumulative count 1)\n50.000% <= 995.839 milliseconds (cumulative count 5)\n75.000% <= 1606.655 milliseconds (cumulative count 8)\n87.500% <= 1692.671 milliseconds (cumulative count 9)\n93.750% <= 1779.711 milliseconds (cumulative count 10)\n100.000% <= 1779.711 milliseconds (cumulative count 10)\n\nCumulative distribution of latencies:\n0.000% <= 0.103 milliseconds (cumulative count 0)\n10.000% <= 189.183 milliseconds (cumulative count 1)\n20.000% <= 392.191 milliseconds (cumulative count 2)\n30.000% <= 540.159 milliseconds (cumulative count 3)\n40.000% <= 896.511 milliseconds (cumulative count 4)\n50.000% <= 996.351 milliseconds (cumulative count 5)\n60.000% <= 1260.543 milliseconds (cumulative count 6)\n70.000% <= 1456.127 milliseconds (cumulative count 7)\n80.000% <= 1606.655 milliseconds (cumulative count 8)\n90.000% <= 1692.671 milliseconds (cumulative count 9)\n100.000% <= 1779.711 milliseconds (cumulative count 10)\n\nSummary:\n  throughput summary: 5.62 requests per second\n  latency summary (msec):\n          avg       min       p50       p95       p99       max\n     1080.454   188.800   995.839  1779.711  1779.711  1779.711
\n

Now check the stats again:

\n
AI.INFO bert-qa{6fd}\n 1) "key"\n 2) "bert-qa{6fd}"\n 3) "type"\n 4) "MODEL"\n 5) "backend"\n 6) "TORCH"\n 7) "device"\n 8) "CPU"\n 9) "tag"\n10) ""\n11) "duration"\n12) (integer) 1767749\n13) "samples"\n14) (integer) 20\n15) "calls"\n16) (integer) 20\n17) "errors"\n18) (integer) 0
\n

Now we get 88387.45 microseconds per call ~0.088387 seconds, which is pretty fast! Also, considering we started with 10 seconds per call, I think the benefits of using RedisAI in combination with RedisGears are pretty obvious. However, the trade-off is high memory usage.

\n

There are many ways to optimize this deployment. For example, you can add a FP16 quantization and ONNX runtime. If you would like to try that, this script will be a good starting point.

\n

Using Grafana to monitor RedisGears throughput, CPU, and Memory usage

\n

Thanks to the contribution of Mikhail Volkov, we can now observe RedisGears and RedisGraph throughput and memory consumption using Grafana. When you cloned repository it started Graphana Docker, which has pre-build templates to monitor RedisCluster, including RedisGears and RedisAI, and Graph - which is Redis with RedisGraph. \"The Pattern\" dashboard provides an overview, with all the key benchmark metrics you care about:

\n

\"Grafana

\n

\"Grafana

\n

This post is in collaboration with Redis.

\n", "https://reference-architecture.ai/properties/date": "2022-06-16", "https://atomicdata.dev/properties/tags": {"categories":["inference","performance","monitoring"],"tags":["redis","redis-cluster","redisai","redisgears","benchmark","performance","benchmarks"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/docs/nlp/", "https://atomicdata.dev/properties/name": "Building a Pipeline for Natural Language Processing using RedisGears", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/docs/nlp/", "https://atomicdata.dev/properties/description": "

Goal

\n

Disclaimer originally published in collaboration with Ajeet Raina on Developer.Redis.Com

\n

In this tutorial, you will learn how to build a pipeline for Natural Language Processing(NLP) using RedisGears. For this demonstration, we will be leveraging the Kaggle CORD19 datasets. The implementation is designed to avoid running out of memory, leveraging Redis Cluster and RedisGears, where the use of RedisGears allows for processing data on storage without the need to move data in and out of the Redis Cluster—using Redis Cluster as data fabric. Redis Cluster allows for horizontal scalability up to 1000 nodes, and together with RedisGears, provides a distributed system where data science/ML engineers can focus on processing steps, without the worry of writing tons of scaffoldings for distributed calculations.

\n

\"nlp\"

\n

This project was built with the aim to make it easier for other people to contribute and build better information and knowledge management products.

\n

Why data scientists uses RedisGears?

\n

RedisGears have enormous potential, particularly for text processing—you can process your data “on data” without needing to move them in and out of memory. Summary of the important points:

\n\n

What is a knowledge graph?

\n

Today, we live in the world of new systems that operate not just files, folders, or web pages, but entities with their properties and relationships between them, organized into hierarchies of classes and categories. These systems are used everywhere from the military-industrial complex to our everyday lives. Palantir, Primer, and other data companies enable massive intelligence and counterintelligence projects in military and security forces, Quid and RecordedFuture enable competitive analytics, Bottlenose and similar enterprises enable online reputation analytics. Microsoft Graph enables new kinds of productivity apps for the enterprises, Google Knowledge Graph and Microsoft’s Satori enable everyday search queries, and together with Amazon Information Graph they power corresponding AI assistants by enabling them to answer questions about the world facts

\n

All these (and many other more specialized) systems are used in different domains, but all of them use Knowledge Graphs as their foundation.

\n

Knowledge graphs are one of the best ways to connect and make sense out of information from different data sources, following the motto of one of the vendors— “It’s about things not strings”.

\n

Knowledge Graph consists of thesaurus, taxonomy and ontology. In this pipeline I assume knowledge is captured in medical metathesaurus UMLS and concepts in text are related if they are part of the same sentence, therefore concept become node, their relationship becomes edge:

\n

\"concepts1\"\n\"concepts2\"

\n

Concepts have CUI (Concept Unique Identifiers) and those will be primary keys in nodes, linked to UMLS thesaurus. For example, if you search, “How does temperature and humidity affect the transmission of 2019-nCoV?” on the demo website http://thepattern.digital/ and move slider to 1996, there is an edge-connecting transmission (C5190195) and birth (C5195639) and the part of sentence matched, “the rate of transmission to an infant born to,” from the report titled, “Afebrile Pneumonia in infants.”

\n

\"concepts3\"

\n

RedisGears for NLP pre-processing

\n

Overall Architecture Overview (Components Diagram)

\n

\"component_diagram\"

\n

Intake step - is very simple put all JSON records into RedisCluster, then NLP pipeline starts processing all records, code is here.

\n

How does the NLP pipeline steps fit into RedisGears?

\n
    \n
  1. \n

    For each record — detect language (discard non English), it’s filter

    \n
  2. \n
  3. \n

    Map paragraphs into a sentence — flatmap

    \n
  4. \n
  5. \n

    Sentences spellchecker — it’s map

    \n
  6. \n
  7. \n

    Save sentences into hash — processor

    \n
  8. \n
\n

Step 1. Pre-requisite

\n

Ensure that you install virtualenv in your system

\n

Step 2. Clone the repository

\n
 git clone --recurse-submodules https://github.com/applied-knowledge-systems/the-pattern.git\n cd the-pattern

Step 3. Bring up the application

\n
 docker-compose -f docker-compose.dev.yml up --build -d

Step 4. Apply cluster configuration settings

\n

You can deploy PyTorch and spacy to run on RedisGears.

\n
 bash post_start_dev.sh
\n

For Data science-focused deployment, RedisCluster should be in HA mode with at least one slave for each master.\nOne need to change a few default parameters for rgcluster to accommodate the size of PyTorch and spacy libraries (each over 1GB zipped), gist with settings.

\n

Step 5. Create or activate Python virtual environment

\n
 cd ./the-pattern-platform/

Step 6. Create new environment

\n

You can create it via

\n
 conda create -n pattern_env python=3.8
\n

or

\n

Alternatively, you can activate by using the below CLI:

\n
 source ~/venv_cord19/bin/activate #or create new venv\n pip install -r requirements.txt

Step 7. Run pipeline

\n
 bash cluster_pipeline.sh

Step 8. Validating the functionality of the NLP pipeline

\n

Wait for a bit and then check:

\n

Verifying Redis Graph populated:

\n
 redis-cli -p 9001 -h 127.0.0.1 GRAPH.QUERY cord19medical "MATCH (n:entity) RETURN count(n) as entity_count" \n redis-cli -p 9001 -h 127.0.0.1 GRAPH.QUERY cord19medical "MATCH (e:entity)-[r]->(t:entity) RETURN count(r) as edge_count"

Checking API responds:

\n
 curl -i -H "Content-Type: application/json" -X POST -d '{"search":"How does temperature and humidity affect the transmission of 2019-nCoV"}'      \n http://localhost:8080/gsearch

Walkthrough

\n

While RedisGears allows to deploy and run Machine Learning libraries like spacy and BERT transformers, the solution above uses simpler approach:

\n
 gb = GB('KeysReader')\n gb.filter(filter_language)\n gb.flatmap(parse_paragraphs)\n gb.map(spellcheck_sentences)\n gb.foreach(save_sentences)\n gb.count()\n gb.register('paragraphs:*',keyTypes=['string','hash'], mode="async_local")
\n

This is the overall pipeline: those 7 lines allow you to run logic in a distributed cluster or on a single machine using all available CPUs - no changes required until you need to scale over more 1000 nodes. I use KeysReader registered for namespace paragraphs for all strings or hashes. My pipeline would need to run in async mode. For data scientists, I would recommend using gb.run to make sure gears function work and it will run in batch mode and then change it to register - to capture new data. By default, functions will return output, hence the need for count() - to prevent fetching the whole dataset back to the command issuing machine (90 GB for Cord19).

\n

Overall pre-processing is a straightforward - full code is here.

\n

Things to keep in mind:

\n
    \n
  1. Node process can only save locally - we don't move data, anything you want to save should have hashtag, for example to add to the set of processed_docs:
  2. \n
\n
 execute('SADD','processed_docs_{%s}' % hashtag(),article_id)
\n
    \n
  1. Loading external libraries into the computational threat, for example, symspell requires additional dictionaries and needs two steps to load:
  2. \n
\n
 """\n load symspell and relevant dictionaries\n """\n sym_spell=None \n\n def load_symspell():\n  import pkg_resources\n  from symspellpy import SymSpell, Verbosity\n  sym_spell = SymSpell(max_dictionary_edit_distance=1, prefix_length=7)\n  dictionary_path = pkg_resources.resource_filename(\n      "symspellpy", "frequency_dictionary_en_82_765.txt")\n  bigram_path = pkg_resources.resource_filename(\n      "symspellpy", "frequency_bigramdictionary_en_243_342.txt")\n  # term_index is the column of the term and count_index is the\n  # column of the term frequency\n  sym_spell.load_dictionary(dictionary_path, term_index=0, count_index=1)\n  sym_spell.load_bigram_dictionary(bigram_path, term_index=0, count_index=2)\n  return sym_spell
\n
    \n
  1. Scispacy is a great library and data science tool, but after a few iterations with deploying it I ended up reading data model documentation for UMLS Methathesaurus and decided to build Aho-Corasick automata directly from UMLS data. (MRXW_ENG.RRF contains all terms form for English mapped to CUI). Aho-Corasick allowed me to match incoming sentences into pairs of nodes (concepts from the medical dictionary) and present sentences as edges in a graph, Gears related code is simple:
  2. \n
\n
 bg = GearsBuilder('KeysReader')\n bg.foreach(process_item)\n bg.count()\n bg.register('sentence:*',  mode="async_local",onRegistered=OnRegisteredAutomata)\n
\n

OnRegisteredAutomata will perform similarly to symspell example above except it will download pre-build Aho-Corasick automata (30Mb).\nAho-Corasick is a very fast matcher and allows to perform >900 Mb text per second even on commodity laptop, RedisGears cluster makes a very smooth distribution of data and ML model and matching using available CPU and Memory. Full matcher code.

\n

Output of the matcher: nodes and edges are candidates to use another RedisGears pattern rgsync where you can write fast into Redis and RedisGears are going to replicate data into slower storage using RedisStreams.\nBut I decided to use streams and handcraft the population of the RedisGraph database, which will be focus of the next blog post.

\n

Output of the matcher: nodes and edges are candidates to use another RedisGears pattern rgsync where you can write fast into Redis and RedisGears are going to replicate data into slower storage using RedisStreams, while this demo uses streams and populates RedisGraph database with nodes and edges calculating rank of each.

\n

Call to action

\n

We took OCR scans in JSON format and turned them into Knowledge Graph, demonstrating how you can traditional Semantic Network/OWL/Methathesaurus technique based on Unified Medical Language System. Redis Ecosystem offers a lot to the data science community, and can take place at the core of Kaggle notebooks, ML frameworks and make deployment and distribution of data more enjoyable. The success of our industry depends on how our tools work together — regardless of whether they are engineering, data science, machine learning and organisational or architectural.

\n

With the collaboration of RedisLabs and community, the full pipeline code is available via https://github.com/applied-knowledge-systems/the-pattern-platform. In case, you want to try it locally, then you can find a Docker Launch script in the root of the repository along with short quickstart guide. PR and suggestions are welcome. The overall goal of the project is to allow other to build their more interesting pipeline on top of it.

\n

References

\n\n", "https://reference-architecture.ai/properties/date": "2022-05-28", "https://atomicdata.dev/properties/tags": {"categories":["redisgears","knowledge-graphs","performance"],"tags":["redis","redis-cluster","redisgears","nlp","redisgraph"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/docs/metadata/", "https://atomicdata.dev/properties/name": "Metadata Management", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/docs/metadata/", "https://atomicdata.dev/properties/description": "

In CORD 19 dataset mentioned in Data Acquisition Metadata stored in the separate csv file from the source data. Here simple script to parse date/times and attach it to JSON/XML files

\n", "https://reference-architecture.ai/properties/date": "2022-05-14", "https://atomicdata.dev/properties/tags": {"categories":["metadata"],"tags":["data","metadata"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/docs/contribution/", "https://atomicdata.dev/properties/name": "Contribution Guidelines", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/docs/contribution/", "https://atomicdata.dev/properties/description": "

General guidelines for contributing to the project.

\n

Main goals

\n

Be data-driven

\n\n

Engineering approach

\n

There should be a a path to be implemented in a real world - good prototype or production deployment.

\n

How to contribute

\n

Welcome pull requests on \n\n\n\n. Check out supported shortcuts Extended Shortcuts

\n

Licenses

\n

When contributing you agreeing to share your contribution under

\n", "https://reference-architecture.ai/properties/date": "2021-12-15", "https://atomicdata.dev/properties/tags": {"categories":["Documentation"],"tags":["contribute","zola"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/docs/intake/", "https://atomicdata.dev/properties/name": "Data Acquisition", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/docs/intake/", "https://atomicdata.dev/properties/description": "

For the Reference Architecture for AI, we used Kaggle Cord19 dataset, \"COVID-19 Open Research Dataset (CORD-19). CORD-19 is a resource of over 1,000,000 scholarly articles, including over 400,000 with full text, about COVID-19, SARS-CoV-2, and related coronaviruses. This freely available dataset is provided to the global research community to apply recent advances in natural language processing and other AI techniques to generate new insights in support of the ongoing fight against this infectious disease.\"

\n

Ingest documents

\n

Example script parses documents taking out body_text and saves under paragraphs in Redis cluster.

\n", "https://reference-architecture.ai/properties/date": "2020-08-31", "https://atomicdata.dev/properties/tags": {"categories":["intake","data acquisition"],"tags":["data","acquisition","intake"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] },{"localId": "https://reference-architecture.ai/docs/ai-product/", "https://atomicdata.dev/properties/name": "The Pattern: Machine Learning Natural Language Processing meets VR/AR", "https://reference-architecture.ai/properties/url": "https://reference-architecture.ai/docs/ai-product/", "https://atomicdata.dev/properties/description": "

To fight ever-increasing complexity, \"The Pattern\" projects help find relevant knowledge using Artificial Intelligence and novel UX elements, all powered by Redis - a new generation real-time data fabric turned into knowledge fabric

\n

Overall repository for CORD19 medical NLP pipeline, API and UI, design and architecture.

\n

Demo Video:

\n
\n \n
\n

Demo Server (no persistance): https://thepattern.digital/

\n

The challenge

\n

The medical profession put a lot of effort into collaboration, starting from Latin as a common language to industry-wide thesauruses like UMLS. However, if full of scandals where publications in a prestigious journal would be retracted, and the World Health Organisation would change its policy advice based on the article. I think \"paper claiming that eating a bat-like Pokémon sparked the spread of COVID-19\" takes a prize. One would say that editors in those journals don't do their job, and while it may seem true, I would say they had no chance: with a number of publications about COVID (SARS-V) passing 300+ per day, we need better tools to navigate via such flow of information.\nWhen exploring science or engineering topics, I look at the diversity of the opinion, not the variety of the same cluster of words or the same thought. I want to avoid confirmation bias. I want to find articles relevant to the same concept, not necessarily the ones which have similar words. My focus is to build a natural language processing pipeline capable of handling a large number of documents and concepts, incorporating System 1 AI (fast, intuitive reasoning) and System 2 (high-level reasoning) and then present knowledge in a modern VR/AR visualisation. Search or rather information exploration should be spatial, preferably in VR (memory palace, see Theatre of Giulio Camillo). A force-directed graph is a path towards it, where visuals are assisted by text — relevant text pops up on the connection and where people explore the concepts and then dig deeper into the text. The purpose of the pipeline is that knowledge should be reusable and shareable.

\n

Community

\n

Join our community on Discord or post on GitHub Discussions](https://github.com/applied-knowledge-systems/the-pattern/discussions)

\n", "https://reference-architecture.ai/properties/date": "2020-08-31", "https://atomicdata.dev/properties/tags": {"categories":["ai product","nlp","medical"],"tags":["ai product","ai","medical"]}, "https://atomicdata.dev/properties/isA": ["https://atomicdata.dev/classes/Article"] }]