mirror of
https://github.com/garrytan/gbrain.git
synced 2026-07-29 19:01:39 +00:00
Four adversarially-verified backlog items, one unit: - #2722 fence-write derived the target file from the slug alone, so a page imported from a spaced filename (`10 People/Jane Doe.md`, slug `10-people/jane-doe`) got a parallel hyphen-path stub instead of its canonical file. `resolveFenceFilePath` now consults `pages.source_path` (markdown-only, containment-checked) with the slug-derived path as the new-page fallback; `forgetFactInFence` shares the same resolver so forgets strike through the same file the write deposited into. Secondarily, a freshly stub-created page is unlinked when the DB stamp fails, so transient DB errors can't leave phantom entity pages. - #2443 gbrain as a container entrypoint (PID 1) never reaped re-parented orphan grandchildren; zombie `git` processes accumulated until the cgroup pids limit starved fork. `installPid1OrphanReaper` (no-op unless PID 1 on Linux) sweeps /proc for Z-state children and reaps pids seen in two consecutive sweeps via libc waitpid(WNOHANG) — the two-sweep gate avoids racing the runtime's own per-child reaping. Deploy docs now recommend `docker run --init` / tini as the primary setup. - #2308 supervisor start was one-shot on the queue DB lock: a recreated container (new hostname) exited LOCK_HELD inside the previous holder's TTL window and nothing retried. `acquireSupervisorDbLockWithWait` polls the acquire while the holder is provably dead (same-host dead PID, or a heartbeat that never advances) and still fails fast on a genuinely live holder, bounded by TTL + steal grace. - #2839 `writePageThrough` atomically rewrote `<slug>.md` from the DB row with no page lock, clobbering `## Facts` fence rows deposited on disk since the last import (the DB body lags fence writes). The read-merge- rename now runs under `withPageLock(slug)` and merges the on-disk fence (union by row_num, disk wins) before rendering over the file. Fixes #2722 Fixes #2443 Fixes #2308 Fixes #2839 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>