Skip to content

Report each failed daemon start's own error - #100

Merged
lydakis merged 1 commit into
mainfrom
claude/project-thread-7oycm8
Oct 10, 2026
Merged

lydakis merged 1 commit into
mainfrom
claude/project-thread-7oycm8

Conversation

@lydakis

@lydakis lydakis commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Before: every auto-start of a store appends to the store's one log, and the launcher read the log's last line as its own child's error. When two starts of the same store failed at the same moment, one command could report the other's error.

After: serve adds its pid to its error line and writes it in a single write. The launcher reads only what was appended after its own spawn and takes the last line carrying its child's pid. A child that exits without such a line is daemon_start_failed, and the detail names the log.

This is the follow-up George asked for on the declined #94 finding (comment, listed in #96). It sets no defaults.

How

  • main.rs: report() adds pid when the process is serve and writes the line with one write_all, so concurrent writers to the append-mode log never interleave inside a line.
  • client.rs: ensure_daemon records the log's length before spawning. child_failure reads from there and picks the last JSON line whose pid matches the child, then drops pid from the reported error.
  • docs/CLI.md says so.
  • test_cli: eight concurrent failed starts per error, two different errors on one store, and each launcher must report its own.

Performance

Wall time of agent run --detach --new auto-starting a daemon, median of 20 runs (IQR), Linux. Before is main at e3454e3, after is this branch. The script is in the ignored local directory.

Case Before After
Good start 109.1 ms (108.9-159.9) 109.2 ms (108.7-110.1)
Failed start 104.8 ms (104.6-105.2) 105.0 ms (104.7-105.9)

The good path adds one fstat on the log. The failed path reads only the bytes past the spawn instead of the whole log, so a long log no longer makes a failed start slower.

Checks

  • cargo fmt --check.
  • cargo clippy -p agent-runtime -p agent-client --all-targets -- -D warnings.
  • cargo test -p agent-runtime -p agent-client: all pass.
  • AGENT_TEST_RUNTIME=1 python3 -m unittest discover -s tests: 421 tests, OK (44 skipped).
  • node --test app/tests/state.test.cjs: 187 pass.

🤖 Generated with Claude Code

Every start of a store appends to its one log. serve now names its pid on
its error line, written in one write, and the launcher reads only lines
past its spawn from its own child. Without one it is daemon_start_failed
naming the log.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01L9TT37y1798majTjQbUtZW
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T03:59:13.148461Z 76c5ee9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lydakis
lydakis merged commit a483fbb into main Oct 10, 2026
1 check passed
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.

2 participants