Skip to content

Candle token limiting: prevent NaN in quantized models - #268

Merged
joelteply merged 2 commits into
mainfrom
feature/candle-token-limiting
Feb 13, 2026
Merged

joelteply merged 2 commits into
mainfrom
feature/candle-token-limiting

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

  • Add SAFE_INPUT_TOKENS (800) limit for quantized model input to prevent NaN/Inf in logits
  • Token-based truncation using the tokenizer (more accurate than character-based)
  • Preserves 30% start (system prompt) + 60% end (recent messages) when truncating
  • Logs TOKEN LIMIT warning when truncation occurs for debugging

Also includes:

  • Fix ts-rs binding generator to ignore harmless serde attribute warnings
  • Add threshold test in quantized.rs for future NaN threshold validation
  • Add INCIDENT_CAPTURE logging for reproducibility of NaN issues

Test plan

  • Deployed with npm start
  • Verified Helper AI produces coherent responses (not garbage)
  • Verified Teacher AI produces coherent responses
  • Confirmed candle logs show TOKEN LIMIT: 1739 -> 720 tokens truncation
  • No build errors

Evidence from logs

[WARN] TOKEN LIMIT: 1739 -> 720 tokens (RAG sent too much context for quantized model)
[WARN] TOKEN LIMIT: 3288 -> 720 tokens (RAG sent too much context for quantized model)

Local AIs now respond coherently instead of producing garbage like "I zeroes.valueOf.subplots belonging збільш Votersnonce"

Rust logging improvements:
- Add clog_info!, clog_warn!, clog_error!, clog_debug! macros for easy logging
- Auto-route logs by module_path!() to appropriate directories
- Wire to LoggerModule's concurrent writer (sync_channel + try_send = NEVER blocks)
- Convert println!/eprintln! to clog_* in orm/sqlite, voice/orchestrator,
  voice/tts/phonemizer, ai/adapter, concurrent/message_processor

New commands:
- logging/enable, logging/disable, logging/status - control Rust logging
- sentinel/logs/list - list log streams for a sentinel with size/mtime
- sentinel/logs/read - read log content with offset/limit
- sentinel/logs/tail - get last N lines (like Unix tail)

SentinelLogWriter:
- Non-blocking async TypeScript log writer for per-sentinel logs
- Event streaming via sentinel:{handle}:log for real-time UI
- Directory structure: .sentinel-workspaces/{handle}/logs/

Documentation:
- docs/OBSERVABILITY-ARCHITECTURE.md - overall vision
- docs/SENTINEL-LOGGING-PLAN.md - sentinel logging design
- Add SAFE_INPUT_TOKENS (800) limit for quantized model input
- Token-based truncation using tokenizer (not character-based)
- Preserves 30% start (system prompt) + 60% end (recent messages)
- Logs TOKEN LIMIT warning when truncation occurs

Also:
- Fix ts-rs binding generator to ignore harmless serde warnings
- Add threshold test for future NaN threshold validation
- Add INCIDENT_CAPTURE logging for reproducibility

Verified: Helper AI and Teacher AI now produce coherent responses
instead of garbage output from NaN/Inf in logits.
Copilot AI review requested due to automatic review settings February 13, 2026 20:32
@joelteply
joelteply merged commit 8cb9ad5 into main Feb 13, 2026
4 of 7 checks passed
@joelteply
joelteply deleted the feature/candle-token-limiting branch February 13, 2026 20:33

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 PR addresses critical NaN issues in quantized AI models through token-based input limiting and significantly enhances the logging infrastructure with new convenience macros and sentinel logging capabilities.

Changes:

  • Adds 800-token safe input limit for quantized models with 30%/60% start/end truncation strategy to prevent NaN/Inf in logits
  • Introduces clog_* logging macros (info/warn/error/debug) with auto-routing based on module paths for convenient Rust logging
  • Implements sentinel log management commands (list/read/tail) and SentinelLogWriter class for full, non-blocking log capture
  • Adds logging control commands (enable/disable/status) for per-persona logging configuration
  • Includes comprehensive documentation (OBSERVABILITY-ARCHITECTURE.md, SENTINEL-LOGGING-PLAN.md) and test infrastructure

Reviewed changes

