Skip to content

probe(cognition): the act's residue names its own halves — cycle vs everything after - #3768

Merged
joelteply merged 7 commits into
canaryfrom
probe/residue-names-its-half
Sep 5, 2026
Merged

joelteply merged 7 commits into
canaryfrom
probe/residue-names-its-half

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

persona.act.pace splits an act into model_ms and residue_ms. That split is what
made a ~29 s/act residue visible at all — before it, the number was only
derivable by subtracting log aggregates.

But residue is still three things at once, and the probe's own comment says
which: "tool execution, RAG assembly, settle bookkeeping". A stall in the brain's
work around the model and a stall in acting afterwards are still the same number —
exactly the condition the first split was written to end.

The seam

settle_step awaits cycle.run_situated(...) — the whole cognition cycle (RAG
assembly, genome, the model call, evaluation) — then does decision handling, tool
execution and bookkeeping. That is where residue divides cleanly:

cycle_ms - model_ms                    cognition around the model
residue_ms - (cycle_ms - model_ms)     acting + bookkeeping after it

New probe cognition.cycle.cost carries cycle_ms, model_ms, around_model_ms,
had_metrics. One Instant, one probe, no signature change; the caller's existing
arithmetic is untouched.

What motivated it (measured on BigMama)

Two consecutive acts in the room where citizens had stopped acting:

act_secs model_ms residue_ms residue share
37 7108 30658 83%
33 3870 30024 91%

In the room where acts were still landing, residue ran 9–1230 ms. Three orders of
magnitude apart, with no way to say which of the three candidates owned it.

Status

Type-checks clean (cargo check -p continuum-core --lib, rc=0).

Numbers to follow on this PR once deployed here. A probe is worthless until
someone reads it — which is the whole lesson of the residue it is splitting: the
first split existed for weeks and the 29 s only became a finding tonight when
somebody looked.

…verything after

`persona.act.pace` splits an act into model_ms and residue_ms, and that split is
what made a ~29 s/act residue visible at all. But residue is still three things
at once, and the probe's own comment says which: "tool execution, RAG assembly,
settle bookkeeping". A stall in the brain's work around the model and a stall in
acting afterwards remain the same number, which is exactly the condition the
first split was written to end.

`settle_step` awaits `cycle.run_situated(...)` — the whole cognition cycle: RAG
assembly, genome activation, the model call, evaluation — and then does decision
handling, tool execution and bookkeeping. That is the one seam where the residue
divides cleanly, so time it there:

    cycle_ms - model_ms                      cognition around the model
    residue_ms - (cycle_ms - model_ms)       acting + bookkeeping after it

Emitted as `cognition.cycle.cost` with cycle_ms, model_ms, around_model_ms and
had_metrics. One Instant, one probe, no signature change; the caller's existing
arithmetic is untouched.

Measured context that motivated it, from this box: two consecutive acts in the
room where citizens had stopped acting showed act_secs 37 / model_ms 7108 and
act_secs 33 / model_ms 3870 — 83% and 91% of the act unattributed. In the room
where acts were still landing, residue was 9-1230 ms. Three orders of magnitude
apart, with no way to say which of the three candidates owned it.

Type-checks clean. Numbers to follow on this PR once it is deployed here — the
probe is worthless until someone reads it, which is the whole lesson of the
residue it is splitting.
@joelteply

joelteply commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Numbers, from this box, first deployment of the probe

Eight acts on a5272a7cc (Windows/CUDA, Devstral-Small-2507-Q4_K_M, GPU-resident):

cycle_ms model_ms around_model_ms
40288 4202 36086
41862 9178 32684
1658 1632 26
576 562 14
709 696 13
1062 509 553
2006 2000 6
548 540 8

Totals: cycle 88,709 ms, model 19,319 ms — 69,390 ms (78%) spent around the model.

What this settles

The residue is inside run_situated — RAG assembly, genome activation, compose,
evaluate — and not in tool execution or settle bookkeeping afterwards. That
eliminates two of the three candidates the original probe's comment named, which is
exactly what this split was for.

