Knowledge: what a source is used for
The knowledge pages say what a repository or source holds, and also whether it is used and whether it can be trusted. This guide covers the records behind those figures. How sources are crawled, imported and indexed is in web knowledge and retrieval.
Categories
A repository says what kind of knowledge it holds (knowledge_repositories.category, migration 112). The kind decides how an agent uses it, so it is the first thing a person chooses when making one. There are three, a vocabulary both services carry byte for byte (app/util/knowledge_categories.py, held by tools/test_shared_modules.py):
| Category | What it holds | What an agent does with it |
|---|---|---|
temporal | Time-sensitive information: news, updates, releases, announcements. | Reads it newest first within a window, searches it whenever a request is about what is current, and never keeps an answer resting on it as a memory. |
reasoning | Analytical and decision frameworks: methods, criteria, checklists, decision models. | Applies it when a request calls for analysis or a decision, as the approach to take rather than as facts. |
How retrieval treats each is in retrieval.
What is not a category
Every other kind of context an agent draws on already has a feature that owns it, and making it a repository kind would give it two homes:
| Kind of context | Its home |
|---|---|
| Context: the conversation and what is attached to it | The chat, and its attachments |
| Episodes: what it did and how it went | Its memory, and the decision record |
| Operations: what it can call or look up live | Its tools |
| Norms: what it may and may not do | Governance rules, access levels, and its instructions |
A policy document people ask about is still Domain knowledge. A rule the agent must obey is a Governance rule. The category picker says so under its three cards (knowledge/categories.ts OWNED_ELSEWHERE).
What an agent draws on
An agent's page shows all eight kinds at once, each from the feature that owns it (app/services/agent_context, GET /app/agents/{id}/knowledge-kinds, October 2026). Each kind is one class registered with register_kind, read in this order:
| Kind | What it reads | State | Where it is changed |
|---|---|---|---|
| Procedural | Its skills, through its skillsets; the one it answers through (_load_agent_skills) | present, or missing | The Skillsets tab |
| Contextual | The conversation and its attachments, always; whether it asks first (clarify_scope) | present | Its Human in the loop setting, on the same page (the row has no link) |
| Episodic | What it remembers of the viewer (svc-ai's memory summary, the viewer's own), and the decision record | present, missing, or unavailable when svc-ai cannot say | The Memory tab |
| Operational | svc-ai's built-in tools, bound to every agent | present, or unavailable | The Tools tab |
| Normative | The rules the engine applies to its turns in this workspace (rule_engine._get_applicable_rules over its invocation_chain, every layer), and whether it has instructions of its own | present, or missing | Governance → Rules |
A kind's state is a meaning (fe-core AGENT_CONTEXT): having none is neutral, never a warning, since an agent may not need a kind, and what svc-ai could not say is set aside. fe-core's agents/agent/AgentContextPanel.tsx draws the panel above the agent's tabs. Its icons and states are pinned to the registry by agentContext.test.ts.
One kind per source
A source belongs to repositories of one kind only, so every knowledge base reaches an agent as exactly one. services/knowledge/repositories.py enforces this:
require_one_categoryraisesCategoryConflict(409) wherever a source joins a repository or a repository's kind changes:adding a source;
a
PATCHnaming a newcategory, which checks every member against its other holders;knowledge setup's
create-from-config;agent setup's
create-from-config, whererequire_one_category_withinalso catches one new source in two new repositories of different kinds.
The message names the other repository only when the caller may read it. Otherwise it says "a … repository in another workspace".
A built-in source's kind is its built-in repository's. Any workspace may put a News feed in a repository of its own. Counting those would let one workspace decide the feed's kind for everyone, so the rule reads a built-in source through built-in repositories only.
categories_ofreads each knowledge base's kind: through an agent's grants (every granted repository counts), or as the rule does. A source held by none is Domain. A source held by two kinds can only be a legacy row from before migration 112. It reads as Domain, how it was used, and is logged.joinableis what the source map offers as suggestions, so "Add to repository" is never refused. fe-core'sheldAs/mayJoinfilter the Add source menus the same way.
Migration 112 sets every repository to Domain except a person's or workspace's whose sources are all built-in website sources, the News feeds, which can only be held as Temporal. A repository mixing News feeds with its own sources stays Domain. Built-in repositories take their kind from SystemRepositorySpec.category (News: Temporal, the guide: Domain), and provisioning versions the change as a release.
On the pages
The category picker (
knowledge/CategoryPicker.tsx) offers one card per kind: what it holds, what an agent does with it, and examples. It is used in the repository's create and edit dialog (RepositoryDetailsModal), and a refused change says why in the dialog.The badge (
cardParts.CategoryBadge) is a neutral chip with the kind's icon, explained on hover. A category is what a repository is for, not a status, so it never takes a status tone.Knowledge → Repositories lists the workspace's own repositories in a section per kind, each section's hint saying what the kind holds. A kind with none says what it would add and offers New … repository of that kind. Before the first repository, one "Your repositories" section says how to start.
The agent's Knowledge tab groups what it is granted by kind and says when a kind is missing. Its Attach picker groups repositories the same way.
New agent now lists the built-in repositories too.
Generating one starts from its kind (W2): the wizard's picker, each kind's starter descriptions, an empty section's Generate, and Generate its updates once a Domain or Reasoning repository is made. See web knowledge.
GET /app/repositories/categoriesserves the catalogue. fe-core'sknowledge/categories.tsholds the same keys, labels, purposes and uses, pinned bycategories.test.ts.
Built-in knowledge
CHAIN-R provides repositories every user can grant to their own agents, so each kind of knowledge can be tried before anyone writes their own (October 2026). They are system rows: owned by nobody, readable by everyone, editable by none; a release is the only way one changes, and each change is a version with no actor (CHAINR Bot).
One registry
app/services/system_resources/knowledge.py declares every built-in repository as a BuiltInRepository:
| Field | What it says |
|---|---|
sources | Exactly the sources it holds. Provisioning adds what is missing and removes what a release dropped, versioning the repository. |
switch | The setting that turns it off (BUILT_IN_NEWS_ENABLED, BUILT_IN_WEB_KNOWLEDGE_ENABLED), or none. Off, it is neither provisioned, crawled nor offered. Rows already written stay. |
grantable | Whether users may grant it. Only the CHAIN-R User Guide is not: it is CHAINR Bot's, provisioned with the bot. |
topics | Words a question about its subject tends to use: what a recommendation matches an agent's questions on before suggesting it. |
Everything that treats built-in knowledge differently reads the registry rather than naming a repository:
provisioning (
provision._provision_repository);the written sync;
the crawler's gate (
web_crawl.due_sourcesviacrawl_enabled: a built-in website source is crawled only while its repository is provided and an agent that is not built in holds it);the source figures' next crawl;
the trust panel's licence signal;
the agent setup catalogue (every enabled grantable built-in, by reference);
the recommendations (News for questions about what is current).
A source no release declares any more is never crawled and claims no terms check.
Two kinds of source
Written by CHAIN-R (
WrittenSourceSpec): a folder of markdown shipped in the image, one document per file.system_resources/written.py(sync_written, run by the hourlychainr_bot_syncjob) indexes each through the same path an upload takes, keyed by filename and content hash: an unchanged source costs one hash per file, a changed document is re-indexed with its old chunks dropped, a removed one is removed, and one that failed is retried next run. The guide is the first written source. Nothing is fetched from anyone. Its trust panel's licence reads met, "Written by CHAIN-R", with its credits.From a publisher: a website source read from the publisher's own site under a licence that permits commercial reuse (
system_resources/licences.py, one registry for every such source), with the credit the publisher asks for on every passage and the date its terms were last checked (terms_checked). Either a feed (news.NewsSourceSpec: News, and Regulation & security updates) or reference pages (publishers.PageSourceSpec: listed pages or the section below them, read weekly, kept whole). See News for the rules every one follows.
What there is
| Repository | Kind | Holds |
|---|---|---|
| AI & data protection law | Domain | The UK GDPR and the Data Protection Act 2018 (legislation.gov.uk), ICO guidance on data protection and AI, and the NIST AI Risk Management Framework with its Playbook. |
| Security guidance | Domain | NCSC guidance (10 Steps, cloud security, secure AI system development) and the NIST Cybersecurity Framework. |
| News | Temporal | Openly licensed news feeds, the last 30 days (News). |
| Regulation & security updates | Temporal | NCSC news and blog, and GOV.UK's DSIT and AI Security Institute feeds, the last 30 days. |
| Systems thinking | Reasoning | Systems and their parts; stocks, flows and delays; feedback loops and causal loop diagrams; the iceberg model; leverage points; system archetypes; second-order effects; boundaries and perspectives (CATWOE). |
| Delivery lifecycles | Reasoning | Choosing a delivery lifecycle; waterfall; V-model; incremental and iterative delivery; spiral model; agile principles; Scrum; Kanban and flow; lean and waste; phase-gate reviews; continuous delivery and DevOps; prioritising scope; planning and estimating. |
| Problem solving & decisions | Reasoning | Framing a problem; issue trees; hypothesis-driven analysis; five whys; fishbone diagram; plan-do-check-act; DMAIC; weighted decision matrix; cost–benefit analysis; decision trees and expected value; reversible and irreversible decisions; pre-mortem; urgent and important; first principles and inversion; OODA loop. |
| Evidence & critical thinking | Reasoning | Facts, assumptions and judgements; evaluating a source; argument structure; common fallacies; cognitive biases; base rates and Bayesian updating; correlation and causation; competing hypotheses; Fermi estimates; reading statistics; expressing uncertainty (the UK probability yardstick). |
| Risk & assurance | Reasoning | The risk assessment cycle; likelihood–impact matrices; failure mode and effects analysis; bow-tie analysis; fault tree analysis; defence in depth; STRIDE threat modelling; control types and effectiveness; reasoning through a DPIA; AI risk management (after the NIST AI RMF); business impact analysis; blameless post-incident review. |
| Strategy & environment | Reasoning | PESTLE analysis; SWOT analysis; five forces; scenario planning; stakeholder mapping; theory of change; value chains and user needs; objectives and key results. |
Read from publishers
system_resources/publishers.py (October 2026) holds the three built-ins read from publishers beyond News. Each address was probed through svc-ai's own fetcher (robots.txt, extraction, feed parsing) before it was added, and each publisher's terms were read on its own site (TERMS_CHECKED, 27 October 2026). All three are off with BUILT_IN_WEB_KNOWLEDGE_ENABLED=false, and crawled only while an agent that is not built in holds them.
| Source | Publisher's terms | Licence | How it is read |
|---|---|---|---|
| Data Protection Act 2018 | legislation.gov.uk | OGL v3.0 | Parts 1, 2, 5 and 6 and Schedules 1 and 2, six pages, weekly |
| ICO guidance on data protection and AI | ICO | OGL v3.0 for text (images are not licensed, and are not kept); credited as the ICO asks | Six guides and the pages below them, ≤ 80 pages, weekly |
| NIST AI Risk Management Framework | NIST | US public domain | The AI RMF and its Playbook on airc.nist.gov, ≤ 60 pages, weekly |
| NCSC guidance | NCSC | OGL v3.0 (third-party images and logos excluded) | Three collections, ≤ 80 pages, weekly |
| NIST Cybersecurity Framework | NIST | US public domain | The section, ≤ 40 pages, weekly |
| NCSC news, NCSC blog | NCSC | OGL v3.0 | Feeds, hourly, 30 days |
| GOV.UK: DSIT, AI Security Institute | GOV.UK | OGL v3.0 | Feeds, hourly, 30 days |
legislation.gov.uk asks crawlers to honour its robots.txt crawl delay (5 seconds) and to stay under 1,500 requests in five minutes; the law sources make seven requests a week.
The first grant starts the first crawl (knowledge/built_in_crawls, 28 October 2026). A website built-in nobody had granted had never been crawled, and the first agent to hold it waited for the scheduler's next tick (up to 15 minutes) and then the crawl, answering from nothing meanwhile. Every grant path (the agent page's grant, agent setup's create, a scenario run's provisioning) now starts, once it has committed, the crawl of each of the repository's website sources that has never been crawled (Trigger.granted, "Granted to an agent" on the crawl history and Activity). A source crawled before is left to its cadence. The crawl is the platform's, as a scheduled one is, and a grant never fails because one could not start.
Knowledge that holds nothing is not searched (svc-ai, 28 October 2026). The gate confirms each collection's count (an exact count when the approximate one reads 0), and the turn's mix leaves an empty one out ("nothing indexed yet"); search_knowledge skips it, and says so when asked for it by name. A request naming one tells the agent it could not be searched, so it answers from what it knows and says so. See Retrieval.
Checked and left out:
CISA (Secure by Design, its cybersecurity advisories and news; removed 28 October 2026): its content is US public domain, and it was probed from a developer machine, but cisa.gov answers every request from the deployed host with 403. All three sources finished every crawl holding nothing, while they were offered and suggested as if they held something.
tests/test_builtin_knowledge.py(REFUSES_THE_HOST) keeps them out.EUR-Lex (the EU AI Act and the EU GDPR): it answers an automated fetch with a JavaScript challenge (HTTP 202, "JavaScript is disabled"), so nothing can be read, although its reuse terms would allow it.
The ICO's news: its RSS feed pages no longer serve a feed, and its news listing draws its articles with JavaScript.
The NCSC's reports feed: its newest entry was over a year old, so a 30-day window would hold nothing.
Parts 3 and 4 of the Data Protection Act (law enforcement and the intelligence services): over half the Act, and few agents need them.
The Reasoning built-ins
General methods are the knowledge least likely to differ between users, so CHAIN-R writes them once (system_resources/reasoning.py, October 2026). Each repository holds one written source of its name, one markdown document per framework in system_resources/frameworks/<slug>/. An agent granted one applies a framework as the method for a request that calls for analysis or a decision, never as evidence for facts (retrieval).
Every document has the same shape, so frameworks are found and applied alike. tests/test_builtin_frameworks.py pins it:
# Title, which the filename spells (a passage reaches the model labelled by its document's name), then a one-paragraph summary and aCredit:line naming whose work it follows.Then seven sections in order:
Use it when: tasks phrased as a request would put them, which is what the Reasoning lane's query planner searches with ("a method for …");
Not for;
How to apply it, as numbered steps;
Questions to ask;
What it produces;
Common mistakes;
Works well with: other built-in frameworks by title, each one that exists, across repositories; every framework is named by at least one other.
350–900 words, each section within one indexed chunk (512 tokens less the 64 of overlap). Titles are unique, and none is a method's trademark.
How they are written. In CHAIN-R's own words: no copyrighted text is quoted (the Scrum Guide and the Agile Manifesto are summarised, not reproduced), originators are credited, and a generic name stands in for a trademarked one (phase-gate reviews). Standards are described in general terms, never reproduced (ISO 31000, ISO 22301). Public-sector material is followed more closely, with its credit: the NIST AI RMF (US public domain), and HM Treasury's Orange Book and Magenta Book and the UK probability yardstick (Open Government Licence). A framework gives a method, not the law: Reasoning through a DPIA sets out the reasoning, says it is not legal advice, and leaves the law to Domain knowledge.
Descriptions say what is inside. Triage, the knowledge tools and the relevance judge read a source's name and description, never its repository's, and the judge reads 300 characters, so each source's description lists its methods within that. A repository's description fits the 200 characters agent setup's catalogue shows.
Adding a framework is a markdown file in its folder: the next chainr_bot_sync indexes it. A new set of frameworks is a folder and one _framework_set entry in reasoning.py, with the next fixed ids (repositories …0601 up, sources …0611 up).
Where people meet them
Every user can grant a built-in to their own agents (CHAINR Bot holds only the guide). They are offered wherever a kind of knowledge is:
Knowledge → Repositories lists them by kind, each kind's built-ins ("Built-in · Reasoning") after the workspace's own of that kind. A kind with none of the workspace's own names the built-ins of that kind ("The built-in Systems thinking, Delivery lifecycles … are ready to grant to any agent").
An agent's "What this agent draws on" panel: a missing kind lists up to three built-ins of that kind (
KindReading.suggestions, best match first for the agent's name, description and instructions against each built-in'stopics), each attached in one click. Attach a repository and the Knowledge tab's empty kind open the picker (agents/agent/AddRepositoryModal) on that kind, with "Show every kind" for the rest.What to improve: questions about what is current with no Temporal knowledge offer the Temporal built-ins the questions' words match (News, else Regulation & security updates, or both); worked problems with no Reasoning knowledge offer the Reasoning built-ins they match, else Problem solving & decisions. Matched on every question's words, only to choose which repository; the offered ids are part of the evidence a set-aside recommendation holds, so a better match brings it back. On an agent's page an offered built-in is granted in one step.
Agent setup offers every enabled grantable built-in by reference, and its review says what keeping each costs, by its kind: written frameworks fetch nothing; a publisher's pages are read weekly and its feeds hourly, at the platform's cost, only while an agent uses them.
Evaluation: a variant's knowledge may name a built-in repository or source as well as the workspace's own (
evaluation/context._resolve_knowledge), so With / without knowledge compares an agent with and without one; the experiment page lists them, marked "built-in".samples/evaluation/reasoning-frameworks.jsonis a dataset for it.
system_resources/knowledge.suggested and matching rank a kind's built-ins against some text; both read the deployment's switches, so a repository turned off is never offered.
Who pays
A built-in source has no owner, so the usage ledger records nothing for it (usage.record_measured writes no row for the platform's own work). What it costs is kept where it was made: a crawl's on its knowledge_crawls.usage row, a written document's last indexing on its document_metadata.index_usage, and the sync job's summary adds them up.
Pinned
tests/test_builtin_knowledge.py holds every built-in to the same rules:
every licence permits commercial reuse;
every publisher's source reads only the publisher's own site, credits every passage, states when its terms were checked, and crawls as its kind (Temporal at least daily with a window; any other kind as
web_config.refresh_forsays);every written source ships its documents and says who wrote it;
ids are fixed and apart from every other built-in;
each repository is provisioned with exactly its sources, nothing is granted to CHAINR Bot but the guide, and a switched-off repository is not provisioned.
every kind has a built-in users may grant, listed Domain, Temporal, Reasoning;
the publishers' repositories turn off together with
BUILT_IN_WEB_KNOWLEDGE_ENABLED, written knowledge has no switch, reference pages are read weekly and kept whole, and the updates read feeds as News does.
The citations record
A grant says what an agent may retrieve from: reach, which is what the network views draw. What an answer actually cited is use. Until October 2026 nothing kept use in a form anyone could count. Each answer stored its sources on its own message (meta.cited_sources, for the chat to show), and nothing summed them per source.
knowledge_citations (migration 110, model KnowledgeCitation) has one row per knowledge source, and per document, that an answer cited.
| Column | What it holds |
|---|---|
invocation_id | The governed turn: the key of its decision record. |
knowledge_id | The source. Deleting the source deletes its rows. |
document_id | The document or page cited. Null for a source cited whole (a graph's facts), or for a document deleted since. |
agent_id | The agent that answered. Null once it is deleted. |
owner_user_id | Who asked: the conversation's person. |
owner_organisation_id, owner_project_id, workspace_user_id | The conversation's workspace, stamped as the usage ledger is (Workspace.ledger_stamp). A project row names its organisation, or its person for a personal project, so Workspace.stamped reads it unchanged. |
tool | How it was cited: the retrieval tool or citation kind svc-ai named. |
cited_at | When the answer was given (its sent_at). |
What it records
The record holds exactly what the answer stores. app/services/knowledge/citations.record is called once, inside agents/transformers._persist_conversation, with the meta.cited_sources that function writes. Every agent answer is stored there: the chat socket, the batch prompt, and blocked and failed turns. So:
A withheld, blocked or failed answer records nothing. It stores no sources.
An answer's sources are the ones it cites, not every passage the turn retrieved. svc-ai sends
cited_citations: the sources CHAIN-R's own Sources block lists (retrieval).Each entry names its source one of two ways. A
search_knowledgepassage or aread_documentresult carries adocument_id, and the document says which source it belongs to, whatever else the entry claims. A graph fact carries only the source'skb_id, which answers have stored since this release (CITED_SOURCE_KEYS). A source cited whole adds no row where one of its documents is cited.What names no knowledge source is skipped: web results, attached documents (a person's, not knowledge) and ids that are not UUIDs.
svc-ai's ids are checked, never trusted. A row is written only for a document or source that exists and that the turn could have read. That means the agent's own reach (its workspace's sources, or the built-ins for a built-in agent) or what the conversation's workspace shows (a chat command's skill runs there).
It never costs the answer. The rows are written in a savepoint, and a failure is logged, not raised.
tests/test_knowledge_citations.py pins all of this. Its AST guard fails any function that writes cited_sources without also recording its citations, so a new path that stores answers cannot leave them out.
What it does not record
Skill runs. A run keeps every passage it retrieved (
skill_runs.citations); only the ones its output cites carry a marker, and a run has no agent. Counting them is one nullable column away.Evaluation cells and dashboard tiles. These are the platform's own calls, not answers a person received.
Model chat. It has no knowledge.
What came before it
Migration 110 backfilled the answers stored before it. These are each assistant message's cited documents that still exist, in a conversation with an agent, and not withheld. They are stamped with the conversation's workspace and dated by the answer. Two things could not be recovered:
graph facts, whose
kb_idanswers did not store;documents deleted before the migration.
The backfill reads answers by the label Postgres stores (ASSISTANT, the enum's name). It casts a document_id only after the UUID pattern has matched, inside a CASE, so no stored value can fail the migration. tests/test_migration_110.py pins the SQL. It was run over a seeded copy on Postgres 16, covering:
each kind of entry;
a withheld answer;
a user message;
malformed meta;
personal, organisation, org-project and personal-project conversations;
down and up, and
alembic check.
Counting
Count distinct answers: COUNT(DISTINCT message_id). An answer cites a document once (uq_knowledge_citations_document). A source cited whole is recorded once per answer by the writer. A deleted document leaves its rows with no document and its source kept; a unique index over those rows would refuse deleting the second of two documents one answer cited, so there is none.
The rows are in the person's data export (data/knowledge_citations.json). Deleting a conversation lowers the counts: they are of answers on record.
The retrieval record
The citations record keeps use: what an answer cited. It cannot say what a turn's knowledge failed to give, and that is what says which knowledge to add:
a search that found passages, all of which the relevance judge ruled out;
a gap the quality check named that the knowledge did not hold;
a file the person named that no source has;
a turn the web answered while the agent's own knowledge was never searched.
The retrieval record (migration 113, October 2026) keeps those, one record per answer of an agent with knowledge. Beside the citations it also tells retrieved from cited. A source whose passages are given to many answers and cited by few is costing tokens for little.
What svc-ai reports
app/util/knowledge_report.py is the report, carried byte for byte by both services (tools/test_shared_modules.py). svc-ai's app/knowledge/turn_report.py builds it from the turn's final state:
The retrieval node's counts. Per knowledge base it records what the search found, what was kept for the agent, what the judge ruled out, and what a temporal source's window left out (
RetrievalBundle.kb_counts). It also records whether the judge ruled out everything (nothing_relevant) and which knowledge bases the turn did not search (scoped_out).The agent's own searches.
search_knowledgereturns an artifact per call: the knowledge bases searched, how many results each gave, and which passages (hits: document and chunk). Each result went to the agent as it was, so it counts as found and kept (tool_searches), once: a passage the turn's evidence already held, or an earlier search returned, is not counted again (turn_report._new_hits, 28 October 2026; a source whose lane handed on 3 passages had been kept 18 times). A plain agent that only searches through its tools therefore does not read as coming up short.Gaps. These are the gaps corrective retrieval searched for and found nothing on.
Triage. The request as retrieval searched for it (≤ 500 characters), whether triage called it live, and its complexity.
The mix (retrieval): the input's
profile, and each source'srolein it (primary, supporting or method).A turn that never searched (the web answered it, or nothing applied) still reports, with
searchedfalse.
An agent with no knowledge reports nothing. The report rides on the stream's done frame and the batch response's context. svc-core captures it on the turn's usage capture (UsageCapture.knowledge_report). The report holds no passage, no document name and no URL.
What svc-core stores
app/services/knowledge/retrievals.py writes two tables. It is called inside agents/transformers._persist_conversation, beside citations.record, in its own savepoint, so a failure costs the record and never the answer. knowledge_turns holds one row per answer:
| Column | What it holds |
|---|---|
invocation_id | The governed turn: the key of its decision record. |
agent_id, owner_user_id and the workspace stamp | As on the citations record (Workspace.ledger_stamp). |
query | The request as searched, redacted. |
live, complexity | What triage made of it. |
profile | The input's profile in the mix (lookup, current, analysis_current…; migration 115). |
searched, nothing_relevant, came_up_short | Whether the knowledge was searched; whether the judge ruled out all it found; whether it did not serve the request (searched, and nothing relevant, nothing kept, or a gap named). |
gaps, unresolved | The gaps the knowledge did not hold, and the files named that no source has. Redacted, ≤ 5 each. |
web_hosts | The hosts of the web pages the answer cited, from its stored sources (≤ 10). |
scoped_out | The knowledge bases the turn did not search, by id. |
knowledge_retrievals holds one row per source the turn searched, with its category, its role in the mix (migration 115) and the counts found, kept, ruled_out, out_of_window and tool_searches. Deleting the source deletes its rows. svc-ai's ids are not trusted at this boundary: a source the turn could not have read (citations._reach) is not recorded. Nor are its labels: a profile or role is kept only when it fits its column and reads as one (retrievals.mix_label: lowercase letters and underscores), else it is stored empty.
Together they measure the mix: how often each profile occurs, and per kind how often it led, supported or was applied as method, and how much of it was kept. Turns before migration 115 have no profile and no roles; nothing is backfilled, since nothing recorded them.
The person's words
query, gaps and unresolved are the person's words, so:
They are redacted as the request was. The turn's Input rules and then its Output rules apply (
retrievals.prepared,RulePass.redact).A withheld answer keeps none of them, nor any web host (it stores no sources). Its counts stay.
They are cleared after
KNOWLEDGE_TURN_TEXT_RETENTION_DAYS(180 by default; 0 keeps them as long as the answer) by the hourlyknowledge_turn_retentionjob. The counts stay, so the figures do not change. The lists areJSON(none_as_null=True), so a cleared list is SQLNULLand retention never finds it again.They go with the answer, and both tables are in the person's data export (
data/knowledge_turns.json,data/knowledge_retrievals.json).
A blocked or failed turn stores no answer, so it has no record (persist_blocked_turn, persist_error_turn). tests/test_knowledge_retrievals.py holds every function that records an answer's citations to record its retrievals too, and every other call storing an answer to pass its report.
What it does not record
Only agent chat writes it, on the socket and the batch prompt. Skill runs, evaluation cells and dashboard tiles do not, as with web search's settled Tools rules.
Nothing before migration 113. No stored answer kept what its search found, so there is no backfill.
Verified on Postgres 16:
a turn and its sources written through the ORM, with another person's source left out;
both 30-day counts, and nothing counted for another workspace;
retention clearing once and then finding nothing;
the cascades from the answer, the source and the agent;
down and up, and
alembic check;for migration 115, a turn's profile and its sources' roles written through the ORM, a malformed label stored empty, and
no_method_knowledgeread from them (an agent holding a Reasoning repository told nothing).
Recommendations
What to change about a workspace's knowledge, each with the evidence that says so and the step that would change it (app/services/knowledge/recommendations, October 2026). They read recorded facts only, never a model: the retrieval record, the citations record, grants, settings and documents.
The kinds
Each kind is one class, registered with register_kind and served at GET /app/knowledge/recommendations/kinds. A kind's section orders the list (what agents could not answer, then use, then upkeep), and within a kind the most evidence comes first.
| Kind | Fires when | The step |
|---|---|---|
no_dated_knowledge | An agent with no Temporal repository was asked 3+ questions about what is current | Attach News (when BUILT_IN_NEWS_ENABLED), or generate Temporal knowledge |
no_method_knowledge | An agent with no Reasoning repository was asked 3+ worked problems in 30 days: the knowledge mix read them as analysis or analysis_current (answers.is_worked; triage's complexity, moderate or complex, for a turn stored before profiles were). Complexity alone had counted news questions | Generate Reasoning knowledge from those questions |
answered_from_the_web | Answers cited the same site 3+ times, and nothing here holds it (trust.source_hosts, subdomains covered) | Add it as a website source, read for its kind (≤ 5 sites at once) |
retrieved_not_cited | A source's passages reached 20+ answers in 30 days and under 10% cited it | Its Usage, then its Content |
granted_not_used | A repository's agents searched in 20+ answers in 90 days and were never given its passages | Who it is granted to, then what it holds |
reaches_no_agent | A repository with sources is granted to no agent here | Its Agents tab ("Use in your agents") |
refresh_for_its_kind | A website source's refresh or window does not suit its kind: Temporal read less than daily or keeping every page; Domain read hourly; Reasoning read hourly or daily | Its settings, the change filled in |
same_documents | Two sources share 3+ documents (the source map's SAME_DOCUMENT_SQL) | Each source's Content (≤ 10 pairs) |
looks_dated | Every source of a Domain repository keeps a window of pages, and the change would be allowed (repositories.may_become) | Its details, Temporal filled in |
mixed_kinds | A repository holds a source also held as another kind (stored before one kind per source) | Its Sources |
The subjects are what the workspace owns: its own agents, repositories and sources, never a built-in or an inherited one, which are changed where they live. Every figure counts the workspace (stamped as the ledger is, projects=False). Examples are the viewer's own questions only, as the usage panel's answers are, and so are the questions a generation is described from.
Where they show
GET /app/knowledge/recommendations serves everything; ?repository_id= what touches that repository or one of its sources, and ?agent_id= what touches that agent. Each kind reads in its own savepoint under a 3 s statement timeout, as the source map does; one that cannot be read is named in unavailable and the page says so, never "nothing to recommend".
In fe-core (knowledge/recommendations/):
The Repositories and Sources lists have a fourth step, What to improve: its count, and the list under the strip when selected. It filters nothing.
A repository's Overview has a What to improve card, drawn only when there is something in it.
An agent's Knowledge tab has What this agent couldn't answer. Attach runs the page's own picker there.
Steps, never actions
An action names an existing flow (Flow) and what to fill it with (Prefill). It opens the flow filled in, and nothing changes until the person saves:
Generate opens the generate dialog on the kind. With
from_turns, svc-core describes the knowledge from those questions (describe_from_turns): the viewer's own, in this workspace, with their words still on record, else a 422. The person may add to the description.Add a website opens New source at
?type=web&url=&name=&refresh=&max_age_days=.Change its settings opens the source's edit page at
?refresh=&max_age_days=, set over the stored settings.Make it Temporal opens the repository's details at
?category=.
Both forms read the address back through prefill.ts, keeping only values they could save, and say what was filled in. A reader (who may not add knowledge here, can_change) sees only the steps that open a page.
Setting one aside
Set aside (POST /app/knowledge/recommendations/dismissals, migration 114, knowledge_recommendation_dismissals) hides a recommendation for everyone in the workspace while its evidence reads the same: the row keeps the kind, the subject and the evidence's fingerprint. Counts are banded (base.BANDS: 1, 3, 10, 30…), so one more question does not bring it back and many more do. Settings are read whole, so a changed setting does. Setting it aside again replaces the row. Undo (DELETE …/dismissals/{id}) brings it back. Both need what acting needs: being able to add knowledge here (may_change). The rows are in the data export of whoever set them aside.
A source map suggestion is set aside the same way (map_suggestion, the repository and the source as its subject). The fingerprint is its tie to a tenth and the kinds behind it, carried on the suggestion node's meta.fingerprint. summary.suggestions_set_aside counts what is aside.
Limits
Only agent chat writes the retrieval record, so the kinds reading it see only chat.
An agent with no knowledge has no record, so nothing says it needs some.
Nothing before migration 113: a turn-based kind starts from empty.
A dismissal lives as long as the workspace's key: deleting a workspace leaves its rows, which name nobody's words.
Figures
app/services/knowledge/stats.py holds the figures a card or a page shows for a source or a repository. Nothing is stored: each figure is read when asked for. There is one query per family of figures, whatever the number of sources. The Sources page used to fetch each card's documents separately. source_figures assembles eight queries for any batch of sources:
| Query | What it reads |
|---|---|
latest_crawls, last_successes | A website's newest crawl (DISTINCT ON) and when its last completed one finished. |
latest_edits | Its newest edit-history version: an edit, or a graph save. |
holding_repositories | The repositories holding it, as this workspace sees them: its own, what it inherits, and the built-ins. |
reaching_agents | This workspace's agents that reach it through any repository. Built-in agents are excluded. |
citation_days | Answers citing it per day, over 30 days, in this workspace. |
retrieved_answers | Answers over 30 days, in this workspace, whose turn kept passages from it (the retrieval record): retrieved, beside citations. |
Figures come in two kinds, scoped differently:
What a source is — its documents, their indexing, its crawls — is the source's own, whoever reads it.
What it is used for — the repositories holding it, the agents reaching it, the answers citing it — is the request workspace's only. A built-in source is held and cited in many workspaces, and how the others use it is theirs.
The same rule applies to when a source is crawled next. Its cadence's interval runs from the last crawl started, exactly as the scheduler judges it (web_crawl.due_sources). A built-in, though, is crawled only while some agent uses it. Whether one in another workspace does is not this workspace's to learn, so its next crawl shows only while one of this workspace's agents reaches it.
A card's config_summary is one line on where the source points (knowledge_config.summary): a website's hosts, a database's or API's address without userinfo or query, or a graph's counts. It never includes a credential.
stats.repository_figures adds up a repository's members' figures, plus three queries of its own: the workspace's agents it is granted to, the answers citing any of its sources, and the answers whose turn kept passages from any of them. A source in two repositories counts in both.
The routes
| Route | Serves |
|---|---|
GET /app/knowledge/{id}/stats | One source's. |
GET /app/knowledge/{id}/usage?days= | Answers citing it over 7–365 days (90 by default). See Usage. |
GET /app/repositories/stats | Every repository the repository listing shows. |
GET /app/repositories/{id}/stats | The repository's figures and each member source's, for its table. |
GET /app/repositories/{id}/usage?days= | Answers citing any of its sources, ranked by source too. |
GET /app/repositories/{id}/map?agents=&suggestions=&days= | Its sources connected by evidence, with suggestions and agents. See The source map. |
GET /app/network/knowledge?knowledge_id= | Where a source is used: the workspace's repositories holding it and its agents granted those (network.load_source_network). |
The figures routers (router/app/knowledge/figures.py, router/app/repositories/figures.py) are mounted before the knowledge and repository routers. Otherwise /knowledge/stats would be read as a source whose id is "stats", and the UUID path would answer 422.
Usage
services/knowledge/usage.py reads the citations record over a window. Every count is of distinct answers in this workspace. A usage response includes:
the window's answers, and the same length of time before it (the trend's baseline);
answers per day;
the top ten agents, documents and (for a repository) sources. A deleted agent is folded into "Deleted agent"; a document deleted since, or a source cited whole, into "The source as a whole";
the viewer's own ten newest answers. The counts include every member's answers, but a conversation is its person's, so only the viewer's own are listed.
Indexes
Migration 111 indexes knowledge_documents.knowledge_id, repository_knowledge.knowledge_id and agent_repositories.repository_id. The two junctions' primary keys lead with the other column. On Postgres 16, over 21,000 documents and 99,000 citations:
one source's document figures read by the new index (16 ms);
its 30 days of citations by
ix_knowledge_citations_knowledge_cited(2 ms);21 sources' figures took 7 queries (340 ms in all), their trust signals 4 more.
Trust signals
app/services/knowledge/trust.py reads what is on record about relying on a source. Each signal is one class (@register_signal), served as a catalogue at GET /app/knowledge/trust/signals. Each answers with:
a state:
met,partial,unmet,conflict,in_progress,unknownornot_applicable;a one-line summary;
the facts it read, each linking to what it names (a rule, a generation run, a person) where it can.
There is no score. The facts are of different kinds: a rule blocking a site is a conflict, while a missing licence is a gap in the record. A number would invent a weighting between them.
| Signal | Reads | States |
|---|---|---|
tools_rules ⚑ | The sites its content comes from (starting URLs, page URLs, imported documents' links) against the active Tools rules governing this workspace (workspace.governing_rules). Domains match with subdomains. | A blocked site is a conflict, whatever else trusts it. Every site trusted: met; some: partial; none named: unknown; no sites: not applicable. |
freshness ⚑ | A website's last successful crawl against its cadence. | Within 1.5× the interval: met. Slipping (up to 2×, or the last crawl failed or waited for budget): partial. Behind, or never crawled: unmet. Crawling now: in progress. Manual, or a built-in no agent here uses: not applicable. |
index_health ⚑ | Its documents' indexing states; a graph's entities. | Any failed: unmet. Waiting (pending, indexing, importing, or held for budget): in progress. A document with no text: partial. All indexed: met. Empty: unknown. A database or API is read where it lives: not applicable. |
provenance | The first edit-history version (who added it, or a CHAIN-R release), the generation run that made it, and documents found by discovery. | Something on record: met. Nothing: unknown. A built-in: maintained by CHAIN-R. |
⚑ marks an attention signal. Its unmet or conflict puts the source on "Needs attention" (trust.needs_attention): one definition for cards, lists and pages. Licence and provenance do not count, because every upload would otherwise need attention.
The signals are display only. Tools rules govern the web an agent searches and reads (see governance); they do not filter knowledge retrieval, and the signal's description says so.
Signals are served per source (GET /app/knowledge/{id}/trust) and per repository (GET /app/repositories/{id}/trust: each member's signals, and how many sources sit in each state). TrustContext.load reads a batch's facts in four queries:
the hosts of each source's content;
the Tools rules;
first versions, with their actors' names;
generation runs and imports.
tests/test_knowledge_trust.py covers each signal, the rule loader and the catalogue.
The lists
Knowledge → Repositories and Knowledge → Sources each read their figures in one request for the whole list (figures.ts: useRepositoryStats, useKnowledgeStats, keyed under the list's own prefix so whatever invalidates the list refreshes them). Each card shows:
where it stands — a
StatusBadgeon theSOURCE_HEALTHscale:Needs attention when a trust signal asks for a look, with why on hover (
ATTENTION_REASON, keyed by signal and pinned to svc-core's attention signals byfigures.test.ts);Indexing while anything waits, budget holds included;
Ready;
Empty;
Read in place for a database or API source;
what it holds:
a repository: its type mix (each type's icon and count) and the first few sources by name;
a source: the one line on where it points (
config_summary);
Indexed — a
MeterBarof how much of it is searchable, and the count;Agents (a repository) or Updated (a source);
Cited · 30 days — a
SparkBarsof answers per day and the total.
A source card's footer names the repositories holding it in this workspace (a built-in's, its built-in repository), or "In no repository", and how many agents it reaches. Removing a source from a repository is on the repository's page; the cards no longer offer it.
The summary strip
Each list's summary slot (KnowledgeSummary.tsx) holds four steps. The first three are each a count over the workspace's own resources and a filter (?show=); the filter narrows the built-ins too. The fourth, What to improve, counts the workspace's recommendations and shows them under the strip, filtering nothing. Selecting a step again shows everything.
| Repositories | Sources |
|---|---|
| Reach no agent — granted to none of the workspace's agents | In no repository — indexed, but no agent can be granted it |
| Not cited in 30 days | Not cited in 30 days |
| What to improve | What to improve |
Above the steps, a headline sums the workspace's own sources' citations over 30 days. It counts per source: an answer citing two sources counts twice.
Both lists sort by Most cited too.
The source's page
A knowledge source's page (knowledge/KnowledgeViewer.tsx) is a DetailPage with three tabs in the address (?tab=). The edit history sits under each one.
Overview (the default;
source/SourceOverview.tsx):the headline figures (
KpiStrip): what it holds, how much is indexed, when it last changed, for a website when it is crawled next, the repositories and agents reaching it here, and 30 days of citations;what it is and whose (a built-in's owner is CHAIN-R), and the repositories holding it, linked;
the trust panel (
source/TrustPanel.tsx): each signal's state on theTRUST_STATEscale. Met is a success; Partly and Unknown are neutral; Not met is a warning; Conflict is a danger; Not applicable is set aside. Under each state are its sentence and the facts it read: a rule linked to its page, a licence to its terms, a time in the reader's zone;where it is used (
source/WhereUsedCard.tsx): the network canvas overGET /network/knowledge?knowledge_id=;for an empty source the viewer may change, a prompt to its Content tab.
Content (named for what it holds: Documents, Pages, Graph or Configuration;
source/SourceContent.tsx). Everything that changes a source, as before:an empty one can find its own material (
FindSourcesPanel);a file source: what it holds by indexing state and by kind (
DocumentsBreakdown), then its documents (source/DocumentsSection.tsx: upload, import from a link, folders, reindex, preview);a website: how it is kept (
source/web/WebInsights.tsx), then its crawls, pages, link graph and page history. How it is kept means each crawl's pages by what became of them (CrawlHistoryChart), when its pages last changed (freshnessBuckets) and the sites they come from (pageHosts), all read from the same crawl and page queries the section lists;a graph: its canvas, and its entity types ranked;
a database or API: its configuration (the reader's view).
Usage (
source/UsagePanel.tsx, which the repository page reads too): answers citing it over 30 days, 90 days or a year, against the same length of time before. Also answers per day (TimeSeriesChart), the agents and documents most cited, the viewer's own newest answers (each opening its message), and itsResourceCostCard(search and indexing).
Every query sits under [KNOWLEDGE_BY_ID, id] (figures.ts: sourceKey, documentsKey, sourceStatsKey, sourceTrustKey), so invalidating the source refreshes all of them. They used to be strings that prefix invalidation could not reach. The router reads a single-object reply only when it is shaped like one (isObjectWith), so an empty API never breaks the page.
The source map
A repository's Overview draws its sources as a web (GET /app/repositories/{id}/map, services/knowledge/source_map/). Nobody draws a connection. CHAIN-R draws one where the record shows two sources belong together, weights it by how much evidence there is, and lets every line say what it rests on. There is no graph builder: what a builder would ask people to assert, the record already holds, and a hand-drawn line would be a claim nothing checks.
Kinds of evidence
Each kind is one class in source_map/evidence.py (@register_evidence), served with the map as its legend. Adding a kind is adding a class.
| Kind | What it counts | strength | τ | Said as |
|---|---|---|---|---|
cited_together | Answers in this workspace citing both in the last 90 days (a self-join on knowledge_citations, stamped as the ledger is) | 0.8 | 3 | "12 answers cited both" |
links_to | Pages in one linking to the site the other's content comes from (its seed hosts and page hosts, subdomains included by web_domains.covered); links within a source's own sites do not count | 0.7 | 5 | "4 links" |
shared_site | Sites and publishers both draw on, each weighted 1 / ln(1 + sources holding it): two sources sharing a site count ~0.9, ten ~0.4 | 0.5 | 1.5 | its examples |
A kind's count becomes a score that saturates, 1 − e^(−count/τ): a little evidence counts, and a lot does not count forever. A connection's weight is its kinds together, 1 − Π(1 − strength × score). Each kind adds to what the others leave, so two kinds read stronger than either, and nothing passes
The weight orders and draws the map; it is not a judgement of either
source. Every edge serves each kind's count, score, what it adds, and up to three examples (cited_together gives none: the answers are other people's conversations, and the count says it).
Not a kind, on purpose:
Semantic similarity (embeddings). Sources may be embedded by different models, the edge could not show an example of why, and the centroids would need recomputing on every crawl.
A page's latest snapshot hash. Pages are matched by address instead: two sources crawling one page under different settings (article text, or the whole page) store different text, and the address already says it is the same page.
What is drawn
builder.build_map is pure; loader.load_source_map reads what it needs.
The repository's sources (
sourcenodes), up to 60 (MAX_MEMBERS).Their connections first: each source keeps its 6 strongest ties to the others (
MAX_EDGES_PER_NODE), 300 edges in all. A suggestion never crowds one out (found on Postgres: as-strong suggestions had filled each source's allowance and the repository's own ties were never drawn).Suggestions (
suggestionnodes): the workspace's own sources outside it (in scope, not built in), ranked by their strongest tie, at least 0.25, at most 8, each drawn with its 2 strongest ties (MAX_SUGGESTION_EDGES). A built-in repository gets none; nothing can be added to it.Agents granted it here (
agentnodes), each with a dottedcited_byline to every source, weighted by that source's share of the agent's citations from the repository over 90 days.
The summary counts every pair, drawn or not: sources, connections, pairs holding the same documents (likely indexed twice), sources tied to no other, and suggestions. truncated says when the caps left anything undrawn.
Each kind runs in its own savepoint under SET LOCAL statement_timeout = '3s'. A kind that fails or times out lands in summary.unavailable, with why, and the page names it: the map shows less than there is, never "no evidence". Nothing is read from source_config but web seed URLs. Verified on Postgres 16 over 21,000 documents and 99,000 citations: about 0.4 s and 30 queries a map, and a forced timeout reading as unavailable with the session still usable.
On the page
knowledge/map/ in fe-core:
The layout (
forceLayout.ts,d3-force): ties pull their ends together, stronger ones shorter and harder; nodes push apart and never overlap; the repository's sources gather in the middle, suggestions on a ring outside and agents outside that. It is deterministic. Nodes are taken in id order, the simulation draws on a seeded random source, and it is stopped as it is built and run for 300 ticks synchronously, so it never animates or runs on. The network tiles'layeredLayoutis for layered graphs (agent → repository → source); a web of ties has no layers.The marks (
SourceMapCanvas.tsx, on the sharedFlowFrame): a source is a circle sized by what it holds (three sizes). Its ring is its health onSOURCE_HEALTH(STATUS_TONE_RING, checked with the dataviz validator on both card surfaces), and "Needs attention" also carries a warning glyph. A suggestion's ring is dashed, an agent is a square, and a connection is a straight line1 + 5 × weightpx wide in one neutral ink: a kind is named, not tinted.The evidence panel (
EvidencePanel.tsx): a connection's kinds, each with its count in words (the kind'sunit_one/unit_many), what it adds and its examples. A source shows its health, what it holds and its ties. A suggestion also shows Add to repository, offered only where the viewer may change the repository, and versioned as any source joining is, and Set aside, which stops suggesting it while its tie holds (setting one aside).Filters (kind chips, Strong only, Suggestions, Agents) only hide. The layout is computed once per map, so nothing moves under the reader. A suggestion hides with its last showing tie.
The Connections table under the canvas lists every connection showing, strongest first, each opening its evidence. It is the map for a screen reader, or for a map too dense to read.
The legend (
SourceMapLegend.tsx) reads the kinds from the map.
The repository's page
A repository's page (knowledge/RepositoryViewer.tsx) is a DetailPage with four tabs in the address. The edit history sits under each one.
Overview (
repository/RepositoryOverview.tsx): its figures (sources and their type mix, what they hold, how much is indexed, how many need attention, agents reaching it, 30 days of citations), the source map, and trust across its sources (repository/RepositoryTrustCard.tsx): each source against each signal, its sentence on hover, and how many stand where under each column.Sources (
repository/RepositorySources.tsx): its sources as a table fromGET /repositories/{id}/stats. Each row shows its type, what it holds, how much is indexed (aMeterBar: complete, in hand, or with failures), its health, when it last changed, and its citations. Every column sorts. Where the viewer may change it, sources are added here and removed from their row.Usage: the source page's
UsagePaneloverGET /repositories/{id}/usage, which adds its sources ranked (a source in two repositories counts in both) and the repository'sResourceCostCard.Agents: the switch that puts it in each of the viewer's own agents (
RepositoryAgentsCard).
Edit opens the details in a dialog (RepositoryDetailsModal, the create dialog's form) and saves them together; it had been an inline card that saved the appearance on every pick. Delete asks first. A built-in or inherited repository offers neither, nor Move, add or remove.
Every query sits under [REPOSITORY_BY_ID, id] (figures.ts: repositoryKey, repositoryMembersKey, repositoryStatsKey, repositoryMapKey, repositoryTrustKey). A source joining or leaving invalidates that prefix, the lists, and the source's own queries, so the map, figures and trust all redraw.