Two changes that make the index reflect work as it happens. Reasoning is now indexed. The model's own justification is where a decision is explained, and it never appears in the text a reader sees. It is also enormous — individual parts reach 175 KB — so each part is truncated to 1.2 KB and each session is budgeted 4 KB. It lands in content (searchable) but stays out of the summary, which is what search results and MCP output show. Capturing it exposed a dedupe bug: sessions were skipped when created_at and summary matched, so content that gained reasoning behind unchanged prose was never recorded. IngestResult now carries a content hash and the sweep compares it, which is what the observation layer already used internally. Freshness: the watcher polls every two minutes, so a finished turn stayed unsearchable that long. IngestSessionsNow shares the watcher's logic, sweeps only sessions newer than a stored watermark, and runs in ~45 ms steady state (a full sweep is ~21 s for 59k messages). The plugin calls it at prompt admission, fire-and-forget.
knox.claims — OpenCode plugin
Warns when a request restates a figure that an earlier turn measured but the current turn did not.
Why
The failure mode is drift, not ignorance: a number is derived once — sometimes
against the wrong reference — then quoted in later turns, and each restatement
makes it feel more established. In this repo that produced "6,884 lines behind
main" from a diff measured against bb852fa, repeated across five turns, which
drove a branch decision that had to be undone.
How it works
The context session hook runs immediately before a request is dispatched,
including tool-driven continuations. It gets the assembled messages, splits them
at the last user message, and passes:
{ "prose": "<last assistant text>", "outputs": ["<this turn's tool output>"], "earlier": ["<previous turns'>"] }
to knox claims check, which replies with each numeric claim tagged
sourced / stale / unsupported. Only stale claims produce a warning, which
is appended as a system part for that request.
All classification lives in the Go binary, so the plugin cannot drift from the tested implementation.
Why there is no @opencode/plugin import
The docs show import { Plugin } from "@opencode/plugin", but a local plugin
loaded by path cannot resolve that bare specifier. Verified by experiment:
| File | Imports | Result |
|---|---|---|
index.js |
none | active |
index.ts |
none | active |
index.ts |
@opencode/plugin |
failed to load |
index.ts |
@opencode-ai/plugin |
failed to load |
Plugin.define is an identity function in the runtime, so exporting the
definition object directly is exactly equivalent. Only node: builtins resolve.
Enable
// ~/.config/opencode/opencode.json
{
"plugins": ["/home/david/assistant/knox/plugins/claims"]
}
Takes effect on the next opencode service restart.
Session freshness
knox's watcher polls opencode.db every two minutes, so a finished turn is not
searchable for up to that long. The plugin runs knox ingest sessions at prompt
admission to close the gap.
Steady state is ~45 ms because the sweep keeps a watermark of the newest
session.time_updated already indexed, so it reads only sessions touched since.
Without the watermark a sweep re-reads every message (~21 s for 59k) — the
reason this is scoped and incremented rather than a full ingest.
The first run after install has no watermark and does a full sweep (~21 s). It is fire-and-forget, so it never delays the turn that triggered it.
Configure
| Env | Default | Meaning |
|---|---|---|
KNOX_BIN |
knox (on PATH) |
Binary to invoke. Set an absolute path when the daemon's PATH does not include it. |
Failure behaviour
Every failure path is swallowed: a missing binary, a timeout (2 s), or malformed JSON results in no warning and an unmodified request. A guardrail must never break the thing it guards.
Not implemented
- It cannot force a re-check; it appears in the system prompt as guidance.
- It only sees numeric claims in prose, not comparatives ("the trees are identical") — those need a different signal and would be far noisier.