Skip to content

Retire legacy mock-server endpoints + /v1/mint-aws-creds + /v1/auth/exchange (closes #77, #72, #78)#96

Merged
hanwencheng merged 3 commits into
mainfrom
claude/ecstatic-wright-7a2b8f
May 21, 2026
Merged

Retire legacy mock-server endpoints + /v1/mint-aws-creds + /v1/auth/exchange (closes #77, #72, #78)#96
hanwencheng merged 3 commits into
mainfrom
claude/ecstatic-wright-7a2b8f

Conversation

@hanwencheng
Copy link
Copy Markdown
Member

Summary

Cleans up three dead/legacy surfaces that were flagged for retirement:

38 files changed, +146 / -2941 lines.

What landed

Issue #77 — legacy endpoints

  • mock-server: drop /identity/link, /identity/resolve, /audit/query routes + their HTTP handler functions. Keep resolve_identity_typed as an internal helper still used by session.rs and auth_request.rs.
  • broker: drop /v1/auth/exchange route, handlers/auth/exchange.rs, auth.rs::validate_bearer_token + ValidatedSession. Keep extract_bearer_token (still used by /v1/mint-oidc-jwt).
  • broker config: drop BROKER_BACKEND_URL + BROKER_BACKEND_TIMEOUT_SECONDS env vars; remove BrokerConfig::backend_url, backend_request_timeout_seconds; remove Tier-2 backend reachability probe + Tier2State::backend_reachable field + the tier2/backend /readyz check.
  • core trait: remove CredentialBackend::query_audit + CredentialBackend::resolve_identity trait methods and all 5 impls (mock_client, s3_backend, test_client, MCP / orchestrator / CLI test stubs).
  • cli: delete Commands::Usage/Link/Recover + their cmd_* handlers. resolve_agent and resolve_agent_to_wallet now require a raw 0x… wallet — alias/email lookup against the deleted endpoints is gone.
  • daemon: resolve_parent_if_set rewritten as sync; requires a raw 0x… wallet (no HTTP call to the removed /identity/resolve).
  • mcp: list_credentials switched from query_audit to the trait's list_credentials method.
  • tests: deleted tests that exercised only the dead endpoints; converted /identity/link setup steps in daemon/tests/pair_tests.rs and mock-server/tests/integration.rs to direct-DB inserts via a new link_identity_direct helper. Updated cli_tests.rs to drop dead-command tests. Updated 8 broker test files to remove backend_url and backend_request_timeout_seconds from BrokerConfig construction.
  • scripts: scripts/broker.env and scripts/setup-broker-host.sh drop BROKER_BACKEND_URL (no longer read).

Issue #72 — /v1/mint-aws-creds

  • broker: drop route + delete handlers/mint.rs entirely (mint_v2 + helpers, ~700 LOC).
  • tests: delete mint_v2_flow.rs + invariant_load_bearing.rs (both exclusively exercised the deleted endpoint).
  • gate-rehoming:
    • Audit is already written by /v1/mint-oidc-jwt (state.audit.record_mint), and AWS CloudTrail captures every AssumeRoleWithWebIdentity call. No re-home needed.
    • Explicit-grant try_consume dropped with the endpoint; AWS PrincipalTag + bucket policy continue to enforce isolation per architecture.md §17.2.
    • Idempotency dedup dropped (JWT TTL is already short).
    • Per-omni rate-limit never existed in mint.rs in this tree (only email/oauth2 rate limits exist, untouched).

Issue #78

Folded into #77 — completing this PR closes #78.

What did NOT land

All plan steps shipped. None deferred.

Test plan

  • cargo build clean (workspace)
  • cargo test -p agentkeys-mock-server — 48 passed
  • cargo test -p agentkeys-broker-server — all suites pass (oidc 6, wallet 7, grant 4, email 0/0, oauth2 0/0, auth_wallet, ses_email ignored)
  • cargo test -p agentkeys-cli — 41 + 9 + 6 = 56 passed
  • cargo test -p agentkeys-core — 73 + 3 passed
  • cargo test -p agentkeys-daemon — 8 + 15 + 15 = 38 passed
  • cargo test -p agentkeys-mcp — 7 passed
  • cargo test -p agentkeys-provisioner — 23 + 7 passed
  • cargo test -p agentkeys-types — 8 passed
  • Operator re-deploy via scripts/setup-broker-host.sh --upgrade confirms /v1/auth/exchange and /v1/mint-aws-creds return 404 and /v1/mint-oidc-jwt + agentkeys init --email|--oauth2-google still work end-to-end (manual verification step).

🤖 Generated with Claude Code

… /v1/auth/exchange (closes #77 #72 #78)

Issue #77 — delete /identity/link, /identity/resolve, /audit/query, /v1/auth/exchange:
- mock-server: drop routes and HTTP handler functions; keep
  resolve_identity_typed as internal helper for session/auth_request paths
- broker: drop /v1/auth/exchange route, handlers/auth/exchange.rs,
  auth.rs::validate_bearer_token + ValidatedSession; keep extract_bearer_token
  (still used by mint-oidc handler)
- broker: drop BROKER_BACKEND_URL + BROKER_BACKEND_TIMEOUT_SECONDS,
  Tier-2 backend reachability probe + readyz check, Tier2State::backend_reachable,
  BrokerConfig::backend_url/backend_request_timeout_seconds
- core: drop CredentialBackend::query_audit and CredentialBackend::resolve_identity
  trait methods and all impls (mock_client, s3_backend, test stubs)
- cli: drop Commands::Usage/Link/Recover + cmd_usage/cmd_link/cmd_recover;
  resolve_agent now requires raw 0x wallet (alias/email lookup retired);
  resolve_agent_to_wallet same
- daemon: resolve_parent_if_set now requires raw 0x wallet, no HTTP call
- mcp: list_credentials uses CredentialBackend::list_credentials directly
  instead of round-tripping query_audit
- tests: remove tests targeting deleted endpoints; convert /identity/link
  setup steps to direct-DB inserts via new link_identity_direct helper

Issue #72 — delete /v1/mint-aws-creds:
- broker: drop /v1/mint-aws-creds route + handlers/mint.rs (mint_v2 + helpers)
- tests: delete mint_v2_flow.rs + invariant_load_bearing.rs (exclusively
  exercised the deleted endpoint). Audit happens at /v1/mint-oidc-jwt;
  AWS submission is daemon-side via OIDC JWT → AssumeRoleWithWebIdentity.

Issue #78 — folded into #77 per its own resolution comment.

scripts/broker.env + scripts/setup-broker-host.sh: drop BROKER_BACKEND_URL
since the broker no longer reads it.

Workspace tests: 73 (core) + 41 (cli) + 38 (daemon) + 7 (mcp) +
31 (provisioner) + 48 (mock-server) + multiple (broker) all pass.
…wup)

After this PR deleted GET /audit/query, the 8 INSERT INTO audit_log writes
in mock-server credential/session handlers became write-only dead code —
nothing reads them now and nothing ever will. Production audit lives at
broker plugin_mint_log (today) → agentkeys-worker-audit + Heima
CredentialAudit contract (post-#97). Mock-server never was on that path.

Removed:
- credential.rs: store/read/list audit INSERTs (6 sites covering ok,
  DENIED, DENIED_SCOPE, NOT_FOUND outcomes)
- session.rs: scope_update/scope_read audit INSERTs on cross-agent probes
  (2 sites)
- db.rs: CREATE TABLE audit_log schema

Tests still green: 48 mock-server, 176 broker, 41 cli, full workspace
(30 test-result groups, 0 failed).

Resolves codex adversarial-review finding [high] from PR #96 review.
@hanwencheng hanwencheng merged commit 15721d9 into main May 21, 2026
1 check passed
hanwencheng pushed a commit that referenced this pull request May 21, 2026
PR #96 retired legacy CLI commands (cmd_link, cmd_recover, cmd_usage) and
the bulk broker endpoints. This PR (#95) independently added two new
signer subcommands (cmd_signer_sign_typed_data, cmd_signer_preview_7730).
The conflict in main.rs was the import list — kept the new additions,
dropped the retired ones.

Workspace build clean; full cargo test suite passes; no behaviour change
from the merge resolution beyond combining the two PRs' independent
additions/removals.
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.

Identity + audit endpoint placement: broker = policy/audit-of-record, signer = execution/audit-emitter (resolves open question from #77)

2 participants