Skip to content

feat: space daemon plugins with git and skills daemons - #156

Merged
sanchitrk merged 5 commits into
canaryfrom
claude/daemon-plugin-v2-8961fd
Nov 13, 2026
Merged

sanchitrk merged 5 commits into
canaryfrom
claude/daemon-plugin-v2-8961fd

Conversation

@sanchitrk

@sanchitrk sanchitrk commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #155: this replaces its pull path for skills (skill.list, projects.skills reading live, the skill table) with daemons that keep space state current from inside CodeWork.

What

Space daemons: one instance per space (one folder in one env), started on the first drain that mounts the space. Each daemon is fed the events of runs in that space, from space.mount.attached to space.mount.detached. It publishes what it finds as its own events, and clients mirror those instead of pulling.

Never wakes a sandbox: a daemon reads only through borrow. That pins a transport a drain lease or a handover hold already attached, under the gate stop claims with, and only while the row is online. A short handover keeps the sandbox readable after the last drain while work is pending.

  • plugin: the daemon contract (plugin/daemon).
  • harness: the space host, the controller's borrow/held/hold, and two builtin daemons.
    • git: status push; per-file diff; a patch cache serving diff on a detached space; untracked folders as one entry.
    • skills: the same discovery as the skill prompt plugin.
  • codework:
    • event.subscribe gained types, filtered before the queue, with the last daemon event per space replayed first.
    • New daemon.call.
    • skill.list is removed.
  • apps/server:
    • A space_state mirror, fed per machine connection.
    • sync/state notices.
    • projects.skills reads the mirror, and the Skills section refreshes live.

Verified

  • Host: harness E2E, the real CLI server (push, replay, daemon.call, restart), and the apps/server mirror.
  • Daytona and Vercel: each produces the same artifact as the host, plus a never-wake check (stopped sandbox → cached diff, provider still offline).
  • Relink Daytona → Vercel → host: each space keeps its own state.
  • A CodeWork server on an OrbStack machine, with and without Daytona: includes a sandbox its owner stopped behind that server's back.
  • The real Electron app with a real model: host and Daytona Skills update live; a stopped sandbox keeps its last list.
  • vp check and vp run typecheck pass.

Peer review

A second model reviewed the code and re-ran every suite above, plus about 20 real-world situations.

  • Passed: a network cut and a stop on an OrbStack machine mid-run, a held index.lock, conflicts, submodules, binary files, hostile file names, a 50k-file untracked folder, an 11 MB change, two worktree spaces, skills edge cases, idle stop and restart.
  • Fixed (last commit):
    • A borrow could rebuild a transport invalidated by wake during a handover.
    • Work outlived a failed daemon start.
    • Idle stop interrupted pending work.
    • Git daemon: a newline in an untracked name could make diff read a path outside the repository; names now stay NUL-separated end to end.
    • git errors returned an empty diff.
    • C-quoted patch paths were not decoded.
    • An SOH byte in a name cut the status short.
    • A deleted space folder kept its old status.

Known

  • apps/server's reads.test.ts can time out under the default parallel run next to the new mirror test (it passes alone and with --maxWorkers=3).
  • Live provider suites fail where credentials or OpenRouter credits are missing; unrelated to this change.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Base automatically changed from claude/desktop-app-pr-148-merge-3292ee to canary November 13, 2026 06:11
sanchitrk and others added 4 commits November 13, 2026 11:42
Space daemons keep a space's state current from inside CodeWork instead of
clients pulling it: one instance per space, started on a drain's mount,
fed the events of runs in that space, reading the space only through I/O
it borrows while a drain or a short handover already holds the sandbox,
so a daemon never wakes one.

- plugin: the daemon contract (scope, events, methods, start with io.use,
  work, events.on/publish, handle).
- harness: the space host (lifecycle, attribution between
  space.mount.attached and detached, handover holds, idle stop, last-event
  replay, daemon.call), controller borrow/held/hold, the git daemon
  (status push, per-file diff, patch cache for detached spaces, untracked
  folders as one entry) and the skills daemon.
- codework: event.subscribe types filter with replay, daemon.call; the
  skill.list pull is gone.
- apps/server: space_state mirror fed per machine, sync/state notices;
  the Skills section reads the mirror and refreshes live.
- E2E on host, Daytona, Vercel, a relink across all three, a CodeWork
  server on an OrbStack machine with and without Daytona, and the real
  CLI server; artifacts under __artifacts__/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Borrow pins only a transport still built: an invalidated one is never
  rebuilt by a daemon, and wake keeps the transport while a handover holds it.
- A daemon's work runs in its own scope, so a failed start stops it.
- Idle stop waits for pending work instead of interrupting it.
- Git daemon: untracked names stay NUL-separated end to end (no path
  injection through a newline in a name), git errors fail diff instead of
  returning no changes, C-quoted patch paths are decoded, sections are
  split by a record of their own, and a shell that cannot run publishes
  available: false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sanchitrk
sanchitrk force-pushed the claude/daemon-plugin-v2-8961fd branch from 8b2c260 to 04b5d78 Compare November 13, 2026 06:12
Nothing is in production yet, so the app keeps one init migration: the
space_state table replaces the skill table there instead of a second
migration creating one and dropping the other.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sanchitrk
sanchitrk merged commit 81a1eb9 into canary Nov 13, 2026
1 check passed
@sanchitrk
sanchitrk deleted the claude/daemon-plugin-v2-8961fd branch November 13, 2026 06:30
Sign up for free to 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.

1 participant