Capsule blocks steps 3+4 for v4: capsules are placed in RAM and load their lowest block

Captain Bob ruled: Block n lands at n-R; the lowest block is
interpreted; chaining is the developer's; together, v4 first.
- v4_blocks_place_capsule copies each Block n into RAM block n - R as 16
  lines of 64, space-padded, in any file order. A later block of the
  same number overwrites. It refuses a block below R.
- The mesh's load(), its capsule reader (CAPSULE-OPEN/(LINES), so a
  child's forth79.4th via BIRTH too), boot.c and test_host_unit's model
  each place a capsule, then interpret "<lowest> LOAD".
- mkdictionary.py skips --> when it types capsules at the hosted prompt.
- The v4 capsules are renumbered into R..2R-1, landing at RAM 1900 and
  up, away from POST's blocks 0-5. Each is chained with -->, and
  centre.4th's gap at 8103 is closed.

Test first:
- test_host_blocks.c gained 6 placement checks; it failed to build
  before.
- test_mesh_boot.c checks forth79's lowest block in RAM block 1900; it
  failed before.

After: POST is 990/990; all 52 tests at 64 bits, test-32, hosted-check
and ASan/UBSan pass; the amd64 kernel builds; the dictionary has 404
words.

Logs are in logs/20261118-capsule-place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
Claude
2026-11-18 20:33:21 +00:00
parent bcfca9fa19
commit 6dcfbe6740
27 changed files with 1399 additions and 97 deletions
+30
View File
@@ -217,6 +217,36 @@ int main(void)
CHECK(!v4_blocks_serve(&w, &n, 5) && !v4_blocks_serve(&w, &n, 0) && !v4_blocks_serve(&w, &n, -6) && v4_dstack_pop(&n.ds) == 22 && v4_dstack_pop(&n.ds) == 11,
"any other request is not served here, and the stack is as it was");
/* ---- a capsule placed in RAM (docs/v4.0.0/plans/2026-11-18-capsule-blocks.md) ----
* Each `Block n` goes to RAM block n - R (R the RAM block count, blk_layout.h), as 16
* lines of 64 characters padded with spaces, whatever its order in the file; a later
* block of the same number overwrites; the lowest placed is given back. */
{
static const char cap[] =
"Block 2050\n( two )\n: TWO 2 ;\n"
"Block 2049\n( one, written first in RAM order )\n"
"Block 2051\n( first )\n"
"Block 2051\n( second, overwrites )\n";
uint32_t lowest = 0;
int placed = v4_blocks_place_capsule((const uint8_t *)cap, (const uint8_t *)cap + sizeof cap - 1u, &lowest);
const uint8_t *b1 = blk_get_buffer(1, 0), *b2 = blk_get_buffer(2, 0), *b3 = blk_get_buffer(3, 0);
unsigned k, spaces = 1;
CHECK(placed == 4 && lowest == 1, "four blocks placed, the lowest at RAM block 1 (%d, %u)", placed, (unsigned)lowest);
CHECK(b2 && memcmp(b2, "( two )", 7) == 0 && memcmp(b2 + 64, ": TWO 2 ;", 9) == 0,
"block 2050 is at RAM block 2: its lines at 0 and 64");
for (k = 7; b2 && k < 64; k++) if (b2[k] != ' ') spaces = 0;
for (k = 128 + 0; b2 && k < 1024; k++) if (b2[k] != ' ') spaces = 0;
CHECK(spaces, " each line padded with spaces to 64, and the rest of the block spaces");
CHECK(b1 && memcmp(b1, "( one, written first in RAM order )", 35) == 0, "block 2049 is at RAM block 1, whatever the file's order");
CHECK(b3 && memcmp(b3, "( second, overwrites )", 22) == 0, "a block of the same number overwrites the first");
}
{
static const char low[] = "Block 2047\n( in the RAM itself )\n";
uint32_t lowest = 99;
CHECK(v4_blocks_place_capsule((const uint8_t *)low, (const uint8_t *)low + sizeof low - 1u, &lowest) == -1,
"a block below the RAM count is refused");
}
printf(" %d checks, %d failures\n", checks, failures);
return failures ? 1 : 0;
}