Skip to content

test(host): read the remote bridge's one-shot packets from the broker record - #1606

Merged
huichen merged 1 commit into
mainfrom
pr/huichen
Nov 14, 2026
Merged

huichen merged 1 commit into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

What and why

Rust macOS test / host-remote failed on CI run 43526331079 in
remote::tests::runtime_tests::start_runs_the_full_bridge_and_stop_winds_it_down
with timed out waiting for a publish on … state.workspaces. The test waited for
the two catalog snapshots on FakeNats::tap, a 256-slot broadcast ring over a
10 ms presence heartbeat, while the catalog publisher is change-driven:
state.sessions and state.workspaces are published on the tick that detects a
change and never re-sent. Two documented ways that loses the packet:

  • a reader the 1955-test binary did not schedule for ~2.5 s overruns the ring
    (measured 3/3 locally by stalling the observer for 3 s, reproducing the same
    panic at test_support.rs:1617 that CI reported);
  • await_publish on the tap also discards what it drains past, so a
    state.workspaces published in a tick whose sessions read failed is swallowed
    by the wait for state.sessions.

This commit takes those one-shot packets from FakeNats' own record instead —
scanned from the start, accepting either arrival order, ending on the record or
on the bridge going away — which is the fixture's documented rule for
change-driven producers. The mirrored event and the offline notice stop()
publishes follow the same rule; the presence heartbeat repeats, so it stays on a
fresh tap (the assertion is that a heartbeat now carries the catalog revision,
not that some heartbeat in the past did). The same one-shot wait in
verify_e2e's baseline measurement carried the ring exposure without the stall
and moves to the record too.

Commits

  • test(host): read the remote bridge's one-shot packets from the broker record

Verification

Local worktree at 7eb9dba69 with the pinned toolchain (rustc 1.99.1), ulimit -n 8192:

  • cargo fmt --all -- --check → clean
  • cargo check -p future-host --all-targets → clean (25 s)
  • cargo clippy -p future-host --all-targets -- -D warnings → clean (24 s)
  • cargo test -p future-host --lib remote:: → 328 passed, 0 failed, 8 ignored (127 s)
  • cargo test -p future-host --lib → 2249 passed, 0 failed, 15 ignored (438 s)

User-visible changes

none — test infrastructure only (two host test files).

… record

`start_runs_the_full_bridge_and_stop_winds_it_down` waited for the two catalog
snapshots on `FakeNats::tap`, a 256-slot broadcast ring over a 10 ms presence
heartbeat, and the catalog publisher is change-driven: `state.sessions` and
`state.workspaces` are published on the tick that detects a change and never
re-sent. Two ways that loses the packet, either of which fails the test on CI
(run 43526331079, `Rust macOS test / host-remote`):

- a reader the 1955-test binary did not schedule for ~2.5 s overruns the ring,
  measured 3/3 locally by stalling the observer for 3 s and failing with the
  same panic at `test_support.rs:1617` that CI reported;
- `await_publish` on the tap also *discards* what it drains past, so a
  `state.workspaces` published in a tick whose sessions read failed is swallowed
  by the wait for `state.sessions`. The publisher skips only the catalog whose
  store read failed (`publisher.rs`, `catalog_loop`), so the arrival order is
  not fixed.

Take them from `FakeNats`' own record instead — scanned from the start, either
arrival order, ending on the record or on the bridge going away — which is the
fixture's documented rule for change-driven producers. Same for the mirrored
event and for the offline notice `stop()` publishes; that one cannot end on "the
bridge is gone", because `stop_runtime` announces offline *after* dropping the
state, and by then a kept tap also holds heartbeats the replay window refuses.
The presence heartbeat repeats, so it stays on a tap, but a fresh one: the
assertion is that a heartbeat now carries the catalog revision, not that some
heartbeat in the past did.

The same one-shot wait in `verify_e2e`'s baseline measurement carried the ring
exposure without the stall, so it moves to the record too.

Verified: 6 isolated runs green; 3 x `remote::` (328 tests, 8 threads) green;
3/3 green with the 3 s observer stall that failed 3/3 before; full
`cargo test -p future-host --lib` 2249 passed / 0 failed; `cargo fmt -p
future-host -- --check` and `cargo clippy -p future-host --all-targets -- -D
warnings` clean.
@huichen
huichen enabled auto-merge (squash) November 14, 2026 00:27
@huichen
huichen merged commit f4383ce into main Nov 14, 2026
40 of 42 checks passed
@huichen
huichen deleted the pr/huichen branch November 14, 2026 00:56
huichen added a commit that referenced this pull request Nov 15, 2026
`catalogue_window_lane_sends_the_newest_rows_and_names_the_rest` failed on
Windows (run 43502377622) at

    assertion `left == right` failed: a deleted conversation is named, not
    left to be inferred
      left: Array []
     right: Array [String("sesswindowborn-7856-764")]

