Metadata-Version: 2.4
Name: cognikernel
Version: 0.1.0
Summary: CogniKernel — persistent, structured project memory for Claude Code and Codex
Project-URL: Homepage, https://github.com/KanishkNoir/cognikernel
Project-URL: Repository, https://github.com/KanishkNoir/cognikernel
Project-URL: Issues, https://github.com/KanishkNoir/cognikernel/issues
Project-URL: Changelog, https://github.com/KanishkNoir/cognikernel/releases
Author: Kanishk Singh
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright [yyyy] [name of copyright owner]
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
License-File: LICENSE
Keywords: ai-agents,claude-code,codex,context,llm,mcp,memory
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development
Requires-Python: >=3.11
Requires-Dist: mcp>=1.0
Requires-Dist: pyahocorasick>=2.0
Requires-Dist: tree-sitter-language-pack>=1.0
Requires-Dist: tree-sitter>=0.22
Provides-Extra: embedding
Requires-Dist: fastembed>=0.3; extra == 'embedding'
Requires-Dist: numpy>=1.24; extra == 'embedding'
Provides-Extra: tokens
Requires-Dist: tiktoken>=0.5; extra == 'tokens'
Description-Content-Type: text/markdown

# CogniKernel

**Persistent, structured project memory for Claude Code — and Codex.** CogniKernel
watches a coding session through its hook surfaces, extracts the *decisions,
constraints, and abandoned approaches* worth keeping, consolidates them into an
event-sourced store, and injects them back as a compact context block the next
time you work — so the agent stops re-deciding what you already decided. The store
is keyed on the project path, so memory made in one tool travels to the other.

It is **not** a vector-database wrapper. It is an event-sourced log of *typed*
memory with lexical-primary retrieval, write-time consolidation, and a fail-open
reliability spine designed never to break your session.

**And there is no LLM in the loop.** Most memory tools work by sending your
transcripts to a generative model to "summarize what mattered" — another API
key, per-session token cost, added latency, and your session content leaving
the machine. CogniKernel treats extraction as *classification, not generation*:
a deterministic sanitize → classify → consolidate pipeline, with two small
fine-tuned encoder models (~130 MB ONNX, run locally on CPU in milliseconds)
scoring salience and detecting when a new decision supersedes an old one. No
API calls, no tokens billed, nothing leaves your machine. The only LLM involved
is the coding agent you already run — CogniKernel makes it remember.

---

## The fine-tuned models

Two small encoder models do the actual thinking behind CogniKernel — not a keyword
list, not an LLM call:

| Model | What it decides | Why it's an encoder, not an LLM |
|---|---|---|
| **`salience_v2`** | For every sentence in a session transcript: is this worth keeping, and what type — `DECISION`, `CONSTRAINT_HARD`/`SOFT`, `APPROACH_ABANDONED_DO_NOT_RETRY`, or noise? This is the model that decides *what gets remembered.* | A fine-tuned SetFit classifier (bge-small backbone, ~130 MB ONNX) runs this on CPU in milliseconds. An LLM doing the same job costs an API call and real latency on every session — CogniKernel spends neither. |
| **`supersession_xenc`** | Does this new fact *replace* an existing one (a decision changed, a constraint was relaxed), or does it just restate what's already stored? This is the model behind latest-wins consolidation. | Same constraint: this fires on every capture. A cross-encoder scores it locally in milliseconds instead of round-tripping to a model API. |

**Validated on held-out data, not vibes.** Each model is scored against a frozen
evaluation set mined from real captured project stores that the training data never
sees — retraining on the eval set is a standing rule violation, not a shortcut we
occasionally allow. Because the underlying task (is this sentence a decision, or just
description?) is itself genuinely ambiguous at the margin, we also measure how much
*two independent human labelers* agree with each other on the same sentences, and hold
the model to that ceiling rather than to a naive 100%. The model's minority classes
(rare event types with few historical examples) are tracked and grown deliberately,
because a thin eval slice can hide the exact class that most needs work.

