Commit 221fbc2
committed
fix(knowledge): replace deletion-safety heuristics with a two-phase tombstone
PR #5883 merged an interim fix (sourceConfirmedEmpty bypassing two
static safety heuristics) before this follow-up redesign was ready.
This supersedes that approach with a properly general fix, matching
how production sync systems (Entra Connect, SCIM/Entra ID
deprovisioning, Cassandra/Couchbase tombstones) handle this exact
problem: never let a single observation trigger an irreversible mass
deletion, no matter how confident the signal looks.
A document missing from a normal sync's listing is now soft-deleted
(marked pending-removal) rather than hard-deleted immediately. It's
only actually purged once a *later* sync confirms it's still absent.
If it reappears in between, it's resurrected automatically — this
self-heals a transient outage or a bad API response without needing
to distinguish 'real' emptiness from 'ambiguous' emptiness at all,
which is what the removed heuristics were trying (and failing) to do
from a single observation.
This removes shouldSkipEmptyListing, exceedsDeletionSafetyThreshold,
and sourceConfirmedEmpty entirely — Google Sheets no longer needs a
connector-specific bypass flag, since a genuinely trashed spreadsheet
now reconciles through the exact same general path as every other
connector, with no special-casing and no new misuse surface for
future connectors. A forced fullSync still purges everything absent
in one pass, preserving the existing 'trigger a full sync to force
cleanup' escape hatch.
Uses the existing (previously unused for individual documents)
document.deletedAt column as the tombstone marker — no schema
migration required. shouldReconcileDeletions (the isIncremental /
listingCapped / listingTruncated gate) is unchanged; it still governs
whether reconciliation may run at all. Resurrection runs
unconditionally even when that gate is closed, since presence is
trustworthy evidence regardless of whether the listing was complete.1 parent 44749b8 commit 221fbc2
4 files changed
Lines changed: 161 additions & 207 deletions
File tree
- apps/sim
- connectors/google-sheets
- lib/knowledge/connectors
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
124 | 123 | | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
| 124 | + | |
131 | 125 | | |
132 | 126 | | |
133 | | - | |
134 | 127 | | |
135 | 128 | | |
136 | 129 | | |
137 | 130 | | |
138 | | - | |
139 | 131 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
| 132 | + | |
146 | 133 | | |
147 | 134 | | |
148 | 135 | | |
149 | 136 | | |
150 | 137 | | |
151 | 138 | | |
152 | | - | |
153 | 139 | | |
154 | 140 | | |
155 | 141 | | |
| |||
162 | 148 | | |
163 | 149 | | |
164 | 150 | | |
165 | | - | |
166 | 151 | | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
| 152 | + | |
173 | 153 | | |
174 | 154 | | |
175 | 155 | | |
176 | 156 | | |
177 | 157 | | |
178 | | - | |
179 | 158 | | |
180 | 159 | | |
181 | 160 | | |
| |||
185 | 164 | | |
186 | 165 | | |
187 | 166 | | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | 167 | | |
197 | 168 | | |
198 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
256 | | - | |
| 256 | + | |
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
280 | 277 | | |
281 | 278 | | |
282 | 279 | | |
283 | | - | |
284 | 280 | | |
285 | 281 | | |
286 | 282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | | - | |
| 79 | + | |
| 80 | + | |
82 | 81 | | |
83 | | - | |
84 | | - | |
| 82 | + | |
| 83 | + | |
85 | 84 | | |
86 | | - | |
87 | | - | |
| 85 | + | |
88 | 86 | | |
89 | | - | |
| 87 | + | |
90 | 88 | | |
91 | 89 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
| 90 | + | |
| 91 | + | |
97 | 92 | | |
98 | | - | |
99 | | - | |
| 93 | + | |
100 | 94 | | |
101 | | - | |
102 | | - | |
103 | | - | |
| 95 | + | |
104 | 96 | | |
105 | 97 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
| 98 | + | |
| 99 | + | |
111 | 100 | | |
112 | | - | |
113 | | - | |
| 101 | + | |
114 | 102 | | |
115 | | - | |
| 103 | + | |
116 | 104 | | |
117 | | - | |
118 | 105 | | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
| 106 | + | |
| 107 | + | |
124 | 108 | | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 109 | + | |
132 | 110 | | |
133 | | - | |
| 111 | + | |
134 | 112 | | |
135 | 113 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
140 | 118 | | |
141 | | - | |
142 | | - | |
| 119 | + | |
143 | 120 | | |
144 | 121 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
| 122 | + | |
| 123 | + | |
149 | 124 | | |
150 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
151 | 129 | | |
152 | 130 | | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 131 | + | |
| 132 | + | |
157 | 133 | | |
158 | | - | |
159 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
160 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
161 | 146 | | |
162 | 147 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
| 148 | + | |
| 149 | + | |
167 | 150 | | |
168 | | - | |
169 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
170 | 156 | | |
| 157 | + | |
| 158 | + | |
171 | 159 | | |
172 | 160 | | |
173 | 161 | | |
| |||
0 commit comments