Skip to content

fix(daemon): F-1 polish — token_path discovery, --help dispatch, stdo…#82

Merged
chauncygu merged 1 commit intomainfrom
fix/daemon-f1-polish
May 3, 2026
Merged

fix(daemon): F-1 polish — token_path discovery, --help dispatch, stdo…#82
chauncygu merged 1 commit intomainfrom
fix/daemon-f1-polish

Conversation

@chauncygu
Copy link
Copy Markdown
Contributor

Four nits surfaced while smoke-testing F-1 (PR #80) on real subprocesses. None are blockers, but they each break a docs-promised path so they deserve a dedicated polish PR rather than getting buried in F-2's diff.

  1. cheetahclaws daemon {status, stop, rotate-token} now read the token path from the discovery file when serve was started with --token-path. discovery.make_info() accepts a new optional token_path keyword (schema stays at 1 — additive); cli.cmd_serve() records it only when the path overrides the default; new commands.daemon_cmd._resolve_token_path() prefers discovery and falls back to the default location for old discovery files / unset case. Previously these verbs always read ~/.cheetahclaws/daemon_token, which silently created a different random token, then failed 401 against the running daemon.

  2. python -m cc_daemon.cli --help (and the cheetahclaws spike-daemon --help backward-compat alias) now print a usage banner and exit 0 instead of unknown subcommand: --help / exit 2. The unknown- subcommand branch also includes the banner so users see how to recover. The PR description for feat(daemon): F-1 foundation — discovery, system methods, daemon CLI, health, e2e (on top of cc_daemon spike) #80 said the spike-daemon alias was "preserved" — this closes the gap.

  3. The three serve-mode startup prints (token: …, cheetahclaws daemon listening on …, audit log: …) now flush=True so they appear immediately when stdout is redirected to a file under &. Previously they sat in Python's 4 KB block buffer until the daemon exited, silently breaking the spike-notes' --print-token > out.log & workflow because the token line never reached disk.

  4. tests/e2e_daemon_skeleton.py::test_daemon_writes_discovery_and_token token-length floor raised from >= 32 to >= 40. secrets.token_urlsafe(32) yields ~43 chars, so the previous floor was loose enough that an accidental shrink to 16 raw bytes (~22 chars) would still ship green.

Tests: 10 new unit tests (4 covering cli.main dispatch, 4 covering _resolve_token_path, 2 covering discovery.make_info's new field). Full suite 669/669 passing on main. End-to-end smoke verified all three runtime fixes against cheetahclaws serve --listen tcp://....

Docs:

Refs #68, #74, #80, #81

…ut flush, test floor

Four nits surfaced while smoke-testing F-1 (PR #80) on real subprocesses.
None are blockers, but they each break a docs-promised path so they
deserve a dedicated polish PR rather than getting buried in F-2's diff.

1. `cheetahclaws daemon {status, stop, rotate-token}` now read the token
   path from the discovery file when `serve` was started with
   `--token-path`. `discovery.make_info()` accepts a new optional
   `token_path` keyword (schema stays at 1 — additive); `cli.cmd_serve()`
   records it only when the path overrides the default; new
   `commands.daemon_cmd._resolve_token_path()` prefers discovery and falls
   back to the default location for old discovery files / unset case.
   Previously these verbs always read `~/.cheetahclaws/daemon_token`,
   which silently created a *different* random token, then failed 401
   against the running daemon.

2. `python -m cc_daemon.cli --help` (and the `cheetahclaws spike-daemon
   --help` backward-compat alias) now print a usage banner and exit 0
   instead of `unknown subcommand: --help` / exit 2. The unknown-
   subcommand branch also includes the banner so users see how to
   recover. The PR description for #80 said the spike-daemon alias was
   "preserved" — this closes the gap.

3. The three serve-mode startup prints (`token: …`, `cheetahclaws daemon
   listening on …`, `audit log: …`) now `flush=True` so they appear
   immediately when stdout is redirected to a file under `&`. Previously
   they sat in Python's 4 KB block buffer until the daemon exited,
   silently breaking the spike-notes' `--print-token > out.log &`
   workflow because the token line never reached disk.

4. `tests/e2e_daemon_skeleton.py::test_daemon_writes_discovery_and_token`
   token-length floor raised from `>= 32` to `>= 40`. `secrets.token_urlsafe(32)`
   yields ~43 chars, so the previous floor was loose enough that an
   accidental shrink to 16 raw bytes (~22 chars) would still ship green.

Tests: 10 new unit tests (4 covering `cli.main` dispatch, 4 covering
`_resolve_token_path`, 2 covering `discovery.make_info`'s new field).
Full suite 669/669 passing on `main`. End-to-end smoke verified all
three runtime fixes against `cheetahclaws serve --listen tcp://...`.

Docs:
* `README.md` docs index — adds row for RFC 0002 (foundation roadmap);
  refreshes the spike row to reflect the actual landing path
  (#77 → reverted → re-landed via #81); marks F-1 as merged via #80.
* `docs/RFC/0002-daemon-foundation-roadmap.md` — F-1 status `OPEN`
  → `MERGED #80`.
* `docs/architecture.md` — daemon section now mentions the optional
  `token_path` discovery field and notes that the daemon-control verbs
  use it.
* `docs/news.md` — May 2, 2026 entry covering the spike re-land and
  F-1 merge sequence, the polish nits, and the intentional "not in F-1"
  list (agent.run, bridges, SQLite, cost guardrails, agent-runner
  subprocess, macOS peer-cred).

Refs #68, #74, #80, #81

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@chauncygu chauncygu merged commit 797a7c2 into main May 3, 2026
6 checks 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.

1 participant