code wiki / (root) / nxtask_store.nx

nxtask_store.nx

buildroot/runtime/nxtask_store.nx

11915 B360 linesdepth 4pulls 4 transitivereach 2 importersview sourcekind tooltopic nxtask
docsdependenciesstructsconstsfunctions

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 · 2 importers

syscalls.nx nxtask.nx nxtask_store.nx nxtask_main.nx prop_nxtask_store_test.nx

imports: syscalls.nxnxtask.nx

imported by: nxtask_main.nxprop_nxtask_store_test.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nxtask_graph_new nxtask_add task_at nxtask_add_dep task_at ↻ nxtask_claim task_at ↻ nxtask_close task_at ↻ nxtask_serialize nxtask_serialized_size task_at ↻ write_i64_le task_at ↻ copy_bytes nxtask_deserialize read_i64_le nxtask_graph_new ↻ task_at ↻ task_at ↻ assert_bytes_equal

structs

none

consts

46const NXT_MAGIC_0: i64 = 0x4E // 'N'
47const NXT_MAGIC_1: i64 = 0x58 // 'X'
48const NXT_MAGIC_2: i64 = 0x54 // 'T'
49const NXT_MAGIC_3: i64 = 0x30 // '0'

functions

53func write_i64_le(buf: *u8, off: i64, val: i64) -> i64 {
called by 1: nxtask_serialize
62func read_i64_le(buf: *u8, off: i64) -> i64 {
called by 1: nxtask_deserialize
74func copy_bytes(dst: *u8, off: i64, src: *u8, n: i64) -> i64 {
called by 1: nxtask_serialize
88func nxtask_serialized_size(g: *TaskGraph) -> i64 {
called by 1: nxtask_serialize calls 1: task_at
103func nxtask_serialize(g: *TaskGraph, buf: *u8, cap: i64) -> i64 {
148func nxtask_deserialize(buf: *u8, n: i64) -> *TaskGraph {
265func assert_bytes_equal(a: *u8, b: *u8, n: i64) -> i64 {
called by 1: main
274func main() -> i64 {