Commit a600fc9
fix(portal): persist discovered factory children to the sync store (#2)
The portal historical sync discovered factory children with its wide scan but
wrote them only to the in-memory childAddresses map — never to the sync store.
Core marks requiredFactoryIntervals cached after every interval and, on startup,
loads children ONLY from the store (no re-derivation from logs). So a single
uninterrupted run worked, but any restart/crash-resume of a factory app loaded
an empty child set against already-cached factory intervals — discovery never
re-ran and every factory-child event was silently skipped.
Fix: queue newly discovered children and flush them via
syncStore.insertChildAddresses inside syncBlockRangeData — the same transaction
core commits with insertIntervals, so "factory interval cached ⇒ its children
are in the store" is atomic. The flush is scoped to children whose creation
block falls within the current interval, leaving the rest queued for their
owning interval. Grabbing the whole cross-interval queue would commit one
interval's children in another interval's transaction and, under core's
concurrent per-interval transactions, could lose a child if that transaction
rolled back after a lower interval had committed as cached (restart
re-discovery is floored at the lowest uncached factory interval and would never
rescan it). This mirrors stock sync-historical's per-interval child set. A
failed flush restores the queue and fails the interval loud (core rolls back).
Tests: persistence in the same syncBlockRangeData call; interval-scoped flush
(fails against a whole-queue flush, verified); loud failure + re-flush;
post-flush insertLogs failure rejects loud; restart seeded only from the store;
live re-discovery de-dup.
Also: delete the orphaned packages/portal-sync/src/historical.ts prototype
(unimported duplicate of the live engine); fix the identical
noAssignInExpressions in portal-realtime.ts; add repo code-style rules
(CLAUDE.md + biome useSingleVarDeclarator).
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 70f48cc commit a600fc9
6 files changed
Lines changed: 684 additions & 233 deletions
File tree
- packages/portal-sync/src
- portal
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
165 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
166 | 168 | | |
167 | 169 | | |
168 | 170 | | |
| 171 | + | |
169 | 172 | | |
170 | 173 | | |
171 | 174 | | |
| |||
0 commit comments