nx_ask_lib.nx
buildroot/runtime/nx_ask_lib.nx
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
imports: nx_syscalls.nxnx_seg_store.nx
imported by: nx_ask.nxnx_ask_gate.nx
structs
| none |
consts
| 15 | const AK_BUF: i64 = 65536 // question/record work buffer |
| 16 | const AK_IDS: i64 = 262144 // ask:ids working copy |
| 17 | const AK_KEY: i64 = 64 // "ask:<id>" key buffer |
| 18 | const AK_RC_USAGE: i64 = 2 // exit: usage |
| 19 | const AK_RC_ABSENT: i64 = 3 // exit: unknown id |
| 20 | const AK_ARG_VERB: i64 = 1 // argv slot: verb |
| 21 | const AK_ARG_P1: i64 = 2 // argv slot: from | id |
| 22 | const AK_ARG_P2: i64 = 3 // argv slot: question | answer text |
| 23 | const AK_ARGC_ASK: i64 = 4 // ask from question |
| 24 | const AK_ARGC_PEND: i64 = 2 // pending |
| 25 | const AK_ARGC_ANS: i64 = 4 // answer id text |
| 26 | const AK_ARGC_GET: i64 = 3 // get id |
| 27 | const AK_F_FROM: i64 = 0 // record field: from |
| 28 | const AK_F_STATE: i64 = 1 // record field: state |
| 29 | const AK_F_Q: i64 = 2 // record field: question |
| 30 | const AK_F_A: i64 = 3 // record field: answer |
| 31 | const AK_TAB: i64 = 9 // '\t' |
| 32 | const AK_NL: i64 = 10 // '\n' |
| 33 | const AK_SPACE: i64 = 32 // ' ' (TAB/NL flatten target) |
| 34 | const AK_ASCII_0: i64 = 48 // '0' |
| 35 | const AK_ASCII_9: i64 = 57 // '9' |
| 36 | const AK_DEC: i64 = 10 // decimal base |
functions
| 38 | func 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 } |
| 39 | func ak_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 40 | func 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 } |
| 41 | func ak_putn(v: i64) -> i64 |
| 51 | func ak_epoch() -> i64 |
| 57 | func ak_key(out: *u8, id: *u8) -> i64 |
| 68 | func ak_ntos(v: i64, out: *u8) -> i64 |
| 79 | func ak_flat(out: *u8, op: *i64, src: *u8) -> i64 called by 1: ak_main |
| 94 | func ak_field(rec: *u8, rl: i64, f: i64, out: *u8) -> i64 |
| 113 | func ak_commit(key: *u8, rec: *u8, rlen: i64, id: *u8, idadd: i64) -> i64 |
| 138 | func ak_main(argc: i64, argv: *i64) -> i64 |