11 Commits
Author SHA1 Message Date
Claude 29b99f90e6 plans: step 3 §6.6 ruled, mkf18a / .f18a; design ruled
Build / Image RASPI (push) Successful in 4m41s
Build / Image PC (push) Successful in 5m50s
Build / Image MILKV (push) Successful in 6m2s
Build / v4 tests (32- and 64-bit cells) (push) Successful in 15m51s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
2026-11-19 16:33:29 +00:00
Claude 6c639e5d20 plans: step 3 §6.5 ruled, the tool's hash is its source's
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
2026-11-19 16:32:59 +00:00
Claude 3733949c28 ABI.md 2c: a word with no fixed effect stays internal, the build does not fail
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
2026-11-19 16:32:39 +00:00
Claude a6371b1ce3 plans: step 3 §6.4 ruled, every fixed-effect word exported
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
2026-11-19 16:32:21 +00:00
Claude 255dd92deb plans: step 3 §6.3a ruled, the nucleus renamed to name order
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
2026-11-19 16:31:07 +00:00
Claude b5e85392c1 plans: step 3 §6.3 ruled, all it finds, name order
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
2026-11-19 16:30:24 +00:00
Claude 9c8b8dbd8b plans: step 3 §6.2a ruled, the nucleus is not an artifact
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
2026-11-19 16:28:47 +00:00
Claude 4ecdc80197 plans: step 3 §6.2 ruled, both, nucleus first
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
2026-11-19 16:27:31 +00:00
Claude 1961348e15 ARTIFACT.md: relocation slot 7, the whole cell (step 3 §6.1 ruled)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
2026-11-19 16:26:29 +00:00
Claude 16b8fddaef plans: artifacts in the build (ADR step 3), draft for ruling
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
2026-11-19 16:25:39 +00:00
Claude f2174a39a4 ABI.md, ARTIFACT.md: three drafting additions confirmed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
2026-11-19 16:24:51 +00:00
3 changed files with 162 additions and 5 deletions
+6 -2
View File
@@ -154,6 +154,7 @@ capsule-blocks.md` §5), and Artemis keeping what is kept (ruling 3).
`.f18` to artifacts on the build machine. It is a second assembler beside the ROM's, so the two must
agree: the tool's output is checked against what the ROM assembles from the same source, cell for cell,
in the build and in CI. The compiler's identity in the provenance record is the tool's own hash.
The cell-for-cell check was added in drafting; confirmed by Captain Bob, 2026-11-19 ("Yes").
2. ~~The stack-effect declaration~~ **Ruled 2026-11-19: "Derived by the tool".**
- A first answer, "the ( -- ) comment, strict", was withdrawn the same day. Captain Bob: "I think I may
have made a bad assumption. I had the idea of that after (- was aliased to ( is for SDK special. We're
@@ -164,7 +165,9 @@ capsule-blocks.md` §5), and Artemis keeping what is kept (ruling 3).
- **2c, ruled 2026-11-19: "Refused as an export".** A word whose effect depends on its data (a loop
leaving a count of values, branches that leave different depths, `EXECUTE`, a `DEFER`red word) has no
fixed count. It cannot be exported by an engine: it stays internal to its train, or is restructured.
Every export has a fixed effect, which the tool derives and the build fails without.
Every export has a fixed effect, derived by the tool; a word with none stays internal, and the build
does not fail for it (`plans/2026-11-19-f18-artifact-build.md` §6.4). *Corrected 2026-11-19: this
said "which the tool derives and the build fails without".*
3. ~~What a capsule carries~~ **Ruled 2026-11-19: "No, by reference".** A train's engine carries only the
hash of the `.f18` source it was assembled from, in its provenance record. The source stays in the
repository and in its own capsule. To check an engine against its source, the source is fetched by
@@ -182,7 +185,8 @@ capsule-blocks.md` §5), and Artemis keeping what is kept (ruling 3).
scans every node's P and return stack for an address inside the old words' code. When none is there, it
writes all of a set's jumps in that one tick. While some are there, it tries again on later ticks. A
message waiting for an old word is not code on a stack and does not hold the set back: the word it
reaches is the new one.
reaches is the new one. That last point was added in drafting; confirmed by Captain Bob, 2026-11-19
("Yes").
7. ~~Proofs first~~ **Ruled 2026-11-19: "Safe activation first".** The first Isabelle/HOL property:
- the jump at each old entry is written only at a tick when no node's P or return stack holds an address
inside the old code (choice 6);
+9 -3
View File
@@ -95,12 +95,16 @@ Each hash is SHA-512 (choice 2).
| Unit | Field |
|---|---|
| 0 | the code cell, as an offset, and in the top 3 bits the slot whose branch field holds the address (0–3) |
| 0 | the code cell, as an offset, and in the top 3 bits the slot whose branch field holds the address (0–3), or 7 for the whole cell |
| 1 | what it points to: `0xFFFFFFFF` for internal, so the base is added; otherwise the import's index |
Placement (`ABI.md` §5) patches each relocation's branch field. It refuses a patched address beyond that
slot's reach: 27, 22, 17 or 12 bits (`iword.h`).
**Slot 7, the whole cell** (ruled 2026-11-19, "Slot 7 = whole cell", step 3's design §6.1). The cell holds
an address as a value: an `&NAME` literal, or a dictionary link. Placement adds the base, or puts in the
import's address, to the whole cell, which reaches all of a node. Slots 4–6 are unused.
## 6. Verification (18 units, ADR §5)
| Units | Field |
@@ -118,7 +122,8 @@ about the format:
- every string pool offset on a counted string, or, for a capabilities list, on a unit holding its count
*n* followed by *n* units, each a `KERNEL-WORD` number;
- every export's entry inside the code;
- every relocation's cell inside the code, its slot one that holds a branch, its import index below I;
- every relocation's cell inside the code, its slot 0–3 one that holds a branch or 7, its import index
below I;
- every reserved unit 0.
## 8. Open, for ruling one at a time
@@ -138,7 +143,8 @@ about the format:
4. ~~Capabilities~~ **Ruled 2026-11-19: "Port bit + request list".** As drafted (§5, unit 5). The tool
derives it from the code: a port opcode sets the bit, and each kernel request the word reaches goes in
its list. Compatibility refuses a replacement that needs one the old did not (`ABI.md` §7). The list
is a count unit then that many request numbers (§7).
is a count unit then that many request numbers (§7). The bit layout and the list's form were chosen in
drafting; confirmed by Captain Bob, 2026-11-19 ("Yes").
5. ~~Endianness for the code cells~~ **Ruled 2026-11-19: "Low-first, like the records".** Every byte of
the artifact has one order, low byte first, so its hashes and signature are the same whichever host
built it. A big-endian host swaps the bytes when it places the code.
@@ -0,0 +1,147 @@
# Artifacts in the build -- design, for ruling
Written 2026-11-19. Step 3 of `ADR-2026-11-19-F18-ARTIFACTS.md` §7, "Integrate artifact production into the
existing build system". It builds on:
- `ABI.md`, ABI v0 as ruled, in particular choice 1, "A host tool";
- `ARTIFACT.md`, the layout as ruled.
**Nothing here is built.** The questions in §6 are ruled (2026-11-19).
## 1. What is there already
- **The host assembler exists.** `v4/src/text.c` assembles `.f18` text onto a node. `v4/tools/mkrom.c`
uses it on the build machine to build the ROM, "as a bitstream is built". The tests use it to build the
system.
- **The ROM and `text.c` are proved to agree.** `test_host_rom_nucleus` assembles the system's source
twice:
- once off the node with `text.c`, the oracle;
- once on the machine, by the ROM fed through the console.
Every word of RAM must be the same, apart from the ROM's own state. This is ABI choice 1's cell-for-cell
check already, for the one train that has `.f18` today.
- **Only one train has `.f18` today: the nucleus.** Its source is `capsules/v4/sys`. The map comes first,
then the fourteen files in `sys_files.h`'s order, then `end.f18`. The boot feeds them to the ROM as the
blobs `v4:sys:*.f18` (`boot.c`).
- **The nucleus is not relocatable.** It is assembled at a fixed origin against the map's fixed addresses.
`end.f18` `store`s addresses into the map's variables, and its dictionary holds absolute links. Ruling 1
keeps it as it is: the ROM still assembles the system at boot (`ABI.md` §8).
## 2. The tool: `v4/tools/mkf18a.c`
A C tool beside `mkrom.c`, built the same way, one per cell width:
mkf18a OUT.f18a MAP.f18 DIR
1. It assembles every `.f18` in DIR with `text.c`, at origin 0, in name order (ruled §6.3), after MAP.
2. It writes the artifact, laid out as `ARTIFACT.md` gives:
- the header;
- the provenance, with its four SHA-512 hashes;
- the exports, the imports and the relocations;
- an empty verification record;
- the string pool and the code, low byte first.
3. It fails the build if anything cannot be written as the ABI requires:
- a relocation whose patched address is beyond its slot's reach;
- a capability it cannot derive.
**The relocations come from `text.c`.** `text.c` gains a record of each cell it lays down that holds an
address: every branch it resolves to a word or a label, and every `&NAME`. That is one hook, and test-first:
`test_text` checks the record against the cells.
**The stack effects come from a new analysis**, `v4/src/effect.c`. It walks each word's instruction words
from its entry to every `;` and counts what each opcode takes and leaves on both stacks:
- the opcode table is `iword.h`'s;
- a call takes the effect of the word it calls, derived first;
- a branch that joins two paths with different depths is "no fixed effect";
- so are a loop whose count is data, `EXECUTE` and a `DEFER`red word.
It is a module of its own, so the proofs can state it on its own (ADR step 5).
## 3. Where it runs
- **`v4/Makefile`:** `make -C v4 artifacts` builds the artifacts of each width into `v4/build/`. `make -C v4
test` runs it, so a `.f18` the tool refuses fails the test gate.
- **The check against the ROM:** the nucleus is not an artifact (ruled §6.2a), so no file is written for it.
`test_host_rom_nucleus` assembles it with the tool's assembler, the address record turned on, and the ROM
must still lay down every word the same. That proves the record changes no cell. The records themselves
are proved by the small train (§4, test 5).
- **The kernel build:** nothing changes in step 3. The boot still feeds the ROM the source. Carrying the
artifact in the capsule, and placing it, is steps 4 and 6.
- **CI:** `build.yml`'s `v4-tests` job runs `make -C v4 test` already, so it gains the gate with no change.
## 4. Test first, seen to fail
1. `test_text`: the address record for a branch, a forward branch, a label, and an `&NAME`.
2. `test_effect`, new: words of known effect, written in `test_text`'s notation:
- `dup` (1 → 2);
- `drop` (1 → 0);
- a call;
- a `for`/`next` loop of fixed count;
- two branches that agree;
- two branches that disagree (no fixed effect).
3. `test_mkf18a`, new: a small text's artifact read back unit by unit against `ARTIFACT.md`. It checks the
magic, the counts, each record, every reserved unit 0, and the code low byte first.
4. `test_host_rom_nucleus`, with the address record on: the ROM's assembly equal to the tool's, word for
word (ruled §6.2a: no artifact file for the nucleus).
5. Then a small train, a few words of `.f18` with one import from the nucleus, is placed from its artifact
at a base other than 0. Its words run, and its calls into the nucleus reach the nucleus (ruled §6.2).
POST, the protocol and the dictionary gate are unchanged, since the boot is unchanged.
## 5. Cost
The build gains one assembly of the nucleus per width, which takes a second or less on the host
(`test_host_rom_nucleus` reports its time today), plus the analysis. That is measured when it is built, as
ADR step 8 asks. The boot gains nothing.
## 6. For ruling, one at a time
1. ~~Address literals~~ **Ruled 2026-11-19: "Slot 7 = whole cell"**, recorded in `ARTIFACT.md` §5 and §7.
As asked: `ARTIFACT.md` §5's relocation covers branch fields only (a slot, 0–3). The
system's source also holds addresses in whole cells: the `&NAME` literals (31 in `capsules/v4/sys`),
and the dictionary's links. One fix is a slot value of 7 meaning "the whole cell". The top 3 bits allow
0–7, so the record keeps its size.
2. ~~Which train first~~ **Ruled 2026-11-19: "Both, nucleus first".** The nucleus is built and checked
against the ROM; then a small train is placed at a base other than 0, to prove the relocations (§4,
test 5). As asked: The nucleus is the only `.f18` train, but it is not relocatable, and the ROM keeps
assembling it (§1). Its artifact can be built and checked (§3), but it is never placed by the loader.
**2a, ruled 2026-11-19: "Nucleus not an artifact".** Asked how an artifact would say it is fixed at an
origin, since `ABI.md` §4 has its code "as if placed at address 0": only relocatable trains are
artifacts. The nucleus is checked as the tool's assembly against the ROM's, and no artifact file is
written for it. `ABI.md` §4 stands.
Is the nucleus the first artifact, or is a small relocatable train written first?
3. ~~The order of the sources~~ **Ruled 2026-11-19: "All it finds, name order".** The tool takes every
`.f18` in a train's directory, sorted by name, so the file names set the order (`00-core.f18`, ...) and
there is no list to keep. As asked: Captain Bob's image is "the .f18 assembler assembles all .f18 files it
finds", but the order matters: the map first, `sys_files.h`'s list, `end.f18` last. Does each train
name its order in a list, as `sys_files.h` does, or does the tool take the files in name order?
**3a, ruled 2026-11-19: "Nucleus too: rename".** Asked whether name order applies to the nucleus,
which is read in `sys_files.h`'s order: it does. `capsules/v4/sys` is renamed so that its name order is
today's order, the map first and `end.f18` last (`00-map`, `01-core`, ... `99-end`), and `sys_files.h`
goes. The boot, the tests and the ROM's feed read the directory in name order. The blob names and the
capsule hashes change, so the protocol runs again. This is a task of its own, designed and tested
first. One point for its design: the directory holds both widths' maps, `map-32.f18` and `map-64.f18`,
and name order would take both.
4. ~~Which words are exports~~ **Ruled 2026-11-19: "Every fixed-effect word".** Every word the tool
derives a fixed effect for is exported; the rest stay internal, and the build does not fail for them.
As asked: The nucleus defines hundreds of words, and some have no fixed effect, which
2c refuses as exports. Is every word with a fixed effect exported, or only those a list names? With a
list, the words outside it stay internal.
5. ~~The tool's identity~~ **Ruled 2026-11-19: "Its source".** The provenance's tool hash is the SHA-512 of
the tool's source: `mkf18a.c`, `text.c`, `effect.c` and the v4 headers they include, in a fixed order.
The same source gives the same hash on every host. As asked: The provenance holds "the host tool's hash". The hash of the binary differs
with the host's compiler. Should it be the hash of the tool's source (`mkf18a.c`, `text.c`, `effect.c`
and their headers), or of the binary?
6. ~~The name~~ **Ruled 2026-11-19: "mkf18a / .f18a"**, after the magic: `v4/tools/mkf18a.c`, and each
train's artifact `<train>.f18a`. As asked: `mkf18a` and `.f18a`, after the magic, or something else?
## 7. Status, and the order of the work
All six questions are ruled, plus 2a and 3a. Each task below is built test-first, seen to fail, and
accepted before the next:
1. `text.c`'s address record (§4, test 1), with `test_host_rom_nucleus` unchanged (test 4).
2. `effect.c`, the stack-effect analysis (test 2).
3. `mkf18a` and `make -C v4 artifacts` (test 3).
4. The small train, placed at a base other than 0 (test 5).
5. The nucleus renamed to name order (3a), designed first: it changes the boot, so the protocol runs.