diff --git a/FABRIC.md b/FABRIC.md index 31943b3..a76e459 100644 --- a/FABRIC.md +++ b/FABRIC.md @@ -4980,15 +4980,159 @@ document and committing that amendment as its own item.* *and keyboard work above. 4.5 (renumbered from 4.4, 2026-08-11) is unaffected by anything* *added above this marker.)* -- [ ] **4.4 — REPL.** *(Scoped 2026-08-11; independent of the 4.3.x framebuffer/keyboard work.* - *This item replaces `docs/lithosananke/ROADMAP.md`'s M8 section entirely — M8 is marked* - *OBSOLETE there as of 2026-08-11, kept for history only. Detailed spec and punch-list* - *sub-items to be written up in the same style as 4.3.x.)* - *Refs:* §25.5, §27.6. +- [ ] **4.4 — Design-only: lock the prompt format and color values.** No code. Write down the + exact target string — `[VM name] ok>` for now, `(user)` added later per 4.4n — and the exact + color values for the bracketed VM name and for `ok>` against + [`repl-mockup.png`](repl-mockup.png). Captain Bob's spoken values (orange, cyan) were both + qualified as tentative/uncertain — this item is where they become specific RGB or ANSI SGR + index values, or are confirmed as still-approximate and revisited later. + *Done when:* a literal prompt string and two specific color values are written into this + document, referencing the mockup. + *Refs:* §25.5, §27.8. - Original visual mockup (Captain Bob, 2026-08-11): [`repl-mockup.png`](repl-mockup.png) — - CANVAS label, scrollable output region, separate REPL input strip with cursor at the - bottom. Source image for the CANVAS/REPL-strip geometry described below. +- [ ] **4.4a — Build `[VM name]` bracket text in the prompt, monochrome.** Replace the two + existing, mutually inconsistent VM-identity conventions — `console.c`'s per-line `[Name]` + prefix (`console_set_vm_name()`/`g_active_vm_name`, unaffected/out of scope for non-prompt + lines) and `repl.c`'s prompt-suffix `)ok>` (`sk_repl_run()`/`sk_repl_step()`) — with + `[VM name] ok>`, no color yet (4.4c). VM attach itself needs no new work: `USE` + (`mama_forth_words.c:1108`) already sets both `g_repl_active_vm` and `console_set_vm_name()` + — this item is a *display* change only. + *Done when:* all three architectures boot to a bracketed `[Hera] ok>` prompt (replacing + today's separate `[Hera]`-per-line-prefix + bare `ok>`); `USE`-driven attach to another VM + shows `[Hermes] ok>` (etc.), replacing today's `Hermes)ok>` suffix; the serial-injection + acceptance harness (greps for `ok>`) still matches; three-arch QEMU boot + logs per + CLAUDE.md. + *Refs:* §27.8. + +- [ ] **4.4b — Resolve: does prompt color depend on 4.4e?** Investigation, not implementation. + Read the REPL's actual output path (`console_puts()` → ... → `vt100_putc()` → + `draw_cursor_glyph()`, all currently `font_8x16.c`) to determine whether a single + hardcoded-color prompt segment can call `TTF-TEXT` directly, independent of the general + ANSI/SGR retarget (4.4e), or whether all REPL output — prompt included — shares one + rendering pipeline that requires 4.4e to land first before *any* TTF output reaches the + screen. + *Done when:* the dependency question is answered in writing here, based on reading the + actual call chain, not assumed. + *Refs:* §27.8. + +- [ ] **4.4c — Apply color to the prompt.** Per 4.4b's finding: either an independent + `TTF-TEXT` call with the color from 4.4, or gated on 4.4e completing first. + *Done when:* three-arch screendump shows `[VM name]` and `ok>` in the colors locked at 4.4; + three-arch QEMU boot + logs per CLAUDE.md. + *Refs:* §27.8. + +- [ ] **4.4d — Verify the VT100 CSI/SGR parser's glyph-draw call site is cleanly separable.** + Verification only, no code change. `vt100.c`'s CSI/SGR state machine (escape parsing, cursor + tracking, 16/256-color SGR) calls `draw_cursor_glyph()` from a single site in `put_char()` — + confirm nothing else in the parser depends on `font_8x16.c`-specific assumptions. + **Specifically check:** the cursor/cell-grid model (`g_vt.cols`/`g_vt.rows`/`cell_h()`) + assumes fixed-width character cells; `TTF-TEXT` uses real per-glyph `hmtx` advance widths + (proportional in general). The chosen v1 font, `JetBrainsMono-Regular.ttf` (§27.7), is + nominally monospace, so advance widths *should* be uniform and tile into the existing + fixed-cell grid — but this item confirms that by reading the font's actual `hmtx` table for + the glyphs in use, not by assuming "monospace" in the filename guarantees it. + *Done when:* the call-site separation is confirmed clean, and the advance-width/cell-grid + compatibility question is answered from the actual font data, in writing here. + *Refs:* §27.8. + +- [ ] **4.4e — Retarget the glyph-draw call site from `font_8x16.c` to `TTF-TEXT`.** Depends + on 4.4d. **Boundary, corrected 2026-08-11:** `font_8x16.c`/VT100 keeps rendering everything + through and including **POST** (the parity/dictionary-hash self-test) — not just the + pre-bootstrap M1–M6 messages originally scoped here. POST runs *after* the capsule/VM system + is up (it hashes the loaded Mama capsule dictionary, per CLAUDE.md), so "before the capsule + bootstrap" was the wrong boundary; "through POST" is later and is what Captain Bob confirmed. + `TTF-TEXT` takes over only once POST completes and the interactive REPL itself starts — per + Captain Bob 2026-08-11, TrueType is the primary path for anything a user is actively working + with; the stroke font (`TEXT`) is reserved for later retro/game-styled work, not this item. + *Done when:* REPL output and CANVAS scroll-box text render via `TTF-TEXT`; all boot-time and + POST messages are unaffected (still `font_8x16.c`/VT100); three-arch QEMU boot + logs per + CLAUDE.md. + *Refs:* §27.8. + + > **Correction, recorded here rather than silently repeated:** §27.7 decision #4 + > (2026-08-09) and Captain Bob's 2026-08-11 restatement both list "early boot" as a + > stroke-font use case. That's imprecise — the stroke font is capsule-based + > (`fabric.4th`) and is exactly as unavailable before the VM/capsule bootstrap as + > TrueType is, per §27.6's own reasoning ("font_8x16.c stays, structurally, not by + > preference"). The actual early-boot/POST fallback is `font_8x16.c` specifically, not "the + > stroke font" generically. + +- [ ] **4.4f — Live-verify ANSI color end-to-end.** Depends on 4.4e. Inject an SGR color + escape sequence (`ESC[3xm`/`ESC[9xm`/256-color) over serial and confirm it visibly changes + `TTF-TEXT`-rendered glyph color in a screendump — the parser and the retargeted draw call + working together, not just each existing independently. + *Done when:* screendump evidence of a color change from an injected SGR sequence, on all + three architectures; three-arch QEMU boot + logs per CLAUDE.md. + *Refs:* §27.8. + +- [ ] **4.4g — Confirm actual booted framebuffer resolution, all three architectures.** + Investigation only. amd64 already confirmed this session: 1280×800 (QEMU/OVMF GOP default, + read directly off the 2026-08-11 verification screendump). aarch64/riscv64 unconfirmed. + *Done when:* resolutions for all three architectures are recorded here from real + screendumps or boot logs, not assumed. + *Refs:* §27.8. + +- [ ] **4.4h — Decide REPL-strip pixel height.** Currently undefined anywhere in this document + or the code. Once 4.4e lands, REPL text renders via `TTF-TEXT` at some chosen point/pixel + size (also not yet chosen) — strip height derives from that size's line height plus padding, + not from `font_8x16.c`'s fixed 8×16 cell. + *Done when:* a REPL text size (px) and a resulting strip height (px) are both decided and + recorded here. + *Refs:* §27.8. + +- [ ] **4.4i — CANVAS rectangle definition, per architecture.** Screen height (4.4g) minus REPL + strip height (4.4h) minus the small fixed gap (exact pixel value chosen here) between CANVAS + and the strip. + *Done when:* a CANVAS rectangle (top-left, width, height) is computed and recorded for each + architecture. + *Refs:* §27.8. + +- [ ] **4.4j — 640×480 scroll-box centering math within CANVAS.** Layout math computed on top + of `TTF-TEXT`'s own coordinate primitive, which is simpler and already fixed: Cartesian, + origin at the bottom-left of the **physical framebuffer** (not CANVAS-relative — resolved + and implemented ahead of this item, 2026-08-11, `ttf_words.c`'s `baseline_y = fb_height() - + y`, verified by amd64 screendump). This item translates 4.4i's CANVAS-relative rectangle + into that same physical-framebuffer space. + **Open, blocking question, not assumed:** if any architecture's CANVAS height (4.4i) is + smaller than 480, this item cannot center the box as specified and must stop and report per + §25.0 rule 5, not silently shrink it. + *Done when:* box top-left coordinates are computed for each architecture, or the item stops + and reports which architecture's CANVAS is too small. + *Refs:* §27.8. + +- [ ] **4.4k — Three-arch screendump verification of 4.4g–4.4j.** Geometry only — not the + toggle or scrollback. + *Done when:* screendump on all three architectures shows the 640×480 box centered within + CANVAS at the computed coordinates, with the fixed gap above the REPL strip visible; + three-arch QEMU boot + logs per CLAUDE.md. + *Refs:* §27.8. + +- [ ] **4.4l — Scrollback, ~1000 lines.** A circular buffer of prior scroll-box lines, target + depth approximately 1000 (Captain Bob's own qualification: "something along those lines," + not a hard-locked spec number). Storage mechanism (`kmalloc` ring buffer vs. static array) + is this item's own implementation call. + *Done when:* scrolling back through more than one screen's worth of REPL output recovers + prior lines up to the target depth, verified live on amd64 at minimum; three-arch QEMU boot + + logs per CLAUDE.md. + *Refs:* §27.8. + +- [ ] **4.4m — Toggle word: hide/show the scroll box.** A FORTH word that hides the 640×480 + scroll box, revealing the rest of CANVAS beneath it for drawing; showing it again restores + the scroll-box content undisturbed, no scrollback loss. Depends on 4.4j/4.4k (geometry) and + 4.4l (scrollback) all being done first. + *Done when:* toggling off then on again, verified by screendump, shows the CANVAS drawing + area unobstructed while off and the exact prior scroll-box content restored when back on; + three-arch QEMU boot + logs per CLAUDE.md. + *Refs:* §27.8. + +- [ ] **4.4n — `(user)` prompt segment — scoped, blocked, not started.** Extends 4.4's prompt + to `[VM name] (user) ok>`, e.g. `[Hera] (zuse) ok>`. **Blocked:** `zuse_session` + (`include/vm.h:393`) is a boolean only — no username/identity string exists anywhere in the + ACL system today (confirmed by reading `capsules/zuse.4th`, `capsules/ACL.4th`, + `vm_core.c`). This item cannot start until ACL identity storage exists — that's the open + Phase 8 PKI/user-minting item already on record in CLAUDE.md's ACL section. Recorded here + so the prompt's final shape isn't lost, not because it's ready to build. + *Refs:* §27.8, CLAUDE.md ACL section (Phase 8). - [ ] **4.5 — Artemis last.** It works today; it is the thing that cannot be broken. *Refs:* §10. @@ -5792,3 +5936,61 @@ no hex/base64 text-encoding, no `mkcapsule.c` changes, no parallel asset mechani direct-arena reference — 4.3.7b's own call) behind that lookup. *Refs:* §25.5 (punch list), GAP-B2. + +### 27.8 REPL: prompt, text path, CANVAS geometry (4.4–4.4n) + +Scoped 2026-08-11, in conversation with Captain Bob, replacing `docs/lithosananke/ROADMAP.md`'s +M8 section entirely (marked OBSOLETE there, kept for history only). Original visual reference: +[`repl-mockup.png`](repl-mockup.png). + +**What this item is not.** Not a new subsystem — every piece below either reuses something +already built (`USE`, `console_set_vm_name()`, `vt100.c`'s CSI/SGR parser, `TTF-TEXT`'s color +argument) or extends it in a small, specific way. The scoping pass below exists because two +things Captain Bob assumed were future work turned out to already exist, and one instruction +("VT100 is completely obsolete") turned out to need a narrower reading once the code was +actually read — all found by checking the tree per §25.0 rule 4, not by assumption. + +**Found already built, not future work:** +- **VM attach by name.** `USE` (`src/starkernel/capsule/mama_forth_words.c:1108`) already sets + `g_repl_active_vm` (`repl.c:48`) and calls `console_set_vm_name()` — the REPL can already + attach to any named VM (Hera, Hermes, Artemis, any birthed child) today. Nothing new needed + here; 4.4 only changes how that identity is *displayed*. +- **Two existing, inconsistent VM-identity displays.** `console.c`'s `g_active_vm_name` prefixes + every console line with `[Name]` — this is what has appeared on every serial log line all + session (`[Hera] ...`). Separately, `repl.c`'s `sk_repl_run()`/`sk_repl_step()` build the + prompt itself as `)ok>` for non-Hera VMs (e.g. `Hermes)ok>`), and `zuse)ok>`/`ok>` for + Hera depending on `vm->zuse_session`. Neither matches Captain Bob's described + `[VM] (user) ok>` format. 4.4 unifies both into one convention at the prompt itself; the + per-line `[Name]` prefix on non-prompt output is unaffected (out of scope, not mentioned by + Captain Bob, not touched here). +- **Stroke-font color.** `TEXT ( c-addr u x y size color -- )` (§27.6.6) already takes a color + argument — confirmed before assuming 4.4e would need to add one. + +**Found, changes the shape of "VT100 is obsolete":** `vt100.c` is a complete ANSI/VT100 +terminal state machine — CSI parameter parsing, cursor tracking, full SGR color support +(`apply_sgr()`, 16/256-color, `ansi256_to_rgb()`) — not just a `font_8x16.c` wrapper. Its +glyph-drawing call is a single, separate site (`put_char()` → `draw_cursor_glyph()`). +Captain Bob's "completely 100% obsolete" instruction, read against this, resolves to: keep the +CSI/SGR engine (it's exactly the "ANSI colorization throughout" mechanism wanted), retarget only + the one glyph-draw call site from `font_8x16.c` to `TTF-TEXT` (4.4d/4.4e). This is not a reversal of +the obsolescence call — the VT100 *console text path as currently wired* (feeding +`font_8x16.c`-rendered REPL text) is still going away for user-facing text; the parser +underneath it is what survives, repointed. + +**Confirmed, not assumed: TrueType is the primary user-facing text path.** This restates +§27.7 decision #4, not a new decision — TTF-TEXT for anything a user actively works with (REPL, +CANVAS), stroke font (`TEXT`) reserved for later retro/game-styled work. See 4.4a's correction +note above for the one inherited imprecision (stroke font is not actually usable pre-bootstrap +either — `font_8x16.c` is the real early-boot fallback, not "the stroke font" generically). + +**CANVAS coordinate layering.** Two distinct coordinate ideas are in play and should not be +conflated: `TTF-TEXT`'s own coordinate primitive is Cartesian with origin at the bottom-left of +the *physical framebuffer*, decoupled from REPL-strip sizing (resolved via `AskUserQuestion` +2026-08-11, implemented in `ttf_words.c` ahead of this item, verified by amd64 screendump +showing y=60/400/700 rendering bottom/middle/top respectively). CANVAS-relative placement — the +640×480 scroll box centered within the region above the REPL strip — is a separate layout +computation (4.4b) that translates into that same physical-framebuffer coordinate space before +calling `TTF-TEXT`. The primitive doesn't know about CANVAS or the REPL strip; 4.4b's layout +math does. + +*Refs:* §25.5 (punch list), §27.6, §27.7.