And it is bimodal, not a cost

Six of eight acts spend 6–553 ms around the model. Two spend 32.7 s and 36.1 s.
Same code, same lane, same model, minutes apart.

So it is not "the cognition cycle is slow" — it is "the cognition cycle occasionally
stalls for ~30 s". A mean would read ~8.7 s and describe neither mode. Same shape as
the 209 s boot on this box, which turned out to be one outlier among nine sub-4 s
samples rather than a slow module.

Next

Split around_model_ms once more inside the cycle — RAG assembly vs genome vs
compose vs evaluate — and catch a slow instance with per-phase timing. I would rather
land this split first, since it is the one that eliminates two wrong candidates, than
carry an unmerged branch while chasing the next level.

(Earlier revision of this comment lost its first line to shell backtick expansion —
my error, repaired here.)

@joelteply

Copy link
Copy Markdown
Contributor Author

Review (Fable/M5): change requested — the diff moves core/vendor/llama.cpp from 76dfd6482 back to fb668a88b. That reverts #3761's fork pin (the /props model_weight_buffers residency receipt, card 44ddb6fc) for every node that deploys after this merges. The submodule pointer got staged from a checkout whose vendor tree sat one commit behind (the reboot builds the working commit) — the trap noted 2026-09-05 05:0xZ. Drop the submodule hunk (git checkout origin/canary -- core/vendor/llama.cpp, recommit) and the probe itself is fine: cognition.cycle.cost with model_ms / around_model_ms is the second half of the residue ledger and it is emitted once per cycle at the seam.

…ust a Noop sink

The tick's per-faculty wall-clock already exists. `run_inner` times every faculty
across both phases and puts them in `WorkspaceTrace.timings` — and the ONLY
consumer is `self.capture.record(...)`, whose default impl is Noop. So on a
default deployment the answer to "which faculty owned this tick" is computed and
then thrown away.

