# A01 — Add research-only principals and durable job budgets Parent epic: E8. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Backend security/durable scheduling. Scheduling source of truth: [manifest entry A01](../manifest.json). No task is authorized until the plan is approved. Dependencies and decision references below describe the design; the manifest controls current readiness. ## Evidence and root cause - **AI-01 — Verified:** Existing small operator auth has read/admin/service roles, not a research-only principal or arbitrary-code isolation boundary. [libs/core/di/src/http/security.ts:4](../../../../libs/core/di/src/http/security.ts#L4); [libs/core/di/src/http/security.ts:144](../../../../libs/core/di/src/http/security.ts#L144). - **WEB-01 — Verified:** The real backtest list/detail/API/SQL flow already exists. Strategy/project/experiment work should extend it; App strategy/analytics views are placeholders. [apps/stock/web-app/src/app/App.tsx:24](../../../../apps/stock/web-app/src/app/App.tsx#L24); [apps/stock/web-api/src/services/backtest-v2.service.ts:211](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L211). ## Intended behavior and implementation scope Extend the small existing auth boundary with stable owner/agent identities and research-scoped permissions. Enforce per-agent concurrent-job/trial/time/resource budgets at admission and execution; record actor and audit events. Do not reinstate global historical data truncation limits. Measurable benefit: Allows autonomous research without autonomous brokerage control. ## Exclusions No speculative distributed infrastructure or weakened correctness gates. ## Likely files and ownership - libs/core/di/src/http/security.ts - apps/stock/web-api/src/routes/ - apps/stock/web-api/src/services/ (admission) - apps/stock/orchestrator/src/backtest/BacktestRunner.ts Write locks: auth-contract, experiment-api. One agent owns this change. Lock names do not override actual overlapping files. ## Dependencies and blockers Implementation requires [R06](R06.md), [O01](O01.md) integrated. Architecture decisions: ADR-007. Agents may not independently amend their policies. Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries. ## Acceptance criteria - AI research token can register hypotheses and submit authorized experiments but cannot call paper/live administration or mutate financial constraints. - Budget reservations are transactional and released on failure/cancellation/restart; retries do not double-charge. - User-configured budgets and rejections are visible; operator's large trusted datasets remain supported. ## Mandatory tests - research_token_live_denied, budget_concurrent_admission, budget_recovery, actor_audit. - Existing security/browser-session/CSRF tests; do not break current operator workflow. Apply the relevant [quality gates](../../QUALITY-GATES.md); submit exact commands, outcomes and skipped checks. Named cases above are required regression scenarios, not claims that those tests already exist. ## Regression risks and rollback Performance measurements can hide semantic changes; require economic hash equivalence. Keep migrations additive and previous results readable. Do not add a switch that restores a correctness defect. Versioned cutover/migration is required only when persisted contracts or active engines change; never silently fall back to old economics. ## Web/API contract and user states - API: Research-scoped credential routes/claims; typed403/429 with budget diagnostics on same experiment APIs. - Backend/data dependencies: Minimal principal/budget/audit persistence; existing local owner maps to one principal. - Loading/error/empty behavior: API identifies quota wait vs invalid request; UI can show admission error without losing experiment draft. - User-facing completion is demonstrated by the acceptance criteria and interaction tests above; a backend-only implementation is insufficient where a UI is in scope. ## Handoff Report scope changes (if any), fixture expectations, API/schema changes, measurements, remaining limitations and commit/PR references once authorized. Request independent review; only the integration/planning owner may mark the manifest done.