Repository navigation
Commit 1ed721b
committed
feat(store): external per-node annotations, keyed by qualified_name
Nodes carry only what the indexer can derive from a syntax tree. Some facts
about a symbol simply are not in the syntax: an elaborated hardware instance
hierarchy, a resolved bit width or packed-struct layout, a profiler's sample
count. A tool that understands the language semantically can compute them, but
there was no way to attach them to the graph — nodes have a fixed column set,
and query_graph's Cypher is read-only.
Add a side table rather than widening nodes:
node_annotations(qualified_name, source, props JSON, updated_at)
PRIMARY KEY (qualified_name, source)
qualified_name is the key because it is the only node identifier stable across
a re-index (ids are AUTOINCREMENT and change on every rebuild). `source`
namespaces annotators so several coexist and one can be refreshed alone. Rows
whose key matches no node are inert, never an error — which is why upsert
reports how many of the written source's rows actually join a node: a payload
that matches nothing is the signature of a wrong key convention, and the caller
needs to see that instead of a clean success.
Read side: cbm_store_has_annotations is a cached one-probe gate so an
un-annotated project keeps its previous cost; cbm_store_annotation_prop pulls
one key via SQL json_extract on the primary-key index; merged_json returns
{"<source>": {props}} per node, keeping annotators that disagree
distinguishable. Reads treat a missing table as "no annotations", so DBs
written by older builds keep working; the existence probe is cached but its
answer is not, so a table created by another process mid-session is picked up.
Survive re-index: a full re-index DELETES the .db file and rebuilds it from the
graph buffer, which is why the ADR already had explicit carry-over (DeusData#516).
Annotations get the same treatment — captured before the delete, restored after
the rebuild, with a 200k-row ceiling whose truncation is logged rather than
silent. An incremental index never touched them. delete_project still removes
everything, annotations included, by design.
Verified: annotations survive a real full re-index of a 900-node SystemVerilog
project (node ids restart from 1, the rows keep their original import timestamp
and still join), plus unit coverage for the rebuild case, source namespacing,
replace semantics, the read path and unkeyable rows.
Signed-off-by: Oliver Barrera <[email protected]>1 parent 7d67801 commit 1ed721b
5 files changed
Lines changed: 943 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
16 | 27 | | |
17 | 28 | | |
18 | 29 | | |
| |||
120 | 131 | | |
121 | 132 | | |
122 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
123 | 141 | | |
124 | 142 | | |
125 | 143 | | |
| |||
242 | 260 | | |
243 | 261 | | |
244 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
245 | 266 | | |
246 | 267 | | |
247 | 268 | | |
| |||
1135 | 1156 | | |
1136 | 1157 | | |
1137 | 1158 | | |
1138 | | - | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
1139 | 1163 | | |
1140 | 1164 | | |
1141 | 1165 | | |
| |||
1147 | 1171 | | |
1148 | 1172 | | |
1149 | 1173 | | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
1150 | 1179 | | |
1151 | 1180 | | |
1152 | 1181 | | |
| |||
1242 | 1271 | | |
1243 | 1272 | | |
1244 | 1273 | | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
1245 | 1294 | | |
1246 | 1295 | | |
1247 | 1296 | | |
| |||
1376 | 1425 | | |
1377 | 1426 | | |
1378 | 1427 | | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
1379 | 1431 | | |
1380 | 1432 | | |
1381 | 1433 | | |
| |||
0 commit comments