Skip to content

feat(core): app composition and full request handler pipeline#38

Merged
viniciusdacal merged 3 commits intomainfrom
feat/core-phase10-app-composition
Feb 6, 2026
Merged

feat(core): app composition and full request handler pipeline#38
viniciusdacal merged 3 commits intomainfrom
feat/core-phase10-app-composition

Conversation

@viniciusdacal
Copy link
Copy Markdown
Contributor

Summary

  • Implements createApp() builder with .register(), .middlewares(), and .handler getter
  • App runner builds a Trie from registered module routers, runs middleware chain, builds ctx via buildCtx(), handles CORS, error responses
  • Service injection: router inject field resolved at boot time, services available in handler ctx
  • Module options propagated to handler via ctx.options
  • Immutable ctx in development mode via makeImmutable()

Test plan

  • createApp() returns builder with register, middlewares, handler
  • Routes GET request to correct handler, returns JSON
  • Returns 404 for unmatched route
  • Passes parsed params to handler via ctx
  • Parses request body for POST routes
  • Handles VertzException with correct status code
  • Handles unexpected errors with 500
  • Returns 405 with Allow header for wrong method
  • Registers multiple modules and combines routes
  • CORS preflight returns 204
  • Middleware chain runs, contributions available in handler ctx
  • Returns 204 when handler returns undefined
  • Middleware exception short-circuits chain
  • basePath prepended to all routes
  • CORS headers applied to actual responses
  • Injects services into handler ctx via router inject
  • Module options accessible via ctx.options
  • Immutable ctx in development mode
  • 154 tests pass across full suite

🤖 Generated with Claude Code

viniciusdacal and others added 3 commits February 6, 2026 16:10
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…into ctx

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor Author

@viniciusdacal viniciusdacal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Post-PR Review

Overall: Solid integration phase. Wires together all prior phases (trie, middleware, context, CORS, error handling) into a clean request pipeline.

Architecture

  • app-builder.ts — Clean builder pattern with lazy handler construction via getter
  • app-runner.ts — Well-decomposed with resolveServices, resolveMiddlewares, resolveRouterServices, registerRoutes helper functions
  • Uses buildCtx() for immutability and collision detection (addresses pre-PR finding)
  • Service injection resolved at boot time, not per-request

Reviewed

  • Request pipeline: CORS → parse → trie match → body parse → middleware → buildCtx → handler → response
  • Error handling: VertzException → serialized status, unexpected → 500
  • 404/405 distinction with Allow header
  • 204 for void handlers
  • basePath prepended to all routes
  • Module options threaded through to ctx.options
  • Router inject resolved from instantiated service map

No actionable findings

  • The entry as any cast in trie storage is pragmatic — the Trie accepts RouteHandler but we store RouteEntry. This works because the trie never calls the handler directly; the app runner casts it back.
  • env: {} is hardcoded — acceptable for now since env is created eagerly at import time and will be passed through in Phase 12 (public API wiring)

LGTM ✅

@viniciusdacal viniciusdacal merged commit 8c5cf99 into main Feb 6, 2026
@viniciusdacal viniciusdacal deleted the feat/core-phase10-app-composition branch February 6, 2026 19:19
viniciusdacal added a commit that referenced this pull request Feb 22, 2026
* feat(core): app composition with builder pattern and request handler

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(app): use buildCtx for immutability, inject services and options into ctx

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor(app): extract helper functions and deduplicate ModuleRegistration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
viniciusdacal added a commit that referenced this pull request Apr 5, 2026
…raph (#2053)

Phase 2 of runtime feature parity tests:
- SSR: verify SSR-enabled server serves HTML shell for page routes (#34)
- HMR Tier 1: WebSocket update message delivery via hmr_hub.broadcast (#37)
- HMR Tier 1: CSS-only update message (not full-reload) (#38)
- HMR Tier 2: FileWatcher detects entry file changes in tempdir (#39)
- Module graph: transitive dependency invalidation A→B→C (#40)
- Shared helpers: copy_fixture() for tempdir-based watcher tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
viniciusdacal added a commit that referenced this pull request Apr 5, 2026
* test(runtime): add Phase 1 parity tests — infra, HTTP, compilation (#2053)

Phase 1 of runtime feature parity tests:
- Test skeleton: main.rs, common.rs (shared helpers), checklist_meta.rs (report validation)
- HTTP serving tests: API delegation (#5), proxy rules (#6), logging middleware (#7)
- Compilation tests: import.meta.env (#19), CSS→JS (#20), tsconfig paths (#22),
  /@deps endpoint (#23), /@css endpoint (#24), theme CSS injection (#25)
- PARITY_REPORT.md with all 55 included + 12 deferred feature rows
- Test fixtures: env-app, css-app, tsconfig-paths-app, theme-app

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test(runtime): add Phase 2 parity tests — SSR, HMR, watcher, module graph (#2053)

Phase 2 of runtime feature parity tests:
- SSR: verify SSR-enabled server serves HTML shell for page routes (#34)
- HMR Tier 1: WebSocket update message delivery via hmr_hub.broadcast (#37)
- HMR Tier 1: CSS-only update message (not full-reload) (#38)
- HMR Tier 2: FileWatcher detects entry file changes in tempdir (#39)
- Module graph: transitive dependency invalidation A→B→C (#40)
- Shared helpers: copy_fixture() for tempdir-based watcher tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test(runtime): add Phase 3 parity tests — errors, diagnostics, MCP, auto features (#2053)

Phase 3 of runtime feature parity tests:
- Error overlay: client error reporting via POST endpoint (#47)
- Console log: ring buffer endpoint returns stored entries (#50)
- MCP: Streamable HTTP responds to tools/list with 7 registered tools (#51)
- MCP: tool invocation returns diagnostics result (#52)
- MCP: events WebSocket delivers initial server status (#53)
- Auto-install: blacklist/dedup coordination logic (#54)
- Dep watcher: detects file changes in linked package dist/ (#55)

All 22 parity tests passing. Full cargo test --all clean. Clippy clean.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(runtime): address review findings in parity tests (#2053)

- Fix ~25 incorrect EXISTING test location references in PARITY_REPORT.md
  to match actual function names in static_serving.rs, client_render.rs,
  ssr_render.rs, and error_overlay.rs
- Rename misleading ssr_redirect_returns_302_with_location_header to
  ssr_enabled_server_returns_html_shell_for_page_routes (test asserts 200,
  not 302)
- Add import.meta.env.SECRET_KEY reference to env-app fixture so the
  non-public env var assertion actually validates the code path

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant