Repository navigation
T24b: keep the sensing runners; time becomes a belief input (#40) - #188
Conversation
923606e to
f0defdd
Compare
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.
f0defdd to
aa832c2
Compare
Which lines of
Everything else in that file is T19's, byte for byte: the module docs, The head is |
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 (a) T19's surface is byte-identical; the lib.rs diff is additive only
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 (b)
|
Clean-room read of
|
| 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.rsrun of 3 (lines 172–174) —now_ns, pre-existing on the rebase base (2fde432, and on
97a50f3); it is the standardSystemTime::now() / .duration_since(UNIX_EPOCH)idiom. T24b adds zero
lines to it. Not this ticket's code.- T24b block, maximum 1 —
.max()isIterator::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 thequalia_shm::LayerWriterAPI; the two other
isolated shared lines are_pad: 0,andtimestamp_ns,,LedgerEntryfield initialisers. Every one is
a name the consumed crate's public contract forces.Cargo.tomlrun of 4 — dependency manifest keys shared withrunners/arena-recorder/Cargo.toml.
The ticket adds exactlyqualia-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 insidecrates/shm/src/lib.rsitself — thepub 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
- Head moved during review. The task and the PR body name
f0defdd; the live head isaa832c2
(base97a50f3).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. - The gate's byte-identity arm is vacuous on this host.
C:/qualiastores 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. - No shared-run finding touches this ticket. The longest whole-file run in
lib.rs(3 lines) is
T19'snow_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/-0lib.rs, +99/-0clock.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.
Reviewed head Reproduced build and tests11 tests, 0 failed — T19's 6 in Semantics against #40 and the ABI it reads
T19's surface and the sensing runners
Falsification (mutate the staleness rule; the tests catch it)Inverted the ordering/staleness guard Reverted ( Notes (2, non-blocking)
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. |
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.
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(onto2fde432, T19's #150 merge) →aa832c2(onto97a50f3, the current main tip). The first round conflicted incrates/braid/src/lib.rs, the one Main flagged: both branches had added to that file from the sameone-line stub.
The resolution keeps T19's file verbatim — module docs,
BRAID_EVENT_SCHEMA,BraidState,BraidEvent(Unknownarm included),BraidError,observeandnow_nsare untouched, byte forbyte — and re-appends this ticket's addition: the
use qualia_shm::{…}line beside T19's otherimports, then the belief-clock block at the end of the file. The second round was mechanical and
touched only the base.
Every line this ticket contributes to
crates/braid/src/lib.rsis an addition; nothing T19 wrote isdeleted, 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'suse std::time::{SystemTime, UNIX_EPOCH};) and the block from the// ── The belief clock ──bannerto end of file (
BeliefClock,newest_belief_ns,newest_ledger_ns).crates/braid/Cargo.tomland
Cargo.lockauto-merged: T19's dependency comment plus this ticket'squalia-shmline.What changed
Step 24b is two halves. The sensing runners keep their present shape —
runners/lidar,camera,vision,floor,vslam,pose,mapandhealthare untouched by this diff;poseandmapwere already paced by the belief commit in T21 (#164). The second half is time as a belief input:
qualia-jepa-modelalready stamps every belief tick fromRuntimeInput::delta_seconds, so thisticket surfaces that timing instead of adding a clock.
crates/braid/src/lib.rsgains 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 newestBeliefSlot::timestamp_nsacross the eightlayer slots (each layer's front buffer, read through
qualia_shm::LayerReader) minus the newestfinished
LedgerEntry::timestamp_nsin the ledger ring. It is0when either side has nothing tocompare (no layer has committed a belief, and/or the ledger holds no finished row), and
0ratherthan a wrapped subtraction when a ledger row reads newer than the newest belief commit. The newest
row is read at sequence
ledger_seq() - 1and only counts when the slot's storedseqis thatsequence — a slot whose
seqis not the one being read is a row the writer claimed but has notfinished, which is the rule
runners/watch'sdrain_ledgeralready uses.BraidStateis deliberately not the receiver: the braid's state is serialised to JSON atGET /braid(T20) and holds no mapping, so the clock is a separate view type.Step 27's TUI consumes it from
runners/watchasqualia_braid::BeliefClock::new(&shm).decision_latency_ns(), renderingbelief 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.rsholds no Kalman or particle filter — its module docs say so and theestimator 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 runnerfills 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 newestrow is read back from slot zero.
Evidence at
aa832c2Host,
-j 2, run twice, rc taken from the run itself (not a pipe):Second run at the same head:
exit=0, the same five result lines.Board (Pinkie, the Waveshare-carried Orin NX at
jetson@192.168.55.1), native aarch64 from agit archiveofaa832c2at~/t24b-bundle, one build, no GPU:qualia-braidis a library, so its test binaries are the artifact: this head builds and runs greennatively 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.lockmoved aside, resolved--offline). Two workspace members cannot be resolvedfrom that vendor —
crates/jepa-registrypulls turso/tokio/qualia-jepa-model, a tree two orderslarger than braid's closure — so
board-trim.py(shipped beside the tree) narrows the board copy'smemberstocrates/{braid,mcap-log,shm,types}and drops braid'squalia-jepa-registryedge,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 compiledcrates/braidisthis 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
crates/braid/src/lib.rsas the file; the diff also addscrates/braid/tests/clock.rs(the ticket's command iscargo test -p qualia-braid), onedependency line in
crates/braid/Cargo.toml(qualia-shm = { workspace = true }— theBeliefSlotandLedgerEntrystamps live in the mapped arena, which is the only handle thatreaches them) and its
Cargo.lockedge.so D-008/D-009 have no surface to keep byte-identical here. The
belief lag: {ms} msline isstep 27's, in
runners/watch.Closes #40