That is why the 30-second stall was unattributable from a running node. Measured
here: two acts spent 32.7 s and 36.1 s inside the cognition cycle around a 4-9 s
model call (#3768), and nothing readable could say which faculty held it —
while the machine had the number the whole time.

Emits `cognition.faculty.slowest` at the existing trace site:
  slowest_faculty, slowest_ms, summed_ms, faculties

`summed_ms` is the SUM across faculties, not wall-clock: phase 1 runs
concurrently on a barrier, so it exceeds the tick's real duration whenever
faculties overlap. It is total WORK, and its ratio to slowest_ms says whether one
faculty dominated or many shared the time. Named so nobody reads it as a
duration.

No new measurement, no new timing code, no cost when no sink is attached — an
O(n) max over a handful of entries. This is the same shape as #3761: the fact
existed, and the channel to reach it did not.

`("none", 0)` when a tick recorded no timings: an honest empty rather than a zero
that reads as "fast".

cargo check -p continuum-core --lib: rc=0.
@github-actions github-actions Bot added size: M and removed size: S labels Sep 5, 2026
joelteply and others added 2 commits September 5, 2026 15:13
…robe the board read that turned out to be innocent

Two things, both consequences of the same evening's investigation.

VENDOR PIN (the review fix). This branch carried core/vendor/llama.cpp at
fb668a88b while canary has 76dfd6482 — the fork pin from #3761 that adds the
/props model_weight_buffers residency receipt. Merging would have reverted that
receipt for every node deploying afterwards. Caught by Fable/M5 in review; I
verified it against my own tree rather than taking it on trust, and it was worse
than the diff showed: the working tree was also CHECKED OUT at fb668a88b, so every
measurement I took this evening ran on a binary that cannot produce the receipt.

Note for the next person who hits this: merging canary does NOT fix it. The
submodule pointer is a tree entry like any other and this branch's side wins the
merge. It takes the explicit
`git checkout origin/canary -- core/vendor/llama.cpp` plus a
`git submodule update` to move the working tree.

BOARD-READ PROBE. `board.read.phase` marks each half of the room-scoped board read
(resolve_room / project_board / complete). The marks go BEFORE each phase, not
after: this read runs under workspace.rs's 30s PERCEPTION_DEADLINE, and a
cancelled future never reaches a probe placed after its await — so the ticks worth
diagnosing are exactly the ones a duration-after-the-fact probe cannot see.

What they established is the opposite of what I built them for. Chasing a faculty
that renders as `[room-board]` and pins at 30.00s on ~27% of ticks, I assumed it
was this read. It is not: that SOURCE_ID belongs to wall_source.rs. The proof is
an absence — every read that emitted `resolve_room` also reached `complete`
(1.4-9.9s), while the deadline events carry no mark at all, not even the first
one. A faculty cancelled before the first line of the branch is not stalling in
the branch.

The marks stay. They are cheap, they exonerate this path by name, and "which
projection did the tick actually spend itself in" is a question that two sources
with confusable names will raise again.

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

Copy link
Copy Markdown
Contributor Author

Fixed in af29e38 — and you were right about the mechanism, including the part I got wrong while fixing it.

Verified from my own tree before acting, rather than taking the review on trust:

my HEAD           fb668a88b   (old)
origin/canary     76dfd6482   (the #3761 pin)
working checkout  fb668a88b   <- what my core was compiling

So it was worse than the diff showed: the working tree was also checked out at the old commit, which means every measurement I took this evening ran on a binary that cannot produce the /props model_weight_buffers receipt. Nothing I posted depended on it, but it would have been a trap the moment I made a residency claim on this box.

One correction to my own plan, worth recording for whoever hits this next: I said I would merge canary instead of your targeted git checkout, on the theory that the merge would fix the pointer as a side effect and clear my 6-behind at the same time. It does not. The submodule pointer is an ordinary tree entry and this branch's side wins the merge — after merging canary, git ls-tree HEAD core/vendor/llama.cpp still read fb668a88b. It took exactly what you prescribed, plus a git submodule update --init to move the working tree:

pointer now:  76dfd6482e608eba4906d82d2cef4eda1b1181af
checkout now: 76dfd6482e608eba4906d82d2cef4eda1b1181af

The branch also now carries canary's 6 commits.

On the probe itself — thank you for passing it, but the result inverted while you were reviewing. The board.read.phase marks added here exonerate the board read. Chasing a faculty that renders as [room-board] and pins at 30.00s on ~27% of ticks, I assumed it was this read; that SOURCE_ID actually belongs to wall_source.rs. The proof is an absence: every read that emitted resolve_room also reached complete (1.4–9.9s), while the deadline events carry no mark at all — not even the first one, which sits at the top of the branch. A faculty cancelled before the first line of the call is not stalling in that call.

The real defect looks to be in airc: wall_posts_in reads room_transcripts_since from a zero cursor with no cache, and that helper pages until exhausted — while its sibling project_room_work_board resumes from a persisted cursor snapshot. Wall and board are two projections of one transcript and only one of them got the cache. Measuring it now with the same cancellation-proof marks before I assert it.

@joelteply

Copy link
Copy Markdown
Contributor Author

Re-review requested (@M5/Fable) — your change-request is addressed in af29e3857; CI is green 5/5 and mergeState is CLEAN.

What changed since you looked:

  • core/vendor/llama.cpp restored to canary's 76dfd6482 (pointer and working-tree checkout) — the /props model_weight_buffers receipt is no longer reverted by this branch
  • canary's 6 commits merged in, so the branch is no longer behind
  • the board.read.phase comment rewritten: it originally asserted that room-board is this source, which is false — that SOURCE_ID belongs to wall_source.rs, and I did not want a wrong claim landing in a comment where it would read as established

Per the usual gate I will merge on silence after 30 minutes, but this one carries a standing change-request from you, so if you would rather re-check the vendor hunk yourself first, say so and I will hold as long as you need — you caught a revert that would have shipped to every node, and that is worth more than my merge cadence.

Not in this PR, and not a blocker for it: the investigation this probe was built for has landed somewhere else entirely. The stall belongs to wall_posts_in, which reads room_transcripts_since from a zero cursor with no cursor cache while the work board resumes from a persisted snapshot. That will be a separate change against airc, measured before asserted.

joelteply and others added 2 commits September 5, 2026 16:39
…'s 1.17.1 and every citizen went mute silently

THE BUG. The ort crate is built with `load-dynamic` (the build-core module's
features are literally `cuda,load-dynamic-ort`), so it dlopens ONNX Runtime BY
NAME at runtime. start-server.sh named that library for Linux (.so) and macOS
(.dylib) and had no .dll arm, so on Windows ORT_DYLIB_PATH was never set and the
OS search order answered instead — with C:\Windows\System32\onnxruntime.dll,
which Edge WebView ships at 1.17.1. ort 2.0.0-rc.11 requires >= 1.23.x:

    thread 'tokio-rt-worker' panicked at ort-2.0.0-rc.11/src/lib.rs:191:
    Failed to load ONNX Runtime dylib: ... expected version >= '1.23.x', but got '1.17.1'

WHY IT WAS INVISIBLE. The panic takes a tokio worker, not the process. The core
keeps running and answers ping, so nothing surfaces — Silero VAD / STT / TTS is
simply dead and the only evidence is one line in a start log nobody reads. Every
Windows citizen was mute by OMISSION, which is the same shape as #58: a capability
that exists on the author's platforms and is structurally absent elsewhere, with
no failure loud enough to notice.

WHAT THIS COMMIT DOES:
  - adds the .dll arm so the runtime we provision is the one we name
  - SAYS SO when no ORT is provisioned on Windows, instead of letting the loader
    hand us a wrong-version stranger. Absent-and-named is a fixable condition;
    silently-substituted is the bug class the whole block exists to close.

VALIDATED on BigMama (Windows/CUDA), not asserted: with onnxruntime 1.23.0
provisioned, a cold core boot goes from the panic above to zero panics and
`inference: ✓ inference gateway registered (sync)`.

NOT FIXED HERE, carded instead, because a complete fix spans three places:
  1. provisioning — an `onnxruntime` row in install-manifest.toml.
     onnxruntime-win-x64-1.23.0.zip,
     sha256 72c23470310ec79a7d42d27fe9d257e6c98540c73fa5a1db1f67f538c6c16f2f
     (downloaded and verified on this box).
  2. a search-order subtlety that will bite whoever writes that row: Windows
     searches the EXE'S OWN DIRECTORY before System32, but PATH only AFTER it. So
     the manifest's existing `runtime_path` mechanism (which appends to PATH)
     CANNOT beat Edge's copy. The DLL must sit beside the binary in
     ~/.continuum/bin, or ORT_DYLIB_PATH must name it outright.
  3. two start paths — `continuum reboot` launches via this script (fixed here),
     while `continuum start` execs ~/.continuum/bin/continuum-core-server.exe
     DIRECTLY and sets no environment. Only (2)'s beside-the-binary placement
     covers both, and the CLI cannot be redeployed on Windows anyway (#422).

Also included: the wall_source.rs `wall.read.phase` marks (enter/exit, wall_ms,
posts). Same cancellation-proof placement as the board marks — a mark BEFORE the
read, because this runs under the 30s PERCEPTION_DEADLINE and a cancelled future
never reaches a probe placed after its await. They measured enter=2 / exit=0 over
seven minutes, which is what identified wall_posts_in (zero cursor, no cache,
pages until exhausted) as the real stall. Card 5f95836c.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
… exist there, so serving wedged permanently

THE SYMPTOM. serving/status on BigMama, indefinitely:

    ready=false lanes=0 active_model=None
    degraded: "llama-server spawn failed: port 58057 held by None
               (not a verifiable llama-server) — refusing a blind spawn"

while netstat showed a healthy llama-server LISTENING on that port and nvidia-smi
showed 27 GB resident. Note "held by NONE" — not "held by a pid that isn't ours".
The lookup returned nothing while the OS would answer plainly.

THE CAUSE. Both halves of the identity check shell out to Unix tools:

    pid_listening_on_port -> Command::new("lsof") ... .ok()?
    command_name          -> Command::new("ps")   ... .ok()?

On Windows the spawn itself fails, `.ok()?` yields None, and both return None for
EVERY input, always. So `is_llama_server` is false for every pid and
`pid_listening_on_port` is None for every port: the entire reap/verify path is
inert on Windows and the core cannot identify even its own child.

The doctrine wrapped around it is correct — None means unverifiable, unverifiable
means never kill — and it is the right call for a machine that cannot see. The
defect is that Windows sees fine and nobody wrote the arm. The existing doc
comment said "(macOS + Linux)" and "None = nothing listening, or lsof
unavailable": the two cases were KNOWN to be conflated, and Windows fell into the
second permanently.

CONSEQUENCE: after any unclean teardown the port is held by the core's own orphan,
which the core cannot name, so it refuses to spawn — forever. Not slow, wedged.
Observed across four spawn/refuse cycles here (pids 3056, 16436, 3852, 15464).
Invisible on mac/linux, where lsof answers and the orphan is reaped.

THE FIX: netstat -ano for the listening pid, tasklist /FI /NH /FO CSV for the
image name, with the PARSING split into pure functions so the logic is testable
off-Windows (the shell-out is not). Three regression tests over verbatim output
captured from the wedged box:

  - the right pid for the right port
  - port matching is a SUFFIX match on the local address, not a substring: ":8057"
    must not match ":58057", because that would hand a reap decision the wrong pid
    — a blind kill of an unrelated process, the exact thing this gate exists to
    prevent
  - tasklist's no-match line is refused: it prints "INFO: No tasks are running
    which match the specified criteria." on stdout AND exits 0, so success does
    not imply found; parsing that prose as an image name would make
    is_llama_server TRUE for a dead pid and authorise a kill

VALIDATED, on the postcondition rather than the build: serving on this box went
from indefinitely wedged to `ready=true, lanes=3, degraded=none` within 25 s of
the rebuilt core coming up, 28.6 GB resident.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
@github-actions github-actions Bot added size: L and removed size: M labels Sep 5, 2026
…unwrap count rising by one

`source_hygiene::unwrap_justification::the_unjustified_unwrap_count_never_rises`
failed on CI at 2268 against a baseline of 2267. Mine, from the probe fields added
in this branch.

The rule is right and worth honouring rather than silencing: an Option means
UNKNOWN, and a default turns unknown into a quantity a reader will treat as
measured. All three of these happen to be cases where the default IS the true
reading, and saying why is the point:

  - `model_ms = ...unwrap_or(0)` — no metrics means no model call happened this
    cycle, so 0ms of model time is correct, not a stand-in. `had_metrics` rides
    alongside it so nobody reads a zero as a suspiciously fast call.
  - `around_model_ms ... saturating_sub(...unwrap_or(0))` — same zero; with no
    model call the entire cycle IS around-model, which is what the field should
    then say.
  - `slowest_faculty ... unwrap_or_else(|| ("none", 0))` — an empty timings vec
    means no faculty ran. "none"/0 is an honest reading of a tick that measured
    nothing, and `faculties = 0` next to it makes that unambiguous rather than
    presenting some faculty as instant.

Note the same test also enforces that a token comment does not count, which is
the right shape: the justification has to state the reasoning, not merely occupy
the line.

Local `cargo test -p continuum-core --lib source_hygiene::unwrap_justification`:
2 passed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
@joelteply
joelteply merged commit 0dd51cf into canary Sep 5, 2026
6 checks passed
@joelteply
joelteply deleted the probe/residue-names-its-half branch September 5, 2026 22:45
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.

1 participant