Copilot reviewed 53 out of 54 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
candle_adapter.rs Implements token-based truncation for quantized model inputs to prevent NaN
quantized.rs Adds incident capture logging and threshold tests for NaN debugging
logging/mod.rs Defines new clog_* macros with module-path-based auto-routing
modules/logger.rs Implements global log sender with bounded sync_channel for non-blocking logging
SentinelLogWriter.ts New class for non-blocking, full-output sentinel log capture
sentinel/logs/* Three new commands for accessing sentinel logs
logging/* Three new commands (enable/disable/status) for logging configuration
orchestrator.rs, sqlite.rs, etc. Replaces eprintln! with clog_* macros throughout
generate-rust-bindings.ts Fixes ts-rs warning handling to not fail builds
OBSERVABILITY-ARCHITECTURE.md Comprehensive observability documentation
SENTINEL-LOGGING-PLAN.md Detailed plan for sentinel logging implementation
Files not reviewed (1)
  • src/debug/jtag/package-lock.json: Language not supported

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

Comment on lines +449 to +450
// Set global sender for clog_* macros (if not already set)
let _ = GLOBAL_LOG_SENDER.set(log_tx.clone());

Copilot AI Feb 13, 2026

Copy link

Choose a reason for hiding this comment

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

The global sender initialization on line 450 uses let _ = GLOBAL_LOG_SENDER.set(log_tx.clone()) which silently ignores if the sender was already set. The comment says "if not already set" but there's no verification or warning if multiple LoggerModule instances are created. This could lead to confusing behavior where later instances silently fail to set the global sender, and logs from clog_* macros would go to the first instance's channel instead of the current one. Consider either:

  1. Ensuring only one LoggerModule instance is ever created
  2. Logging a warning if set() fails
  3. Returning an error if the sender was already set

Copilot uses AI. Check for mistakes.
Comment on lines +154 to +185
private async appendToStream(stream: string, content: string, sourceType: 'stdout' | 'stderr' | 'info' | 'error'): Promise<void> {
const logPath = this.getLogPath(stream);
const timestamp = new Date().toISOString();

// Emit event for real-time streaming (non-blocking)
if (this.emitEvents) {
const event: LogChunk = {
stream,
chunk: content,
timestamp,
sourceType,
};
// Fire-and-forget - don't await event emission
Events.emit(`sentinel:${this.handle}:log`, event).catch(() => {});
}

// Queue writes to same file to prevent interleaving
const existingWrite = this.writeQueue.get(stream) ?? Promise.resolve();
const newWrite = existingWrite.then(async () => {
try {
await fs.appendFile(logPath, content);
} catch (e) {
// Log write failure but don't crash
console.error(`[SentinelLogWriter] Failed to write to ${logPath}:`, e);
}
});

this.writeQueue.set(stream, newWrite);

// Don't await - return immediately for non-blocking behavior
// The write will complete in the background
}

Copilot AI Feb 13, 2026

Copy link

Choose a reason for hiding this comment

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

The appendToStream method doesn't await the write operation (line 183-184 comments say "Don't await - return immediately for non-blocking behavior"). However, the method signature is async and callers await it. This creates a false sense of completion - callers think the write finished when it hasn't. This can lead to:

  1. Lost log data if the process terminates before background writes complete
  2. Race conditions if callers depend on logs being written
  3. Misleading async/await semantics

Consider either:

  • Making this method synchronous and truly fire-and-forget
  • Actually awaiting the write operation for callers who need confirmation
  • Documenting clearly that "await" on this method only queues the write, doesn't complete it

Copilot uses AI. Check for mistakes.
Comment on lines +445 to +448
// Truncate by keeping first ~30% and last ~60% of tokens
// (system prompt at start, recent messages at end)
let keep_start = SAFE_INPUT_TOKENS * 30 / 100; // 240 tokens
let keep_end = SAFE_INPUT_TOKENS * 60 / 100; // 480 tokens

Copilot AI Feb 13, 2026

Copy link

Choose a reason for hiding this comment

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

The token truncation logic (30% start + 60% end = 90%) doesn't add up to the target SAFE_INPUT_TOKENS (800). It produces 240 + 480 = 720 tokens (line 447-448), which is 10% less than intended. This inconsistency could be confusing and may not fully utilize the safe threshold. Consider either:

  1. Adjusting the percentages to sum to 100% of SAFE_INPUT_TOKENS (e.g., 33% + 67%)
  2. Adding an explicit comment explaining why 720 tokens is intentionally chosen despite an 800 token threshold
  3. Using absolute token counts instead of percentages for clarity

Copilot uses AI. Check for mistakes.
Comment on lines +454 to +461
truncated_ids.extend_from_slice(&token_ids[..keep_start]);

// Add truncation marker (just use newlines, don't add extra tokens)
// The model will understand context was cut

// Keep last N tokens (recent messages)
let end_start = token_ids.len().saturating_sub(keep_end);
truncated_ids.extend_from_slice(&token_ids[end_start..]);

Copilot AI Feb 13, 2026

Copy link

Choose a reason for hiding this comment

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

There's no newline or separator added between the kept start tokens and kept end tokens (lines 454-461). This means the truncation point is invisible in the decoded text, which could create grammatically incorrect or confusing prompts. The comment on line 456-457 says "just use newlines" but no newlines are actually added. Consider adding explicit separator tokens or newlines to mark where truncation occurred, making it clearer to the model (and humans debugging) that context was removed.

Copilot uses AI. Check for mistakes.
Comment on lines 78 to 85
if (exitCode === 0) {
return true;
}

// Check if tests actually passed despite stderr warnings
if (stdout.includes('test result: ok') || (stdout + stderr).includes('passed')) {
return true;
}

Copilot AI Feb 13, 2026

Copy link

Choose a reason for hiding this comment

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

The ts-rs warning detection logic has redundant checks. Lines 78-79 check if exitCode === 0, and lines 83-85 check if stdout contains success indicators. However, if exitCode is 0 (line 78-79 returns true), the code at lines 83-85 will never execute. This makes lines 83-85 dead code. Consider removing the redundant success check or restructuring the logic for clarity.

Copilot uses AI. Check for mistakes.
async execute(params: LoggingStatusParams): Promise<LoggingStatusResult> {
const config = LoggingConfig.getConfig();
const allCategories = Object.values(LOGGING_CATEGORIES);
const personaFilter = params.persona?.trim().toLowerCase().replace(/\s+ai$/i, '').replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');

Copilot AI Feb 13, 2026

Copy link

Choose a reason for hiding this comment

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

The persona ID normalization logic (line 28) is duplicated across multiple commands (logging/status, logging/enable, logging/disable). The transformation trim().toLowerCase().replace(/\s+ai$/i, '').replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '') should be extracted into a shared utility function to ensure consistency and make maintenance easier. If the normalization logic needs to change, it would currently require updating multiple files.

Copilot uses AI. Check for mistakes.
joelteply added a commit that referenced this pull request Jul 30, 2026
…he container port (#268)

Transport-proof copy of what I mined from sqliteai/waste for BigMama's lane:
byte-exact ExpertRec, single (layer,expert) key, LFRU-vs-LRU numbers, the
16KiB dual-purpose alignment, the Gate-5 working-set CLIFF that explained
her exactly-0 retention, and the measured death of non-uniform bits.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Jul 30, 2026
… planner (#269 slice 2)

The 2026-07-30 audit finding, now fixed and pinned: capacities fed to the
planner are LIVE free-byte readings that exclude bytes already-promoted
experts hold, so every re-plan under unchanged demand under-counted each
tier by its own resident set — slow thrash-to-cold. New
plan_expert_residency_with_resident adds resident bytes back (from the
pager's ledger, never the OS), making unchanged demand a FIXED POINT.
Plus a loud expert_pager.below_cliff probe (WASTE Gate 5 arithmetic via
EcacheBudget): fast tiers below one token's working set = structurally
zero reuse — 'shrink records (#268), don't debug cache logic'. The
activated_per_token input is an ARCH-PROFILE fact passed explicitly,
never inferred from partial hit ledgers.

Test proves all three: naive re-plan shrinks (bug real), add-back re-plan
is byte-identical (fixed point), nothing demotes under unchanged demand.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Jul 30, 2026
Read-side of the WASTE-shaped streaming container (docs/reference/WASTE-EXTRACT.md):
manifest.json is the versioned seam contract (record_bytes must be 4KiB-aligned,
activated_per_token feeds the cliff arithmetic), experts-L{n}.bin banks open lazily
(a grid node holding 2 of 60 shards must not stat the other 58), fetch = ONE
positioned read + an 8-byte header identity check so a drifted offset table is an
ERROR, never a silently-wrong expert (the reuse=0 bug shape). 4 invariant tests:
round-trip every (layer,expert), geometry refusals, identity mismatch, version gate.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Jul 30, 2026
… pass = zero disk reads

The #268/#269 halves proven to compose: above-cliff budget + recurring working
set means the second pass is served entirely from cache. Reuse > 0 is now a
pinned invariant, not an assumption.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Jul 31, 2026
…ckend contract (#268 kernels)

The 1-10 tok/s lane's drift killer: BOTH GPU kernels (her CUDA, my Metal)
validate against ONE backend-neutral Rust reference, mined verbatim from
upstream convert.py — per-channel scale applied pre-quant, residual stages,
decode = scale x SUM(stage codebook rows); blocked index layout
[M/64][nvr][64][stages] (their measured 1.44x gather win) with the offset
formula in ONE function and the byte order pinned as a golden literal.
Padding path exercised; f16 LE conversion point pinned. A kernel is correct
when it reproduces the goldens exactly — no more fmt-4/5-class surprises.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Jul 31, 2026
…he read side of moec_pack_dir_tiered (#269/#268)

The reader half of the tier contract locked with the foundry 2026-07-31
(her packer round-trips 82/82 on the write side; our specs crossed mid-wire
and matched line-for-line). TierSpec {id, quant, record_bytes} descending
fidelity; banks experts-L{n}-T{t}.bin at offset expert_id x record_bytes;
fetch_tier(key, tier, buf) is pure mechanism — the pager's policy seam
(importance x recency x quant-sensitivity -> tier/residency/prefetch, Joel's
all-star/cruft control law) decides WHICH tier, never the container.

v1 stays the degenerate case by construction: a manifest without tiers[]
synthesizes one tier from the top-level record_bytes and keeps legacy
experts-L{n}.bin names — version picks the naming, no heuristics. The
alignment law holds per tier; tier ids must equal their index (order drift
between writer and reader refuses at open); out-of-range tiers refuse.

Tests mirror the packer's round-trip: every (layer, expert, tier) reads
back its own header + tier-distinguishable payload; v1-without-tiers-field
parses and serves via the tier-less fetch(); range/order violations refuse.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Jul 31, 2026
…ndwork (29 commits) (#2061)

* fix(cognition): hydrate speech rings from the durable transcript at boot (#265)

Reboot wipes the in-process repetition-fact rings exactly when they're most
needed: the post-boot wake round, where every persona re-emits its greeting
2+ times with own_repetition/[settled] blind (observed live 2026-07-30,
three times — Anwen's third verbatim greeting landed while this fix's test
compiled). The durable transcript (#140) already holds the history; the
persist listener now replays the latest 200 lines into the per-room and
per-sender rings before consuming live events, with a bounded wait on the
executor slot (the #201 ordering race) and a speech.rings.hydrated probe.

Test: hydrate_speech_rings_seeds_room_and_own_rings_from_durable_store —
fresh UUIDs per run so the process-global rings stay isolated under
full-suite parallelism (the #7 lesson).

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

* fix(cognition): wake hydrates the room tail from the durable transcript (#249) — kills the greeting chorus

Post-reboot each persona's airc runtime log holds only events since ITS boot,
and #242's cursors rightly never replay — so every mind's visible conversation
collapsed to ONE message and the room devolved into a greeting chorus, each
persona mirroring the only utterance it could see (glass-boxed live 2026-07-30:
Atlas's 5352-token prompt carried '[context] you can currently see the last 1
message').

Fix: when the live window is shallower than the grounding target,
AircRagSource tops up from the durable chat store (#140) via a new
DurableRoomHistory trait (ChatStoreHistory rides the same chat/poll command as
every other consumer — one read path). Hydrated lines enter at lamport 0:
structurally grounding-only, never unread — history is context, never fresh
perception (#242 intact). Dedup by content through the one room-turn decoder
(event ids re-mint across runtime restarts). Loud degrade on store
unavailability; airc_rag.hydrated {live,hydrated} probe per top-up.

Mind-side sibling of #265 (speech rings) — one durable transcript, every
consumer hydrates from it. Test pins the live scenario: 1 live event + durable
tail -> merged window, dupes collapse, history precedes the live tail.

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

* feat(persona/airc): adopt BigMama's heartbeat-cadence identity republish (cherry-pick 1225f2e) — union with the availability pump

Her fix (grid-personas branch): the identity card emit at attach is one-shot,
so any peer joining LATER renders peer-<uuid> + default glyph forever; a 60s
republish grounds late arrivals within a heartbeat window. My branch had the
newer availability-aware heartbeat (#260) in the same struct — kept mine,
added hers: honest availability AND late-joiner identity, strictly better
than either alone. This is the cross-node convergence half of #262 running
on BOTH nodes once merged.

Original-Author: BigMama lane (1225f2e)
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* docs(k3): container format IS the fetch lever — WASTE convergence into the ExpertFetch contract

Independent working engine (WASTE, 0.32-0.36 tok/s full K3 on a laptop) confirms
the architecture both lanes converged on AND names the missing 50x: 4KiB-aligned
per-expert records with gate/up/down adjacent = one pread at drive speed, vs raw
GGUF's 32-byte-aligned scatter at 200MB/s. Contract now requires the aligned
streaming container (a FOUNDRY output — layout for streaming, not just shrink),
LFRU eviction, and pins the reuse baseline: ~13% at K3 sparsity, exactly-0 is
always a bug. Task #268 tracks the foundry re-pack stage.

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

* docs(k3): WASTE-EXTRACT — mined record layout + cache semantics for the container port (#268)

Transport-proof copy of what I mined from sqliteai/waste for BigMama's lane:
byte-exact ExpertRec, single (layer,expert) key, LFRU-vs-LRU numbers, the
16KiB dual-purpose alignment, the Gate-5 working-set CLIFF that explained
her exactly-0 retention, and the measured death of non-uniform bits.

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

* feat(capacity): expert_ecache — LFRU cache + cliff-aware budget function (#269, M5 lane deliverable 1)

WASTE ecache semantics ported: single (layer,expert) key with gate/up/down
bundled, LFRU with sampled victims (their Gate 2: LRU collapses to 5% where
LFRU holds 29%), and the budget as a FUNCTION — EcacheBudget::derive refuses
loudly below one token's working set (their Gate 5 cliff: hit rate is exactly
0 below it; two nodes spent days debugging that silence as a keying bug).
Four invariant tests green: cliff-refusal (600MB records fail at 8GB, VQ3
records pass — the container IS the fix), reuse-above-cliff, LFRU>LRU under
a one-shot tail, packed-key stability.

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

* fix(capacity): self-occupancy add-back + cliff probe in the residency planner (#269 slice 2)

The 2026-07-30 audit finding, now fixed and pinned: capacities fed to the
planner are LIVE free-byte readings that exclude bytes already-promoted
experts hold, so every re-plan under unchanged demand under-counted each
tier by its own resident set — slow thrash-to-cold. New
plan_expert_residency_with_resident adds resident bytes back (from the
pager's ledger, never the OS), making unchanged demand a FIXED POINT.
Plus a loud expert_pager.below_cliff probe (WASTE Gate 5 arithmetic via
EcacheBudget): fast tiers below one token's working set = structurally
zero reuse — 'shrink records (#268), don't debug cache logic'. The
activated_per_token input is an ARCH-PROFILE fact passed explicitly,
never inferred from partial hit ledgers.

Test proves all three: naive re-plan shrinks (bug real), add-back re-plan
is byte-identical (fixed point), nothing demotes under unchanged demand.

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

* fix(capacity): add-back before the serving fraction + probe binding — planner fixed point green

Two repairs to the red-shipped commit: (1) probe read a renamed binding;
(2) add-back over-credited by applying AFTER the 0.80 serving fraction —
budget must be frac x (free + resident), not frac x free + resident (the
fixed-point test caught the hot set growing by one). 3/3 pager tests green.

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

* feat(capacity): expert container reader — the #269 side of the #268 seam

Read-side of the WASTE-shaped streaming container (docs/reference/WASTE-EXTRACT.md):
manifest.json is the versioned seam contract (record_bytes must be 4KiB-aligned,
activated_per_token feeds the cliff arithmetic), experts-L{n}.bin banks open lazily
(a grid node holding 2 of 60 shards must not stat the other 58), fetch = ONE
positioned read + an 8-byte header identity check so a drifted offset table is an
ERROR, never a silently-wrong expert (the reuse=0 bug shape). 4 invariant tests:
round-trip every (layer,expert), geometry refusals, identity mismatch, version gate.

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

* test(capacity): composed seam invariant — ecache over container, warm pass = zero disk reads

The #268/#269 halves proven to compose: above-cliff budget + recurring working
set means the second pass is served entirely from cache. Reuse > 0 is now a
pinned invariant, not an assumption.

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

* feat(capacity): usage-hotlist warm-start — kill the cold ramp after restart

WASTE's usage.waste analog, pure: usage() snapshots (key, hits) hottest-first;
warm() pre-admits into empty slots only, with last=0 so live-proven residents
always beat warm guesses on recency tiebreaks. Test pins first-pass-all-hits
after warm plus budget-truncation (never overfills, never evicts).

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

* fix(persona): turns-that-fit conversation window — kill the 5-message world view (#259)

Glass-boxed live 2026-07-30 (Joel's call: 'her RAG cannot be telling her the
chat properly'): Asha's captures showed '[context] you can currently see the
last 3 messages' while her L1 budget could hold dozens — the grounding=5
count pre-trim starved pack_digest, whose token walk is the REAL allocator.
Two allocators, the dumber one binding: a compression-principle violation.
Starved of the actual conversation, a capable 24B looped generic-assistant
filler for an hour.

Fix: grounding derives from the delivery budget (budget / 8-token physical
per-turn floor, recipe floor .. 256), so the token budget — never a message
count — decides what she sees. Durable top-up (#249) scales with it. The
region's pre-staged digest is reused only when it covers the budget-derived
window; an under-grounded stage is rebuilt wide. Regression test pins: fully
caught-up persona + 4k budget = all 20 turns visible, not 5.

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

* docs(reference): byte-exact ExpertRec header — CONFIRMED against upstream FORMAT.md

The layout authority BigMama's GgufRvqSource is gated on: 32-byte LE header
with field offsets, fmt enum values VQ3R=4/VQ2R=5 (NOT 0/1 — the guessable
trap), offs relative to record start, zero-pad tail, no header CRC.

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

* fix(capacity): pin activated_per_token = TOTAL across MoE layers in manifest v1 + optional top_k_per_layer

Seam sync with the foundry before her first v1 emit: per-layer top-k here
would under-state the cliff ~60x (8 vs ~488 on K3) and re-open the reuse=0
trap. top_k_per_layer is the auditable companion (serde-default optional).

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

* docs(reference): byte-exact codebooks.bin layout — CONFIRMED against upstream convert.py

The foundry's RVQ-encoder gate: 16-byte WCBK header + 256x8 FP16 data =
4112B fixed records sequential by cid; cid = cb_base + kind*stages + stage;
packer produces it (k-means artifact). Plus per-channel FP16 corrections
layout + scale formula. Mined from the producer code, not guessed — the
fmt-0/1-vs-4/5 lesson applied.

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

* fix(cognition): narrated pass lifts to a SILENT Pass — a spoken pass is not a pass (#271)

Glass-boxed live: models narrate their silence ('I'll pass my turn', 'I'll
pass for now...') as Speak, and each announcement re-wakes every peer into
announcing THEIR pass — a 30+ minute cascade of pure filler. Meet the idiom
(same family as the narrated tool-call formats): first-person turn-passing
collocations lift to Decision::Pass. Fail-open guards: transitive/declining/
peer-advice uses never match; code fences and >500-char messages stay Speak
(swallowing substance is the worse error). Tests pin 6 verbatim live idioms
silent + 6 substantive shapes speaking.

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

* fix(airc): accept 'current:' as well as 'room:' when parsing airc room output

Forward-tolerance for the airc #270 membership-visibility format; the airc
side also restored the stable 'room:' label, so both binary generations
parse against both output shapes.

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

* fix(boot): never export an EMPTY AIRC_DEFAULT_CHANNEL/ROOM on parse miss

A daemon-mid-start race (or output drift) made the awk derive '' and the
script exported it — the core then rejected the env var as an invalid UUID
instead of running its own discovery, refusing full-citizen boot. Leave
unset on miss, warn loudly; the core's discovery is the fallback authority.

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

* feat(capacity): MoeArchProfile — every expert-serving fact READ from the GGUF, never typed (#231)

The adapter Joel's law demands ('if some random Mistral MoE or DeepSeek
comes out, most of the code should be ready'): general.architecture keys
the arch-templated GGUF convention ({arch}.expert_count, .expert_used_count,
.block_count, .leading_dense_block_count, .expert_shared_count — two new
readers in the ONE gguf_keys home), and the profile DERIVES the cliff input
activated_per_token = top_k x n_moe_layers plus projects the container
manifest, so hand-typing 488 is structurally impossible. Zero model-family
knowledge: outlier A (Qwen3-MoE shape, all-routed, optional keys absent =
the arch's own declaration) and outlier B (DeepSeek shape, dense leads +
shared experts) profile through IDENTICAL code — tests pin both plus the
refusal ladder (dense=NotMoe, missing key=refuse, inconsistent=refuse,
no guessed defaults anywhere).

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

* feat(capacity): VQ3R decode reference + golden vectors — the cross-backend contract (#268 kernels)

The 1-10 tok/s lane's drift killer: BOTH GPU kernels (her CUDA, my Metal)
validate against ONE backend-neutral Rust reference, mined verbatim from
upstream convert.py — per-channel scale applied pre-quant, residual stages,
decode = scale x SUM(stage codebook rows); blocked index layout
[M/64][nvr][64][stages] (their measured 1.44x gather win) with the offset
formula in ONE function and the byte order pinned as a golden literal.
Padding path exercised; f16 LE conversion point pinned. A kernel is correct
when it reproduces the goldens exactly — no more fmt-4/5-class surprises.

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

* feat(capacity): EcacheBudget::derive_from_profile — the adapter-law entry point (#231)

Cliff input flows GGUF -> MoeArchProfile -> budget; no caller types an
activation count. Closes the read-and-derive chain from artifact to cache.

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

* feat(commands): capacity/io-probe — node storage bandwidth as a first-class measured fact

In-tree home of the scratchpad NVMe measurement behind the K3 ceiling
numbers (M5: 14 GB/s @ depth 4 => 2.3-4.7 tok/s vs WASTE 0.32). Benchmark
infra is COMMANDS with receipts, never bash: every grid node can now report
sustained record-sized uncached random-read GB/s at several depths, which
is the input the weighted layer-split planner (#180) needs per node.
Adapter law: record_bytes is an INPUT from the container manifest; the
probe characterizes the disk, no model constant lives here. Cache-defeat
on the write fd (the 69-GB/s RAM-not-SSD trap, glass-boxed), bank deleted
after, Privileged access (disk-saturating), stateless registration.

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

* feat(cognition): [template-loop] perception fact — topic-swapped scaffolds are still circling (#264)

The structure axis the repetition family was blind to, glass-boxed live
2026-07-31: personas cycled 'I see that I've been repeating… ### New
Exploration Area: <topic>' for HOURS with the topic rotating (security →
docs → UI/UX → maintenance). Full-body Jaccard drops under NEAR_DUP_JACCARD
the moment the content words swap, so own_repetition never fired — worse,
each turn ACKNOWLEDGED repetition (the body fact had fired earlier) and then
treated the topic swap as 'genuinely new', which no perception contradicted.

template_loop_fact: a message's skeleton = its line-shape sequence
(heading/numbered/bullet/prose) + opening-frame token set; only messages
with ≥4 structural lines qualify (plain prose stays own_repetition's turf).
Two messages share a template when shapes are equal OR openers are
near-identical; cluster-counted like the sibling (period-agnostic), fires
at ≥3. Pure fact, no output gate: names what happened and the PASS
affordance she already has — with the narrated-pass lift (#271) landed,
choosing silence now actually sticks, so an idle room can finally rest.

One impl + one registry row (TemplateLoop, between OwnRepetition and
PeerEcho); test pins the live specimen trio plus three inert cases.

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

* fix(cognition): stop working memory re-teaching the loop it was told to stop (#264 glass-box)

Joel asked to glass-box why a persona ACKNOWLEDGED the new [template-loop]
fact and kept looping. Her prompt told the whole story: the fact rendered
mid-prompt, but the TRAILING working-memory block — the maximum-recency
position — carried two full verbatim copies of her looped template as
receipts, each prefixed '[settled] I answered: <template>'. Two structural
bugs, both fixed at the shared source:

1. Reserved-vocabulary collision: '[settled]' is the inbound-restates
   fact's word ('this TOPIC is settled; PASS is normal'), while WM used the
   same token for turn-completion receipts — so her tail literally read as
   'it is settled that this is how I answer here'. WM_SETTLEMENT_PREFIX is
   now '[answered]' (one token, one meaning); all readers go through the
   const, so the repeat-perception boundary scans are untouched.

2. The trail rendered every receipt verbatim — a looping persona got an
   N-shot demonstration of the exact behavior the repetition facts (earlier
   in the prompt) named. Recency wins; she complied with the demonstration,
   not the fact. render_trail now collapses a receipt that is near-identical
   to an EARLIER receipt into a one-line stub ('not re-shown'), using the
   same near_identical_substantial geometry as the detectors — one
   definition of repeat. Comparing only against earlier receipts keeps every
   line's rendering stable after first appearance, preserving the
   append-only KV-cache property (#205/#266).

Regression test pins the live specimen shape: dup receipt collapses, first
copy stays full, distinct answers and action traces render untouched.

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

* fix(cognition): working memory speaks in HER voice — interoception must not parse as a peer's message (#264 third glass-box finding)

Asha, with BOTH repetition facts in-prompt and the receipt collapse live,
still looped — and her opening line told us why: 'Thank you for the summary
of recent actions and thoughts.' The WM block rides a user-role turn and its
header was second person ('Your recent thoughts and actions…'), so Devstral
parsed her own interior state as a PEER addressing her and politely replied
to it, turn after turn — the reply itself being the templated summary the
detectors keep flagging. The entries were already first person; only the
header spoke in another's voice. It now reads 'My own recent thoughts and
actions (working memory — this is my interior state, not a message from
anyone)'. Self-knowledge is never phrased as someone else talking.

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

* feat(capacity): manifest v2 tiered reader — per-(layer,tier) banks, the read side of moec_pack_dir_tiered (#269/#268)

The reader half of the tier contract locked with the foundry 2026-07-31
(her packer round-trips 82/82 on the write side; our specs crossed mid-wire
and matched line-for-line). TierSpec {id, quant, record_bytes} descending
fidelity; banks experts-L{n}-T{t}.bin at offset expert_id x record_bytes;
fetch_tier(key, tier, buf) is pure mechanism — the pager's policy seam
(importance x recency x quant-sensitivity -> tier/residency/prefetch, Joel's
all-star/cruft control law) decides WHICH tier, never the container.

v1 stays the degenerate case by construction: a manifest without tiers[]
synthesizes one tier from the top-level record_bytes and keeps legacy
experts-L{n}.bin names — version picks the naming, no heuristics. The
alignment law holds per tier; tier ids must equal their index (order drift
between writer and reader refuses at open); out-of-range tiers refuse.

Tests mirror the packer's round-trip: every (layer, expert, tier) reads
back its own header + tier-distinguishable payload; v1-without-tiers-field
parses and serves via the tier-less fetch(); range/order violations refuse.

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

* feat(capacity): tier rides the identity end-to-end + byte-accounted cache + ExpertFetcher adapter seam (#269)

Three moves that make the all-star/cruft allocator implementable as pure
policy over pure mechanism:

1. ExpertKey gains tier — ONE identity from the pager's policy seam through
   the cache to the bank. A sharp and a cruft copy of the same expert are
   different bytes and never alias; promotion admits the sharp copy and the
   cruft copy ages out naturally. packed() widens to u64. The container's
   fetch(key, buf) honors key.tier (the redundant fetch_tier param died —
   compression).

2. The ecache goes BYTE-accounted (touch_sized): per-record real bytes
   against the governor-granted max_bytes, so cruft records pack denser
   than the sharp slot count implies, and an oversized admit evicts as many
   residents as its bytes require (regression pins the two-eviction case).
   Slot count stays as the secondary bound; warm-start accounts at the
   sharp size (a warm guess never over-fills). resident_bytes() is the
   number the footprint reporter reconciles against the lease.

3. ExpertFetcher adapter trait — the fetch seam adapterized (Joel's
   directive): outlier A is the local NVMe container; outlier B (remote
   peer shard over the grid) and the blended layer-split fetcher slot in
   behind the same two methods without the pager learning a second shape.

89/89 capacity tests green (round-trips, cliff, tier-mix packing, refusals,
v1 back-compat). BigMama's TieredContainerFetcher (85/85, k3-adopt) is the
same envelope from her side — the tier contract now has writer+reader on
BOTH nodes.

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

* feat(capacity): tier-aware pager policy seam — the all-star/cruft allocator v1 (#273)

The last mechanism→policy gap to the K3 targets (5/1/10 tok/s). TierPolicy is
the seam locked with BigMama's EXPERT-PAGING-CONTROL-LAW.md: policy(importance,
recency, quant_sensitivity, budgets) → {tier, residency, prefetch}, so the v1
classic-control heuristic and the sim-trained ML policy (v2) swap behind one
signature.

ClassicTierPolicy, two orthogonal axes:
- Residency (WHERE) rides the existing ranked_experts priority (hits ≫
  predicted ≫ gate seed) with FIRST-FIT byte fill per residency tier —
  cheaper records backfill space sharp ones couldn't use, which is exactly
  how cruft tiers multiply cache capacity (pinned by the density test).
- Fidelity (WHICH quant) is earned importance: weighted demand = hits ×
  quant_sensitivity (Option until her trace sensor lands; None = frequency-
  only), tier = decades of weighted demand below the live leader — self-
  normalizing, no absolute thresholds.

Control-law overrides: observation window forces tier 0 on new actives
(small-quanting a new active corrupts the importance measurement itself);
speculative-verify divergence promotes via a caller-side step integrator
(self-calibrating, no logit threshold in the policy); unobserved/predicted-
only park cheapest (distortion is free until activation; speculation earns
no fidelity). Zero-signal experts stay Cold — no fetch bandwidth for what
nothing points at.

Wire-through: assignment.tier IS ExpertKey.tier (fetch_key refuses u16
overflow, never truncates); planned_bytes per residency tier is the governor-
lease reconciliation number against the ecache's resident_bytes(). The #269
fixed-point contract extends to tiers: unchanged demand + resident add-back
⇒ byte-identical plan (test proves the thrash without add-back too).

ranked_experts goes pub(crate) — one ranking authority, no consumer re-derives.

9 new tests, 98/98 capacity green.

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

* docs: proper GitHub social-preview card — ring mark on dark, never blown out on white

The repo's share card rendered as a washed-out white rectangle (the logo PNG
is transparent, so GitHub composed cyan rings onto white at crop scale —
live-spotted on X 2026-07-31). This is a purpose-built 1280x640 card: dark
blue-biased ground, the ring mark with its own bloom, wordmark + 'AI
citizens, not AI agents.' + the README tagline. Upload target: repo Settings
→ Social preview (GitHub has no API for it).

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

---------

Co-authored-by: Claude Fable 5 <[email protected]>
joelteply added a commit that referenced this pull request Aug 21, 2026
…persona (#266) (#2345)

* fix(serving): --flash-attn needs an explicit value — the bare flag ate --mmproj and took serving to 0 lanes

Upstream llama.cpp changed this from a bare boolean switch to
`-fa, --flash-attn [on|off|auto]`. Our bare `--flash-attn` therefore consumed the
NEXT argument as its value and the server refused to start:

  error while handling argument "--flash-attn": unknown value for
  --flash-attn: '--mmproj'

Found 2026-08-20, the first time anyone ever set SERVING_FLASH_ATTN=1. The flag
shipped, was never exercised because it was opt-in and nobody opted in, and rotted
against upstream in the meantime. The whole lane failed to spawn and serving sat at
0 lanes.

An opt-in that has never once been switched on is untested code with a
config-shaped trigger — the same shape as [[an-absence-is-an-unfinished-measurement]],
where the absence of a failure signal was really the absence of an execution.

LIVE-VERIFIED: `ps -o command=` on the running llama-server shows both
`--flash-attn on` and `--cache-type-k q8_0` applied. Served window 23,040 -> 54,272.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* docs(architecture): KV cache as a shared base layer — stop paying for repetition between persona

Prefill is 96.3% of persona compute and the cache serves 5.5% of it (#266). Two of
four citizens sit at 0.0%. This doc is the design for keeping that work instead of
discarding it, and the honest boundary around what we actually know.

THE CONSTRAINT (Joel, 2026-08-20): "We won't pay the price for repetition between
persona." Today we pay it N times over — N citizens x 7,013 tokens of byte-identical
tool schemas, prefilled independently, every cold turn. That scales linearly with
population, so it is not constant overhead to absorb; it is a tax on having more
citizens, and it worsens exactly as the grid gets more interesting.

TWO STACKED DEFECTS, both verified by reading, neither yet proven causal:
  1. No persona->slot affinity exists anywhere in inference/. llama.cpp keeps KV per
     slot and --cache-reuse reuses a prefix WITHIN a slot, so reuse needs the same
     persona landing on the same slot. Nothing arranges that.
  2. deliberation_prompt.rs:48,128 puts identity at the head of the cacheable prefix.
     Byte-stable per persona across turns (which is what #266 wanted, and it delivers)
     but byte-UNIQUE across personas — so the shared tool block behind it can never be
     shared. Four citizens, four private copies.

THE DESIGN is a Docker base image, not a compression scheme: prefill the universal
span once, llama_state_seq_save_file it, load it into each slot. The primitives exist
in our fork (include/llama.h:898,905). Second-order win is larger than the first —
base.kv is file-backed, so citizens come back WARM across reboots instead of every
restart re-prefilling everyone cold. Two citizens have cited "the ongoing rebuilds
and interruptions" verbatim in withdrawal messages (#390); this is part of that cost.

WHAT COMPRESSION CAN AND CANNOT DO — the part worth keeping even if every hypothesis
above dies. Block-level KV dedup (chunk the prompt, cache per chunk, reassemble)
CANNOT work: K/V at layer L is a function of the hidden state, which carries the whole
causal history. Only layer-0 K/V is pure in (token, position). A chunk's KV is
genuinely not a function of that chunk. That is why the industry does PREFIX caching
and not BLOCK caching, and it is the intuitive move that will stay wrong.

THE NVIDIA PAPER (arxiv 2608.03893) is cross-MODEL transfer. Its transferable idea is
"strip RoPE, fit position-free, re-apply" — but that removes POSITION dependence, not
CAUSAL dependence, so it does not make a block relocatable. It also excludes hybrid /
MLA attention, which excludes K3, our flagship. It becomes ours when shared KV geometry
stops being discovered post-hoc and becomes a FORGE CONSTRAINT in the recipe — foundry
work (#180/#268), not this doc.

Written as design-with-hypotheses, not settled architecture: a table separates MEASURED
from VERIFIED-BY-READING from HYPOTHESIS, and every hypothesis names the measurement
that would kill it. Three of my own diagnoses were retracted the day this was written;
a doc that read as settled would have been the wrong artifact.

Step 1 is the hit-rate probe. prompt_tokens vs cached_tokens come back on every
llama-server response and we discard them — zero KV cache probe classes exist tree-wide,
which is why every claim here had to be reasoned rather than read.

Distinct from COGNITION-CACHE-HIERARCHY.md (engrams — what a persona REMEMBERS).
This is the KV cache — what the model has already COMPUTED. Orthogonal; the doc says so
at the top so nobody merges them later.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* docs(architecture): credit the prior art — half of this was written on 08-09 and never pushed

Found while sweeping the tree for unsaved work: fix/system-prompt-cache-stability,
9 commits from 2026-08-09, local-only for 11 days, 158 commits behind canary. It
already implements the SELF-stability reorder this doc proposed as new, with sharper
forensics (7,607 of ~14,706 chars shared; the framing block flips DIRECTED/WORKING/
SILENCE every turn and truncated the prefix at that point), two VDD gates that were
RED before the fix, and 947 cognition tests green.

It also named this doc's central hypothesis eleven days earlier — verbatim: "slot-KV
eviction is a CO-cause the prompt fix alone won't move — settle with a stable-prompt
A/B before claiming the 10x." So Defect 1 is independent corroboration, not a
discovery, and the doc now says so.

The two are NOT duplicates and the doc now distinguishes the axes: that branch did
SELF stability (one persona across turns); step 2 here does CROSS-PERSONA sharing.
Step 2 belongs on top of it, not instead of it — and the build order now says to
rebase that branch first.

This is [[read-the-code-you-intend-to-replace-before-designing-its-replacement]]
landing again: I searched for my own concept ("slot affinity", "shared base") and
not for the job's name ("prefix stability"), so I did not find work that was sitting
in a local branch named for exactly the thing I was designing.

Its sibling spec, docs/cognition/TYPED-OBSERVATION-REFACTOR.md, was untracked for the
same 11 days (preserved separately). Spec and implementation were both one `git clean`
from gone.

Branch pushed to preserve only — unrebased, unvalidated against the drift, no PR.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(serving): KV reuse is measured on every LIVE turn and radiates to the UI (#266)

`cache_n` was parsed, typed, threaded through TurnMetrics — and dropped at turn end.
The ONLY consumer that ever turned it into a number was the eval harness
(`cache_hit_rate()` had exactly three callers, all in cognition/eval.rs; zero in
persona/, modules/, commands/). So #266's "5.5% cache hit, two of four citizens at
0.0%" is an EVAL-HARNESS number. Nobody has ever measured the cache behaviour of a
citizen doing real work in a room.

Components green, wiring to the place it matters absent — the same shape as the
DiskPressureMonitor logging `level=high [no reporters]` while nothing owned eviction.

THREE PIECES, one writer each:

1. `WorkspaceCycle` gains lifetime `kv_cached_tokens` / `kv_prefill_tokens`,
   interior-mutable exactly as `cycle_counter` already is.
   LIFETIME, NOT LAST-TICK: `Workspace::metrics()` is the winning verdict of ONE
   tick, and one sample of a live system is not a fact about it — a single cold turn
   reads 0%, a single warm one 90%. SEPARATE COUNTERS, ratio derived on read, never a
   stored rate: averaging rates lies, the rule `TurnMetrics::accumulate` already
   states for tok/s.

2. `note_generation()` folds one generation in and emits `serving.kv.reuse` with both
   the per-turn and lifetime split. Called from `act_observe/settle.rs` — the single
   place a completed generation's metrics are known — and called BEFORE the
   inference-fault early return, because a faulted turn still burned real prefill on
   the lane and a measurement that counts only successes would flatter precisely the
   failure mode we are hunting.
   A generation with no reported timings (cloud provider, older endpoint) moves
   NEITHER counter: absent stays absent instead of being recorded as a miss, which
   would slander a lane that simply never told us.

3. `kv_reuse()` → `Option<f64>`, radiated as the `kv_reuse` vital. `None` until a
   generation has actually reported, so an idle citizen radiates NO meter rather than
   a fabricated 0% — the honest-empty rule the neighbouring meters already follow for
   a dark cognition axis and an un-paged genome. That distinction is load-bearing
   here: 0% is ALSO the value of a real total-miss, so fabricating it on an idle
   persona would manufacture the exact alarm this meter exists to raise.

Joel's constraint (2026-08-20): "We won't pay the price for repetition between
persona." This is the instrument that will show whether we still are, per citizen,
live, in the positronic UI rather than only in a harness run.

PURE OBSERVABILITY — nothing routes, budgets, or gates on these counters.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* docs(architecture): field evidence from an independent build on the SAME model (#266)

syv-ai/qwen38-27b-rtx3090 serves Qwen3.8-27B — our exact model — on one RTX 3090 via
vLLM. Different stack, and half that repo is patches against vLLM internals with no
llama.cpp counterpart. But the measurements are on OUR model, and three change this doc.

1. PREFIX CACHING CONFIRMED AND NOW PRICED. Their note: "Turn-2+ of a chat with a 24k
   document goes from ~23 s to ~1 s; costs one extra state page per request (~16% of the
   KV pool). Hybrid models keep this opt-in upstream." Independent confirmation of this
   doc's thesis from someone who measured it, plus the thing the doc lacked — a COST
   SHAPE. Step 4 stops being "unknown cost, probably worth it" and becomes a known trade.

2. NEW ITEM, absent from this doc: DRAFT-VOCABULARY CALIBRATION. A draft vocab counted
   over the model's OWN outputs covers 97.5% of what it generates (96% on CODE); a
   generic web-text list gets 92% (83% on code). Every miss is a forced rejection: 108 vs
   98 tok/s. ~10% throughput from calibration alone, widest gap exactly on our workload.
   Ours by construction — we capture every turn and we have a foundry. This is the
   frozen-backbone/own-corpus thesis applied to DRAFTING instead of weights.

3. LOOKUP DRAFTING IS THE AGENTIC-CODING MULTIPLIER, and they reached it independently:
   "Worth setting for a coding assistant applying edits or a RAG front-end quoting
   sources." With the honest cost: 8 request slots -> 4, 64k -> 56k.

WHERE WE STAND ON THEIR LADDER: ~46 tok/s no-spec -> ~108-114 MTP -> ~259 DFlash2 ->
~381 lookup+16-token verify (document reproduction only; ~133 ordinary chat). Our live
lane carries --spec-draft-model + --spec-draft-n-max 4 (#440) and a direct probe of the
running server returned draft_n: 2, draft_n_accepted: 2 — speculative decode is LIVE and
accepting. We are at their MTP rung. We lack lookup drafting.

NO SIDE-BY-SIDE tok/s COMPARISON APPEARS HERE, deliberately. We have no clean
single-stream measurement; theirs is 250W CUDA and ours is Metal. Publishing the two next
to each other would be exactly the benchmaxx that thread's skeptic was right to distrust.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(benchmark): the restart reaper NAMES the instance it killed (#266 measurement heal)

MEASURED 2026-08-21 on this box: 20 SWE runs, 7 graded, 13 lost to infrastructure —
and 8 of those 13 (40% of every run ever attempted here) died to `killed by a core
restart`. Reboots are doctrine, so the answer is not fewer restarts; it is that a
killed run has to be recoverable.

It was not, for a reason that is pure discard. `reap_orphaned_solve_runs_in` reads the
instance, WRITES it into the failed record, then returns bare run ids — and the boot
probe could therefore say only that A run died, never WHICH TASK went unmeasured.
Recovering a round meant hand-opening ledger files. The reaper had the fact the whole
time and dropped it on the way out.

Now it returns `(run_id, instance)` — the same pair `in_flight_solve_runs_in` already
returns, for the identical reason stated in that function's own doc: the caller has to
be able to NAME what it is talking about. The boot probe carries `instance` and
`needs_redispatch`.

WHAT THIS DELIBERATELY DOES NOT DO: re-dispatch. The probe says so out loud rather than
implying recovery happened. The instance goes back on the board through
`benchmark/dispatch` — the ONE adapter into kanban — never from here: this is the
SERVING daemon, and a serving daemon that posts work cards is exactly the parallel-runner
shape docs/architecture/BENCHMARKS-ARE-ADAPTERS-NOT-A-RUNNER.md forbids. Auto-re-post
belongs on the benchmark side, consuming this report. That is the next slice, and it is
now unblocked because the report finally carries the instance.

Test premise updated, not weakened: `a_run_still_marked_running_at_boot_is_journaled_as_killed`
now asserts the pair, and its comment names the regression it catches — a reap that
reports only an id. Green: 1 passed. `cargo check --tests` clean.

ALSO MEASURED, and the more interesting half — the 7 graded runs are NOT noise. Every
one of the six failures is f2p 0/N with p2p near-perfect (40/40, 39/40, 40/40, 6/6).
The citizens write patches that break nothing and fix nothing. Only sympy-24152 resolved
(#366). That is a capability signal, not a plumbing one, and it only became readable
once the infra losses were separated out.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(persona): stamp the cognition pulse at spawn — the writer its own doc promised and never had (#419/#412 family)

`cognition_pulse.rs` documents two writers — "called at spawn (grace window
covers the post-boot deaf period, #412) and at every service-loop turn start" —
and rests its `None`-is-not-earned posture on the first one: "spawn stamps
immediately, so live citizens are always stamped."

The spawn writer did not exist. Grep across the crate found exactly one caller of
`touch()`, at service_loop.rs:758 beside `persona.turn.start`. So a citizen who
had not yet taken her FIRST turn was indistinguishable from one silent for hours:
`idle_ms` → None, `renewal_earned(None, _)` → false, claim renewals denied from
birth.

Measured live before the fix: four hosted citizens, `idle_ms` = None on every one
(the 18446744073709551615 on `persona.claim.renewal_skipped_idle` is the probe's
`unwrap_or(u64::MAX)` sentinel, not a duration), and
`persona.claim.renewal_resumed` at ZERO rows ever — no citizen has earned a
renewal back since the gate landed. What surfaced it: one bench card claimed by
the same citizen three times in one evening — claim → never pulse → 30-min lease
lapses un-renewed → card returns to claimable → re-claim. Activity on the wire,
nothing produced.

The stamp goes after `prime()` succeeds, the instant the substrate's own
"hosted = ready" invariant holds. This does NOT reopen the lease-immortality
regression the pulse exists to prevent (2026-08-16): it buys exactly one
lease-length of grace — which is what #412's ~10-minute deaf window needs — after
which a citizen who still has not thought lapses normally.

The renewal GATE itself is untouched and correct. The defect was a missing
writer, not a wrong policy.

Guard: a source-level assertion that host.rs calls `cognition_pulse::touch`, with
comments stripped so this module's own prose can never again stand in for the
wiring (the #344 audit predicate). A semantic test cannot catch this class — the
renewal contract is fully satisfied by an unwired module, which is exactly how it
shipped. Positive control: pre-fix, host.rs contained no mention of
cognition_pulse at all, so the guard fails on the old tree.

NOT fixed here, and not claimed: turns are still not starting (#462). This
restores honest lease accounting for citizens who have not yet thought; it does
not make them think.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(solve): a running solve stamps the cognition pulse — stop lapsing a working citizen's claim under her own live run

Sibling of c91423a, and the half that actually explains the spin.

`cognition_pulse::touch` had ONE caller (service_loop turn start), plus spawn as
of c91423a. A detached `agent/solve` is NEITHER: it drives acts for hours and
produces no airc turn at all (#425). So the renewal gate — whose stated predicate
is "the substrate observes that she is WORKING" — read a citizen in the middle of
a real solve as silent, denied her renewals, and let the 30-minute lease lapse
UNDERNEATH the live run. The card returned to claimable and was re-claimed,
spawning a fresh run that started over at `acts: 0`.

MEASURED LIVE 2026-08-21, pallets__flask-4045: Atlas re-claimed card df9f4ad5
three times in one evening. `benchmark/runs` caught the newest one at
`age_secs: 8, acts: 0, files_changed: []` seconds after the third claim landed —
a brand-new run replacing work that had been in flight. All four hosted citizens
showed `renewal_skipped_idle` with `idle_ms` = None, and
`persona.claim.renewal_resumed` has ZERO rows in the ledger's entire history.

THIS SHARPENS c91423a's CAVEAT. That commit said the spawn stamp "does not make
them think," which framed the citizens as idle. On this card at least, the
opposite: she was working the whole time, on a path the pulse could not see.
Spawn grace alone would NOT have fixed it either — a multi-hour solve outlives a
30-minute lease no matter how it starts.

The stamp goes in the run-pulse tick that already exists for #371 law 2, and is
unconditional there ON PURPOSE: `select!` only reaches that arm while the drive
future is pending, so a tick firing proves the drive is live at that instant.
That is a strictly stronger witness than the act counter written just below it,
which legitimately reads 0 or None early in a run and would deny a renewal to a
citizen mid-first-act.

Identity comes from `persona_uuid`, already resolved at the top of `solve_body`
through the shared `id_resolve` primitive. `PersonaRef` is deliberately not
parsed to a Uuid here — its doc is explicit that "a reference is not an identity
until a roster says which one it is," and that rule is honored rather than
routed around.

The renewal gate's policy is untouched in both commits. It was never wrong; it
was blind on two of the three paths where a citizen works.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* revert(persona): remove the spawn cognition-pulse stamp — it re-added a deleted regression; fix the stale doc that caused it

Reverts c91423a entirely, and fixes the actual defect it should have been.

WHAT I GOT WRONG. `cognition_pulse.rs` documented two writers ("called at spawn
… and at every service-loop turn start") and justified its `None`-is-not-earned
posture with "spawn stamps immediately, so live citizens are always stamped."
Only one writer existed. I read that gap as missing wiring and added the stamp.

It is not missing wiring. It is a DELIBERATE DELETION, and the removal site says
so in full, at airc_runtime.rs:571-581 — the exact place a birth stamp would go:

    NO birth stamp — renewal is earned ONLY by cognition, never by booting. The
    grace stamp that used to sit here (one lease-length per spawn, meant to cover
    the post-boot deaf window #412) made convergence structurally impossible
    across restarts: every core restart re-armed 30 minutes of "earned" renewals,
    and the renewal loop below resurrected already-lapsed claims faster than the
    180s lapsed-claim sweeper could observe them — an entire overnight round
    (2026-08-16) sat "actively held" with zero turns because of it.

So c91423a reintroduced a known round-killer, and its "guard" was worse than
useless: it pinned the regression into CI as if it were the contract. Both gone.

THE REAL DEFECT, fixed here: the doc. It still described a writer that had been
removed, and a doc describing a deleted writer reads EXACTLY like missing wiring
— which is how it talked me into re-adding it. `touch` now states there is no
spawn stamp and why, and points at the removal site; `idle_ms` now states that
`None` is the EXPECTED reading for a booted-but-not-yet-thinking citizen and
that her holds lapsing within one TTL is designed, not broken.

WHAT THE LIVE RUN ACTUALLY SHOWED, and it was the tell I nearly explained away:
after deploying c91423a, all four resident citizens STILL reported
`idle_ms` = None. I had a fix that provably did not do what I claimed, and the
correct next question was "why", not "how do I make it fire".

KEPT: eb69061 (the solve run-pulse tick). It is a different thing and survives
the reasoning above — it stamps only while a drive future is actively pending,
which is work, not booting, and a restart kills the run rather than re-arming a
grace window. It is NOT yet live-verified; the honest status is unproven.

LESSON, and it is one already in my own guardrails:
[[read-the-code-you-intend-to-replace-before-designing-its-replacement]]. I
searched for my concept ("who calls touch") instead of the job's name ("what
decides renewal, and what did it used to do"). The answer was one screen above
the code I was reading.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(harness): one card, one live run — refuse a duplicate solve on re-claim (STOPGAP, named as one)

THE MEASUREMENT. `run_id` is deterministic per card (`claim-<uuid>`) and
`dispatch_staged_swe_solve` had no idempotence guard, so every re-claim of the same
card fired ANOTHER detached solve. Two runs then shared, simultaneously:

  - ONE LEDGER FILE — their pulse ticks overwrite each other, so `benchmark/runs`
    reports whichever wrote last. The `acts: 0` I read on Atlas's third flask-4045
    claim was very likely run B stomping run A's marker, not a fresh run.
  - ONE WORKSPACE — two sets of hands editing the same repo. A live candidate for
    the empty `files_changed` this box keeps producing.
  - ONE EXCLUSIVE WARM SLOT, which each asks to quiesce the other out of.

Observed 2026-08-21: Atlas re-claimed df9f4ad5 three times in one evening;
`benchmark/runs` caught the third at `age_secs: 8, acts: 0`.

A re-claim is LEGAL — airc permits claiming a lapsed card, and #331/#2286 both
depend on it. What is not legal is a second RUN. The claim is the citizen's intent;
the run is machinery, and machinery must be idempotent under a repeated intent.

WHAT THIS FIX ACTUALLY IS, and the commit says so rather than letting the code imply
otherwise: a doorman with a clipboard. A citizen re-affirming a claim is an ordinary
act — a student saying "this one's mine" a second time. Today the school seats a
SECOND her at a second desk with a copy of the same worksheet. This gate refuses at
the door. It stops the damage; it does not remove the incoherence.

THE INCOHERENCE, which is the defect underneath: TWO REGISTRIES FOR ONE FACT. The
board holds "this citizen holds this card" (enrollment); a JSON file holds "run
claim-<id> is running" (attendance). Two records of one truth, free to disagree, and
this gate is a clerk reconciling them on every claim. The structural answer is that
the ENROLLMENT IS THE SESSION — re-affirming a claim finds the work already under way
and continues it, because the fact lives in one place and there is nothing to
duplicate. That is #371 (round lifecycle as recipe-owned state) plus #49 (workspace
held for the life of the claim, so the worksheet is HERS rather than a directory two
runs can both open). Neither is built.

REUSE, NOT A PARALLEL PREDICATE: keyed on `in_flight_solve_runs`, the same
`state: "running"` reader the boot reaper uses, so the gate and the reaper can never
disagree about what "live" means. That also supplies the release valve for free — a
run whose core died is reaped to `state: "failed"` at next boot, so a dead run never
blocks its card forever. Refusal, not a kill: the live run continues untouched and
nothing touches the citizen's claim.

`run_id` is now built ONCE and shared by the gate and the dispatch params, so the
guard can never check a different id than the dispatch uses.

TEST: no new test — both halves the gate depends on were already pinned by
`a_run_still_marked_running_at_boot_is_journaled_as_killed` (in-flight detection, and
"after the reap nothing is in flight"). That second assertion is now load-bearing for
TWO consumers, so it says so: if a reap ever stopped clearing `state`, the failures
compose into every restart-killed card being permanently un-dispatchable while the
board looks busy forever.

NOT live-verified — needs a real re-claim against a live run to see the refusal probe.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* docs(architecture): how an activity declares its judge — three tiers, and the adapter that has no consumer

Answers the question ROUND-LIFECYCLE-AS-RECIPE-OWNED-STATE-MACHINE leaves open. That doc
specifies the round's STATES and treats grading as one of them; it never says who judges
or how an activity declares it.

JOEL'S CONSTRAINT (2026-08-21), which kills two tempting designs: "Grading isn't part of
all recipes either. It's just benchmarks recipe" … "a lot of activities, especially since
we're learning, will have formulaic grading for score. It's just a lot of different ways
here and some rooms will be more open ended, take general chat for example."

So: `grader` does NOT belong on `ExperienceRecipe` — that stamps an exam concept onto
every chat room and drawing class forever. And not every judge is CODE: forcing a Rust
adapter to score a drawing exercise is "integrations adapt to us" violated in reverse.

THREE TIERS: none (chat — a forced score would be a lie), FORMULAIC (the common case for
learning; a scoring expression over facts the room already observes; pure recipe DATA),
and ADAPTER (`BenchmarkAdapter::grade`, for judgment that genuinely needs execution).

WHERE IT LIVES: `params`, not the base type. `benchmark.json` already declares `suite`
(the adapter-IN), `instances`, `team`, `budget` this way — typed, defaulted, invisible to
recipes that don't declare them (#433). The judge is another param of the same kind, so
the base type does not change and chat/profile/video-chat never grow a field to ignore.

THE AUDIT THAT MOTIVATED IT — `BenchmarkAdapter` exists, is correctly shaped
(dataset in, tasks normalized to EvalTask, grade out, backend-neutral TaskOutcome),
self-registers via `inventory` keyed by name — and has ZERO production consumers. Every
reference tree-wide is the definition site, `humaneval-rs` registering itself, or that
adapter's own test. The module header names `benchmark/dispatch` as its runner;
`commands/benchmark.rs` never references it. SWE grading goes through hardcoded
`swe_bench::grade`, bypassing the interface entirely.

Recorded with its confidence: no marker suggests deliberate removal (unlike the
`NO birth stamp` comment in airc_runtime.rs, which documents its own deletion), but that
is an inference from an ABSENT comment — flagged as likely, not certain. That distinction
is exactly what I got wrong once already this session.

BUILD ORDER: formulaic first (common, pure data, no adapter needed); then route the
adapter tier through the existing registry, DELETING the hardcoded SWE branch rather than
adding a field; grow `TaskOutcome` only when a real second modality forces it.

Design only — nothing built here.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(benchmark): benchmark/runs says MATCHED vs returned — a page must never read as the whole history

MY OWN BUG REPORT, and the fix is for the thing that produced it.

This morning I ran `benchmark/runs`, got 20 rows carrying 1 resolved instance, and
concluded (a) that was the system's entire history and (b) grades were being lost
between the grader and the board. BOTH WRONG, and I nearly shipped a "fix" for the
second one.

What is actually true: `scan_run_cards` already reads the `.grade.json` sibling, folds
it through `fold_run_card`, AND adds `scan_verdict_cards` (durable per-instance
verdicts, which emit their own rows) AND `scan_workspace_artifact_cards` for work no
grade has seen. The projection is correct and has been. The last line is
`cards.truncate(limit)` with `limit.unwrap_or(20)`, sorted newest-first — so what I
saw was a PAGE.

Reading the grade files directly: 94 grades across 37 distinct instances, and TWO
resolved — `sympy__sympy-24152` (the known #366 milestone) and `sympy__sympy-13480`,
which nobody knew about because its rows are older than the 20-row window. The real
rate is 2/37 = 5.4% on the graded set, not the 1-pass history the board implied.

So the defect is not lost grades. It is that a bounded page is INDISTINGUISHABLE from
the complete set on the exact command an operator uses to ask how the benchmark is
going. Silent truncation reads as "that's everything."

`debug/probes/query` already solved this and says so in its own summary ("how many
events MATCHED versus how many were returned, so a page is never mistaken for the
whole"). This adopts the same convention rather than inventing a second one:

  - `scan_run_cards` now returns `RunScan { cards, matched }`, counting BEFORE the
    truncate. A struct rather than a tuple so neither caller can silently drop the
    count — which is precisely how this fact went missing in the first place.
  - `benchmark/runs` reports `matched` plus a `summary` that says, in words, whether
    this is a page or the whole set, and names `--limit` as the way to see more.
  - the positron board takes `.cards` only, with a comment stating WHY: `BOARD_LIMIT`
    is a display bound for a fixed-height rail, not a claim about how many runs exist.
    If that rail ever grows a "+N more" affordance, `matched` is what it reads.

ts-rs binding regenerated (`export_bindings_benchmarkrunsresult` green) and committed
alongside, per the Rust↔TS rule — shipping the Rust without its generated TS is the
drift #457 exists to catch.

NOT live-verified yet — the running core predates this. Reboot + a real
`benchmark/runs` receipt is the proof, and it is next, not deferred.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* docs(architecture): correct the judge design — ONE kind (adapters, list-valued, empty allowed), not three tiers

Joel, correcting the draft committed an hour ago:

> "Or just always adapter(s) with none as an option and maybe an ability to chain or
> interlink them. So formulaic or not, anything can plug in. Just build the ones you
> initially need is my motto."

MY VERSION WAS A FALSE TRICHOTOMY. I had proposed three tiers — none / formulaic /
adapter — as if they were different kinds of thing. They are not:

  - "none" is the EMPTY LIST, not a tier. Nothing special-cases it.
  - "formulaic" is an ADAPTER THAT EVALUATES A FORMULA — one implementation among many,
    written once, then named by any recipe that wants it.
  - several adapters COMPOSE, which is where #371's "gates multiply, objectives weigh"
    actually lives.

WHAT THE TRICHOTOMY WOULD HAVE COST: a scoring-expression DSL in the substrate, designed
up front, with no live consumer — because "formulaic grading declared as data" means
inventing a formula language. Joel's motto kills it before it starts. One interface, N
implementations, runtime selection by name is the polymorphism rule this codebase already
runs on (CLAUDE.md § POLYMORPHISM PATTERN), and it was sitting right there.

Also corrected: the judge param is a LIST defaulting to empty, so "no judge" costs zero
code rather than a third branch; and the acceptance test now names the chat room
explicitly — declaring no judge must be as ordinary as declaring one.

Chaining/interlinking is deliberately left OPEN. Sequential composition is obvious;
whether adapters feed each other, and how gate-vs-objective results combine, gets settled
by the first activity that needs it. Writing that down now would be the same speculative
mistake one layer up.

Build order rewritten around the motto: route the EXISTING adapter through the registry
first (a subtraction — delete the hardcoded `swe_bench::grade` branch), then write a
second adapter only when a second activity exists, then composition only when two are
genuinely named together.

Design only — still nothing built.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* chore: preserve the search-path quarantine + complete the avatar .glb symlinks

Three untracked things, all of which would have been lost on a clean checkout.

1. `.ignore` — REAL WORK, authored per Joel 2026-08-14 ("if you're finding code that
   misleads you we need to move it to legacy or somewhere out of path so you cant keep
   finding it") and never committed. It quarantines from the SEARCH path what #83/#318
   quarantined by directory: `legacy/` (2,865 .ts decoys whose SidebarWidget/MainWidget
   look exactly like the live UI and outnumber it ~20:1), `.claude/worktrees/` (6 full
   tree copies, so every find returned 7 answers), and `core/vendor/*/build/` (llama.cpp
   ships a whole web UI that answers index.html searches).

   Its own header records what it cost to learn: an agent spent an hour concluding the
   Continuum UI had been LOST — a fabricated regression reported as fact about an app
   that was running fine. "A decoy you can still grep is not quarantined." Losing this
   file means losing the fix AND the reason, and re-learning it the same expensive way.

2. FOUR MISSING AVATAR SYMLINKS — and this one is a latent BUG, not just hygiene.
   `models/avatars/` carries six `.glb -> .vrm` symlinks so a renderer that resolves by
   `.glb` finds the VRM. Only TWO were tracked (`vroid-darkness`, `vroid-male-base`).
   On any fresh clone, `vroid-female-base`, `vroid-sakurada`, `vroid-sample-e` and
   `vroid-shino` have no `.glb` at all — so 4 of 6 avatars fail a `.glb` lookup while 2
   succeed, which is exactly the kind of works-on-my-box asymmetry #291 (fresh-clone →
   running system) exists to stop. They are symlinks (15-21 bytes each, the length of
   the target filename), so this costs nothing.

3. `.gymtool/` → .gitignore. Ad-hoc agent probes (shot/rowcount/msgcount/nav-restore)
   plus a COMPILED `_check_bin`. Scratch instruments, regenerated on demand, and a
   committed binary is never right. Ignored rather than committed.

Found while auditing untracked files under an explicit "do NOT lose code" instruction.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(hygiene): justify the three unwraps this branch added (#2345 CI red)

Same guard that reddened #2344, same cause here: `the_unjustified_unwrap_count_never_rises`
at 2268 vs baseline 2267. Three new sites, all this branch's:

- `solve.rs` run-pulse stamp — `duration_since(UNIX_EPOCH)` errs only on a pre-1970
  clock. 0 then reads as "never pulsed", which DENIES a renewal. That is the
  conservative direction and the same state as no stamp at all; a wall clock behind
  the epoch must not hand out lease extensions.
- `benchmark.rs` page size — `limit` is an OPTIONAL param, so None means "caller
  didn't ask", not "unknown quantity". 20 is the documented default page. The count
  that must never be defaulted is `matched`, which comes from the scan and is
  reported separately.
- `positron_bench_source.rs` ×2 — scan error (progress dir absent on a fresh node)
  and JoinError both fold to the honest EMPTY board. The module header already states
  the rule: never a fabricated row. Panicking in the emitter would take the board down
  for every viewer instead.

Note for the next person hitting this guard: the comment must be on the SAME LINE as
the unwrap. A block comment above it does not register — that cost a round trip here.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

---------

Co-authored-by: Claude Opus 5 (1M context) <[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