Archived
swarm: local-swarm integration harness + one-flip primitive seam + telemetry
- primitive_seam.el: SWARM_PRIMITIVE_SEAM selects stub (default, hermetic) vs decorated (reshape's dharma-bus primitives). Every seam call is an afferent signal; telemetry (seam_mode + afferent tick) rides the vertical result path. - primitive_binding.el: THE ONE FLIP POINT — bound_think/attend/learn today fall back to the stub; when the reshape's decorated primitives land, flip one line each and set SWARM_PRIMITIVE_SEAM=decorated. No other change anywhere. - swarm.el: default blueprint routes think through the seam; the @manager aggregates afferent counters from worker results (containment-safe, no shared bus register) and journals a swarm.telemetry record; telemetry in the return. - harness_local_swarm.el: 17/17 GREEN on :8901 with the stub — 8 native-thread workers at concurrency 4, reduce+vote convergence, CCR scoping+non-leak, all three containment rules (incl. live Rule-2 denial), durable work-tracking, afferent telemetry observed. Runs identically under seam=decorated today (binding fallback), proving the flip path executes. Engram writes stay opt-in (durable journal is the substrate); daemon healthy.
This commit is contained in:
+34
-5
@@ -88,12 +88,17 @@ fn swarm_run_blueprint(ctx: String) -> String {
|
||||
return json_set_str("{}", "blueprint_status", st)
|
||||
}
|
||||
|
||||
// default (analyze_item): the CCR execution cycle think -> intend -> act.
|
||||
// default (analyze_item): the CCR execution cycle think -> intend -> act,
|
||||
// with `think` routed through the CONFIGURABLE PRIMITIVE SEAM. Telemetry
|
||||
// (seam_mode + afferent tick) rides the worker's returned output.
|
||||
let instruction: String = "process input: " + input_item
|
||||
let thought: String = primitive_think(knowledge, instruction)
|
||||
let thought: String = seam_think(knowledge, instruction)
|
||||
let intent: String = primitive_intend(thought)
|
||||
let effect: String = primitive_act(intent, input_item)
|
||||
return json_set_str(effect, "blueprint_status", "ok")
|
||||
let e1: String = json_set_str(effect, "blueprint_status", "ok")
|
||||
let e2: String = json_set_str(e1, "seam_mode", json_get_string(thought, "seam_mode"))
|
||||
let e3: String = json_set_str(e2, "afferent", json_get_string(thought, "afferent"))
|
||||
return e3
|
||||
}
|
||||
|
||||
// ── native-thread fan-out, bounded by concurrency, order-preserving ──────────
|
||||
@@ -324,14 +329,28 @@ fn swarm_run(blueprint: String, knowledge_refs: String, inputs_json: String, con
|
||||
// ── native-thread fan-out (bounded) ──
|
||||
let results: [String] = swarm_fanout("swarm_worker_entry", envelopes, concurrency)
|
||||
|
||||
// record per-worker terminal status
|
||||
// record per-worker terminal status + aggregate AFFERENT telemetry.
|
||||
// Afferent counters (primitive signals travelling toward the @manager)
|
||||
// are summed from the vertical result path — no shared bus register,
|
||||
// so the aggregation is containment-safe.
|
||||
let succ = 0
|
||||
let afferent = 0
|
||||
let seam_mode_seen: String = "stub"
|
||||
let rn: Int = el_list_len(results)
|
||||
let r = 0
|
||||
while r < rn {
|
||||
let res: String = el_list_get(results, r)
|
||||
let wid: String = json_get_string(res, "worker_id")
|
||||
let st: String = json_get_string(res, "status")
|
||||
let out: String = json_get_raw(res, "output")
|
||||
let aff: Int = str_to_int(json_get_string(out, "afferent"))
|
||||
let afferent = afferent + aff
|
||||
let sm: String = json_get_string(out, "seam_mode")
|
||||
if str_eq(sm, "") {
|
||||
let seam_mode_seen = seam_mode_seen
|
||||
} else {
|
||||
let seam_mode_seen = sm
|
||||
}
|
||||
if str_eq(st, "completed") {
|
||||
let succ = succ + 1
|
||||
worktrack_append("worker.completed", corr_id, wid, json_set_str("{}", "status", "completed"))
|
||||
@@ -345,6 +364,15 @@ fn swarm_run(blueprint: String, knowledge_refs: String, inputs_json: String, con
|
||||
let vg: String = json_set("{}", "success_count", int_to_str(succ))
|
||||
worktrack_append("swarm.converging", corr_id, corr_id, vg)
|
||||
|
||||
// swarm.telemetry — afferent counters observed by the @manager.
|
||||
let tkv: [String] = el_list_empty()
|
||||
let tkv = el_list_append(tkv, "seam_mode")
|
||||
let tkv = el_list_append(tkv, seam_mode_seen)
|
||||
let telem0: String = json_build_object(tkv)
|
||||
let telem1: String = json_set_str(telem0, "afferent_think", int_to_str(afferent))
|
||||
let telemetry: String = json_set_str(telem1, "results_received", int_to_str(rn))
|
||||
worktrack_append("swarm.telemetry", corr_id, corr_id, telemetry)
|
||||
|
||||
// ── failure threshold (Swarm §4.3), integer per-mille math ──
|
||||
// require succ/n >= min_success_ratio <=> succ*1000 >= permille*n
|
||||
let permille: Int = ratio_to_permille(json_get_string(config_json, "min_success_ratio"))
|
||||
@@ -379,7 +407,8 @@ fn swarm_run(blueprint: String, knowledge_refs: String, inputs_json: String, con
|
||||
let ok2 = el_list_append(ok2, "completed")
|
||||
let out1: String = json_build_object(ok2)
|
||||
let out2: String = json_set(out1, "report", rep2)
|
||||
return json_set(out2, "merged", merged)
|
||||
let out3: String = json_set(out2, "merged", merged)
|
||||
return json_set(out3, "telemetry", telemetry)
|
||||
}
|
||||
// ── denied: caller was a worker trying to open a swarm (Rule 2) ──
|
||||
let dkv: [String] = el_list_empty()
|
||||
|
||||
Reference in New Issue
Block a user