Corrected agent confabulations
This commit is contained in:
19
CLAUDE.md
19
CLAUDE.md
@@ -110,13 +110,13 @@ Format: comma-separated contexts, semicolon-separated URL-encoded params per con
|
||||
|
||||
### 3. Frontend-Agnostic Rendering (SSR + PSR)
|
||||
|
||||
**SSR** — Django template backend integration. `render(request, 'ProfilePage', props)` calls a persistent Bun subprocess that runs `renderToString`.
|
||||
**SSR** — Django template backend integration. `render(request, 'components/Hello.tsx', props)` — the template name is a `.tsx`/`.jsx` **file path** (resolved against `DIRS`), not a component name — calls a persistent Bun subprocess that runs `renderToString`.
|
||||
|
||||
**PSR** (Preemptive Static Rendering) — pages re-rendered on mutation, not on request. Edge caches the result. Controlled by the manifest's `render_strategy` field.
|
||||
|
||||
**The Bun worker protocol** — JSON-RPC over stdin/stdout:
|
||||
**The Bun worker protocol** — JSON-RPC over stdin/stdout. The worker `import()`s the file and renders it (no component registry):
|
||||
```
|
||||
→ {"id": 1, "method": "render", "params": {"component": "ProfilePage", "props": {"userId": 5}}}
|
||||
→ {"id": 1, "method": "render", "params": {"file": "/abs/path/Hello.tsx", "props": {"name": "World"}}}
|
||||
← {"id": 1, "html": "<div>...</div>"}
|
||||
```
|
||||
|
||||
@@ -356,8 +356,9 @@ Three independent secrets, each with its own blast radius:
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'mizan.ssr.MizanTemplates',
|
||||
'DIRS': [BASE_DIR / 'frontend'],
|
||||
'OPTIONS': {
|
||||
'worker_path': 'frontend/ssr-worker.tsx',
|
||||
'worker': 'path/to/mizan-ssr/src/worker.tsx',
|
||||
'timeout': 5,
|
||||
},
|
||||
},
|
||||
@@ -371,14 +372,14 @@ from django.shortcuts import render
|
||||
|
||||
def profile_page(request, user_id):
|
||||
profile = get_user_profile(user_id)
|
||||
return render(request, 'ProfilePage', {'profile': profile})
|
||||
return render(request, 'components/Profile.tsx', {'profile': profile})
|
||||
```
|
||||
|
||||
`render()` calls `MizanTemplates.get_template('ProfilePage')` which returns a `MizanTemplate`. The template's `render(context)` sends JSON-RPC to the Bun worker.
|
||||
`render()` calls `MizanTemplates.get_template('components/Profile.tsx')` — the name is a file path resolved to an absolute path against `DIRS` — which returns a `MizanTemplate`. The template's `render(context)` sends JSON-RPC (`{file, props}`) to the Bun worker.
|
||||
|
||||
### SSR Bridge (bridge.py)
|
||||
|
||||
- Spawns `bun run <worker_path>` on first render
|
||||
- Spawns `bun run <worker>` on first render
|
||||
- Persistent subprocess — stays alive across requests
|
||||
- JSON-RPC over stdin/stdout with message ID correlation
|
||||
- Thread-safe: multiple Django workers can call `render()` concurrently
|
||||
@@ -388,8 +389,8 @@ def profile_page(request, user_id):
|
||||
### Bun Worker (worker.tsx)
|
||||
|
||||
- Reads newline-delimited JSON from stdin
|
||||
- Component registry: `registerComponent('ProfilePage', ProfilePage)`
|
||||
- Calls `renderToString(createElement(Component, props))`
|
||||
- Resolves the component by **file path** — `import(file)` (cached) — no registry
|
||||
- Calls `renderToString(createElement(Component, props))` on the imported default export
|
||||
- Returns `{"id": N, "html": "..."}` or `{"id": N, "error": "..."}`
|
||||
- Health check: `{"method": "ping"}` → `{"pong": true}`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user