test(#87): author the MISSING test_boot_routes.py + real-subprocess credential_helper #154
Reference in New Issue
Block a user
Delete Branch "fix/87-boot-routes-regression-test"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #87 (follow-on: the documented gate is referenced by source but ABSENT; conftest stubs the a2a+claude SDKs so nothing real runs; credential_helper runs every boot untested).
Problem
Issue #87 calls out a documented-but-absent test gate:
test_boot_routes.pyis referenced inmolecule_runtime/boot_routes.pyas the contract for thebuild_routespure function. The function was extracted precisely so the contract could be unit-tested without the heavya2a-sdk/claude_agent_sdkimports — but the test file was never authored. Themain.pyconsumer was# pragma: no coverand the only coverage was end-to-end via the responsiveness-e2e job, which is too slow for the fast unit lane.credential_helper(the 2026-06-08 "MiniMax cred incident" — lost 39 workspaces because the helper was only mocked) was tested only viatest_credential_helper_determinism.pywith mocked subprocess calls. Real subprocess calls togit config,nohup,gh auth loginwere never exercised in CI.Fix
Two new test files, no production code change:
tests/test_boot_routes.py(6 tests, 4-branch card/JSON-RPC contract + real-executor smoke).tests/test_credential_helper_subprocess.py(5 tests, real subprocess).The 4-branch contract:
executor is not None→DefaultRequestHandler+InMemoryTaskStore.executor is None,adapter_error is None→not_configured_handler(generic).executor is None,adapter_error is set→not_configured_handlerwith the operator hint (the 2026-06-15 family of incidents; the operator MUST see the failure reason in canvas, not a generic "agent not configured" message).build_routeswith a reala2a-sdkAgentCard+ a realDefaultRequestHandler. Loudly skipped ifa2a-sdkis not installed; the unit-tests lane in CI has it viapip install -e ..The credential_helper subprocess contract:
_extract_scripts()writes real bash scripts + executable bit._configure_git_credential_helper()runs realgit configand the result is readable back viagit config --global --get(the!-prefixed shell-command convention is asserted)._start_refresh_daemon()spawns a real nohup'd process and writes a parseable PID file.install_credential_helper()undergitea: full no-op (the "do not install GitHub machinery" contract — regression class for the 2026-06-08 incident).install_credential_helper()undergithub+ token-shaped value: all three artifacts (scripts, git config, PID file) produced; the token-shaped value does NOT leak into the log output.Test plan
tests/test_boot_routes.py: 6 tests, all pass locally.tests/test_credential_helper_subprocess.py: 5 tests, all pass locally.responsiveness-e2ejob.)SOP checklist
pytest --ignore=tests/integration) — 664 passed, 1 skipped. The new tests cover both the unit-level build_routes contract and the real-subprocess credential_helper wire that previously was only mocked. No production code changed.pip install -e .step in CI'sunit-testsandresponsiveness-e2ejobs already pulls the real a2a-sdk; the newtest_build_routes_real_executor_smoketest will exercise the real wire on every CI run.build_routeswas extracted in PR #2756. Without this gate, a future re-coupling refactor would silently bypass the decoupling and the "stuck-booting-forever" UX would re-ship. For credential_helper, the test exercises the real subprocess (the part that was mocked and missed the 2026-06-08 incident).feedback_no_single_source_of_truth(the test file is the SSOT for the build_routes contract),feedback_no_such_thing_as_flakes(the credential_helper subprocess test pins the wire against non-determinism — if a future refactor introduces a real regression, the test fails LOUDLY).APPROVED: 5-axis review complete. Correctness: tests-only change adds real coverage for the documented boot-route contract and credential-helper subprocess side effects; no production behavior changes. Robustness: covers card route presence/order, executor/not-configured branches, adapter-error path, git config side effects, daemon PID artifact, and provider no-op behavior with temp HOME isolation. Security: no secrets added; subprocess tests use token-shaped fixtures only and secret-scan is green. Performance: tests are bounded and use temp dirs/subprocess smoke rather than long-running integration flows. Readability: long but well-scoped regression tests with clear incident context. CI is green.
5-axis review: APPROVED at head
a1c0045a.Test-only PR.
test_boot_routes.pypins the boot-route contract, including always-mounted agent-card route, JSON-RPC route behavior, route ordering, and a real Starlette/TestClient smoke.test_credential_helper_subprocess.pyexercises real subprocess/git-config side effects under temp HOME rather than only mocked behavior. No production behavior/security/performance change; CI reported green and PR is mergeable.