Start

Concepts

This page defines the terms used across the Groundwork docs and points at the code or spec behind each one.

Projects

A project is one body of data with its own sources, configuration, golden sets and scores. In the hosted design a project also scopes API keys (see Projects and keys). Locally, a project is a data folder: the San Francisco demo lives in tmp/sf, and every command takes --data <dir> to point at another.

Sources

A source is anything Groundwork reads: a folder, a table, a set of transcripts, a YouTube channel, a bucket, a database. Each source belongs to one of two classes, set per source:

  • Ingest. Copied through the full pipeline and indexed.
  • In place. Queried live at answer time (SQL, Cypher or a federated vector search) and never re-embedded. It still emits catalog records so the answer agent knows what exists.

Promotion moves a source from in place to ingest when evals show it helps. It is a switch on the source, not a rebuild. Only ingest sources exist in code today; in place and promotion are planned. See Sources.

Records

Every source emits the same shape, IngestRecord (src/record.ts):

ts
type IngestRecord = {
  id: string;                 // hash of connection id and native id, stable across syncs
  source: { kind: string; connection: string; nativeId: string; uri?: string; container?: string };
  version: { hash: string; sourceVersion?: string; modifiedAt?: string; observedAt: string };
  op: "upsert" | "delete";
  content?: { mime: string; text?: string; blob?: string; bytes?: number; language?: string };
  metadata: Record<string, unknown>;
  tags: string[];
  access?: { users?: string[]; groups?: string[]; public?: boolean };
  links?: { type: string; target: string }[];
  error?: { code: string; message: string };
};

The id stays the same when a record changes. The version hash changes only when the content or metadata does, so an unchanged row keeps its hash across syncs and nothing downstream reruns.

Stages and the cache key

The pipeline is built from one primitive, the stage (src/stage.ts). A stage is a pure async function with a name, a version, and a configOf function that picks out only the config fields it reads. Its output is cached under:

text
<name>@<version>/<hash(input)>/<hash(config fields it reads)>

This has a few consequences:

  • A retry or a duplicate event finds its output already in the cache.
  • Changing a query setting such as query.topK reuses every index-time stage.
  • Changing the chunker reuses parsing and transcription.
  • Bumping a stage's version invalidates only that stage and what depends on it.

cached wraps a stage with a blob store, cachedEach does the same item by item for batch stages such as embedding, and pipe chains stages left to right, stopping at the first result that is not ok.

Adapters and ports

Every pipeline step is a port with a small interface in src/core/ports.ts: parse, transcribe, chunk, embed, store, route, rerank and generate. An adapter is one implementation of a port, in one file, chosen by an id such as local/bge-small or store/sqlite-vec. The adapter id is part of the config a stage reads, so it lands in the cache key and swapping one reruns only what depends on it. See Pipeline and adapters.

Canonical entities and fields

Extraction finds entities in records, and resolution groups mentions into one canonical entity per real thing, keyed type.normalized-id (for example address.150-hayes-st). Each entity keeps:

  • one canonical value per field,
  • every candidate value seen, with its provenance (the record, the source, the extractor that set it, and a time),
  • the records that mention it.

Conflicts are kept, and the canonical value is picked by a rule. The demo's rule is trusted-then-recent: the most trusted source wins, then the most recent value. Entities are stored in xgraph2.

Answers and citations

An answer is the result of one question on one answer path. It holds the written answer (when an answer model is set), the evidence it rests on, the canonical entities it touched, a trace of the steps taken, the number of model calls and the time. Rendered as an answer document, each claim cites a declared source with a [^id] marker. See Answer format.

Golden sets

A golden set is a list of questions with what a good answer needs: the records, transcript moments or PDF pages that hold the evidence, and the facts the answer should state. The San Francisco set is evals/sf/golden.json. See Evals and golden sets.

The scorecard

The scorecard summarises evals and benchmarks as a grid: one row per dimension (retrieval, facts, answers, citations, and so on), one column per use case, each cell a traffic light against a stated threshold and each cell naming the file it came from. See Scorecard.

The audit ledger and run ids

Each question gets a run id. Adapter calls made for that question write a row to the audit ledger (src/core/audit.ts): run id, step, adapter id and version, input and output hashes, time, cost, whether it was a cache hit, and when it ran. deno task gw audit <run-id> prints the chain. The XML answer includes the run id in its run attribute, so any answer can be traced back to the adapters that produced it.