Skip to content

fix(network): send a stage note only while it's still true, so a late result costs three hub calls instead of five - #4206

Open
mvschwarz wants to merge 3 commits into
mainfrom
dev60review/network-results-before-findings
Open

mvschwarz wants to merge 3 commits into
mainfrom
dev60review/network-results-before-findings

Conversation

@mvschwarz

@mvschwarz mvschwarz commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

What a person sees

rig network is experimental and unsupported. When a connected seat held a backlog, work it had finished could read "in
progress" on the hub for many minutes.

Why: a result reported late cost up to five hub calls:

  • a "Queued for the connected local seat. Not picked up yet." note;
  • a "Picked up by the local seat at …" note;
  • then the read, close and read that settle the result.

Under a backlog, the two notes reached the hub minutes late, together with the result, and the first was no longer true.

Now: a stage note goes out only while it's still true.

  • An item the seat picked up before its queued note went out gets the pickup note alone.
  • One that finished before its notes went out gets only its result: three hub calls instead of five.
  • A stage passed this way counts as reported, so its note never goes out later.

The pass's order stays as it was:

  • A hub's stall findings are answered as they're taken, within intake's half of the deadline.
  • Results are reported until three quarters of it.
  • Then the answers to the seat's own requests are read.

Each stage keeps its window in every pass. An earlier revision of this PR answered findings after results. That only
moved the pass's time from one stage to another, so it's out.

No wire change: the same hub tools with the same arguments, minus the stale notes. A member running an earlier
version behaves as before.

Evidence

  • A recorded run, with an older hub and a newer member: drain passes that answered 150 to 187 findings settled 46 to
    63 results. The drain with no findings settled 197.

  • A model of one drain pass, at a tenth of that scale: every hub call waits 5 ms, a pass has 6 s, and it uses the
    connector's own tests' hub. Two runs of each:

    Results settled, no findings Results settled, 150 findings Findings answered
    before 112, 121 54, 51 130, 118
    this change 184, 136 79, 79 125, 118
    • With findings, about 50% more results settle, and findings answered don't change.
    • The noise between identical runs on a shared test box is large: 136 to 184 for the same code.
    • It's a model, not a run between two machines.

Tests

  • packages/daemon/test/network-connector.test.ts, two new cases, both failing on main:

    • an item that finished before its stage notes went out gets its result alone, and nothing more later;
    • an item picked up before its queued note went out gets the pickup note, never "Not picked up yet".
  • One existing case updated: after a reconnect, an item that finished before it gets its result without a late
    pickup note (pickupsSent 1, was 2). It fails on main.

  • The recorded-hub contract (packages/cli/test/fixtures/network-hub/inbound-loop.json): pass 2 is an item the seat
    picked up and closed before the pass. It drops the one pickup-note exchange this no longer sends, and its description
    says why. On main, the connector sends that note and the contract fails, since no recorded exchange matches it.

  • Ran locally, with Node 22:

    Suite Result
    Daemon network-* and queue-stuck-sweep* files 24 files, 752/752
    CLI network-connector-hub, network-connector-contract, network-command, mcp-http-grant-service-network 52/52
    Daemon and CLI tsc --noEmit exit 0
    Docs guard exit 0

Not run here

  • A run between two machines. The model above isn't one.
  • How many findings an older hub files once results settle sooner. It should file fewer, since a settled item stops
    counting as stalled, but that isn't measured here.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Stage updates reflect an item’s current state: completed items receive a result without stale queued or pickup notes, while picked-up items receive a pickup note without a stale queued note.
  • Documentation
    • Clarified that stage notes are sent only while the corresponding stage remains current.

…'s stall findings, without stale stage notes

A stage note goes out only while it's still true: an item picked up before its queued note went out gets the pickup
note alone, and one that finished before its notes went out gets only its result, three hub calls instead of five.

A hub's stall findings are still claimed with intake, but answered after the pass's results are reported, until nine
tenths of its deadline; one left over stays claimed for a later pass. A finding the connector can't answer is still
taken as work.

The recorded-hub contract's inbound-loop pass 2 drops the pickup note it no longer sends.
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The connector now checks an item's current state before sending queued or pickup notes. It marks skipped stages as reported and sends the result for completed items without stale stage notes. Tests, a recorded exchange, and documentation reflect this behavior.

Changes: Network connector stage reporting

Layer / File(s) Summary
Report notes for current stages
packages/daemon/src/domain/network/network-connector.ts, packages/daemon/test/network-connector.test.ts, packages/cli/test/fixtures/network-hub/inbound-loop.json, packages/cli/test/network-connector-contract.test.ts, docs/reference/network-connector.md
The connector resolves the local handoff chain before stage reporting. It skips queued notes for claimed or ended items and pickup notes for ended items. Skipped stages are marked as reported, and pickupsSent increases only when a pickup note is sent. Tests, the recorded exchange, and documentation cover these outcomes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • mvschwarz/openrig#3963: Changes the same connector reporting path and sequences result reporting and findings against the pass deadline.
  • mvschwarz/openrig#2993: Introduced connector stage reporting, which this change modifies.
  • mvschwarz/openrig#3918: Added the recorded-exchange contract test that uses the fixture changed here.

Suggested reviewers: openrig-review

Merge Risk: Minimal · up to e2d2d

The connector now sends only the result for an item that finishes before its stage notes go out, which means fewer hub calls. This affects only the experimental, unsupported network connector, with no wire change. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main behavioral change: a stage note is sent only while it is still accurate, which avoids stale notes when a late result arrives. It also gives the hub-call reduction (five to thr…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the main behavioral change: a stage note is sent only while it is still accurate, which avoids stale notes when a late result arrives. It also gives the hub-call reduction (five to three) for the late-result case. The changeset matches this: network-connector.ts now checks the item's current state before sending queued or pickup notes, the tests cover finished and picked-up items, and the hub fixture drops the stale pickup exchange. The title is specific and on topic, though it is long (114 characters, 21 words) and slightly exceeds a concise title.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 312ad1cf-2e25-4e8b-8519-39dec6a205fe
Commits

Reviewing files that changed from the base of the PR and between c86db5f and e2d2dec.

Files selected for processing: 3

  • docs/reference/network-connector.md
  • packages/daemon/src/domain/network/network-connector.ts
  • packages/daemon/test/network-connector.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review.

…nswer findings before the seat's request reads

A finding claimed at intake now gets a receipt that keeps it owed (outcome
"finding"), so a pass that stops before answering it no longer loses it. The
hub lists held items newest first, 200 at most, and a claimed item has left
pending, so before this an older finding behind 200 newer held items was never
listed again. Answering the finding removes its receipt; taking it as work turns
the receipt into that work's own, so there is still one local item.

Findings are answered after results and before the requests the seat sent are
read, until nine tenths of the pass. Slow request reads can no longer use up
their turn every pass; the requests keep the rest of the pass and still rotate.
@mvschwarz mvschwarz moved this to In Progress in OpenRig roadmap Nov 30, 2026
…g intake again

Answering a hub's stall findings after results moved the pass's limited time
from one stage to another without adding any: results gained what findings
lost, and the seat's own requests lost their window. Findings are answered as
they're taken again, as before, so every stage keeps its window in each pass:
intake up to half the deadline, results until three quarters, then the
answers to the seat's requests.

A stage note still goes out only while it's true: a result that finished
before its notes went out costs three hub calls instead of five.
@mvschwarz mvschwarz changed the title fix(network): a connected seat's results reach its hub before the hub's stall findings, without stale stage notes fix(network): send a stage note only while it's still true, so a late result costs three hub calls instead of five Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant