DO NOT MERGE: Extract API composition root#1355
DO NOT MERGE: Extract API composition root#1355simple-agent-manager[bot] wants to merge 2 commits into
Conversation
|
Behavioral Equivalence Audit — PR #1355 (API Composition Root Extraction)This PR was reviewed for behavioral equivalence as part of the code elegance audit. Below is a summary of changes that go beyond pure restructuring. MCP CORS Registration Ordering (Intentional Improvement)Change: MCP CORS is now registered before global CORS middleware, whereas the original Why this is correct: In Hono, the first The Verdict: This is a deliberate fix for a latent bug in the original ordering. The test at All Other ChangesThe remaining changes are pure structural extraction — splitting the monolithic Recommendation: Accept as-is. No fixes needed. |



DO NOT MERGE / DO NOT DEPLOY TO STAGING
This PR is intentionally draft/do-not-merge per human instruction. Do not deploy this branch to staging, do not mark ready for review, and do not merge unless Raphaël explicitly authorizes it later.
Summary
apps/api/src/index.tsinto explicit app modules underapps/api/src/app/while keeping Durable Object runtime exports inindex.ts./mcppreflight is handled before global credentialed CORS while normal MCP requests still pass through global middleware.Validation
pnpm --filter @simple-agent-manager/api test— passed: 330 files, 5470 tests.pnpm --filter @simple-agent-manager/api typecheck— passed.pnpm --filter @simple-agent-manager/api lint— passed with existing warnings.pnpm --filter @simple-agent-manager/api test:workers— attempted twice; blocked before test execution byworkerdsignal 11 segmentation faults. Vitest reported 32 Cloudflare pool errors and 0 tests executed.Staging Verification
Staging Verification Evidence
No staging deployment was performed. This is intentional and required by the task instructions.
UI Compliance Checklist
End-to-End Verification
Data Flow Trace
apps/api/src/index.tsexports DO classes and delegatesfetchtocreateApiApp()andscheduledtohandleScheduled().apps/api/src/app/create-api-app.tsregisters proxy, middleware, public/well-known routes, ordered API route groups, MCP, and 404.apps/api/src/app/register-routes.tsowns auth precedence and project callback-before-session-auth groups.apps/api/src/app/scheduled.tsowns cron classification and job delegation.Untested Gaps
Worker runtime tests could not execute because
workerdcrashed with signal 11 on two attempts. No staging verification was performed by explicit human constraint.Post-Mortem
N/A: refactor plus behavior-preserving extraction, not a bug fix.
Specialist Review Evidence
/mcppreflight without credential headers.Agent Preflight
Classification
External References
N/A: no external API/library behavior changes. Used SAM MCP
get_instructions, SAM MCPget_idea, local task/audit context, and codebase rules.Codebase Impact Analysis
Affected
apps/apicomposition root, route registration tests, scheduled source-contract tests, and task record. No route module splitting and no API contract changes intended.Documentation & Specs
N/A: internal refactor; task record updated. Public docs are not changed because user-facing behavior should be unchanged.
Constitution & Risk Check
Checked route ordering, auth/CORS behavior, and hardcoded-value risk. No new env vars or config values added. Main risk is Worker-runtime verification gap due
workerdcrash; local API test/type/lint coverage passed.Exceptions
workerd; staging deployment explicitly forbidden by human.