21 lines
3.8 KiB
Markdown
21 lines
3.8 KiB
Markdown
# RP20 — Enable research authentication in the normal API server
|
|
|
|
Parent E12. Priority P1 / High functional defect. Complexity S. Dependencies A01 and A03. The owner's “commit and continue” authorizes the bounded research follow-up and this prerequisite, including validated commits. Root owns planning/integration; one backend implementer owns API composition and focused regression tests. Independent review required.
|
|
|
|
Verified evidence: `apps/stock/web-api/src/server-with-websocket.ts` constructs and supplies HTTP security without `resolveResearchCredential`. `routes/create-routes.ts` installs the resolver only when security is omitted. `libs/core/di/src/http/security.ts` therefore reports research disabled in normal startup. Test hosts explicitly install the resolver and mask the omission. Operator research-credential provisioning and research bearer requests cannot use the deployed application's intended A01 path.
|
|
|
|
Scope: wire `ResearchAgentsService.authenticate` into the normal application's shared HTTP/WebSocket security instance. Prefer one small composition seam used by production and its regression tests; preserve explicit supplied-security behavior, token/environment validation, browser sessions, CORS, synchronous WebSocket authorization and existing service lifecycle. Do not expose research tokens as privileged identities. Avoid a new authentication framework or mutable global resolver state.
|
|
|
|
Exclusions: new roles or capabilities, wider agent permissions, financial/native/schema changes, general server-lifecycle refactoring, research execution, paper/live activation and performance work. A later bounded study uses this existing credential path; it is not part of this fix.
|
|
|
|
Acceptance and mandatory tests:
|
|
|
|
- Regression executes the same composition invoked by normal server startup, fails on the missing resolver, and verifies credential-backed operator provisioning can reach its existing service. Tests must not silently supply an independently configured research resolver.
|
|
- An issued research token authenticates an allowed scoped research request through the real resolver; invalid/revoked credentials fail. Preserve agent identity and existing budget enforcement rather than using an operator fallback.
|
|
- Research tokens cannot provision credentials, enter browser sessions, upgrade WebSockets, or call paper/live/administrative routes. Disabled-auth provisioning stays fail-closed. Explicit supplied security keeps its declared capabilities.
|
|
- Existing research-agent API/security tests and scoped types/lint/format pass. Root runs the repository check and affected disposable PostgreSQL research-agent tests. No tests or provisioning against development accounts.
|
|
- Independent review checks production wiring, shared security identity, denial-before-side-effects and whether tests actually cover the startup seam. Record exact commands and limitations before closing.
|
|
|
|
Regression risks: tests reconstructing a different security object again; accidentally permitting async research identities on the privileged WebSocket path; weakening disabled-auth rules; moving startup validation without preserving failure behavior. Keep the implementation focused on composition, not authorization policy.
|
|
|
|
Accepted October 27, 2026: plan `fd90d172`, implementation `7de497e9`. Independent security tests passed 21 tests / 175 assertions. Root full repository check passed, including 1,382 integration and 150 Rust tests. Disposable PostgreSQL proof passed 13 tests / 143 assertions for actual issuance, scope/identity, quota admission/rejection and revocation. Authored-test types, lint, formatting and diff checks passed. [Execution evidence](../../real-data-research.md#rp20--production-research-authentication) retains the failing baseline, corrected test expectations and verification limits. No development credentials, research runs or trading state changed.
|