diff --git a/capsules/BLOCK_MAP.md b/capsules/BLOCK_MAP.md
index 9f3ec4d8..212710d6 100644
--- a/capsules/BLOCK_MAP.md
+++ b/capsules/BLOCK_MAP.md
@@ -6,7 +6,7 @@
## Capsule Summary
-| Capsule | Blocks claimed | xxHash64 | Signed |
+| Capsule | Blocks used | xxHash64 | Signed |
|---------|----------------|----------|--------|
| `ACL.4th` | 4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4015 | `0xf8890c05c0d8f921` | n/a |
| `acl-std79.4th` | 4023, 4024, 4025, 4026, 4027, 4028, 4029, 4030, 4031, 4032, 4033, 4034, 4035, 4036, 4037, 4038, 4039, 4040, 4041, 4042, 4043, 4044, 4045, 4046, 4047, 4048 | `0x773bf9209df191d1` | n/a |
@@ -386,9 +386,5 @@
| 8203 | `v4:physics.4th` | `0x747d89ca8d57e29c` | ok |
| 8204 | `v4:physics.4th` | `0x747d89ca8d57e29c` | ok |
-## Conflicts
-
-None.
-
---
*40 capsule(s) scanned. Re-run `mkcapsule --manifest
` to refresh.*
diff --git a/docs/v4.0.0/plans/2026-11-18-capsule-blocks.md b/docs/v4.0.0/plans/2026-11-18-capsule-blocks.md
index 543c8b0f..c99333c9 100644
--- a/docs/v4.0.0/plans/2026-11-18-capsule-blocks.md
+++ b/docs/v4.0.0/plans/2026-11-18-capsule-blocks.md
@@ -88,7 +88,20 @@ Each step is test first, then POST and the protocol:
The plan as written: `block_subsystem.h` and the kernel read
it, and `mkcapsule` is given it at build time in place of its literal 2048.
-2. **`mkcapsule`.**
+2. **`mkcapsule`. Built 2026-11-18** (rulings: overwrite within a capsule too, "consistent with
+ VOCABULARY FORGET & FENCE philosophy, not implementation"; of what only prevents collisions, "All of
+ it goes"):
+ - the cross-capsule collision gate is gone;
+ - so are `tools/capsule-reserved.txt` with its check, and the interactive resolver with its claim
+ registry;
+ - the map says "Blocks used", and marks a shared number "the later write overwrites";
+ - an unknown option is refused with the usage, so a removed mode is never taken for the capsules
+ directory.
+
+ A repeat within one capsule had no check to remove. Tested by `scripts/test_mkcapsule_overwrite.sh`,
+ 9 checks, in `logs/20261118-mkcapsule-overwrite/`.
+
+ The plan as written:
- Its floor comes from the knob.
- Its cross-capsule collision check goes, since a later write overwrites.
- `BLOCK_MAP.md` says "Blocks used".
diff --git a/logs/20261118-mkcapsule-overwrite/build-amd64.log b/logs/20261118-mkcapsule-overwrite/build-amd64.log
new file mode 100644
index 00000000..a4666851
--- /dev/null
+++ b/logs/20261118-mkcapsule-overwrite/build-amd64.log
@@ -0,0 +1,262 @@
+HOSTCC tools/mkcapsule.c tools/pkcs8_ed25519.c kernel/src/crypto/ed25519.c kernel/src/crypto/fe25519.c kernel/src/crypto/scalar25519.c kernel/src/crypto/sha512.c kernel/src/crypto/x509_ed25519.c
+ V4ROM capsules/v4/rom -> build/amd64/kernel/v4_rom_64.c build/amd64/kernel/v4_map_64.c build/amd64/kernel/v4_mesh_rom_64.c
+CC (kernel) v3/src/blkio_ram.c
+CC (kernel) v3/src/block_subsystem.c
+CC (kernel) v3/src/compudynamics.c
+CC (kernel) v3/src/dictionary_heat_optimization.c
+CC (kernel) v3/src/dictionary_management.c
+CC (kernel) v3/src/heartbeat_export.c
+CC (kernel) v3/src/inference_engine.c
+CC (kernel) v3/src/io.c
+CC (kernel) v3/src/math_portable.c
+CC (kernel) v3/src/memory_management.c
+CC (kernel) v3/src/physics_execution_hooks.c
+CC (kernel) v3/src/physics_hotwords_cache.c
+CC (kernel) v3/src/physics_metadata.c
+CC (kernel) v3/src/physics_pipelining_metrics.c
+CC (kernel) v3/src/physics_runtime.c
+CC (kernel) v3/src/profiler.c
+CC (kernel) v3/src/rolling_window_of_truth.c
+CC (kernel) v3/src/ssm_jacquard.c
+CC (kernel) v3/src/stack_management.c
+CC (kernel) v3/src/vm_api.c
+CC (kernel) v3/src/vm_debug.c
+CC (kernel) v3/src/word_registry.c
+CC (kernel) v3/src/word_source/acl_words.c
+CC (kernel) v3/src/word_source/arithmetic_words.c
+CC (kernel) v3/src/word_source/block_words.c
+CC (kernel) v3/src/word_source/control_words.c
+CC (kernel) v3/src/word_source/defer_words.c
+CC (kernel) v3/src/word_source/defining_words.c
+CC (kernel) v3/src/word_source/dictionary_heat_diagnostic_words.c
+CC (kernel) v3/src/word_source/dictionary_manipulation_words.c
+CC (kernel) v3/src/word_source/dictionary_words.c
+CC (kernel) v3/src/word_source/double_words.c
+CC (kernel) v3/src/word_source/editor_words.c
+CC (kernel) v3/src/word_source/format_words.c
+CC (kernel) v3/src/word_source/framebuffer_words.c
+CC (kernel) v3/src/word_source/inference_words.c
+CC (kernel) v3/src/word_source/io_words.c
+CC (kernel) v3/src/word_source/keyboard_words.c
+CC (kernel) v3/src/word_source/lifecycle_words_hosted.c
+CC (kernel) v3/src/word_source/log_words.c
+CC (kernel) v3/src/word_source/logical_words.c
+CC (kernel) v3/src/word_source/memory_words.c
+CC (kernel) v3/src/word_source/mixed_arithmetic_words.c
+CC (kernel) v3/src/word_source/physics_benchmark_words.c
+CC (kernel) v3/src/word_source/physics_diagnostic_words.c
+CC (kernel) v3/src/word_source/physics_freeze_words.c
+CC (kernel) v3/src/word_source/physics_pipelining_diagnostic_words.c
+CC (kernel) v3/src/word_source/q48_words.c
+CC (kernel) v3/src/word_source/return_stack_words.c
+CC (kernel) v3/src/word_source/scroll_words.c
+CC (kernel) v3/src/word_source/stack_words.c
+CC (kernel) v3/src/word_source/starforth_words.c
+CC (kernel) v3/src/word_source/string_words.c
+CC (kernel) v3/src/word_source/system_words.c
+CC (kernel) v3/src/word_source/ttf_words.c
+CC (kernel) v3/src/word_source/vocabulary_words.c
+CC (kernel) v3/src/test_runner/test_common.c
+CC (kernel) v3/src/test_runner/test_contracts.c
+CC (kernel) v3/src/test_runner/test_runner.c
+CC (kernel) v3/src/test_runner/modules/acl_words_test.c
+CC (kernel) v3/src/test_runner/modules/arithmetic_words_test.c
+CC (kernel) v3/src/test_runner/modules/block_words_test.c
+CC (kernel) v3/src/test_runner/modules/control_words_test.c
+CC (kernel) v3/src/test_runner/modules/defining_words_tests.c
+CC (kernel) v3/src/test_runner/modules/dictionary_manipulation_words_test.c
+CC (kernel) v3/src/test_runner/modules/dictionary_words_test.c
+CC (kernel) v3/src/test_runner/modules/double_words_test.c
+CC (kernel) v3/src/test_runner/modules/format_words_test.c
+CC (kernel) v3/src/test_runner/modules/inference_words_test.c
+CC (kernel) v3/src/test_runner/modules/integration_tests.c
+CC (kernel) v3/src/test_runner/modules/io_words_test.c
+CC (kernel) v3/src/test_runner/modules/logical_words_test.c
+CC (kernel) v3/src/test_runner/modules/mama_forth_words_test.c
+CC (kernel) v3/src/test_runner/modules/memory_words_test.c
+CC (kernel) v3/src/test_runner/modules/mixed_arithmetic_words_test.c
+CC (kernel) v3/src/test_runner/modules/physics_freeze_words_test.c
+CC (kernel) v3/src/test_runner/modules/q48_words_test.c
+CC (kernel) v3/src/test_runner/modules/return_stack_words_test.c
+CC (kernel) v3/src/test_runner/modules/stack_words_test.c
+CC (kernel) v3/src/test_runner/modules/starforth_words_test.c
+CC (kernel) v3/src/test_runner/modules/stress_tests.c
+CC (kernel) v3/src/test_runner/modules/string_words_test.c
+CC (kernel) v3/src/test_runner/modules/system_words_test.c
+CC (kernel) v3/src/test_runner/modules/vocabulary_words_test.c
+ MKCAP capsules -> build/amd64/kernel/capsule_generated.c
+mkcapsule: scanning capsules
+ [p] zuse.4th (1684 bytes, hash=0x490ded9be257a90b)
+ [p] font.4th (17688 bytes, hash=0x3f305911500c78f6)
+ [p] MANIFEST_AUTO.md (11687 bytes, hash=0xe022545a0755960f)
+ [p] multiuser-doe.4th (3942 bytes, hash=0x22140588ee7c39e6)
+ [p] hestia:init.4th (891 bytes, hash=0x64e111990fbc45ff)
+ [p] contrib:README.md (1855 bytes, hash=0x4212e52b927793e7)
+ [p] ACL.4th (4318 bytes, hash=0xf8890c05c0d8f921)
+ [p] workload-3.4th (2189 bytes, hash=0x62b7a71576ad1041)
+ [p] init-l8-diverse.4th (430 bytes, hash=0xaa293201a6c91838)
+ [p] user-font-demo.4th (1674 bytes, hash=0xce1fd7d1b581a56d)
+ [p] workload-9.4th (1321 bytes, hash=0x3f2bec73142aa424)
+ [p] lib.4th (619 bytes, hash=0x4b216635c359ef73)
+ [p] workload-calib1.4th (304 bytes, hash=0x3b9f2d17b554fabc)
+ [m] init.4th (669 bytes, hash=0xd09db9461b336431)
+ [p] workload-1-lite.4th (540 bytes, hash=0x44a7a7e3176dcc8d)
+ [p] init-l8-stable.4th (278 bytes, hash=0xdc3830f189063a9a)
+ [p] v4:physics.4th (2937 bytes, hash=0x747d89ca8d57e29c)
+ [p] v4:forth79.4th (1208 bytes, hash=0x4055641ee17d176b)
+ [p] v4:sys:log.f18 (4535 bytes, hash=0x544cd004233dff62)
+ [p] v4:sys:qmath.f18 (8607 bytes, hash=0xa93783c2c8f9b7db)
+ [p] v4:sys:map-32.f18 (3162 bytes, hash=0x5bdf8cbbebdd3c8f)
+ [p] v4:sys:blocks.f18 (6112 bytes, hash=0x09d361dbe6174236)
+ [p] v4:sys:input.f18 (10692 bytes, hash=0x0f13c3f9d5fd07fc)
+ [p] v4:sys:dict.f18 (13816 bytes, hash=0xe3453808afd5a0af)
+ [p] v4:sys:forth.f18 (12617 bytes, hash=0xc4c0ad315c95eda4)
+ [p] v4:sys:quit.f18 (32141 bytes, hash=0x7fa7a7668b6bf1ed)
+ [p] v4:sys:map-64.f18 (3201 bytes, hash=0x06cb44832df2b8fd)
+ [p] v4:sys:codegen.f18 (4999 bytes, hash=0x36d2ae84d2911b90)
+ [p] v4:sys:acl.f18 (4100 bytes, hash=0x76e7e746befa2733)
+ [p] v4:sys:core.f18 (24370 bytes, hash=0x0f415502fccc3fba)
+ [p] v4:sys:system.f18 (10189 bytes, hash=0xfe257eb084c43a5d)
+ [p] v4:sys:numout.f18 (6641 bytes, hash=0xca0fb0f9c1589e20)
+ [p] v4:sys:words.f18 (9642 bytes, hash=0x2f4e5f7f3e7f736f)
+ [p] v4:sys:compile.f18 (23099 bytes, hash=0xb46bf77ceee7245a)
+ [p] v4:sys:end.f18 (1452 bytes, hash=0x98fd33b1c431cfe7)
+ [p] v4:starshipos.4th (702 bytes, hash=0x5658ee1b771b5963)
+ [p] v4:hera.4th (1372 bytes, hash=0x85300ad4e6e8b86b)
+ [p] v4:rom:sym.f18 (5610 bytes, hash=0xbbad5748f5bbf863)
+ [p] v4:rom:main.f18 (2284 bytes, hash=0x6994f1f1d567e163)
+ [p] v4:rom:math.f18 (5108 bytes, hash=0x9be63ad87934622f)
+ [p] v4:rom:dir.f18 (5112 bytes, hash=0x51b069f0623ded16)
+ [p] v4:rom:num.f18 (2634 bytes, hash=0x08b76f1b058cac17)
+ [p] v4:rom:pack.f18 (4583 bytes, hash=0x65a944d8eb7de7f2)
+ [p] v4:rom:word.f18 (12966 bytes, hash=0x9210d6c2ac424d11)
+ [p] v4:rom:in.f18 (4230 bytes, hash=0x65798bed38a09f0f)
+ [p] v4:rom:mesh.f18 (449 bytes, hash=0x83723d76b9620c2c)
+ [p] v4:centre.4th (3899 bytes, hash=0xccd1b28a101c78b2)
+ [p] README.md (2305 bytes, hash=0x09a684ebdfbeb01c)
+ [p] block-acl.4th (980 bytes, hash=0xf6cc2a59e3a6734e)
+ [p] sdk.4th (2295 bytes, hash=0x008fdbbb62c94a3a)
+ [p] pki:starshipos-intermediate.der (408 bytes, hash=0xb40aab540c19f877)
+ [p] init-l8-omni.4th (1986 bytes, hash=0x5979e314d6452045)
+ [p] acl-std79.4th (5040 bytes, hash=0x773bf9209df191d1)
+ [p] doe-campaign.4th (2369 bytes, hash=0x26fb485e5c9dc6ff)
+ [p] init-l8-volatile.4th (718 bytes, hash=0x98caabbbd92abac4)
+ [p] doe.4th (3244 bytes, hash=0xf154616d248e861f)
+ [p] fabric.4th (10359 bytes, hash=0x9d9489cbeca4099b)
+ [p] workload-4.4th (469 bytes, hash=0x099619264e650b1c)
+ [p] init-l8-temporal.4th (363 bytes, hash=0x51abd4c138246651)
+ [p] workload-5.4th (480 bytes, hash=0x526964c7c9506a11)
+ [p] fonts:README.md (1846 bytes, hash=0xf628c2b7a49f4d46)
+ [p] fonts:JetBrainsMono-Regular.ttf (270224 bytes, hash=0xf4b7077dab274e6b)
+ [p] init-l8-transition.4th (529 bytes, hash=0xbcc1a81976f0a4c9)
+ [p] workload-2.4th (1321 bytes, hash=0xf113b3d0bcccae47)
+ [p] workload-1.4th (1041 bytes, hash=0x63e251adb0a03613)
+ [p] workload-5-lite.4th (468 bytes, hash=0xea0303f38824f254)
+ [p] workload-0.4th (290 bytes, hash=0x93f86f60aeba8feb)
+ [p] artemis:init.4th (16782 bytes, hash=0x7ba120e2a6aab239)
+ [p] MANIFEST.md (35813 bytes, hash=0x9d3a6fdb7415d224)
+ [p] workload-7.4th (206 bytes, hash=0x02862291387eb7ac)
+ [p] BLOCK_MAP.md (22886 bytes, hash=0x04227af00df2126e)
+ [p] turtle.4th (3254 bytes, hash=0x4d470418ca543365)
+ [p] workload-8.4th (172 bytes, hash=0x56b7f2f0efa000df)
+ [p] workload-6.4th (1986 bytes, hash=0x06fc0ce1e369ef5a)
+mkcapsule: 74 capsule(s) collected
+CC (loader) v3/src/blkio_ram.c
+CC (loader) v3/src/block_subsystem.c
+CC (loader) v3/src/compudynamics.c
+mkcapsule: wrote build/amd64/kernel/capsule_generated.c
+ MKCAP capsules -> capsules/BLOCK_MAP.md
+mkcapsule: manifest written to capsules/BLOCK_MAP.md (40 capsule(s))
+CC (loader) v3/src/dictionary_heat_optimization.c
+CC (loader) v3/src/dictionary_management.c
+CC (loader) v3/src/heartbeat_export.c
+CC (loader) v3/src/inference_engine.c
+CC (loader) v3/src/io.c
+CC (loader) v3/src/math_portable.c
+CC (loader) v3/src/memory_management.c
+CC (loader) v3/src/physics_hotwords_cache.c
+CC (loader) v3/src/physics_execution_hooks.c
+CC (loader) v3/src/physics_metadata.c
+CC (loader) v3/src/physics_pipelining_metrics.c
+CC (loader) v3/src/physics_runtime.c
+CC (loader) v3/src/profiler.c
+CC (loader) v3/src/rolling_window_of_truth.c
+CC (loader) v3/src/ssm_jacquard.c
+CC (loader) v3/src/stack_management.c
+CC (loader) v3/src/vm_api.c
+CC (loader) v3/src/vm_debug.c
+CC (loader) v3/src/word_registry.c
+CC (loader) v3/src/word_source/acl_words.c
+CC (loader) v3/src/word_source/arithmetic_words.c
+CC (loader) v3/src/word_source/block_words.c
+CC (loader) v3/src/word_source/control_words.c
+CC (loader) v3/src/word_source/defer_words.c
+CC (loader) v3/src/word_source/defining_words.c
+CC (loader) v3/src/word_source/dictionary_heat_diagnostic_words.c
+CC (loader) v3/src/word_source/dictionary_manipulation_words.c
+CC (loader) v3/src/word_source/dictionary_words.c
+CC (loader) v3/src/word_source/double_words.c
+CC (loader) v3/src/word_source/editor_words.c
+CC (loader) v3/src/word_source/format_words.c
+CC (loader) v3/src/word_source/framebuffer_words.c
+CC (loader) v3/src/word_source/inference_words.c
+CC (loader) v3/src/word_source/io_words.c
+CC (loader) v3/src/word_source/keyboard_words.c
+CC (loader) v3/src/word_source/lifecycle_words_hosted.c
+CC (loader) v3/src/word_source/log_words.c
+CC (loader) v3/src/word_source/logical_words.c
+CC (loader) v3/src/word_source/memory_words.c
+CC (loader) v3/src/word_source/mixed_arithmetic_words.c
+CC (loader) v3/src/word_source/physics_benchmark_words.c
+CC (loader) v3/src/word_source/physics_diagnostic_words.c
+CC (loader) v3/src/word_source/physics_freeze_words.c
+CC (loader) v3/src/word_source/physics_pipelining_diagnostic_words.c
+CC (loader) v3/src/word_source/q48_words.c
+CC (loader) v3/src/word_source/return_stack_words.c
+CC (loader) v3/src/word_source/scroll_words.c
+CC (loader) v3/src/word_source/stack_words.c
+CC (loader) v3/src/word_source/starforth_words.c
+CC (loader) v3/src/word_source/string_words.c
+CC (loader) v3/src/word_source/system_words.c
+CC (loader) v3/src/word_source/ttf_words.c
+CC (loader) v3/src/word_source/vocabulary_words.c
+CC (loader) v3/src/test_runner/test_common.c
+CC (loader) v3/src/test_runner/test_contracts.c
+CC (loader) v3/src/test_runner/test_runner.c
+CC (loader) v3/src/test_runner/modules/acl_words_test.c
+CC (loader) v3/src/test_runner/modules/arithmetic_words_test.c
+CC (loader) v3/src/test_runner/modules/block_words_test.c
+CC (loader) v3/src/test_runner/modules/control_words_test.c
+CC (loader) v3/src/test_runner/modules/defining_words_tests.c
+CC (loader) v3/src/test_runner/modules/dictionary_manipulation_words_test.c
+CC (loader) v3/src/test_runner/modules/dictionary_words_test.c
+CC (loader) v3/src/test_runner/modules/double_words_test.c
+CC (loader) v3/src/test_runner/modules/format_words_test.c
+CC (loader) v3/src/test_runner/modules/inference_words_test.c
+CC (loader) v3/src/test_runner/modules/integration_tests.c
+CC (loader) v3/src/test_runner/modules/io_words_test.c
+CC (loader) v3/src/test_runner/modules/logical_words_test.c
+CC (loader) v3/src/test_runner/modules/mama_forth_words_test.c
+CC (loader) v3/src/test_runner/modules/memory_words_test.c
+CC (loader) v3/src/test_runner/modules/mixed_arithmetic_words_test.c
+CC (loader) v3/src/test_runner/modules/physics_freeze_words_test.c
+CC (loader) v3/src/test_runner/modules/q48_words_test.c
+CC (loader) v3/src/test_runner/modules/return_stack_words_test.c
+CC (loader) v3/src/test_runner/modules/stack_words_test.c
+CC (loader) v3/src/test_runner/modules/starforth_words_test.c
+CC (loader) v3/src/test_runner/modules/stress_tests.c
+CC (loader) v3/src/test_runner/modules/string_words_test.c
+CC (loader) v3/src/test_runner/modules/system_words_test.c
+ CC build/amd64/kernel/capsule_generated.c
+CC (loader) v3/src/test_runner/modules/vocabulary_words_test.c
+ CC (kernel) build/amd64/kernel/capsule_generated.c
+LD (kernel) build/amd64/kernel/starkernel_kernel.elf
+ld: warning: build/amd64/kernel/obj/kernel/arch/amd64/switch.o: missing .note.GNU-stack section implies executable stack
+ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
+Kernel built: build/amd64/kernel/starkernel_kernel.elf
+LD (loader PE) build/amd64/kernel/starkernel_loader.efi
+Loader built: build/amd64/kernel/starkernel_loader.efi
+StarKernel built successfully for amd64
+ Loader: build/amd64/kernel/starkernel_loader.efi
+ Kernel: build/amd64/kernel/starkernel_kernel.elf
+rc=0
diff --git a/logs/20261118-mkcapsule-overwrite/mesh-boot.log b/logs/20261118-mkcapsule-overwrite/mesh-boot.log
new file mode 100644
index 00000000..56bf384e
--- /dev/null
+++ b/logs/20261118-mkcapsule-overwrite/mesh-boot.log
@@ -0,0 +1,81 @@
+mkcapsule: scanning /home/user/LithosAnanke/capsules
+ [p] zuse.4th (1684 bytes, hash=0x490ded9be257a90b)
+ [p] font.4th (17688 bytes, hash=0x3f305911500c78f6)
+ [p] MANIFEST_AUTO.md (11687 bytes, hash=0xe022545a0755960f)
+ [p] multiuser-doe.4th (3942 bytes, hash=0x22140588ee7c39e6)
+ [p] hestia:init.4th (891 bytes, hash=0x64e111990fbc45ff)
+ [p] contrib:README.md (1855 bytes, hash=0x4212e52b927793e7)
+ [p] ACL.4th (4318 bytes, hash=0xf8890c05c0d8f921)
+ [p] workload-3.4th (2189 bytes, hash=0x62b7a71576ad1041)
+ [p] init-l8-diverse.4th (430 bytes, hash=0xaa293201a6c91838)
+ [p] user-font-demo.4th (1674 bytes, hash=0xce1fd7d1b581a56d)
+ [p] workload-9.4th (1321 bytes, hash=0x3f2bec73142aa424)
+ [p] lib.4th (619 bytes, hash=0x4b216635c359ef73)
+ [p] workload-calib1.4th (304 bytes, hash=0x3b9f2d17b554fabc)
+ [m] init.4th (669 bytes, hash=0xd09db9461b336431)
+ [p] workload-1-lite.4th (540 bytes, hash=0x44a7a7e3176dcc8d)
+ [p] init-l8-stable.4th (278 bytes, hash=0xdc3830f189063a9a)
+ [p] v4:physics.4th (2937 bytes, hash=0x747d89ca8d57e29c)
+ [p] v4:forth79.4th (1208 bytes, hash=0x4055641ee17d176b)
+ [p] v4:sys:log.f18 (4535 bytes, hash=0x544cd004233dff62)
+ [p] v4:sys:qmath.f18 (8607 bytes, hash=0xa93783c2c8f9b7db)
+ [p] v4:sys:map-32.f18 (3162 bytes, hash=0x5bdf8cbbebdd3c8f)
+ [p] v4:sys:blocks.f18 (6112 bytes, hash=0x09d361dbe6174236)
+ [p] v4:sys:input.f18 (10692 bytes, hash=0x0f13c3f9d5fd07fc)
+ [p] v4:sys:dict.f18 (13816 bytes, hash=0xe3453808afd5a0af)
+ [p] v4:sys:forth.f18 (12617 bytes, hash=0xc4c0ad315c95eda4)
+ [p] v4:sys:quit.f18 (32141 bytes, hash=0x7fa7a7668b6bf1ed)
+ [p] v4:sys:map-64.f18 (3201 bytes, hash=0x06cb44832df2b8fd)
+ [p] v4:sys:codegen.f18 (4999 bytes, hash=0x36d2ae84d2911b90)
+ [p] v4:sys:acl.f18 (4100 bytes, hash=0x76e7e746befa2733)
+ [p] v4:sys:core.f18 (24370 bytes, hash=0x0f415502fccc3fba)
+ [p] v4:sys:system.f18 (10189 bytes, hash=0xfe257eb084c43a5d)
+ [p] v4:sys:numout.f18 (6641 bytes, hash=0xca0fb0f9c1589e20)
+ [p] v4:sys:words.f18 (9642 bytes, hash=0x2f4e5f7f3e7f736f)
+ [p] v4:sys:compile.f18 (23099 bytes, hash=0xb46bf77ceee7245a)
+ [p] v4:sys:end.f18 (1452 bytes, hash=0x98fd33b1c431cfe7)
+ [p] v4:starshipos.4th (702 bytes, hash=0x5658ee1b771b5963)
+ [p] v4:hera.4th (1372 bytes, hash=0x85300ad4e6e8b86b)
+ [p] v4:rom:sym.f18 (5610 bytes, hash=0xbbad5748f5bbf863)
+ [p] v4:rom:main.f18 (2284 bytes, hash=0x6994f1f1d567e163)
+ [p] v4:rom:math.f18 (5108 bytes, hash=0x9be63ad87934622f)
+ [p] v4:rom:dir.f18 (5112 bytes, hash=0x51b069f0623ded16)
+ [p] v4:rom:num.f18 (2634 bytes, hash=0x08b76f1b058cac17)
+ [p] v4:rom:pack.f18 (4583 bytes, hash=0x65a944d8eb7de7f2)
+ [p] v4:rom:word.f18 (12966 bytes, hash=0x9210d6c2ac424d11)
+ [p] v4:rom:in.f18 (4230 bytes, hash=0x65798bed38a09f0f)
+ [p] v4:rom:mesh.f18 (449 bytes, hash=0x83723d76b9620c2c)
+ [p] v4:centre.4th (3899 bytes, hash=0xccd1b28a101c78b2)
+ [p] README.md (2305 bytes, hash=0x09a684ebdfbeb01c)
+ [p] block-acl.4th (980 bytes, hash=0xf6cc2a59e3a6734e)
+ [p] sdk.4th (2295 bytes, hash=0x008fdbbb62c94a3a)
+ [p] pki:starshipos-intermediate.der (408 bytes, hash=0xb40aab540c19f877)
+ [p] init-l8-omni.4th (1986 bytes, hash=0x5979e314d6452045)
+ [p] acl-std79.4th (5040 bytes, hash=0x773bf9209df191d1)
+ [p] doe-campaign.4th (2369 bytes, hash=0x26fb485e5c9dc6ff)
+ [p] init-l8-volatile.4th (718 bytes, hash=0x98caabbbd92abac4)
+ [p] doe.4th (3244 bytes, hash=0xf154616d248e861f)
+ [p] fabric.4th (10359 bytes, hash=0x9d9489cbeca4099b)
+ [p] workload-4.4th (469 bytes, hash=0x099619264e650b1c)
+ [p] init-l8-temporal.4th (363 bytes, hash=0x51abd4c138246651)
+ [p] workload-5.4th (480 bytes, hash=0x526964c7c9506a11)
+ [p] fonts:README.md (1846 bytes, hash=0xf628c2b7a49f4d46)
+ [p] fonts:JetBrainsMono-Regular.ttf (270224 bytes, hash=0xf4b7077dab274e6b)
+ [p] init-l8-transition.4th (529 bytes, hash=0xbcc1a81976f0a4c9)
+ [p] workload-2.4th (1321 bytes, hash=0xf113b3d0bcccae47)
+ [p] workload-1.4th (1041 bytes, hash=0x63e251adb0a03613)
+ [p] workload-5-lite.4th (468 bytes, hash=0xea0303f38824f254)
+ [p] workload-0.4th (290 bytes, hash=0x93f86f60aeba8feb)
+ [p] artemis:init.4th (16782 bytes, hash=0x7ba120e2a6aab239)
+ [p] MANIFEST.md (35813 bytes, hash=0x9d3a6fdb7415d224)
+ [p] workload-7.4th (206 bytes, hash=0x02862291387eb7ac)
+ [p] BLOCK_MAP.md (22886 bytes, hash=0x04227af00df2126e)
+ [p] turtle.4th (3254 bytes, hash=0x4d470418ca543365)
+ [p] workload-8.4th (172 bytes, hash=0x56b7f2f0efa000df)
+ [p] workload-6.4th (1986 bytes, hash=0x06fc0ce1e369ef5a)
+mkcapsule: 74 capsule(s) collected
+mkcapsule: wrote /home/user/LithosAnanke/v4/build/capsule_generated.c
+ [mesh boot, V4_CELL_BITS=64]
+v4 mesh boot: V4_CELL_BITS=64
+ PARITY:V4_POST tests=990 pass=990 fail=0
+ 109 checks, 0 failures
diff --git a/logs/20261118-mkcapsule-overwrite/test-after.log b/logs/20261118-mkcapsule-overwrite/test-after.log
new file mode 100644
index 00000000..316ee593
--- /dev/null
+++ b/logs/20261118-mkcapsule-overwrite/test-after.log
@@ -0,0 +1,9 @@
+PASS: two capsules sharing a block number build
+PASS: one capsule repeating a block number builds
+PASS: a page in a once-reserved range builds
+PASS: and tools/capsule-reserved.txt is gone
+PASS: --resolve is no longer a mode: it is answered with the usage
+PASS: and the tool has no such mode
+PASS: the map says Blocks used
+PASS: and calls no number a conflict
+RESULT: PASS
diff --git a/logs/20261118-mkcapsule-overwrite/test-before.log b/logs/20261118-mkcapsule-overwrite/test-before.log
new file mode 100644
index 00000000..785ef341
--- /dev/null
+++ b/logs/20261118-mkcapsule-overwrite/test-before.log
@@ -0,0 +1,9 @@
+FAIL: two capsules sharing a block number build
+PASS: one capsule repeating a block number builds
+FAIL: a page in a once-reserved range builds
+FAIL: and tools/capsule-reserved.txt is gone
+FAIL: --resolve is no longer a mode: it is answered with the usage
+FAIL: and the tool has no such mode
+FAIL: the map says Blocks used
+FAIL: and calls no number a conflict
+RESULT: FAIL
diff --git a/scripts/test_mkcapsule_overwrite.sh b/scripts/test_mkcapsule_overwrite.sh
new file mode 100755
index 00000000..d9acba38
--- /dev/null
+++ b/scripts/test_mkcapsule_overwrite.sh
@@ -0,0 +1,55 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LicenseRef-Starship-1.0
+# Copyright (c) 2023-2026 Robert A. James
+# test_mkcapsule_overwrite.sh -- the tests of capsule blocks step 2
+# (docs/v4.0.0/plans/2026-11-18-capsule-blocks.md). Captain Bob: "Overwrite. That's it.
+# Deterministic and final." -- within a capsule and across capsules, "consistent with VOCABULARY
+# FORGET & FENCE philosophy, not implementation"; and of what only prevents collisions: "All of it
+# goes".
+#
+# What is checked, mkcapsule run from the repository root (where it reads tools/):
+# - two capsules sharing a block number build;
+# - one capsule repeating a block number builds;
+# - a page in a range capsule-reserved.txt held builds, and that file is gone;
+# - --resolve is no longer a mode;
+# - the map says "Blocks used", and calls no number a conflict.
+#
+# No QEMU. Prints PASS:/FAIL: per check and RESULT:; exits 0 only if every check passes.
+set -uo pipefail
+ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+T=$(mktemp -d)
+trap 'rm -rf "$T"' EXIT
+ok=1
+check() { if eval "$2"; then echo "PASS: $1"; else echo "FAIL: $1"; ok=0; fi; }
+
+MK="$T/mkcapsule"
+cc -std=c99 -O2 -I"$ROOT/v3/include" -I"$ROOT/kernel/include" -I"$ROOT/tools" -o "$MK" \
+ "$ROOT/tools/mkcapsule.c" "$ROOT/tools/pkcs8_ed25519.c" "$ROOT/kernel/src/crypto/ed25519.c" \
+ "$ROOT/kernel/src/crypto/fe25519.c" "$ROOT/kernel/src/crypto/scalar25519.c" \
+ "$ROOT/kernel/src/crypto/sha512.c" "$ROOT/kernel/src/crypto/x509_ed25519.c" 2> "$T/cc.log"
+build() { (cd "$ROOT" && "$MK" "$1" "$T/out.c" > "$T/build.log" 2>&1); } # build
+
+mkdir -p "$T/shared"
+printf 'Block 3000\n( first capsule )\n' > "$T/shared/a.4th"
+printf 'Block 3000\n( second capsule, the same number )\n' > "$T/shared/b.4th"
+check "two capsules sharing a block number build" 'build "$T/shared"'
+
+mkdir -p "$T/repeat"
+printf 'Block 3000\n( once )\nBlock 3000\n( again )\n' > "$T/repeat/r.4th"
+check "one capsule repeating a block number builds" 'build "$T/repeat"'
+
+mkdir -p "$T/reserved"
+printf 'Block 4300\n( where process.4th was )\n' > "$T/reserved/p.4th"
+check "a page in a once-reserved range builds" 'build "$T/reserved"'
+check " and tools/capsule-reserved.txt is gone" '[ ! -e "$ROOT/tools/capsule-reserved.txt" ]'
+
+(cd "$ROOT" && "$MK" --resolve "$T/shared" < /dev/null > "$T/resolve.log" 2>&1)
+check "--resolve is no longer a mode: it is answered with the usage" 'grep -q "^Usage" "$T/resolve.log" && ! grep -q -i "conflict\|renumber" "$T/resolve.log"'
+check " and the tool has no such mode" '! grep -q -- "--resolve" "$ROOT/tools/mkcapsule.c"'
+
+(cd "$ROOT" && "$MK" --manifest "$T/shared" "$T/map.md" > /dev/null 2>&1)
+check "the map says Blocks used" 'grep -q "Blocks used" "$T/map.md" 2>/dev/null'
+check " and calls no number a conflict" '! grep -q -i "conflict\|claimed" "$T/map.md" 2>/dev/null'
+
+if [ $ok = 1 ]; then echo "RESULT: PASS"; else echo "RESULT: FAIL"; fi
+[ $ok = 1 ]
diff --git a/tools/capsule-reserved.txt b/tools/capsule-reserved.txt
deleted file mode 100644
index 4de9ba40..00000000
--- a/tools/capsule-reserved.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# capsule-reserved.txt — human-authored, git-tracked block ranges NOT
-# owned by any capsule (FABRIC-3.md §XXIV, 2026-09-12).
-#
-# mkcapsule can already catch a capsule colliding with ANOTHER capsule --
-# every capsule is a .4th file it scans. It has zero visibility into a
-# block something else owns: Artemis's own non-capsule persistent data
-# (identity records, home-blocks fence, etc.), or anything similar added
-# later. This file is how a human tells it.
-#
-# Format, one range per line:
-# START-END description
-#
-# START and END are inclusive logical block numbers (LBN). Lines starting
-# with '#' and blank lines are ignored. Checked by both the plain build
-# gate (check_reserved_conflicts(), hard-fails on collision) and
-# `mkcapsule --resolve` (suggests renumbering around these too).
-#
-# Known device boundaries, for reference when adding entries (not
-# reserved ranges themselves -- ramdrive is legitimately shared/reused by
-# capsules; only entries below reserve anything):
-# 2048-3071 volatile ramdrive (capsule_loader.c, KRD_MAX_BLOCKS=1024)
-# 3072+ Artemis's real virtio-blk device (persistent, disk/artemis.img)
-#
-# No ranges reserved yet for non-capsule infrastructure (Artemis's own
-# actual block usage becomes known from block_subsystem.c's BAM/
-# home-blocks fence accounting, not guessed) -- but see below for a
-# second, narrower use: recording a block range a capsule strip just
-# freed, so mkcapsule's collision machinery won't let a future capsule
-# silently reclaim it before a human decides to (FABRIC-3.5.md SXXII.4,
-# SXVIII.4). These are lifted, not permanent, once someone deliberately
-# wants the range back.
-
-# Freed 2026-09-19 by the Tripod/kernel reshuffle's Category A surgical
-# strip (FABRIC-3.6.md tasks 0.2/0.3; see capsules/MANIFEST.md's
-# "Deleted capsules" section for the full account):
-4055-4059 formerly common/msg.4th -- deleted, block content confirmed dead by all three FABRIC-3.5.md SXXII.2 routes
-4300-4399 formerly process.4th -- deleted, block content confirmed dead by all three FABRIC-3.5.md SXXII.2 routes
diff --git a/tools/mkcapsule.c b/tools/mkcapsule.c
index 9ffa5e1f..548f8677 100644
--- a/tools/mkcapsule.c
+++ b/tools/mkcapsule.c
@@ -12,18 +12,10 @@
mkcapsule --lint lint all .4th files
mkcapsule --manifest print block manifest to stdout
mkcapsule --manifest write block manifest to file
- mkcapsule --resolve interactive block-conflict
- resolver (FABRIC-3.md SXXIV)
- --resolve is the only interactive mode -- never part of the plain build
- path above, which stays non-interactive so CI/unattended builds never
- block on a prompt. It maintains tools/capsule-claims.txt (auto-created,
- derived, git-ignored) and checks against tools/capsule-reserved.txt
- (human-authored, git-tracked, blocks something other than a capsule
- owns -- e.g. Artemis's own non-capsule persistent data). On a genuine
- conflict it suggests a renumbering that preserves the capsule's own
- existing block spacing, prompts y/N, and on acceptance rewrites the
- .4th source in place and records the decision in tools/patches/.
+ A block number is not a claim: a later write to a number overwrites it,
+ within a capsule or across capsules (docs/v4.0.0/plans/
+ 2026-11-18-capsule-blocks.md). No mode refuses a shared number.
Build mode generates a C source file containing:
- capsule_arena[] (all payload bytes concatenated)
@@ -32,9 +24,8 @@
- capsule_directory (CapsuleDirHeader)
Manifest mode generates a markdown block ownership index:
- - Capsule summary (name, blocks claimed, xxHash64)
- - Block map sorted by LBN with conflict detection
- - Conflict register
+ - Capsule summary (name, blocks used, xxHash64)
+ - Block map sorted by LBN (a convenience; a shared number is shown, not refused)
The xxHash64 column is the anchor for future Ed25519 fingerprints (Phase 8).
Name encoding: relative path from capsules_dir root, '/' replaced by ':'.
@@ -768,7 +759,7 @@ static void generate_manifest(FILE *out) {
/* Capsule summary */
fprintf(out, "## Capsule Summary\n\n");
- fprintf(out, "| Capsule | Blocks claimed | xxHash64 | Signed |\n");
+ fprintf(out, "| Capsule | Blocks used | xxHash64 | Signed |\n");
fprintf(out, "|---------|----------------|----------|--------|\n");
for (int i = 0; i < manifest_count; i++) {
ManifestEntry *e = &manifest_entries[i];
@@ -799,43 +790,14 @@ static void generate_manifest(FILE *out) {
for (int i = 0; i < ref_count; i++) {
int lbn = refs[i].lbn;
ManifestEntry *e = &manifest_entries[refs[i].idx];
- int conflict = (i > 0 && refs[i-1].lbn == lbn) ||
- (i < ref_count - 1 && refs[i+1].lbn == lbn);
+ int shared = (i > 0 && refs[i-1].lbn == lbn) ||
+ (i < ref_count - 1 && refs[i+1].lbn == lbn);
fprintf(out, "| %d | `%s` | `0x%016" PRIx64 "` | %s |\n",
lbn, e->name, e->hash,
- conflict ? "CONFLICT" : "ok");
+ shared ? "shared: the later write overwrites" : "ok");
}
fprintf(out, "\n");
- /* Conflict register */
- int any = 0;
- for (int i = 0; i + 1 < ref_count; i++)
- if (refs[i].lbn == refs[i+1].lbn) { any = 1; break; }
-
- fprintf(out, "## Conflicts\n\n");
- if (!any) {
- fprintf(out, "None.\n\n");
- } else {
- fprintf(out, "| LBN | Capsules |\n");
- fprintf(out, "|-----|----------|\n");
- int i = 0;
- while (i < ref_count) {
- int lbn = refs[i].lbn;
- int j = i;
- while (j < ref_count && refs[j].lbn == lbn) j++;
- if (j - i > 1) {
- fprintf(out, "| %d | ", lbn);
- for (int k = i; k < j; k++) {
- if (k > i) fprintf(out, ", ");
- fprintf(out, "`%s`", manifest_entries[refs[k].idx].name);
- }
- fprintf(out, " |\n");
- }
- i = j;
- }
- fprintf(out, "\n");
- }
-
fprintf(out, "---\n");
fprintf(out,
"*%d capsule(s) scanned. "
@@ -844,521 +806,19 @@ static void generate_manifest(FILE *out) {
}
/*===========================================================================
- * Block Conflict Gate
+ * No claims on block numbers (docs/v4.0.0/plans/2026-11-18-capsule-blocks.md)
*
- * Runs the same block-collision scan as --manifest, but as a hard build
- * gate: any two capsules claiming the same LBN fail the build outright.
- * This exists because the ordinary build path (process_file / nftw below)
- * bakes capsules with zero collision checking, which is exactly how two
- * real bugs (Hermes vs Artemis; workload-6.4th/init-l8-omni.4th vs init.4th)
- * went undetected for days until someone happened to run --manifest by
- * hand. See capsules/MANIFEST.md Conflict Register C1/C2/C5.
+ * A capsule page `Block n` is written to block n and copied down to be
+ * interpreted. A later write to a number already used overwrites it --
+ * within one capsule or across capsules -- deterministically, in the
+ * fixed load order (Captain Bob: "Overwrite. That's it. Deterministic and
+ * final"; "consistent with VOCABULARY FORGET & FENCE philosophy, not
+ * implementation"). So nothing here refuses a shared number: the collision
+ * gate, the reserved ranges (tools/capsule-reserved.txt) and the
+ * interactive renumbering resolver, with its claim registry, are gone
+ * ("All of it goes"). The manifest still lists the numbers each capsule
+ * uses, as a convenience ("Block map is a convenience").
*===========================================================================*/
-static int check_block_conflicts(void) {
- manifest_count = 0;
- if (nftw(base_dir, manifest_file, 20, FTW_PHYS) != 0) {
- fprintf(stderr, "mkcapsule: ERROR: directory scan failed during conflict check\n");
- return 1;
- }
-
- static BlockRef refs[MAX_CAPSULES * MAX_BLOCKS_PER_CAPSULE];
- int ref_count = 0;
- for (int i = 0; i < manifest_count; i++) {
- for (int j = 0; j < manifest_entries[i].block_count; j++) {
- refs[ref_count].lbn = manifest_entries[i].blocks[j];
- refs[ref_count].idx = i;
- ref_count++;
- }
- }
- qsort(refs, (size_t)ref_count, sizeof(BlockRef), cmp_blockref);
-
- int conflicts = 0;
- int i = 0;
- while (i < ref_count) {
- int lbn = refs[i].lbn;
- int j = i;
- while (j < ref_count && refs[j].lbn == lbn) j++;
- if (j - i > 1) {
- fprintf(stderr, "mkcapsule: ERROR: block %d claimed by %d capsules: ",
- lbn, j - i);
- for (int k = i; k < j; k++) {
- if (k > i) fprintf(stderr, ", ");
- fprintf(stderr, "%s", manifest_entries[refs[k].idx].name);
- }
- fprintf(stderr, "\n");
- conflicts++;
- }
- i = j;
- }
-
- if (conflicts > 0) {
- fprintf(stderr,
- "mkcapsule: ERROR: %d block conflict(s) found — resolve in the\n"
- " .4th source (renumber one side) and in capsules/MANIFEST.md\n"
- " before building. Run `mkcapsule --manifest %s` for the full\n"
- " report.\n",
- conflicts, base_dir);
- }
-
- return conflicts > 0 ? 1 : 0;
-}
-
-/*===========================================================================
- * Reserved Ranges (FABRIC-3.md SXXIV, 2026-09-12)
- *
- * capsule-reserved.txt is human-authored and git-tracked -- mkcapsule can
- * discover collisions between capsules on its own (they're all .4th files
- * it scans), but it has zero visibility into blocks something OTHER than a
- * capsule owns (Artemis's own non-capsule identity/home-blocks data, e.g.)
- * unless a human tells it. Never auto-created, never auto-modified: a
- * missing file just means "nothing reserved yet," not an error.
- *===========================================================================*/
-#define RESERVED_FILE_PATH "tools/capsule-reserved.txt"
-#define CLAIMS_FILE_PATH "tools/capsule-claims.txt"
-#define PATCHES_DIR_PATH "tools/patches"
-#define MAX_RESERVED_RANGES 256
-
-typedef struct {
- int start;
- int end; /* inclusive */
- char desc[256];
-} ReservedRange;
-
-static ReservedRange reserved_ranges[MAX_RESERVED_RANGES];
-static int reserved_count = 0;
-
-/* load_reserved_ranges: parse "START-END description" lines, '#'-comments
- * and blank lines ignored. Missing file -> reserved_count stays 0, silently
- * (this file is optional until a human seeds it). */
-static void load_reserved_ranges(const char *path) {
- reserved_count = 0;
- FILE *f = fopen(path, "r");
- if (!f) return;
-
- char line[512];
- while (fgets(line, sizeof(line), f)) {
- char *p = line;
- while (*p == ' ' || *p == '\t') p++;
- if (*p == '#' || *p == '\n' || *p == '\0') continue;
-
- int start = 0, end = 0;
- int consumed = 0;
- if (sscanf(p, "%d-%d%n", &start, &end, &consumed) != 2) continue;
- if (reserved_count >= MAX_RESERVED_RANGES) break;
-
- ReservedRange *r = &reserved_ranges[reserved_count];
- r->start = start;
- r->end = end;
- p += consumed;
- while (*p == ' ' || *p == '\t') p++;
- size_t dlen = strcspn(p, "\r\n");
- if (dlen >= sizeof(r->desc)) dlen = sizeof(r->desc) - 1;
- memcpy(r->desc, p, dlen);
- r->desc[dlen] = '\0';
- reserved_count++;
- }
- fclose(f);
-}
-
-/* reserved_owner_of: returns the reserved range covering lbn, or NULL. */
-static const ReservedRange *reserved_owner_of(int lbn) {
- for (int i = 0; i < reserved_count; i++) {
- if (lbn >= reserved_ranges[i].start && lbn <= reserved_ranges[i].end)
- return &reserved_ranges[i];
- }
- return NULL;
-}
-
-/* check_reserved_conflicts: hard build-gate companion to
- * check_block_conflicts() -- same manifest_entries scan, checked against
- * capsule-reserved.txt instead of against each other. Call AFTER
- * check_block_conflicts() has already populated manifest_entries via its
- * own nftw scan (avoids scanning the directory twice). */
-static int check_reserved_conflicts(void) {
- load_reserved_ranges(RESERVED_FILE_PATH);
- if (reserved_count == 0) return 0;
-
- int conflicts = 0;
- for (int i = 0; i < manifest_count; i++) {
- for (int j = 0; j < manifest_entries[i].block_count; j++) {
- int lbn = manifest_entries[i].blocks[j];
- const ReservedRange *r = reserved_owner_of(lbn);
- if (r) {
- fprintf(stderr,
- "mkcapsule: ERROR: block %d (%s) falls inside reserved "
- "range %d-%d: %s\n",
- lbn, manifest_entries[i].name, r->start, r->end, r->desc);
- conflicts++;
- }
- }
- }
- if (conflicts > 0) {
- fprintf(stderr,
- "mkcapsule: ERROR: %d capsule block(s) collide with reserved "
- "ranges in %s\n", conflicts, RESERVED_FILE_PATH);
- }
- return conflicts > 0 ? 1 : 0;
-}
-
-/*===========================================================================
- * Claim Registry + Interactive Resolve (mkcapsule --resolve)
- *
- * capsule-claims.txt is auto-created/regenerated -- pure derived state,
- * never hand-edited, git-ignored. Unlike the plain build gate (which just
- * re-scans and hard-fails every time, no memory needed), --resolve needs
- * to tell "this capsule's own content changed" apart from "a genuinely new
- * collision with something else," which needs the previous run's state.
- *===========================================================================*/
-typedef struct {
- char name[CAPSULE_NAME_MAX];
- uint64_t hash;
- int blocks[MAX_BLOCKS_PER_CAPSULE];
- int block_count;
-} ClaimEntry;
-
-static ClaimEntry claim_registry[MAX_CAPSULES];
-static int claim_count = 0;
-
-static ClaimEntry *find_claim(const char *name) {
- for (int i = 0; i < claim_count; i++) {
- if (strcmp(claim_registry[i].name, name) == 0) return &claim_registry[i];
- }
- return NULL;
-}
-
-/* load_claims_registry: parse " ,,..." lines.
- * Missing file -> claim_count stays 0 (fresh baseline, not an error --
- * this is the auto-create case). */
-static void load_claims_registry(const char *path) {
- claim_count = 0;
- FILE *f = fopen(path, "r");
- if (!f) return;
-
- char line[2048];
- while (fgets(line, sizeof(line), f)) {
- if (line[0] == '#' || line[0] == '\n' || line[0] == '\0') continue;
- if (claim_count >= MAX_CAPSULES) break;
-
- char name[CAPSULE_NAME_MAX];
- char hashbuf[32];
- char blocklist[1600] = "";
- int nf = sscanf(line, "%511s %31s %1599[^\n]", name, hashbuf, blocklist);
- if (nf < 2) continue; /* nf==3 has a block list; nf==2 is a valid
- * empty-block-list entry (raw code capsule,
- * no "Block N" headers at all) */
-
- ClaimEntry *e = &claim_registry[claim_count];
- snprintf(e->name, CAPSULE_NAME_MAX, "%s", name);
- e->hash = strtoull(hashbuf, NULL, 16);
- e->block_count = 0;
-
- char *tok = strtok(blocklist, ",");
- while (tok && e->block_count < MAX_BLOCKS_PER_CAPSULE) {
- while (*tok == ' ') tok++; /* defensive: tolerate stray
- * whitespace from older/
- * hand-written registry files */
- if (*tok == '\0') { tok = strtok(NULL, ","); continue; }
- e->blocks[e->block_count++] = (int)strtol(tok, NULL, 10);
- tok = strtok(NULL, ",");
- }
- claim_count++;
- }
- fclose(f);
-}
-
-static void save_claims_registry(const char *path) {
- FILE *f = fopen(path, "w");
- if (!f) {
- fprintf(stderr, "mkcapsule: WARNING: could not write %s\n", path);
- return;
- }
- fprintf(f, "# DO NOT EDIT — re-run mkcapsule --resolve to refresh.\n"
- "# This file is derived state, not a source of truth (the\n"
- "# .4th files themselves are) -- git-ignored on purpose.\n");
- for (int i = 0; i < claim_count; i++) {
- ClaimEntry *e = &claim_registry[i];
- fprintf(f, "%s %016" PRIx64, e->name, e->hash);
- for (int j = 0; j < e->block_count; j++) {
- fprintf(f, "%s%d", j == 0 ? " " : ",", e->blocks[j]);
- }
- fprintf(f, "\n");
- }
- fclose(f);
-}
-
-/* blocks_free_at_delta: true if shifting every block in `blocks` by `delta`
- * lands on numbers that are simultaneously free -- not claimed by any OTHER
- * current capsule (manifest_entries, ground truth for this run, excluding
- * `skip_idx` itself) and not inside a reserved range. */
-static int blocks_free_at_delta(const int *blocks, int block_count, int delta,
- int skip_idx) {
- for (int j = 0; j < block_count; j++) {
- int candidate = blocks[j] + delta;
- if (candidate < (int)BLK_RAM_USER_BLOCKS) return 0; /* the VM's fast RAM: the build's knob (blk_layout.h) */
- if (reserved_owner_of(candidate)) return 0;
- for (int i = 0; i < manifest_count; i++) {
- if (i == skip_idx) continue;
- for (int k = 0; k < manifest_entries[i].block_count; k++) {
- if (manifest_entries[i].blocks[k] == candidate) return 0;
- }
- }
- /* also check other candidates within the SAME shifted set don't
- * collide with each other (only possible if the caller passes a
- * pathological blocks[] with duplicate relative offsets) */
- for (int j2 = 0; j2 < j; j2++) {
- if (blocks[j2] + delta == candidate) return 0;
- }
- }
- return 1;
-}
-
-/* suggest_renumbering: preserves the capsule's own existing relative
- * spacing (workload-3.4th's 4606,4615,4625,... convention, e.g.) by
- * searching for a single shift delta that lands every block on free
- * ground at once, rather than reassigning each block independently. */
-#define MAX_DELTA_SEARCH 20000
-static int suggest_renumbering(const int *blocks, int block_count,
- int skip_idx, int *out_delta) {
- for (int delta = 0; delta <= MAX_DELTA_SEARCH; delta += 1) {
- if (blocks_free_at_delta(blocks, block_count, delta, skip_idx)) {
- *out_delta = delta;
- return 1;
- }
- }
- return 0;
-}
-
-/* rewrite_block_headers: in-place rewrite of a capsule's own "Block N"
- * header lines to "Block N+delta", preserving everything else in the file
- * byte-for-byte (content, comments, formatting). Returns 1 on success. */
-static int rewrite_block_headers(const char *fpath, int delta) {
- FILE *f = fopen(fpath, "rb");
- if (!f) return 0;
- fseek(f, 0, SEEK_END);
- long sz = ftell(f);
- rewind(f);
- uint8_t *data = malloc((size_t)sz + 1);
- if (!data || fread(data, 1, (size_t)sz, f) != (size_t)sz) {
- free(data); fclose(f); return 0;
- }
- fclose(f);
-
- FILE *out = fopen(fpath, "wb");
- if (!out) { free(data); return 0; }
-
- size_t pos = 0;
- while (pos < (size_t)sz) {
- size_t start = pos;
- while (pos < (size_t)sz && data[pos] != '\n') pos++;
- size_t line_len = pos - start;
- int has_nl = (pos < (size_t)sz);
-
- if (line_len >= 7 &&
- data[start+0]=='B' && data[start+1]=='l' && data[start+2]=='o' &&
- data[start+3]=='c' && data[start+4]=='k' && data[start+5]==' ') {
- int bn = (int)strtol((const char *)(data + start + 6), NULL, 10);
- fprintf(out, "Block %d", bn + delta);
- } else {
- fwrite(data + start, 1, line_len, out);
- }
- if (has_nl) { fputc('\n', out); pos++; }
- }
- fclose(out);
- free(data);
- return 1;
-}
-
-/* write_renumber_patch: permanent, git-tracked decision record -- not a
- * generic diff (the only thing a renumber ever changes is Block header
- * integers, so a structured before/after list is more directly useful
- * than a line diff would be). */
-static void write_renumber_patch(const char *capsule_name, const int *old_blocks,
- int block_count, int delta,
- const char *reason) {
- mkdir(PATCHES_DIR_PATH, 0755); /* ignore EEXIST */
-
- time_t now = time(NULL);
- struct tm *tm_ptr = gmtime(&now);
- char stamp[32];
- strftime(stamp, sizeof(stamp), "%Y%m%dT%H%M%SZ", tm_ptr);
-
- char safe_name[CAPSULE_NAME_MAX];
- size_t k;
- for (k = 0; capsule_name[k] && k < sizeof(safe_name) - 1; k++) {
- char c = capsule_name[k];
- safe_name[k] = (c == '/' || c == ':') ? '_' : c;
- }
- safe_name[k] = '\0';
-
- char path[MAX_PATH_LEN];
- snprintf(path, sizeof(path), "%s/%s-%s.patch", PATCHES_DIR_PATH, stamp, safe_name);
-
- FILE *f = fopen(path, "w");
- if (!f) {
- fprintf(stderr, "mkcapsule: WARNING: could not write patch record %s\n", path);
- return;
- }
- fprintf(f, "# mkcapsule --resolve renumber patch\n");
- fprintf(f, "# capsule: %s\n", capsule_name);
- fprintf(f, "# timestamp: %s\n", stamp);
- fprintf(f, "# reason: %s\n", reason);
- for (int j = 0; j < block_count; j++) {
- fprintf(f, "%d -> %d\n", old_blocks[j], old_blocks[j] + delta);
- }
- fclose(f);
- fprintf(stderr, "mkcapsule: wrote patch record %s\n", path);
-}
-
-/* prompt_yes_no: reads one line from stdin, true only on 'y'/'Y'. */
-static int prompt_yes_no(const char *question) {
- fprintf(stderr, "%s [y/N] ", question);
- char reply[16];
- if (!fgets(reply, sizeof(reply), stdin)) return 0;
- return (reply[0] == 'y' || reply[0] == 'Y');
-}
-
-/* cmd_resolve: mkcapsule --resolve -- see main()'s usage text and
- * FABRIC-3.md SXXIV for the full design. Deliberately the ONLY interactive
- * mkcapsule mode; the plain build path (check_block_conflicts/
- * check_reserved_conflicts) stays non-interactive so CI/unattended builds
- * never block on a prompt. */
-static int cmd_resolve(const char *dir) {
- base_dir = dir;
- base_dir_len = strlen(base_dir);
- while (base_dir_len > 0 && base_dir[base_dir_len - 1] == '/') base_dir_len--;
-
- manifest_count = 0;
- if (nftw(base_dir, manifest_file, 20, FTW_PHYS) != 0) {
- fprintf(stderr, "mkcapsule: ERROR: directory scan failed\n");
- return 1;
- }
-
- load_reserved_ranges(RESERVED_FILE_PATH);
-
- int fresh_registry = (access(CLAIMS_FILE_PATH, F_OK) != 0);
- load_claims_registry(CLAIMS_FILE_PATH);
- if (fresh_registry) {
- fprintf(stderr, "mkcapsule --resolve: %s not found, creating fresh "
- "baseline from current state\n", CLAIMS_FILE_PATH);
- }
-
- int registered = 0, updated = 0, resolved = 0, rejected = 0;
-
- for (int i = 0; i < manifest_count; i++) {
- ManifestEntry *m = &manifest_entries[i];
- ClaimEntry *prior = find_claim(m->name);
-
- if (prior && prior->hash == m->hash &&
- prior->block_count == m->block_count &&
- memcmp(prior->blocks, m->blocks,
- (size_t)m->block_count * sizeof(int)) == 0) {
- continue; /* unchanged, nothing to do */
- }
-
- /* Does this capsule's CURRENT block set collide with anything else
- * live right now (ground truth = this run's fresh scan), or with
- * a reserved range? Fresh-registered-or-updated-in-place capsules
- * whose own new content simply doesn't collide need no prompt --
- * only an actual collision needs a human decision. */
- int collides = 0;
- for (int j = 0; j < m->block_count && !collides; j++) {
- int lbn = m->blocks[j];
- if (reserved_owner_of(lbn)) { collides = 1; break; }
- for (int k = 0; k < manifest_count; k++) {
- if (k == i) continue;
- for (int b = 0; b < manifest_entries[k].block_count; b++) {
- if (manifest_entries[k].blocks[b] == lbn) { collides = 1; break; }
- }
- if (collides) break;
- }
- }
-
- if (!collides) {
- ClaimEntry *dest = prior ? prior : &claim_registry[claim_count++];
- memcpy(dest->name, m->name, CAPSULE_NAME_MAX); /* same-sized arrays: a whole copy, no truncation (#143) */
- dest->hash = m->hash;
- dest->block_count = m->block_count;
- memcpy(dest->blocks, m->blocks, (size_t)m->block_count * sizeof(int));
- if (prior) { updated++; fprintf(stderr, "mkcapsule --resolve: %s updated (no conflict)\n", m->name); }
- else { registered++; fprintf(stderr, "mkcapsule --resolve: %s registered\n", m->name); }
- continue;
- }
-
- /* Real conflict -- try to suggest a renumbering. */
- fprintf(stderr, "\nmkcapsule --resolve: CONFLICT for %s:\n", m->name);
- for (int j = 0; j < m->block_count; j++) {
- int lbn = m->blocks[j];
- const ReservedRange *r = reserved_owner_of(lbn);
- if (r) {
- fprintf(stderr, " block %d is reserved: %s\n", lbn, r->desc);
- continue;
- }
- for (int k = 0; k < manifest_count; k++) {
- if (k == i) continue;
- for (int b = 0; b < manifest_entries[k].block_count; b++) {
- if (manifest_entries[k].blocks[b] == lbn) {
- fprintf(stderr, " block %d also claimed by %s\n",
- lbn, manifest_entries[k].name);
- }
- }
- }
- }
-
- int delta;
- if (suggest_renumbering(m->blocks, m->block_count, i, &delta)) {
- fprintf(stderr, " suggested renumbering (shift by %+d):\n", delta);
- for (int j = 0; j < m->block_count; j++) {
- fprintf(stderr, " %d -> %d\n", m->blocks[j], m->blocks[j] + delta);
- }
- char fpath[MAX_PATH_LEN];
- int flen = snprintf(fpath, sizeof(fpath), "%s/%s", base_dir, m->name);
- if (flen < 0 || (size_t)flen >= sizeof(fpath)) { /* a cut path names another file (#143) */
- fprintf(stderr, " ERROR: the path of %s is longer than %d bytes -- left unchanged\n",
- m->name, MAX_PATH_LEN - 1);
- rejected++;
- continue;
- }
- /* capsule name uses ':' for subdirectories; the real path uses '/' */
- for (char *p = fpath; *p; p++) if (*p == ':') *p = '/';
-
- if (prompt_yes_no(" Accept this renumbering?")) {
- if (rewrite_block_headers(fpath, delta)) {
- char reason[256];
- snprintf(reason, sizeof(reason),
- "block conflict, resolved via --resolve");
- write_renumber_patch(m->name, m->blocks, m->block_count,
- delta, reason);
- for (int j = 0; j < m->block_count; j++) m->blocks[j] += delta;
- ClaimEntry *dest = prior ? prior : &claim_registry[claim_count++];
- memcpy(dest->name, m->name, CAPSULE_NAME_MAX); /* as below: same-sized arrays (#143) */
- dest->hash = m->hash;
- dest->block_count = m->block_count;
- memcpy(dest->blocks, m->blocks, (size_t)m->block_count * sizeof(int));
- resolved++;
- } else {
- fprintf(stderr, " ERROR: could not rewrite %s\n", fpath);
- rejected++;
- }
- } else {
- fprintf(stderr, " rejected -- %s left unchanged\n", m->name);
- rejected++;
- }
- } else {
- fprintf(stderr, " no free renumbering found within +%d of any "
- "existing block -- resolve %s by hand\n",
- MAX_DELTA_SEARCH, m->name);
- rejected++;
- }
- }
-
- save_claims_registry(CLAIMS_FILE_PATH);
-
- fprintf(stderr, "\nmkcapsule --resolve: %d registered, %d updated, "
- "%d resolved, %d rejected/unresolved\n",
- registered, updated, resolved, rejected);
- return rejected > 0 ? 1 : 0;
-}
-
/*===========================================================================
* C Source Generation
*===========================================================================*/
@@ -1654,15 +1114,6 @@ int main(int argc, char **argv) {
return 0;
}
- /* --resolve mode: interactive block-conflict resolver (FABRIC-3.md
- * SXXIV). The ONLY interactive mkcapsule mode -- deliberately a
- * separate, deliberate invocation, never part of the plain `make`
- * build path (that stays non-interactive so CI/unattended builds
- * never block on a prompt). */
- if (argc == 3 && strcmp(argv[1], "--resolve") == 0) {
- return cmd_resolve(argv[2]);
- }
-
/* --lint mode: validate all .4th files without generating C output */
if (argc == 3 && strcmp(argv[1], "--lint") == 0) {
base_dir = argv[2];
@@ -1682,6 +1133,13 @@ int main(int argc, char **argv) {
* [--sign-key ] . Read once here,
* not per-capsule -- process_file() just checks have_sign_seed. */
int arg0 = 1;
+ /* An option this tool does not have is refused with the usage, never
+ * taken for the capsules directory (a removed mode, such as the old resolver,
+ * would otherwise name the output file). */
+ if (argc >= 2 && argv[1][0] == '-' && argv[1][1] == '-'
+ && strcmp(argv[1], "--sign-key") != 0) {
+ argc = 0; /* to the usage below */
+ }
if (argc >= 2 && strcmp(argv[1], "--sign-key") == 0) {
if (argc != 5) {
fprintf(stderr, "mkcapsule: ERROR: --sign-key requires "
@@ -1700,8 +1158,6 @@ int main(int argc, char **argv) {
" %s --lint lint all .4th files\n"
" %s --manifest [--sign-key ] []\n"
" print/write block manifest\n"
- " %s --resolve interactive block-conflict\n"
- " resolver (see file header)\n"
"\n"
"Lint checks (per .4th file):\n"
" - each block opens with 'Block N'\n"
@@ -1710,14 +1166,13 @@ int main(int argc, char **argv) {
" - every line terminated with newline\n"
"\n"
"Manifest output:\n"
- " - capsule summary (name, blocks claimed, xxHash64)\n"
- " - block map sorted by LBN with conflict detection\n"
- " - conflict register\n"
+ " - capsule summary (name, blocks used, xxHash64)\n"
+ " - block map sorted by LBN (a shared number: the later write overwrites)\n"
" xxHash64 column is the anchor for Ed25519 fingerprints (Phase 8 PKI).\n"
"\n"
"Names are colon-separated relative paths (e.g. core:init.4th).\n"
"Files whose encoded name exceeds %d bytes are skipped with a warning.\n",
- argv[0], argv[0], argv[0], argv[0], CAPSULE_NAME_MAX - 1);
+ argv[0], argv[0], argv[0], CAPSULE_NAME_MAX - 1);
return 1;
}
@@ -1731,14 +1186,6 @@ int main(int argc, char **argv) {
const char *output_path = argv[arg0 + 1];
- fprintf(stderr, "mkcapsule: checking for block conflicts...\n");
- if (check_block_conflicts() != 0) {
- return 1;
- }
- if (check_reserved_conflicts() != 0) {
- return 1;
- }
-
fprintf(stderr, "mkcapsule: scanning %s\n", base_dir);
if (nftw(base_dir, process_file, 20, FTW_PHYS) != 0) {