Skip to content

feat(choice-cards): put the recommended option first; fix(host): budget the fixture cleanup barrier - #1642

Merged
huichen merged 5 commits into
mainfrom
pr/huichen
Nov 18, 2026
Merged

huichen merged 5 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

The model now puts the option it recommends first on every choice card, in both modes, and the host's test fixture cleanup no longer fails slow-but-passing work on a loaded Windows runner. Both changes are small and independent; they travel together because both landed on dev-huichen while this PR was in flight.

Commits

  • feat(choice-cards): put the recommended option first — row order is the only recommendation signal a card carries: the parser, the desktop card and the phone all draw options in the order the fence lists them and nothing re-sorts them, so a card whose best option sat last made the reader re-rank a question the model had already answered. The rule lives in choice.md next to the option: line's shape, so it applies whichever mode a card settles on; re-sorting rows in a client instead would silently disagree with the reply's own wording ("do this one" pointing at a row that moved). prompt_teaches_the_choice_card_fence pins it and the prompt budget moves 40 → 42 lines; docs/design/choice-cards.md and its zh-CN pair record why the rule belongs in the prompt rather than in the renderers.
  • fix(host): budget the fixture cleanup barrier by the work it waits for — cancel_test_tasks waited a flat 5 s for process-lifetime work before a fixture publishes a new HOME, but Tokio cannot stop a blocking closure that has already started, so that number is the budget for the work, not a spin timeout. shadow_review::process::COMMAND_TIMEOUT allows such a job 30 s, so healthy work could exceed the barrier by design; Rust Windows test / host-core failed two headless tests on exactly that. The budget is now derived as twice that deadline instead of a literal, the barrier itself is unchanged (a task that really hangs still fails the expect and still names where it was registered), and two tests pin both halves.

Verification

Local, on the pinned toolchain (rustc 1.99.1, ulimit -n 8192):

  • At the choice-cards tree: cargo fmt --all -- --check clean; cargo clippy -p future-agent --all-targets -- -D warnings clean; cargo test -p future-agent --lib 3110 passed, 5 failed: sandbox::tests::add_session_allow_maps_read_op, sandbox::tests::enabled_gates_writes_outside_workspace, sandbox::tests::session_allow_takes_effect, sandbox::windows_plan::tests::allow_write_rule_lands_in_writable_allow_read_does_not, sandbox::windows_plan::tests::writable_roots_are_minimized_by_ancestor. The same five fail identically on unmodified origin/main in a clean worktree and all five pass when run in isolation, so they are pre-existing and load-sensitive, not caused by this branch. make check-docs 423 docs checked, 0 pairs pending bilingualization.
  • For the host fix, at the re-frozen head 4291715d4 on the same pinned toolchain: cargo test -p future-host --lib runtime::tests 21 passed, 0 failed (includes both new tests, the_fixture_stop_budget_outlasts_the_longest_blocking_deadline and the_fixture_barrier_waits_for_blocking_work_that_still_finishes), and cargo test -p future-host --lib agent_bridge::headless::tests::run_prepared_prompt 3 passed — the two tests that failed on the Windows runner among them. This PR's own CI re-runs the full matrix on that head.

User-visible changes

Choice cards (with the choiceCards setting on) now list the recommended option first, in single and multi alike: the first row is what the reader takes as the model's pick, and in multi it is the row the others build on. Before, the model was free to put its pick anywhere and often wrote the best option last — the same waste as a prose list the reader has to re-rank. No setting, default value, permission or performance characteristic changes; clients already rendered rows in file order, so nothing needed to change in them. Revert 3b5b3371f.

The host change is test-infrastructure only (cancel_test_tasks is #[cfg(any(test, feature = "test-support"))]), so it is not user-visible. Revert 79739ea45.

Notes

dev-huichen was re-frozen onto this branch once, at 4291715d4, to bring the host fix into the PR after the Windows failure above.

Row order is a recommendation and nothing downstream re-sorts it: the renderer
draws `options` in the order the fence lists them, so row 1 is what the reader
takes as the model's pick. A card whose best option sits last makes them
re-rank a question the model already answered for them — in `multi` too, where
the first row is the one the others build on.

The rule goes in `choice.md`, next to the `option:` line's shape, so every card
carries it whichever mode it settles on. Reordering rows in a client instead
would disagree with the reply's own wording ("先做这个" pointing at a row that
moved).

The prompt budget moves 40 -> 42 because this changes what the model writes on
every card, unlike the rest of §4's prose.
@huichen
huichen enabled auto-merge (squash) November 18, 2026 03:29
`cancel_test_tasks` waited a flat 5 s for process-lifetime work before a
fixture publishes a new HOME. Tokio cannot stop a blocking closure that has
already started (`run_blocking` stays registered for exactly that reason), so
that number is not a spin timeout — it is the budget for the work the barrier
waits for, and it has to outlast the longest blocking job the Host starts on
purpose. 5 s was below that: `shadow_review::process::COMMAND_TIMEOUT` allows a
shadow-review Git command (or its lock wait) 30 s, so healthy work could exceed
the barrier by design.

`Rust Windows test / host-core` failed two headless tests on it (run
44230694304, job 134554848559). Their Run ended with an error, so
`agent_prompt` deferred `review::materialize_changeset` — two store reads that
take 40-70 ms on a developer machine, and 0.69 s in the same run's *passing*
`run_prepared_prompt_completes_a_clean_run` — and that job was still running
when the fixture dropped: cleanup timed out and panicked at `runtime.rs:190`.
Store work is genuinely variable on that runner (its `initialize_app_store`
took 20-24 s), and the repo's test lane already refuses to fail
slow-but-passing work (nextest adds no per-test deadline).

Derive the fixture budget from the shadow-review deadline (2×, 60 s) instead of
a literal, so the two cannot drift apart, and keep the barrier: a task that
really hangs still fails the `expect` in `cancel_test_tasks` and still names
where it was registered. Two tests pin that — the budget outlasts the longest
blocking deadline, and the barrier still waits out blocking work that does
finish inside it (the shape of the leak above, reproduced locally by slowing
that job past the old 5 s).
@huichen huichen changed the title feat(choice-cards): put the recommended option first feat(choice-cards): put the recommended option first; fix(host): budget the fixture cleanup barrier Nov 18, 2026
@huichen
huichen merged commit 590d555 into main Nov 18, 2026
25 checks passed
@huichen
huichen deleted the pr/huichen branch November 18, 2026 04:43
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