You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6fb0800
Browse filesBrowse the repository at this point in the historyBrowse files
#3 (Med) Docs claimed schema v23 while code is at v26. Updated ARCHITECTURE.md
(listing v24 historian_runs, v25 pi_stable_id_scheme, v26 memory_mutation_log +
cached_m1_bytes) and STRUCTURE.md to v26. Added the safeguard the audit asked
for: export LATEST_MIGRATION_VERSION (derived from the MIGRATIONS array) and a
schema-version-fence.test.ts asserting LATEST_SUPPORTED_VERSION ===
LATEST_MIGRATION_VERSION, so forgetting to bump the fence ceiling (a bug the
project already hit in v2 work) now fails CI.
Documented the remaining accepted/deferred findings in AUDIT-KNOWN-ISSUES.md so
future audits don't re-flag them:
- A14 #2 vestigial session_facts/plugin_messages (inert; drop gated on min TUI)
+ code pointer at getSessionFactsVersion
- A15 #18 in-session memory mutation eventual-consistency (by design)
- A16 #24 session queries not harness-scoped (latent; IDs don't collide)
- A17 #26 materializeM0 double budget-guard (observation, no risk)
- A18 #16 legacy V5 key-files path (deferred; V6 trust enforcement added earlier)
- A19 #13 Pi inject-compartments byte-parity test (guarded by PARITY.md + audits)
Copy file name to clipboardExpand all lines: ARCHITECTURE.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -383,7 +383,7 @@ Magic Context runs in three effective modes depending on `ctx_reduce_enabled` an
383
383
384
384
**Storage:** Use the SQLite database created by `src/features/magic-context/storage-db.ts` under the cortexkit data directory resolved by `src/shared/data-path.ts` (`~/.local/share/cortexkit/magic-context/context.db` on Linux/macOS, XDG-equivalent on Windows). Legacy OpenCode-plugin-folder DBs are migrated forward on first boot. The same DB is shared cross-harness between OpenCode and Pi; session-scoped tables include a `harness` discriminator (`'opencode'` / `'pi'`) while project-scoped tables (memories, git commits) are shared.
385
385
386
-
**Schema migrations:** `src/features/magic-context/migrations.ts` declares versioned migrations v1–v23 (`LATEST_SUPPORTED_VERSION = 23` in `storage-db.ts` is the schema-fence ceiling and MUST be bumped with every new migration). Notable: v10 `tool_owner_message_id` (composite tool-tag identity); v11 `todo_synthetic_*` (synthetic-todowrite); v12 orphan `memory_embeddings` cleanup; v13 `pending_compaction_marker_state` (deferred-marker drain); v14 project-scoped key files + version counter; v15 `deferred_execute_state` (boundary execution); v16 context-limit cache sentinels; v17 multi-anchor note-nudge/auto-search JSON storage; v18 `pending_pi_compaction_marker_state`; v19 compartment-state lease table; v20 subagent invocation token accounting; v21 session lifetime work metrics; **v22 the v2.0 cache-architecture foundation (m[0]/m[1] split tables, `project_state` epoch counter, plus per-compartment `p1`–`p4` tier columns, `importance`, `episode_type`, `p1_embedding`, and `legacy` flag); v23 `compartment_events` (historian-extracted causal_incident / trajectory_correction, stored-not-rendered in v2.0).** Migration runner uses `schema_migrations` table with version-ordered execution and sibling-startup race protection (duplicate-insert is tolerated).
386
+
**Schema migrations:** `src/features/magic-context/migrations.ts` declares versioned migrations v1–v26 (`LATEST_SUPPORTED_VERSION = 26` in `storage-db.ts` is the schema-fence ceiling and MUST be bumped with every new migration; a unit test — `schema-version-fence.test.ts` — asserts `LATEST_SUPPORTED_VERSION === LATEST_MIGRATION_VERSION` so the two can't drift). Notable: v10 `tool_owner_message_id` (composite tool-tag identity); v11 `todo_synthetic_*` (synthetic-todowrite); v12 orphan `memory_embeddings` cleanup; v13 `pending_compaction_marker_state` (deferred-marker drain); v14 project-scoped key files + version counter; v15 `deferred_execute_state` (boundary execution); v16 context-limit cache sentinels; v17 multi-anchor note-nudge/auto-search JSON storage; v18 `pending_pi_compaction_marker_state`; v19 compartment-state lease table; v20 subagent invocation token accounting; v21 session lifetime work metrics; **v22 the v2.0 cache-architecture foundation (m[0]/m[1] split tables, `project_state` epoch counter, plus per-compartment `p1`–`p4` tier columns, `importance`, `episode_type`, `p1_embedding`, and `legacy` flag); v23 `compartment_events` (historian-extracted causal_incident / trajectory_correction, stored-not-rendered in v2.0); v24 `historian_runs` telemetry (per-run chunk range, compartment/fact/event counts, importance min/max/avg, status + failure reason, FK to `subagent_invocations`); v25 `pi_stable_id_scheme` (Pi stable-id cutover watermark); v26 `memory_mutation_log` + `cached_m1_bytes` (memory supersede-delta — non-additive in-session memory mutations render as an m[1] `<memory-updates>` delta instead of bumping the project epoch, plus the frozen-m[1]-bytes cache column).** Migration runner uses `schema_migrations` table with version-ordered execution and sibling-startup race protection (duplicate-insert is tolerated).
387
387
388
388
**Harness-aware behavior:**`src/shared/harness.ts` exposes `setHarness()`/`getHarness()` for the runtime to identify itself; production INSERTs into session-scoped tables tag rows with the current harness. Pi-specific session-resolution paths are skipped on OpenCode and vice versa.
-`src/features/magic-context/storage-meta-persisted.ts`: Read and write per-session persisted scalars and JSON blobs.
122
-
-`src/features/magic-context/migrations.ts`: Versioned schema migrations v1–v23 (`LATEST_SUPPORTED_VERSION` in `storage-db.ts` must track the highest).
122
+
-`src/features/magic-context/migrations.ts`: Versioned schema migrations v1–v26 (`LATEST_SUPPORTED_VERSION` in `storage-db.ts` must track the highest; `schema-version-fence.test.ts` asserts they stay in lockstep).
123
123
-`src/features/magic-context/message-index.ts`: FTS-backed raw-message index for `ctx_search`.
124
124
-`src/features/magic-context/search.ts`: Unified retrieval over memories, raw messages, and git commits.
0 commit comments