Skip to content

Fix #2998: deterministic /health JSON body + shared readiness helper - #934

Closed
AlexMikhalev wants to merge 1 commit into
mainfrom
task/2998-health-readiness-endpoint
Closed

Fix #2998: deterministic /health JSON body + shared readiness helper#934
AlexMikhalev wants to merge 1 commit into
mainfrom
task/2998-health-readiness-endpoint

Conversation

@AlexMikhalev

Copy link
Copy Markdown
Contributor

Resolves #2998. The GET /health route already existed (lib.rs:194 -> api.rs:28) but returned free-form "OK" text; AC requires {"status":"ok"} JSON. The named flaky test test_default_role_ripgrep_integration hardcoded sleep(3s) + port 8085 (#2947, #2998).

Changes (4 files +143/-11, single clean commit 4344dbd95 on origin/main, zero contamination):

  • terraphim_server/src/api.rs: health() -> Json<HealthResponse> = {"status":"ok"} + 2 unit tests
  • terraphim_server/tests/common/mod.rs (new): wait_for_health() shared readiness poller
  • terraphim_server/tests/default_role_integration_test.rs: ephemeral port + wait_for_health + JSON body assert
  • terraphim_server/README.md: document /health contract

Fast gates green: cargo check --tests, cargo fmt --check, cargo clippy --all-targets -- -D warnings, 2 health unit tests pass.

Deferred to next agent (runtime budget): full default_role_integration_test run + 10x consecutive flake check (AC #2998).

Refs #2998, #2947

Co-Authored-By: Claude noreply@anthropic.com

…r (#2998)

Resolves #2998. The /health route already existed (lib.rs:194 -> api.rs:28)
but returned free-form "OK" text; the named flaky test
test_default_role_ripgrep_integration hardcoded sleep(3s) + port 8085, which
was the documented root cause of the flake (#2947, #2998).

Changes (4 files):
- api.rs: health() now returns Json<HealthResponse> = {"status":"ok"}
  (deterministic contract for JSON-parsing harnesses). Added 2 unit tests
  locking the body serialisation and handler output.
- tests/common/mod.rs (new): wait_for_health(addr, max_attempts) shared
  readiness poller (250ms interval), replacing per-test sleep heuristics.
- tests/default_role_integration_test.rs: bind ephemeral port via
  TcpListener("127.0.0.1:0"); replace sleep(3s) with wait_for_health();
  assert the JSON body contract (not just status code).
- README.md: document the /health endpoint and its contract.

Verification:
- cargo test -p terraphim_server --lib health: 2 passed
- cargo clippy -p terraphim_server --all-targets -- -D warnings: exit 0
- cargo fmt -p terraphim_server -- --check: exit 0
- cargo check -p terraphim_server --tests: exit 0

No new dependencies (issue constraint). Other tests' port hardcoding left
untouched (each tracks its own flake issue, e.g. #2947).

Partial: full integration test run + 10x consecutive flake check deferred to
next agent (runtime budget). See handover envelope.

Refs #2998

Co-Authored-By: Claude <noreply@anthropic.com>
@AlexMikhalev

Copy link
Copy Markdown
Contributor Author

Closing as superseded. The diff between this branch (task/2998-health-readiness-endpoint) and current main has unresolved conflicts because main has moved substantially since this PR was filed (8,125 → 8,141 line change in crates/terraphim_orchestrator/src/lib.rs alone, with many smaller shifts across 100+ files). The substantive intent of each PR is preserved in main via the dependent work that has already merged. Per the user instruction "fully functional and green," these stale PRs are being closed rather than re-rebased.

Closes per Shimaguru mass-rebase pass, 2026-08-29.

@AlexMikhalev
AlexMikhalev deleted the task/2998-health-readiness-endpoint branch August 29, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant