A dated history of how a person changed, dated by when the reviewer noticed

witness

A pure-Go binary that distills coding-agent sessions or NDJSON corpora into observations, versioned per-lens facets with confidence decay, and narrative profiles, served over MCP.

LicenceMIT in LICENSE, matching the five npm manifests
Size33,066 lines of non-test Go and 49,867 of Go tests; the memory is internal/store (7,775), internal/distill (5,014), internal/mcp (462) and internal/vector (69), with prompts under prompts/
Activity181 commits from 2 July to 24 November 2026, 162 of them by one author and 19 by three others; 35 tags, latest v0.15.1 on 23 November 2026
Tests1,224 top-level Go test functions in 228 files; CI runs go test ./... on Ubuntu and Windows and -race on two packages, with OpenCode and Codex contract suites in their own workflows; none run for this reading

Carries 1 of 7 rubric mechanisms. Most systems here carry none or one (41%), and a dash means the mechanism was not found at this commit — not that the system needed it. Each mark is one LLM reviewer's reading of the code at this commit rather than a run of it — known limits.

  • Tombstone
  • Trust state
  • Bi-temporal
  • Scope enforced
  • Mutation audit
  • Human review
  • Negative evals

1. Executive Summary

witness is a single pure-Go binary that turns a text stream into a dated record of how its subject changed. It captures Claude Code, OpenCode and Codex sessions through hooks, or any corpus through NDJSON ingest, into one SQLite file. A background worker distills them in three model-driven passes: raw turns into observations, observations into versioned facets, facets into Markdown portraits. Notable: the model judges and Go applies the rules. A facet changes value only on a flagged contradiction, confidence moves at most 0.1 per review and decays on read, and a deleted observation reaches the facets without a refold. Weak: the headline. A facet version's valid_from and recorded_at come from the same review clock, so the dated history records when witness noticed a change, not when it happened.

The design is collect-only. Nothing is injected into a session. An agent reads the archive over five MCP tools, a person reads witness profile or a static HTML view, and every derived layer is regenerable from the verbatim raw turns.

Three things matter more than the rest:

  • One clock under two names. All six writers of a facet version set ValidFrom: nowStr, RecordedAt: nowStr, and the field's own comment says "review time, not content ts" (internal/store/types.go:108). The source dates exist one layer down, and the HTML view computes the real arrival from them, "a median of 15 days later on the reference clone" (internal/view/traits.go:172-186). Nothing stores it.
  • Backfills fold in completion order. The review reads observations by insertion sequence, which a parallel drain sets by whichever model call returned first. The prompt tells the model they are "in chronological order (oldest first)" (prompts/default/review.md:9).
  • The agent holds both evidence verbs. record_observation stores the agent's sentence verbatim as evidence and delete_observation removes any observation by id. Neither is authenticated.

Licence. MIT in LICENSE, matching the five npm manifests. The Windows zip built by make package-windows ships the multilingual-e5-small weights and tokenizer with no licence file beside them (Makefile:37-49).

One mark, negative_eval. Section 9 gives the reason for each of the six withheld.

2. Mental Model

A memory is a facet: a named attribute of the subject within a lens and a dimension, such as default · thinking · diagnoses_before_acting, whose value is a paragraph of model prose. Beneath it sit observations, one sentence each with an evidence anchor and a poignancy, and beneath those the raw turns, append-only and never touched by a model (internal/store/types.go:5-13).

A facet has a list of versions and at most one open one. The review model sees the new observations and the live facets of one lens, and returns assertions with contradicts_prior (internal/distill/reviewer.go:76-84). Go then applies one of four branches (:304-402):

  • New key: a version opens.
  • No open version: a version reopens.
  • Contradiction with a different value: the open version gets valid_to and a new one opens.
  • Anything else: confidence steps toward the returned number by at most 0.1, and the cited ids are merged in.

Absence never closes a version. It lowers confidence on read, by half every 3,000 observations of that lens since the facet was last confirmed, floored at 0.1 (internal/store/types.go:123-199).

