feat: implement global workspace, working memory and the cognitive cycle
Phase 4 (ADR-0001). internal/attention scores thought candidates as a normalised weighted sum over ten named features with a per-term breakdown, ranked by (score, id) so ordering is total and replayable. internal/workspace holds the capacity-limited workspace (refresh by subject, decayed competition, explained admit/reject outcomes) and the decaying working memory. internal/brain runs one runtime per active mind: debounced wake-ups from the event bus (own output never re-triggers), a settle window so concurrently committing events are not skipped, bounded concurrent Observe calls with per-process isolation and timeouts, deterministic scoring, a loop detector that suppresses recurring thoughts and raises a metacognition warning, executive dispatch by thought kind, and one transaction per cycle whose events are published only after commit. Every candidate, selection, attention shift and broadcast is an event with provenance back to the triggering observation. Operators can run a cycle, pause, resume, reset transient state and change attention weights live; the manager reconciles runtimes with mind status. cognition/attend is the first process: deterministic candidates from external events using an urgency lexicon, novelty against context and trust-based operator priority.
This commit is contained in:
@@ -151,3 +151,12 @@ pre.json { background: var(--surface-2); padding: .75rem; border-radius: 8px; ov
|
||||
.chain-arrow { text-align: center; color: var(--muted); }
|
||||
ol.corr li.current { font-weight: 600; }
|
||||
.cats { display: flex; flex-wrap: wrap; gap: .3rem; margin: .4rem 0; }
|
||||
|
||||
/* Workspace */
|
||||
.bd { display: flex; height: 10px; width: 160px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
|
||||
.bd-term { display: block; height: 100%; } .bd-term i { display: block; height: 100%; }
|
||||
.f-salience { background: #0ea5a4; } .f-urgency { background: #e11d48; } .f-novelty { background: #8b5cf6; } .f-affect { background: #f472b6; } .f-goal_relevance { background: #16a34a; }
|
||||
.f-consequence { background: #d97706; } .f-confidence { background: #64748b; } .f-contradiction { background: #b91c1c; } .f-operator_priority { background: #2563eb; } .f-context_relevance { background: #0891b2; }
|
||||
ul.wm li { padding: .45rem 0; border-bottom: 1px solid var(--border); } ul.wm li:last-child { border-bottom: 0; }
|
||||
.weights { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
|
||||
.weights label { font-size: .8rem; }
|
||||
|
||||
@@ -96,8 +96,32 @@
|
||||
});
|
||||
}
|
||||
|
||||
// Live sections: <div id="x" data-refresh-on="type1,type2" data-refresh-url="/page" data-stream="/api/.../stream?...">
|
||||
// On a matching event the page is re-fetched and the section swapped in place.
|
||||
function attachRefreshers() {
|
||||
document.querySelectorAll("[data-refresh-on][data-stream]").forEach((el) => {
|
||||
const types = el.dataset.refreshOn.split(",");
|
||||
const status = document.querySelector("[data-stream-status]");
|
||||
let timer = null;
|
||||
const refresh = () => fetch(el.dataset.refreshUrl, { credentials: "same-origin" }).then((r) => r.text()).then((html) => {
|
||||
const doc = new DOMParser().parseFromString(html, "text/html");
|
||||
const fresh = doc.getElementById(el.id);
|
||||
if (fresh) el.innerHTML = fresh.innerHTML;
|
||||
}).catch(() => {});
|
||||
stream(el.dataset.stream, {
|
||||
cognitive_event: (ev) => {
|
||||
if (status) status.textContent = "live";
|
||||
if (!types.includes(ev.type)) return;
|
||||
clearTimeout(timer); timer = setTimeout(refresh, 400);
|
||||
},
|
||||
});
|
||||
if (status) status.textContent = "live";
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
attachStreams();
|
||||
attachRefreshers();
|
||||
const tt = document.querySelector("[data-theme-toggle]");
|
||||
if (tt) tt.addEventListener("click", cycleTheme);
|
||||
const nt = document.querySelector("[data-nav-toggle]");
|
||||
|
||||
Reference in New Issue
Block a user