code wiki / (root) / nx_rungclose_lib.nx

nx_rungclose_lib.nx

buildroot/runtime/nx_rungclose_lib.nx

64244 B1293 linesdepth 3pulls 3 transitivereach 3 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_rungclose_lib.nx -- THE CLOSE RULER (ecosystem EC57): ONE stage per rung, MEASURED from evidence the estate already keeps and NEVER SIGNED -- not by a seat, not by the operator. OPERATOR 2026-09-17 (three messages): completion needs NO manual sign-off, theirs or a seat's typed done row; everything goes all the way done MECHANICALLY; maturity is TESTED STAGES -- alpha, beta, production; issues DEMOTE and flag REWORK. v1 (the same day) read a typed done row as ATTESTED and a typed DONE frame as CLOSED, so the 27 rungs that were built, live and wired sat one signature short of done for good, and a door that closed on a signature closed 19 rungs on a SLICE the same afternoon (retracted within the hour). v2 reads evidence only: links, in the order a rung climbs them (each 1 holds | 0 fails | -1 could not be observed): JOURNAL the board's journal has a row for the rung (somebody started) BUILT the contract symbol is present in its organ (a rung that declares no contract holds by declaration) LIVE the capability answers on the callable surface: the treat row's MCP tool, else the contract organ's own tool (its basename, a lib's basename less _lib), on the allowlist TESTED the gate that proves the subject (resolved by nx_organ_ship_lib, the ship loop's own resolver) has a GREEN roster row at or after the rung's newest land, in the production journal or in the journal of any roster (nx_rosterconf_lib pair) whose conf lists the gate -- a slow beat's evidence is read where that beat writes it WIRED something runs it unattended: the treat row is COMPLETE, else the execution-surface census puts it on a clock, cron, daemon, roster, plan or fork surface -- a seat's MCP call alone is not wired OPERATED its beat HAS run it: an unattended run at or after the newest land and inside the freshness margin, read from the clock's own actlog rows or the roster journal (a process killed by a signal did not run) PAGE the published page is at least as new as the newest land stages: OPEN, STARTED, BUILT, LIVE, ALPHA (tested), BETA (wired), OPERATED, PRODUCTION (published) ISSUES DEMOTE, each class with its own ceiling; three of them flag rework: RED the gate's newest roster row is RED ceiling LIVE rework RETRACT a retract row is newer than the newest land ceiling LIVE rework FLAKY the verdict turned twice or more since the land, the last turn inside the margin ceiling ALPHA rework STALE the roster has not run the gate inside the margin ceiling ALPHA the harness's defect, not the rung's stage = the highest word whose links ALL hold in that order, lowered to the lowest ceiling a present issue sets; the WEAKEST LINK is the first that does not hold (or the issue that capped it), BY NAME, with the rule that decided it and the remedy that moves it. A link that could not be observed stops the climb exactly like a failed one and is NAMED unobservable: I could not look is never it is broken, and never it is fine. Pure: every function takes buffers and numbers, so a gate drives it in-process on planted rows. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 2 imports · 3 importers

nx_syscalls.nx nx_costest_lib.nx nx_rungclose_lib.nx nx_rungclose.nx nx_rungclose_gate.nx nx_seat.nx

imports: nx_syscalls.nxnx_costest_lib.nx

imported by: nx_rungclose.nxnx_rungclose_gate.nxnx_seat.nx

structs

none

consts

