Skip to content

Daemon lifecycle: dev worktrees, production app, and Pro/community builds collide on shared launchd service + socket - #1469

Merged
malibio merged 2 commits into
mainfrom
worktree-issue-1468-daemon-lifecycle-scoping
Jul 2, 2026
Merged

malibio merged 2 commits into
mainfrom
worktree-issue-1468-daemon-lifecycle-scoping

Conversation

@malibio

@malibio malibio commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Closes #1468

Michael Libio and others added 2 commits July 1, 2026 18:42
… collisions (closes #1468)

Dev builds now use daemon-dev.sock / app.nodespace.daemon.dev and Pro builds
append -pro, so a dev worktree never kills the production daemon and community
and Pro editions never fight over the same launchd job or socket.

- Add daemon_socket_relative(), launch_agent_label(), plist_filename() functions
  that return build-variant-scoped paths (debug_assertions × is_pro_build)
- Remove DAEMON_SOCKET_RELATIVE constant; grpc_client fallback now calls
  daemon_setup::daemon_socket_relative() so GUI dials the same socket as the plist
- Harden bootstrap_launchd_agent: any non-success exit code triggers bootout +
  retry rather than silently succeeding, making exit-code-5 I/O errors self-healing
- Tighten process-match in kill_stale_daemon_sync / kill_running_daemon: compare
  full argv[0] against the installed binary path instead of a trailing-substring
  heuristic (ends_with "nodespaced") that could match unrelated processes
- Update grpc_client test to assert daemon socket is under .nodespace/daemon*
  rather than the hardcoded .nodespace/daemon.sock (varies by build mode)

Co-Authored-By: Claude <[email protected]>
…ename from label

- watcher.rs: update private socket_path() fallback to use daemon_socket_relative()
  instead of hardcoded .nodespace/daemon.sock — without this, the WatchNodes stream
  dials the wrong socket in dev/Pro builds (blocker from review)
- daemon_setup.rs: derive plist_filename() from launch_agent_label() + ".plist" to
  eliminate the duplicate 4-arm match that could silently diverge if the label changed
- daemon_setup.rs: rename ks_err_str → retry_stderr for clarity
- daemon_setup.rs, watcher.rs: update stale module doc comments

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Re-review: All initial findings addressed

Blocker resolved

watcher.rs socket_path() now calls crate::daemon_setup::daemon_socket_relative() instead of the hardcoded .nodespace/daemon.sock. The private function in watcher.rs is now consistent with grpc_client::resolve_socket_path() and daemon_setup itself — all three socket-path resolution paths converge on the same variant-scoped function.

Suggestions resolved

plist_filename() now returns String via format!("{}.plist", launch_agent_label()). The call site at launch_agents_dir(&home).join(plist_filename()) compiles correctly: PathBuf::join accepts AsRef<Path>, which String satisfies. The separate match table that could drift is gone.

Doc comments in watcher.rs and grpc_client.rs updated to reference the variant-scoped path rather than the hardcoded default.

ks_err_str renamed to retry_stderr — clearer intent, consistent with surrounding log variable names.

No new issues introduced

Verified:

  • DAEMON_SOCKET_RELATIVE, LAUNCH_AGENT_LABEL, and PLIST_FILENAME constants are fully removed with zero remaining references.
  • The only occurrences of .nodespace/daemon.sock in source are inside daemon_socket_relative() itself (doc comment + the release-community return value) — correct by definition.
  • All four socket-resolution call sites (daemon_setup x2, grpc_client, watcher) route through daemon_socket_relative().
  • constants.rs updated with a tombstone comment directing callers to the right function.

Issue #1468 coverage

All four requirements remain intact: variant-scoped socket paths, variant-scoped launchd labels, self-healing launchd bootstrap (bootout+retry+kickstart), and exact-path binary identity check replacing the trailing-substring heuristic.

Approved.

@malibio
malibio merged commit fd2a89b into main Jul 2, 2026
@malibio
malibio deleted the worktree-issue-1468-daemon-lifecycle-scoping branch July 2, 2026 09:27
malibio pushed a commit that referenced this pull request Jul 2, 2026
Unrelated to this branch's Ornith work — origin/main itself currently
fails `cargo clippy -D warnings` after #1469 merged (an overindented doc
comment and two clippy::trim_split_whitespace lints). Fixed here since
merging main into this branch surfaced them and blocked quality:fix.

