20bd9ed00b
Binds the api-reshape surface at wt/api-reshape@d4f401d (op_think/read/attend/ learn, verified against engram.cognition-20260814) into the swarm: - reshape_surface.el composes the reshape's proven read/cognition primitives verbatim (write ops omitted — they need the gate-1 write-healthy clone). - primitive_binding.el: bound_think -> op_think over the worker's NODE-ID anchor (ctx.input); attend/learn bound behind SWARM_WRITE_HEALTHY. - cognize blueprint derives the vote verdict from the REAL gradient's n_support (json_get_int) — per-anchor diversity (6/16/87 support) drives a genuine vote. - build.sh now defines HAVE_CURL. CRITICAL FIX: without it every http_* was a '{"error":"not built with HAVE_CURL"}' stub, so prior 'live engram' retrieval was a false positive (matched the ref string, not real content). With HAVE_CURL the swarm genuinely hits /api/think on the :8901 clone. harness_real_cognition.el: 17/17 GREEN with seam=decorated — 8 native-thread workers each a REAL think (768-dim gradient) over its CCR-scoped node-id anchor, @manager reduce+vote convergence, all 3 containment rules incl. live Rule-2 denial, afferent telemetry (8 real think signals), durable work-tracking. Reads only — daemon stays healthy; writes stay gated on the gate-1 clone. Prod :8742 untouched.
76 lines
3.4 KiB
EmacsLisp
76 lines
3.4 KiB
EmacsLisp
// reshape_surface.el — the api-reshape agent's PROVEN decorated primitives,
|
|
// composed into the swarm build to bind real cognition.
|
|
//
|
|
// PROVENANCE: these fns are the reshape's surface at wt/api-reshape @ d4f401d
|
|
// ("reshape: decorator-as-seam — port @route codegen, prove decorate->serve,
|
|
// rewrite surface as decorated El"), verified live against
|
|
// engram.cognition-20260814. Copied verbatim (read/cognition ops only) so the
|
|
// swarm binds the REAL primitives, not a reimplementation. The write ops
|
|
// (op_write/op_relate/op_supersede/op_ground) are intentionally NOT composed
|
|
// here — they exercise the persist_node write path that needs the gate-1
|
|
// write-healthy clone; the swarm's proven run is read-cognition (think/read).
|
|
//
|
|
// Ops route to the ENGRAM over ENGRAM_URL — pinned by THIS worktree's .nsbx-env
|
|
// to the :8901 swarm clone (never the reshape agent's :8900). Separate clones,
|
|
// no collision.
|
|
|
|
fn engram_url() -> String {
|
|
let u: String = env("ENGRAM_URL")
|
|
if str_eq(u, "") { return "http://127.0.0.1:8900" }
|
|
return u
|
|
}
|
|
fn engram_key() -> String {
|
|
let k: String = env("ENGRAM_API_KEY")
|
|
if str_eq(k, "") { return "sbx-dev-api-reshape" }
|
|
return k
|
|
}
|
|
fn SELF_KEY() -> String { return "kn-efeb4a5b-5aff-4759-8a97-7233099be6ee" }
|
|
fn VALUES_KEY() -> String { return "kn-5b606390-a52d-4ca2-8e0e-eba141d13440" }
|
|
|
|
// self/values name -> keystone id; anything else passes through unchanged.
|
|
fn resolve_named(v: String) -> String {
|
|
if str_eq(v, "self") { return SELF_KEY() }
|
|
if str_eq(v, "neuron") { return SELF_KEY() }
|
|
if str_eq(v, "values") { return VALUES_KEY() }
|
|
if str_eq(v, "values_hub") { return VALUES_KEY() }
|
|
return v
|
|
}
|
|
|
|
// read — THE VANTAGE-READ. Re-origin at a point + aperture -> a BOUNDED slice.
|
|
fn op_read(vantage: String, typ: String, k: Int) -> String {
|
|
let vid: String = resolve_named(vantage)
|
|
if str_eq(typ, "edges") {
|
|
return http_get(engram_url() + "/api/neighbors/" + vid)
|
|
}
|
|
if str_starts_with(vid, "kn-") {
|
|
return http_get(engram_url() + "/api/neighbors/" + vid)
|
|
}
|
|
return http_get(engram_url() + "/api/search?q=" + url_encode(vid) + "&limit=" + int_to_str(k))
|
|
}
|
|
|
|
// think — THE ONE OPERATION. anchor (node ids) steered by faculty -> gradient.
|
|
fn op_think(seeds: String, faculty: String) -> String {
|
|
let s: String = resolve_named(seeds)
|
|
let f: String = if str_eq(faculty, "") { "reason" } else { faculty }
|
|
return http_get(engram_url() + "/api/think?seeds=" + url_encode(s) + "&faculty=" + f)
|
|
}
|
|
|
|
// attend — aim attention at a region. (POST — needs a write-healthy clone.)
|
|
fn op_attend(node: String, observer: String) -> String {
|
|
let n: String = resolve_named(node)
|
|
let o: String = if str_eq(observer, "") { SELF_KEY() } else { resolve_named(observer) }
|
|
let body: String = "{\"_auth\":\"" + engram_key() + "\",\"node\":\"" + n
|
|
+ "\",\"observer\":\"" + o + "\",\"salience\":\"0.6\"}"
|
|
return http_post_json(engram_url() + "/api/attend", body)
|
|
}
|
|
|
|
// learn — the reflexive correspondence-beat: calibrate the steering-prior.
|
|
// (POST — needs a write-healthy clone.)
|
|
fn op_learn(seeds: String, faculty: String) -> String {
|
|
let s: String = resolve_named(seeds)
|
|
let f: String = if str_eq(faculty, "") { "induce" } else { faculty }
|
|
let body: String = "{\"_auth\":\"" + engram_key() + "\",\"seeds\":\"" + s
|
|
+ "\",\"faculty\":\"" + f + "\",\"keystone\":\"false\"}"
|
|
return http_post_json(engram_url() + "/api/correspondence-beat", body)
|
|
}
|