Commit f13ad97
fix(sync): defer moved-file frontmatter writes until the move batch commits
apply_project_index_move_batch called the move content updater inside the
open db.scoped_session, and the local updater wrote the moved file's
permalink frontmatter to disk via update_frontmatter_with_result before
the transaction committed. If the batch rolled back (e.g. an intra-batch
permalink collision), the database reverted but the on-disk rewrites
persisted, leaving files ahead of their indexed state.
The ProjectIndexMoveContentUpdater capability is now split into
plan_moved_file_content — which runs inside the transaction, resolves the
permalink, and builds the updated markdown in memory without touching
storage — and write_moved_file_content, which the store calls only after a
successful commit. The database rows are stamped from the planned content,
whose checksum matches the exact bytes the post-commit write persists, so
DB and file agree when the write lands; a failed write (or formatter or
platform newline divergence) is logged and surfaces on the next scan as a
checksum-mismatch modified file, which re-indexes from disk.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: phernandez <paul@basicmachines.co>1 parent d2bbb05 commit f13ad97
5 files changed
Lines changed: 484 additions & 31 deletions
File tree
- src/basic_memory
- indexing
- index
- tests
- indexing
- index
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
14 | 23 | | |
15 | 24 | | |
16 | 25 | | |
| |||
63 | 72 | | |
64 | 73 | | |
65 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
66 | 102 | | |
67 | 103 | | |
68 | 104 | | |
69 | 105 | | |
70 | 106 | | |
71 | 107 | | |
72 | 108 | | |
73 | | - | |
| 109 | + | |
74 | 110 | | |
75 | 111 | | |
76 | 112 | | |
| |||
91 | 127 | | |
92 | 128 | | |
93 | 129 | | |
94 | | - | |
95 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
96 | 133 | | |
97 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
98 | 141 | | |
99 | 142 | | |
100 | | - | |
101 | | - | |
| 143 | + | |
| 144 | + | |
102 | 145 | | |
103 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
104 | 154 | | |
105 | 155 | | |
106 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
103 | 108 | | |
104 | 109 | | |
105 | 110 | | |
106 | 111 | | |
107 | 112 | | |
108 | 113 | | |
109 | 114 | | |
110 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
111 | 122 | | |
112 | | - | |
| 123 | + | |
113 | 124 | | |
114 | 125 | | |
115 | 126 | | |
116 | 127 | | |
117 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
118 | 135 | | |
119 | 136 | | |
120 | 137 | | |
| |||
543 | 560 | | |
544 | 561 | | |
545 | 562 | | |
546 | | - | |
547 | | - | |
548 | | - | |
| 563 | + | |
549 | 564 | | |
550 | 565 | | |
551 | 566 | | |
552 | 567 | | |
553 | | - | |
554 | | - | |
| 568 | + | |
555 | 569 | | |
556 | 570 | | |
557 | 571 | | |
558 | 572 | | |
559 | 573 | | |
560 | 574 | | |
561 | 575 | | |
| 576 | + | |
562 | 577 | | |
563 | 578 | | |
564 | 579 | | |
565 | 580 | | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
575 | 587 | | |
576 | 588 | | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
577 | 593 | | |
578 | 594 | | |
| 595 | + | |
579 | 596 | | |
580 | 597 | | |
581 | 598 | | |
| |||
686 | 703 | | |
687 | 704 | | |
688 | 705 | | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
689 | 728 | | |
690 | 729 | | |
691 | 730 | | |
| |||
716 | 755 | | |
717 | 756 | | |
718 | 757 | | |
719 | | - | |
720 | | - | |
721 | | - | |
| 758 | + | |
722 | 759 | | |
723 | 760 | | |
724 | 761 | | |
| |||
0 commit comments