Skip to content

Delivery init-stamp-is - #416

Merged
LeXwDeX merged 10 commits into
mainfrom
fix/415-init-stamp-is
Aug 21, 2026
Merged

Delivery init-stamp-is#416
LeXwDeX merged 10 commits into
mainfrom
fix/415-init-stamp-is

Conversation

@LeXwDeX

@LeXwDeXLeXwDeX commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Closes#415

Why

The /init stamp (project.time_initialized) is written only by a Command.Event.Executed listener (packages/opencode/src/project/project.ts:418-424). If the event is missed (subscription not yet established when /init runs), the stamp is never written and /memory on blocks with "run /init first" — re-running /init can lose the same race again. Real case: a project carried time_initialized = NULL forever; recovery required manual sqlite surgery.

What changed

  • packages/opencode/src/memory/memory.ts (statusReason): when the stamp is NULL but the worktree has a non-empty AGENTS.md (the durable artifact /init produces), heal the row via setInitialized instead of reporting the blocker. FSUtil is accessed through Effect.serviceOption so a missing wire degrades to no-heal, not a crash.
  • The no-artifact blocker now carries the DB row state (time_initialized=NULL, worktree=..., sandboxes=...) so a stale identity (worktree pointing at a deleted clone) is visible at a glance.
  • packages/opencode/test/memory/memory-init-stamp-selfheal.test.ts: both behaviors pinned (heal-on-artifact; blocker-with-diagnostics without artifact).

Evidence

Checklist

  • Root cause identified (listener race) and real-world case reproduced
  • Self-heal + diagnostics implemented with regression tests
  • Typecheck + memory suite + DAG core gate green locally
  • CI gates green

llama.cpp's OpenAI-compatible server rejects tool schemas whose pattern
lacks ^...$ anchoring. isStartsWith("dag") serialized to ^dag and broke
every request carrying the workflow tool. isPattern(/^dag.*$/) keeps
identical starts-with semantics with a fully anchored pattern.
…agnostics
The stamp listener (Command.Event.Executed) can lose the race with /init,
leaving time_initialized NULL forever; re-running /init hits the same
race. statusReason now heals the row when a non-empty AGENTS.md (the
durable /init artifact) exists, and the no-artifact blocker carries the
DB row state so stale identities are visible.
@LeXwDeX
LeXwDeX marked this pull request as ready for review August 21, 2026 04:09
Shared XDG_CONFIG_HOME across bun test files let an earlier file's
enabled global memory.jsonc turn the post-heal statusReason into a
model-unavailable blocker on CI.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: /init stamp is lost to an event-listener race, leaving MEMORY fail-closed with no self-heal

1 participant

@LeXwDeX