Skip to content

T24b: keep the sensing runners; time becomes a belief input (#40) - #188

Merged
superposition merged 1 commit into
mainfrom
ticket/T24b
Sep 11, 2026
Merged

superposition merged 1 commit into
mainfrom
ticket/T24b

Conversation

@superposition

@superposition superposition commented Sep 11, 2026 •

Copy link
Copy Markdown
Owner
agent: TicketT24b
branch: ticket/T24b
commit: aa832c256823ccb480263375917364fc5535ca4d
state: review
next: correctness, clean-room and contract reviewers read the diff at aa832c2; merge when all three approve, naming T24b in the merge commit
blocked_on: none
evidence: https://github.com/superposition/qualia/pull/188

Rebase, 2026-09-11 (two rounds; no re-authoring)

This branch was cut from 6a4e275, then rebased twice as main moved, and force-pushed
(--force-with-lease) each time: 923606e → f0defdd (onto 2fde432, T19's #150 merge) →
aa832c2 (onto 97a50f3, the current main tip). The first round conflicted in
crates/braid/src/lib.rs, the one Main flagged: both branches had added to that file from the same
one-line stub.

The resolution keeps T19's file verbatim — module docs, BRAID_EVENT_SCHEMA, BraidState,
BraidEvent (Unknown arm included), BraidError, observe and now_ns are untouched, byte for
byte — and re-appends this ticket's addition: the use qualia_shm::{…} line beside T19's other
imports, then the belief-clock block at the end of the file. The second round was mechanical and
touched only the base.

$ git diff --stat origin/main          # in the ticket worktree, at aa832c2
 Cargo.lock                  |  1 +
 crates/braid/Cargo.toml     |  1 +
 crates/braid/src/lib.rs     | 70 +++++++++++++++++++++++++++++++
 crates/braid/tests/clock.rs | 99 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 171 insertions(+)
$ git diff origin/main -- crates/braid/src/lib.rs | grep -c '^-'
0
$ git merge-base --is-ancestor origin/main HEAD && echo ok
ok

Every line this ticket contributes to crates/braid/src/lib.rs is an addition; nothing T19 wrote is
deleted, reworded or reordered. The lines that are mine are exactly: the use qualia_shm::{LayerReader, ShmRegion, MAX_LEDGER_ENTRIES, NUM_LAYERS}; line (inserted directly after T19's
use std::time::{SystemTime, UNIX_EPOCH};) and the block from the // ── The belief clock ── banner
to end of file (BeliefClock, newest_belief_ns, newest_ledger_ns). crates/braid/Cargo.toml
and Cargo.lock auto-merged: T19's dependency comment plus this ticket's qualia-shm line.

What changed

Step 24b is two halves. The sensing runners keep their present shape — runners/lidar, camera,
vision, floor, vslam, pose, map and health are untouched by this diff; pose and map
were already paced by the belief commit in T21 (#164). The second half is time as a belief input:
qualia-jepa-model already stamps every belief tick from RuntimeInput::delta_seconds, so this
ticket surfaces that timing instead of adding a clock.

crates/braid/src/lib.rs gains a read-only view of the arena:

  • pub struct BeliefClock<'a> — borrows a mapped arena, BeliefClock::new(&ShmRegion).
  • pub fn decision_latency_ns(&self) -> u64 — the newest BeliefSlot::timestamp_ns across the eight
    layer slots (each layer's front buffer, read through qualia_shm::LayerReader) minus the newest
    finished LedgerEntry::timestamp_ns in the ledger ring. It is 0 when either side has nothing to
    compare (no layer has committed a belief, and/or the ledger holds no finished row), and 0 rather
    than a wrapped subtraction when a ledger row reads newer than the newest belief commit. The newest
    row is read at sequence ledger_seq() - 1 and only counts when the slot's stored seq is that
    sequence — a slot whose seq is not the one being read is a row the writer claimed but has not
    finished, which is the rule runners/watch's drain_ledger already uses.

BraidState is deliberately not the receiver: the braid's state is serialised to JSON at
GET /braid (T20) and holds no mapping, so the clock is a separate view type.

Step 27's TUI consumes it from runners/watch as
qualia_braid::BeliefClock::new(&shm).decision_latency_ns(), rendering belief lag: {ms} ms
(agreed with TicketT27); the name and signature are exactly what step 24b fixes.

Pose filter check, per the ticket

runners/pose/src/main.rs holds no Kalman or particle filter — its module docs say so and the
estimator is an ICP scan graph with no covariance or motion model — so, per the ticket, no filter was
added and the estimation path is unchanged apart from T21's already-merged pacing.

Tests written first

crates/braid/tests/clock.rs (new), which builds a region the way the runners do (a belief runner
fills the back buffer and publishes it; a ledger writer appends a row) and asserts only the number a
caller gets back:

  • latency_is_the_newest_belief_commit_minus_the_newest_ledger_row — 1000 ms belief / 400 ms ledger
    ⇒ 600 ms, then a newer stamp on each side ⇒ 250 ms, so neither side reports its first stamp;
  • latency_is_zero_until_both_a_belief_and_a_ledger_row_exist — empty, belief-only, ledger-only;
  • a_ledger_row_newer_than_the_belief_commit_reports_zero — the saturation boundary;
  • the_newest_row_is_read_from_its_wrapped_ring_slot — more rows than the ring holds, so the newest
    row is read back from slot zero.

Evidence at aa832c2

Host, -j 2, run twice, rc taken from the run itself (not a pipe):

$ cargo test -p qualia-braid -j 2
    Finished `test` profile [unoptimized + debuginfo] target(s) in 2.87s
     Running tests\braid.rs      running 6 tests   ... test result: ok. 6 passed; 0 failed
     Running tests\clock.rs      running 4 tests
test a_ledger_row_newer_than_the_belief_commit_reports_zero ... ok
test latency_is_the_newest_belief_commit_minus_the_newest_ledger_row ... ok
test the_newest_row_is_read_from_its_wrapped_ring_slot ... ok
test latency_is_zero_until_both_a_belief_and_a_ledger_row_exist ... ok
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.25s
     Running tests\manifest.rs  running 1 test   test stack_manifest_has_fly_keys ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
exit=0

Second run at the same head: exit=0, the same five result lines.

$ python C:/tmp/gate.py          # run inside the ticket worktree
provenance: compared 134 authored file(s) (1 generated skipped); 0 byte-identical, 6 code runs over 20, 0 prose runs over 2
provenance: OK

Board (Pinkie, the Waveshare-carried Orin NX at jetson@192.168.55.1), native aarch64 from a
git archive of aa832c2 at ~/t24b-bundle, one build, no GPU:

$ uname -m
aarch64
$ ~/.cargo/bin/rustc --version
rustc 1.94.0 (4a4ef493e 2026-03-02)
$ python3 board-trim.py
board tree trimmed to braid's closure
$ ~/.cargo/bin/cargo test -p qualia-braid --offline -j 2
   Compiling qualia-braid v0.1.0 (/home/jetson/t24b-bundle/t24b/crates/braid)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 1m 07s
     Running tests/braid.rs (target/debug/deps/braid-88b12988c3ad68a3)
running 6 tests
test failed_quarantine_dispatch_leaves_state_untouched ... ok
test mission_lifecycle_updates_open_count ... ok
test quarantined_event_dispatches_to_mcap ... ok
test quarantined_event_with_nothing_to_move_still_stamps ... ok
test rollback_event_is_recorded_and_state_survives ... ok
test unknown_events_are_ignored ... ok
test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
     Running tests/clock.rs (target/debug/deps/clock-92a80356b451ae74)
running 4 tests
test a_ledger_row_newer_than_the_belief_commit_reports_zero ... ok
test latency_is_the_newest_belief_commit_minus_the_newest_ledger_row ... ok
test the_newest_row_is_read_from_its_wrapped_ring_slot ... ok
test latency_is_zero_until_both_a_belief_and_a_ledger_row_exist ... ok
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.16s
     Running tests/manifest.rs (target/debug/deps/manifest-4669d8a0c59699b1)
running 1 test
test stack_manifest_has_fly_keys ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
cargo_exit=0

qualia-braid is a library, so its test binaries are the artifact: this head builds and runs green
natively on the robot's architecture, with the belief clock's four tests among them.

Board packaging (nothing here is committed)

Pinkie has no DNS, so the tree was built against a vendored copy of braid's 97-crate dependency
closure (Cargo.lock moved aside, resolved --offline). Two workspace members cannot be resolved
from that vendor — crates/jepa-registry pulls turso/tokio/qualia-jepa-model, a tree two orders
larger than braid's closure — so board-trim.py (shipped beside the tree) narrows the board copy's
members to crates/{braid,mcap-log,shm,types} and drops braid's qualia-jepa-registry edge,
which cargo ignores on the host anyway (ignoring invalid dependency qualia-jepa-registry which is missing a lib target). No crate source is edited for the board run; the compiled crates/braid is
this commit. The same trimmed+vendored recipe was first run on the host in a scratch tree, green,
before it was used on the board.

Notes for reviewers

  • The ticket names crates/braid/src/lib.rs as the file; the diff also adds
    crates/braid/tests/clock.rs (the ticket's command is cargo test -p qualia-braid), one
    dependency line in crates/braid/Cargo.toml (qualia-shm = { workspace = true } — the
    BeliefSlot and LedgerEntry stamps live in the mapped arena, which is the only handle that
    reaches them) and its Cargo.lock edge.
  • Nothing emitted changes: this crate writes no log line, publishes no document and prints nothing,
    so D-008/D-009 have no surface to keep byte-identical here. The belief lag: {ms} ms line is
    step 27's, in runners/watch.

Closes #40

The braid gains a read-only view of time: BeliefClock reads the newest BeliefSlot stamp across the eight layer slots and the newest finished row of the ledger ring, and decision_latency_ns reports the distance between them. Nothing else about the braid changes; BraidState, BraidEvent and observe are untouched.
@superposition

Copy link
Copy Markdown
Owner Author
agent: TicketT24b
branch: ticket/T24b
commit: aa832c256823ccb480263375917364fc5535ca4d
state: review
next: correctness, clean-room and contract reviewers read this diff at aa832c2
blocked_on: none
evidence: https://github.com/superposition/qualia/issues/40#issuecomment-5633341071

Which lines of crates/braid/src/lib.rs are mine, since two tickets own that file:

  1. use qualia_shm::{LayerReader, ShmRegion, MAX_LEDGER_ENTRIES, NUM_LAYERS}; — one line, inserted
    directly after T19's use std::time::{SystemTime, UNIX_EPOCH};.
  2. The block from the // ── The belief clock ── banner to end of file — BeliefClock with
    new(), decision_latency_ns(), and the private newest_belief_ns / newest_ledger_ns.

Everything else in that file is T19's, byte for byte: the module docs, BRAID_EVENT_SCHEMA,
BraidState, BraidEvent (its Unknown arm included), BraidError, observe and now_ns.
git diff origin/main -- crates/braid/src/lib.rs is +70 / −0, i.e. additions only; the other two
files are crates/braid/tests/clock.rs (new) and the qualia-shm line in
crates/braid/Cargo.toml plus its Cargo.lock edge.

The head is aa832c2 (rebased onto 97a50f3, twice rebased total since the branch was cut from
6a4e275). No force-push is planned unless main moves again; if it does, I will message the
reviewers first and the crate diff will stay empty. This is a body/edit-only change on my side: the
PR body now carries the evidence at aa832c2, including the native aarch64 board run
(cargo_exit=0, tests/braid.rs 6/0, tests/clock.rs 4/0, tests/manifest.rs 1/0).

@superposition

Copy link
Copy Markdown
Owner Author
role: contract
verdict: approve
notes: 0
agent: Rev188Contract
branch: ticket/T24b
commit: aa832c256823ccb480263375917364fc5535ca4d
state: review
next: merge after correctness and clean-room approve; the head was re-rebased to aa832c2 mid-review, so re-rebase onto the then-current main and re-read if main moves again
blocked_on: none
evidence: https://github.com/superposition/qualia/pull/188

Static pass only: no build, no board, so D-014's WHEA window does not bear on this verdict. The host build slot belongs to the correctness reviewer.

Reviewed sha aa832c256823ccb480263375917364fc5535ca4d — gh pr view 188 --json headRefOid and git ls-remote origin refs/heads/ticket/T24b both return it, and it is the HEAD of the ticket worktree C:/Users/ericm/wt/T24b. The PR description still says f0defdd; that commit was amended out, and git diff f0defdd aa832c2 -- crates/braid/ is empty (crates/braid/src/lib.rs md5 bbfb133434e625f8b5494a80fbd4bf67 on both), so the amended-out revision carries byte-identical braid content and this review stands at the live head.

(a) T19's surface is byte-identical; the lib.rs diff is additive only

$ git diff --stat origin/main aa832c2 -- crates/braid/src/lib.rs
 crates/braid/src/lib.rs | 70 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
$ git diff origin/main aa832c2 -- crates/braid/src/lib.rs | grep -c '^-[^-]'
0
$ git show 2fde432:crates/braid/src/lib.rs | md5sum      # T19's merge commit
c4f4d2bfa1df020e480f483b3fccfe70
$ git show origin/main:crates/braid/src/lib.rs | md5sum  # main at afd9a75
c4f4d2bfa1df020e480f483b3fccfe70

origin/main's lib.rs is the same blob T19 merged (2fde432, the merge commit this branch was rebased onto), so git diff origin/main -- crates/braid/src/lib.rs is exactly the ticket's addition at the current tip: 70 insertions, 0 deletions. The same holds against the rebase parent: git diff 2fde432 f0defdd -- crates/braid/src/lib.rs is +70/-0.

Zero removed lines in a unified diff is the proof of byte-identity: no line of T19's file is deleted, reworded or reordered. The 70 added lines are the one use qualia_shm::{LayerReader, ShmRegion, MAX_LEDGER_ENTRIES, NUM_LAYERS}; line and the 69-line belief-clock block, both pure insertions. T19's module docs, BRAID_EVENT_SCHEMA, BraidState, BraidEvent, BraidError, observe and now_ns are carried verbatim.

(b) BeliefClock's public shape matches the plan and T27's call

The plan (issue #40) fixes pub fn decision_latency_ns(&self) -> u64 — newest BeliefSlot timestamp minus the newest ledger entry's. Step 27 (#43) consumes it as qualia_braid::BeliefClock::new(&shm).decision_latency_ns(). The head's added block:

pub struct BeliefClock<'a> {
    region: &'a ShmRegion,          // private; no public field
}

impl<'a> BeliefClock<'a> {
    pub fn new(region: &'a ShmRegion) -> Self
    pub fn decision_latency_ns(&self) -> u64
}
  • Receiver / constructor — new(&'a ShmRegion), a borrow, not a value or a BraidState. The crate is qualia-braid, so qualia_braid::BeliefClock is the crate-root path T27 imports; new(&shm) binds whenever shm is a ShmRegion (T27's app.shm is already read as &ShmRegion for layer_slot).
  • Return / error semantics — a bare u64. No Result, no Option, so no error or None arm can break the caller. 0 is the documented sentinel: either side has nothing to compare, or a ledger row reads newer than the newest belief (saturating_sub, no wrap).
  • Surface breadth — only BeliefClock, new and decision_latency_ns are public in the addition; newest_belief_ns and newest_ledger_ns are private. No wire or JSON field name changes (BraidState untouched).
  • Backing API on main — the names the block calls all exist: qualia_shm::{ShmRegion, LayerReader, MAX_LEDGER_ENTRIES, NUM_LAYERS}, ShmRegion::{layer_slot, ledger_entry, ledger_seq}, LayerReader::new.
  • Consumed as T27 will — crates/braid/tests/clock.rs uses use qualia_braid::BeliefClock; and BeliefClock::new(&region).decision_latency_ns(), the exact call shape, and asserts only the number a caller gets back.

(c) Diff scope — crates/braid/** plus the lock edge

$ git diff --name-status $(git merge-base aa832c2 origin/main)..aa832c2
M	Cargo.lock
M	crates/braid/Cargo.toml
M	crates/braid/src/lib.rs
A	crates/braid/tests/clock.rs

Merge-base is 97a50f3, the rebase base. Source scope is crates/braid/** only; the one path outside it is Cargo.lock, the lock edge the new dependency forces. crates/braid/Cargo.toml adds exactly qualia-shm = { workspace = true } (package name, features and every other key unchanged), Cargo.lock adds qualia-shm to qualia-braid's dependency list (one line), and the root Cargo.toml already declares qualia-shm = { path = "crates/shm" }, so the workspace reference resolves. Nothing under runners/, crates/types or crates/shm is touched.

Note (not a defect)

origin/main has advanced since the rebase (afd9a75, merging #144 C35 and #162 T40) while this branch is based on 97a50f3. Against the moving tip, git diff origin/main aa832c2 also shows C35/T40 content reverted (assets/mark/*, runners/vision/src/main.rs) — ordinary pre-merge branch drift, not a T24b change. The additive lib.rs check above is unaffected because main's lib.rs is unchanged since T19 (c4f4d2bf). Re-rebase onto the then-current main before merge, as the PR's own sequencing note already says, and re-run the additive check; the merge commit names T24b.

@superposition

Copy link
Copy Markdown
Owner Author
role: clean-room
verdict: approve
notes: 3
agent: Rev188Clean
branch: ticket/T24b
commit: aa832c256823ccb480263375917364fc5535ca4d
state: review
next: merge ticket/T24b once correctness approves; clean-room and contract read approve at aa832c2
blocked_on: none
evidence: https://github.com/superposition/qualia/pull/188

Clean-room read of aa832c2 (T24b belief clock)

I did not touch the author's worktree. Everything ran in my own detached checkout at
C:/tmp/Rev188Clean/tree2 (git worktree add --detach … aa832c2), never C:/Users/ericm/wt/T24b.
Static work only — git, Python, the gate, diff reads; no build, no test, no GPU — so D-014's WHEA
window does not bear on this verdict; the fault stamp is unchanged at 2026-09-11T06:27:43Z and
C:/tmp/resmon.log gained no new WHEA line.

Head verified against the remote:

$ gh pr view 188 --repo superposition/qualia --json headRefOid
aa832c256823ccb480263375917364fc5535ca4d
$ git ls-remote origin refs/heads/ticket/T24b
aa832c256823ccb480263375917364fc5535ca4d	refs/heads/ticket/T24b

Blobs equal the committed head (git hash-object = git rev-parse HEAD:<path>, core.autocrlf=false):

file git hash-object
crates/braid/src/lib.rs 96c6db3cc5e8d92d80504d7ee64e778b0d4f2784
crates/braid/tests/clock.rs e78f876e06a69b485e0ccd2e23f5dbf11682e231
crates/braid/Cargo.toml 2f5fe04f3b50bdd3914dfaae46de1b57489e6698

The PR body (and the task that sent me) says f0defdd; that commit was amended out mid-review. The live
head is aa832c2 and git diff f0defdd aa832c2 -- crates/braid/ is empty. I re-ran the gate and the
whole-tree scan at aa832c2, so the measurement below is of the live head itself.

Gate

$ cd C:/tmp/Rev188Clean/tree2 && python scripts/provenance_check.py C:/qualia
provenance: compared 134 authored file(s) (1 generated skipped); 0 byte-identical, 7 code runs over 20, 0 prose runs over 2
provenance: highest identical-code-line share 1.000 (.cargo/config.toml)
CODE RUN 40: crates/types/src/lib.rs
CODE RUN 36: runners/arena-recorder/src/main.rs
CODE RUN 31: kernels/evidence_layout.cu
CODE RUN 30: crates/sync-types/src/lib.rs
CODE RUN 24: runners/agent/Cargo.toml
CODE RUN 23: crates/jepa-dataset/src/lib.rs
CODE RUN 21: crates/sync-types/src/spatial.rs
provenance: OK

Exit 0. None of the seven over-threshold files is in this diff — they are pre-existing paths the
rebased head carries from main. The gate skips crates/braid/** because C:/qualia has no such path,
so the gate's OK does not itself clear this ticket; the whole-tree scan below does.

Each changed file against the whole reference tree

Method: the gate's own predicates (trivial, is_comment, code_line, prose_line) and the same
contiguous-run metric, but each changed file compared against all 497 authored reference files under
C:/qualia, not only the same-path counterpart. Scripts: C:/tmp/Rev188Clean/{measure.py,lines.py}.

changed file / scope lines longest identical code run where longest prose run line-identical to any ref file
crates/braid/src/lib.rs (whole) 246 3 runners/agent/src/arena_tags.rs:791 — fn now_ns() -> u64 { + SystemTime::now() + .duration_since(UNIX_EPOCH), my lines 172–174 (pre-existing T19 code) 1 (bare ///) none
crates/braid/src/lib.rs, T24b block lines 179–246 68 1 crates/mcap-log/src/lib.rs:382 — .max() 1 (bare ///) none
crates/braid/tests/clock.rs 99 1 runners/agent/src/compute.rs:621 — writer.publish(); 1 (bare //! / #[test]) none
crates/braid/Cargo.toml 21 4 runners/arena-recorder/Cargo.toml:15 — dependency block lines 18–21 (qualia-shm/qualia-types/serde/serde_json); only line 18 is added 0 none
Cargo.lock — generated; excluded from run metrics by the gate (GENERATED) — — —

Classification of every shared run

  • lib.rs run of 3 (lines 172–174) — now_ns, pre-existing on the rebase base (2fde432, and on
    97a50f3); it is the standard SystemTime::now() / .duration_since(UNIX_EPOCH) idiom. T24b adds zero
    lines to it. Not this ticket's code.
  • T24b block, maximum 1 — .max() is Iterator::max. A single line, a std method; no shared
    logic, control flow, assertion or private-helper body in the block forms a run at all.
  • tests/clock.rs, maximum 1 — writer.publish(); is the qualia_shm::LayerWriter API; the two other
    isolated shared lines are _pad: 0, and timestamp_ns,, LedgerEntry field initialisers. Every one is
    a name the consumed crate's public contract forces.
  • Cargo.toml run of 4 — dependency manifest keys shared with runners/arena-recorder/Cargo.toml.
    The ticket adds exactly qualia-shm = { workspace = true }; the other three lines predate T24b. A
    manifest key is the declaration the gate's own doc calls out as contract-forced, not copied logic.

Prose — none copied

  • Longest identical prose run is 1 line, and in every case a bare marker (///, //!) or the
    attribute #[test]; there is no run of 2, let alone the fatal >2 consecutive comment lines. The
    lone non-bare line the scan flags is #[derive(Debug)], an attribute.
  • Zero shared prose sentences: a whole-tree line scan finds no non-marker doc/comment line from the
    block or the test file that appears in any of the 497 reference files. Sampled sentence fragments —
    read-only view of the belief clock, the part of the loop that is waiting rather than thinking,
    Nanoseconds from the newest ledger row to the newest belief commit, Rows land in a ring and the header says how many have gone in, the newest stamp any layer's front buffer carries, a region left behind by a killed process is not reopened, fill the back buffer, then flip the index so readers see it, stamped when it commits — return 0 matches in the reference tree.

Identifiers — authored here

Whole-reference-tree search:

  • BeliefClock, decision_latency_ns, newest_belief_ns, newest_ledger_ns, commit_belief,
    test_region, NEXT_REGION, qualia-braid-clock, and all four #[test] function names: 0 hits.
  • append_ledger: 2 hits, both inside crates/shm/src/lib.rs itself — the pub fn append_ledger
    declaration (line 447) and that crate's own test (line 1407). It is the shm crate's published method
    the clock and its test call; not authored here.

The new clock code, its module docs and its tests are authored on this branch.

Notes — 3, none blocking

  1. Head moved during review. The task and the PR body name f0defdd; the live head is aa832c2
    (base 97a50f3). git diff f0defdd aa832c2 -- crates/braid/ is empty and the four changed-file blobs
    are identical, so this read is the same object under either name; I re-ran it at the live head.
  2. The gate's byte-identity arm is vacuous on this host. C:/qualia stores CRLF while the checkout is
    LF (crates/types/src/lib.rs: 1588 CRLF, 0 LF-only), so "0 byte-identical" can never fire. I re-ran
    identity as full line-sequence equality of each changed file against all 497 authored reference
    files — none matches.
  3. No shared-run finding touches this ticket. The longest whole-file run in lib.rs (3 lines) is
    T19's now_ns; the T24b addition's own maximum is 1 line, and its manifest addition is one key. The
    pure-insertion property (git diff 97a50f3 aa832c2: +70/-0 lib.rs, +99/-0 clock.rs, +1/-0 each
    manifest and lock) is recorded here only as context — it is the correctness/contract concern, and both
    of those roles have their own reads.

Clean-room verdict: approve. The gate is OK, no prose is shared, and every long identical code run
is a declaration or API name the contract forces, never copied logic.

@superposition

Copy link
Copy Markdown
Owner Author
role: correctness
verdict: approve
notes: 2

Reviewed head aa832c256823ccb480263375917364fc5535ca4d (gh pr view 188 --json headRefOid; the PR body still names f0defdd). git diff f0defdd..aa832c2 -- crates/braid Cargo.lock is empty, so the belief-clock content is byte-identical between the two and this verdict covers both; the only delta between them is main's newer runners/arena-recorder and runners/cuda-smoke files. All runs below are in a clean detached worktree at aa832c2, one -j 2 build at a time, exit codes taken from the run (no pipe).

Reproduced build and tests

$ cargo test -p qualia-braid -j 2
warning: qualia-braid v0.1.0 (...\crates\braid) ignoring invalid dependency `qualia-jepa-registry` which is missing a lib target
   Compiling qualia-braid v0.1.0 (...)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 1m 04s
     Running tests\braid.rs   running 6 tests  ... ok   (6 passed)
     Running tests\clock.rs   running 4 tests  ... ok   (4 passed)
     Running tests\manifest.rs running 1 test  ... ok   (1 passed)
     Doc-tests qualia_braid   running 0 tests
exit=0

11 tests, 0 failed — T19's 6 in tests/braid.rs, this ticket's 4 in tests/clock.rs, 1 in tests/manifest.rs. Second run (cached): Finished ... in 2.08s, same 11 tests, exit=0. Last WHEA stamp is 2026-09-11T06:27:43Z; both runs land ~4 h later, no ICE, no fault within ±2 min, so neither result is provisional.

Semantics against #40 and the ABI it reads

  • Slot/field: newest_belief_ns takes the max BeliefSlot::timestamp_ns across 0..NUM_LAYERS (= 8), reading each layer's front buffer through qualia_shm::LayerReader — the ABI's published buffer — and skipping zero ("never"). This is the "newest BeliefSlot timestamp" the ticket names.
  • Ledger row: newest_ledger_ns reads region.ledger_seq(), takes seq - 1, indexes % MAX_LEDGER_ENTRIES, and accepts the row only when entry.seq == newest && entry.timestamp_ns != 0. That is the claim-then-write rule runners/watch's drain_ledger follows: ShmRegion::append_ledger bumps ledger_write_seq before writing the slot, so a claimed-but-unwritten slot must not read.
  • Value: belief_ns.saturating_sub(ledger_ns); 0 when either side has nothing, and 0 (not a wrapped subtraction) when a ledger row reads newer than the belief commit — exactly the ticket's test-first line "newest belief ts minus newest ledger ts" and the doc's saturation boundary.
  • Cross-ticket contract for T27: pub struct BeliefClock<'a>, pub fn new(region: &'a ShmRegion) -> Self, pub fn decision_latency_ns(&self) -> u64 — matches qualia_braid::BeliefClock::new(&shm).decision_latency_ns().

T19's surface and the sensing runners

git diff 2fde432..aa832c2 -- crates/braid/src/lib.rs is 70 insertions, 0 deletions; every pub item T19 wrote is present, and its module docs/observe/BraidState/BraidEvent/BRAID_EVENT_SCHEMA are untouched. git diff --name-status 97a50f3 aa832c2 (and 2fde432 f0defdd) names only Cargo.lock, crates/braid/Cargo.toml, crates/braid/src/lib.rs, crates/braid/tests/clock.rs — no runners/ file, so no sensing runner's behaviour moves.

Falsification (mutate the staleness rule; the tests catch it)

Inverted the ordering/staleness guard belief_ns.saturating_sub(ledger_ns) → ledger_ns.saturating_sub(belief_ns):

$ cargo test -p qualia-braid --test clock -j 2
---- a_ledger_row_newer_than_the_belief_commit_reports_zero stdout ----
panicked at crates\braid\tests\clock.rs:80: assertion `left == right` failed
  left: 500000000
 right: 0
---- latency_is_the_newest_belief_commit_minus_the_newest_ledger_row stdout ----
panicked at crates\braid\tests\clock.rs:53: left: 0, right: 600000000
---- the_newest_row_is_read_from_its_wrapped_ring_slot stdout ----
panicked at crates\braid\tests\clock.rs:95: left: 0, right: 9998995936
test result: FAILED. 1 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out
exitA=101

Reverted (git status --porcelain empty) and re-ran the full suite: 11/11, exit=0 — the staleness rule the doc states is genuinely guarded.

Notes (2, non-blocking)

  1. The claim-then-write freshness guard is untested here. Deleting entry.seq == newest && leaves all four clock.rs tests green (exitB=0). clock.rs only ever appends complete rows, so the "sequence claimed, slot not yet written" state is never constructed; that path is exercised only by runners/watch's FakeLedger tests. A clock test that bumps the sequence without writing the slot would pin it in this crate too.
  2. No in-tree producer appends a ledger row. git grep -n "append_ledger\|ledger_write_seq" finds only crates/shm/src/lib.rs (the definition and its init) plus tests (crates/shm/tests, runners/watch/tests). So in the live stack ledger_seq() is 0 and decision_latency_ns() returns the documented "nothing published" zero; the function is correct against its contract and this ticket does not ask for the writer, but T27's belief lag: {ms} ms will read 0 until one lands.

Verdict: approve — the diff does what step 24b says, the boundaries (empty, one-sided, ordering, wrapped ring, newest-of-each) are asserted as the caller-visible number, and the evidence reproduces at the verified head twice.

@superposition
superposition merged commit f89ee57 into main Sep 11, 2026
superposition added a commit that referenced this pull request Sep 11, 2026
Step 27: runners/watch gains the two operator surfaces the plan names, and the
ops dashboard's last references leave the tree.

- Mission panel (tab 8, reading GET /braid): the braid's session, generation,
  open missions, promotion and quarantine stamps and schema_version, drawn from
  the agent's wire body (`qualia.braid-state.v1`); an agent that is not
  answering degrades the panel to the reason instead of blanking it. The poll is
  a blocking client on a worker thread, the shape the ops dashboard used
  (`docs/frontend-lessons.md`, source 2).
- Braid line in the chrome: `braid gen {n} · belief lag: {ms} ms`, the value
  from Step 24b's `qualia_braid::BeliefClock::decision_latency_ns()`; the
  generation prefix is source 2's "the chrome names which stack it is watching".
- `QUALIA_OPS_URL` is gone (from `docs/frontend-lessons.md`, the only file that
  still carried it), so `grep -rn QUALIA_OPS_URL` returns nothing. `runners/ops`,
  its workspace member and the `runners/README.md` row were never carried in
  this repository and are still absent; its stack survives only as the fallback
  Step 26 named.

Files beyond the ticket's `runners/watch/src/main.rs`, all forced:
`src/braid.rs` and `tests/braid.rs` (this crate's own doc says the library holds
what is testable without a TTY, and the panel is what the ticket asks to see),
`src/view.rs` (the four-edit panel convention documented in that file),
`Cargo.toml`/`Cargo.lock` (the reqwest and qualia-braid dependencies) and
`docs/frontend-lessons.md` (the ticket's own grep test).

Blocked on #150 (T19) then #188 (T24b): this branch calls
`qualia_braid::BeliefClock`, which lands with those two PRs, so it does not
compile against main alone.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

T24b Sensing runners stay; time becomes a belief input

1 participant