The wait had been satisfied — by the wrong packet. It was
`await_publish(&mut tap, &subject, ..)`, which answers with *the next packet on
the subject*: the lane publishes one packet per change, so a second packet on
`p.{pair}.state.sessions` describing the state *before* the deletion (the same
change detected twice, a restarted loop's resync, a second publisher
generation) is taken as the answer, and `removed` reads `[]`. The tap is also a
256-slot ring over a 100/s heartbeat, so the same wait loses a change-driven
packet outright when the reader is descheduled — the reason the bridge test
already reads the broker record instead (#1606).

Both waits now do that: `FakeNats::await_publish` reads the record (nothing is
dropped, and a packet published before the wait began is still found) and is
keyed by `accepts` — the packet that *says* what the caller awaits — not by the
next arrival. The window and delta lane tests ask for `full: true`, for the
packet naming the row that was born, and for the one naming the removal.

The window test also publishes the shift packet once more before deleting: that
one repeated packet is the flake's timing, made deterministic. With the old
wait it is taken and the test fails with the output above, byte for byte; with
the condition-keyed wait it is skipped and the test is green. A wait that times
out now names the newest packet on the subject instead of only the budget.

host: cargo test -p future-host --lib remote → 715 passed, 0 failed
      (the window test 5x, the delta lane 1x, the four await_publish tests)
huichen added a commit that referenced this pull request Nov 15, 2026
…ogue-lane wait; bump skills (#1625)

* feat(cli): pin and unpin conversations and workspaces from the terminal

The desktop app's pinned section had no CLI: `future session list` is a gRPC
call to the Agent, which has no notion of a pin, and nothing read the flag the
app stores on `threads.pinned` / `workspaces.pinned`. So a user could see the
section in the app and had no way to inspect or change it from a terminal.

Adds both scopes, both directions, and both listings:

  future session pin|unpin <session-id>
  future session pinned [--json|--format toon]
  future workspace pin|unpin <path|id|name>
  future workspace list --pinned [--json]

The writes go through `store::pin_thread` / `store::pin_workspace` — the same
calls the app and the remote bridge use — so the catalogue-dirty signal that
tells the app and a paired phone to re-read is not bypassed, and `pinned` stays
an ordering flag rather than becoming an activity event: neither `updated_at`
nor `last_opened_at` is rewritten, which a test asserts at both scopes. The
readings use the store's own queries (`list_pinned_threads` with the app's
`Recent` scope, `list_pinned_workspaces`), so the terminal, the sidebar and the
phone cannot disagree about what is pinned or in which order.

Two consequences of the app's existing rules are reported rather than left to be
discovered: archiving clears the pin (a pinned row on the shelf would hide
behind it), so `unpin` is not the inverse of `archive`; and a pin on an archived
row, or on a row inside an archived workspace, is stored while the section keeps
it out of sight — the note names whichever restore command applies, read from
the row and its workspace. Both are easy to get wrong: the first draft printed
that note on a successful *unpin* of a live row, and inferred the cause instead
of reading it, which only showed up against the real store.

Reads never create the app database (`open_existing` first), so a machine that
never ran the app gets `count: 0` and an empty-state line, or `[]` under
`--json` — not an error, and not a new file. A store `workspace add` created
without a `threads` table lists nothing rather than failing on the missing
table.

The archive module's shared helpers (`parse_target`, `desktop_store`,
`resolve_workspace`, `with_flag`, `pretty`) are now `pub(super)` and its test
harness moved to `test_store`, rather than duplicating either in the new module.

* test(host): name the packet a catalogue-lane wait is waiting for

`catalogue_window_lane_sends_the_newest_rows_and_names_the_rest` failed on
Windows (run 43502377622) at

    assertion `left == right` failed: a deleted conversation is named, not
    left to be inferred
      left: Array []
     right: Array [String("sesswindowborn-7856-764")]

The wait had been satisfied — by the wrong packet. It was
`await_publish(&mut tap, &subject, ..)`, which answers with *the next packet on
the subject*: the lane publishes one packet per change, so a second packet on
`p.{pair}.state.sessions` describing the state *before* the deletion (the same
change detected twice, a restarted loop's resync, a second publisher
generation) is taken as the answer, and `removed` reads `[]`. The tap is also a
256-slot ring over a 100/s heartbeat, so the same wait loses a change-driven
packet outright when the reader is descheduled — the reason the bridge test
already reads the broker record instead (#1606).

Both waits now do that: `FakeNats::await_publish` reads the record (nothing is
dropped, and a packet published before the wait began is still found) and is
keyed by `accepts` — the packet that *says* what the caller awaits — not by the
next arrival. The window and delta lane tests ask for `full: true`, for the
packet naming the row that was born, and for the one naming the removal.

The window test also publishes the shift packet once more before deleting: that
one repeated packet is the flake's timing, made deterministic. With the old
wait it is taken and the test fails with the output above, byte for byte; with
the condition-keyed wait it is skipped and the test is green. A wait that times
out now names the newest packet on the subject instead of only the budget.

host: cargo test -p future-host --lib remote → 715 passed, 0 failed
      (the window test 5x, the delta lane 1x, the four await_publish tests)

* chore(skills): bump future-skills to document pinning (#125)
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.

1 participant