3496a1beb7
Persist orchestration artifacts, including plan definition, progress state, decisions, issues, and learnings gathered during delegated execution and QA gates. This preserves implementation rationale and auditability without coupling documentation snapshots to runtime logic commits.
1.1 KiB
1.1 KiB
Learnings: NATS Port Dynamic Allocation Fix
Problem
- Hardcoded
NATS_PORT = 4222caused test failures when port 4222 was occupied by system services - F4 flagged this as scope-fidelity drift
Solution
- Added
_find_open_port()helper usingsocket.socket().bind(("127.0.0.1", 0))to find available port - Updated
nats_serverfixture to yield(bool, int)tuple instead of just bool - Updated
_start_nats_container(port: int)to accept dynamic port parameter - Wired dynamic port through all test methods using
nats_url = f"nats://127.0.0.1:{port}"
Key Implementation Details
- Port discovery happens in fixture before container start
- Same port used for Docker
-p {port}:{port}mapping and NATS URL - Fixture returns
(False, 0)when Docker/server unavailable to preserve skip behavior - Cleanup via
_stop_nats_container()preserved infinallyblock
Verification Results
pytest tests/demo/test_nats.py -q: 9 passed, 2 skipped (Docker unavailable in CI)basedpyright tests/demo/test_nats.py: 0 errors, 1 warning (reportAny on socket.getsockname)
Files Modified
tests/demo/test_nats.pyonly (as required)