36const RGC_I64: i64 = 8
37const RGC_L_JOURNAL: i64 = 0
38const RGC_L_BUILT: i64 = 1
39const RGC_L_LIVE: i64 = 2
40const RGC_L_TESTED: i64 = 3
41const RGC_L_WIRED: i64 = 4
42const RGC_L_OPERATED: i64 = 5
43const RGC_L_PAGE: i64 = 6
44const RGC_LINKS: i64 = 7
45const RGC_HOLDS: i64 = 1
46const RGC_FAILS: i64 = 0
47const RGC_UNOBS: i64 = 0 - 1
48const RGC_ST_NORUNG: i64 = 0
49const RGC_ST_OPEN: i64 = 1 // declared, no link holds; OPEN plus the count of links that hold in order is the stage
50const RGC_ST_STARTED: i64 = 2
51const RGC_ST_BUILT: i64 = 3
52const RGC_ST_LIVE: i64 = 4
53const RGC_ST_ALPHA: i64 = 5
54const RGC_ST_BETA: i64 = 6
55const RGC_ST_OPERATED: i64 = 7
56const RGC_ST_PRODUCTION: i64 = 8
57const RGC_STATES: i64 = 9
61const RGC_F_DECLARED: i64 = 0 // journal facts of ONE rung (rgc_journal)
62const RGC_F_ROWS: i64 = 1
63const RGC_F_LAND: i64 = 2
64const RGC_F_RETRACT: i64 = 3
65const RGC_F_SYM_O: i64 = 4
66const RGC_F_SYM_L: i64 = 5
67const RGC_F_COST: i64 = 6
68const RGC_F_DONE: i64 = 7 // the newest done row: a NOTE since v2, read by nothing that decides a stage
69const RGC_F_LAST: i64 = 8 // the newest journal row of ANY kind: when the rung was last touched
70const RGC_F_DECLS: i64 = 9 // how many rung rows DECLARE this id: more than one and every row that names it is ambiguous
71const RGC_F_SLOTS: i64 = 10
72const RGC_RUNG_F_SYMBOL: i64 = 3 // rung|id|title|symbol|note|kind|cost|deps
73const RGC_MX_F_ORGAN: i64 = 1 // label|organ|symbol|exceed|c1..c4|note
74const RGC_MX_F_SYMBOL: i64 = 2
75const RGC_MX_MIN_NF: i64 = 3
76const RGC_ABSENT_PFX: *u8 = "_ABSENT_:"
77const RGC_KIND_DONE: *u8 = "done" // a journal kind the boards render; since v2 it decides nothing
78const RGC_CH_TAB: i64 = 9
79const RGC_CH_CR: i64 = 13
80const RGC_CH_SP: i64 = 32
81const RGC_CH_SLASH: i64 = 47
82const RGC_CH_DOT: i64 = 46
83const RGC_CH_MINUS: i64 = 45
84const RGC_CH_COMMA: i64 = 44
85const RGC_CH_GT: i64 = 62
88const RGC_W_NONE: i64 = 0
89const RGC_W_ROWS: i64 = 1 // JOURNAL holds: rows name the rung
90const RGC_W_NOROWS: i64 = 2 // JOURNAL fails
91const RGC_W_SYMBOL: i64 = 3 // BUILT holds: the symbol ruler found the contract
92const RGC_W_DECLARED: i64 = 4 // BUILT holds: the rung declares no contract
93const RGC_W_DARK: i64 = 5 // BUILT fails: the organ was read (or is unreadable) and the symbol is not declared
94const RGC_W_NOROW: i64 = 6 // BUILT unobservable: no matrix row names the contract
95const RGC_W_TREAT: i64 = 7 // LIVE/WIRED hold through the treat row's declaration, verified
96const RGC_W_TOOL: i64 = 8 // LIVE holds: the contract organ's own tool is on the allowlist
97const RGC_W_NOCONTRACT: i64 = 9 // LIVE fails: no contract and no treat row names a tool
98const RGC_W_UNREGISTERED: i64 = 10 // LIVE fails: the subject tool is not on the allowlist
99const RGC_W_GREEN: i64 = 11 // TESTED holds
100const RGC_W_NOGATE: i64 = 12 // TESTED fails: no gate resolves for the subject
101const RGC_W_UNROSTERED: i64 = 13 // TESTED fails: the gate resolves and is not on the roster
102const RGC_W_NOGREEN: i64 = 14 // TESTED fails: rostered, and no GREEN row at or after the land
103const RGC_W_SURFACE: i64 = 15 // WIRED holds: the census puts it on an unattended surface
104const RGC_W_MCPONLY: i64 = 16 // WIRED fails: only a seat's MCP call has run it
105const RGC_W_NOSURFACE: i64 = 17 // WIRED fails: nothing runs it
106const RGC_W_NOTINCENSUS: i64 = 18 // WIRED unobservable: the surface census has no row for it
107const RGC_W_RUN: i64 = 19 // OPERATED holds
108const RGC_W_NORUN: i64 = 20 // OPERATED fails: its beat has not run it since the land inside the margin
109const RGC_W_BLIND: i64 = 21 // OPERATED unobservable: its surface keeps no per-run witness this ruler reads
110const RGC_W_UNREADABLE: i64 = 22 // the evidence the link reads could not be read
111const RGC_W_PAGE: i64 = 23 // PAGE holds
112const RGC_W_PAGEOLD: i64 = 24 // PAGE fails: the page is older than the land
113const RGC_WHYS: i64 = 25
296const RGC_ES_F_CLOCK: i64 = 1
297const RGC_ES_F_CRON: i64 = 2
298const RGC_ES_F_DAEMON: i64 = 3
299const RGC_ES_F_FORK: i64 = 4
300const RGC_ES_F_ROSTER: i64 = 5
301const RGC_ES_F_ACTLOG: i64 = 6
302const RGC_ES_F_FIRST: i64 = 7
303const RGC_S_NONE: i64 = 0 // no surface, or only a reference (ref:)
304const RGC_S_MCP: i64 = 1 // only the MCP door (a seat's call)
305const RGC_S_BLIND: i64 = 2 // unattended, and no per-run witness this ruler reads: a plan step, a cron row, a daemon, a fork
306const RGC_S_ROSTER: i64 = 3 // the roster runs it: witnessed per run in the roster journal
307const RGC_S_CLOCK: i64 = 4 // a clock row runs it directly: witnessed per run in the clock's actlog rows
308const RGC_ES_OUT_CLASS: i64 = 0 // rgc_es_class out slots
309const RGC_ES_OUT_FO: i64 = 1
310const RGC_ES_OUT_FL: i64 = 2
311const RGC_ES_OUT_SLOTS: i64 = 3
312const RGC_SURF_CLOCK: *u8 = "clock"
313const RGC_SURF_PLAN: *u8 = "plan"
384const RGC_WORK_BEAT_S: i64 = 86400 // the census beat (clock row rungclose): the list is rewritten once a day
385const RGC_WORK_BEATS_OF_MARGIN: i64 = 2 // one full missed beat of margin before a reading is called stale
411const RGC_GX_EPOCH: i64 = 0
412const RGC_GX_GOFF: i64 = 1
413const RGC_GX_GLEN: i64 = 2
414const RGC_GX_V: i64 = 3
415const RGC_GX_STRIDE: i64 = 4
416const RGC_GR_F_ROSTER: i64 = 1
417const RGC_GR_F_GATE: i64 = 2
418const RGC_GR_F_VERDICT: i64 = 3
419const RGC_ROSTER_PROD: *u8 = "roster" // trial runs write other roster names; only the production roster tests a rung
420const RGC_V_RED: i64 = 0
421const RGC_V_GREEN: i64 = 1
422const RGC_V_OTHER: i64 = 0 - 1 // SKIP, UNKNOWN: the gate abstained, which is neither
423const RGC_VERDICT_GREEN: *u8 = "GREEN"
424const RGC_VERDICT_RED: *u8 = "RED"
426const RGC_G_ROWS: i64 = 0
427const RGC_G_NEWEST: i64 = 1 // the newest row's epoch
428const RGC_G_NEWEST_V: i64 = 2 // and its verdict
429const RGC_G_GREEN: i64 = 3 // the newest GREEN at or after `since` (CES_NONE when none)
430const RGC_G_FLIPS: i64 = 4 // GREEN/RED turns among rows at or after `since`
431const RGC_G_LAST_FLIP: i64 = 5
432const RGC_G_SLOTS: i64 = 6
512const RGC_RJ_BUF: i64 = 0
513const RGC_RJ_LEN: i64 = 1
514const RGC_RJ_GX: i64 = 2
515const RGC_RJ_GXROWS: i64 = 3
516const RGC_RJ_ORIGIN: i64 = 4
517const RGC_RJ_STRIDE: i64 = 5
518const RGC_RJ_UNREAD: i64 = 0 - 1
520const RGC_RC_GREEN_IN: i64 = 0 // the pair whose journal supplied the newest GREEN since the land (CES_NONE when none)
521const RGC_RC_UNREAD: i64 = 1 // 1 when a journal that could hold the evidence could not be read
522const RGC_RC_CONSULTED: i64 = 2 // how many distinct journals were read or tried
523const RGC_RC_SLOTS: i64 = 3
584const RGC_AX_EPOCH: i64 = 0
585const RGC_AX_COFF: i64 = 1 // the command column as written (the forked path; an older writer may carry arguments)
586const RGC_AX_CLEN: i64 = 2
587const RGC_AX_BOFF: i64 = 3 // its program: the first token's basename less .elf
588const RGC_AX_BLEN: i64 = 4
589const RGC_AX_JOFF: i64 = 5 // the clock row's name after job= in the last field; JLEN is CES_NONE when the row carries none
590const RGC_AX_JLEN: i64 = 6
591const RGC_AX_STRIDE: i64 = 7
592const RGC_JOB_KEY: *u8 = "job="
593const RGC_AL_F_LANE: i64 = 1
594const RGC_AL_F_CMD: i64 = 2
595const RGC_AL_F_NOTE: i64 = 5
596const RGC_LANE_CLOCK: *u8 = "clock"
597const RGC_EXIT_KEY: *u8 = "exit="
598const RGC_EXIT_SIGNALLED: i64 = 128 // UNIT: a shell reports death by signal N as 128 plus N
599const RGC_ELF_SFX: *u8 = ".elf"
781const RGC_I_RED: i64 = 0
782const RGC_I_RETRACT: i64 = 1
783const RGC_I_FLAKY: i64 = 2
784const RGC_I_STALE: i64 = 3
785const RGC_ISSUES: i64 = 4
786const RGC_FLAKY_TURNS: i64 = 2 // a verdict that went one way and came back: GREEN-RED-GREEN or RED-GREEN-RED
937const RGC_WORK_TAG: *u8 = "work"
938const RGC_WORK_HEAD: *u8 = " RUNGCLOSE-WORKLIST asof="
939const RGC_WORK_HEAD_TAIL: *u8 = " src=nx_rungclose-census-all fields=state,domain,rung,weakest,unobservable,last_epoch,cost_deciu states=2-STARTED,3-BUILT,4-LIVE,5-ALPHA,6-BETA,7-OPERATED\n"
940const RGC_WORK_NF: i64 = 8
941const RGC_WORK_F_STATE: i64 = 1
942const RGC_WORK_F_DOM: i64 = 2
943const RGC_WORK_F_RUNG: i64 = 3
944const RGC_WORK_F_WEAK: i64 = 4
945const RGC_WORK_F_UNOBS: i64 = 5
946const RGC_WORK_F_LAST: i64 = 6
947const RGC_WORK_F_COST: i64 = 7
948const RGC_WORK_FRESH: i64 = 1
949const RGC_WORK_STALE: i64 = 0
950const RGC_W_TOTAL: i64 = 0 // rgc_work_pick accounting: well-formed rows, rows on the asked board, rows picked, malformed rows
951const RGC_W_MATCHED: i64 = 1
952const RGC_W_SHOWN: i64 = 2
953const RGC_W_MALFORMED: i64 = 3
954const RGC_W_SLOTS: i64 = 4
955const RGC_PICK_STRIDE: i64 = 2 // a pick is a line span: start, end
956const RGC_CH_STAR: i64 = 42
1127const RGC_STAGE_TAG: *u8 = "stage"
1128const RGC_STAGE_HEAD: *u8 = " RUNGCLOSE-STAGES asof="
1129const RGC_STAGE_HEAD_TAIL: *u8 = " fields=domain,rung,state,issues,since,rework\n"
1130const RGC_STAGE_NF: i64 = 7
1131const RGC_SG_F_DOM: i64 = 1
1132const RGC_SG_F_RUNG: i64 = 2
1133const RGC_SG_F_STATE: i64 = 3
1134const RGC_SG_F_ISSUES: i64 = 4
1135const RGC_SG_F_SINCE: i64 = 5
1136const RGC_SG_F_REWORK: i64 = 6
1137const RGC_SG_OUT_STATE: i64 = 0 // rgc_stage_find out slots
1138const RGC_SG_OUT_SINCE: i64 = 1
1139const RGC_SG_OUT_IO: i64 = 2 // the issues span in the snapshot
1140const RGC_SG_OUT_IL: i64 = 3
1141const RGC_SG_OUT_SLOTS: i64 = 4
1236const RGC_KIND_MEASURE: *u8 = "measure"
1237const RGC_KIND_LESSON: *u8 = "lesson"
1238const RGC_KIND_QUEUE: *u8 = "queue"
1239const RGC_CH_CR: i64 = 13
1240const RGC_LOG_PIPES: i64 = 4 // log|epoch|rung|kind|text

