code wiki / (root) / nx_ask_lib.nx

nx_ask_lib.nx

buildroot/runtime/nx_ask_lib.nx

11690 B246 linesdepth 3pulls 3 transitivereach 2 importersview sourcekind librarytopic ask
docsdependenciesstructsconstsfunctions

about

nx_ask_lib.nx -- USER-QUESTION capability, LIBRARY half (ak_main dispatcher + pure helpers) (closes the coverage BUILD-queue gap "user-question" -- the Claude AskUserQuestion peer for sovereign organs). An autonomous organ/agent that hits a decision only the OPERATOR can make posts a question and polls for the answer; the operator lists pending and answers. Backed by the sovereign seg store (knowledge/store/ask-): append-only, additive (rule 13), no TSV files. ask <from> <question> -> posts; prints "NX-ASK id=<epoch-id>" (agent -> operator) pending -> "<id>\t<from>\t<question>" per OPEN question (operator view) answer <id> <text> -> marks ANSWERED with the text (operator -> agent) get <id> -> labeled state/question/answer; agents poll until state=ANSWERED Record: ask:<id> = from \t state \t question \t answer (answer "-" while OPEN); ask:ids = TAB id index. TABs inside question/answer are flattened to spaces at the boundary (rule 12) so the record stays parseable. exit: 0 ok | 2 usage | 3 unknown id license_tier: ORIGINAL

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_seg_store.nx nx_ask_lib.nx nx_ask.nx nx_ask_gate.nx

imports: nx_syscalls.nxnx_seg_store.nx

imported by: nx_ask.nxnx_ask_gate.nx

structs

none

consts

15const AK_BUF: i64 = 65536 // question/record work buffer
16const AK_IDS: i64 = 262144 // ask:ids working copy
17const AK_KEY: i64 = 64 // "ask:<id>" key buffer
18const AK_RC_USAGE: i64 = 2 // exit: usage
19const AK_RC_ABSENT: i64 = 3 // exit: unknown id
20const AK_ARG_VERB: i64 = 1 // argv slot: verb
21const AK_ARG_P1: i64 = 2 // argv slot: from | id
22const AK_ARG_P2: i64 = 3 // argv slot: question | answer text
23const AK_ARGC_ASK: i64 = 4 // ask from question
24const AK_ARGC_PEND: i64 = 2 // pending
25const AK_ARGC_ANS: i64 = 4 // answer id text
26const AK_ARGC_GET: i64 = 3 // get id
27const AK_F_FROM: i64 = 0 // record field: from
28const AK_F_STATE: i64 = 1 // record field: state
29const AK_F_Q: i64 = 2 // record field: question
30const AK_F_A: i64 = 3 // record field: answer
31const AK_TAB: i64 = 9 // '\t'
32const AK_NL: i64 = 10 // '\n'
33const AK_SPACE: i64 = 32 // ' ' (TAB/NL flatten target)
34const AK_ASCII_0: i64 = 48 // '0'
35const AK_ASCII_9: i64 = 57 // '9'
36const AK_DEC: i64 = 10 // decimal base

functions

38func ak_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 3: ag_checkmainak_main calls 1: sys_write
39func ak_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
40func ak_seq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 }
called by 2: mainak_main
41func ak_putn(v: i64) -> i64
called by 1: main calls 2: sys_writesys_mmap
51func ak_epoch() -> i64
57func ak_key(out: *u8, id: *u8) -> i64
called by 2: mainak_main
68func ak_ntos(v: i64, out: *u8) -> i64
called by 1: ak_main calls 1: sys_mmap
79func ak_flat(out: *u8, op: *i64, src: *u8) -> i64
called by 1: ak_main
94func ak_field(rec: *u8, rl: i64, f: i64, out: *u8) -> i64
called by 2: mainak_main
113func ak_commit(key: *u8, rec: *u8, rlen: i64, id: *u8, idadd: i64) -> i64
138func ak_main(argc: i64, argv: *i64) -> i64