Repository navigation
Commit c33f8cb
committed
fix(plugin): self-heal legacy synthetic-todo rows with empty stateJson
Oracle final audit caught the only remaining HIGH-severity gap in the
synthetic-todowrite feature: a legacy upgrade scenario where a row was
written with (callId, messageId) only, then v11 migration's column
DEFAULT '' added stateJson=''. On a cache-busting pass with matching
callId, Branch 3 idempotently re-injected but didn't backfill the
empty stateJson. The next defer pass would skip replay (line 770
guard fails on length===0), the synthetic would vanish from T1, and
prefix bytes would diverge from T0 — exactly the cache-stability
regression Council Finding #1's original fix was meant to prevent.
Fix: in Branch 3 of B7 (transform-postprocess-phase.ts), backfill
todo_synthetic_state_json with sessionMeta.lastTodoState whenever the
persisted row has empty stateJson. Safe because callId equality under
sha256 collision-resistance proves current snapshot equals what the
old build hashed.
Adds regression test seeding (callId, msg, stateJson='') → cache-bust
T0 → assert anchor backfilled → defer T1 from fresh messages → assert
T1 bytes equal T0 bytes. Without the fix this fails at the final
expect (T1 omits the synthetic part).1 parent 8b4dec8 commit c33f8cb
2 files changed
Lines changed: 88 additions & 0 deletions
File tree
- packages/plugin/src/hooks/magic-context
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
746 | 746 | | |
747 | 747 | | |
748 | 748 | | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
749 | 770 | | |
750 | 771 | | |
751 | 772 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
110 | 120 | | |
111 | 121 | | |
112 | 122 | | |
| |||
544 | 554 | | |
545 | 555 | | |
546 | 556 | | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
547 | 614 | | |
548 | 615 | | |
549 | 616 | | |
| |||
0 commit comments