Commit 9335ba5
fix(forks): stop copying connector-managed knowledge base documents
A fork copies a KB's documents but never its connectors, so a
connector-sourced document arrives with `connector_id` nulled and its
`external_id` intact. The sync engine keys every existing/tombstone/
exclusion lookup off `connector_id`, so that copy is invisible to it -
never updated, reconciled, or purged - and `doc_connector_external_id_idx`
does not constrain it either, since its `connector_id` is NULL.
Attaching a connector in the child then re-ingests every page as a NEW
row on top of the snapshot. Each fork hop re-copies the previous hop's
orphans and adds one more generation, so a prod -> UAT -> staging chain
leaves three rows per page and a knowledge search returns the same page
three times, one of them serving content frozen at the fork date.
Exclude connector-managed documents from all four doors a document can
enter a fork through: the whole-KB content copy, the in-transaction
placeholder pre-creation, the sync-only copy into an already-mapped KB,
and the content fill (guarded for payloads planned by a pre-change
worker mid-rollout). The placeholder path matters as much as the copy
loop - filtering only the content phase would leave a permanently
archived row behind a persisted `knowledge_document` mapping. Skipped on
both sides, the reference clears like any other uncopied document's.
A document whose connector was deleted already has a null `connector_id`
(the FK is ON DELETE SET NULL) and is static in the source too, so it
still copies. One count(*) per copied KB logs what was left behind, since
a fully connector-synced KB now forks to zero documents.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 1c69372 commit 9335ba5
3 files changed
Lines changed: 191 additions & 9 deletions
File tree
- apps
- docs/content/docs/en/platform/enterprise
- sim/ee/workspace-forking/lib/copy
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
| 177 | + | |
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
230 | | - | |
| 230 | + | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
234 | 251 | | |
235 | 252 | | |
236 | 253 | | |
| |||
Lines changed: 108 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
311 | 313 | | |
312 | 314 | | |
313 | 315 | | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
314 | 338 | | |
315 | 339 | | |
316 | 340 | | |
| |||
1051 | 1075 | | |
1052 | 1076 | | |
1053 | 1077 | | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
1054 | 1097 | | |
1055 | 1098 | | |
1056 | 1099 | | |
| |||
1359 | 1402 | | |
1360 | 1403 | | |
1361 | 1404 | | |
| 1405 | + | |
1362 | 1406 | | |
1363 | 1407 | | |
1364 | 1408 | | |
1365 | | - | |
| 1409 | + | |
| 1410 | + | |
1366 | 1411 | | |
1367 | 1412 | | |
1368 | 1413 | | |
| |||
1377 | 1422 | | |
1378 | 1423 | | |
1379 | 1424 | | |
1380 | | - | |
| 1425 | + | |
1381 | 1426 | | |
1382 | 1427 | | |
1383 | 1428 | | |
| |||
1458 | 1503 | | |
1459 | 1504 | | |
1460 | 1505 | | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
1461 | 1535 | | |
1462 | 1536 | | |
1463 | 1537 | | |
| |||
1510 | 1584 | | |
1511 | 1585 | | |
1512 | 1586 | | |
1513 | | - | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
1514 | 1590 | | |
1515 | 1591 | | |
1516 | 1592 | | |
| |||
1526 | 1602 | | |
1527 | 1603 | | |
1528 | 1604 | | |
| 1605 | + | |
1529 | 1606 | | |
1530 | 1607 | | |
1531 | 1608 | | |
1532 | 1609 | | |
1533 | | - | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
1534 | 1618 | | |
1535 | 1619 | | |
1536 | 1620 | | |
| |||
1539 | 1623 | | |
1540 | 1624 | | |
1541 | 1625 | | |
1542 | | - | |
| 1626 | + | |
1543 | 1627 | | |
1544 | 1628 | | |
1545 | 1629 | | |
| |||
1584 | 1668 | | |
1585 | 1669 | | |
1586 | 1670 | | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
1587 | 1690 | | |
1588 | 1691 | | |
1589 | 1692 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
371 | 376 | | |
372 | 377 | | |
373 | 378 | | |
| |||
784 | 789 | | |
785 | 790 | | |
786 | 791 | | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
787 | 798 | | |
788 | 799 | | |
789 | 800 | | |
| |||
803 | 814 | | |
804 | 815 | | |
805 | 816 | | |
| 817 | + | |
806 | 818 | | |
807 | 819 | | |
808 | 820 | | |
| |||
845 | 857 | | |
846 | 858 | | |
847 | 859 | | |
848 | | - | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
849 | 863 | | |
850 | 864 | | |
851 | 865 | | |
| |||
877 | 891 | | |
878 | 892 | | |
879 | 893 | | |
| 894 | + | |
880 | 895 | | |
881 | 896 | | |
882 | 897 | | |
| |||
1124 | 1139 | | |
1125 | 1140 | | |
1126 | 1141 | | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
1127 | 1166 | | |
1128 | 1167 | | |
1129 | 1168 | | |
1130 | 1169 | | |
1131 | 1170 | | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
1132 | 1184 | | |
1133 | 1185 | | |
| 1186 | + | |
1134 | 1187 | | |
1135 | 1188 | | |
1136 | 1189 | | |
| |||
1273 | 1326 | | |
1274 | 1327 | | |
1275 | 1328 | | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
1276 | 1338 | | |
1277 | 1339 | | |
1278 | 1340 | | |
| |||
0 commit comments