Commit 536f56b
committed
fix(knowledge): don't resurrect a tombstoned document whose content refresh failed
Critical race found by adversarial audit: resurrectIds was derived
purely from 'externalId was seen in the listing', independent of
whether the paired content update actually succeeded. If updateDocument
threw (hydration failure, storage upload failure, or any other
transient error) or the deferred-hydration fetch itself failed, the
document's row was never touched — yet the separate unconditional
resurrect step still cleared deletedAt for it anyway, reproducing the
exact bug this PR fixes (visible again, serving stale pre-tombstone
content), just triggered by a failed write instead of a gated one.
Track externalIds whose refresh attempt failed (hydration rejection or
write rejection) and exclude them from partitionSyncReconciliation's
resurrectIds. A failed refresh leaves the document tombstoned as-is —
not soft-deleted, not hard-deleted, not resurrected — so a later sync
gets a clean retry instead of the row landing in an inconsistent state
either way.1 parent 4ceff36 commit 536f56b
2 files changed
Lines changed: 93 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
85 | | - | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
93 | | - | |
| 94 | + | |
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
101 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
102 | 109 | | |
103 | 110 | | |
104 | 111 | | |
105 | 112 | | |
106 | 113 | | |
107 | 114 | | |
108 | 115 | | |
109 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
110 | 123 | | |
111 | 124 | | |
112 | 125 | | |
113 | 126 | | |
114 | 127 | | |
115 | 128 | | |
116 | 129 | | |
117 | | - | |
| 130 | + | |
118 | 131 | | |
119 | 132 | | |
120 | 133 | | |
121 | 134 | | |
122 | 135 | | |
123 | 136 | | |
124 | 137 | | |
125 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
126 | 145 | | |
127 | 146 | | |
128 | 147 | | |
| |||
135 | 154 | | |
136 | 155 | | |
137 | 156 | | |
| 157 | + | |
138 | 158 | | |
139 | 159 | | |
140 | 160 | | |
| |||
152 | 172 | | |
153 | 173 | | |
154 | 174 | | |
| 175 | + | |
155 | 176 | | |
156 | 177 | | |
157 | 178 | | |
158 | 179 | | |
159 | 180 | | |
| 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 | + | |
| 221 | + | |
| 222 | + | |
160 | 223 | | |
161 | 224 | | |
162 | 225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
264 | 268 | | |
265 | 269 | | |
266 | 270 | | |
| |||
269 | 273 | | |
270 | 274 | | |
271 | 275 | | |
| 276 | + | |
272 | 277 | | |
273 | 278 | | |
274 | 279 | | |
275 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
276 | 284 | | |
277 | 285 | | |
278 | 286 | | |
| |||
610 | 618 | | |
611 | 619 | | |
612 | 620 | | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
613 | 629 | | |
614 | 630 | | |
615 | 631 | | |
| |||
735 | 751 | | |
736 | 752 | | |
737 | 753 | | |
738 | | - | |
| 754 | + | |
| 755 | + | |
739 | 756 | | |
740 | 757 | | |
741 | 758 | | |
742 | 759 | | |
| 760 | + | |
743 | 761 | | |
744 | 762 | | |
| 763 | + | |
745 | 764 | | |
746 | 765 | | |
747 | 766 | | |
| |||
804 | 823 | | |
805 | 824 | | |
806 | 825 | | |
| 826 | + | |
807 | 827 | | |
808 | 828 | | |
809 | 829 | | |
| |||
835 | 855 | | |
836 | 856 | | |
837 | 857 | | |
| 858 | + | |
838 | 859 | | |
839 | 860 | | |
840 | 861 | | |
| |||
0 commit comments