Repository navigation
Description
Context
Split out of #2878, which attributes the stale-input refusal of .brain-index/brain.db-shm to a read-only search connection on the live index. Its repair, PR #4011, is merged as main 5af689769: the stage wal-index is no longer copied, and both before-copy refusals now print both stamps.
#2878 also recorded two native-output-copy refusals in the native pi --apply-timing cell (UID 1000, 2,000 notes) while proving #2853, in 2 of 7 runs:
Native output changed before copy: .brain-index/brain.db-shmat the drained automatic refresh. Since fix(ui-sdk): a read-only index connection no longer refuses native publication #4011 the stage wal-index is excluded from the copy (WAL_INDEX,packages/ui-sdk/src/server/worker-native-output.ts:231), so this variant can no longer surface. That hides it without explaining it; it was the same stage-side before-copy check as the database-file variant.Native output changed before copy: .brain-index/brain.dbat the same-turnbrain_searchbarrier (IndexFlushError,APPLY_TIMING_SEARCH_WAITED_FOR_INDEX). This one is not explained.
The check compares the stage file's stamp (device, inode, mode, size, mtime, ctime) at copy time with the stamp captured when publication inspected the stage (const found = stamp(await input.stat, packages/ui-sdk/src/server/worker-native-output.ts:475-476). Publication runs after the maintenance worker has exited, so something still wrote the stage's database, or replaced it, between inspection and copy. No writer is attributed. Since #4011 the refusal prints both stamps (inspected …, found …). The stamp fields distinguish replacement from in-place modification; they do not by themselves identify the writer. Attribute the process rather than inferring one from a stamp change.
Scope
- Reproduce or capture one failing run with the two stamps, and name the process that changed the stage database after inspection.
- Fix that writer, or the drain that should have waited for it, so the refresh publishes.
Out of scope
- The live-side stale-input comparison and the wal-index (ui-sdk: native index publication intermittently refuses changed database or sidecar stamps #2878).
- Copy-staged publication without native storage.
Acceptance criteria
- A failing run's error, with both stamps, is recorded on this issue and names the writer, or a test reproduces the refusal with a real concurrent writer on the stage.
- After the fix, that test, or 7 of 7 runs of the cell, publishes without
Native output changed before copy.
Verification
bun scripts/prove-native-host.ts --backend=pi --app-uid=1000 --apply-timing, repeated at least 7 times.
Contract impact
None expected.
Bounded triage attempt — 2026-11-15
On isolated main c09454c338b6c420fedee8e1a66aa338a695bcdd, bun scripts/prove-native-host.ts --backend=pi --app-uid=1000 --apply-timing exits 1 at scripts/prove-native-host.ts:56: Native proof image is absent. No native cell, stage copy or writer was exercised. Do not count this as a reproduction of Native output changed before copy or as one of the seven requested timing runs.
Keep needs: repro. The next qualified native-host run must retain the exact checkout, cell, both stage identities (using the diagnostic when actually delivered, or equivalent bounded instrumentation), failure phase and process evidence. It must distinguish a stage write/replacement from the already-attributed live-side SHM change. No common writer is inferred. The stage-writer investigation can proceed independently of merging #4011; no dependency wait, release commitment or human-only requirement is introduced. Keep standalone: no existing epic’s complete outcome covers this native stage-writer repair merely because it shares the SDK or verification harness.
2026-11-15 follow-up triage at main c09454c338b6c420fedee8e1a66aa338a695bcdd: Separated the active #2878/#4011 proposal from delivered main and repaired the copy-boundary citation. Recorded the missing native-image prerequisite without claiming a runtime reproduction; needs: repro and p2 remain.
2026-11-16 correction: #4011 is merged (main 5af689769). Updated the context to say the stage wal-index is no longer copied and both stamps are printed, and moved the copy-boundary citation from :435 to :475-476. The reproduction-panel findings are in the comment of the same date.
Active evidence after the panel — 2026-11-16
The latest comment forces the before-copy refusal with a real product-configured SQLite writer that has committed frames and closes after inspection but before copy. Read-write/no-write, read-only and no-late-connection controls publish. This distinguishes a viable late-writer mechanism from a mere read connection; it does not identify the production writer or exclude a metadata/identity replacement in the historical native cell.
Retain the panel's exact stamp-pair diagnostic and the next qualified native run's stage identity, worker-helper mode, drain binding/process/descriptor evidence and failure phase. The existing seven-run acceptance remains; the panel’s suggested up-to-thirty search is an investigation cap, not a new passing-proof requirement or permission to infer a writer. Keep needs: repro until the actual writer or a source-qualified equivalent cause is identified. No forced local success or #4011 SHM exclusion substitutes for that attribution.
2026-11-20 triage — Built the proof image from the pinned Dockerfile and ran bun scripts/prove-native-host.ts --backend=pi --app-uid=1000 --apply-timing with that image on main bd751d434. The offline container exited 1 opening /dev/loop-control (PermissionError: [Errno 13]) before the stage/database cell ran. Its cleanup reported no attached loop or mounted filesystem. The stage-writer attribution still needs a qualified native runner and the paired stamps/process evidence above.
Activity
schlessera commentedon Nov 15, 2026
Triage — 2026-11-15. #4011 is still open: its SHM treatment and two-stamp diagnostic are proposed changes, not main behavior. The body now makes that distinction and points at main’s actual before-copy check. The local timing command stopped at the absent native-image prerequisite, before any stage writer was exercised; retain needs: repro. No fix, seven-run result or process attribution is supplied.
schlessera commentedon Nov 16, 2026
Reproduction panel findings — 2026-11-16 (main
5af689769)Three agents on different models worked this independently, then cross-reviewed each other's write-ups. The refusal class is reproduced; the production writer is still unidentified.
needs: reprostays.What is reproduced
A forcing test that holds a real SQLite connection on the stage index, opened with the product's
openDatabasepragmas (WAL, persistent WAL), and closes it insidepublishLocked's firstlock.acquire(packages/ui-sdk/src/server/worker-native-output.ts:407-408). That point is strictly after inspection and before the before-copy check at:475-476.Native output changed before copy: .brain-index/brain.db (inspected …, found …): same dev/ino/mode, later mtime and ctimeTwo panelists ran it independently (4 of 4 and 2 of 2 passes). So the actor must have committed frames to the stage index. A process that only opened it read-write, or a read-only
brain_searchconnection, cannot produce thebrain.dbvariant.Ruled out or weakened
validateGitScaffoldsreturns immediately (worker-native-output.ts:347-348), and no private reader path is used.packages/ui-sdk/src/server/native-brain-stage.ts:22); only the lower is Btrfs.Ranked hypotheses
await executionDrain.get(prepared)?.exited,worker-native-output.ts:368); its late checkpoint or close moves committed frames intobrain.db(≈0.40). No in-tree route was found by reading.prepareMaintenanceIndexreturns early (packages/ui-sdk/src/server/maintenance-index-input.ts:44).brain.dbthen reaches the tmpfs upper by copy-up on the indexer's read-write open, with an origin in the lower.exitedand overwrites it on every bind (bindNativeMaintenanceExit,worker-native-output.ts:142-143). A launch that returned early on an abort or kill path while its child lived would orphan its drain.The first failing stamp pair separates these:
Next run (needs the native proof image; ≈2 h on a quiet host)
bun scripts/prove-native-host.ts --backend=pi --app-uid=1000 --apply-timingup to 30 times, stopping at the first refusal. Thebrain.dbvariant appeared once in seven runs.BRAIN_UI_WORKER_IDENTITY_HELPERwas set;/proc/*/fdfor the stage index inodes at drain time and at refusal;fanotifywatch, which gives the acting pid where inotify does not;