jsdoc typing round, phases 3-4: the clerk (tool/memory.mjs) and the SPA (web/) typed under strict -- row shapes local to their owners (the clerk's five tables in its header; the SPA's response envelopes in the new web/shapes.mjs, the server's shared shapes imported at their use sites: User, LogEvent, JobState, HttpError); the db boundary cast at every .get()/.all(), fail as @returns {never} so guard-narrowing works; web via a second tsconfig (tsconfig.web.json: DOM libs in their own program, node types riding along because shapes.mjs's Provider typedef pulls provider.mjs in), npm run typecheck runs both; every non-annotation delta audited onto a small intended list (COUNT(*) Number() wraps, impossible-path guards, ?? ''/?? undefined null-absorbers, the RewordOp reason fix -- the validator demands it, the reminder-find naming its tag); smoke 110/110 + restart + reminder + repo checks + a zero-console-error browser pass green; the typing round is complete

This commit is contained in:
2026-11-15 19:57:07 +00:00
parent f81b188ce1
commit 8d4a6b91df
22 changed files with 567 additions and 227 deletions
+48 -19
View File
@@ -9,18 +9,55 @@ file is the "where did we leave off" map.
## Where we are
- **The server core is JSDoc-typed, strict, green (2026-11-15,
evening) -- committed.** tsc runs as a
no-emit checker (`npm run typecheck`) over plain `.mjs` with JSDoc
annotations; the shared shapes live in `server/shapes.mjs` (log
events as a tagged union, wire messages, manifests, job state,
the Ctx). Dev tooling only: `typescript` + `@types/node` in
- **The typing round is COMPLETE: all four phases (2026-11-15).**
Phases 1-2 (the server core) are committed (`f81b188`); phases 3
(the clerk) and 4 (web/) are done the same sitting and land with
this commit. tsc runs as a no-emit checker (`npm run typecheck`) over
plain `.mjs` with JSDoc annotations; the shared shapes live in
`server/shapes.mjs` (log events as a tagged union, wire messages,
manifests, job state, the Ctx), the db row shapes live local to
their owners (the clerk's five tables typed in tool/memory.mjs's
header, like users.mjs's rows), and the SPA's response envelopes
live in `web/shapes.mjs` with the server's shared shapes (User,
LogEvent, JobState) imported from server/shapes.mjs at their use
sites. Dev tooling only: `typescript` + `@types/node` in
devDependencies, `node_modules/` gitignored -- the runtime stays
zero-dependency (QUESTIONS #4 amended to say so). Verified: the
full diff audited change-by-change (every non-annotation delta is
an impossible-path guard or a behavior-identical wrap), smoke
105/105, restart-check, check-repo, all green. Phases to come are
steps 5 and 6 below.
zero-dependency (QUESTIONS #4 amended to say so).
- The clerk round: every `.get()`/`.all()` cast at the db
boundary, `fail` annotated `@returns {never}` so guard-narrowing
works, tsconfig's include widened to `tool/`. Non-annotation
deltas, all of them: Number() wraps around COUNT(*) reads, two
impossible-path guards (apply's session, the runs-list fill),
`?? ''` where a possibly undefined cmd indexes the phase rules /
run-less set, and the RewordOp shape fix (reason required -- the
validator demands it; no server code constructs reword ops).
- The web round: a SECOND tsconfig (`tsconfig.web.json`) -- DOM
libs in their own program, keeping the server program free of
DOM/node global collisions; the typecheck script runs both.
`node` types ride along in the web config because
server/shapes.mjs's Provider typedef pulls provider.mjs into
the web program. `$`/`el` typed at the DOM boundary
(HTMLElement; typed-element casts at input/dialog/select use
sites), timers as `?ReturnType<typeof setTimeout>`. The full
diff audited; the non-annotation deltas, all of them: the
transcript's reminder-find gains `x.t === 'msg' &&` (reminder
lives only on msg events), `clearTimeout(x ?? undefined)` on
the three null-initialized timers (null and undefined are both
no-ops), `!!()`-wraps on the two `mine` booleans (null vs
false, used only truthily), five impossible-path guards (the
router's named-view, the play/setup/story enter run-ids,
setup's signed-in owner check, saveDirty's currentFile), the
setup `files` local initialized `{}` instead of null (never
read before enter), and view-new caching the create-pc lookup
in one local (same element, same accesses).
- Verified, both rounds: typecheck green (both programs), smoke
110/110, restart-check on a genuine restart, check-reminder
(aimed at the fork lineage -- the source run's newest logged
session is the near-empty session 4), check-repo, and a full
browser pass over the SPA (claim, home + admin, play incl. a
live turn + pane edits, story, the setup editor incl. dirty
markers + draft stash, new-run incl. the name roll) with zero
console errors; test state cleaned.
- **Everything is built, proven, and committed (through `d737e47`,
2026-11-15).** The full scope, each round mock-proven end to end
@@ -89,14 +126,6 @@ file is the "where did we leave off" map.
candidates), coin-flip personality (choices offloaded to chance
that should be character), and whether her variants stay same-turn
alternatives rather than sequences.
5. **Typing phase 3: the clerk** (`tool/memory.mjs`, the big one).
The db row shapes (entries, records, status, agenda, the events
journal), the CLI dispatch, the manifest validator -- typed at the
db boundary per the same doctrine, then widen tsconfig's include
to `tool/`.
6. **Typing phase 4: web/** -- DOM types for the SPA modules
(`"lib": ["DOM"]` or a second tsconfig), the same shared shapes
imported from server/shapes.mjs where the wire surfaces appear.
## Not yet exercised (expect first-use friction)