Commit 7d8e4b0
committed
fix: close 6 data-integrity/correctness findings from Oracle audit wave 1
Three parallel read-only Oracle audits (transform cache-stability, data
integrity, workspaces security). Cache-stability core verified safe (6/6 replay
mechanisms). Six source-confirmed bugs fixed; two design questions banked to
.alfonso/oracle-loop-findings.md (NOT guessed).
1. Cheap-gate historian suppression (compartment-trigger.ts). With NO in-memory
tail (post-restart / marker-drain lag), the trigger's cheap pre-gate used the
scoped tagger floor for getTriggerTagTokenUpperBound. A collapsed floor above
live eligible tags excluded their tokens → could falsely cheap-skip a needed
historian fire (context overflow). Fix: use floor 0 for the bound when
inMemoryTail is undefined (full active+dropped sum is still a valid upper
bound, just looser; pre-boundary tags only inflate it). The inMemoryTail-
present path is self-correcting (estimateUntaggedInMemoryTailUpperBound charges
below-floor tags since coveredOwnerMessageIds is also floor-scoped). +test.
2. v22 backfill embedding loss (v22-deferred-backfill.ts). The legacy collision-
merge path deleted a source memory row (FK-cascading its embedding) without
transferring one to the survivor — same class as the live-path fix in 21ef95c,
missed here. Fix: INSERT OR IGNORE the source embedding onto the target before
delete. +test (real FK cascade under foreign_keys=ON).
3. migrate-session split-brain hardening (migrate-session.ts). (a) context.db
BEGIN IMMEDIATE moved INSIDE the try with a txBegan guard so a throwing BEGIN
(after OpenCode already committed) still compensates; rollback guarded so it
can't mask the original error or skip compensation. (b) Refuse to apply when
the OpenCode session row is missing (no half-migration). (c) Open context.db
with PRAGMA foreign_keys=ON + busy_timeout=5000 — the CLI bypasses
initializeDatabase, so without this the merge-delete leaves ORPHANED embeddings
instead of cascading. +2 tests.
4. Dashboard category change didn't bump epoch (db.rs update_memory_category). A
category edit is render- and visibility-changing (heading + workspace
shared/non-shared flip) but only queued an m[1] "update" delta, leaving cached
m[0] CAS-valid — a member session could keep receiving a now-non-shared foreign
memory (or miss a now-shared one). Fix: bump member epochs (workspace fan-out
inside the tx) like update_memory_status; no-op guard skips same-category;
epoch-bump XOR delta. +1 test, existing test updated.
Gate: plugin 2168/0, CLI 179/0, dashboard rust 93+21+10+20/0, tsc+biome clean.1 parent bfce553 commit 7d8e4b0
8 files changed
Lines changed: 221 additions & 30 deletions
File tree
- packages
- cli/src/commands
- dashboard/src-tauri
- src
- tests
- plugin/src
- features/magic-context
- hooks/magic-context
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
455 | 468 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
243 | 251 | | |
244 | 252 | | |
245 | 253 | | |
| |||
248 | 256 | | |
249 | 257 | | |
250 | 258 | | |
251 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
252 | 264 | | |
253 | 265 | | |
254 | 266 | | |
| |||
280 | 292 | | |
281 | 293 | | |
282 | 294 | | |
283 | | - | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
284 | 299 | | |
| 300 | + | |
| 301 | + | |
285 | 302 | | |
286 | 303 | | |
287 | 304 | | |
| |||
351 | 368 | | |
352 | 369 | | |
353 | 370 | | |
354 | | - | |
355 | | - | |
356 | | - | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
357 | 383 | | |
358 | 384 | | |
359 | 385 | | |
| |||
481 | 507 | | |
482 | 508 | | |
483 | 509 | | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
484 | 522 | | |
485 | 523 | | |
486 | 524 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2868 | 2868 | | |
2869 | 2869 | | |
2870 | 2870 | | |
2871 | | - | |
| 2871 | + | |
| 2872 | + | |
| 2873 | + | |
| 2874 | + | |
| 2875 | + | |
| 2876 | + | |
| 2877 | + | |
2872 | 2878 | | |
2873 | 2879 | | |
2874 | 2880 | | |
2875 | | - | |
2876 | | - | |
| 2881 | + | |
| 2882 | + | |
2877 | 2883 | | |
2878 | | - | |
| 2884 | + | |
2879 | 2885 | | |
2880 | 2886 | | |
2881 | 2887 | | |
| |||
2903 | 2909 | | |
2904 | 2910 | | |
2905 | 2911 | | |
2906 | | - | |
2907 | | - | |
2908 | | - | |
2909 | | - | |
2910 | | - | |
2911 | | - | |
2912 | | - | |
2913 | | - | |
2914 | | - | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
| 2917 | + | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
2915 | 2923 | | |
2916 | 2924 | | |
2917 | 2925 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
702 | 702 | | |
703 | 703 | | |
704 | 704 | | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
716 | 732 | | |
717 | 733 | | |
718 | 734 | | |
| |||
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
182 | 221 | | |
183 | 222 | | |
184 | 223 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
298 | 308 | | |
299 | 309 | | |
300 | 310 | | |
| |||
312 | 322 | | |
313 | 323 | | |
314 | 324 | | |
| 325 | + | |
315 | 326 | | |
316 | 327 | | |
317 | 328 | | |
| |||
Lines changed: 55 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
279 | 334 | | |
280 | 335 | | |
281 | 336 | | |
| |||
Lines changed: 12 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
489 | 489 | | |
490 | 490 | | |
491 | 491 | | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
492 | 503 | | |
493 | 504 | | |
494 | 505 | | |
495 | | - | |
| 506 | + | |
496 | 507 | | |
497 | 508 | | |
498 | 509 | | |
| |||
0 commit comments