code wiki / _hdl_build / nx_workstream_popqueue.nx

nx_workstream_popqueue.nx

buildroot/runtime/_hdl_build/nx_workstream_popqueue.nx

16929 B330 linesdepth 4pulls 5 transitivereach 2 importersview sourcekind librarytopic workstream
docsdependenciesstructsconstsfunctions

about

nx_workstream_popqueue.nx -- WMS rung REG-POP: FULL REGISTRY POPULATION (close the completeness gap). The "never lose an empire again" payoff. WMS-R1 seeded 15 sample streams; the assignment_queue holds ~1251 work-unit ids that the R4 audit reports as UNREGISTERED (prose/queue-only, never in the SSOT). This organ ENUMERATES every queue id and REGISTERS it into the WMS-R1 store, so R4's unregistered count drops from ~1248 toward 0. It does NOT move `untracked` (that counts *.nx organs with no code_link -- queue ids are work-units, not code paths; that is a SEPARATE rung, flagged OPEN here). SOVEREIGN COMMIT DISCIPLINE: ws_put commits ONE new segment per call -> 1248 puts would blow the seg-store 256-segment cap. So this builds ONE writer buffer (ss_begin) holding the merged ws:ids index PLUS every changed ws:<id> record, then ONE ss_commit = ONE new segment. Re-runs that change nothing add ZERO records to the buffer -> ZERO new segments (idempotent; the 256 cap is never threatened). The idempotency engine is a byte-compare against the store's current value (mirrors the seed organ's wss_streq_store skip). EMPIRE DERIVATION (data-driven, rule 11): queue ids carry no empire field, so empire is derived from the id's prefix family via a TABLE (parallel const arrays), and every derived empire is a real member of ws:empires so the R1 internal audit (ws_audit_complete) stays clean. Unknown prefix -> E-MISC. State = FLOATING (queue-only, no measured detail -- honest per the seed doctrine "ABSENT honestly rather than invented"; FLOATING is in the store's documented label set). memory_link/code_link = "-" (intentionally none -> NOT an orphan, per wa_*_link_resolves "-" handling). MANDATORY write discipline: the evidence log line is built into ONE buffer and emitted via the locked atomic fa_appendz (following cn_emit_green/cn_emit_red), with a UNIQUE scratch path (epoch+microsecond) so the organ is safe to run concurrently with itself. The registry writes themselves go through the atomic ss_commit (tmp+fsync+rename commit point). Sovereign: imports only nx_workstream_store + nx_seg_store + nx_framed_append + nx_syscalls (no gcc). Additive-only: does NOT modify any existing organ. license_tier: ORIGINAL

dependencies 4 imports · 2 importers

nx_workstream_store.nx nx_seg_store.nx nx_framed_append.nx nx_syscalls.nx nx_workstream_popqueue.nx nx_popqueue_probe.nx nx_workstream_popqueue_run.nx

imports: nx_workstream_store.nxnx_seg_store.nxnx_framed_append.nxnx_syscalls.nx

imported by: nx_popqueue_probe.nxnx_workstream_popqueue_run.nx

structs

none

consts

36const POP_LOG: *u8 = "knowledge/status/workstream_popqueue.log"
37const POP_QUEUE: *u8 = "knowledge/registry/assignment_queue.tsv"
38const POP_REC_CAP: i64 = 512 // bounded log record size (no magic number)
39const POP_ID_CAP: i64 = 4000 // hard bound on queue ids collected (JPL rule 2; ~1251 today)

functions

41func pq_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
44func pq_has_prefix(id: *u8, pre: *u8) -> i64
called by 1: pq_empire_for
54func pq_cpy(dst: *u8, src: *u8) -> i64
called by 1: pq_empire_for
65func pq_empire_for(id: *u8, out: *u8) -> i64
called by 1: pq_reg_one calls 2: pq_has_prefixpq_cpy
107func pq_build_record(id: *u8, empire: *u8, out: *u8) -> i64
called by 1: pq_reg_one calls 1: fa_cat
117func pq_build_key(id: *u8, out: *u8) -> i64
called by 1: pq_reg_one
130func pq_streq_store(prefix: *u8, key: *u8, val: *u8) -> i64
149func pq_streq_h(h: *i64, key: *u8, val: *u8) -> i64
165func pq_collect_ids(queue_path: *u8, ids_out: *i64, cap: i64) -> i64
201func pq_merge_ids(h: *i64, ids: *i64, nids: i64, out: *u8) -> i64
228func pq_id_eq(a: *u8, b: *u8) -> i64
called by 1: pq_stage_records
239func pq_reg_one(h: *i64, w: *i64, id: *u8, keybuf: *u8, recbuf: *u8, empbuf: *u8, out4: *i64) -> i64
259func pq_stage_ids(h: *i64, w: *i64, ids: *i64, nids: i64) -> i64
269func pq_stage_records(h: *i64, w: *i64, ids: *i64, nids: i64, omit: *u8, out4: *i64) -> i64
286func pq_populate_omit_p(prefix: *u8, queue_path: *u8, omit: *u8, out4: *i64) -> i64
308func pq_populate(out4: *i64) -> i64
called by 1: main calls 1: pq_populate_omit_p
315func pq_log(out4: *i64, verdict_green: i64) -> i64