Restore documentation layer — match current substrate
ROADMAP: done items moved out of "Next" (codegen rewrite, SSR bridge, edge manifest, X-Mizan-Invalidate, return-type branching, affects_params, kernel extraction, two-stage codegen, mizan-ts). Real "Next" in: framework-adapter wrapper layer (MizanContext + useMizan + DjangoError on top of the kernel) for React/Vue/Svelte; A1–A4 from ISSUES.md. CLAUDE: 4-package layout replaced with the actual 7-package layered architecture (backend protocol adapters + frontend kernel + framework adapters + SSR worker). "STALE codegen" section rewritten to describe what's emitted vs. the wrapper layer that isn't yet. docs/ now tracked (6 files). AFI_ARCHITECTURE rewritten — replaced the speculative `mizan-ast`/`mizan-csr`/`mizan-rpc`/`mizan-schema` package names with the real layout, dropped KDL-schema language for the actual schema-export format. The other 5 docs/ files were already current and are tracked as-is. ARCHITECTURE-REWORK.md deleted — same expert review is re-tracked in the fresher ISSUES.md, two parallel trackers was sediment. README.md deleted — drift was beyond surgical fixes (`mizan_clients.py` convention, `<DjangoContext>` provider, removed `@compose` and `context='local'`, wrong codegen output filenames, 3-package structure vs. 7). Rewrite waits for the wrapper-layer codegen to land so user-facing examples reflect reality. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
46
CLAUDE.md
46
CLAUDE.md
@@ -10,13 +10,23 @@ Django + React ships first. The protocol is language-agnostic (proven by mizan-t
|
||||
|
||||
## Package Layout
|
||||
|
||||
```
|
||||
packages/
|
||||
mizan-django/ Python backend adapter (323+ tests)
|
||||
mizan-react/ React frontend adapter (33 tests)
|
||||
mizan-ts/ TypeScript backend adapter (22+ tests, proves AFI)
|
||||
mizan-ssr/ Bun SSR worker subprocess
|
||||
```
|
||||
Two layers per side. Per-framework adapters wrap a single shared kernel; codegen targets the adapter.
|
||||
|
||||
**Backend protocol adapters** — implement the wire protocol on a server stack:
|
||||
|
||||
- `mizan-django/` — Django adapter
|
||||
- `mizan-ts/` — TypeScript adapter (proves the protocol is language-agnostic)
|
||||
|
||||
**Frontend kernel + framework adapters** — kernel is the imperative client primitive set; each framework adapter wraps the kernel in its own idiomatic constructs:
|
||||
|
||||
- `mizan-runtime/` — framework-agnostic kernel; owns data, status, error; adapters subscribe
|
||||
- `mizan-react/` — React contexts + hooks over the kernel
|
||||
- `mizan-vue/` — Vue composables over the kernel
|
||||
- `mizan-svelte/` — Svelte stores/runes over the kernel
|
||||
|
||||
**SSR worker:**
|
||||
|
||||
- `mizan-ssr/` — Bun subprocess used by the Django template backend
|
||||
|
||||
---
|
||||
|
||||
@@ -432,8 +442,24 @@ urlpatterns = [
|
||||
|
||||
---
|
||||
|
||||
## What the Codegen Currently Produces (STALE)
|
||||
## Codegen — Current State
|
||||
|
||||
The codegen in `mizan-django/generate/` still produces the **old pattern** that wraps `MizanProvider`. This needs rewriting to use the runtime (`mizanFetch`/`mizanCall`/`registerContext`) directly. See the `mizan-react/src/runtime/index.ts` for the target API.
|
||||
The codegen is two-stage and per-framework. Stage 1 (in `mizan-django/generate/`) emits the framework-agnostic protocol layer (`callXxx` for mutations, `fetchXxx` for context bundles, types). Stage 2 emits per-framework hooks/composables/stores that subscribe to the `mizan-runtime` kernel.
|
||||
|
||||
The SSR pipeline works independently of the codegen — it renders whatever components are registered in the Bun worker. The codegen gap only affects the client-side hooks and context providers.
|
||||
**What's in place:**
|
||||
|
||||
- Function hooks (`useEcho`, `useUserProfile`, etc.) in the React adapter, subscribing to kernel state via `useSyncExternalStore`
|
||||
- Context hooks for named contexts and `global`
|
||||
- Channel hooks for WebSocket transport
|
||||
- Vue and Svelte equivalents (Stage 2 templates compile, but no live-backend example exercises them — see `ISSUES.md` A4)
|
||||
|
||||
**What's not yet emitted (the wrapper layer):**
|
||||
|
||||
- `<MizanContext>` provider component for React (calls `configure()` and mounts the kernel into the component tree)
|
||||
- `useMizan()` hook for accessing the kernel from React
|
||||
- Framework-named error class (e.g. `DjangoError`) wrapping `MizanError` from the kernel
|
||||
- Vue and Svelte equivalents
|
||||
|
||||
The legacy `MizanProvider` in `mizan-react/src/context.tsx` (~750 lines) and the `forms.ts` consumer (~1163 lines) still depend on the pre-kernel API. They're tracked as `ISSUES.md` A1 and A3. Removing them is gated on the wrapper layer above being emitted.
|
||||
|
||||
The SSR pipeline is independent of the codegen — it renders whatever components are registered in the Bun worker.
|
||||
|
||||
Reference in New Issue
Block a user