5.2 KiB
5.2 KiB
TASK METADATA
- Target Files:
src/core/,src/features/,src/shared/,src/tests/arch/,server/(legacy),ui/(legacy). Note:sdk/andspire_ffi/must remain independent top-level root modules. - Core Objective: Execute a multi-phase, non-overlapping architectural transition to a Datastar-driven Hypermedia paradigm and Vertical Feature Slicing.
- Dependencies:
docs/HYPERMEDIA_ARCHITECTURE_BLUEPRINT.md,AGENTS.md. - Additional Important Notes: The code does not need to maintain
backwards-compatible bridges for legacy vanilla scripts during intermediate
phases; optimize for a clean, uncompromised vertical slice architecture in
src/.
Architectural Considerations & Risks
- Risks:
- Moving from a separated
server/andui/structure to co-locatedsrc/features/will require extensive routing and import refactoring. - Dropping legacy imperative DOM scripts in favor of Datastar requires strict
adherence to
data-ignorefor WebAuthn micro-scripts so the DOM diffing engine doesn't wipe critical ceremony state. - Converting SSE streams to the typed adapter (
core/sse_adapter.ts) might break existing real-time UI components if payload formats are mismatched.
- Moving from a separated
- Alternatives:
- Instead of moving to
src/, we could restructure withinserver/. However, adoptingsrc/features/enforces a clean break from the legacy horizontally sliced architecture and clearly demarcates the new vertical hypermedia standard.
- Instead of moving to
Proposed Implementation
Phase 1: Core Foundation, Tooling & Safety Guards
Establish the authoritative infrastructure, transport toolkit, and invariant
guards inside src/core/.
- Create
src/core/directory. - Migrate and adapt foundational integrations from
server/(strictly read-only reference):db.ts: PostgreSQL connection pool and queries.valkey.ts: Valkey connection and Pub/Sub broker.spire_ffi.ts: Rust SPIFFE/mTLS FFI bindings.
- Implement
auth_guards.ts(enforcing max 16KB payload cap, rate limiting, and CSRF/Origin checks). - Implement
content_negotiation.tsto route between Datastar HTML, CLI/JSON clients, and shell strings. - Implement
sse_adapter.tsfor typed Datastar SSE streaming helper logic. - Implement
error_fragments.tsxfor standardized error toast and field-error JSX morph fragments. - Setup
src/main.tswithserveStaticfor/public/datastar-v1.x.js. - Add
deno task lint:archinscripts/lint_arch.ts(blockingdocument.getElementByIdand unescaped HTML) and integrate intodeno.json.
Phase 2: Base Vertical Slices & Shared UI
Migrate domain-agnostic presentation atoms and standard CRUD-style feature slices.
- Create
src/shared/ui/with distinctive fragment names (LayoutFragment,NavbarFragment,ToastFragment,DrawerShellFragment,PillGroupFragment,AccordionFragment). - Create
src/features/auth/and migrate/login,/register, and/recovery. Extract WebAuthn ceremony scripts intowebauthn.tswith explicitdata-ignoreattributes. - Create
src/features/admin/and migrate admin routes, SQL queries, and fragments (AdminUserTableFragment,AdminAppCardFragment,RoleModalFragment). - Add pure JSX unit tests:
auth.test.tsandadmin.test.ts.
Phase 3: Real-Time Slices & Script Elimination
Migrate complex, interactive features and eliminate legacy imperative scripts in favor of targeted SSE and Datastar morphs.
- Create
src/features/events/:- Migrate event routing, queries, and JSX fragments
(
EventCockpitDeckFragment,WorkshopPassDrawerFragment,GuestDrawerAttendeesFragment). - Implement
stream.tsusingsrc/core/sse_adapter.tsfor live seat counters bound to Valkey Pub/Sub.
- Migrate event routing, queries, and JSX fragments
(
- Create
src/features/sessions/:- Migrate routing, queries, and fragments (
SessionTableFragment,SessionHandoffCardFragment,DirectPassDrawerFragment). - Eliminate legacy
SessionsScript.tsxcompletely, replacing interactive flows with Datastar reactive attributes (data-on-click,data-patch).
- Migrate routing, queries, and fragments (
- Add pure JSX unit tests:
events.test.tsandsessions.test.ts.
Phase 4: Persistent Architectural Test Suite
Implement the invariant test harness defined in the blueprint to prevent regression.
- Create
src/tests/arch/. - Implement
transport_efficiency.test.ts(asserts routine mutations returntext/htmlin <2ms). - Implement
sse_lifecycle.test.ts(asserts connection limits, draining, and memory stability for 100+ concurrent live listeners). - Implement
proxy_buffering.test.ts(assertsX-Accel-Buffering: nois emitted). - Implement
error_fragment.test.ts(asserts 4xx/5xx responses yield valid JSX morph fragments for#status-banner). - Implement
content_negotiation.test.ts(asserts proper dual-mode REST vs Datastar handling) andxss_fuzzing.test.ts(fuzzes fragment rendering).
Phase 5: Legacy Deprecation & Final Cleanup
Execute cleanup only after Phase 4 architectural tests and existing test suites pass 100%.
- Safely delete legacy
server/andui/directories. - Perform dead-code cleanup and dependency verification.
- Verify all gates:
deno fmt,deno task lint,deno task check, anddeno test -A --no-check.