harness(phase-0): sudo-free Host-header path + chat_history + envelope replays - #2492
Merged
HongmingWang-Rabbit merged 1 commit intoMay 2, 2026
Merged
Conversation
…e replays Three changes that bring the local harness from "covers what staging covers minus the SaaS topology" to "exercises every surface we shipped this session against the prod-shape Dockerfile.tenant image." 1. Drop the /etc/hosts requirement. Replays previously needed `127.0.0.1 harness-tenant.localhost` in /etc/hosts to resolve the cf-proxy. That gated the harness behind a sudo step on every fresh dev box and CI runner. The cf-proxy nginx already routes by Host header (matches production CF tunnel: URL is public, Host carries tenant identity), so the no-sudo path is to target loopback :8080 with `Host: harness-tenant.localhost` set as a header. New `tests/harness/_curl.sh` centralises this — curl_anon / curl_admin / curl_workspace / psql_exec wrappers all set the Host + auth headers automatically. seed.sh, peer-discovery-404.sh, buildinfo-stale-image.sh updated to source it. Legacy /etc/hosts users still work via env-var override. 2. Fix the seed.sh FK regression that blocked DB-side replays. POST /workspaces ignores any `id` in the request body and generates one server-side. seed.sh was minting client-side UUIDs that never reached the workspaces table, so any replay that INSERTed into activity_logs (FK-constrained on workspace_id) failed with the workspace-not-found error. Capture the returned id from the response instead. 3. Two new replays cover the surfaces shipped this session. chat-history.sh — exercises the full SaaS-shape wire that PR #2472 (peer_id filter), #2474 (chat_history client tool), and #2476 (before_ts paging) ride on. 8 phases / 16 assertions: peer_id filter, limit cap, before_ts paging, OR-clause covering both source_id and target_id, malformed peer_id 400, malformed before_ts 400, URL-encoded SQLi-shape rejection. Verified PASS against the live harness. channel-envelope-trust-boundary.sh — exercises PR #2471 + #2481 by importing from `molecule_runtime.*` (the wheel-rewritten path) so it catches "wheel build dropped a fix that unit tests still pass." 5 phases / 11 assertions: malicious peer_id scrubbed from envelope, agent_card_url omitted on validation failure, XML-injection bytes scrubbed, valid UUID preserved, _agent_card_url_for direct gate. Verified PASS against published wheel 0.1.79. run-all-replays.sh auto-discovers — no registration needed. Full lifecycle (boot → seed → 4 replays → teardown) runs clean. Roadmap section updated to reflect Phase 1 (this PR) → Phase 2 (multi-tenant + CI gate) → Phase 3 (real CP) → Phase 4 (Miniflare + LocalStack + traffic replay). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
HongmingWang-Rabbit
requested a review
from hongmingwang-moleculeai
as a code owner
May 2, 2026 03:13
HongmingWang-Rabbit
enabled auto-merge
May 2, 2026 03:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 0 of the long-term harness roadmap — three changes that bring the local harness from "covers what staging covers minus the SaaS topology" to "exercises every surface we shipped this session against the prod-shape `Dockerfile.tenant` image."
1. Drop the `/etc/hosts` requirement
Replays previously needed `127.0.0.1 harness-tenant.localhost` in `/etc/hosts` to resolve the cf-proxy. That gated the harness behind a sudo step on every fresh dev box and CI runner. cf-proxy nginx already routes by Host header (matches production CF tunnel), so the no-sudo path is to target loopback `:8080` with `Host: harness-tenant.localhost` set as a header.
New `tests/harness/_curl.sh` centralises this — `curl_anon`, `curl_admin`, `curl_workspace`, and `psql_exec` wrappers all set the right Host + auth headers automatically. `seed.sh`, `peer-discovery-404.sh`, `buildinfo-stale-image.sh` updated to source it. Legacy `/etc/hosts` users still work via env-var override.
2. Fix the `seed.sh` FK regression that blocked DB-side replays
`POST /workspaces` ignores any `id` in the request body and generates one server-side. `seed.sh` was minting client-side UUIDs that never reached the workspaces table, so any replay that INSERTed into `activity_logs` (FK-constrained on `workspace_id`) failed with `workspace not found`. Capture the returned id from the response instead.
3. Two new replays cover the surfaces shipped this session
`replays/chat-history.sh` — exercises the full SaaS-shape wire that PR #2472 (peer_id filter), #2474 (chat_history client tool), and #2476 (before_ts paging) ride on. 8 phases / 16 assertions:
`replays/channel-envelope-trust-boundary.sh` — exercises PR #2471 + #2481 by importing from `molecule_runtime.*` (the wheel-rewritten path) so it catches "wheel build dropped a fix that unit tests still pass." 5 phases / 11 assertions:
`run-all-replays.sh` auto-discovers `replays/*.sh` — no registration needed.
Verification
```
$ ./run-all-replays.sh
[run-all] booting harness...
[run-all] seeding workspaces...
[run-all] ━━━ buildinfo-stale-image ━━━ PASS
[run-all] ━━━ channel-envelope-trust-boundary ━━━ PASS (11/11 against wheel 0.1.79)
[run-all] ━━━ chat-history ━━━ PASS (16/16)
[run-all] ━━━ peer-discovery-404 ━━━ PASS
[run-all] Replay summary: 4 passed, 0 failed (of 4 total)
```
Test plan
🤖 Generated with Claude Code