A facet leaves the live profile in two ways, both archival. Compaction merges several facets into a survivor or retires one, on a model's plan that a person confirms. A review retires a facet whose current version cited observations that have all been deleted (internal/distill/reviewer.go:248-283). A retired key comes back when a later review asserts it again, and an assertion on a merged key lands on the survivor (:314-320).

The facet is never verified. Every assertion is live the moment it is written, and confidence describes how often the evidence recurred, not whether the claim may be acted on.

Diagram — a facet version opens and closes on the review clock; source dates stop at the observation, and a delete reaches the facet at the next review
Diagram source
%% caption: a facet version opens and closes on the review clock; source dates stop at the observation, and a delete reaches the facet at the next review
flowchart TD
  SRC["raw turn or record<br/>ts = capture time,<br/>or caller's ts on ingest"]
  SRC --> OBS["observation<br/>ts = session's last turn"]
  AG["record_observation<br/>agent text, verbatim"] --> OBS
  OBS --> WIN["review window<br/>insertion order,<br/>not ts order"]
  WIN --> M{"model asserts:<br/>contradicts_prior?"}
  M -->|"new key"| OPEN["version opens<br/>valid_from = recorded_at<br/>= review clock"]
  M -->|"yes, new value"| CLOSE["old valid_to =<br/>review clock;<br/>new version opens"]
  M -->|"no"| STEP["confidence moves<br/>at most 0.1"]
  OPEN --> LIVE["live facet<br/>decays on read to 0.1"]
  CLOSE --> LIVE
  STEP --> LIVE
  DEL["delete_observation"] --> PR["next review strips id;<br/>no evidence left:<br/>retired"]
  PR --> ARCH["archived<br/>out of every live read"]
  LIVE -->|"compact: person's y<br/>or --yes"| ARCH
  ARCH -->|"retired key<br/>asserted again"| LIVE

3. Architecture

One binary, witness, serves every role: hook entry points, the MCP server, the CLI and the detached worker. The data directory holds witness.db and profile/*.md, located by resolveRoot over dataDirNames (internal/store/store.go:13-25).

  • Store. SQLite through the pure-Go modernc driver, one connection per process, WAL, busy_timeout=5000, foreign keys on (internal/store/db.go:136-150). The database is also the work queue: a progress row per session and lens is the mining watermark. The schema is at version 15 (internal/store/testdata/schema/v15.sql).
  • Embeddings. multilingual-e5-small in ONNX, run in Go through GoMLX, 384 dimensions, fetched once from a pinned Hugging Face revision and checked by SHA-256 (internal/model/fetch.go:36-44).
  • Search. A brute-force cosine scan (internal/vector/vector.go).
  • Models. Every model call goes to the user's own runner: claude -p with --safe-mode and --tools "" (internal/platform/claude/runner.go:253), a private opencode serve with a deny-all tool policy, or codex exec under a witness-owned login.

Deployment and ergonomics

./install.sh claude builds the binary, fetches the 448 MB model and wires hooks and MCP; npm packages carry prebuilt binaries for OpenCode. Capture and local reads need no account and no network. Distillation needs one of the three agent CLIs signed in, and without one no observation, facet or portrait is ever written. The store is plain SQLite and Markdown, readable and repairable by hand. witness export --all copies database, config and lenses; witness merge folds another archive in after showing a plan.

4. Essential Implementation Paths

  • Capture. cmdCapture appends one raw record per hook event and always returns nil (cmd/commands/capture.go:37-71, internal/platform/claude/capture.go:20-43). OpenCode and Codex are imported from their own SQLite and JSONL histories.
  • Ingest. groupSessions turns NDJSON into file: sessions and normalises a caller's ts, falling back to now (cmd/commands/ingest.go:94-177). A changed body under the same id replaces the session's suffix and rolls the watermark back (internal/store/raw.go:26-72).
  • Mining. MineSession runs each enabled lens's extract prompt over that lens's delta; CommitMining writes observations and advances watermarks in one generation-guarded transaction (internal/distill/worker.go:206-551).
  • Review. Reviewer.Run prunes deleted evidence, then foldLensWindowed folds each lens in windows, writing facets and confidence events together and stamping the per-lens watermark after each (internal/distill/reviewer.go:87-227).
  • Facet write. WriteFacetsPruned deletes every facet row and reinserts the whole profile under BEGIN IMMEDIATE (internal/store/facets.go:125-229).
  • Compaction. witness compact plans per dimension, prints the plan and asks; Compactor.Apply archives absorbed and retired facets and rewrites survivors (cmd/commands/compact.go:63-181, internal/distill/compact.go:880-995).
  • Portraits. Summarizer regenerates a lens's Markdown when the signature of model, prompt and facet text changes; Resolver links portrait sentences to the traits they rest on (internal/distill/summarize.go, internal/distill/sources.go).
  • MCP. Five tools (internal/mcp/server.go:190-382).

5. Memory Data Model

Raw. session, seq, ts, role, effort, text. Claude Code turns carry capture time; imported and ingested turns carry their source's time.

Observation. obs_id is the first 12 hex characters of sha1(session|lens|text), so the same sentence in the same session is one row (internal/store/obs.go:11-18). ts is the session's last raw turn at mining time, since the extract prompt returns none (internal/distill/worker.go:227, :449-451). source is mined or active. An embedding failure keeps the row without a vector, and search skips it.

Facet. UNIQUE(lens, dimension, key) with last_seen, archived_at, merged_into and archive_reason. Versions sit in facet_versions, keyed by (facet_id, pos), with value, claim, confidence, confidence_seq, because_of as a JSON list, and the three time columns. Row ids change on every write, so merged_into names a facet by dimension/key text.

Time. valid_from and recorded_at are equal on every version, and valid_to is the time of the review that closed it. A state facet, which the review prompt asks the model to close by recency, closes at the review that notices.

Confidence log. confidence_log takes one row per accepted assertion and per compaction survivor: facet name, time, clock, from, to and one of seven kinds (internal/store/confidencelog.go:5-31).

Scope. A lens tag on every observation and facet; session ids prefixed opencode:, codex:, file: or mcp:; session_meta.cwd, read only by witness merge (internal/store/types.go:67-76). Separate corpora are meant to live in separate data directories.

6. Retrieval Mechanics

Observations are searched by cosine against the query's embedding, filtered to one lens before ranking, top 8 by default, with no score floor (internal/vector/vector.go:46-69, internal/mcp/server.go:196-232). Every call reads and decodes all of that lens's embeddings. The query is capped at 8,000 characters because the tokenizer allocates per byte.

Facets are not searched. get_facets prints every live facet of a lens with its full Value and its decayed confidence (internal/mcp/server.go:443-462). The review prompt uses the short Claim because values are long: a comment records 2,039 facets carrying 2,411,507 characters of value on the author's archive (internal/distill/reviewer.go:600-612). Compaction reduces the count. Without it, one get_facets call on a lens that size returns megabytes into the agent's context.

Portraits are served as stored, with a note when the facets have moved since (internal/mcp/server.go:335-357).

Nothing is automatic. The agent chooses to call a tool, so the provider's prefix cache is untouched.

7. Write Mechanics

Mining sends a session's new turns to one model call per lens, with chunking off by default, and keeps every returned observation that has text (internal/distill/worker.go:561-601). The observation log keeps every occurrence: a cosine dedup that dropped near-duplicates was removed on the stated ground that repetition is the reinforcement signal (:419-434). Truncated JSON is a retryable failure; prose with no JSON array advances the watermark and is counted as drift.

The review fold sends at most 16,000 characters of observations per call with the lens's live facets, re-reads the profile between windows, and asks the model only which facets the new evidence bears on (internal/distill/reviewer.go:150-227). Its order is seq, chosen so a window boundary never skips a row (:138-149). In live capture seq roughly follows time. In a backfill it does not: pending sessions are ordered by session id (internal/store/queue.go:551), and the drain commits each session when its model call returns, "we drop only the ORDER" (internal/distill/drain.go:274-281). A corpus ingested in one run is folded in an order unrelated to its dates, and each window's contradiction verdicts are judged against whatever earlier windows left.

Agent writes go through record_observation, staged verbatim as active and drained at the next mine, capped at 200 per session and 5,000 in total (internal/mcp/server.go:242-293, internal/store/obs.go:65-101).

Deletion removes the observation row and appends its id to a pending list in meta, in one transaction (internal/store/obs.go:211-230). The next review strips the id from every version of every facet and retires an active facet whose current version is left citing nothing, logging a retire event (internal/distill/reviewer.go:248-283). The docstring calls the delete "Durable against re-mining" because "obs_id dedup would catch it even if it did" (internal/store/obs.go:197-199). It would not: the dedup is INSERT OR IGNORE against a row that no longer exists, and PendingDeletedObservations drops any id that names an observation again (:241-245). A re-mine after a raw replace or lens backfill --fresh can put the row back, and a paraphrase gets a new id regardless. The prune's own test requires that outcome: TestPruneSkipsADeletedIDThatExistsAgain re-stages a deleted sentence and requires the facet to keep citing it (internal/distill/prunedeleted_test.go:134-147).

Compaction is the one structural rewrite, planned by a model per dimension and validated in Go (internal/distill/compact.go:16-80). It runs only on witness compact.

Operational cost

Capture is one SQLite insert per turn on the hook's path. Mining runs in a detached worker that the session-start and session-end hooks spawn (cmd/commands/session.go:22-53), one model call per session per lens. An observation is searchable once its session is mined, at the next session boundary. A facet moves at the next review, after five mined sessions or 30 points of poignancy by default (internal/store/config.go:112-113, :701-708). A review that changes facets also regenerates every affected portrait and resolves its sources, so portraits cost model calls whether or not anyone reads them, as docs/how-it-works.md says. No model pass re-reads the whole store unprompted. Every facet write rewrites the whole facets table in SQLite.

8. Agent Integration

witness wire claude|opencode|codex installs capture and the MCP entry. The five tools are search_observations, get_facets, get_profile, record_observation and delete_observation. The profile tool defaults to the cross-lens unified portrait and the two read tools to the default lens. Hooks print no context, so the agent sees memory only when it asks.

The model has write power over the evidence and none over the facets. The tool descriptions call facets reviewer-owned and name adding or deleting an observation as the supported correction. A lens is a directory of lens.json, an extract prompt and a review prompt, registered centrally and never read from a repository, so a cloned repository cannot change what gets noticed. witness lens try previews a lens on real sessions without writing.

Adapting it to another agent means an importer for that agent's transcript store: internal/platform/registry.go requires only identity and treats capture, import and running as optional.

9. Reliability, Safety, and Trust

What the dates mean

A reader of witness facets --expand, or of the README's 2026-02 → 2026-05 example, would take those as when a habit changed. They are the dates of the reviews that wrote and closed each version. For a person's own sessions the gap is the review lag. For a corpus spanning 2024 to 2026 ingested in one evening, every facet opens that evening, and the only dates that describe the subject are on the observations. The code computes evidence time in two places, the view's arrival and the merge's evidenceTime, the latest timestamp among a version's cited observations (internal/store/merge.go:1316-1330). Neither writes it to the version.

Provenance

Every version cites observation ids, and every observation carries an evidence anchor and its session, so a claim traces back to turns. The citations are the model's: a comment counts 48 facets on a real archive resting on ids the model invented (internal/distill/reviewer.go:240-242).

Prompt injection and the agent's reach

The extractor runs with tools disabled, so hostile text in a session can at worst shape what is noticed. The agent's reach is larger. record_observation writes any sentence as evidence about the user, with poignancy up to 10, so three calls cross the default poignancy trigger for a review. delete_observation takes any id. The server's own comment calls the record tool unauthenticated and bounds it by quantity alone (internal/mcp/server.go:54-58).

Concurrency and data loss

One connection per process, WAL, BEGIN IMMEDIATE on facet writes, and a worker lock across review, compaction and merge. Mined observations commit with the watermark under a raw-generation check, so a replace landing mid-mine discards the stale result. Capture swallows every error by contract. lens backfill --fresh deletes a lens's observations, facets and confidence history and warns first, because active observations are not re-created by a re-mine (internal/store/queue.go:419-472).

Marks withheld

  • bitemporal. One clock. All six writers set valid_from and recorded_at from nowStr (internal/distill/reviewer.go:326, :348, :358, internal/distill/compact.go:928, :951, :980), and no read filters on either column. Content time exists on observations and is derived for display, never stored on a version.
  • tombstone. The pending-delete list is consumed by the next review and ignores ids that exist again. witness merge says in its own header that "There are no tombstones that cross" (internal/store/merge.go:26-27).
  • trust_state. A facet is active or archived, and every assertion is active when written. Confidence is a float that decays to a floor and never withholds. mined and active record provenance, not belief.
  • scope_enforced. The lens is applied as a filter on every read, and it partitions by analytic question, not by owner or context: every enabled lens mines every session, and the caller names the lens per call. Separate archives are separate directories.
  • audit_log. confidence_log is the near miss. It is written in the same transaction as the facets and no review truncates it. It records no row for a facet that compaction archives, none for the claim pass or a merge, and nothing for the deletion of an observation. lens backfill --fresh deletes it, and a merge renames rows in place (internal/store/queue.go:459-462, internal/store/merge.go:367-376).
  • human_review. Nothing waits. Facets are live on write. Compaction's confirmation is a prompt inside one invocation with a --yes flag for scripts (cmd/commands/compact.go:51), and the agent holds the evidence verbs.

10. Tests, Evals, and Benchmarks

The suite is large and specific. Many tests pin a past defect by name: a review that could only ratchet confidence up, a delete that refolded a whole lens, archived facets resurrected by the next fold, source-scan tests that broke on CRLF checkouts. Store tests open real SQLite in a temporary directory, and schema dumps from five past versions are migrated and compared to a fresh archive.

The negative cases concern archived facets. The CLI listing, the review prompt and the HTML view each hold a live facet beside merged and retired ones and require only the live one (cmd/commands/facets_archived_test.go:46-60, internal/distill/compactintegration_test.go:18-39, internal/view/traits_test.go:342-373). TestDeleteThenReviewRetiresWithoutRefolding runs delete, review and re-assertion end to end on a real store with a fake model (internal/distill/prunedeleted_test.go:263-301).

Gaps:

  • vector.Search's lens filter, which its comment marks "CRITICAL", has no test; internal/vector/vector_test.go holds TestCosine only.
  • The MCP tests use a fake store whose ReadObservations ignores the lens, so a leak across lenses would pass them (internal/mcp/fakestore_test.go:46-50).
  • No case requires a deleted observation to stay gone after a re-mine, folds a backfill out of order, or asserts what valid_from means.

There is no retrieval-quality eval, no benchmark harness and no paper. The README's numbers for its worked examples, such as 188 articles to 392 observations to 52 facets, describe committed sample output under examples/; none was re-run.

11. For Your Own Build

Steal

  • Let the model judge and let code apply. The model says which facets the evidence bears on and whether a change is sustained; code decides what a change does to the history and refuses a malformed assertion.
  • Decay on read, on an evidence clock. Store confidence as of its last confirmation, decay it by the observations of that lens since, floor it, and show the model the decayed value so agreement cannot snap it back.
  • Cap the step per review in both directions. A symmetric 0.1 stops one weak window from flattening a facet built on forty observations, and stops a max() from turning confidence into a ratchet.
  • Make deletion reach the derived layer by list, not by refold. Record the deleted id, strip it at the next fold under the writer's lock, and retire what is left citing nothing.
  • Split the claim from the analysis. Send the review one sentence per facet and keep the prose for people.

Avoid

  • Calling record time validity time. If a version's start comes from the writer's clock, the column is a second copy of recorded_at. Carry the evidence's time through to the version, or name the column for what it is.
  • Telling a model its input is chronological when the queue is not. Sort each window by the time the prompt promises, or state the real order in the prompt.
  • Docstrings that assert durability. A claim that a delete survives a re-mine needs the test that re-mines.
  • Unbounded structured reads. A tool that returns every full record of a growing set needs a budget before the archive reaches the size its author already measured.

Fit

witness suits one person who wants a reflective record of their own working habits over months, accepts model calls every few sessions on their own subscription, and never wants memory injected into a session. Read its dates as review dates and it does what it says. It is a poor base for the README's second use, a dated history of a corpus whose events carry dates of their own, because those dates do not reach the facets. It is also a poor fit for an agent that must act on what it remembers: nothing is verified, the agent can edit the evidence, and the read surface is a profile of a person rather than facts for a task.

12. Open Questions

  • Is valid_from meant to take the evidence time once a backfill path exists, and would the merge and the view then read it instead of deriving it?
  • How large does get_facets get on archives never compacted, and has an agent been observed truncating it?
  • How often does a backfill's out-of-order fold produce a close-and-reopen arc that a time-ordered fold would not?
  • Is anything done with the 48 invented citations beyond counting them?

Appendix: File Index

  • Store and schema: internal/store/types.go, db.go, facets.go, obs.go, raw.go, queue.go, confidencelog.go, merge.go, testdata/schema/v15.sql
  • Distillation: internal/distill/worker.go, drain.go, reviewer.go, compact.go, claim.go, summarize.go, sources.go
  • Prompts: prompts/default/extract.md, review.md, prompts/summarize/
  • Retrieval: internal/vector/vector.go, internal/embed/embed.go, internal/model/fetch.go
  • Surfaces: internal/mcp/server.go, cmd/commands/capture.go, session.go, ingest.go, facets.go, compact.go, observations.go
  • View: internal/view/traits.go
  • Tests: cmd/commands/facets_archived_test.go, internal/distill/compactintegration_test.go, prunedeleted_test.go, confidencelog_test.go, reviewer_test.go, internal/mcp/fakestore_test.go, internal/view/traits_test.go, internal/vector/vector_test.go

Recorded searches

Run from the repository root at the pinned commit with /usr/bin/git grep.

  • Every version start is the review clock. git grep -n -E 'ValidFrom:' -- '*.go' ':!*_test.go' returns six writers, each ValidFrom: nowStr, RecordedAt: nowStr, and the reader in facets.go.
  • No read filters on validity. git grep -n -i -E 'valid_from|valid_to' -- '*.go' ':!*_test.go' returns the schema, one SELECT, one INSERT and comments; no WHERE clause.
  • No trust state on a facet or observation. git grep -n -i -E 'status|verified|trusted|candidate|rejected' -- internal/store/testdata/schema/v15.sql internal/store/types.go returns nothing; archived|merged_into on the same files matches.
  • No scope key beyond cwd. git grep -n -i -E 'user_id|tenant|project_id|cwd' -- internal/store/testdata/schema/v15.sql internal/distill internal/mcp returns only session_meta.cwd.
  • The pending-delete list has one consumer. git grep -n -E 'PendingDeletedObservations|deletedObsPendingKey' -- '*.go' ':!*_test.go' returns the writer and reader in obs.go, the prune in reviewer.go, the facet write that clears it and the interface; no mining or append path appears.
  • Two of four facet writers log nothing. git grep -n -E '\.WriteFacets(Logged|Pruned)?\(|writeFacetsTx\(' -- '*.go' ':!*_test.go' shows the claim pass on WriteFacets and the merge on writeFacetsTx, neither with events.
  • The lens filter in search is untested. grep -n 'func Test' internal/vector/vector_test.go returns TestCosine only.
  • No memory benchmark. git grep -n -i -E 'longmemeval|locomo' -- . returns nothing; poignancy|locomo on the same tree matches.
  • No paper. git grep -n -i -E 'arxiv|bibtex|@article|@misc|doi\.org' -- . returns only ingest-id examples in cmd/commands/ingest.go and its test; CITATION.cff is absent.
  • No submodules. .gitmodules is absent.

History

2026-12-02 — f3998902…. First reading at the pin, read at the user's request from the 2026-12-02 triage shortlist, from a full clone at the head of main (tag v0.15.1), read only. Screened: two auto-run surfaces (hooks/witness.sh, which a plugin manifest can register, and server.json, an MCP manifest whose start command fetches a package with npx), two build-time surfaces (Makefile and the prepublishOnly script in npm/opencode/package.json), nothing inside the cooldown, go.sum unchanged for 151 days; AGENTS.md and CLAUDE.md read as data. Nothing was installed, built or run, and no test was run. One mark (section 9).