// primitive_seam.el — the configurable primitive seam + telemetry. // // One switch selects where a worker's primitive invocation goes: // SWARM_PRIMITIVE_SEAM=stub (default) — hermetic in-process think. // SWARM_PRIMITIVE_SEAM=decorated — the reshape's decorated // primitives on the dharma bus // (see primitive_binding.el). // // Every seam invocation is an AFFERENT signal — a primitive call travelling // toward the manager. The seam stamps telemetry onto each thought (seam_mode + // one afferent tick) so the coordinator can aggregate afferent counters across // the swarm without any shared mutable state (containment-safe: counts ride the // vertical result path, not a shared bus register). // seam_mode — "stub" (default) or "decorated". fn seam_mode() -> String { let m: String = env("SWARM_PRIMITIVE_SEAM") if str_eq(m, "decorated") { return "decorated" } return "stub" } // seam_think — route a worker's `think` through the configured seam and stamp // telemetry. Returns the thought JSON augmented with: // seam_mode : which side of the seam served this call // afferent : "1" — one afferent primitive signal was emitted fn seam_think(ctx: String, instruction: String) -> String { let mode: String = seam_mode() let thought: String = "" if str_eq(mode, "decorated") { let thought = bound_think(ctx, instruction) } else { let thought = primitive_think(ctx, instruction) } let t1: String = json_set_str(thought, "seam_mode", mode) let t2: String = json_set_str(t1, "afferent", "1") return t2 } // seam_attend / seam_learn — same seam for the other primitives (used when a // blueprint retrieves or writes through the bus). fn seam_attend(query: String, limit: Int) -> String { if str_eq(seam_mode(), "decorated") { return bound_attend(query, limit) } return primitive_attend(query, limit) } fn seam_learn(corr_id: String, observation: String) -> String { if str_eq(seam_mode(), "decorated") { return bound_learn(corr_id, observation) } return primitive_learn(corr_id, observation) }