d5411fb58a
Single-writer append-only JSONL journal keyed by correlation ID: swarm + worker + convergence records, reconstructable into a status report. Optional engram mirror via POST /api/node when ENGRAM_URL is set. Coordinator is the only writer (workers return structured results), which is race-free and enforces Swarm containment rule 3 by construction. Also prototype now_millis/now_ns in el_runtime.h (defined in el_runtime.c but unprototyped — blocked any El program needing a real ms clock under clang 21). Test proves durability + inspectability end-to-end.
39 lines
1.3 KiB
EmacsLisp
39 lines
1.3 KiB
EmacsLisp
// test_worktrack.el — durability + inspectability of the work-tracking journal.
|
|
|
|
fn main() -> Int {
|
|
let corr: String = "test-" + uuid_v4()
|
|
|
|
// record a swarm lifecycle
|
|
let p1: String = json_set("{}", "input_count", "3")
|
|
worktrack_append("swarm.created", corr, "swarm-1", p1)
|
|
worktrack_append("worker.started", corr, "worker-001", "{}")
|
|
worktrack_append("worker.started", corr, "worker-002", "{}")
|
|
worktrack_append("worker.completed", corr, "worker-001", "{}")
|
|
worktrack_append("worker.failed", corr, "worker-002", "{}")
|
|
worktrack_append("swarm.completed", corr, "swarm-1", "{}")
|
|
|
|
// inspect: reconstruct the report from the durable journal
|
|
let report: String = worktrack_swarm_report(corr)
|
|
print("report=" + report)
|
|
|
|
let recs_n: Int = el_list_len(worktrack_records(corr))
|
|
print("records=" + int_to_str(recs_n))
|
|
|
|
let state: String = json_get_string(report, "state")
|
|
let completed: Int = str_to_int(json_get_string(report, "workers_completed"))
|
|
let failed: Int = str_to_int(json_get_string(report, "workers_failed"))
|
|
|
|
if str_eq(state, "completed") {
|
|
if completed == 1 {
|
|
if failed == 1 {
|
|
if recs_n == 6 {
|
|
print("PASS worktrack")
|
|
return 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
print("FAIL worktrack")
|
|
return 1
|
|
}
|