Repository navigation
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
… mislabelling region blobs Measured first, then fixed what the numbers justified (`precall-broker --example frame_throughput`, `precall-frame --example client_cost`): * server ingest at 1080p: 1494 captures/s encrypted (201 MB/s), 3072/s plaintext, store primitives ~1980/s combined — 60 fps needs ~4% of it, so neither the datacenter nor the store is the constraint; * per client: JPEG q80 at 1080p costs 57 ms/frame (desktop-like) and 116 ms (photographic), and the wire costs 3.7-23.8 MB/s at a 16 ms cadence (~30-190 Mbps up). So full framerate with full frames is bounded by the uplink and the encoder, not by the server — the lever is sending only what changed. This commit lands the parts of that which are correct regardless, and makes the missing pieces explicit rather than silent: * `precall-frame` (new): `LatestSlot` (one-frame handoff, drop-oldest, counted), a sampled frame fingerprint, and the cadence policy — all platform-independent so they can be tested and measured off Windows, where the client cannot even compile. Invariant tested under a producer faster than its consumer: `published = taken + dropped + resident`, `resident <= 1`. * client: the capture thread publishes into that slot instead of an **unbounded** `std::sync::mpsc` channel (at 1080p60 the display produces ~480 MB/s of BGRA, so an unbounded handoff grew without limit and the stream fell further behind every second); the cadence floor drops from 200 ms (a hard 5 captures/s ceiling) to the shared 10 ms policy; per-capture work — 57-116 ms of encode plus OCR and UI Automation — moves to the blocking pool instead of stalling the runtime; dedup uses the content fingerprint, and the misnamed `dirty_regions` field is documented for what it is (DXGI pointer-metadata size, not a change signal). * heartbeat gains `frames_dropped` (additive, serde-defaulted), computed from the slot, so the link being the bottleneck is reported instead of inferred. * broker: a multi-region frame is **not** a JPEG whatever codec its regions used — the assembler concatenates them into `[l,t,r,b,len][data]…`. It was relabelled from the codec id alone, so a dirty-rect frame would have been stored as a corrupt `.jpg`, served as `image/jpeg`, and handed to the image embedder as garbage. It is now stored as `.raw` with a warning that compositing is not implemented, and `FrameAssembler::finish` returns the region count that decided it. Tests: 24 on this branch (new: slot invariants, fingerprint stride behaviour, cadence policy, and `multi_region_frames_are_not_labelled_as_jpeg`, which sends two dirty rectangles through the real broker and asserts the object is `.raw`, the blob carries both regions, and no `.jpg` was written). The client itself is Windows-only and is verified by CI on windows-latest.
3732371 to
6f0badc
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37323710c1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Both findings from the Codex review of 3732371, and both were mine. 1. The sampled fingerprint was wrong, not merely approximate. A 1920-pixel BGRA row is 7680 bytes — a multiple of 64 — so sampling one byte every 64 landed on the same blue byte of the same sub-pixel column in every row. A red- or green-only update confined to the unsampled pixels produced an identical fingerprint, and `run.rs` treated a real screen update as "unchanged" and never recorded it. `frame_fingerprint` is now an exact word-wise fold: every byte participates, measured at 1.18 ms per 1080p frame (7.4% of a 16 ms budget, 6.4x faster than byte-at-a-time). The regression test pins it at 1920-px row width with a red-only change, a green-only change, a single-pixel change, and a word swap (a commutative fold would cancel). 2. `LatestSlot` had lost the close semantics the old std channel had. When duplication could not be (re)established the capture thread returned, its `Arc` dropped, and the bridge blocked forever in `recv()` — the client reconnected, kept heartbeating, and captured nothing, forever. `close()` now wakes the consumer, `recv()` returns `None`, the bridge drops the sender so the select arm sees the channel end, and the run loop restarts the worker on its next pass. Tests: a closed slot wakes a blocked consumer instead of hanging, and publishing after close is a no-op. Tests: 62 Rust (was 60) and 14 pytest; clippy -D warnings clean.
The new exactness test wrote `frame[4 * 1000 + 0]`; clippy's identity_op is right that the `+ 0` does nothing. Caught because I committed the previous change after running the tests but before gating on clippy — both gates are now run before a commit, and the tests/clippy/pytest triple is green.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b6773e771d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ft-shaped choice) Which fork: the one Microsoft would pick. Two primary precedents decide it. RDPEGFX is already a surface protocol — `WIRE_TO_SURFACE` applies each bitmap *into* a surface the server owns, and RemoteFX progressive/AVC444 work the same way. Their remote-display architecture is "server composes", not "client replays deltas". Recall's own store is `ukg.db` plus one full-frame JPEG per capture (`ImageToken`), and this project's stated property is bidirectional migration between a Recall cache and PreCall's. Keyframe+delta storage would break every reader — snapshot route, Click-to-Do, image embedder, export — and stop a local cache from being Recall-compatible at all. So the broker keeps a per-client desktop surface, applies each dirty rectangle to it, and archives the composed desktop as an ordinary JPEG: * `precall-broker/src/canvas.rs` — the surface: region blit with negative/clipped virtual-desktop coordinates, refusal (not stretching) of a rectangle whose payload does not match it, and the one expensive step, the JPEG encode. * ingest — a keyframe is still archived verbatim and a full-frame-only client *never pays a decode*: the surface is seeded lazily from the previous capture's archived JPEG the first time a client sends rectangles. Until a surface exists, a rectangle frame is stored as an honest `.raw` blob with a warning, never as a corrupt `.jpg`. * `precall-frame` — the tested client-side policy and mechanics: `plan_capture` (deltas, keyframe when the change exceeds half the screen or the rect list exceeds its budget, and keyframe for DXGI *move* rectangles, because the wire has no surface-copy operation), and `extract_bgra_region`. * client — reads dirty and move rectangles from the DXGI metadata, plans each frame, encodes only the changed rectangles, and sends them as several WIRE_TO_SURFACE PDUs in one frame (`Connection::send_regions`). With DXGI rectangles available they are the authoritative change signal, so the 1.18 ms fingerprint is skipped on that path; unreadable metadata forces a keyframe rather than "no change". Measured (same harness, two rectangles per capture): wire 5.1 KiB vs 253 KiB per capture (50x less), client encode ~2 ms vs 58 ms, server 45.3 ms per capture for the canvas compose+encode. At Recall cadence that is 1.5% of one core per client; at a 60 fps stream it is ~2.7 cores per client, which is the hardware encoder case. The README records this and why deltas were rejected for storage. Tests: 71 (was 62) — canvas composition/clipping/refusal/round-trip, the plan policy including the move-rect and oversized-change rules, region extraction, and two end-to-end broker tests: a keyframe plus two dirty rectangles yields a *decodable JPEG* containing both patches over the keyframe's content, and rectangles with no keyframe stay an honest `.raw` blob.
The previous commit's edit to that initializer silently did nothing: I used a blind text replacement whose anchor spelled `self.ctx.Unmap(&self.staging)` while the file has `(&self.staging, 0)`, so the fields were added to the struct and read by the loop but never populated. windows-latest CI caught it (E0063). Every replacement in code I cannot compile locally now asserts that its anchor matched exactly once, and CI remains the verifier for the Windows-only crate.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad1bae3c1d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Two of these were wire-format bugs that would have made the feature inert on Windows, and one of them is pre-existing: 1. **The client's capture framing was malformed.** `send_frame` hand-rolled the GFXRDP bytes and emitted a START_FRAME whose flags/length/timestamp fields were mis-sized (the codec read `pdu_len` as 0x000C0000 and rejected the payload as truncated) and 4-byte rectangle coordinates where the PDU has four `i16`. No client frame had ever been decodable — every end-to-end test drives `precall-mock`, which uses the codec, and the Windows client only ever faced a compiler. Framing now lives in the codec (`precall_proto::encode_capture_frame`) with a round-trip test, including several rectangles and negative origins, and both `send_frame` and the new `send_frame_regions` call it. The spurious FRAME_ACKNOWLEDGE the client used to append (a server→client message) is gone. 2. **A one-rectangle delta was classified as a keyframe** (and, after the first fix attempt, every non-keyframe was routed by region count, so a one-rect delta was stored as a `.raw` blob). A small edit is commonly one rectangle: the broker archived the patch as the capture and replaced the surface with a patch-sized image, corrupting every later composition. The test is now geometric — one rectangle starting at or before the origin and reaching the advertised display size — and every non-keyframe goes through the compositor. The client now advertises its real display size (`primary_output_size`) in the hello instead of 0x0, which is what makes that test possible. 3. **Dirty rectangles were lost with discarded frames.** DXGI reports changes relative to the previous *acquired* frame, so planning a delta from only the newest frame applied just the last change to the server's surface and archived stale screenshots. The loop accumulates the dirty lists of every frame it discards and merges them (`precall_frame::merge_rects`, transitive, bounded by MAX_DIRTY_RECTS so accumulation stays a delta rather than becoming a keyframe). 4. **`close()` could lose its wakeup.** Setting the flag and notifying without the slot mutex recreated the dead-producer hang it was meant to fix. The flag is now set under the same lock the waiter holds; a 500-iteration stress test asserts the consumer never sleeps past a close. 5. **Discarded frames were not counted.** `frames_dropped` only counted slot overwrites, so the heartbeat could claim the pipeline was keeping up while the select loop threw frames away. It now counts both the slot's drops and the frames the loop discards (and drains the channel newest-only, so staleness is bounded by one tick). 6. **A test could hang the suite.** The slot's memory-bound test blocked on a frame the producer might never publish. It is now deterministic (publish, then drain with `try_recv`), with a separate non-hanging wakeup test. Also: `PendingFrame.regions` is gone (the keyframe decision is geometric), and the proto/tests cover the framing that used to be hand-rolled. Tests: 76 Rust (was 71) + 14 pytest, clippy -D warnings clean. The client half is still compile-verified only by windows-latest: no Windows runtime here.
Trimming the hand-rolled-framing imports also removed RDPGFX_CODECID_JPEG, which the hello's advertised codec list still uses — windows-latest caught it (E0425, the third such miss in Windows-only code). I tried to type-check the Windows target locally instead of paying another CI round trip: `cargo check --target x86_64-pc-windows-msvc` dies in a dependency's C build (aws-lc-sys compiled for Windows by a Linux cc), so CI remains the only compiler for this crate. The follow-up was a static scan for bare constants/types used without an import across the client files; it found this one and nothing else.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2b35ee1bc0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Four findings from the Codex review of the previous round, all in the accumulation I added last time — and all real, because DXGI reports changes relative to the previous *acquired* frame, so any frame that dies before it is planned loses those pixels for the broker's surface. 1. **The slot overwrote frames before the accumulation could see them.** `LatestSlot` holds one frame, and while the sender is encoding or the link is slow (routine at 16 ms) the producer overwrites the resident frame — its dirty list died with it. `precall_frame` gains `LatestSlot::publish_swap` (returns the displaced frame) and `ChangeSlot<T: ChangeMeta>`, which folds a displaced frame's rectangles and scroll flag into the metadata handed out with the next frame, merging overlaps so arbitrary backpressure still yields a bounded delta. `CaptureFrame` implements `ChangeMeta`, so taking the metadata empties the frame and nothing can be double-counted. An unreadable read (`None`) propagates through the union as "send the whole frame" rather than quietly sending a partial delta. Tested: a rectangle from a frame overwritten 48 publishes earlier still arrives, the scroll flag survives, unreadable metadata dominates, and a taken frame leaves nothing pending. (That last test caught a bug in this very change: draining with `take()` left `None`, which the union read as unreadable.) 2. **A scroll flag was lost when its frame was replaced.** The accumulated `moved` flag now rides along with the rectangles and forces a keyframe: the wire has no surface-copy operation, so sending dirty rectangles over a scroll leaves the moved area stale. 3. **The accumulated delta grew without bound while capture was paused or an excluded window stayed foreground.** Those paths consumed a frame and `continue`d, so nothing was ever cleared. They now keep the rectangles (the pixels were never sent, so the surface still needs them) and *bound* them: merge, and past `MAX_DIRTY_RECTS` the next frame is a keyframe. Memory stays bounded and correctness is kept — and no excluded content can leak, because every rectangle is repainted from the pixels of the next *permitted* frame. 4. **The heartbeat's drop baseline reset on every reconnect**, so each reconnect re-added every historical slot overwrite (100 before + 10 after reported as 210, growing with each reconnect). The cursor now lives outside the connection loop, next to the counters, because the slot it watches does. Also fixed a duplicated comment left in the tick arm. Tests: 80 Rust (was 76) + 14 pytest, clippy -D warnings clean.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b75734b447
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…sure Three findings from the review of b75734b. Two of them are holes in the "delayed, never lost" argument I wrote in that commit — the metadata *could* be stranded, so the claim was wrong, not just the code. 1. **The displaced metadata was paired with the replacement non-atomically.** `publish_swap` exposed the replacement before the displaced frame's rectangles were recorded under a separate lock, so a consumer could take (and drain) it in between. If that overwrite was the desktop's final change, no later frame existed to carry the rectangles and the broker's surface stayed stale indefinitely. `LatestSlot::publish_swap` is replaced by `publish_with(frame, on_displaced)`, which runs the callback **while the slot lock is held**, so no taker can observe the replacement before the displaced frame has been dealt with. Lock order is slot → accumulator everywhere (consumers drain the accumulator only after releasing the slot), and the comment on `publish_with` says what a callback may lock. 2. **The accumulator grew for the whole outage.** While the bridge is blocked by a slow link or a server outage the producer keeps overwriting, and every overwrite appended. Recording now merges on publication and collapses to the keyframe state past `MAX_DIRTY_RECTS`, so an arbitrarily long outage yields a bounded delta or a keyframe. 3. **The heartbeat's drop baseline must reset with the slot.** A restarted capture worker installs a fresh slot whose `dropped()` starts at zero; keeping the old baseline subtracted an unrelated count and hid the new worker's early drops. Tests (20 in `precall-frame`, up from 17): a displaced frame's rectangles come out with the *very next* take and leave nothing behind; the guarantee holds under 200 iterations of producer/consumer contention (the first frame's change is never stranded); and 20,000 overwrites while the consumer is blocked stay inside the per-capture budget. 83 Rust tests + 14 pytest, clippy clean.
709ebe1 to
f286b21
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f286b21946
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5004e3b3ac
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Two more findings, both valid.
1. **`recv()` released the slot lock before draining the accumulator.** A
producer could publish B and overwrite it with C after a consumer took A but
before the drain ran: B's rectangles were then attached to A and removed from
C, so they would be painted from A's older pixels and never corrected. The
two-lock pair was the wrong shape. `ChangeSlot` now owns its state — frame,
accumulated rectangles, scroll flag, closed flag — under a **single** mutex,
so a take returns the frame and exactly the changes that belong to it. This
subsumes the previous round's `publish_with`/`publish_swap`: there is no
second lock to interleave with, and `LatestSlot` goes back to its simple
one-frame form.
2. **`last_hash` went stale after metadata-backed sends.** It was only updated on
the metadata-less path, so a later metadata failure could compare against a
value describing a frame the broker no longer displays and skip a real change.
It is now `Option<u64>`: recorded only for a frame that was **actually sent**
through the fallback path, and set to `None` ("unknown") after any
metadata-backed send, because no fingerprint was computed for that frame. An
unknown value never deduplicates, so the only cost is a redundant send, never
a missed change; a dropped preparation no longer leaves a hash for a frame the
broker never received.
Tests (20 in `precall-frame`): 20,000 overwrites with distinct rectangles while
the consumer is blocked stay inside the per-capture budget; a displaced frame's
change rides with the very next take and leaves nothing behind; and 200
iterations of producer/consumer contention never strand the first frame's change.
83 Rust + 14 pytest, clippy clean.
5004e3b to
4a5ca5a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4a5ca5a9f2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Three findings from the review of 4a5ca5a, two of them mine from the previous round. 1. **Composition blocked a Tokio worker.** A dirty-rectangle capture decodes every patch and encodes the whole desktop — the measured 45 ms at 1080p — on the session's own runtime worker, so enough dirty-rect clients would starve socket reads and heartbeats for healthy sessions. Composition now runs on the blocking pool, and the liveness test that pinned it (`worker_threads = 1`, probe measuring the largest gap between 5 ms runtime ticks while a delta is composed) showed the first attempt was still blocking for **270 ms**: the *seeding decode* of the previous capture — which I had left on the worker believing it was cheap — was the dominant blocker, not the encode. All image work now leaves the worker: seeding decodes the base inside the blocking task (the object read stays on the task, it is I/O), keyframe surface refresh decodes there too, and the encode was already there. The test passes with gaps under the 35 ms bound. `handle_meta` takes `&mut ClientStore` rather than `&ClientStore`: the store holds a rusqlite connection (`!Sync`), so a *shared* borrow held across an await would make the session future `!Send` — `&mut T` is `Send` when `T` is. 2. **`primary_output_size` hard-coded adapter 0.** On a machine whose primary adapter drives no display, capture finds a later adapter while the size query failed and the client advertised `(0, 0)` — which makes the broker classify every single-rectangle delta as a keyframe, the exact failure fixed last round. Both now use one `select_output` walk, and the hello prefers the size the capture thread actually selected. 3. **A display mode change left the broker's geometry stale.** DXGI access loss re-creates the duplicator; the broker's surface still had the handshake's dimensions, so after a resolution change a full frame no longer looked like one (or an old one did). The capture thread now publishes a generation counter and its current size: a new generation forces a keyframe (the old surface is not a valid delta base), and a changed size re-handshakes so the broker builds a surface of the right shape. Tests: 84 Rust + 14 pytest, clippy clean. Client-side changes are compile-verified by windows-latest only, as always.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7338eeb017
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
windows-latest failed 'a_single_rectangle_delta_composes_onto_the_surface' (timeline 1, expected 2): a fixed 300 ms sleep after sending a delta, which is now composed on the blocking pool, is not enough on a slower runner. The flake was mine, not the broker's. All four composition tests now poll for the captures they expect (bounded at 30 s) before closing the session, so the assertion is about the broker's behaviour rather than the machine's speed.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b6d87de686
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
windows-latest clippy (-D warnings) rejected two dead initialisers I added: last_generation and advertised were initialised before the connection loop and unconditionally overwritten before any read. They now live in the connection scope, declared at their first assignment — which also makes 'advertised' immutable, since it is only read after that. My Linux clippy cannot see this crate, so I re-checked the two lint classes (unused assignment after a dead initialiser, and unused mut) over the client source by hand: 14 mut bindings, all reassigned.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 696592b46f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Eight findings from the review of 696592b, all valid. Broker (tested here): 1. **A partially applied canvas.** `apply_region` mutated the shared surface as it went, so a delta whose *later* region was undecodable or the wrong size left the earlier regions applied — and that half-applied surface became the base for every later archive frame. `Canvas` now splits `decode_region` (validating) from `blit` (infallible), and composition validates every region before touching the surface. New test `a_failed_delta_leaves_the_surface_untouched` sends a valid red rectangle plus a mismatched one, then a valid blue one far away: the failed frame is a blob and the blue frame shows no trace of the red. **That test then caught a follow-on bug of mine**: seeding looked only at the newest capture, so once a capture was stored as a blob, no later delta could ever seed a surface again — permanently degraded to blobs. Seeding now walks back (bounded, 64 captures) to the newest archived *image*. 2. **Signed rectangle bounds in keyframe detection.** `rect.right as u32 >= dw` wraps a negative coordinate to a huge value, so a rectangle entirely left of the desktop satisfied the "reaches the display" test and its patch would be archived as the capture. The comparison is signed now, and the display's advertised origin is honoured (`Display::Surface { width, height, origin_x, origin_y }`), which matters for a display left of the origin. Test `a_negative_rectangle_is_not_a_keyframe`. 3. **One canvas for several surfaces.** The assembler carried a frame's region count but not which surface each region came from, so a multi-surface client's frame would be composed onto the wrong canvas. The surface id is preserved and a frame from a surface other than the one the hello advertises (`surface_id` from the client's own `DisplayInfo`, not a constant) is stored as a region blob with a warning. Multi-surface support itself is not implemented — refusing is the honest behaviour meanwhile. 4. **The liveness test measured wall-clock time**, which a loaded runner can exceed even with correct code. Placement is now asserted directly: the broker records the thread that ran each composition (`COMPOSE_THREADS`, `#[doc(hidden)]`), and the test asserts none of them is the runtime worker it runs on. Client (compile-verified by CI): 5. **A delta was sent even when a region failed to encode**, and the send path clears the accumulated set — so the omitted pixels were never applied. A delta is now sent only if every planned rectangle encoded; otherwise the whole frame. 6. **A forced reconnect keyframe could be deduplicated away.** `last_hash` outlives the connection while the broker's new session has no surface, so an unchanged frame after a reconnect could `continue` and leave the new session with no capture at all. The hash is reset per connection and the dedup is skipped while a keyframe is forced. 7. **Frames queued before a reconnect** (possibly at the old size) could be sent as the new session's forced keyframe; the channel is drained before each handshake. 8. **The live dirty accumulator was never collapsed**, so a busy desktop at a long cadence could grow it far past the per-capture budget and re-merge a growing vector every tick. It now uses the same over-budget transition to "unknown" (keyframe) as the drop paths. Tests: 86 Rust + 14 pytest, clippy -D warnings clean.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e01b707620
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
windows-latest clippy (-D warnings) again rejected a dead initialiser: last_hash was declared before the reconnect loop with 'None' and then unconditionally reset to 'None' at the start of every connection, so the outer value was never read. It now lives in the connection scope, which is also the correct lifetime — a fingerprint describing the previous broker session must not suppress the keyframe this one needs. The generation-change reset is gone with it: it was redundant because a forced keyframe is never deduplicated and the next send sets the value.
There was a problem hiding this comment.
💡 Codex Review
PreCall/crates/precall-client/src/run.rs
Line 151 in bf05768
When a mode change occurs while the capacity-two channel is full, frame_bridge may already have removed an old-sized frame from the slot and be blocked in blocking_send; draining the receiver here frees capacity, but that sender can enqueue its held frame immediately after try_recv() reports empty. Fresh evidence beyond the prior stale-queue finding is this in-flight frame outside frame_chan, so the new session can still transmit an old-sized forced keyframe before any frame from the recreated duplicator arrives. Drop/recreate the bridge or tag frames with the geometry generation instead of relying only on draining the receiver.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Two findings from the review of bf05768, both holes in the guard I added last round. 1. **Mixed-surface frames passed the gate.** `FrameAssembler` records `surface_id: None` when a frame's regions span several surfaces, and `is_some_and(|s| s != primary)` is false for `None` — so that frame fell through and its regions were blitted into the primary canvas. The gate now compares the `Option` (`f.surface_id == Some(store.primary_surface)`), so "another surface" and "no single surface" are both refused. The mock gained `send_regions_mixed` so the test can build one frame across two surfaces (`a_frame_from_two_surfaces_is_not_composed`). 2. **A keyframe the decoder rejected left the old surface in place.** The client's later deltas are relative to *that* frame, so composing them onto an older surface would leave every area it changed permanently stale. A failed keyframe decode now clears the canvas, and deltas are stored as blobs until a keyframe that decodes (`a_rejected_keyframe_invalidates_the_surface`). Tests: 88 Rust + 14 pytest, clippy -D warnings clean.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4218725c2c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…st surface Five findings from the review of 4218725, two of them P1 regressions I had just introduced. 1. **The placement instrumentation leaked in production.** Every composition appended a `ThreadId` to a process-global vector that only a test ever cleared — five million entries per client per day at 60 fps, plus a global mutex on every composition. Recording is now off unless a test sets `COMPOSE_RECORDING`, and bounded even then. 2. **Draining the channel before a handshake could discard the only frame.** DXGI need not publish another frame while the desktop is static, so an unconditional drain could leave a new session with nothing to send. Frames now carry the duplicator *generation* that produced them; the drain keeps the newest frame matching the current generation and drops the rest. 3. **A delta that could not be applied left the surface usable.** After a failed composition the frame is stored as a blob, but the old canvas stayed — and the next delta is relative to the frame that was lost, so composing it onto the old surface would publish a stale image. There is now an explicit `surface_invalid` state: a failed delta, a rejected keyframe, or a refused frame invalidates the surface; deltas are stored as blobs until a keyframe that decodes re-seeds it. (Recovering required one more fix: the keyframe path only decoded when a canvas already existed, so an invalidated surface could never be recovered — it now decodes whenever a surface exists *or* was invalidated.) 4. **A refused mixed-surface frame invalidates too**, since it may carry primary-surface updates that are now lost. 5. **Rectangles are output-local, so the display origin must not be applied.** Last round I made keyframe detection origin-aware after a review of the signed comparison; that was wrong for this client, which sends an output-local `(0, 0, width, height)` for a whole frame with the size from the same output. Detection is back to 0-based with *signed* comparisons (the part of that finding that was right), and the reason is written down where it lives: if a client ever sends virtual-desktop coordinates, detection and composition have to become origin-aware together. Tests: 88 Rust + 14 pytest, clippy clean. `a_failed_delta_leaves_the_surface_untouched` now covers the whole lifecycle: failure → blob → invalid → keyframe → composes again.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8603dca0a6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Three findings from the review of 8603dca. 1. **The generation snapshot predated the handshake.** If the capture thread created or re-created the duplicator while `Connection::connect` was in flight, the drain compared against the old generation and discarded the only current frame — and on a static desktop DXGI need not produce another, leaving the new session with no keyframe. The geometry is re-read *after* connecting and the current generation used for the drain. 2. **A recreation mid-session left stale frames in place.** The geometry-change branch forced a keyframe but could still send a frame from the old duplicator as it. Both paths now share `retain_current_generation`, which drops frames whose generation differs and keeps the newest matching one. 3. **A keyframe's image size was never checked against the surface.** A decodable JPEG whose rectangle claims the full surface but whose image is smaller became the canvas, so every later delta clipped into a wrong-sized surface and was archived at the wrong dimensions. Keyframes and seeded archives are now validated against the advertised display (`dimensions_match`); a mismatch invalidates the surface instead of adopting it. Test `a_wrong_sized_keyframe_does_not_become_the_surface`. Two existing tests needed fixing rather than the code: their fixtures used keyframes of a different size than the surface the mock advertises (64x64 and 1920x1080 against 1280x720), which is exactly what the new check is for. Tests: 89 Rust + 14 pytest, clippy clean.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b0729880bc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
windows-latest clippy rejected a dead store again: last_generation was declared from the pre-handshake snapshot and then unconditionally overwritten by the post-handshake re-read before any read. That is the fourth instance of this class in this PR, and the pattern is the same every time — declaring a variable before an await and authoritatively assigning it after. It is now declared at the re-read, after the handshake, where the value it holds is the one used. I scanned the file for the same shape again (initialise, await, reassign before any read): the only hit is the pre-existing retry backoff, whose initialiser is read by the retry log.
1a12180 to
3a5bfe5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a5bfe5bd9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…e worker Three findings from the review of the generation-retention commit. 1. **The receive arm accepted stale generations.** Retention at the transition is not enough: the bridge can already be blocked in `blocking_send` with a frame from the previous duplicator, which lands *after* the drain frees capacity. The arm (and its newest-only drain) now drops any frame whose generation is not the current one, so an obsolete frame cannot become the new session's keyframe and leave later deltas composed onto the old desktop. 2. **The capture worker outlived its consumer.** When `run` returned, dropping the receiver did not stop the thread: it holds the slot's `Arc`, `publish` cannot see that nobody is consuming, and the loop had no cancellation. The bridge now closes the slot when its send fails, and the capture loop exits on a closed slot — instead of acquiring and copying desktop frames, plus DXGI resources and a full BGRA frame, for the rest of the process. 3. **The throughput harness could stop its timer one frame early.** Its warm-up reused `encoded[0]`, so that frame's row *was* the warm-up row and "wait for `frames` rows" only worked by coincidence — a reader could reasonably have "fixed" it into a wrong wait. The warm-up now has its own token, and it is waited for *before* the timer starts, so the expected row count is exactly `1 + frames`. (My first attempt at this measured the baseline after the timer and hung for the full 120 s timeout; caught by running the harness.) Tests: 90 Rust + 14 pytest, clippy clean.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…y frames Two findings from the review of a4a2de3 — and the first was worse than a benchmark inaccuracy. 1. **The dirty-rect benchmark had stopped measuring composition.** The mock advertised 1280x720 while the benchmark sent 1920x1080 keyframes with a hardcoded 1280x720 rectangle, so after keyframe size validation landed the broker rejected every seed, invalidated the surface, and stored every measured delta as a blob. It reported **1739 captures/s (0.6 ms/capture)** for work it was not doing. The mock now advertises the geometry the session asks for (`connect_sized`) and sends full frames at the size it advertised, so the default 1920x1080 run measures the real thing: **20 captures/s, 50 ms per capture** — the same order as the 45.3 ms recorded before validation existed, which is why the regression went unnoticed. README numbers updated to the re-measured 50 ms (1.7% of a core at Recall cadence, ~3 cores per client at 60 fps). 2. **A frame with no regions panicked the session.** `surfaces[0]` indexed an empty vector, so a syntactically valid START/END frame without a `WIRE_TO_SURFACE` killed an authenticated connection. It uses `first()` now, and an empty frame is stored as an (empty) blob to preserve the frame↔metadata pairing *without* invalidating a surface it says nothing about — test `an_empty_frame_neither_panics_nor_invalidates` covers both halves. Tests: 91 Rust + 14 pytest, clippy clean.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Why
The requirement is that the capture path works at full framerate and at Recall's collection cadence. Rather than assume, both ends were measured first:
put+insert_captureConclusion: the server is not the constraint (60 fps needs ~4% of it) — the constraint is per client and it is the uplink, then the encoder:
That is why Recall collects a capture every few seconds instead of streaming, and why the lever is sending only what changed (dirty rectangles), not a faster server.
What this PR does
precall-framecrate — the frame-flow decisions live outside the Windows-only client so they can be tested and measured here:LatestSlot(one-frame handoff, drop-oldest, counted), a sampled fingerprint, and one cadence policy. Invariant tested under a producer faster than its consumer:published = taken + dropped + resident,resident <= 1.std::sync::mpscchannel — at 1080p60 the display produces ~480 MB/s of BGRA, so a pipeline slower than the screen grew without limit and the stream fell further behind every second. It now overwrites a one-frame slot, the bridge channel is capacity 2, and frames are never queued.16= streaming,3000= Recall, floor 10 ms.dirty_regionsfield is documented as DXGI pointer-metadata size rather than a change signal; the heartbeat gainsframes_dropped(additive,#[serde(default)]) so uplink pressure is reported instead of inferred.FrameAssembler::finishconcatenates multi-region frames into[l,t,r,b,len][data]…, but the ingest labelled the object from the codec id alone — so a dirty-rect frame would have been stored as a corrupt.jpg, served asimage/jpeg, and handed to the image embedder as garbage. It is stored as.rawwith a warning (compositing is not implemented), andfinishreturns the region count that decides the label. This is the prerequisite for dirty-rect streaming rather than the feature itself.Tests
24 on this branch, including
multi_region_frames_are_not_labelled_as_jpeg(two dirty rectangles through the real broker: the object is.raw, the blob carries both regions, no.jpgis written), the slot invariants, the fingerprint's stride behaviour, and the cadence policy. The client is Windows-only and is verified by CI onwindows-latest.Not in this PR — the decision it sets up
Dirty-rect streaming is what makes full framerate affordable (wire and CPU proportional to changed area). The protocol already carries regions and the broker already assembles them; what is missing is (a) the client computing dirty rects via DXGI
GetFrameDirtyRectsand encoding each rect, and (b) the server turning a sequence of rects into a stored desktop image. (b) is a real design fork:I have not picked one: it changes a documented compat property (stored objects are Recall-shaped full-frame JPEGs) and the right answer depends on whether you want the datacenter or the readers to pay. Say which and I will implement it with the compositing tests.
Review rounds 6–14: every finding answered (45 total)
Codex reviewed each push, and the loop stayed useful to the end: 45 findings, all addressed in-thread, with a fix or a stated reason for disagreeing. The classes that mattered:
rightcast tou32had wrapped to a huge value and made a patch left of the desktop look like a full screenshot). Where a finding asked for the display origin to be applied, I pushed back with the reason, and wrote the invariant next to the type.Arc, so nothing told it the receiver was gone — the bridge now closes the slot, and the loop exits); placement instrumentation leaked a thread id per composition into a process-global vector (now off unless a test enables it, and bounded); a frame with no regions panicked an authenticated session (surfaces[0]on an empty vector).Also: keyframes whose image does not match the advertised surface are refused rather than adopted, a mixed-surface frame is stored as a blob instead of composed onto the wrong canvas, stale duplicator generations are filtered at the receive arm (not only at the transition), and dedup no longer suppresses a forced keyframe.
Tests: 91 Rust + 14 pytest, clippy
-D warningsclean, CI green onwindows-latest,aiandweb.The verification boundary is unchanged and worth repeating: the broker half is proven end-to-end here; the client half is compile-verified only — every client-side finding in these rounds was found by reading the code, not by running it, because there is no Windows runtime on this box.