open-design/specs/current
Golden Obsidian LLC aa0616062d
refactor(daemon): introduce HTTP Request Adapter + typed Deps (#2636)
* refactor(daemon): introduce HTTP Request Adapter + typed Deps (proof on active-context-routes)

Adds a typed HTTP boundary Adapter under apps/daemon/src/http/ that replaces
the untyped ServerContext service-locator pattern (30+ fields, mostly any)
for route handlers. Routes become pure (input, deps) -> Result<output>
functions, unit-testable without Express or supertest.

Six new modules under apps/daemon/src/http/:
  - types.ts        Result<T,E>, ok(), err(), JsonRouteSpec, Handler,
                    RouteInputContext, HttpMethod, InputParser
  - parse.ts        rawInput(req), validationError(message, issues?)
  - response.ts     sendJson(), sendApiError(), statusForError() +
                    ERROR_STATUS_BY_CODE map
  - origin-guard.ts guardSameOrigin(req, origin) wrapping isLocalSameOrigin
                    as a Result
  - adapter.ts      defineJsonRoute(), mountJsonRoute() (only place that
                    knows about req/res)
  - index.ts        barrel

active-context-routes.ts migrated as proof of pattern. parsePostActive(),
handlePostActive(), handleGetActive() are now pure functions; postActiveRoute
and getActiveRoute are exported route specs. The wire signature
registerActiveContextRoutes(app, ctx) is preserved so server.ts is untouched.

Spec at specs/current/daemon-http-adapter.md captures the strangler migration
order for the remaining route files (mcp-routes, chat-routes, artifact
routes, etc.) and a StreamRoute follow-up where the Run Orchestrator lands.

Wire-format note: cross-origin response moves from the legacy
{ error: 'cross-origin request rejected' } shape to the structured
{ error: { code: 'FORBIDDEN', message: ... } } shape. Backwards-compatible
via the existing CompatibleErrorResponse = ApiErrorResponse | LegacyErrorResponse
union in @open-design/contracts.

Validation:
  - pnpm install (post-rebase, exit 0)
  - pnpm --filter @open-design/daemon typecheck (both tsconfig.json and
    tsconfig.tests.json silent => pass)
  - pnpm --filter @open-design/daemon test: 15 new tests pass
    (tests/http/adapter.test.ts + tests/active-context-routes.test.ts).
    84 pre-existing failures across 23 files are unchanged and unrelated
    to this PR (Windows symlink / short-name / colon-in-filename, upstream
    behavior drift, missing plugin marketplace fixtures, and a freshly-
    added tools-connectors-cli suite of 38 failures that landed during
    the rebase).

Sharpens W4/W5 of specs/current/maintainability-roadmap.md and unlocks
W6 (Run Orchestrator).

* chore: add core-js, electron-winstaller, protobufjs, sharp to pnpm.onlyBuiltDependencies
2026-05-22 15:20:15 +08:00
..
architecture-boundaries.md Add shared contracts and migrate project code to TypeScript (#118) 2026-04-30 13:01:15 +08:00
automation-self-evolution.md [codex] Add automation templates and proposal workflows (#2193) 2026-05-19 16:35:28 +08:00
critique-theater-plan.md docs: fix - update prompts path from web to daemon in README files (#756) 2026-05-09 15:23:23 +08:00
critique-theater.md docs: fix - update prompts path from web to daemon in README files (#756) 2026-05-09 15:23:23 +08:00
daemon-http-adapter.md refactor(daemon): introduce HTTP Request Adapter + typed Deps (#2636) 2026-05-22 15:20:15 +08:00
design-system-import-project.md Add design system package quality guard (#2224) 2026-05-19 16:53:29 +08:00
maintainability-roadmap.md fix(daemon): typecheck core server paths (#952) 2026-05-08 20:43:51 +08:00
manual-edit-mode-requirements.md Implement manual edit mode (#620) 2026-05-06 16:13:52 +08:00
plugin-authoring-flow-plan.md feat(daemon, web): implement plugin folder installation and enhance atom worker registry 2026-05-12 21:38:45 +08:00
plugin-driven-flow-plan.md feat(daemon, web): implement plugin folder installation and enhance atom worker registry 2026-05-12 21:38:45 +08:00
plugin-registry-strategy-plan.md feat(plugins): add registry protocol and enhance plugin management features 2026-05-14 08:55:36 +08:00
research-feature.md feat: agent-callable research command and /search (#615) 2026-05-08 10:33:44 +08:00
run.md Fix chat runs surviving web disconnects (#146) 2026-04-30 20:16:46 +08:00
runtime-adapter.md feat[qoder cli] add Qoder CLI agent support (#626) 2026-05-06 19:54:03 +08:00
skills-and-design-templates.md feat: generic skills + split skills/design-templates + finalize-design API (#955) 2026-05-11 17:48:34 +08:00
status.md Fix chat runs surviving web disconnects (#146) 2026-04-30 20:16:46 +08:00