notes

The interactive boot: its processes, its filesystem and its stack

An appendix to nifeos/nife:notes/pipes.md, which is the page to read. This file holds the five processes an interactive boot runs, how the filesystem reaches the shell, and the four stack overflows. It moved here as the index says.

The records this file cites by number:

The five processes an interactive boot now runs

For a reader arriving at this file cold, the shape of the system 2> completed:

  init ──builds──► console server            reads a page, writes the UART
              ├──► line_editor               the terminal contract: OPERATION_WRITE, OPERATION_READLINE,
              │                              OPERATION_BYTES, OPERATION_INTRCOUNT, OPERATION_PRINT
              ├──► input driver              the UART receive interrupt, into the terminal
              ├──► swish                     the prompt
              └──► terminal_sink_caretaker             the sink contract, into OPERATION_PRINT

The fifth is new (DECISIONS §67, notes/sink-protocol.md), and it is the only one a person never interacts with directly. It exists so "the terminal" can be a destination a capability designates rather than a thing only the shell can reach, and its whole job is turning sink messages into terminal prints. The progenitor keeps the endpoint it serves and hands it to any child whose manifest declares a second stream, the way it hands out the clock.

The boot that has a filesystem, which is what > was actually waiting for

The kernel brings the block server and the FS server up before the progenitor exists and hands the progenitor the file-service endpoint plus the frame its clients map. The progenitor narrows both into the shell: slot 4, and the page at FS_VA. Nothing else in the system changed shape; the shell simply holds one more capability.

  kernel  ── wires blk + redoxfs_server, drains both readiness sentinels ──┐
                                                                     v
          ── spawns init, granting the FS endpoint and the page (GRANT on both)
                                                                     |
  init    ── builds console, line_editor, input ──────────────────────── |
          ── builds the shell: slot 4 = the FS endpoint (WRITE, no GRANT)
                                          + the page at 0x60_0000
                              slot 5 = the clock page (READ, no GRANT)  [milestone 86]
                                          + the page at 0xd0_0000
          ── starts it with arg1 = the dir rights that endpoint carries
                            arg2 = the clock's slot, 0 for none         [milestone 86]

The clock is granted after the FS pair so a boot with no disk takes exactly the path it took before it existed. That means its slot moves (4 without a disk, 5 with one) and the shell is told the number rather than assuming one. See notes/time-command.md.

arg1 is 0 on a machine with no RedoxFS disk attached, and then the shell is exactly the shell it was: Nav::empty(), and every verb that would need a directory says so. The same ELF is in both positions, which is why kernel::user::pipeline_tests (no slot 4) and kernel::user::redirection_tests (slot 4) are each other's control.

Three things had to move to make room, and each is a fact worth keeping:

The shell's stack, a fourth time, and what the pattern is now

Milestone 50 hit "a boot that printed nothing" three times and one of them was four stack pages being one deep call short of the redirection path. Milestone 31's input operand hit the same symptom in the same file and it is worth naming the shape rather than the instance.

wc out.txt reaches run_pipeline through dispatch -> dispatch_one -> run, where a line with an operator on it reaches it through dispatch -> pipeline. One frame deeper, on a program whose frames carry parsed lines and planned endowments by value, and the scripted wiring's six extra pages were not enough. The result was a data abort one word below the lowest mapped page, mid-script, with far equal to sp.

Two things came out of it, and the second is the one to keep:

And a fourth time, for 2>. A second FileOut on run_pipeline's frame overflowed eight pages by twenty-four bytes, in the same place, with the same signature. Each carries a 256-byte staging buffer by value, because the filesystem's write unit is a page and the sink contract's is sixteen bytes. All three wirings are twelve now, and the number went up by four rather than one on purpose: every previous instance bought exactly enough headroom and the next change found the wall again. 48 KiB of address space per child is not worth a fifth bisect.

The pattern the four instances share is worth more than any of them. This shell's frames carry whole values that grew as the milestone grew (a parsed Line, an array of Endowments each holding a NameSet, a listing buffer, now two file buffers). None of that shows up anywhere a reader would look. The symptom is always a data abort one word below the lowest mapped page.