Repository navigation
feat(insights): the store indexes the words (M19c) - #36
Open
jgrodziski wants to merge 4 commits into
Open
jgrodziski wants to merge 4 commits into
jgrodziski wants to merge 4 commits into
Conversation
Migration 1, the first rung of the ladder to run on a real file, creates insight_word: one row per entry of a block's `words`, the entry as JSON text less its `meaning`, with word, concern, sense and confidence generated over it, indexed on word and id. A record's rows are written with it in the unit's transaction (the replaced record's deleted first), an import rebuilds the table, and nothing is exported from it. The migration projects the words a version-1 block already holds: a build asking prompt 2 on a version-1 store wrote some. A reader still refuses an older store; its message now says any `explain` on it migrates it, --dry-run included, which calls no model. Tests: a property that the table is every record's words in block order for any side-car, rebuilt by an import; a put replacing words, and a refused unit writing none; and, from fixtures/store-v1.sql (the .dump of a store the version-1 build wrote, with its export), the migration keeping records, failures, ledger and stamp, exporting the same bytes, the reader's refusal, and a failed migration left at 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`codegraph insights` on a store the version-1 build wrote exits 2, names the migration that calls no model, and leaves the file's bytes alone; `explain --dry-run` on it migrates it to version 2, with its six records, asks for no client and writes no side-car. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/insights.md describes insight_word and the migration, and that a reader refuses an older store with the way to migrate it; docs/ cli.md says so for `codegraph insights`. The `--insights` help (and the website's serve page, which restates it) and the route's comment say the panel shows nothing for a store no explain has migrated yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
§20.3 records the store as built: JSON entries with generated columns, no `meaning`, the backfill §20.3 said was not needed, the reader rule kept, the real-file fixture, and the scale measured on a synthetic side-car at Broadleaf's counts. §20.4 checks the item, the real Broadleaf side-car owed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second step of milestone M19c in PLAN.md §20 (word cloud / glossary, #6). Stacked on #35: review that first. This PR's diff is the four commits after #35.
The insights store moves to version 2. A new table,
insight_word, holds one row per word a record defines, indexed by word and by record id, so the readers in PR 11 (insights --word,/glossary.json…) look a word up through an index instead of scanning every block.The table (
packages/insights)words, in block order. The row keeps the entry as JSON (entry);word,concern,senseandconfidenceare generated columns over it, asconceptalready is overinsight.block. A column string holding U+0000 reads back cut short throughnode:sqlite, so a side-car that decodes would otherwise fail its round trip.instays insideentry: it is a reserved word in SQL, and nothing filters on it.meaning. It was a third of the table. A reader that shows it reads the record's block.--importrebuilds the table. Nothing is exported from it: the side-car round trip is unchanged.The migration from version 1
INSIGHTS_DB_VERSIONmoves from 1 to 2. The migration creates the table and fills it from the words already stored. PLAN expected nothing to fill, but #35's build writes words into a store still at version 1. A migration that fails leaves the file at version 1, untouched.The test is a real version-1 file: a
sqlite3 .dumpof a store #35's build wrote (test/fixtures/store-v1.sql), with that build's export and the script that wrote it. It is a text dump because.gitignoreexcludes*.db. Migrated, the store keeps its records, failures, ledger and export stamp, and exports the version-1 build's bytes.Worth a look in review: readers still never migrate. PLAN's M16c rule is kept:
codegraph insightsandserverefuse a store that is not at this build's version. So after upgrading,insightsrefuses every existing store, and theservepanel shows no explanations, until anycodegraph explainruns on it. The message says so, and that--dry-run, which calls no model, migrates it; a CLI test checks that it does. The alternative is to let a reader read a version-1 store, which would answer the same (no prompt-1 record has words), but that changes a documented rule.Docs
docs/insights.mdgains a "Version 2" paragraph, and its readers paragraph gives the remedy for an older store;docs/cli.mdlikewise.--insightshelp and theservereference say an unmigrated store shows no explanations.Verification
pnpm -r buildand typecheck are green, eslint is clean on every changed file,pnpm run gen:schemasleavesschemas/unchanged, and the Hugo site builds.insightsrefuses the version-1 file and leaves its bytes;explain --dry-runmigrates it without a call);node:sqlitewarning test noted on feat(core): language lexicons on profiles (M19a) #26.meaningkept by the migration, and by a put)../build.sh --ts --seapasses its smoke checks.insight_word22.1 MB of a 90.9 MB store (indexes included);WHERE word = 'order'0.5 ms; migrating a version-1 store that size 0.6 s.Still owed for M19c:
Part of #6.
🤖 Generated with Claude Code