functions

115func rgc_why_word(w: i64) -> *u8
called by 2: rp_link_linemain
144func rgc_why_need(w: i64) -> *u8
called by 2: rp_printmain
165func rgc_journal(plan: *u8, pn: i64, rung: *u8, f: *i64) -> i64
214func rgc_has_contract(plan: *u8, f: *i64) -> i64
called by 3: rp_evalrp_printmain
220func rgc_span_eq2(a: *u8, aoff: i64, alen: i64, b: *u8, boff: i64, blen: i64) -> i64
230func rgc_matrix_organ(mx: *u8, mn: i64, plan: *u8, soff: i64, slen: i64, o: *i64) -> i64
262func rgc_built(has_contract: i64, resolved: i64, sd: i64, why: *i64) -> i64
called by 2: rp_evalmain
272func rgc_live(has_contract: i64, treat_mcp: i64, allow_ok: i64, tool_on: i64, why: *i64) -> i64
called by 2: rp_evalmain
285func rgc_tested(gate_resolved: i64, jr_ok: i64, green_since: i64, rostered: i64, why: *i64) -> i64
called by 2: rp_evalmain
316func rgc_tab_field(buf: *u8, p: i64, e: i64, k: i64, off: *i64) -> i64
333func rgc_flag1(buf: *u8, p: i64, e: i64, k: i64, off: *i64) -> i64
called by 1: rgc_es_class calls 1: rgc_tab_field
340func rgc_es_class(es: *u8, en: i64, tool: *u8, out: *i64) -> i64
373func rgc_wired(treat_complete: i64, es_ok: i64, es_found: i64, sclass: i64, why: *i64) -> i64
called by 2: rp_evalmain
386func rgc_margin_s() -> i64 { return RGC_WORK_BEAT_S * RGC_WORK_BEATS_OF_MARGIN }
391func rgc_operated(run: i64, land: i64, now: i64, act_ok: i64, sclass: i64, has_agent: i64, why: *i64) -> i64
called by 2: rp_evalmain calls 1: rgc_margin_s
401func rgc_page(page_mtime: i64, land: i64, why: *i64) -> i64
called by 2: rp_evalmain
435func rgc_lines(buf: *u8, n: i64) -> i64
442func rgc_verdict_of(buf: *u8, off: i64, len: i64) -> i64
called by 1: rgc_gx_index calls 1: ces_span_is
448func rgc_gx_index(jr: *u8, jn: i64, ix: *i64, cap: i64) -> i64
478func rgc_gate_facts(jr: *u8, ix: *i64, rows: i64, gate: *u8, since: i64, g: *i64) -> i64
528func rgc_facts_merge(acc: *i64, one: *i64) -> i64
called by 1: rgc_roster_credit
543func rgc_roster_credit(jt: *i64, np: i64, lists: *i64, name: *u8, since: i64, g: *i64, gt: *i64, seen: *i64, out: *i64) -> i64
602func rgc_exit_code(buf: *u8, p: i64, e: i64) -> i64
631func rgc_job_span(buf: *u8, p: i64, e: i64, o: *i64) -> i64
650func rgc_prog_span(buf: *u8, coff: i64, clen: i64, o: *i64) -> i64
called by 1: rgc_ax_index calls 2: ces_slences_span_is
663func rgc_ax_index(al: *u8, an: i64, ix: *i64, cap: i64) -> i64
705func rgc_ax_newest_prog(al: *u8, ix: *i64, rows: i64, prog: *u8) -> i64
called by 2: rp_evalmain calls 2: ces_slences_span_is
720func rgc_ax_newest_cmd(al: *u8, ix: *i64, rows: i64, src: *u8, coff: i64, clen: i64) -> i64
called by 2: rp_evalmain calls 1: rgc_span_eq2
735func rgc_ax_newest_job(al: *u8, ix: *i64, rows: i64, src: *u8, noff: i64, nlen: i64) -> i64
called by 2: rp_evalmain calls 1: rgc_span_eq2
750func rgc_first_epoch(buf: *u8, n: i64) -> i64
called by 2: rp_read_sincemain calls 1: ces_parse_int
761func rgc_clock_cmd(clock: *u8, cn: i64, noff: i64, nlen: i64, nsrc: *u8, off: *i64) -> i64
789func rgc_issues(g: *i64, land: i64, retract: i64, now: i64, iss: *i64) -> i64
called by 2: rp_evalmain calls 1: rgc_margin_s
804func rgc_cap(state: i64, iss: *i64) -> i64
called by 2: rp_evalmain
812func rgc_rework(iss: *i64) -> i64
called by 2: rp_evalmain
817func rgc_issue_name(k: i64) -> *u8
825func rgc_issue_need(k: i64) -> *u8
called by 3: rp_printmainmain
834func rgc_issue_word(iss: *i64, dst: *u8, o0: i64) -> i64
851func rgc_issue_word_bound() -> i64
859func rgc_capping_issue(state: i64, iss: *i64) -> i64
called by 2: rp_evalmain
874func rgc_state(declared: i64, links: *i64, stop: *i64) -> i64
called by 2: rp_evalmain
884func rgc_state_name(s: i64) -> *u8
911func rgc_weak_issue0() -> i64 { return RGC_LINKS + 1 }
912func rgc_weak_codes() -> i64 { return rgc_weak_issue0() + RGC_ISSUES }
913func rgc_weak_name(w: i64) -> *u8
925func rgc_hold_name(v: i64) -> *u8
959func rgc_work_member(state: i64) -> i64
967func rgc_work_row_fixed() -> i64
978func rgc_work_pipe(buf: *u8, o: i64) -> i64
984func rgc_work_row(buf: *u8, o0: i64, state: i64, dom: *u8, rung: *u8, weakest: i64, unobs: i64, last: i64, cost: i64) -> i64
1006func rgc_work_head_bound() -> i64
1011func rgc_work_head(buf: *u8, o0: i64, asof: i64) -> i64
1020func rgc_work_asof(buf: *u8, n: i64) -> i64
1038func rgc_work_fresh(asof: i64, now: i64) -> i64
1047func rgc_work_line_state(buf: *u8, p: i64, e: i64, off: *i64) -> i64
1058func rgc_work_line_dom_is(buf: *u8, p: i64, e: i64, dom: *u8, off: *i64) -> i64
called by 1: rgc_work_pick calls 2: ces_fieldces_span_is
1064func rgc_work_line_active(buf: *u8, p: i64, e: i64, now: i64, off: *i64) -> i64
1075func rgc_work_pick(buf: *u8, n: i64, dom: *u8, now: i64, maxn: i64, picks: *i64, acc: *i64) -> i64
1143func rgc_stage_row_fixed() -> i64
1147func rgc_stage_head_bound() -> i64
called by 2: rp_census_allmain calls 1: ces_slen
1151func rgc_stage_head(buf: *u8, o0: i64, asof: i64) -> i64
1159func rgc_stage_row(buf: *u8, o0: i64, dom: *u8, rung: *u8, state: i64, iss: *i64, since: i64, rework: i64) -> i64
1180func rgc_stage_line_is(buf: *u8, p: i64, e: i64, dom: *u8, rung: *u8, out: *i64, off: *i64) -> i64
1202func rgc_stage_find(buf: *u8, n: i64, dom: *u8, rung: *u8, cur: *i64, out: *i64) -> i64
1223func rgc_move_word(dst: *u8, o0: i64, from: i64, to: i64) -> i64
called by 2: rp_censusmain calls 2: ces_catrgc_state_name
1243func rgc_kind_ok(kind: *u8) -> i64
1255func rgc_text_ok(text: *u8, off: *i64) -> i64
called by 5: rp_journalmainmainmainmain calls 1: ces_slen
1272func rgc_log_row_bound(rung: *u8, kind: *u8, text: *u8) -> i64
called by 2: rp_journalmain calls 1: ces_slen
1277func rgc_log_row(buf: *u8, o0: i64, lead_nl: i64, epoch: i64, rung: *u8, kind: *u8, text: *u8) -> i64