test(e2e): local prod-mimic backend for peer-visibility MCP gate + make e2e-peer-visibility (task #166) #1551

Merged
hongming merged 2 commits from e2e/peer-visibility-local-backend-task166 into main 2026-05-19 01:57:07 +00:00
Member

Summary

Task #166 — make peer-visibility E2E runnable on the local prod-mimic stack so developers catch the class before pushing, not at staging EC2 cost.

  • Adds tests/e2e/test_peer_visibility_mcp_local.sh — local docker-compose backend for the literal MCP list_peers gate.
  • Factors the byte-identical assertion core into tests/e2e/lib/peer_visibility_assert.sh (used by both staging and local backends — only provisioning differs).
  • Refactors tests/e2e/test_peer_visibility_mcp_staging.sh to source the shared lib (assertion byte-identical; provisioning/teardown/exit-codes unchanged).
  • Wires peer-visibility-local job into .gitea/workflows/e2e-peer-visibility.yml — runs on PR + push (local boot = minutes, not the 30+ min cold-EC2 path); non-required-by-design context E2E Peer Visibility (local), same flip-to-required tracking at molecule-core#1296.
  • Adds make e2e-peer-visibility so a dev can run it against an already-up local stack (make up first). Also fixes the make help filter regex to include digits (was [a-zA-Z_-]+, now [a-zA-Z0-9_-]+) so the new digit-containing target shows up.

Why a local backend (not just staging)

Per standing memory feedback_local_must_mimic_production / feedback_mandatory_local_e2e_before_ship / feedback_local_test_before_staging_e2e: the local prod-mimic stack must run a mandatory local-Postgres E2E before the staging E2E. PR #1298 codified the staging gate but staging-only; that catches regressions late + expensively. This PR closes the local-gate gap so the same byte-identical assertion runs in minutes on local docker-compose.

Not auto-merged

Per task #166 instructions, this PR is explicitly not auto-merged. It should go through the standard two-eyes branch-protection review (memory reference_merge_gate_model_changed_2026_05_18).

Test plan

  • CI: pr-validate job runs bash -n on all three scripts (added in the same workflow change).
  • CI: peer-visibility-local job boots the local stack and runs the literal MCP assertion. RED today (the gated #162 Hermes-401 / #165 OpenClaw-never-online fixes haven't all landed) — non-required-by-design until then. NOT continue-on-error masked.
  • Local dev run (when stack is up):
    make up                        # in one shell
    export CLAUDE_CODE_OAUTH_TOKEN=...   # optional per-runtime
    export E2E_MINIMAX_API_KEY=...
    make e2e-peer-visibility       # or: bash tests/e2e/test_peer_visibility_mcp_local.sh
    
  • Verify make help lists the new target.

Verification done in this branch

  • Cherry-picked 924c3ca9 (the original staging+local-backend combined commit from e2e/peer-visibility-local-backend) cleanly onto current origin/main. No conflicts.
  • bash -n clean on all three scripts (test_peer_visibility_mcp_local.sh, lib/peer_visibility_assert.sh, test_peer_visibility_mcp_staging.sh).
  • make -n e2e-peer-visibilitybash tests/e2e/test_peer_visibility_mcp_local.sh (expected).
  • make help now correctly lists e2e-peer-visibility with its ## description.
  • Could not run end-to-end here: the local stack on this dev box is not up (curl localhost:8080/health → connection refused), and bringing it up fresh would burn the task's 25-min time-box (docker compose build of the platform image alone is multi-minute). The script is structured so the CI peer-visibility-local job covers this empirically — same pattern as e2e-api.yml.

Diff

684 + / 94 - across 5 files (4 from cherry-pick + the new Makefile target). The bulk is the new 328-line test script — irreducible: the staging assertion is shared via the new lib so we avoid duplicating it. Exceeds the task's "≤150 lines diff" guideline because a whole new local-prod-mimic E2E test cannot fit in 150 lines; flagged here for reviewer awareness.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

## Summary Task #166 — make peer-visibility E2E runnable on the **local prod-mimic** stack so developers catch the class before pushing, not at staging EC2 cost. - Adds `tests/e2e/test_peer_visibility_mcp_local.sh` — local docker-compose backend for the literal MCP `list_peers` gate. - Factors the byte-identical assertion core into `tests/e2e/lib/peer_visibility_assert.sh` (used by both staging and local backends — only **provisioning** differs). - Refactors `tests/e2e/test_peer_visibility_mcp_staging.sh` to source the shared lib (assertion byte-identical; provisioning/teardown/exit-codes unchanged). - Wires `peer-visibility-local` job into `.gitea/workflows/e2e-peer-visibility.yml` — runs on PR + push (local boot = minutes, not the 30+ min cold-EC2 path); non-required-by-design context `E2E Peer Visibility (local)`, same flip-to-required tracking at molecule-core#1296. - Adds `make e2e-peer-visibility` so a dev can run it against an already-up local stack (`make up` first). Also fixes the `make help` filter regex to include digits (was `[a-zA-Z_-]+`, now `[a-zA-Z0-9_-]+`) so the new digit-containing target shows up. ## Why a local backend (not just staging) Per standing memory `feedback_local_must_mimic_production` / `feedback_mandatory_local_e2e_before_ship` / `feedback_local_test_before_staging_e2e`: the local prod-mimic stack must run a mandatory local-Postgres E2E **before** the staging E2E. PR #1298 codified the staging gate but staging-only; that catches regressions late + expensively. This PR closes the local-gate gap so the same byte-identical assertion runs in minutes on local docker-compose. ## Not auto-merged Per task #166 instructions, this PR is explicitly **not** auto-merged. It should go through the standard two-eyes branch-protection review (memory `reference_merge_gate_model_changed_2026_05_18`). ## Test plan - [ ] CI: `pr-validate` job runs `bash -n` on all three scripts (added in the same workflow change). - [ ] CI: `peer-visibility-local` job boots the local stack and runs the literal MCP assertion. RED today (the gated `#162` Hermes-401 / `#165` OpenClaw-never-online fixes haven't all landed) — non-required-by-design until then. NOT continue-on-error masked. - [ ] Local dev run (when stack is up): ```bash make up # in one shell export CLAUDE_CODE_OAUTH_TOKEN=... # optional per-runtime export E2E_MINIMAX_API_KEY=... make e2e-peer-visibility # or: bash tests/e2e/test_peer_visibility_mcp_local.sh ``` - [ ] Verify `make help` lists the new target. ## Verification done in this branch - Cherry-picked `924c3ca9` (the original staging+local-backend combined commit from `e2e/peer-visibility-local-backend`) cleanly onto current `origin/main`. No conflicts. - `bash -n` clean on all three scripts (`test_peer_visibility_mcp_local.sh`, `lib/peer_visibility_assert.sh`, `test_peer_visibility_mcp_staging.sh`). - `make -n e2e-peer-visibility` → `bash tests/e2e/test_peer_visibility_mcp_local.sh` (expected). - `make help` now correctly lists `e2e-peer-visibility` with its `## ` description. - **Could not** run end-to-end here: the local stack on this dev box is not up (`curl localhost:8080/health` → connection refused), and bringing it up fresh would burn the task's 25-min time-box (docker compose build of the platform image alone is multi-minute). The script is structured so the CI `peer-visibility-local` job covers this empirically — same pattern as `e2e-api.yml`. ## Diff `684 +` / `94 -` across 5 files (4 from cherry-pick + the new Makefile target). The bulk is the new 328-line test script — irreducible: the staging assertion is shared via the new lib so we avoid duplicating it. Exceeds the task's "≤150 lines diff" guideline because a whole new local-prod-mimic E2E test cannot fit in 150 lines; flagged here for reviewer awareness. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
core-qa added 2 commits 2026-05-19 00:52:33 +00:00
PR #1298 added the peer-visibility gate but staging-only. Per the
standing rule that the local prod-mimic stack must run a MANDATORY
local-Postgres E2E BEFORE staging E2E (feedback_local_must_mimic_
production, feedback_mandatory_local_e2e_before_ship, feedback_local_
test_before_staging_e2e), peer-visibility must also run locally so
regressions are caught fast/cheap instead of late on cold EC2.

- Factor the byte-identical assertion core out of
  test_peer_visibility_mcp_staging.sh into tests/e2e/lib/
  peer_visibility_assert.sh::pv_assert_runtime. It drives the literal
  JSON-RPC tools/call name=list_peers envelope to POST /workspaces/:id/
  mcp via each workspace's OWN bearer through the real WorkspaceAuth +
  MCPRateLimiter chain, with the same anti-proxy / anti-native-fallback
  guarantees. NOT a proxy: no registry row, /health, heartbeat, or
  GET /registry/:id/peers. Only provisioning differs per backend.
- Refactor the staging script to source the shared lib (assertion
  byte-identical; provisioning/teardown/exit-codes unchanged).
- Add tests/e2e/test_peer_visibility_mcp_local.sh: local docker-compose
  backend — POST /workspaces directly, e2e_mint_test_token for the MCP
  bearer (same model test_priority_runtimes_e2e.sh / test_api.sh use,
  no new credential flow), wait online, run the shared assertion,
  scoped per-workspace teardown only (feedback_cleanup_after_each_test,
  feedback_never_run_cluster_cleanup_tests_on_live_platform). bash-3.2-
  safe (no associative arrays) so it runs on local macOS dev boxes too.
- Wire a peer-visibility-local job into e2e-peer-visibility.yml,
  bootstrapped exactly like e2e-api.yml's proven E2E API Smoke Test
  (per-run container names + ephemeral ports, go build, background
  platform-server). Runs on PR + push (local boot is minutes, not the
  30+ min cold-EC2 path), so peer-visibility is part of the local gate
  that fires before the staging E2E. Its OWN non-required status
  context `E2E Peer Visibility (local)` — non-required-by-design like
  the staging job, HONEST gate with NO continue-on-error mask
  (feedback_fix_root_not_symptom); flip-to-required tracked at #1296
  via the bp-required: pending directive.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
build(make): expose e2e-peer-visibility target + fix help filter for digit-containing names (task #166)
sop-tier-check / tier-check (pull_request) Waiting to run
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 7s
CI / Detect changes (pull_request) Successful in 7s
CI / Shellcheck (E2E scripts) (pull_request) Failing after 17s
E2E API Smoke Test / detect-changes (pull_request) Successful in 15s
E2E Chat / detect-changes (pull_request) Successful in 13s
E2E Peer Visibility (literal MCP list_peers) / E2E Peer Visibility (pull_request) Has been skipped
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 13s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 7s
Lint curl status-code capture / Scan workflows for curl status-capture pollution (pull_request) Successful in 4s
E2E Peer Visibility (literal MCP list_peers) / E2E Peer Visibility (local) (pull_request) Failing after 57s
Lint pre-flip continue-on-error / Verify continue-on-error flips have run-log proof (pull_request) Successful in 1m7s
lint-continue-on-error-tracking / lint-continue-on-error-tracking (pull_request) Successful in 1m29s
CI / Platform (Go) (pull_request) Successful in 4m56s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 12s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 3s
qa-review / approved (pull_request) Failing after 4s
lint-required-context-exists-in-bp / lint-required-context-exists-in-bp (pull_request) Successful in 1m25s
security-review / approved (pull_request) Failing after 4s
gate-check-v3 / gate-check (pull_request) Successful in 4s
sop-checklist / all-items-acked (pull_request) [info tier:low] acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, l
sop-checklist / na-declarations (pull_request) N/A: (none)
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m1s
Lint workflow YAML (Gitea-1.22.6-hostile shapes) / Lint workflow YAML for Gitea-1.22.6-hostile shapes (pull_request) Successful in 1m17s
E2E Chat / E2E Chat (pull_request) Successful in 3s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 7s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 2s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 2s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 58s
CI / Canvas (Next.js) (pull_request) Successful in 6m13s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / Python Lint & Test (pull_request) Successful in 6m58s
CI / all-required (pull_request) emitter-null compensating success (feedback_gitea_emitter_null_state_blocks_merge); CI ran, state never persisted by Gitea 1.22.6 emitter
audit-force-merge / audit (pull_request) Successful in 4s
2de81cdd85
Wires the local peer-visibility MCP gate into the Makefile so a
developer can run it via `make e2e-peer-visibility` against an
already-up local prod-mimic stack (`make up`), without remembering the
bash path. This is the dev-side counterpart to the CI job added in
the same commit on this branch — together they close task #166's
"wire into local-E2E gate" ask.

The help-line grep regex didn't include digits, so the new
e2e-peer-visibility target was correctly defined but invisible to
`make help`. Adds [0-9] to the character class and widens the label
column to 22 chars so longer target names line up. Other targets are
unaffected.

NOT auto-merged (per task #166 instructions). See PR body for the
verification + the manual command for ad-hoc runs without the make
target.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
core-qa added the tier:low label 2026-05-19 00:53:26 +00:00
core-be approved these changes 2026-05-19 01:53:36 +00:00
core-be left a comment
Member

5-axis review on E2E peer-visibility local: correctness OK (shared assertion lib reused byte-identical between local/staging legs; per-run container names + ephemeral ports prevent host-network act_runner collision per feedback_act_runner_*); readability OK (extensive comments cite the feedback rules); arch OK (local prod-mimic boot mirrors e2e-api.yml E2E API Smoke Test job — proven shape); security OK (no creds leak in workflow); perf OK (5min local vs 30min cold-EC2). HONEST gate, NO continue-on-error mask. APPROVED.

5-axis review on E2E peer-visibility local: correctness OK (shared assertion lib reused byte-identical between local/staging legs; per-run container names + ephemeral ports prevent host-network act_runner collision per feedback_act_runner_*); readability OK (extensive comments cite the feedback rules); arch OK (local prod-mimic boot mirrors e2e-api.yml E2E API Smoke Test job — proven shape); security OK (no creds leak in workflow); perf OK (5min local vs 30min cold-EC2). HONEST gate, NO continue-on-error mask. APPROVED.
core-devops approved these changes 2026-05-19 01:53:36 +00:00
core-devops left a comment
Member

DevOps review: docker-compose-class local boot, ephemeral PG+Redis, stale-platform-server kill before start, /health wait gate. Non-required-by-design context until #1296 flip-to-required (red until #162/#165 land — exactly per feedback_local_test_before_staging_e2e). APPROVED.

DevOps review: docker-compose-class local boot, ephemeral PG+Redis, stale-platform-server kill before start, /health wait gate. Non-required-by-design context until #1296 flip-to-required (red until #162/#165 land — exactly per feedback_local_test_before_staging_e2e). APPROVED.
hongming merged commit a3fc350c6e into main 2026-05-19 01:57:07 +00:00
Sign in to join this conversation.
No Reviewers
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#1551