CodeForPhilly / CodeForPhilly/codeforphilly-ng
boot: reconcile fast-forward does not re-open the store snapshot, so in-memory state is built from the pre-reconcile tree
- Ngôn ngữ chính
- TypeScript
- Star
- 1
- Fork
- 1
- Merge trung bình
- 5 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 9
Mô tả
## What
`buildApp` registers the plugins in this order: `store` (opens the gitsheets public store; each Sheet caches a `dataTree` snapshot at open time) → `reconcile` (fetch + fast-forward/rebase against `origin/`) → `services` (builds `InMemoryState` + FTS from `fastify.store.public`).
When the local bare clone is behind origin at boot, `reconcile` fast-forwards the branch, but nothing calls `Store.swapPublic` afterwards. `services` then builds the in-memory state from the Sheet snapshots captured before the fast-forward. Records that arrived in the fast-forward are invisible until the next hot-reload webhook or a restart.
The hot-reload path (`reloadInMemoryStateAndFts`) already handles this correctly by re-opening the public store after reconcile. The boot path skips that step.
## Why it hasn't bitten
Production pods bare-clone the data repo on every boot (`emptyDir` volume), so the clone is in sync with origin by the time `reconcile` runs and the outcome is `in-sync`. The gap only shows when a clone is reused across boots: local dev, and tests that seed the remote after creating the rig (see the re-import test in `apps/api/tests/internal-reload.test.ts`, which works around it with an explicit `git fetch origin main:main` before boot).
## Fix sketch
In the `reconcile` plugin (or a small step between it and `services`), when the outcome is anything other than `in-sync`/`fetch-failed`, re-open the public store and `fastify.store.swapPublic(freshPublic)` before `services` reads it. Or reorder so the store opens after reconcile; `reconcile` only needs the repo path and the lock, not the Sheet handles.
Found while working on the hot-reload stale-indices fix (`fix/hot-reload-stale-indices`); out of scope there.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu với việc đăng ký store → reconcile → services của buildApp và so sánh với reloadInMemoryStateAndFts. Đọc apps/api/tests/internal-reload.test.ts, đặc biệt là test re-import và fetch workaround trước khi boot. Hoàn thành khi một clone được tái sử dụng tạo ra state trong bộ nhớ và FTS chứa các record được reconcile đưa vào trước khi services được khởi tạo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- git, typescript
- Lĩnh vực
- api, backend, search
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 58/100