**They're optional but on by default — here's the fail-open contract.** `cognikernel init`
writes a per-project config that already selects the fine-tuned path
(`extractor = "v2-broad"`, `cross_encoder_supersession = true`). What's missing after
`init` is the ~270 MB of model weights themselves — that's what
`cognikernel install-heads` fetches. Until you run it, CogniKernel works, but degrades
both decisions to a deterministic keyword/lexical fallback (weaker: it can miss
decisions phrased outside its trigger vocabulary, and it can't catch a paraphrased
correction lexical matching misses) — `cognikernel doctor` names this state explicitly
rather than leaving it invisible (see below). Nothing breaks either way — that's
the fail-open design — but the fine-tuned path is the better-quality one, and the
one new projects are configured to use by default. See [Quickstart](#quickstart) to
install them.

---

## The memory loop

Everything CogniKernel does is one loop: **observe → extract → consolidate →
store → retrieve → assemble → inject**. The left rail captures; the right rail
recalls; the spine underneath keeps both honest.

```
   +========================= CLAUDE CODE SESSION =========================+
   | working memory  -  the context window the agent reasons in            |
   +--------------+-----------------------------------------+--------------+
                  | Stop hook captures transcript           | inject block
                  v                                         ^
   +--------------+---------------+         +---------------+--------------+
   | [1] EXTRACTION PIPELINE      |         | [6] COMPRESSION + INJECTION  |
   |   sanitize -> classify ->    |         |   authority-weighted budget, |
   |   salience (ONNX) ->         |         |   drop-to-fit (keep every    |
   |   decision-key + contracts   |         |   constraint) -> block       |
   +--------------+---------------+         +---------------+--------------+
                  | enqueue                                 | rank + fit
                  v                                         ^
   +--------------+---------------+         +---------------+--------------+
   | [2] WORKER + CONSOLIDATION   |         | [5] RETRIEVAL                |
   |   claim -> delta-merge ->    |         |   FTS5 BM25 + dense -> RRF   |
   |   supersede (latest-wins) -> |         |   prohibition_search (K1)    |
   |   project   (idempotent)     |         |   skeleton graph (PageRank)  |
   +--------------+---------------+         +---------------+--------------+
                  | persist (atomic)                        | recall
                  v                                         ^
   +--------------+-----------------------------------------+--------------+
   | [3] EVENT-SOURCED STORE   *   SQLite (WAL)                            |
   | typed events | evidence | provenance | FTS5 | embeddings | ledger     |
   +----------------------------------------------------------------------+
   | [4] RELIABILITY SPINE   atomic migrations | idempotent replay |       |
   | doctor --strict | fail-open hooks | import-linter | CI gate           |
   +----------------------------------------------------------------------+
```

---

## The four hook surfaces

CogniKernel attaches to a session at four points. Each is fail-open — if memory
is unavailable or errors, the hook logs at `WARNING`, returns cleanly, and the
session continues. `salience_v2` and `supersession_xenc` (above) do the
classification behind Capture and Session block; nothing here is a hardcoded
keyword list unless the fallback path is active.

| Surface | Hook | Authority | What it does | Why you care |
|---|---|---|---|---|
| **Session block** | `SessionStart` | advisory | injects the canonical decisions/constraints/skeleton block | a new session already knows what the last one decided — no "let me re-read the codebase to remember where we were" |
| **CK-1 recall** | `UserPromptSubmit` | advisory | surfaces prompt-relevant memory, dual-evidence gated, dedup'd via render ledger | ask about a subsystem and the relevant prior decision rides in with your prompt, unasked |
| **Read/Edit gate** | `PreToolUse` | **hard / JIT** | read-efficiency gate on Read/Grep; **just-in-time prohibition surfacing** on Write/Edit (K2) | the agent gets warned *at the moment it's about to violate a past decision*, not three files later when you notice |
| **Capture** | `Stop` | side-effect | extracts and persists decisions — you never write memory to CLAUDE.md by hand | you never write down what you decided; the next session already has it |

---

## What gets remembered

Memory is **typed**, not free-text chunks. The type drives ranking, rendering,
and supersession:

- `DECISION` — a choice that was made ("use Redis for the rate limiter")
- `CONSTRAINT_HARD` / `CONSTRAINT_SOFT` — rules, graded by deontic force
- `APPROACH_ABANDONED_DO_NOT_RETRY` — a dead end, kept in the **graveyard** so
  the agent doesn't re-attempt it
- conventions, config facts, schema decisions (canonical role keys)

A **decision key** lets a later restatement *supersede* an earlier one
(latest-wins), so the store self-consolidates instead of accumulating
contradictions. An optional cross-encoder adds semantic supersession when the
encoder backend is installed.

---

## Retrieval

Lexical-primary, with dense as a fused signal — never pure vector:

- **Hybrid core** — FTS5 BM25 ∪ optional dense embeddings → Reciprocal Rank Fusion
- **prohibition_search** — a type-restricted lexical pool so a "do not do X" rule
  can't be crowded out by topically-similar prose at the moment you're about to do X
- **Skeleton** — an AST symbol graph ranked by PageRank; `find_related` unions
  **semantic (embedding) neighbours** with **import-graph-adjacent** events to
  surface what a change touches (the semantic axis needs the `embedding` extra)
- **Golden-record consolidation at read** — latest-wins reconciliation so recall
  returns one coherent answer, not a pile of revisions

---

## What it saves you

Benchmarked in a three-arm comparison — CogniKernel vs flat curated notes vs no
memory — with real agent sessions across four multi-session projects:

- **File reads: the universal win.** The CogniKernel arm made the fewest file
  reads in *every* project — typically **2–4× fewer** (23 vs 63, 16 vs 47/53,
  40 vs 89/83), and in the best case **3 reads vs 29** because the injected
  block + AST skeleton carried the whole repo's shape. Fewer reads means fewer
  tool round-trips and more of the context window left for actual work — your
  session gets *longer* before compaction, not just cheaper.
- **Tokens: up to ~20% cheaper where memory matters.** Price-weighted token
  cost (cache-write 1.25×, cache-read 0.1×, output 5×) came out **18–23% lower**
  on projects with evolving decisions and cross-file dependencies — and roughly
  a wash on small implementation-heavy projects where the code itself is cheap
  to re-read. We publish the honest number, not the raw-token one (raw sums
  look ~30–40% better, but ~95% of any session's bill is discounted cache-read).
- **Recall instead of re-derivation.** Where memory earns its keep is projects
  whose state is too large, too evolving, or too long-lived to re-derive
  cheaply: the agent starts already knowing the decisions, constraints, and
  dead ends, instead of spending the first quarter of the session rediscovering
  them.

---

## Reliability — the spine

The system is designed to degrade *legibly*, never silently:

- **Atomic migrations** — each numbered migration applies its body + version bump
  in one transaction; safe to crash mid-script
- **Idempotent replay** — a re-run worker job can't double-count or drift decay (evidence-provenance guard)
- **Fail-open hooks** — every surface swallows its own failure *and logs at WARNING*; silence never reads as success
- **`cognikernel doctor --strict`** — per-subsystem health (schema, FTS5, embeddings, symbols, worker queue); non-zero exit when degraded
- **Architecture enforcement** — `import-linter` layered contracts, guarded by a meta-test so a typo can't silently disable them
- **CI promotion gate** — lint + full suite (incl. `tests/reliability/` failure-injection) on every PR; see [`CONTRIBUTING.md`](CONTRIBUTING.md)

---

## Cross-platform (Codex)

The store is platform-neutral — one SQLite DB per logical project, so Claude Code
and Codex working in the same directory share one memory. Project resolution is
**alias-aware**: `C:\repo` and `/mnt/c/repo` resolve to the same store, so memory
follows the checkout across Windows, WSL, and native mounts; for genuinely
different checkout paths, an opt-in `project_identity` key in
`.cognikernel/config.toml` pins them to one shared store. Codex reads memory through
the registered MCP server (`get_session_state` / `recall`); the capture direction
is **pull-based**, because Codex has no `Stop`-hook equivalent:

- **`cognikernel codex-sync <project>`** scans `~/.codex/sessions` for rollouts whose
  recorded `cwd` maps to the project and captures the delta through the *same*
  extraction pipeline (a rollout→transcript adapter is the only Codex-specific
  code; delta/dedup/idempotency are shared and unchanged).
- **Automatic at the handoff** — Claude's SessionStart drains pending Codex
  rollouts before building the block, and the MCP server's queue drainer pulls
  new rollouts each cycle, so a live Claude session picks up Codex-side decisions
  without waiting for the next session; on the Codex side, `init` writes an
  `AGENTS.md` instruction + a `ck-sync` skill so Codex pulls at session start.
- **`init` provisions both** — `.mcp.json` (Claude) and `.codex/config.toml`
  (with the server's `cwd` + project env pinned) + `AGENTS.md` (Codex),
  idempotently and without clobbering existing settings.
- **`cognikernel doctor`** reports a `codex` health line (sessions dir + rollout
  count, or "nothing to sync" — Codex is optional, so its absence is healthy).

A decision made in Codex reaches the next Claude session's block, and
vice versa. The action-point surfaces (CK-1, PreToolUse gate) are Claude-only —
Codex has no per-prompt/per-tool hook — so on Codex the loop degrades to the shared
block + MCP recall.

---

## Interfaces

**MCP tools** (the session block is injected automatically; these are for targeted use):
`recall` · `find_related` · `skeleton` · `get_session_state`

**CLI:**
- `cognikernel init <project>` — register the project and install the session hooks
- `cognikernel doctor [--strict] <project>` — subsystem health report
- `cognikernel codex-sync <project>` — capture Codex CLI sessions for this project
- `cognikernel install-heads` — install the trained encoder artifacts (salience + cross-encoder ONNX bodies): downloaded from the [`heads-v1` release](https://github.com/KanishkNoir/cognikernel/releases/tag/heads-v1) and sha256-verified, or copied from a local `models/` export when present
- `cognikernel show <project>` / `cognikernel reset <project>` — inspect / clear stored memory

---

## Quickstart

```sh
# 1. Install the package
uv sync                      # core (lexical-only)
uv sync --extra embedding    # + dense retrieval (fastembed + numpy) — recommended

# 2. Register the project (writes .mcp.json, hooks, and a per-project config that
#    already selects the fine-tuned extraction path — see below)
uv run cognikernel init .

# 3. Install the fine-tuned encoder heads — the models described above
uv run cognikernel install-heads     # ~270 MB, one-time, sha256-verified

# 4. Confirm everything is wired up
uv run cognikernel doctor .
```

Step 3 is the one easiest to skip and most worth not skipping: `cognikernel init`
already configured this project to use `salience_v2` and `supersession_xenc`
(`extractor = "v2-broad"`, `cross_encoder_supersession = true` in
`.cognikernel/config.toml`) — `install-heads` is what actually supplies the model
weights those settings call for. Skip it and CogniKernel still runs, just on the
weaker deterministic fallback (fail-open, not a hard error). The download pulls
from the [`heads-v1` release](https://github.com/KanishkNoir/cognikernel/releases/tag/heads-v1)
by default; pass `--source <dir>` to install from a local `models/` export instead,
or `--no-download` to skip the network fetch and rely on the fallback deliberately.

Step 4 actually tells you which path is active — `cognikernel doctor`'s subsystem
health block reports `salience_head` and `supersession_head` by name:

```
-- subsystem health -----------------------------------------
  [OK] salience_head    : installed, loads from ~/.cognikernel/models/salience_v2
  [OK] supersession_head: installed, loads from ~/.cognikernel/models/supersession_xenc
```

If you skipped `install-heads` (or ran `uv sync` without `--extra embedding`,
which is where the ONNX runtime itself comes from), the same lines say
`not installed` / `onnxruntime/tokenizers not installed` and name the exact
command to fix it — this is always informational, never a `doctor --strict`
failure, since the legacy fallback is a fully supported mode.

Then start a Claude Code session in the project — the memory block appears
automatically at session start, and decisions are captured when the session ends.

---

## Project layout

```
src/cognikernel/
  integration/   hooks, CLI, MCP server, session/worker orchestration
  extraction/    sanitize -> classify -> salience -> decision-key pipeline
  delta/         delta-merge + supersession (latest-wins; cross-encoder optional)
  retrieval/     hybrid BM25 + dense -> RRF
  storage/       event-sourced SQLite, FTS5, migrations, render ledger
  embedding/     optional dense vectors (fastembed)
  symbols/       AST skeleton + PageRank graph
  compression/   authority-weighted drop-to-fit budget
  injection/     block template assembly
  model.py       Event — the dependency-free domain primitive
tests/
  unit/          per-subsystem
  reliability/   crash-replay · worker-contention · corrupt-input injection
```

---

## Status

Schema **v18** (includes the Codex cross-platform capture). Architecture
contracts: 3 kept / 0 broken. CI gate: lint + full suite on Ubuntu (3.11/3.12) and
Windows. See `CONTRIBUTING.md` for the Definition of Done that gates every change.
