You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two compounding fixes that drop fstack-brain ops from ~3s to ~50ms.
== Local-first writes ==
All write commands (intent write/infer/ship, decide write, handoff
write/auto, log-edit, heartbeat) used to perform 3-5 sequential Supabase
round-trips per invocation. Replaced with a write-locally-then-flush
pattern:
- brain/cli/src/queue.ts (NEW)
- enqueue() appends a JSONL line to ~/.fstack/queue/writes.jsonl
- drainQueue() flushes to Supabase, called by all read commands
- getCachedIntent/setCachedIntent — local cache for read-after-write
- reserveDecisionNumber — local counter, bootstrap from Supabase once
- Lock via atomic mkdir to prevent concurrent drains
- brain/cli/src/context.ts
- Split buildCtx into:
* buildCtx (sync, lite) — git ops only, no Supabase. For writes.
* buildCtxFull (async) — full ensureRepo+ensureBranch with local
cache (~/.fstack/cache/repos.json, branches.json). For reads.
- First buildCtxFull call resolves+caches IDs; subsequent calls hit
cache and avoid Supabase.
- All write commands switched to buildCtx (lite). Returns synchronously,
queues the brain write, exits.
- All read commands (sync, presence, standup, why, decide search,
handoff list, conflict-precheck) use buildCtxFull and call drainQueue
before querying Supabase. Just-written entries surface in the next read.
- New 'flush' subcommand for explicit drain.
- New 'queue' subcommand for queue depth.
Failure semantics: a failed flush row stays in the queue and retries on
next drain. Local cache is authoritative for the writer until flushed.
Local artifacts (ADR markdown files for /decide) are written immediately
regardless of brain reachability.
== Native-fs binary install ==
bin/fstack-brain-setup now COPIES the compiled binary to ~/.local/bin
instead of symlinking to the source dist/. The symlink path forced Bun to
load the 88MB compiled binary off /mnt/<windows>/ on WSL every invocation,
costing ~800ms per call across the WSL filesystem boundary. Native ext4
makes it ~40ms.
== Measured impact ==
decide write : 3.0s -> 55ms (55x)
intent get : 2.8s -> 47ms (60x)
heartbeat : 3.0s -> 50ms (60x)
bun cold : 2.8s -> 43ms (65x)
Brain writes from hooks (PostToolUse log-edit on every Edit/Write) now
finish in tens of ms, well within Claude Code's hook latency budget.
/decide and /intent finally feel weightless.
Resolves intent: 'Local-first writes — make every brain write feel
weightless' (ba76ee6f-b618-4b15-9fa2-6872c3b75a18).
0 commit comments