- Doc comment: reindent wrapped continuation lines to 7 spaces (clippy's
  doc_overindented_list_items).
- Remove redundant .trim() before .split_whitespace() (the latter already
  ignores leading/trailing whitespace) in two identical exe_check closures.

No logic changes.

Co-Authored-By: Claude <[email protected]>
malibio added a commit that referenced this pull request Jul 2, 2026
…update_node prompt) (#1467)

* Add Ornith 1.0 to model catalog (closes #1465)

Adds the three remaining production tasks identified by the #1464
evaluation: a catalog entry for Ornith 1.0 9B (ModelFamily::Qwen35,
same OAI-compat Jinja path as Gemma 4), an XML `<tool_call>` parser
(Format D) wired into emit_oai_delta so Ornith's tool calls surface as
uniform ToolCallStart/ToolCallArgs chunks instead of leaking as plain
text, and a `<think>`/`</think>` routing path (ThinkSplitter, mirroring
Gemma 4's ChannelSplitter) so Ornith's reasoning emits as
ChatChunk::Reasoning. Also fixes the update_node tool description with
concrete example values so Ornith calls it directly instead of asking
for clarification.

Co-Authored-By: Claude <[email protected]>

* Address review: route channel-splitter carry through ThinkSplitter on finalize

The finalize path emitted ChannelSplitter's leftover carry (e.g. a
truncated "<thi" fragment) straight to the answer/reasoning sinks
without passing it through ThinkSplitter first, unlike the streaming
push path where content always flows channel_splitter -> think_splitter.
A <think> marker truncated by the token cap at the same moment
ChannelSplitter held an unresolved partial marker could have leaked
into the visible answer. Fixed and added a regression test exercising
the combined finalize path. Also clarifies the Ornith catalog entry's
sha256 comment to call out DeepReinforce as a non-official repo
requiring a hash before promotion, matching the stated policy.

Addresses reviewer feedback from PR #1467 (skipped: index-arithmetic
naming nit in parse_xml_tool_call_block — code is already covered by
7 passing unit tests, not worth the churn; context_window/temperature
values match the sibling QWEN35_9B entry's conventions, no action
needed).

Co-Authored-By: Claude <[email protected]>

* Fix Ornith download URL, enable in UI, fix response-leak, correct docs

- Corrects the Ornith catalog entry's HuggingFace URL: the org name/casing
  was wrong (DeepReinforce vs. the real deepreinforce-ai), causing every
  download attempt to 401. Verified the corrected URL resolves and fixed
  the file size to the exact byte count.
- Widens the desktop-app allowlist and frontend ModelFamily type/filters so
  Ornith (and any future qwen35-family model) can actually appear and be
  downloaded/selected in Settings > AI Models, alongside Ministral.
- Fixes a real bug found via live testing: Ornith's tail-inference path
  (used after the ReAct loop's duplicate-tool-call guard breaks out) had no
  stripper for Ornith's leaked <tool_call> XML or its <|mask_end|> special
  token, so malformed raw model output was being persisted verbatim as the
  assistant's chat message. Added strip_ornith_tool_call_leak (mirrors the
  existing Gemma <|channel> stripper) with regression tests using the exact
  real transcript content that reproduced the bug. Also fixes a related gap
  where an empty-after-stripping response would have persisted an empty
  assistant bubble instead of falling back to a tool-result summary.
- Corrects the catalog entry's doc comment: the #1464 evaluation's "later
  turns won't slow down" claim was an extrapolation from single-shot decode
  benchmarks, not a measured result for multi-iteration ReAct loops. Ornith's
  recurrent (SSM) layers cannot do partial KV-cache reuse (confirmed both in
  our logs and upstream: ggml-org/llama.cpp issues #19858, #20003, #20153,
  #20225, #21912 — an open, unresolved limitation affecting all Qwen
  3.5-based hybrid models), so every ReAct iteration re-decodes the entire
  growing prompt from scratch. A 4-iteration turn took ~108s in practice.
  Added a visible warning in the Settings model card so this is disclosed
  before a user selects it, rather than discovered mid-conversation.

Co-Authored-By: Claude <[email protected]>

* Address review: document truncation assumption + doc comment shelf-life

- response_processing.rs: adds a one-line comment explaining why a dangling
  <tool_call> opener is safely truncated as trailing-only (truncation always
  happens at generation's end, so there's never legitimate prose after it).
- model_manager.rs: notes the ORNITH_1_9B doc comment's upstream llama.cpp
  issue citations reflect state as of 2026-07-01 and aren't self-updating —
  flags that a future reader should re-check those issues before assuming
  the KV-cache limitation still applies to a newer vendored llama.cpp.

Also live-tested the strip_ornith_tool_call_leak fix against the running
daemon: loaded Ornith via `nodespace model load`, ran two real conversation
turns through scripts/aichat.ts (a successful multi-tool turn, and a
tool-failure-recovery turn), and confirmed via `aichat.ts show` that the
persisted messages are clean — no raw <tool_call>/<|mask_end|> leakage in
either case. Neither run happened to hit the exact duplicate-tool-call-loop
tail-inference branch the fix targets (Ornith self-corrected within normal
iterations both times rather than looping), so this is strong but not
exhaustive live confirmation — combined with the 3 unit tests reproducing
the original captured leak text and the reviewer's independent hand-trace
of the strip logic, this is sufficient confidence to consider the fix
verified, but noting the caveat rather than overclaiming full coverage.

Addresses reviewer feedback from PR #1467, 3rd review round.

Co-Authored-By: Claude <[email protected]>

* Hide Ornith from Settings UI pending multi-step slowdown resolution

Removes ornith-1-9b-q4km from EXPOSED_GGUF_MODEL_IDS. All backend plumbing
(catalog entry, download, tool-call parsing, response-leak fix) stays
merged and functional — this only controls whether it appears in the
Settings > AI Models picker. Tracked for re-enablement in #1477.

Co-Authored-By: Claude <[email protected]>

* Fix pre-existing clippy failures on main in daemon_setup.rs

Unrelated to this branch's Ornith work — origin/main itself currently
fails `cargo clippy -D warnings` after #1469 merged (an overindented doc
comment and two clippy::trim_split_whitespace lints). Fixed here since
merging main into this branch surfaced them and blocked quality:fix.

- Doc comment: reindent wrapped continuation lines to 7 spaces (clippy's
  doc_overindented_list_items).
- Remove redundant .trim() before .split_whitespace() (the latter already
  ignores leading/trailing whitespace) in two identical exe_check closures.

No logic changes.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Michael Libio <[email protected]>
Co-authored-by: Claude <[email protected]>
malibio added a commit that referenced this pull request Jul 3, 2026
…t daemon writes (closes #1483) (#1485)

#1469 scoped daemon sockets/labels by build variant, which made it possible for
a dev and production daemon to run concurrently against the shared SQLite DB.
Without busy_timeout, a write from one process while the other holds the write
lock fails immediately with SQLITE_BUSY instead of retrying. Setting
busy_timeout = 5000ms (applied per-connection, since it's not persisted in the
DB file) makes the second writer wait for the lock instead of erroring.

Co-authored-by: Michael Libio <[email protected]>
Co-authored-by: Claude <[email protected]>
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.

Daemon lifecycle: dev worktrees, production app, and Pro/community builds collide on shared launchd service + socket

1 participant