Skip to content

fix(setup): stop doctor probe 3 reporting a live gateway as not running - #1815

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:fix/doctor-probe-3-marketplace-gateway
Oct 25, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
potiuk:fix/doctor-probe-3-marketplace-gateway

Conversation

@potiuk

@potiuk potiuk commented Oct 25, 2026

Copy link
Copy Markdown
Member

Summary

  • On a marketplace install, isolated-setup-doctor probe 3 reported ✗ gateway socket missing … container gateway not running while the gateway was serving and docker version worked through it. The adopter repository has neither .apache-magpie/tools/container-gateway/src nor tools/container-gateway/src, so the probe's status call could not import, returned nothing, and gw_state mapped that to not-running before the socket or <rt> info check ran.
  • The probe now falls back to the operator install the SessionStart hook itself runs ($HOME/.claude/scripts/container-gateway/src, install Step L.1), which the reference allowRead already covers.
  • No status is no longer read as "not running". Only status can vouch that the socket is the gateway's (a raw daemon socket answers <rt> info just as well), so with no gateway source, or a status that exits without a report (e.g. macOS's /usr/bin/python3 3.9 cannot import the gateway), the probe reports ✗ gateway status unavailable — <reason> and never ✓.
  • A status that exits 2 without a report has refused the run directory (validate_run_dir raises SystemExit(2) on a symlinked or wrongly owned component); the probe reports ✗ gateway status refused the run directory.
  • The doctor's SKILL.md documents the third source and both new results; its token stamp is refreshed.

Type of change

  • Skill change (.claude/skills/<name>/) — eval fixtures updated below
  • Tool / bridge contract (tools/<system>/*.md)
  • Python package (tools/*/ with pyproject.toml)
  • Groovy reference impl
  • Cross-cutting (RFC, AGENTS.md, sandbox, privacy-LLM)
  • Documentation (docs/, README.md, CONTRIBUTING.md)
  • Project template (projects/_template/)
  • CI / dev loop (prek, workflows, validators)
  • Other:

Test plan

  • prek run --files on the changed files passes
  • For Python packages touched: uv run pytest / ruff check / mypy passes
  • For Groovy bridges touched: command-line invocation tested end-to-end
  • For skill changes: eval suite passes for the affected skill
  • For skill behaviour changes: a new or updated eval fixture is included in this PR
  • Other: tests/test_probe_3_container_gateway.py, 10/10 with python3 -m unittest, run outside the sandbox so the socket fixtures can bind. Four fail on main:
    • test_operator_install_source_used — stub gateway under $HOME/.claude/scripts/container-gateway/src reporting no backend → the "running without a docker backend" branch.
    • test_no_gateway_source_is_not_a_pass — no gateway source, live socket, working CLI → ✗ gateway status unavailable — no gateway source …, never ✓.
    • test_status_import_failure_is_not_a_refusal — status exits 1 with no output → ✗ gateway status unavailable — status exited rc=1 ….
    • test_status_refusal_is_reported — status exits 2 with no output, live socket → ✗ gateway status refused the run directory.
    • test_gateway_not_running now uses a stub reporting "running": false, since a missing source no longer means "not running".
  • Other: reproduced on a marketplace install (0.9.0.dev202610250024, macOS) in an unadopted repository; with the fix the probe reaches the gateway.

RFC-AI-0004 compliance

  • Sandbox — no new host access: the probe still only calls the read-only status subcommand, from inside the sandbox, against a path the reference allowRead already grants.

Linked issues

Refs #1775, #1776 (earlier probe 3 fix for /tmp writes; this is a separate defect).

Notes for reviewers (optional)

The hook deliberately refuses sandbox-writable gateway sources because it runs outside the sandbox. The probe runs inside it and only reads status, so that rule does not bind here; the new fallback is the same operator copy the hook uses.

🤖 Generated with Claude Code

On a marketplace install the adopter repository has neither
.apache-magpie/tools/container-gateway/src nor tools/container-gateway/src,
so the probe's `status` call failed to import, returned nothing, and was
read as "gateway not running" before the socket or `<rt> info` was ever
tried. The probe told operators to restart a gateway that was serving.

Fall back to the operator install the SessionStart hook itself runs
($HOME/.claude/scripts/container-gateway/src), which the reference
allowRead already covers. When there is still no status, say so instead
of "not running": only `status` can vouch that the socket is the
gateway's, so the probe fails with the reason rather than trusting a
socket a raw daemon would answer just as well. A `status` that exits 2
without a report has refused the run directory, and is reported as such.

Generated-by: Claude Opus 5
@potiuk potiuk added family:setup setup-* skills capability:fix Implement code change to resolve an issue labels Oct 25, 2026
@github-actions github-actions Bot added capability:reassess Re-run historical issues against current code capability:platform Framework / agent substrate skills (install, verify, doctor, override, status, setup bootstrap) labels Oct 25, 2026
@potiuk
potiuk enabled auto-merge (squash) October 25, 2026 14:57
@potiuk
potiuk disabled auto-merge October 25, 2026 14:57
@potiuk
potiuk merged commit 963afb2 into apache:main Oct 25, 2026
11 checks passed
potiuk added a commit to potiuk/magpie that referenced this pull request Oct 25, 2026
The test file apache#1815 added is not ruff-formatted, so the workspace
ruff-format hook fails on main and on every PR built on it.

Generated-by: Claude Opus 5
potiuk added a commit to potiuk/magpie that referenced this pull request Oct 25, 2026
main's prek has failed on this file since apache#1815.

Generated-by: Claude Code (Claude Opus 5)
potiuk added a commit that referenced this pull request Oct 25, 2026
…tainer command (#1814)

* fix(container-gateway-hook): start the gateway on demand before a container command

The gateway exits mid-session after its idle timeout, when another session on the same project ends, or on a crash, and only SessionStart ever started it again. A new ensure action, wired as a PreToolUse hook on Bash, starts it before a docker/podman command, after the same trust checks as start.

Generated-by: Claude Opus 5

* style(setup): ruff-format the doctor probe 3 tests

main's prek has failed on this file since #1815.

Generated-by: Claude Code (Claude Opus 5)

* fix(container-gateway-hook): judge the session's project, not the agent's cwd

The payload's cwd follows the agent's cd: before every tool call, and at
the SessionStart that follows a compaction, /clear or resume. Judged from
another directory, the session project's own write grants went uncounted,
so a sandboxed cd elsewhere could get a source or interpreter the sandbox
can write past the trust checks. Every action now takes the directory
from CLAUDE_PROJECT_DIR, which Claude Code sets on every hook to the
directory the session started in; it does not follow cd, and a settings
env entry cannot override it (checked against Claude Code). start and
stop fall back to the payload's cwd when it is unset; ensure does
nothing. The payload's cwd and its settings are counted as writable too.

Generated-by: Claude Code (Claude Opus 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capability:fix Implement code change to resolve an issue capability:platform Framework / agent substrate skills (install, verify, doctor, override, status, setup bootstrap) capability:reassess Re-run historical issues against current code family:setup setup-* skills

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant