1. Executive Summary
Fist KB is a local memory for Claude Code and Codex in which the
agent decides what to record. It writes typed records through one MCP
tool and reads them through another, and a session-start hook puts the
project's orientation into context. State is four files in a
KnowledgeBase folder, bound together by hashes in
core.json. There is no model call and no automatic
capture.
Notable: the write path. One request commits as one revision or not at all, every replaced value goes to a journal and can be restored, a replacing operation is refused if its target changed after the revision it names, and an interrupted write reports which files it replaced.
Weak: statuses rank and never withhold, so a superseded or disputed record is returned beside its replacement. An agent-written owner decision is labelled an owner message by default. The writer's name is whatever the caller supplies, and no operation deletes a record or erases a journalled value.
Two marks are present and five are withheld (section 9).
Licence. MIT in LICENSE (copyright 2026
Fist) and in pyproject.toml, with no rider. The engine is a
port of a Seed KB v08 package that PROVENANCE.json
identifies only by name and per-file hashes; that package is not in the
tree, and VALIDATION.md:40 says one of its engine test
cases was not ported because it needs data outside the repository. No
SECURITY.md is committed, so no private reporting route is
stated.
2. Mental Model
A record is what the agent chose to write down, labelled by kind. The
schema separates an owner's decision from an observed fact, a source's
claim, the agent's inference and an assumption, and gives each kind its
own statuses (src/fist_kb/_engine/kb_schema.json:55-64).
Inferences and assumptions are born provisional; everything
else is born active or open.
A record changes only through operations, and each operation that
replaces a value writes the old one to the journal first
(kb_write.py:355-378). The current record is the answer;
the journal is how it came to be. Status is moved by the same agent with
the status operation, and superseded links the
old record to its replacement in both directions
(kb_write.py:496-545).
Status never removes a record from a read. Search multiplies a
superseded or historical record's score by 0.5 and a disputed one's by
0.75, and returns it with superseded_by
(kb_read.py:32, :496-497,
:520-521). A committed test requires the superseded record
to appear (tests/test_engine.py:634-641).
Diagram source
%% caption: one request becomes one revision with every replaced value journalled; on the way back, status changes the order and never the membership
flowchart TD
AG["Agent: kb_write<br/>changes, by, revision"] --> B["Builder on a copy<br/>of revision N"]
B --> ST{"replacing op and<br/>target changed after<br/>expect_revision?"}
ST -- "yes" --> NW["not_written"]
ST -- "no" --> AR["old value to<br/>journal history"]
AR --> V{"whole candidate<br/>validates and base<br/>files unchanged?"}
V -- "no" --> NW
V -- "yes" --> REP["records, journal,<br/>sources replaced"]
REP --> CORE["core.json last:<br/>file hashes, N+1"]
CORE --> RD["kb_read or hook:<br/>hashes checked"]
HK["SessionStart hook"] --> RD
RD --> SC["term score<br/>x status weight"]
SC --> OUT["every status returned;<br/>superseded at 0.5"]3. Architecture
The package is src/fist_kb. The engine in
_engine/ holds storage and the commit protocol
(kb_store.py), writes (kb_write.py), reads and
search (kb_read.py), migration from the 0.3.x layout, a
read-only guest reader, and a preparer that turns registered files into
searchable JSONL. Around it sit a CLI that runs every engine call as a
child process with -P and a per-KB write lock
(cli.py:33-79, :173-178), a Python API that
calls the same CLI (api.py:62-96), an MCP server
(mcp_server.py), per-project selection
(setup.py), and the hook text
(session_context.py).
The package checks its own bytes against a shipped manifest on every
read and write, and a write is refused on a mismatch
(runtime.py:72-96, kb_store.py:574-588,
kb_write.py:73-76). The manifest detects edits to the
installed package; its own docstring says it is not a signature.
Deployment and ergonomics
The plugin starts the MCP server through uv, which on
first launch downloads Python 3.12.15 and the locked dependencies into a
per-user runtime folder (scripts/launch.py:59-82). The hook
runs uv --offline and adds nothing until that runtime
exists (hooks/hooks.json:10-11,
scripts/launch.py:85-94). The project installer, by default
fetched from main by curl | sh
(install.sh:14-15), writes the CLI, skills and hooks into
the project and pre-approves the read tools; it pre-approves
kb_write only with --allow-writes
(scripts/install_project.py:534-538).
dist/ holds the 0.4.2 wheel and plugin ZIP with a
release manifest. Each archive's SHA-256 matches
dist/release-manifest.json, and every entry of both matches
the tree's file byte for byte; I compared them without extracting or
running either.
4. Essential Implementation Paths
- Select.
kb_setupsaves{format, project, kb}to.fist-kb.json; every project-mode tool call names the project andread_bindingrefuses a file whoseprojectis another folder (setup.py:35-51,:133-183,mcp_server.py:38-48). - Write.
_write: tool check, load and validate, writer name, idempotentrequest_id,expect_revisionfor replacing operations, build, then preview or publish (kb_write.py:66-116). - Build.
Builder.apply_allallocates ids and$refnames, applies each operation to a copy, archives replaced values, andfinishappends the write entry (kb_write.py:226-247,:382-389,:756-774). - Commit.
store.commit: validate the candidate, stage four files, refuse if any base file changed, replace withcore.jsonlast, reload and validate (kb_store.py:634-677). - Read.
_read: load with hash check, validate, build the mode's parts, page them to a budget (kb_read.py:49-83,:142-155). - Search.
search_mode(kb_read.py:465-547). - Orient and inject.
orientationandsession_context(kb_read.py:158-184,session_context.py:34-73).
5. Memory Data Model
- Record (
records.jsonl):id(DEC-0001,FACT-0001and so on),kind,status,title,statement, optionaltopics,related,sources,origin,resolutionand kind-specific fields; automaticcreated_at,created_by,updated_at,created_rev,updated_rev,superseded_by,supersedes(kb_schema.json:28-64). Fields are closed and size-limited. - Origin:
type(owner message, observation, source, inference, peer message, import) with optionalby,at,channel,reason, each a string of at most 300 bytes (kb_store.py:311-322). - Journal (
journal.jsonl):writeentries (rev, at, by, note, ops, request id and digest),logentries numbered per record, andhistoryentries numbered per record holding a field's replaced value (kb_store.py:194-202,:423-452). - Sources (
sources.json): a file path inside the bound folder or a URL, SHA-256 and size at registration, and a supersession chain when a file is revised (kb_write.py:655-752). - Core (
core.json): purpose, owner, current task, up to 12 pinned records, up to 40 routes,guest_reads, the last write, and the three state files' hashes (kb_store.py:36-37,:376-420).
Times are the server's write time and the revision.
origin.at is free text the caller supplies, and no code
parses it.
6. Retrieval Mechanics
A query is split into lowercase terms
(kb_read.py:390-391). Each term scores 1 for a whole word
or its inflection, 2/3 for a word start and 1/3 inside a word
(:398-430), weighted by field: id 12, title and topics 8,
statement 6, down to history 1 (kb_schema.json:67). Log and
history count once, at their best entry, so many matching notes cannot
swamp a matching title (kb_read.py:476-478). Coverage is
squared, and a query whose every term matched gets 40 more
(:433-440). The status weight applies last
(:496-497). Ties follow the lead order of a route the query
names (:504-511).
Search covers current fields and log entries, history only with
scope: "all", and never origin
(:454-462). Matching sources and prepared evidence are
appended; evidence whose bytes do not match their recorded hash is
skipped (kb_store.py:521-528).
Every result pages to an estimated token budget, bytes over three,
and a continuation token carries the request and the revision, so a
changed KB is reported rather than mixed (kb_read.py:59-79,
kb_store.py:76-79).
The orientation the hook injects holds the core, the current task
with its rule titles and statuses, the five latest writes, an index of
counts, the task's three latest log entries and every pinned record in
full (kb_read.py:158-184). The hook tries five budgets to
fit 6,000 bytes (session_context.py:18-23,
:53-73).
No retrieval-quality evaluation is committed.
7. Write Mechanics
The agent writes when it judges something material, following the
skill (skills/fist-kb/SKILL.md:30-39). Nothing captures
conversation. A write is synchronous: the MCP tool runs the CLI as a
child process, which takes the write lock, commits, re-reads and returns
the echo, so the record is retrievable on the next read. No background
pass rewrites anything.
new allocates the id and sets the default status. It
does not look for an existing record with the same content; the skill
asks the agent to search first. set with null
removes an optional field and archives it; title and
statement cannot be removed
(kb_write.py:359-369). restore puts a history
entry's value back, except status, which only status moves
(kb_write.py:547-568).
Concurrency is handled three ways: an exclusive
.write.lock in the CLI (cli.py:33-65), a check
that no state file changed while the candidate was built
(kb_store.py:649-652), and expect_revision,
which every replacing operation needs and which refuses a target updated
after it (kb_write.py:103-109, :310-320). A
request_id makes a resend return the first outcome
(:119-134).
Operational cost
No model calls. Each write re-serialises all four files, the whole
journal included, and each read loads and validates the entire state
before answering (kb_store.py:639-664,
kb_read.py:60-61), so both grow with the journal.
8. Agent Integration
The MCP server registers kb_status,
kb_setup, kb_read and kb_write
(mcp_server.py:92-123); a test lists exactly these four
(tests/test_mcp.py:64). In project mode every call carries
the project directory, and there is no global or last-used KB
(mcp_server.py:43-44). The server instructions and the
operating skill tell the agent when to read, when to write, and that
recorded knowledge confers no authority.
The SessionStart hook prints the orientation as plain text under a
header calling it read-only evidence, not instructions
(session_context.py:51-61). A project without a selection
gets nothing; a selection naming another project gets one line
(:36-42). hooks/hooks.json registers
SessionStart only, with the matcher
startup|resume|clear|compact.
A guest reader lets another agent read a KB through the CLI after
checking its own bytes against the manifest;
guest_reads: false refuses it, and its docstring says it is
not an access-control boundary (guest.py:1-13,
:123-127).
9. Reliability, Safety, and Trust
The commit is the strongest part
commit validates the whole candidate before touching
disk, writes four staged files, refuses if any base file changed,
replaces them with core.json last, then reloads and
validates (kb_store.py:634-677). Progress is tracked per
file, so a failure reports not_written,
uncertain or committed_unverified with the
files replaced (kb_store.py:608-622,
kb_write.py:49-63). A committed test injects faults before
replacement, after the records file and after core, and checks each
outcome and that a half-written state refuses reads and writes
(tests/test_engine.py:292-314).
The same hash check makes a hand edit fatal. Any change to a state
file outside the tool leaves every read and write returning
recovery_required, and admin recover only
inspects (kb_store.py:244-249, kb.py:72-84).
The usage guide says not to edit by hand
(docs/USAGE.md:44); the README offers the files to inspect
and back up.
Status ranks, it does not withhold
No read path filters on status unless the caller lists statuses
(kb_read.py:273-276). A superseded decision stays pinned
until someone unpins it, because status does not touch
core.pinned, and the orientation injects every pinned
record in full at each session start (kb_write.py:496-545,
kb_read.py:181-183). The status is shown beside the record,
and the skill tells the model what it means.
Who wrote it, and who said it
created_by and the journal's by are the
name the caller supplies, or KB_ACTOR from the environment
(kb_write.py:79-82). An owner_decision written
without an origin is stored as {"type": "owner_message"},
while the comment on the line above says origin is never silently the
recorder (kb_write.py:35, :415-418). The only
check is a warning when the record has no quote
(:424-425).
Nothing leaves
There is no delete operation, and no value leaves the journal.
Correcting a statement keeps the old wording in history, where
scope: "all" searches it and restore brings it
back. A secret written once stays until someone edits the files and
repairs the hashes by hand.
Marks
audit_log— present.journal.jsonlholds one entry per committed write and every replaced value, appended by both writers and hash-bound bycore.json; the writer is self-declared.negative_eval— present. Tampered prepared evidence and a page's script text must stay out of search, and a topic-limited search must leave out records an unscoped one returned.trust_state— withheld. Provisional, disputed, superseded and historical are discrete and agent-settable, and every read returns them; the statuses rank and label.bitemporal— withheld. Records carry write time and revision; the old value's time is its history entry's.origin.atis caller text no code reads.scope_enforced— withheld. Each project has its own folder, a physical partition with no key on a record and no predicate on a read. The selection file and the KB's bound parent folder refuse a mismatched pairing.human_review— withheld.previewandconfirmare fields of the samekb_writecall the agent holds, and the confirmingbyis any name. The task statusawaiting_ownergates nothing.tombstone— withheld. A superseded record and an archived value are keyed on the record;newcompares nothing, so the corrected wording can be written again as a freshactiverecord.
10. Tests, Evals, and Benchmarks
The suite is unittest: 98 test functions in nine files.
The engine tests (26) run every operation through the public CLI as
separate processes, the way a host does
(tests/test_engine.py:1-7). The MCP tests start a real
stdio server and client (tests/test_mcp.py,
tests/test_project_mcp.py). The hook tests run the
session-context entry point and the launcher
(tests/test_session_context.py). The installer has 14
cases. Two cases skip without uv or off Linux.
No CI configuration is committed. VALIDATION.md records
the maintainer's runs per release, including ten mutation controls for
0.4.0, each a fault that made its targeted test fail
(VALIDATION.md:41-49). Those are claims about runs I did
not see. I ran none of the tests.
The negative cases are about integrity and topic, not belief. In one
test, search returns a prepared page's evidence without its script text;
one byte appended to the prepared file then removes the evidence from
the next search (tests/test_engine.py:548-578). The
session-start tests assert that a project with no selection, and a
selection file naming another project, inject no core
(tests/test_session_context.py:81-102).
Cases to want first: a search after supersession that asserts what the agent is given, or a test that names the ranking as the intended contract; a pinned superseded record in the orientation; and an owner decision written without an origin.
No paper describes Fist KB.
11. For Your Own Build
Steal
- Archive on replace, in the engine. If every
replacing operation writes the old value before the new one, a
correction is never a loss and
restoreis a write like any other. - Name the revision you read. Requiring
expect_revisionon replacing operations only, and checking it per target, refuses the stale edit without serialising every append. - Report the honest outcome. Tracking which files
were replaced lets an interrupted write say
uncertainrather than retry, and arequest_idmakes the resend safe. - Page, never truncate. A continuation token that carries the revision makes a large read complete or explicitly stale.
Avoid
- Do not default provenance to the most authoritative source. If the writer omits an origin, record that it was omitted.
- Do not leave a superseded record pinned. Supersession should unpin, or the orientation should drop it.
- Do not make the store's own files a trap. A hash check that refuses every read after a hand edit needs a repair command beside it.
Fit
Fits one developer who wants a coding agent to keep decisions and findings in a format they can read, diff and back up, and who wants every correction kept. The write path is careful enough to copy.
Walk away if a correction must stop the old answer reaching the agent, if several people write to one KB and attribution matters, or if remembered content may need to be erased.
12. Open Questions
- Whether status is meant to filter anywhere, given that the usage guide documents ranking and the skill says ranking does not establish supersession.
- Whether
owner_messageis the intended default origin for an agent-written owner decision. - How a user is meant to remove a value from the journal.
- What the one unported Seed KB engine test covered.
Appendix: File Index
- Engine:
src/fist_kb/_engine/kb_store.py,kb_write.py,kb_read.py,kb_schema.json,kb.py - Sources and evidence:
src/fist_kb/_engine/prepare.py,src/fist_kb/_engine/source_versions.py - Guest and migration:
src/fist_kb/_engine/guest.py,src/fist_kb/_engine/kb_migrate.py - Agent surface:
src/fist_kb/mcp_server.py,src/fist_kb/session_context.py,skills/fist-kb/SKILL.md,skills/setup/SKILL.md,hooks/hooks.json,hooks/codex-hooks.json - Selection and process:
src/fist_kb/setup.py,src/fist_kb/cli.py,src/fist_kb/api.py,src/fist_kb/runtime.py - Install and launch:
scripts/launch.py,scripts/install_project.py,install.sh,install.ps1 - Claims:
PROVENANCE.json,VALIDATION.md,docs/USAGE.md,docs/EVIDENCE.md - Tests:
tests/test_engine.py,tests/test_session_context.py,tests/test_mcp.py,tests/test_project_mcp.py,tests/test_setup.py
Recorded searches
Run from the repository root at the pinned commit with
/usr/bin/git grep.
- No operation deletes a record.
git grep -n -E 'def op_' -- src/fist_kb/_engine/kb_write.pyreturnsop_new,op_set,op_log,op_add,op_remove(list items),op_status,op_restore,op_coreandop_source. - Nothing erases.
git grep -n -i -E 'erase|purge|forget' -- srcreturns nothing; the same search with|redactadded matches 42 lines, all inprepare.py. - Status is not a default filter.
git grep -n -F 'STATUS_WEIGHT' -- srcreturnskb_read.py:32and:497;git grep -n -E 'statuses' -- src/fist_kb/_engine/kb_read.pyreturns onlyfilteredat:274-276, which applies a caller's list. - No validity time.
git grep -n -w -E 'valid_from|valid_to|valid_until|expires_at|expires' -- srcreturns nothing;-w -E 'created_at|updated_at'matches in three files. - Origin is never searched or parsed.
git grep -n -E 'origin' -- src/fist_kb/_engine/kb_read.pyreturns:340,:370(echo and paging) and:456, which excludes it from search. - No duplicate check on a new record.
git grep -n -i 'duplicate' -- src/fist_kb/_engine/kb_write.pyreturns onlyduplicate_sourceat:692. - No tombstone.
git grep -n -i -E 'rejected|tombstone|denylist|blocklist' -- srcreturns nothing. - Supersession does not unpin.
git grep -n -E 'pinned' -- src/fist_kb/_engine/kb_write.pyreturnsCORE_TARGETat:33and thepin/unpinbranch at:594-600. - One hook event.
git grep -n -E 'PreCompact|Stop' -- hooksreturns nothing;SessionStartmatches both hook files at line 4. - No CI, security policy or paper.
git ls-files | grep -i -E 'security|^\.github|citation'returns nothing;git grep -n -i -E 'arxiv|doi\.org|bibtex' -- .returns nothing.
History
2026-12-04 — e555d37c….
First reading, at the head of main on 2026-12-04. Screened:
ten files; five auto-run surfaces (the Claude Code marketplace and
plugin manifests, the plugin manifest starting the MCP server,
hooks/hooks.json and hooks/codex-hooks.json,
which register SessionStart only, and mcp.json). Two
dependency surfaces fell inside the cooldown, a count the depth-1 clone
inflates; one build-time execution point was flagged by name,
src/fist_kb/setup.py, which is the KB selection module
under a Hatchling build; no surface was unpinned. Nothing was installed,
built or run, and none of the 98 test functions was run. Two marks (section 9).