fix(router): spec-compliance probe checks canonical multi-domain endpoints (#119) #123

Merged
mahmoud merged 1 commit from development_router_diag_probe into development 2026-06-14 17:29:49 +00:00
Owner

Fixes the /api/diagnostics/{service} Spec compliance probe so a healthy, fully-migrated oschema service reports Compliant, and stops flagging admin.sock / web.sock as unknown.

Root cause

  • probe_socket (rpc) probed the pre-migration bare endpoints: POST /rpc, GET /openrpc.json, GET /health, GET /.well-known/heroservice.json — all 404 on a migrated service.
  • classify_socket only knew rpc/ui/rest/openapi/web_*, so admin.sock and the bare web.sock fell into "Unknown socket files (not in spec)".

Fix (aligned to current hero_sockets.md)

  • classify_socket now recognizes canonical roles: admin.sock, bare web.sock, resp.sock; legacy ui.sock → HTML-UI role.
  • probe_socket (rpc) probes /health.json, /heroservice.json, /api/domains.json, /api/ping, then reads /api/domains.json and probes /api/{domain}/openrpc.json + POST /api/{domain}/rpc for every domain (fallback main).
  • admin/rest/openapi/web probe sets use /health.json + /heroservice.json; web stays optional (third-party).

Tests

  • Unit: classify_socket canonical roles, parse_domain_names (multi/single/garbage→main), validate_rpc_dispatch envelope.
  • Functional (live, real hero_fake_service): new functional/diagnostics.rs asserts compliant, no unknown sockets, every /api/{domain}/rpc probed & passing.

End-to-end verification (live router + two-domain fake service)

compliant : True
required  : 8 pass / 0 fail
unknown   : []
--- rpc.sock (type=rpc) pass=8 fail=0
      GET  /health.json              passed=True 200
      GET  /heroservice.json         passed=True 200
      GET  /api/domains.json         passed=True 200
      GET  /api/ping                 passed=True 200
      GET  /api/alpha/openrpc.json   passed=True 200
      POST /api/alpha/rpc            passed=True 200
      GET  /api/beta/openrpc.json    passed=True 200
      POST /api/beta/rpc             passed=True 200
--- web.sock (type=web) pass=0 fail=0  (optional /, /health.json, /heroservice.json all 200)

cargo fmt --check, cargo clippy --all-targets, cargo test -p hero_router (146) all clean.

Closes #119.

Note: based on development_router_diag_probe (off development, already includes #121 + #122). Diff is just the probe changes.

🤖 Generated with Claude Code

Fixes the `/api/diagnostics/{service}` **Spec compliance probe** so a healthy, fully-migrated oschema service reports **Compliant**, and stops flagging `admin.sock` / `web.sock` as unknown. ### Root cause - `probe_socket` (rpc) probed the pre-migration bare endpoints: `POST /rpc`, `GET /openrpc.json`, `GET /health`, `GET /.well-known/heroservice.json` — all 404 on a migrated service. - `classify_socket` only knew `rpc/ui/rest/openapi/web_*`, so `admin.sock` and the bare `web.sock` fell into "Unknown socket files (not in spec)". ### Fix (aligned to current `hero_sockets.md`) - **`classify_socket`** now recognizes canonical roles: `admin.sock`, bare `web.sock`, `resp.sock`; legacy `ui.sock` → HTML-UI role. - **`probe_socket` (rpc)** probes `/health.json`, `/heroservice.json`, `/api/domains.json`, `/api/ping`, then reads `/api/domains.json` and probes `/api/{domain}/openrpc.json` + `POST /api/{domain}/rpc` for **every** domain (fallback `main`). - **admin/rest/openapi/web** probe sets use `/health.json` + `/heroservice.json`; web stays optional (third-party). ### Tests - Unit: `classify_socket` canonical roles, `parse_domain_names` (multi/single/garbage→`main`), `validate_rpc_dispatch` envelope. - Functional (live, real `hero_fake_service`): new `functional/diagnostics.rs` asserts compliant, no unknown sockets, every `/api/{domain}/rpc` probed & passing. ### End-to-end verification (live router + two-domain fake service) ``` compliant : True required : 8 pass / 0 fail unknown : [] --- rpc.sock (type=rpc) pass=8 fail=0 GET /health.json passed=True 200 GET /heroservice.json passed=True 200 GET /api/domains.json passed=True 200 GET /api/ping passed=True 200 GET /api/alpha/openrpc.json passed=True 200 POST /api/alpha/rpc passed=True 200 GET /api/beta/openrpc.json passed=True 200 POST /api/beta/rpc passed=True 200 --- web.sock (type=web) pass=0 fail=0 (optional /, /health.json, /heroservice.json all 200) ``` `cargo fmt --check`, `cargo clippy --all-targets`, `cargo test -p hero_router` (146) all clean. Closes #119. > Note: based on `development_router_diag_probe` (off `development`, already includes #121 + #122). Diff is just the probe changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(router): spec-compliance probe checks canonical multi-domain endpoints
All checks were successful
Build & Test / check (pull_request) Successful in 12m56s
207274102e
Closes #119. The `/api/diagnostics/{service}` probe reported a healthy,
fully-migrated oschema service as Non-compliant because it probed the
pre-migration bare endpoints on rpc.sock (`POST /rpc`, `GET /openrpc.json`,
`GET /health`, `GET /.well-known/heroservice.json` — all 404), and it flagged
`admin.sock` / `web.sock` as "Unknown socket files (not in spec)".

Align the probe with the current `hero_sockets.md` contract:

- `classify_socket`: recognize the canonical roles `admin.sock` and the bare
  `web.sock` (plus `resp.sock`); map legacy `ui.sock` to the HTML-UI role. No
  more spurious "unknown socket" for first-party sockets.
- `probe_socket` (rpc): probe `/health.json`, `/heroservice.json`,
  `/api/domains.json`, `/api/ping`, then fetch `/api/domains.json` and probe
  `/api/{domain}/openrpc.json` + `POST /api/{domain}/rpc` for **every** domain
  (falls back to `main`). JSON-RPC dispatch still validated by envelope.
- admin/rest/openapi/web probe sets use `/health.json` + `/heroservice.json`
  (not `/health` + `/.well-known/heroservice.json`); web stays optional.

Tests:
- unit: `classify_socket` canonical roles, `parse_domain_names`
  (multi/single/garbage → `main` fallback), `validate_rpc_dispatch` envelope.
- functional (live, real `hero_fake_service`): new `functional/diagnostics.rs`
  asserts the multi-domain service is compliant, no unknown sockets, and every
  `/api/{domain}/rpc` is probed and passes.

Verified end-to-end against a live router + two-domain fake service:
compliant=true, unknown=[], 8/8 rpc.sock endpoints pass, web.sock=type:web.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mahmoud merged commit cb1d53f5f5 into development 2026-06-14 17:29:49 +00:00
mahmoud deleted branch development_router_diag_probe 2026-06-14 17:29:58 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_router!123
No description provided.