feat: panopticon doctor preflight command and fail-fast spawn errors#247
Draft
tildesrc wants to merge 5 commits into
Draft
feat: panopticon doctor preflight command and fail-fast spawn errors#247tildesrc wants to merge 5 commits into
tildesrc wants to merge 5 commits into
Conversation
Adds `panopticon doctor` (and `make doctor`) — a preflight self-check that verifies Docker, tmux, uv, the panopticon-base image, the task service, and per-repo env-file token presence/shape. Prints OK/WARN/FAIL with a one-line remediation per check; exits non-zero on any FAIL. Adds fail-fast spawn errors: the spawner now checks the env-file for a recognisable auth token (CLAUDE_CODE_OAUTH_TOKEN / ANTHROPIC_API_KEY) before attempting to spawn, and LocalRunner.spawn() checks that the target image exists and tmux is available before issuing docker run / tmux commands. Missing preconditions surface as a legible LifecyclePhase.FAILED detail in the dashboard (with "run panopticon doctor") instead of a silently idle container. Wire-up: macOS setup docs updated to include `make doctor` in the quick start, and the tmux limitation note now points to the doctor command. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
Code review —
|
Reframe `panopticon doctor` for a pip-installed operator (no Makefile/uv/ source checkout): - Remediations now point at `panopticon build` / `panopticon start`, not `make build` / `make serve`. - Drop the dev-only `uv` check; add a `git` check (the session service clones each task's checkout on the host). - Fix crash when the task service is down: fetch repos lazily via a callback, only after the service check passes, so doctor's headline case (service offline) reports cleanly instead of raising ConnectError. - env_file mode check rejects any group/other access (`mode & 0o077`) instead of exact `!= 0o600`, so a stricter 0o400 no longer FAILs. - local_runner spawn-precheck remediation: `make build` -> `panopticon build`. - Note the spawner's presence-only token check divergence from doctor's shape check deliberately (a spawn false-positive fails the whole task). - Move tests to tests/terminal/test_doctor.py per the new package layout. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
`panopticon doctor` is meant to run *before* the first `panopticon start`. At that point the base image isn't built and the task service isn't running — both by design (the runner auto-builds the image on first spawn; the service is started by `panopticon start`). Red-FAILing them told a fresh machine its environment was broken when it was simply not set up yet. Split the checks: - Host prerequisites (Docker, git, tmux) — tools you install yourself — stay hard FAILs; a missing one is the only thing that sets a non-zero exit. - Base image and task service become non-fatal WARN heads-up items. A fresh-but-ready machine (Docker/git/tmux present) now exits 0 with a "here's what happens at first start" list. Per-repo token checks are unchanged (still run only when the service is up). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Main added `panopticon quickstart` and the `setup-repo` shell workflow (a `runner_type="shell"` task the session service runs on the host, no container, to exec `claude setup-token`). Reframe the preflight so its yardstick is "can quickstart + setup-repo succeed here?": - Add a host `claude` CLI check (FAIL) — setup-repo execs `claude setup-token` on the host, so quickstart's final step needs it. Remediation points at https://claude.ai/install.sh. - Soften the per-repo env-file checks from FAIL to WARN: the token is what setup-repo mints and quickstart writes the secrets file at default mode, so a missing/loose/absent token is the normal pre-setup state, not a machine fault. Enforcement stays at spawn time (spawner FAILs a container task with no token). - Host prerequisites (Docker, git, tmux, claude) remain the only FAILs / the only thing that sets a non-zero exit. Merge mechanics: main refactored `_spawn` into `_spawn_container`/`_spawn_shell` (execution router) — moved the env-file fail-fast check into `_spawn_container` so it applies to container tasks only (shell setup-repo is exempt). Re-applied the local_runner spawn pre-check call-index shifts and env-file reader injection onto main's reformatted tests. B904 (`raise ... from`) + ruff format applied. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
panopticon doctor— a preflight self-check for a pip-installed operator host, oriented around the question "canpanopticon quickstartand thesetup-repoworkflow succeed here?"claudeCLI.setup-repois a shell workflow the session service runs on the host to execclaude setup-token, so quickstart's final step needsclaudepresent; remediation points athttps://claude.ai/install.sh.panopticon-baseimage, the task service, and per-repo tokens. Before first start none exist yet (the base image is auto-built on first spawn; the service is started bypanopticon start; the token is whatsetup-repomints), so doctor reports them as a "here's what quickstart will do" checklist rather than red-flagging a machine that simply hasn't run quickstart. A fresh host with the four tools installed exits 0.doctorfetches repos lazily — only after the task service check passes — so the offline-before-first-start case reports cleanly instead of crashing.Fail-fast spawn errors (defense-in-depth for container tasks):
CLAUDE_CODE_OAUTH_TOKEN/ANTHROPIC_API_KEYbefore spawning a container task (the shellsetup-repopath is exempt), andLocalRunner.spawn()checks the image exists and tmux is available beforedocker run/tmux. Missing preconditions surface as a legibleLifecyclePhase.FAILEDdetail in the dashboard (referencingpanopticon doctor) instead of a silently idle container.Also wires
make doctor(dev convenience) into the Makefile and updatesdocs/macos-setup.md.Plan: plan.md
🤖 Generated with Claude Code