1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# Namespace-backed sites: implementation and validation
## Design
One 9web process supervises builds and posts a pure service as `9web` in the
normal per-user 9P registry. A separate host-only export consumes its composed
namespace through 9ns. Website HTTP, Files, catalogue metadata and controls use
the same 9P mux. The host export is never posted back into itself.
Plan 9 references reviewed locally in Principia Softwarica: `srv(3)`,
`namespace(6)`, `mntgen(4)`, `exportfs(4)`, and `httpd(8)` (namespace webroot and
internal URL mappings). A conversational critique review caught public-file
reopening across publication and two HTML prefix parsing edge cases; all have
regression tests. Explicit recipe configuration remains policy, not a
self-registration protocol. Unix listener posting is a Linux adaptation of
channel publication, not identical `/srv` semantics.
## Deployment
- Enabled user unit `9web.service`, wrapped with `9ns --mntgen`.
- Sole HTTP listener `[::]:8090`, reachable using LAN IPv4 and IPv6.
- Existing 8091–8095 site listeners removed from configuration; miniserve untouched.
- Whole `/`, including `/mnt/9p`, retained in Files; pure service at `/mnt/9p/9web`.
- URLs `/sites/{entomology,cafe,standards,pardes,cafe-hub}/`.
- Preview generations under `~/.local/state/9web/public/`; normal output unchanged
by prefix packaging. Initial publication reused existing builds.
- `--url-prefix` is optional in project build commands and never enabled by
default. The service explicitly supplies it for builds and managed watch.
- Optional compatibility site port is represented as `?u16 = null`, not zero.
- Configuration backup: `~/.config/9web/sites.before-namespace.json`.
The helper `9web-prefix` is installed by `zig build` and locally at
`~/.local/bin/9web-prefix`. It relocates generated HTML/CSS only. JavaScript,
JSON, authored content and source URLs are unchanged. The archive stays
read-only in the service. Old preview generations are retained, not garbage
collected. Same-origin site scripts are trusted operator code, not isolated
from writable files or build controls. Cloudflare APIs are not implemented.
## Companion build commits
| Project | Commit | Scope |
|---|---|---|
| Entomology lab | `da9d227` | Optional prefix/output/reuse flags in existing builder |
| Standards | `4ad43a0` | Same optional build flags |
| 0x4200.cafe | `2d47b2b` | Optional flags in build/build.sh; default/watch preserved |
| Pardes website | `a1da335` | Build entry point with optional prefix packaging |
| Café hub archive | `3e07a67` | Optional static archive build/packaging entry point |
Existing unrelated project edits were not committed. No remote push.
## Checks
`zig build -Doptimize=ReleaseSafe catalog-test host-fs-test http-fs-test
catalog-ui-test mux-test prefix-test` passes. Coverage includes:
- Index/pretty URLs, redirects with query preservation, MIME, HEAD and byte ranges.
- Identical website bytes through namespace/9P and HTTP; traversal rejection.
- Pinned public file reads when a new generation replaces its pathname.
- Scoped HTML/CSS prefixing, CSS selectors, entities, srcset/data URLs, unchanged
scripts/code examples/external URLs and normal-output hashes.
- Atomic publication, stale-asset exclusion and preservation on failure.
- Whole-host operations and mounted 9P controls, large directories, blocking
events and repeated flush/clunk without reader exhaustion.
- Existing Files/Sites/Services shell, mobile layout, editing and history.
Live Chromium validation (`NINE_WEB_LIVE=http://127.0.0.1:8090 node
test/web/catalog_ui.mjs zig-out/bin/9web`) also passes: `/mnt/9p/9web`, agents,
zmx, `/usr/bin`, all five site landing pages, 22 same-origin images across
Entomology and the café, and café blog/pretty article navigation. LAN IPv4 and
IPv6 site requests return 200. An actual café build requested through
`/fs/mnt/9p/9web/sites/cafe/ctl` completed with exit code 0 and published a new
prefixed generation; no preview daemon was started.
`zig build -Doptimize=ReleaseSafe e2e` passes all 32 original gateway scenarios.
## Parallel-read follow-up
A final cold browser run exposed an intermittent load failure despite earlier
successful runs. Sixteen concurrent large-asset requests reproduced HTTP 502s:
independent host-read completions could overfill the runner's bounded 9P output
queue. The synchronous dispatch path already checked output space, but these
asynchronous completions bypassed it.
`Runner.Conn.replyAsync` now waits on an output-space condition, reserving one
additional full frame for an already-dispatched synchronous handler. It waits
without the catalogue mutex, remains cancellable, and is joined before slot
reuse. HTTP streaming now aborts an upstream read error instead of ending a
truncated response successfully.
`test/web/parallel_reads.mjs` checks 80 exact multi-frame responses with 16
simultaneous readers, 40 interrupted downloads and mixed HEAD requests. It is
part of the mounted-host browser fixture and can also be run read-only against
the live café:
```
node test/web/parallel_reads.mjs http://127.0.0.1:8090/sites/cafe/ \
/home/goblin/.local/state/9web/public/cafe
```
The deployed service passes this load test against 37 café source files, followed
by the complete live browser traversal again. Protocol/unit, catalogue, mounted
host, HTTP FS, mux, UI and original 32-scenario E2E checks pass after the fix.
|