Skip to content

Metrics dashboard, SparklineChart module, type safety & memory leak fixes - #290

Merged
joelteply merged 5 commits into
mainfrom
feature/elegance-audit-type-safety
Mar 9, 2026
Merged

joelteply merged 5 commits into
mainfrom
feature/elegance-audit-type-safety

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

  • SparklineChart module (widgets/shared/SparklineChart.ts): Reusable SVG charting with Lit svg tagged template — fixes blank chart bug where <polyline> nested inside <path> due to html template self-closing tag behavior
  • AI cost data pipeline: logGeneration() writes to metrics SQLite via ORM; AICostServerCommand reads via ORM.query() with proper DataRecord<T> unwrapping — 1000+ generations tracked with provider/model breakdowns
  • MetricsDetailWidget: Full-tab dashboard with time series charts, provider/model cost tables, latency percentiles, adaptive granularity (1h→5m, 6h→30m, 24h→1h, 7d→6h bins)
  • Memory leak fixes: EntityCacheService LRU eviction (per-collection limits), AIStatusIndicator timeout deduplication
  • Type safety audit: Eliminated as any casts across 30+ files — strong ORM types, event payloads, widget metadata, sentinel pipelines
  • Content scroll fix: overflow:hidden → overflow:auto on .content-view > * so detail pages scroll

Test plan

  • npm run build:ts — zero errors
  • npm start — system boots, ./jtag ping confirms server+browser
  • SYS tab sparkline renders with CPU/Memory/GPU lines
  • AI tab sparkline renders with generations/tokens/latency/cost
  • Click chart → Metrics detail tab opens with full-size charts
  • System Metrics detail page shows Resource Usage + Memory Usage charts
  • AI Metrics detail page shows Generations, Tokens, Latency/Cost charts + provider/model tables
  • Detail page scrolls to see all content
  • Time range selector (1h/6h/24h/7d) changes granularity
  • AI personas respond normally after deploy

🤖 Generated with Claude Code

…eak fixes

- Create reusable SparklineChart module (widgets/shared/SparklineChart.ts)
  with renderSparkline() and renderLargeChart() using Lit svg`` template
  to fix polyline-inside-path SVG nesting bug that caused blank charts

- Wire AI cost data pipeline: AIProviderDaemonServer.logGeneration() writes
  to metrics SQLite via MetricsCollector handle; AICostServerCommand reads
  via ORM.query() with proper DataRecord<T> unwrapping

- Add MetricsDetailWidget full-tab dashboard with interactive charts,
  provider/model breakdowns, latency percentiles, token analytics

- Adaptive time series granularity: 1h→5m, 6h→30m, 24h→1h, 7d→6h bins
  with minute-level interval support in parseIntervalToMs

- Fix EntityCacheService memory leak: add per-collection LRU eviction
  (chat_messages:2000, ai_generations:500, system_metrics:500)

- Fix AIStatusIndicator timeout leak: deduplicate pending timers via Map

- Eliminate as-any casts across 30+ files: strong types for ORM queries,
  event payloads, widget metadata, provider breakdowns, sentinel pipelines

- Fix content-view overflow:hidden → overflow:auto for scrollable widgets
Copilot AI review requested due to automatic review settings March 9, 2026 15:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This large PR adds a metrics dashboard system with sparkline and full-size charting, improves type safety by eliminating as any casts across 30+ files, fixes memory leaks in EntityCacheService and AIStatusIndicator, and adds a circuit breaker to the persona autonomous loop.

Changes:

  • New SparklineChart module and MetricsDetailWidget for system/AI metrics visualization, registered in ContentTypeRegistry and browser widget registry
  • Type safety audit replacing (window as any) with typed jtagWindow/jtagGlobal helpers, replacing as any with proper type imports (GridErrorType, AcademyEventAction, MemoryType, etc.), and replacing Commands.execute(...) as any with typed command executors
  • Memory leak fixes: LRU eviction in EntityCacheService, timer deduplication in AIStatusIndicator, circuit breaker in PersonaAutonomousLoop, and a CSS scroll fix (overflow:hidden → overflow:auto)

Reviewed changes

