code wiki / _hdl_build / nx_plane_append.nx
nx_plane_append.nx
buildroot/runtime/_hdl_build/nx_plane_append.nx
about
nx_plane_append.nx -- SAFE APPEND OF ONE ROW TO A SOVEREIGN SEG-STORE PLANE.
WHY THIS EXISTS (proved by experiment 2026-07-26, debt seq1067). `sts_seed` REPLACES a plane; it does
not append. Seeding the same 2-row fixture twice into a throwaway prefix left 2 rows, not 4. So the
obvious way to "add one row" to a shared catalog -- call the seeder with your row -- DESTROYS every
row already there. Adding one row to knowledge/store/commontask- that way would have turned its 42
rows into 1. Two unrelated pieces of work were blocked on this single missing primitive: registering
an organ in the capability catalog, and adding the additive KIND column the atlas measure-gap axis
needs (seq1046). It was never a catalog problem. It was a WRITE-API problem.
FAIL-SAFE BY CONSTRUCTION, not by promise (Rule 13 / Rule 26 spirit):
* the ORIGINAL bytes are held in memory for the whole operation, so a restore is always possible;
* an absent or empty plane is REFUSED, never silently created -- a typo in a prefix must not
conjure a new plane that later reads as authoritative;
* the new buffer must be strictly LONGER than the old one AND must still start with the old bytes,
checked before the commit -- an append that does not preserve its input is not an append;
* after the commit the plane is RE-LOADED and the row count verified; on any mismatch the original
buffer is written back and the tool reports RED rather than leaving a mangled registry.
HONEST LIMIT, stated because it matters: the lock serialises appends made THROUGH THIS ORGAN. Any
other writer calling sts_seed directly bypasses it. This is the one correct path, not a guarantee
about every path, and it cannot become one until the other writers route through here.
nx_plane_append <prefix> <row>
nx_plane_append selftest
expect_exit: 0 license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_itoa_lib.nxnx_store_seed_lib.nxnx_seg_store.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 31 | const PA_MAGIC_65536: i64 = 65536 |
| 32 | const PA_MAGIC_4096: i64 = 4096 |
| 34 | const PA_CAP: i64 = 4194304 |
| 35 | const PA_LOCK_MODE: i64 = 420 |
| 36 | const PA_NL: i64 = 10 |
| 37 | const PA_OUTFD: i64 = 1 |
| 38 | const PA_EXIT_OK: i64 = 0 |
| 39 | const PA_EXIT_USAGE: i64 = 2 |
| 40 | const PA_EXIT_REFUSED: i64 = 3 |
| 41 | const PA_EXIT_IO: i64 = 4 |
| 42 | const PA_EXIT_CORRUPT: i64 = 5 |
functions
| 44 | func pa_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(PA_OUTFD, s, n); return 0 } |
| 49 | func pa_n(v: i64) -> i64 { nxi_out(v); return 0 } |
| 50 | func pa_streq(a: *u8, b: *u8) -> i64 called by 1: main |
| 56 | func pa_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 59 | func pa_rows(buf: *u8, n: i64) -> i64 |
| 69 | func pa_prefix_ok(oldb: *u8, oldn: i64, newb: *u8, newn: i64) -> i64 |
| 88 | func pa_lock(prefix: *u8) -> i64 |
| 92 | func pa_unlock(fd: i64) -> i64 |
| 97 | func pa_append(prefix: *u8, row: *u8, quiet: i64) -> i64 |
| 172 | func pa_selftest() -> i64 |
| 269 | func pa_append_fast(prefix: *u8, row: *u8, quiet: i64) -> i64 |
| 315 | func main(argc: i64, argv: *i64) -> i64 |