nx_nxtask_store.nx
buildroot/runtime/nx_nxtask_store.nx
about
nxtask_store.nx -- persistence layer for nxtask (beads-equivalent).
Provides buffer round-trip of a TaskGraph + convenience wrappers
that go through fs.nx for disk persistence. Single-file binary
format; zero runtime deps beyond syscalls + fs.
Format v1 -- magic "NXT0":
4 magic ("NXT0", little-endian bytes)
8 n_tasks (i64 LE)
repeat n_tasks:
8 state
8 created_ns
8 updated_ns
8 desc_len
desc_len desc bytes (no trailing NUL)
8 claimed_by_len
claimed_by_len claimed_by bytes (omitted when 0)
8 summary_len
summary_len summary bytes (omitted when 0)
8 n_blocked
8*n_blocked blocked_by task indices (i64 LE each)
Design notes:
* We store strings inline rather than via a separate string pool
because each task's text is small (<2 KB) and the whole file
typically fits in one page. A pool only pays off when many
tasks share identical text, which isn't the nxtask workload.
* id_hash is NOT persisted. v0.0.1 uses counter-hash which is a
function of the task's position + creation order, both of
which are recovered at load time. v0.1.0 will persist a real
sha256(desc + created_ns) once we switch to content-addressed
ids.
* Little-endian is the RISC-V default so this is the native byte
order. No byte-swap needed.
This commit ships the buffer API only. An fs_save/fs_load wrapper
dependencies 2 imports · 1 importers
imports: nx_syscalls.nxnx_nxtask.nx
imported by: nx_nxtask_main.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 51 | const NXT_MAGIC_16384: i64 = 16384 |
| 53 | const NXT_MAGIC_0: i64 = 0x4E // 'N' |
| 54 | const NXT_MAGIC_1: i64 = 0x58 // 'X' |
| 55 | const NXT_MAGIC_2: i64 = 0x54 // 'T' |
| 56 | const NXT_MAGIC_3: i64 = 0x30 // '0' |
functions
| 60 | func write_i64_le(buf: *u8, off: i64, val: i64) -> i64 called by 1: nxtask_serialize |
| 69 | func read_i64_le(buf: *u8, off: i64) -> i64 called by 1: nxtask_deserialize |
| 81 | func copy_bytes(dst: *u8, off: i64, src: *u8, n: i64) -> i64 called by 1: nxtask_serialize |
| 95 | func nxtask_serialized_size(g: *TaskGraph) -> i64 |
| 110 | func nxtask_serialize(g: *TaskGraph, buf: *u8, cap: i64) -> i64 |
| 155 | func nxtask_deserialize(buf: *u8, n: i64) -> *TaskGraph |
| 272 | func assert_bytes_equal(a: *u8, b: *u8, n: i64) -> i64 called by 1: main |
| 281 | func main() -> i64 |