refactor(sandbox): deduplicate docker not found message and name timeouts (#41) - #271
refactor(sandbox): deduplicate docker not found message and name timeouts (#41)#271ulises-jeremias wants to merge 3 commits into
Conversation
|
Nice, tightly-scoped refactor — this is the right shape for #41. Specifically well done:
One blocking item — the PR misses the site the issue lists first.
# src/readme2demo/sandbox.py:113-115
except FileNotFoundError as e: # docker not installed
raise SandboxError(
"docker CLI not found — install Docker and ensure it is on PATH"
) from eThe PR body and the commit message both say the constant is "used at all 4 sites ( Nothing catches this because Nits (take or leave):
On "no behavior change": the CLI preflight string does change for users ( Merge order — this is why I'd sequence it rather than land it now. Base is current Next step: fold |
…ants (alphacrack#41) - sandbox.py: _run FileNotFoundError now raises SandboxError(DOCKER_NOT_FOUND_MSG) - test: match=re.escape(DOCKER_NOT_FOUND_MSG) with import re - render.py: extract _FFPROBE_TIMEOUT_S=60 and use for ffprobe subprocess Address review on alphacrack#271 Co-Authored-By: internal-model
|
Addressed review (c6af240) — corrected formatting:
37/37 sandbox tests pass, mypy clean. Thanks! |
Verified independently — mergingRe-verified on a worktree rebased onto current
On the earlier review findingRESOLVED by follow-up commit 871bdd4 "fix(sandbox,render): use DOCKER_NOT_FOUND_MSG constant, timeout constants (#41)", which is on the branch head. src/readme2demo/sandbox.py:113 now reads What I actually ranRan two scripts against the rebased worktree, plus a 6-case mutation sweep. (1) ALL FOUR MESSAGE SITES, docker absent (subprocess.run patched to raise FileNotFoundError): sandbox._run via Sandbox.start() -> SandboxError('docker CLI not found — install Docker and ensure it is on PATH'); render.check_render_image -> RenderError(same); render.run_render -> RenderError(same); cli._preflight(Config(dry_run=False, llm_backend="claude-cli")) with shutil.which("docker")->None printed "✗ docker CLI not found — install Docker and ensure it is on PATH". Script reported: "distinct raise-site messages: 1" and "cli printed text contains constant: True". So the PR's central claim is true at runtime, and the old CLI wording ("on PATH — install Docker Desktop and retry.") is gone. (2) ALL SEVEN TIMEOUT CONSTANTS, subprocess.run spied to record the timeout kwarg — sandbox: 60 <- ['docker','run','--rm'] (socket gid), 120 <- ['docker','run','-d'] (start), 300 <- docker cp in, 300 <- docker cp out, 60 <- ['docker','rm','-f'] (destroy); render: 120 <- check probe, 300 <- gif preview, 60 <- ['ffprobe','-v','error']. Every value is byte-identical to the pre-PR literal in the diff, so this is a genuine no-op rename — no hardening/timeout weakening. (3) MUTATION SWEEP (each mutation applied, full suite run, then Verdict: MERGE-WITH-NIT. Pure refactor that genuinely works — all 4 sites verified emitting the identical constant and all 7 timeouts verified unchanged at the subprocess boundary — with the prior review concern fixed AND pinned by a tightened assertion; the nit is that the anti-drift property is pinned at only 1 of 4 sites (render.py x2 and cli.py can each re-drift with a fully green 750). |
…outs (alphacrack#41) - Extract DOCKER_NOT_FOUND_MSG constant in sandbox.py and use at all 4 sites (sandbox._run, render.check_render_image, render.run_render, cli._preflight) - Name magic timeouts as module constants (_START_TIMEOUT_S=120, _CP_TIMEOUT_S=300, _DESTROY_TIMEOUT_S=60, _SOCKET_GID_TIMEOUT_S=60, _CHECK_TIMEOUT_S=120, _GIF_TIMEOUT_S=300) Pure refactor, no behavior change. Closes alphacrack#41
…ants (alphacrack#41) - sandbox.py: _run FileNotFoundError now raises SandboxError(DOCKER_NOT_FOUND_MSG) - test: match=re.escape(DOCKER_NOT_FOUND_MSG) with import re - render.py: extract _FFPROBE_TIMEOUT_S=60 and use for ffprobe subprocess Address review on alphacrack#271 Co-Authored-By: internal-model
Both FileNotFoundError render paths and the CLI docker-missing row must use the shared constant (re.escape in matchers).
b31a346 to
d8fa0b0
Compare
|
Pinned the anti-drift nits:
Ready for re-review. |
What this changes
Fixes #41 — two small copy-paste debts in the container layer:
DOCKER_NOT_FOUND_MSG = "docker CLI not found — install Docker and ensure it is on PATH"defined insandbox.py, imported inrender.pyandcli.py, used at all 4 sites (sandbox._run,render.check_render_image,render.run_render,cli._preflight). Previously the CLI wording wason PATH — Docker Desktopand would drift._START_TIMEOUT_S=120,_CP_TIMEOUT_S=300,_DESTROY_TIMEOUT_S=60,_SOCKET_GID_TIMEOUT_S=60insandbox.py;_CHECK_TIMEOUT_S=120,_GIF_TIMEOUT_S=300inrender.py. Making them config knobs is out of scope — named constants are enough.Pure refactor, no behavior change;
python -m pytest tests/ -qpasses untouched.Closes #41.
The grounding invariant
Tests
python -m pytest tests/ -q716 passed (1 pre-existing unrelated)ruff check src/readme2demo/sandbox.py src/readme2demo/render.py src/readme2demo/cli.pycleanPrompt changes
Housekeeping