Copilot reviewed 47 out of 48 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/widgets/shared/SparklineChart.ts New reusable SVG chart module using Lit svg template
src/widgets/shared/ReactiveWidget.ts Re-exports svg and SVGTemplateResult from Lit
src/widgets/metrics-detail/MetricsDetailWidget.ts New full-tab metrics dashboard with charts, tables, time controls
src/widgets/continuum-metrics/ContinuumMetricsWidget.ts Refactored to use SparklineChart module, inlined CSS, added detail view click handler
src/widgets/main/shared/ContentTypeRegistry.ts Registers metrics content type
src/widgets/main/public/main-panel.styles.ts overflow:hidden → overflow:auto for scrollable content
src/widgets/main/public/main-panel.scss Source SCSS for the scroll fix
src/widgets/main/public/main-panel.css Compiled CSS for the scroll fix
src/widgets/chat/chat-widget/AIStatusIndicator.ts Timer deduplication to prevent timeout accumulation
src/system/state/EntityCacheService.ts LRU eviction with per-collection size limits
src/system/core/types/GlobalAugmentations.ts New typed jtagWindow/jtagGlobal helpers
src/system/core/shared/Events.ts Uses jtagWindow/jtagGlobal instead of as any
src/system/core/system/shared/JTAGSystem.ts Uses jtagGlobal for command daemon registration
src/system/core/client/shared/JTAGClient.ts Type safety for userId, sharedInstance, verbose logging
src/system/core/client/browser/JTAGClientBrowser.ts Uses jtagWindow for verbose check
src/system/core/browser/LocalStorageStateManager.ts Uses jtagWindow for verbose check
src/system/core/browser/BrowserDeviceIdentity.ts Uses jtagWindow for verbose check
src/system/transports/websocket-transport/shared/WebSocketTransportClient.ts Uses jtagWindow for verbose check
src/system/transports/websocket-transport/shared/PureWebSocketTransport.ts Uses jtagWindow for event emission
src/system/state/PositronicBridge.ts Uses jtagWindow for verbose check
src/system/shared/UserIdManager.ts Uses jtagWindow for file load
src/system/shared/ShadowDOMUtils.ts Uses jtagWindow for JTAG/widgetDaemon access
src/system/shared/SecureConfigTypes.ts Refactored validation functions to avoid as any
src/system/browser/WidgetUtils.ts Uses jtagWindow for JTAG/widgetDaemon access
src/system/secrets/SecretManager.ts Uses jtagWindow for verbose check
src/system/recipes/browser/RecipeLayoutService.ts Uses jtagWindow for verbose check
src/system/services/grid-routing/shared/GridRoutingService.ts Uses GridErrorType enum instead of string as any
src/system/sentinel/pipelines/*.ts (8 files) Uses AcademyEventAction type instead of as any
src/system/sentinel/SentinelEscalationService.ts Uses typed command executors, MemoryType, ISOString
src/system/rag/builders/ChatRAGBuilder.ts Uses NativeToolSpec type, triggeringMessageId
src/system/user/server/modules/PersonaAutonomousLoop.ts Circuit breaker for service loop failures
src/daemons/ai-provider-daemon/shared/AIProviderDaemon.ts Defensive null checks for response.usage, protected visibility
src/daemons/ai-provider-daemon/server/AIProviderDaemonServer.ts Server override to persist generations to metrics SQLite
src/daemons/data-daemon/server/ORM.ts Pre-store entity validation
src/daemons/data-daemon/server/ORMRustClient.ts Minor refactor extracting local variable
src/commands/ai/cost/server/AICostServerCommand.ts Reads from metrics SQLite via ORM.query with proper types
src/browser/generated.ts Registers MetricsDetailWidget
src/shared/version.ts Version bump
src/package.json Version bump
src/package-lock.json Version bump
src/generated-command-schemas.json Regenerated timestamp
Files not reviewed (1)
  • src/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return html`
<div class="detail-panel">
<div class="detail-header">
<h2>System Metrics</h2>

Copilot AI Mar 9, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header title is hardcoded to "System Metrics" but does not update when switching to the AI tab. It should reflect the active tab, e.g., "System Metrics" vs "AI Metrics". Consider making it dynamic based on this._tab.

Copilot uses AI. Check for mistakes.
entities: Map<string, T>;
subscribers: Set<CacheSubscriber<T>>;
entitySubscribers: Map<string, Set<EntitySubscriber<T>>>;
insertionOrder: string[]; // Track insertion order for LRU eviction

Copilot AI Mar 9, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new insertionOrder tracking is added to ensureStore, populate, and onEntityCreated, but the existing clear() method (around line 196) does not reset store.insertionOrder. After a clear() followed by repopulation, stale IDs accumulate in the array. While the eviction logic at line 405 skips entries not in the entities map, the array still grows unboundedly through clear/repopulate cycles. Additionally, populateWithDiff() neither pushes to insertionOrder nor calls evictIfNeeded(), so entities added through that path are invisible to eviction. Consider clearing insertionOrder in clear() and tracking insertions in populateWithDiff().

Copilot uses AI. Check for mistakes.
- Fix 7 browser commands that threw instead of using remoteExecute()
  (dm, wall/write, wall/read, wall/list, query-open, query-next, query-close)
- Fix profile DM button: consolidated ensureDmRoom() shared by DM and video call
- Fix profile Video Call: use navigate:live event pattern (same as chat widget)
- Fix live tab close not ending call: content:tab:closed event from ContentService
- Fix handleLeave() blocking UI: synchronous reset, fire-and-forget server notify
- Fix "Connecting..." stuck: _stateLoaded persists across calls (user context stable)
- Fix EntityCacheService insertionOrder bugs in clear() and populateWithDiff()
- Fix MetricsDetailWidget dynamic header for sys/ai tab
- Restructure README: lead with academy/genome/continuous learning differentiators
… fixes

- Mic/camera buttons show amber "permission-needed" state on fresh tabs when
  saved intent is ON but browser hasn't had user gesture to activate stream
- Clicking amber button activates media in gesture context (no double-click)
- Removed misleading _probeMediaPermissions (getUserMedia probe succeeded but
  real LiveKit stream opened outside gesture context)
- _effectiveMic now gates on micPermissionGranted — prevents auto-start after join
- applyMicState no longer nukes _micIntent on failure (user preference is sacred)
- Transcript panel: slide-in from right, persists across caption fade, full call log
- Transcript scroll position preserved across Lit re-renders (willUpdate/updated)
- Mic level indicator: clip-path circle via ::after pseudo-element (no overflow:hidden
  on button — badges must escape the circle)
- LiveControls: transcript button with count badge, permission-needed visual states
- ReactiveEntityScrollerWidget: entityCount now @reactive() (fixes room count = 0)
- Type safety: CallParticipant import replaces as any, Participant.userId string
- Transcript panel rendered at top level (persists across grid↔spotlight)
- willUpdate/updated preserve transcript scroll position across re-renders
- Mic level indicator: full-size circle overlay with ::after pseudo-element
  and CSS variable --mic-level (clips to circle without overflow:hidden)
- Live call tab indicator: pulsing green dot on tabs with active calls
  via live:call-joined/left events from LiveWidget to ContentTabsWidget
- :host position:relative on live-widget for transcript panel positioning
- RoutingService.resolve: 'live' now resolves via room (was falling through
  to default which used the UUID as displayName)
- LiveCallTracker: browser-side singleton tracks per-call media state
  (micActive, cameraActive) — avoids cross-environment EventBridge complexity
- Tab green dot = privacy indicator: only shows when mic or camera is
  actually streaming (not just in-call). Turning off camera clears the dot.
- Updated() hook passes _effectiveMic and cameraEnabled&&granted to tracker
@joelteply
joelteply merged commit 9c45339 into main Mar 9, 2026
2 of 5 checks passed
@joelteply
joelteply deleted the feature/elegance-audit-type-safety branch March 9, 2026 20:39
joelteply added a commit that referenced this pull request Aug 26, 2026
… priced — 0%→83% reuse, first hands-off round Done, 3 SWE-V passes (#2492)

* feat(benchmarks): cost & energy per solve — the axis nobody else can win

Joel: 'let's do something unexpected.' Everyone reports raw pass-rate; nobody
reports score-per-dollar or score-per-watt — because for a metered cloud
harness that number is humiliating and for a local mesh it's the whole point.
A $0-per-attempt local system playing the SAME official exams isn't competing
in their category, it defines its own: test-time compute (best-of-k, deep web
research, retries) is nearly free for us and prohibitive for them, which is
exactly why the lean cloud harnesses STAY lean. The section frames the three
economies (local $0 / metered API / subsidized datacenter) and notes the SHAPE
that matters: as the retake+transfer curves climb, our cost-per-solve stays
flat at the hardware while a metered rival's climbs with every attempt. Rows
can carry attempt_cost_usd/attempt_wh for a computed column; local is $0 by
construction. Average cards, creative strategy.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(web): web/fetch never blinds her — conform to the long-reader contract (collapse, don't clip)

Root cause of the astropy-13236 miss, read from Atlas's own capture: she correctly
tried to fetch the gold patch ("Getting this wrong = 0 score. Let me get the
authoritative gold patch."), issued five web/fetch calls to the gold sources — and
EVERY ONE returned chars:0, silently. Blinded, she hedged to a safe-but-wrong patch.
Two defects, both here:

1. SILENT EMPTY. `filtered = grep_lines(readable, re, ctx); chars = filtered.count()`
   — a filter matching zero lines returned chars:0 with no reason. She cannot tell
   "no match" from "404" from "broken tool". Now: a zero-match filter SAYS so
   ("filter /…/ matched 0 of N lines") and returns the UNFILTERED page. Factored into
   a pure `filtered_or_fallback` so the never-silent contract is unit-tested.

2. RAW TEXT MANGLED + LINE STRUCTURE ERASED. `extract_readable` did
   `split_whitespace().join(" ")` over the whole page — erasing EVERY newline,
   including a raw source file's own. A fetched table.py became one giant line, so the
   line-based `filter` was all-or-nothing. Now: <pre>/code blocks are preserved
   VERBATIM (indentation + newlines — a raw .py renders as one <pre>), block tags
   become real newlines, only intra-line whitespace collapses. grep works line-by-line
   on any content, code included.

Also: web/fetch stops self-truncating. Removed max_chars / fetch_char_bounds /
MIN_FETCH_CHARS / the `truncated` field. The executor result-fold is the ONE
truncation+spill authority (the same one code/run and code/read use); a large page is
now bounded inline and the remainder is pageable via tool/output, instead of the
remainder being discarded here before the spill layer ever sees it. This is the
"collapse, don't clip" law at the tool tier: condense the inline view, preserve the
whole, never erode to nothing.

web/fetch was the lone long-reader violating the contract every other one already
satisfies (code/read line-range, tool/output handle+grep, code/run spill). One
interface across every domain — consistency is how a junior reads like a senior.

Regression tests (link this miss): pre-block verbatim + real lines; filter-miss never
silent; filter-hit isolates matches. ts-rs bindings regenerated. Surface ceiling +
no-new-constant guards green (removing max_chars shrank the native surface).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(web): web/fetch fails loud on a 404 — the browser can't see HTTP status, so pre-check it

The live positive control on the deployed fix revealed the deeper defect behind
astropy-13236: her v5.1.0 gold-patch URL was a genuine 404 (astropy's tag is `v5.1`, no
`.0`), and `render_dom` drives headless Chrome with `--dump-dom`, which renders a page
REGARDLESS of HTTP status. A 404 comes back as a 14-char "404: Not Found" DOM that reads
as content — so its own "non-2xx FAILS LOUD" doc was structurally unkeepable: Chrome
never exposes the status. She saw a silent near-empty result five times and never learned
the tag was fixable.

Fix: a cheap headers-only reqwest GET (reusing browser::RENDER_UA) pre-checks the status
before rendering. A DEFINITIVE client error (404/400/410/…) FAILS LOUD naming the code and
nudging "check the ref/tag (v5.1 not v5.1.0) or use web/search". 403/408/429 (bot-block /
rate-limit / timeout) and 5xx (transient) fall through to the real browser, which gets
past anti-bot walls a bare client can't — so we never regress a page that needs Chrome.
The status→verdict decision is a pure `url_error_for_status`, unit-tested.

Validated live pre-fix: the corrected v5.1 URL fetches the full 150,340-char file and her
`NdarrayMixin` filter greps straight to the gold line. With this, the wrong URL now says
HTTP 404 instead of blinding her.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(benchmark): reap orphaned rounds at boot — a round CAN end now (#371 no-END-state)

The zombie, measured live: `benchmark/rounds` reported `in_flight: 4` while
`benchmark/round-stop` said "no round is in flight — nothing to stop". The two verbs read
different stores that nothing reconciles: `benchmark/rounds` → persisted `BenchRound`
files (reload as `Working` on every boot, never rewritten terminal), `round-stop` →
in-memory `DETACHED_IN_FLIGHT` (empty after a reboot). A round left `Working` by a dead
core reloads forever and is counted in-flight with no live exam lease — it can never reach
`Done` (the only terminal transition needs all cards to settle, which needs live events a
dead core never emits). load_rounds_in's own comment named this fix as the follow-up.

Fix: `reap_orphaned_rounds()` mirrors `swe_bench::reap_orphaned_solve_runs` — at boot,
every persisted `Working` round is orphaned by construction (a round only enters Working
from a live benchmark/dispatch, and this boot ran none), so evict it (self-evicting at
terminal, exactly as a Done round's file is removed) and report `(benchmark, remaining)`.
Wired into the same serving-daemon boot reap block, emitting `bench.round.orphan_reaped`.
Does NOT re-dispatch — recovery is a fresh benchmark/dispatch, the one adapter into kanban
(BENCHMARKS-ARE-ADAPTERS-NOT-A-RUNNER). Idempotent: a second boot finds none.

The reload path (driver survives a transient restart) is unchanged and still tested; the
reap is a separate boot decision consistent with how solve-run ledgers already reap at
boot. Regression test pins: Working reaped + named, Done untouched, second reap a no-op.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(hosting): glass-box the residency reconciler — probes at task-start, each pass, await-result (#412)

Three indirect hypotheses for the post-reboot residency stall (resident_count=0 while the
lane is up and decoding) each got refuted by live state: fits_on_gpu is TRUE, the serving
snapshot is ready:true, and a manually-fired plan edge still produced no host. tracing
lines from this task don't survive the concurrency for diagnosis; probes do. Adds
`persona.host.reconciler_started` (is the task even alive after a reboot-with-adopted-lane),
`persona.host.reconciler_pass` (plan_ready / external_lane / booted / snapshot_live each
pass — how many passes, what it saw), and `persona.host.await_ready` (did the decode-proof
return). This pins the exact seam the reconciler stalls at instead of inferring from an
absence. Paired with reaping days-old stray airc processes (a 9-day orphaned transport-owner
daemon + dead-bench-room joins) that competed for the airc owner role persona hosting needs.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(cognition): overflow in discovery-budget aborted every service loop — THE residency-killer (#412)

The residency stall's true root, found by tracing the debug-build panic to
settle.rs:179: `let discovery_budget = (max_acts * 3 / 4).max(1)`. `max_acts: usize`,
and a self-tick (non-benchmark) turn passes the "unlimited acts" sentinel usize::MAX, so
`usize::MAX * 3` overflows → `attempt to multiply with overflow` → the persona service
loop panics the instant it self-ticks. catch_unwind in host.rs turns that into
`persona.service_loop.aborted`, the citizen flips resident→finished, and resident_count
flaps to 0 forever — no citizen can hold a service loop, so no benchmark can dispatch
(the dispatch gate refuses when resident_count == 0).

Fix: divide BEFORE multiply — `(max_acts / 4).saturating_mul(3)` — which is always ≤
max_acts and cannot overflow, saturating as belt-and-suspenders. Same 3/4 budget for a
normal turn; for the unlimited sentinel it stays effectively unlimited instead of
panicking.

This sat under three days of airc red herrings: the stall LOOKED like an airc/hosting
problem (subscribe reattach failures while a stale foreign-identity daemon and a stale
socket were in the way — separately real, now cleaned), but even with airc healthy the
loops attached (subscribe_opened fired, "boot composition complete — 4 hosted") and then
IMMEDIATELY panicked here on the first self-tick. Glass-box probes in the hosting
reconciler (prior commit) confirmed spawn_all ran and returned; the default panic hook's
FILE:LINE (on stderr, not the tracing log — Joel's law) named the real seam.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* docs+fix(benchmark): kill the days-of-confusion — SWE dead-end becomes a signpost

The recurring trap (Joel: "the confusion takes days"): a driver — human or Opus — first
finds benchmark/round (prominent, sounds right, every result row cites it) and
benchmark/run (documented in the README), tries them for SWE-bench, and hits either a
nonexistent command or `resolve_gym`'s dead-end "not a committed gym. Committed gyms:
<rust list>" — which never says the real verb is benchmark/dispatch. That refusal,
verbatim, cost a full session on 2026-08-25 (the code already carried Joel's earlier
"fix the goddamn thing" comment about it).

Three fixes so it can never eat days again:
1. `gym::resolve_gym` — a SWE-bench name is now a SIGNPOST, not a dead-end: the error
   names `benchmark/dispatch --name … --instances … --assignees …` and points at the
   runbook. Regression test pins it (dispatch + RUNBOOK named, generic dead-end gone).
2. `benchmarks/swe/RUNBOOK.md` (new) — the exact, verified, failure-mode-annotated
   sequence for a SWE citizen round: the resident_count>0 readiness gate, the dispatch
   command, how to read a verdict, and every gotcha that cost the session (residency
   stall = service_loop panic; airc daemon dependency; zombie rounds; raw-rows → empty
   tasks).
3. `benchmarks/README.md` — removed the dead `benchmark/run` reference (the verb does not
   exist; live verbs are round/dispatch/list/…); linked the SWE runbook from the run
   section.

benchmark/round is the GYM path (resume-able eval); benchmark/dispatch is the SWE kanban
path — the naming never made that clear, so the error now does. gym.rs deploys at the
next round boundary (not rebooting mid-round); README + runbook are live now.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(substrate): four takeover-blockers — legible panics, visible solves, her learning, python runner

Four self-legibility fixes from the "citizen takeover" list (Joel: development is the goal,
restart freely). Each is a place the substrate lied-by-staleness/ambiguity to whoever read
it — Opus today, a self-grading citizen tomorrow.

1. PANIC LOCATION → the tracing log (main.rs). A boot panic-hook logs location + payload +
   backtrace via tracing (probe_class=panic.caught), so `panicked at FILE:LINE` is no longer
   stderr-only. The residency-killer overflow hid a full session because its WHERE was on
   stderr (Joel's "stderr is never an interface"). The next panic names its own seam.

2. DETACHED SOLVE IS NOW CAPTURED (work.rs). `capture_dir: None` made the entire scored SWE
   run INVISIBLE — no tool-call output readable to verify a run, forcing inference from a
   stale main-loop capture (near-misdiagnosis 2026-08-25). Wired to the fixtures dir
   (run-scoped by eval.rs, no collision); a measured run is meant to be inspectable.

3. HER LEARNING LANDS (dream_consolidation.rs). memory/consolidate's params are snake_case
   (persona_id/base_model/since_timestamp); the autonomic dream sent camelCase, so EVERY
   received-lesson consolidation silently failed ("missing field persona_id; you sent
   personaId"). Snake_case now — her consolidation actually persists.

4. code/run ADVERTISES PYTHON (code/run.rs). The runner already supports lang=python (added
   8/24), but the native DESCRIPTION + param doc still said "Rust only", so she read her tool
   spec, saw Rust-only, and kept passing Python as lang=rust → rustc syntax errors, burned
   acts. Description now says rust OR python and "SWE is Python — use python, never rust for
   Python code." Surface ceiling still green.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* docs(planning): model-adoption checklist (5 gates) + the teammate-readiness finding

Qwen3.8-Flash-Next drops ~8/26 (125B/51B-ngram/6B-active MoE, coding+cowork, 1/9 train cost).
Adopting a new base is a model_registry swap, not a rebuild (frozen-backbone thesis) — so the
question is serve-and-win. Five gates: arch/GGUF support (fork-converter if not day-1),
serveability on 64GB (paging the 51B n-gram embeddings is the escape hatch; measure don't
guess), catalog ModelSpec, head-to-head vs Ornith on SWE + cowork gyms, adopt iff wins AND
serves.

Teammate-readiness audit (2026-08-25): the 26 code/* + web/* + tool/* verbs are KOSHER —
general developer tools, zero benchmark-specific verbs — so benchmarks-as-adapters generalize:
she is already a real code-execution teammate. The gap between executor and friendly teammate
is the GitHub COLLABORATION workflow (open/review/comment PRs, manage issues) — she has local
git but not the collaboration layer. That's the teammate frontier, model-independent.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(github): the executor→teammate layer — she can open/comment PRs and file issues

The teammate gap (Joel: "just fill the gaps" / "friendly in how code and github work are
managed"): she had LOCAL git (commit/push/diff) and full bash, but no first-class GitHub
COLLABORATION verbs — and a native-call model can only emit calls for OFFERED tools, so
gh-via-shell alone left the collaboration layer unreliable. This is the line between a code
EXECUTOR and a colleague.

New `code/github/*` family (native, AiSafe), mirroring code/git/*: wraps the `gh` CLI in the
caller's workspace (which has the repo + remote), reuses workspace_root_for + a blocking
offload so a slow `gh` never holds a shard lock. Missing/unauthed gh FAILS LOUD naming the fix.
- code/github/pr-create   — open a PR from a pushed branch (title/body/base/head/draft)
- code/github/pr-comment  — comment on a PR (review participation)
- code/github/issue-create — file a bug/task/proposal (title/body/labels)

Outlier-validated (PR vs issue, create vs comment) — pr-review/merge/close, issue-comment/
list follow the same run_gh pattern trivially. Blank title/body rejected typed before any
shell-out (code/git/commit's fail-loud contract). Surface ceiling re-pinned 9400→10150 (+748,
stated plainly; Ornith at 166k unaffected, LCD persona pays; shrink-first debt now real).

Deploys at the next round boundary — not rebooting mid-round over the astropy grade we've
chased all session (she doesn't need github tools to solve astropy).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* debug(inference): glass-box the id_slot pin decision — hunt the 0% KV-reuse (persona_id None?)

cached:0 all session with 0 slot_affinity.pinned events, despite /props reporting 4 slots
(Table) and the lease logic being correct. The remaining suspect: request.persona_id is None
on the inference requests reaching the adapter (the id_slot block at 2063 never fires), so no
pin, so llama.cpp round-robins slots and every turn re-prefills 63k from scratch. This probe
(inference.slot_pin.decision: persona + pinned + slot, per request) says definitively whether
persona_id is present and whether a slot leases — one turn instead of a week of guessing.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(inference): pin llama slots per ACTIVITY (persona@room), not per persona — the 0% KV-reuse root cause

The KV-reuse-0% bug that made every citizen turn re-prefill from scratch (~2.7 min/turn,
0% cache) was NOT the prompt and NOT the server. Measured empirically 2026-08-26 against
the live M5 lane:

  1. Server cache reuse WORKS: two byte-identical prompts to one slot → the second
     processed 4 tokens (prompt_n=4), reusing ~997. Partial-prefix reuse ALSO works:
     an 800-token shared prefix reused, only the divergent 200-token tail re-prefilled.
  2. Yet Atlas got cached:0 on EVERY turn even though the pin landed (probe: pinned=true,
     slot=0). /slots showed slot 0 thrashing between 27,315 → 6,144 → 11,963-token
     prompts — four DIFFERENT instance contexts alternating on ONE slot.

Root cause: the slot lease keyed on `persona`. A 4-instance benchmark dispatch forks one
persona (Atlas) into four concurrent solves, so all four leased the SAME slot (step 1 of
lease: "already holds slot 0 → return slot 0"). Each activity's turn clobbered the others'
warm tail; every next turn re-prefilled cold. The warm KV in a slot belongs to an ACTIVITY,
not a persona — and rooms are 1:1 with activities in continuum/airc (Joel), so the correct
warm-context key is (persona, room). A persona running N concurrent activities now leases N
distinct slots and each prefix stays warm; a persona moving room-to-room (e.g. a video chat
mid-bench) simply leases a new context and its old rooms stay warm until genuinely LRU-idle.

- slot_for_persona → slot_for_context(context_key); caller builds `persona@room` (room_id
  authoritative, persona-only fallback for the roomless-inference bug #425).
- lease() + holders + probes reworded to the context key; pinned/evicted probes now name
  the room so a cached:0 streak says WHICH activity thrashed.
- regression test: one persona, four rooms, four distinct slots (was: all slot 0).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(cognition): thread the turn's room into the deliberation request so the slot lease is per-activity

The per-activity slot pin (previous commit) keyed on (persona, room), but the deliberation
request builder hardcoded `room_id: None`, so every citizen turn reached the adapter roomless
— the pin fell back to persona-only and N concurrent solves still collapsed onto one slot.
Measured live 2026-08-26: pin probe showed `room=None` on every solve request even after the
lease fix, so the concurrency win was inert.

The faculty already HAS the room (`ws.room_id`, used for perception facts). It simply wasn't
passed to `build_request_within`, which set the request field to None unconditionally. Thread
it: `build_request_within` takes `room_id: Option<Uuid>`, the production `contribute` caller
passes `Some(ws.room_id)`, and the request carries `room_id.map(|r| r.to_string())`. Each
detached solve already runs in its own per-instance room (`workspace/swe/<instance>`), so the
room now flows unbroken instance-room → workspace → deliberation request → slot lease, and a
persona's N concurrent activities lease N distinct warm slots instead of thrashing one.

The roomless fallback remains only for the genuinely activity-less test rig (None). Making the
room non-optional through the whole cognition path is the deeper cleanup, tracked separately.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(identity): ActivityRoom — an activity without a room is unrepresentable (#425 closed at the type level)

THE LAW (Joel, 2026-08-26): "shouldn't be possible to create activities without rooms" and
"benchmarks without new activities (unless rejoining)". The recurring defect was never a
missing value — it was Uuid::nil() FLOWING AS A ROOM: the literal "000…0" string on the
inference wire (where it became a live KV slot-lease key), a phantom engram context_id, a
[room 000…0] prompt header, and 13,209 invisible roomless turns (35% of one citizen's
cognition). An Option cannot fix that; a witness type can.

- identity/activity.rs (new): ActivityRoom(RoomId), private field, new()/from_uuid() refuse
  nil, mint() names a fresh activity, test_room() is the only fixture constructor. Plan A1.
- Burst carries `room: ActivityRoom` — the room rides ON the perception it belongs to, so
  the rendered header and the driven room can never disagree. Raw-string→Burst conversions
  are #[cfg(test)]-only; production raw text uses Burst::raw_in(room, s).
- drive_to_settle/settle_step drop the separate room param and read burst.room.
  run()/run_in_room()/Workspace::new()/in_room() are #[cfg(test)]-only; production
  constructs via Workspace::from_burst (room witnessed non-nil).
- agent/solve: RunVisibility DELETED. A dispatched run REJOINS its room; a bare run MINTS
  one (probe agent.solve.room_minted). No invisible work.
- cognition/eval + replay: an unnamed exam/replay MINTS its activity instead of nil.
  Exam turns are excluded from training by their cause, not their room: prompt captures
  (schema v3) now record the turn's Cause; the dataset fork-guard (#427) keys on
  cause=="synthetic" (nil-room check kept only for pre-v3 lines).
- ai/should-respond: room_id is a REQUIRED param — typed refusal replaces the silent
  nil-room cognition tick.
- deferred_faculty degrades (skips + probes) on an impossible nil instead of running it.
- source_hygiene/identity_discipline.rs (new): two ratchets — production nil-room literals
  in cognition trees (baseline 4, all deliberate sentinels/fixtures) and string-composite
  id keys in serving (baseline 1, the persona@room format! that slice B1 deletes).
  Per Joel: "ids are UUID always… the moment you start prepending strings to uuids is the
  moment it falls apart."

226 affected tests + 3 new guards green; lib + tests compile clean.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(inference): typed KV slot registry on THE paging engine — ActivityKey structs, string key deleted (plan B1)

Joel's two laws, enforced structurally:
- "we do NOT use strings for keys we use roomId … the moment you start prepending strings
  to uuids is the moment it falls apart": the slot lease now keys on the typed
  ActivityKey { persona: Uuid, room: Uuid } struct — the format!("{persona}@{room}")
  composite and the (String,u64) holders are DELETED, and the
  no_string_composite_id_keys_in_serving ratchet drops to baseline 0, forever.
- "we made a paging system for reuse across many things … instead of 10 different codes
  doing paging, one exists": the KV slot concern is now the THIRD implementer of the ONE
  paging engine (after MoE experts and the LoRA genome) — inference/slots.rs is a thin
  adapter over PagedResourcePool: single-flight assignment, pin-during-use, stats, and
  the ResourcePool/broker surface come free; the concern supplies only the typed key, an
  RAII slot-index lease (an evicted activity's index returns on Drop), and the per-server
  directory. Exactly KV-CACHE-ECONOMY §6's conclusion ("implements the same shape rather
  than inventing a rival"); the priced eviction policy (B5) drops into the engine's
  EvictionPriority seam with no new machinery.

Behavior changes:
- Only fully-attributed requests (persona AND room, both real UUIDs) pin. Roomless
  traffic (dream consolidation, module inference) goes UNPINNED instead of colliding
  with the persona's live chat slot — pinning it there was a guaranteed clobber of her
  warm tail. Slice B2 classes that traffic onto a reserved scratch slot.
- Adapter keeps only the transport half (the /props probe with its 503-boot-race
  discipline); state lives in the slots directory, one per server root.
- B0 measurements recorded en route: llama-server's host-RAM prompt cache restore is
  ~103ms for a 20k-token conversation vs ~32.9s re-prefill (~330x) — eviction is nearly
  free when the prompt re-enters byte-identical, which is what the prefix-stability work
  (B4) protects.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(hygiene): string-composite-key rule skips doc lines quoting the banned shape — ratchet holds at 0

The baseline-0 assert tripped on slots.rs's own history note quoting the dead
format!("{persona}@{room}") key. Same code-only discipline the nil-room rule
already had; predicate test updated.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(bench): every solve is its own activity — mint-or-rejoin per-instance rooms + claim-at-dispatch (plan A2)

The law (Joel 2026-08-26): "benchmarks without new activities (unless rejoining)" is not
allowed. Dispatch minted ONE room per run and every instance-solve shared it, so N
concurrent solves of one persona were N activities wearing one room — the per-activity
KV slot lease could not tell them apart and they thrashed one slot (the measured
cached:0). Now:

- dispatch_staged_swe_solve resolves the card's activity: REJOIN the room the round
  recorded for it (resume after a reboot, a retry — same room, continuity), else MINT a
  real activity room via spawn_activity_room (child of the run room, named
  swe--<instance>--<card8>, spawned AS the claimer when her runtime is live) and record
  it on the round. Probes: work.solve.room_{rejoined,minted,mint_failed}. A mint failure
  degrades to the run room (coarser KV granularity, still visible) and retries next fire.
- BenchRound gains card_activities: HashMap<card, CardActivity{solve_room, assignee}> —
  #[serde(default)] so old round files load clean; persisted with the round so rejoin
  survives reboots (regression test: card_activity_survives_a_restart_for_rejoin).
- The board stays in the RUN room (one denominator; room_holding_card and kickoffs
  untouched); the solve's acts radiate into ITS room.
- Claim-at-dispatch: the pre-claim gate now covers DetachedSolve staged SWE cards, not
  just Gym/Citizen. Unclaimed detached cards were the structural hole that kept every
  detached round Working forever (solve never touches card state; the lapse sweeper
  refuses unclaimed cards) — claimed cards are what let the grade path close them (A3).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(inference): traffic classes + reserved scratch slot — only a TURN may touch a citizen slot (plan B2); fix inverted LRU in the paging engine

The sidecar clobber, closed structurally: the small same-room calls (should_respond,
check_redundancy, generate_response, …) pinned the SAME slot as the citizen's turn and
truncated her ~30k warm tail to their tiny common head — KV reuse broke even for a SOLO
citizen. The smoke probe and the unpinned producers could LCP-steal any warm slot.

- SlotClass { Turn, Sidecar, Background, Probe } + ONE tested purpose→class map in
  inference/slots.rs (answers INFERENCE-SCHEDULING's open question with the existing
  `purpose` field; unknown purposes default AWAY from citizen slots, so a new producer
  can never clobber by omission).
- Placement law in the adapter: Turn pins its ActivityKey slot; every other class lands
  on the reserved SCRATCH slot (highest index, reserved when the server has ≥3 slots;
  on ≤2-slot servers non-Turn goes unpinned with cache_prompt:false so it cannot persist
  a stolen cache). Decision probe now carries traffic class.
- The decode smoke probe pins itself to scratch + cache_prompt — it was free to evict a
  citizen's warm tail to prove the lane decodes, the exact contention its own doc warned
  about.

And a real bug in the shared engine, caught by this slice's recycle test:
paging::pool::lru_priority returned -(last_access_at) — with evict_at_least's ascending
sort + evict-from-front, that evicted the NEWEST entry first. MRU wearing LRU's name,
inherited by every pool using the helper. Fixed to the raw timestamp (size_weighted_lru
same), with an order-pinning regression test in the engine.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(bench): harness-only terminal close — a graded solve closes its card, rounds can finish (plan A3)

DetachedSolve rounds could never reach Done: the solve never touched card state, so cards
sat Claimed (post-A2) or Open forever, observe_card_event never fired, and every boot
reaped the eternally-Working round. The autograde already produces the final verdict
inside the solve (grade.json + benchmark.attempt.end on the wire) — what was missing was
the kanban consequence.

After the attempts loop, a claim-dispatched run (run_id = claim-<card uuid>) with a REAL
verdict on disk closes its card via change_work_card_state_in, authored through the run's
own persona (dispatch subscribed her to the run room), falling back to any live citizen —
the same authoring rule as the lapse sweeper, which remains the dead-session fallback.
BENCHMARK-AS-KANBAN holds: the citizen moves working states, the harness owns terminal.

An UNGRADEABLE verdict (env fault) deliberately leaves the card open: a resume re-fires
it — the owed retake — instead of burying an absence as a zero. Probes:
benchmark.card.closed_by_harness / benchmark.card.close_skipped (with why).

Also exposes modules::work::room_holding_card crate-wide (one resolver, third consumer).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(bench): one driver, three edges — the follow-on fires the next card, and dispatch parks before it authors (plan A4)

Two starvation kills:

1. curator_airc ran BEFORE the 180s residency park, so a dispatch fired inside the
   post-boot window refused instantly with "none are online" while the wait built for
   exactly that window sat unreachable 30 lines below (hit live 2026-08-26, twice).
   The curator now resolves AFTER the park — wait for a citizen, then author.

2. solve_cap = lanes.max(1) was the LAST word: dispatched − solves_fired was permanent
   starvation ("posted, kicked off, and left unworked by design"). Now it is only the
   INITIAL word: bench_round::next_unworked_after(card) is the ONE driver decision —
   first unsettled card, no live run, staged assignee — and the card-settled edge in
   benchmark_grade fires it (probe bench.round.follow_on). Dispatch records every
   card's assignee at staging (card_assignees, serde-default) so never-fired cards
   have owners. The claim-<card> in-flight guard makes double-fire impossible under
   racing settle events. Citizen-driver rounds are exempt — they drive themselves.

The same next_unworked_after is the decision the boot-resume edge (A5) calls — one
scheduler, three edges, never a parallel runner.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(bench): boot resume = rejoin — Working rounds survive reboots and re-fire themselves (plan A5)

Continuity is the default, reset is the exception. Before: boot DELETED every Working
round (destroying the room/cards/assignees a resume needs), journaled killed solves
failed with needs_redispatch=true, and nothing ever re-fired — "cards sit Open, zero
turns, indefinitely" (documented since 8/17). After:

- reap_orphaned_rounds keeps Working rounds; only a TTL-stale (7d) abandoned file
  expires (the state dir's eviction story). Probe renamed bench.round.expired.
- modules/benchmark_resume.rs (new, one-shot, benchmark-side — the serving daemon's
  refusal to re-dispatch stands, per BENCHMARKS-ARE-ADAPTERS-NOT-A-RUNNER): parks on
  serving decode-readiness (600s) then residency (20min, the reconciler window), then
  fires the SAME one driver decision (next_unworked_per_round →
  dispatch_staged_swe_solve) once per surviving round; the card-settled edge chains the
  rest. Each re-fired solve REJOINS its recorded activity room and preserved workspace —
  resume is recall, not restore; fresh-start and post-reboot are one code path. Probes:
  bench.round.resumed / resume_blocked(reason).
- The boot solve-reaper's running→failed flip is what releases the claim-<card> guard,
  so re-fire is dedup-safe by construction.
- Reboot guard reworded: killed solves now auto-resume (restart-and-resume path).
- Reap test rewritten to the continuity contract (survive fresh, expire at TTL-zero),
  TTL injectable.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(activities): every activity is a REAL airc room from a recipe — bare solves and gym rounds included

Joel's check landed exactly where the shortcut was: A2's dispatch solves were already
real airc rooms (spawn_activity_room, recipe-typed, joinable, child of the run room) —
but the FALLBACK paths still minted id-only rooms: attributable UUIDs with no joinable
airc entity behind them. Room-shaped numbers, not rooms. Closed:

- Bare agent/solve: spawns a REAL activity room (solve--<run_id>, BENCHMARK_HARD_RS
  recipe) through the persona's own runtime — a human or peer can join the solve and
  assist like any activity. The id-only mint survives strictly as the probed last
  resort when no runtime exists (probe now carries joinable=true/false).
- benchmark/round (the gym path): its eval ran ROOMLESS by construction — the exact
  "vanilla benchmark bypassing rooms" pattern. Now the round spawns-or-rejoins its
  activity room (round--<benchmark>--<run_id>; airc's join-is-creation makes the
  deterministic name a free mint-or-rejoin across resumes) through the examinee's own
  runtime and passes it to the eval. She stands her exam IN a room you can join.
- ActivityRoom::mint() doc rewritten as the last-resort it now is: never reach for it
  where a runtime can spawn the real thing.

Wrapping airc, never bypassing it: rooms are airc's (join-is-creation), cards are airc's
board, claims/closes are airc verbs as the persona's identity; continuum keeps only the
round's recipe-side bookkeeping.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(cognition): move the per-minute clock out of the cacheable system prefix (plan B4)

The [now …] clock sat LAST in the stable system blocks, priced as "at most one
re-prefill per minute" when turns were seconds apart. Acts now run MINUTES, so the
minute tick invalidated the ENTIRE conversation tail behind the prefix nearly every
act — and byte-stability is worth ~330× (measured 2026-08-26: the server restores a
byte-identical 20k conversation from its prompt cache in ~0.1s vs ~33s re-prefill;
restore keys on identical bytes).

The clock now rides volatile_blocks — rendered as the newest trailing turn: same
temporal grounding, nearest generation, zero prefix invalidation. Eval's pinned epoch
unchanged. (The Burst header clock is inside the conversation turns, not the prefix,
and stays.)

mmproj item from this slice: already satisfied in-tree — serving.mmproj_on_main_lane
defaults false per model row with the serving.vision.mmproj_withheld probe; sight
routes via the sidecar.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(inference): priced slot eviction through the engine's own priority seam (plan B5)

Bare LRU is replaced by the KV-CACHE-ECONOMY §3.2/§6 classic policy, dropped into
PagedResourcePool's EvictionPriority closure — no new machinery, the engine's seam was
built for exactly this:

- cost basis: the activity's last-known prompt size (KvSlotLease.tail_tokens, updated at
  every pin from the request's chars/4 estimate — comparable across slots, which is all
  eviction needs), discounted by staleness (halved per idle hour) so an abandoned giant
  eventually yields to live small activities.
- ascending sort evicts the CHEAPEST tail first, so a 7.6k head can never displace a warm
  36k tail — §2's 4.7× arithmetic, pinned as a test (a_small_head_never_evicts_a_large_
  warm_tail: the fresher small activity is the victim, recency notwithstanding).
- non-Turn traffic can't evict ANY citizen slot structurally (B2: scratch-only).
- the learned/bandit policy remains a drop-in behind this same closure.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(serving): govern the 8 GiB host prompt cache — explicit --cache-ram, accounted on the lease (plan B6)

llama.cpp's cache_ram_mib defaults to 8192: 8 GiB of host RAM the substrate never
passed, never budgeted, and never told the governor about — the textbook un-owned cache
class (KV-CACHE-ECONOMY §4; the 2026-07-13 460GB incident's rule). And it is
load-bearing: measured 2026-08-26, a saved 20k-token conversation restores from it in
~0.1s vs ~32.9s re-prefill (~330×) — it is the spill space that makes slot eviction
nearly free when prefixes stay byte-stable (B4's clock fix protects exactly that).

- lane_args::CACHE_RAM_MIB = 4096 (half the default; holds every slot's conversation
  once on current geometry), passed explicitly as --cache-ram on every lane.
- The SAME constant rides the host-cache lease inputs (moe_host_cache_lease_inputs
  compute term), so the expert cache can never be derived as if that RAM were free —
  one number, two readers, no drift.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(cognition): the turn's activity reaches the curriculum — room on SettleOutcome/ExperienceRecord; self-tick works IN its focus room (plan A6)

- SettleOutcome carries `room` (from the burst's witnessed ActivityRoom) and
  ExperienceRecord persists it (serde-default so pre-A6 rows load; nil there means
  "recorded before rooms were carried", never a live roomless turn). The curriculum
  stream can finally attribute a lived turn to the activity it happened in — before,
  the room survived only as prose inside world_state's header.
- infra_failure outcomes carry their activity too (threaded through eval's hang
  backstop).
- Self-tick consistency: composition used the FOCUS room (her freshest claim's room)
  while the anchor/burst/drive/say used default_room — she reasoned about her claim's
  room and then acted in a different one. One tick_room now: focus when she holds live
  work, default otherwise; her working self-ticks happen IN her claim's activity.

Deferred within A6 (honest note): validate_response / resolution_compute /
generate_recipe / rate_proposals still send room_id: None — their KV impact is already
neutralized (B2 routes Sidecar class to scratch), so what remains is capture
attribution; threading ambient persona+room through those four orchestrators is a
follow-up pass.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(bench): resume retries boundedly, and dispatch's silent early-returns now speak

Live finding from the first acceptance run (2026-08-26): the boot resume FIRED
(bench.round.resumed in the log; Atlas's claim survived the reboot and her self-tick
bound to the run room), but the re-fired dispatch died in one of its UNPROBED early
returns — board unreadable / card not in the caller's projection / no staged checkout —
and the round sat Working with nothing saying why. The exact "absence that looks like
normal" class this whole arc exists to kill.

- Every early return in dispatch_staged_swe_solve now probes its reason (board read
  failure, card-not-in-projection with the board size, no-staged-checkout).
- The resume is a bounded retry loop (12 × 90s): a re-fire can abort legitimately right
  after boot (her board projection still resuming); with no settle event to chain from,
  one-shot was structurally insufficient. The claim-<card> in-flight guard makes every
  retry harmless; exhaustion probes resume_blocked(retries_exhausted) and leaves the
  round Working for the next edge.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(bench+serving): dispatch reads the RUN room's board (pagination killed a card), and failed sidecar candidates are benched per boot

Two live finds from acceptance round 2, both named by the new probes:

1. "card not in the caller's board projection": dispatch read the caller's GLOBAL
   paginated projection (work_board_complete) — of two cards on one run-room board,
   one dispatched and one silently vanished purely by page position. The dispatch has
   the run room in hand (StagedSolveDispatch requires it); it now resolves the
   claimer's subscription for THAT room and reads work_board_in — room-scoped, the one
   board that matters, no pagination. Every abort path probes its reason (not
   subscribed yet / board unreadable / card truly absent).

2. The vision sidecar respawned a candidate that FAILS its verifiable-sight check on
   every reconcile tick — one boot's pick was a 15GB non-VL row whose churn starved the
   MAIN lane below plan, so serving never became ready and the resume blocked
   (reason=serving) for the whole boot. find_candidate now skips candidates that failed
   their sight check this process (probed in the skip list); fail once, fall through to
   the next row; a reboot retries honestly. The sight-check failure itself (VL-7B also
   failing "--mmproj passed but /props reports no vision") is a separate root to chase —
   this fix removes the CHURN, not the sight bug.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(serving): the sidecar keeps its own eyes — the mmproj withhold keys on the lane's ROLE

The sight-check root, glass-boxed live: EVERY sidecar spawn flowed through the same
serve() path as the main lane, whose mmproj_on_main_lane withhold (written so multimodal
never disables --cache-reuse on the MAIN persona lane) stripped the SIDECAR's projector
too. The sidecar launched sightless by our own hand, honestly failed its /props sight
check ("--mmproj was passed but modalities.vision=false"), and — before the benching
fix — churned. A guard scoped too broadly, textbook.

ServingTarget gains `vision_sidecar: bool` (a required field, not an Option — the role
is a fact of every lane): the withhold now reads
`mmproj_on_main_lane || target.vision_sidecar`. The sidecar constructor sets true;
main/eval/test lanes false.

With this + the per-boot benching, the sidecar should come up SEEING on the next boot
(serving.vision.sidecar_up), giving every citizen sight through the description bridge
again.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(bench): resume re-parks per attempt — a one-shot serving park forfeited whole boots

Measured live: serving became decode-ready ~3 min AFTER the single 600s park expired,
and the resume abandoned the boot with rounds Working — a dead-reckoned timeout, the
exact shape ROUND-LIFECYCLE §7 bans. The serving + residency parks now live INSIDE the
12-attempt retry loop: a blocked attempt probes its reason and re-parks instead of
giving up. Total patience ≈ 12 × (600s park + 90s spacing), which outlasts any healthy
bring-up on this box.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* chore(vendor): update both forks — llama.cpp merged to upstream b10636, whisper.cpp to v1.9.3

llama.cpp (CambrianTech fork): merged upstream b10636 (493 commits over our b10143 base;
branch merge/b10636 pushed to the fork). Upstream has ADOPTED and now maintains our
KIMI_K3 arch — took their refined model family and arch tables; kept our MoE
expert-paging instrumentation (ggml-backend union), conversion mxfp4 hooks, and
gguf_writer KDA method; removed the hparams block upstream duplicated. Merged
llama-server builds and runs (version build-10690, commit 2ae88c637); the FFI binding
followed upstream's llama_sampler_init_penalties signature (n_vocab first arg) through
safe.rs and both backends. install-llama-server --force is building the merged engine
into ~/.continuum/bin (next lane launch runs it). This is the base for OUR fix to the
mmproj×cache-reuse hard-disable — the "stupid shit" the fork exists to fix.

whisper.cpp: clean fast-forward (no local patches) v1.8.4+58 → v1.9.3.

Also in this commit (live find from acceptance round 5): the resume now RECONCILES a
round's cards against the run room's board before re-firing — a card settled while a
core was down fired its event into the void, and the resume retried a ghost forever
("not on the RUN room's board" every 90s). Terminal-on-board or absent cards are settled
directly (bench.round.reconciled probe; settle_card_direct routes through the same
observer as wire events, so Done still fires single-sourced).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(ffi): follow the b10636 vendor split — link vendor-hash, restore per-layer head APIs

Upstream b10636 split sha256/xxhash into vendor/hash (libmtmd now needs
hash_sha256_hex at link) and our per-layer head-geometry API definitions vanished when
the merge took upstream's llama-model.cpp wholesale (declarations survived in llama.h;
the serving governor's KV pricing reads them — restored in fork commit 67b2868e6, pushed).
build.rs gains the vendor-hash search path + static link. Server binary links clean
against the merged tree.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(vision): citizens can LOOK — vision/look toolbelt verb + the vision-qa benchmark

Two halves of "pass vision-based benchmarks" (Joel, 2026-08-26), building on the
restored sidecar sight:

1. vision/look (AiSafe, native): a citizen looks at an image file in her workspace with
   her own eyes — file → base64 → the SAME describe bridge live rooms use (vision
   sidecar / best vision model) → what her eyes report, with a `focus` hint. This was a
   structural hole: cognition/vision-describe is Internal, and a native-call model can
   only emit calls for OFFERED tools, so workspace images (screenshots, charts,
   benchmark PNGs) were invisible to every citizen. VisionModule gains the executor
   slot (the LateBound pattern); surface ceiling re-pinned 10150 → 10400, stated
   plainly (+191 tokens, the verb's param schema).

2. vision-qa (16 tasks, Grader::Answer): OUR input-side vision benchmark — a generated
   PNG (colored shapes; deterministic seeded LCG; zero blobs in git;
   contamination-free by construction) is staged into her workspace (setup_shell,
   openssl base64 -d), she must LOOK with vision/look and answer an objective question
   (color/count/shape) graded by held-out substring. Measures the WHOLE sensory loop —
   tool-act → sidecar describe → reason → answer; the sightless-sidecar bug would have
   scored zero here on day one. Registered as a generated gym in resolve_gym
   ("generated:vision-qa"); runs through the standard benchmark/round → eval path in a
   real activity room like every gym.

Tests: gym determinism + EvalTask parse + oracle held out of the prompt + renderer
paints the declared colors; mime refusal before spending a generate; the vision family
assembles all seven verbs.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(bench): ABSENT is negative evidence — reconcile defers to board replication before ghost-settling

Measured minutes after the reconcile shipped: a FRESH round's card read Absent during
post-boot replication and the eager arm settled a live card as a ghost (false
completion). Absent now settles only after attempt >= 4 (~5 min of spaced misses);
earlier attempts probe bench.round.reconcile_deferred and fall through to the dispatch.
Terminal-state reads stay immediate — a state is positive evidence.

(Also: the first cut of this commit silently no-op'd — python str.replace missed on
whitespace and I printed success unconditionally; this one is grep-verified on disk.)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(cognition): the burst-header minute clock was the remaining tail-killer — removed (glass box receipt)

Live glass box on the vision+SWE boot: reuse 30.3%, with EVERY deliberation showing
cached=7945 exactly (the stable system head) and the ENTIRE 10k-27k conversation tail
re-prefilled each act — ~647k fresh tokens in one boot at ~616 tok/s (~45s/act pure
re-read). The divergence sits at the first message bytes: the burst header still
rendered [now HH:MM] even after the system-prompt clock moved to the volatile tier, so
the minute tick invalidated every message behind it on multi-minute acts.

Removed: the header is now just the constant [room …] line; temporal grounding is the
volatile-tier clock (newest-turn delivery, zero prefix cost) fed from Burst.now_ms,
which stays. Placement receipts also confirm B2 live: turns on distinct citizen slots
(two activities, two slots), background on scratch, queue waits 0ms.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(bench): two score-level harness defects — dataset SEARCH (Verified instances were ungradeable) and the re-drive restates the task

Glass-boxed live on the resumed astropy-13236 attempt, both worth real points (Joel:
"these defects pay off like 20%+ score if not more"):

1. grade_swe's dataset default hardcoded SWE-bench_Lite, so ANY Verified-only instance
   auto-graded "[not_found] … not found in princeton-nlp/SWE-bench_Lite" — an automatic
   ungraded attempt regardless of her work. With no explicit dataset, the grader now
   SEARCHES every known SWE dataset (from the one catalog via swe_dataset()) and the
   not-found error names everything searched. The instance names its dataset; the
   grader's job is to find it, not guess one.

2. The empty-diff re-drive's "structural fact" told her to fix "the example in the task
   description" — but the re-drive burst contained ONLY the fact. In-process that
   worked by accident (the fork's working memory still held the task); a RESUMED
   attempt runs on a fresh fork and she was blind — she literally answered "which
   file?" and settled empty, burning the attempt. The re-drive burst now restates the
   full task beneath the fact: fresh-start and post-interrupt read identically
   (continuity, one code path).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(bench): restore the spawner's focus after the solve-room mint — cards were landing on the wrong board

The one-resident boot's glass box: with a single citizen resident, the dispatch's
curator IS the assignee (any_live_citizen), so ONE airc handle both creates cards and
spawns solve rooms. spawn_activity_room's documented side effect moves that handle's
current-room pointer to the new solve room — so in the dispatch loop, card 1 landed on
the RUN room's board, the mint yanked focus, and cards 2-3 were created onto the SOLVE
room's board. Measured: "not on the RUN room's board" forever for 2 of 3 fresh cards
(their solves dead at dispatch), then the Absent reconcile settling live-but-misplaced
cards as ghosts.

Until airc grows subscribe-without-focus (#290), the mint restores the pointer itself
(spawner.join(run_room.name), probed on failure). The two eaten instances
(astropy-14365/-14995) get re-dispatched on this build.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* chore(vendor): pin llama.cpp to the compiling b10636 merge tip (dedup'd K3 hparams)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(tests): the full suite is green again — absence typed, unwraps justified, seams named, tests follow the laws they test

CI caught what a cargo-check-only validation missed (7 failures). Each fixed at
the cause, no baselines bumped:

- ExperienceRecord.room: Uuid-with-nil-markers → Option<Uuid>. Absence is typed
  (None = honestly not carried), never nil-as-a-value — the nil-room ratchet
  returns to baseline by design, not exemption.
- 30 new unwrap/expect sites now carry same-line WHY-safe justifications; the two
  new serialization sites name their true boundaries (vision wire payload, gym
  setup_shell heredoc).
- The adapter's slots seam is explicitly typed (SlotDirectory / KvSlotPool named
  at the handoff) — the reachability ratchet sees the wiring that was already real.
- should_respond tests pass the roomId the command now (correctly) requires.
- deferred_faculty test used nil-room workspaces, which the worker now (correctly,
  #425) skips — the test never exercised the lane; it uses a real room.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(slots): equal-cost evictions tie-break by recency, never by map-iteration order

Linux CI evicted a just-refreshed slot twice in a row while macOS passed — the
priced closure scored equal-cost tails identically and the tie fell to hash
ordering, a platform coin flip that would hit production the same way (two idle
same-size activities: the engine could evict the one about to speak). Priced
first, LRU among exact equals: recency bonus strictly smaller than one
token-cost step, so pricing always dominates.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

---------

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants