Skip to content

fix(cli,scripts,ci,host,goal): verify installs, fail over apt mirrors, reserve the Windows stack - #1309

Merged
huichen merged 29 commits into
mainfrom
pr/dev-huichen
Oct 22, 2026
Merged

huichen merged 29 commits into
mainfrom
pr/dev-huichen

Conversation

@huichen

@huichen huichen commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

This PR lands the work accumulated on dev-huichen since the last merge to main: installers that verify what they download, a CI apt step that fails over between mirrors instead of dying on one, a Windows stack reserve that keeps the CLI from dying with STATUS_STACK_OVERFLOW, replay-accurate goal creation times, a host tail read that no longer reports a live turn as lost history, and a set of CLI mock-platform fixtures that stopped failing for reasons unrelated to what they test.

Commits

  • 948088eaa test(desktop): say why a host status is not ready — the intermittent owned-host test now prints the whole AgentStatus, so a repeat names the transport, handshake or data-root cause instead of a bare unavailable.
  • d597984af fix(goal): replay restores created_at from the ledger, not the replay clock — GoalStarted carries the creation time back through apply, the registry entry is the fallback for legacy goals, and the replay clock is only the last resort.
  • b915cc8ac fix(cli): reserve the platform stack on Windows — the CLI inherited the linker's 1 MB main-thread reserve; cli/build.rs now passes /STACK:8388608,65536, with a test that reads SizeOfStackReserve off the built image.
  • 4ab42a613 test(cli): a mock-platform fixture that survives a connection with no request — an empty connection is skipped and a malformed one is recorded, instead of panicking the listener thread and failing unrelated login tests.
  • 1cdd6ee51 fix(scripts): verify pinned installs and fail closed without a checksum — a pinned version verifies against its own release manifest; a missing entry, checksum or hashing tool aborts instead of warning, and skipping needs an explicit FUTUREOS_SKIP_VERIFY=1.
  • 3172d1ab4 fix(cli): scope the Windows stack reserve to the binary — narrows the link argument to -bins so cargo test binaries keep the default reserve.
  • 758c61cbe test(cli): an abandoned request is not a fault in the mock platform — a request cut off mid-write moves to its own abandoned counter; only fully received, unserviceable requests count as faults.
  • 30b7e844e chore(skills): bump future-goal to the cross-model ensemble workflow.
  • f991d4bff chore(skills): bump future-goal registry metadata.
  • 466056f54 test(cli): assert the stack reserve did not reach the tests, without pinning the default.
  • 368641ed3 test(cli): record an abandoned connection once, not once per symptom.
  • 6d6703265 fix(host): read an empty tail page as a live turn, not lost history — a run that tails past the end of its journal is still live, so the reader no longer drops it from history.
  • 6006335f4 fix(ci): move the mirror list, not just the apt sources, when failing over — the failover rewrites every mirror reference the plan uses, so a fallback does not leave apt pointed at the mirror it just abandoned.
  • ec7fbd857 chore(skills): ship the future-goal dispatch rule.
  • 658a14b17 fix(ci): resolve the mirror list in the apt plan, not the pseudo-URI — the plan resolves the mirror list before it builds the apt sources, so the resolved URL is what gets written.

Verification

Local checks on the pinned toolchain (rustc 1.97.0), run on this branch before the last four commits landed:

  • cargo fmt --all -- --check — clean, plus cargo fmt --check under desktop/src-tauri.
  • cargo clippy -p future-cli --all-targets -- -D warnings and cargo clippy -p future-goal --all-targets -- -D warnings — clean.
  • cargo test -p future-goal --lib — 463 passed.
  • cargo test -p future-goal --test quota_read_model_contract — 10 passed.
  • cargo test -p future-cli --test bin — 25 passed.
  • python3 scripts/tests/test-install.py — 16 tests OK.
  • cargo test -p future-cli --lib — 1383 passed, 1 failed: mcp_client::tests::process::the_stderr_tail_keeps_the_last_lines_and_drops_the_oldest. It passes in isolation and fails identically on origin/main (54e409e) in a full-suite run, so it is a pre-existing load-sensitive fixture, not a regression from this branch; cli/src/commands/mcp_client.rs is untouched here.

The apt-mirror and skills commits added after that pass are covered by CI on the current head.

Notes

  • Pinned installs are now verified by default: a caller relying on the old fail-open behaviour must pass FUTUREOS_SKIP_VERIFY=1 explicitly.
  • The Windows stack reserve applies to CLI binaries only, not to test binaries.
  • scripts/tests/test-install.py is not wired into CI yet: updating ci.yml needs a token with the workflow scope, and the current gh token has only gist, read:org and repo. The test runs offline.
  • .github/workflows/** is untouched by this branch.

huichen and others added 13 commits October 23, 2026 00:17
`an_owned_host_counts_its_activity_and_a_stopped_host_reports_none` failed once
on a loaded Windows machine with only

    assertion `left == right` failed
      left: "unavailable"
     right: "ready"

and the child's own output could not narrow it further: `AgentStatus` carries the
transport, handshake or data-root reason in `error`, and nothing printed it. The
assertion now includes the whole status, so a repeat names the cause instead of
asking the reader to reproduce it.

Investigating that flake: it is not reproducible here. The case passed 30
sequential runs, three full library suites at `--test-threads=16`, and four and
eight concurrent runs of the whole fixture module with the CPU saturated, all on
the merged tree. The two failures both came from one build of an unmerged branch
state, so this commit adds the diagnosis rather than a fix for a cause that was
not established.
… clock

`replay()` seeds state with `Goal::new`, which stamps `created_at:
now_epoch()`, and the `GoalStarted` fold dropped the event's `ts`. Replaying
therefore re-dated creation to the moment of the read: `created_at` drifted on
every replay and only looked stable while both clock reads landed in the same
wall-clock second.

That is what failed CI on main (run 39809589270): the goal's newest ledger ts
(1792685455) was compared against `created_at`, re-stamped to 1792685456.

- `apply(GoalStarted)` restores `created_at` from the event ts - the ledger is
  the canonical source of the creation time.
- `replay()` seeds `created_at` from the registry entry first, so a legacy
  goal whose ledger has no `GoalStarted` keeps its registration time. The
  replay clock is now only the last resort, for a goal with neither source.
- Regression tests: creation backdated two seconds must survive replay
  (deterministically red before the fix), plus the registry fallback tier.
- webui: comments no longer claim replay re-stamps creation with "now".
A Windows process takes its main-thread stack size from its PE header, and the
linker default — 1 MB, measured on this crate's own `future.exe` — is an eighth
of what Linux and macOS give the same code. Growth is on demand, so a frame that
runs past the reserve is fatal and silent:
`STATUS_STACK_OVERFLOW` (0xc00000fd), no message, no exit path.

That is not hypothetical: `future session list` died exactly that way on one
build of this CLI while `models list`, `task list` and `auth status` all worked
on the same isolated Agent — the shape of a reserve that is barely big enough.
The desktop already passes `/STACK:8388608,65536` for its command dispatch
(#1153); `build.rs` now passes the same for every binary of this crate. The
reserve is address space, not memory: commit stays at 64 KB and the stack grows
into it on demand.

`cli/tests/windows_stack.rs` reads `SizeOfStackReserve` off the built binary, so
losing the link argument fails a test. Checked as a negative control: with the
argument removed the test fails and names the 1 MB default, and with it restored
the built image reports 8388608 bytes / 65536 commit.
… request

`auth_login_writes_the_key_itself_when_no_agent_is_running` and
`auth_login_saves_through_a_running_agent` failed in roughly two of every three
full-suite runs on a Windows runner, and passed when run alone. The failure read
as two unrelated things: the listener thread reported
`assertion failed: request.read_line(..).expect("request headers") > 0`, and the
test reported `Network error: error sending request for url (…/device/code)`.

They are one thing. The CLI occasionally opens a connection to the platform,
sends nothing, closes it, and then makes its real request on a new connection —
a connect it abandoned and retried, seen under load and never in isolation
(verified: 12 concurrent `auth login` runs against a Python server produced
none, while full-suite runs produced one or two). Measuring the peer pid at
accept time named `future.exe`, the test's own CLI.

The fixture asserted `> 0` on that read. The assertion runs on the listener
thread, so the empty connection panicked the thread, the listener socket was
dropped with it, and the login the test is about then failed on a refused
connection — three removes from the cause.

The fixture now answers requests instead of policing the client: a connection
that carries no request is skipped, a malformed one is recorded in the new
`faults` list (and answered with 413 when it is oversized) rather than panicking,
and a test that cares asserts the list is empty. Both auth tests do, so a
genuinely malformed request is still a failure — with a message that names it.

Verified: 15 consecutive full-suite runs, 0 failures (before: 2 of 3 failing),
and 37 more after the final formatting pass. Negative control: restoring the
fatal `panic!` on the empty connection makes the new regression test
`a_connection_that_sends_nothing_does_not_poison_the_mock_platform` fail with the
original signature, so the guard is not vacuous.
The one-line installers run straight from `curl | bash`, yet two paths installed
artifacts without verifying anything:

- a pinned FUTUREOS_VERSION constructed the asset URL and skipped the manifest,
  so `FUTUREOS_VERSION=v1.0.2` downloaded and installed with no SHA-256 at all;
- a host without shasum/sha256sum logged a warning and returned success, which
  callers read as "verified".

Both now fail closed. A pinned install reads that release's own manifest
(releases/<version>/latest.json, published beside its artifacts) and shares the
latest-path verification; a release with no manifest entry, or a manifest entry
without sha256, is refused. Skipping the check requires FUTUREOS_SKIP_VERIFY=1,
documented as the deliberate risk it is. install.ps1 gets the same
pinned-manifest lookup and opt-in; it already failed closed on the hash tool,
because Get-FileHash ships with PowerShell (it now also refuses a pinned release
with no windows-x86_64 sha256, and a host without Get-FileHash).

Tests: scripts/tests/test-install.py gains pinned, fail-closed and opt-in cases
and now runs in CI's affected job; test-install.ps1 exercises the manifest, the
refusal and the opt-in, and no longer risks running a real `future init`.
The reserve the CLI needs is for the shipped `future` binary. A bare
`rustc-link-arg` gave it to every target of the package, including every
test binary Cargo links for this crate.

`-bins` narrows it to `[[bin]]` targets. `cli/tests/windows_stack.rs`
now asserts both halves: the binary reports an 8 MB reserve and this test
binary reports the 1 MB linker default, so widening the scope again fails a
test rather than passing silently.

Measured after the change: target/debug/future.exe reserve=8388608
commit=65536, target/debug/deps/windows_stack-*.exe reserve=1048576
commit=4096.
`auth_login_saves_through_a_running_agent` flaked because the fixture
reported a connection the client abandoned as something it could not serve:
the login test then failed on its `faults` assertion, three steps away from
the login it is about. The empty-connection half was fixed first (a connect
that sends nothing); a connect that gets a few bytes of the request out
before closing still landed in `faults`, and recorded it again.

The fixture now separates the two records. `faults` is a request received
in full and unservable (an unparseable `Content-Length`, an oversized
body). `abandoned` is everything that ended before the request did: no
bytes, an unreadable request line, headers that stop early, a short body. A
partial request was never answerable, so counting it as a fault only made
the fixture blame the client it was serving.

`a_request_abandoned_half_written_does_not_poison_the_mock_platform`
covers the second half deterministically: it writes a partial request line,
and a request line plus one header, then closes, waits for the fixture to
record both, and asserts the real login after them is served with no faults.
Reverting the `headers ended early` branch makes it fail.
@huichen
huichen enabled auto-merge (squash) October 22, 2026 17:23
@huichen huichen changed the title batch(dev): installer verification, CLI stack reserve, and two test-fixture flakes (13 commits) fix(cli,scripts,goal,desktop): verify installs, reserve the Windows stack, replay exact goal times Oct 22, 2026
Points the skills submodule at future-skills 32e9173, which adds the Ensemble
goal workflow (one frozen brief, different models, blind judging, synthesis),
its references/ensemble.md templates and the contract test guarding them.
Points the skills submodule at future-skills 8c28fd9, which describes the
cross-model ensemble workflow in the future-goal registry entry so the skill
panel shows it.
…pinning the default

The new assertion compared this test binary's reserve to the 1 MB linker
default by value. That passes today and fails on an unrelated toolchain or
linker upgrade that moves the default, reporting a stack-reserve bug that
does not exist — and CI runs this test on windows-latest, so the false red
would land on an unrelated PR.

What has to hold is narrower: this binary did not receive the reserve the CLI
got. `test_reserve < binary_reserve` says exactly that. Verified in both
directions: widening `build.rs` back to a bare `rustc-link-arg` fails the
test with `this test binary reserves 8388608 bytes and the CLI reserves
8388608`, and `rustc-link-arg-bins` passes with 1048576 against 8388608.
A reset can reach the fixture as an unreadable header line *and* as headers
that stopped early, and the header loop recorded both: one connection added
two entries to `abandoned`. The count then depended on which side of the
reset the fixture happened to see, which made the new regression test's
`== 2` assertion an occasional failure of its own.

The error is now carried out of the loop and recorded once, with the detail
kept, and the test treats the count as a precondition (`>= 2`) rather than
the property under test -- what that test asserts is that the login after the
abandoned connections is served and reports no faults.

15 consecutive `cargo test -p future-cli --test bin` runs: 25 passed each.
create_run stamps the thread's activity as soon as a send starts, while the
Agent persists the user entry only once the prompt is admitted. A reload that
lands inside that window read an empty history page for a conversation that
already claimed activity, and the GUI showed "Conversation history is
unavailable: restore its matching Agent database" on top of a healthy first
reply.

Only a conversation with nothing running can really be missing its history:
exempt the in-flight case (store::has_active_run) and keep the banner for a
settled conversation whose Agent page is empty.
… over

The apt failover added for run 39802801818 never switched anything. GitHub's
Ubuntu images name no hostname in their sources: 24.04 ships
`URIs: mirror+file:/etc/apt/apt-mirrors.txt` and keeps the endpoints in that
mirror list (azure priority:1, archive.ubuntu.com priority:2,
security.ubuntu.com priority:3 - 144 bytes, which is exactly the size apt
reported fetching from the mirrorlist in the log). `switch_to_public_archive`
grepped the sources for an azure hostname, matched nothing, rewrote nothing and
returned success, so the retry again called azure.archive.ubuntu.com.

Evidence from run 39822317986, job `Rust check / desktop`:

  17:36:12  Get:2 http://azure.archive.ubuntu.com/... libjavascriptcoregtk...
  17:39:12  Package installation did not finish (status 124); switching...
  17:39:12  Hit:2 http://azure.archive.ubuntu.com/ubuntu noble InRelease
  17:39:14  Get:2 http://azure.archive.ubuntu.com/... (same packaging, 145 s)

The endpoint never moved, so the second 180 s budget went to the same
~50 kB/s transfer. The mirror itself is not inherently slow - a sibling job in
the same run (`Rust Linux test / desktop`, 17:25) fetched the same 59 MB from
azure in 19 s.

What changed:

- `switch_to_public_archive` rewrites every file that can name the endpoint:
  sources.list, sources.list.d/*.sources|*.list and the file each
  `mirror+file:`/`file:` URI defers to (the mirror list). It reports each file
  it rewrote and *fails* when nothing matched, instead of claiming a switch.
- Every attempt prints the archive host and one sample URI apt would actually
  fetch, taken from `apt-get --print-uris` rather than from the source files,
  so the log shows whether a switch moved the endpoint.
- Download and unpack are separate phases with separate budgets; the download
  budget follows the payload from `--print-uris` (90 s + 4 s/MB, 180-480 s)
  instead of a flat 180 s. A failure names the phase that ran out, the host it
  was using and the archives still outstanding.
- `--self-test` exercises the rewrite against a runner-shaped fixture tree
  (mirror-list layout, classic sources.list, arm64 ports list, and a no-op that
  must not claim success); `scripts/tests/ci-plan.test.mjs` runs it.

Refs #1309
Bump the skills submodule to future-skills 9b5e98c, which teaches future-goal
that a bare `/future-goal` is a full invocation: the token carries a request to
run the accompanying work as a supervised goal, so the session dispatches at
least one worker instead of answering inline. Previously the same task ending in
just the token produced no goal and no worker, while the same task ending in
"使用 /future-goal 技能启动多个 worker" dispatched reliably.

The installed copy under ~/.future/agent/skills was updated in place; this
pointer is what makes a fresh checkout and `future skills install` ship 5.3.0.
`apt-get --print-uris` does not resolve a `mirror+file:` source. The first CI
run of #1309's follow-up printed, in the very line meant to prove which archive
the job would use:

  APT sample URI: mirror+file:/etc/apt/apt-mirrors.txt/pool/main/b/...deb
  APT download: 2.4 MB from apt

`apt` was the third field of the mirror-list path, not a host. The same pseudo-
URI comes back before and after a switch, so that comparison would have
reported "nothing changed" for a switch that did move the endpoint.

Resolve it the way apt does: the `mirror+file:` target's lowest priority number
wins and the rest are failover, substituted back into the plan line, so host,
sample URI and byte budget all describe the archive the transfer will really
touch. The attempt line now reads, on the same plan line:

  before: APT mirror list /etc/apt/apt-mirrors.txt: 3 entries, using http://azure.archive.ubuntu.com/ubuntu/
  after:  APT mirror list /etc/apt/apt-mirrors.txt: 3 entries, using http://archive.ubuntu.com/ubuntu/

The self-test asserts the resolution on both sides of the switch, on an
identical plan line.
@huichen huichen changed the title fix(cli,scripts,goal,desktop): verify installs, reserve the Windows stack, replay exact goal times batch(dev): installer verification, CLI stack reserve, apt mirror plan, and three test-fixture fixes (29 commits) Oct 22, 2026
@huichen huichen changed the title batch(dev): installer verification, CLI stack reserve, apt mirror plan, and three test-fixture fixes (29 commits) fix(cli,scripts,ci,host,goal): verify installs, fail over apt mirrors, reserve the Windows stack Oct 22, 2026
@huichen
huichen merged commit 94d8b77 into main Oct 22, 2026
103 of 105 checks passed
@huichen
huichen deleted the pr/dev-huichen branch October 22, 2026 18:30
huichen added a commit that referenced this pull request Oct 22, 2026
Audited every failed `ci.yml` job in the last 200 runs (48 runs, 144 failed
jobs) and grouped the failures by test. Most were already fixed by #1293,
#1305 and #1309; this is the residual set with an established cause.

remote/host: an expired reply slot is replaced on read, not only by its timer.
The single-flight cache scheduled retirement through the Host executor, and
that path is best-effort: `runtime::spawn` drops the future outright when task
admission is closed, and the registry's timer can be cancelled by a fixture in
the same binary. A lost timer then served a cached reply forever — the test
that waits on the real eviction reported `Elapsed(())` on `Shared host (Windows)`
in runs 39437825835, 39440217807, 39526548081 and 39540018985. `CachedReply`
now carries its own deadline: a read past it replaces the entry, so a retry
executes instead of receiving a retired reply, and the timer is only
reclamation. A slot still executing is never replaced (`prompt` runs for its
600 s TTL), so single-flight is unchanged. The two host fixtures assert the
contract — an expired id re-executes — instead of waiting on the process-global
task registry.

host/remote: the two bridge fixtures that took no lock now hold the HOME
fixture. The control gate consults the process-global `SUPERVISOR`, which every
bridge fixture start re-points at its own pairing, so a fixture with no lock at
all clobbered whichever test was mid-command:
`declared_capability_reaches_the_running_command_loop` received
`{"success":false,"error":"superseded"}` in runs 39724323762 and 39540018985.
With both fixtures holding the lock every bridge test in the binary serialises
on it (the rest already did).

channels/qq: ack the gateway heartbeat when the first heartbeat is *recorded*
rather than after a fixed 130 ms. With a 90 ms interval the ack raced the next
interval on a loaded runner and the gateway reported "not acknowledged" (run
39742523871). The interval is 300 ms and the ack is ordered on the frame, so the
ack has a whole interval to be read.

agent: the no-progress journal failure is eventual (batch window + worker
thread), not synchronous; its 500 ms poll failed once on main (run 39767494038).
Five seconds still fails a journal that never reports.

cli (Windows): a console that goes away with the child is not a delivery fault.
`SetConsoleCtrlHandler(NULL, TRUE)` fails once the target's console is gone, and
the old assertion reported that as a broken Ctrl+C (runs 39576790228,
39474870891). Both calls now treat an already-exited target as "interrupt moot"
— the same rule the attach above them already uses — and still fail loudly while
the child is alive.

mobile: the `SessionList` setup hook renders once and flushes one microtask; the
5 s Jest default measured the machine (`Exceeded timeout of 5000 ms for a hook`,
run 39742523871) while the whole suite runs in one worker. A 30 s budget only
keeps a real hang from wedging the suite.

desktop: `acquire_transaction_lease` reported every `try_lock_exclusive` error
as "Another update transaction is active". Only `WouldBlock` is a concurrent
transaction now; anything else surfaces its own message, which is what the
unexplained first-`begin` failure in a fresh directory (run 39767494038, 1 round
in 6 measured in #1305) needed to be diagnosed.
huichen added a commit that referenced this pull request Oct 22, 2026
…forked store after closing it (#1310)

* test(desktop): say why a host status is not ready

`an_owned_host_counts_its_activity_and_a_stopped_host_reports_none` failed once
on a loaded Windows machine with only

    assertion `left == right` failed
      left: "unavailable"
     right: "ready"

and the child's own output could not narrow it further: `AgentStatus` carries the
transport, handshake or data-root reason in `error`, and nothing printed it. The
assertion now includes the whole status, so a repeat names the cause instead of
asking the reader to reproduce it.

Investigating that flake: it is not reproducible here. The case passed 30
sequential runs, three full library suites at `--test-threads=16`, and four and
eight concurrent runs of the whole fixture module with the CPU saturated, all on
the merged tree. The two failures both came from one build of an unmerged branch
state, so this commit adds the diagnosis rather than a fix for a cause that was
not established.

* fix(goal): replay restores created_at from the ledger, not the replay clock

`replay()` seeds state with `Goal::new`, which stamps `created_at:
now_epoch()`, and the `GoalStarted` fold dropped the event's `ts`. Replaying
therefore re-dated creation to the moment of the read: `created_at` drifted on
every replay and only looked stable while both clock reads landed in the same
wall-clock second.

That is what failed CI on main (run 39809589270): the goal's newest ledger ts
(1792685455) was compared against `created_at`, re-stamped to 1792685456.

- `apply(GoalStarted)` restores `created_at` from the event ts - the ledger is
  the canonical source of the creation time.
- `replay()` seeds `created_at` from the registry entry first, so a legacy
  goal whose ledger has no `GoalStarted` keeps its registration time. The
  replay clock is now only the last resort, for a goal with neither source.
- Regression tests: creation backdated two seconds must survive replay
  (deterministically red before the fix), plus the registry fallback tier.
- webui: comments no longer claim replay re-stamps creation with "now".

* fix(cli): reserve the platform stack on Windows

A Windows process takes its main-thread stack size from its PE header, and the
linker default — 1 MB, measured on this crate's own `future.exe` — is an eighth
of what Linux and macOS give the same code. Growth is on demand, so a frame that
runs past the reserve is fatal and silent:
`STATUS_STACK_OVERFLOW` (0xc00000fd), no message, no exit path.

That is not hypothetical: `future session list` died exactly that way on one
build of this CLI while `models list`, `task list` and `auth status` all worked
on the same isolated Agent — the shape of a reserve that is barely big enough.
The desktop already passes `/STACK:8388608,65536` for its command dispatch
(#1153); `build.rs` now passes the same for every binary of this crate. The
reserve is address space, not memory: commit stays at 64 KB and the stack grows
into it on demand.

`cli/tests/windows_stack.rs` reads `SizeOfStackReserve` off the built binary, so
losing the link argument fails a test. Checked as a negative control: with the
argument removed the test fails and names the 1 MB default, and with it restored
the built image reports 8388608 bytes / 65536 commit.

* test(cli): a mock-platform fixture that survives a connection with no request

`auth_login_writes_the_key_itself_when_no_agent_is_running` and
`auth_login_saves_through_a_running_agent` failed in roughly two of every three
full-suite runs on a Windows runner, and passed when run alone. The failure read
as two unrelated things: the listener thread reported
`assertion failed: request.read_line(..).expect("request headers") > 0`, and the
test reported `Network error: error sending request for url (…/device/code)`.

They are one thing. The CLI occasionally opens a connection to the platform,
sends nothing, closes it, and then makes its real request on a new connection —
a connect it abandoned and retried, seen under load and never in isolation
(verified: 12 concurrent `auth login` runs against a Python server produced
none, while full-suite runs produced one or two). Measuring the peer pid at
accept time named `future.exe`, the test's own CLI.

The fixture asserted `> 0` on that read. The assertion runs on the listener
thread, so the empty connection panicked the thread, the listener socket was
dropped with it, and the login the test is about then failed on a refused
connection — three removes from the cause.

The fixture now answers requests instead of policing the client: a connection
that carries no request is skipped, a malformed one is recorded in the new
`faults` list (and answered with 413 when it is oversized) rather than panicking,
and a test that cares asserts the list is empty. Both auth tests do, so a
genuinely malformed request is still a failure — with a message that names it.

Verified: 15 consecutive full-suite runs, 0 failures (before: 2 of 3 failing),
and 37 more after the final formatting pass. Negative control: restoring the
fatal `panic!` on the empty connection makes the new regression test
`a_connection_that_sends_nothing_does_not_poison_the_mock_platform` fail with the
original signature, so the guard is not vacuous.

* fix(scripts): verify pinned installs and fail closed without a checksum

The one-line installers run straight from `curl | bash`, yet two paths installed
artifacts without verifying anything:

- a pinned FUTUREOS_VERSION constructed the asset URL and skipped the manifest,
  so `FUTUREOS_VERSION=v1.0.2` downloaded and installed with no SHA-256 at all;
- a host without shasum/sha256sum logged a warning and returned success, which
  callers read as "verified".

Both now fail closed. A pinned install reads that release's own manifest
(releases/<version>/latest.json, published beside its artifacts) and shares the
latest-path verification; a release with no manifest entry, or a manifest entry
without sha256, is refused. Skipping the check requires FUTUREOS_SKIP_VERIFY=1,
documented as the deliberate risk it is. install.ps1 gets the same
pinned-manifest lookup and opt-in; it already failed closed on the hash tool,
because Get-FileHash ships with PowerShell (it now also refuses a pinned release
with no windows-x86_64 sha256, and a host without Get-FileHash).

Tests: scripts/tests/test-install.py gains pinned, fail-closed and opt-in cases
and now runs in CI's affected job; test-install.ps1 exercises the manifest, the
refusal and the opt-in, and no longer risks running a real `future init`.

* fix(cli): scope the Windows stack reserve to the binary

The reserve the CLI needs is for the shipped `future` binary. A bare
`rustc-link-arg` gave it to every target of the package, including every
test binary Cargo links for this crate.

`-bins` narrows it to `[[bin]]` targets. `cli/tests/windows_stack.rs`
now asserts both halves: the binary reports an 8 MB reserve and this test
binary reports the 1 MB linker default, so widening the scope again fails a
test rather than passing silently.

Measured after the change: target/debug/future.exe reserve=8388608
commit=65536, target/debug/deps/windows_stack-*.exe reserve=1048576
commit=4096.

* test(cli): an abandoned request is not a fault in the mock platform

`auth_login_saves_through_a_running_agent` flaked because the fixture
reported a connection the client abandoned as something it could not serve:
the login test then failed on its `faults` assertion, three steps away from
the login it is about. The empty-connection half was fixed first (a connect
that sends nothing); a connect that gets a few bytes of the request out
before closing still landed in `faults`, and recorded it again.

The fixture now separates the two records. `faults` is a request received
in full and unservable (an unparseable `Content-Length`, an oversized
body). `abandoned` is everything that ended before the request did: no
bytes, an unreadable request line, headers that stop early, a short body. A
partial request was never answerable, so counting it as a fault only made
the fixture blame the client it was serving.

`a_request_abandoned_half_written_does_not_poison_the_mock_platform`
covers the second half deterministically: it writes a partial request line,
and a request line plus one header, then closes, waits for the fixture to
record both, and asserts the real login after them is served with no faults.
Reverting the `headers ended early` branch makes it fail.

* chore(skills): bump future-goal to the cross-model ensemble workflow

Points the skills submodule at future-skills 32e9173, which adds the Ensemble
goal workflow (one frozen brief, different models, blind judging, synthesis),
its references/ensemble.md templates and the contract test guarding them.

* chore(skills): bump future-goal registry metadata

Points the skills submodule at future-skills 8c28fd9, which describes the
cross-model ensemble workflow in the future-goal registry entry so the skill
panel shows it.

* test(cli): assert the stack reserve did not reach the tests, without pinning the default

The new assertion compared this test binary's reserve to the 1 MB linker
default by value. That passes today and fails on an unrelated toolchain or
linker upgrade that moves the default, reporting a stack-reserve bug that
does not exist — and CI runs this test on windows-latest, so the false red
would land on an unrelated PR.

What has to hold is narrower: this binary did not receive the reserve the CLI
got. `test_reserve < binary_reserve` says exactly that. Verified in both
directions: widening `build.rs` back to a bare `rustc-link-arg` fails the
test with `this test binary reserves 8388608 bytes and the CLI reserves
8388608`, and `rustc-link-arg-bins` passes with 1048576 against 8388608.

* test(cli): record an abandoned connection once, not once per symptom

A reset can reach the fixture as an unreadable header line *and* as headers
that stopped early, and the header loop recorded both: one connection added
two entries to `abandoned`. The count then depended on which side of the
reset the fixture happened to see, which made the new regression test's
`== 2` assertion an occasional failure of its own.

The error is now carried out of the loop and recorded once, with the detail
kept, and the test treats the count as a precondition (`>= 2`) rather than
the property under test -- what that test asserts is that the login after the
abandoned connections is served and reports no faults.

15 consecutive `cargo test -p future-cli --test bin` runs: 25 passed each.

* fix(host): read an empty tail page as a live turn, not lost history

create_run stamps the thread's activity as soon as a send starts, while the
Agent persists the user entry only once the prompt is admitted. A reload that
lands inside that window read an empty history page for a conversation that
already claimed activity, and the GUI showed "Conversation history is
unavailable: restore its matching Agent database" on top of a healthy first
reply.

Only a conversation with nothing running can really be missing its history:
exempt the in-flight case (store::has_active_run) and keep the banner for a
settled conversation whose Agent page is empty.

* fix(ci): move the mirror list, not just the apt sources, when failing over

The apt failover added for run 39802801818 never switched anything. GitHub's
Ubuntu images name no hostname in their sources: 24.04 ships
`URIs: mirror+file:/etc/apt/apt-mirrors.txt` and keeps the endpoints in that
mirror list (azure priority:1, archive.ubuntu.com priority:2,
security.ubuntu.com priority:3 - 144 bytes, which is exactly the size apt
reported fetching from the mirrorlist in the log). `switch_to_public_archive`
grepped the sources for an azure hostname, matched nothing, rewrote nothing and
returned success, so the retry again called azure.archive.ubuntu.com.

Evidence from run 39822317986, job `Rust check / desktop`:

  17:36:12  Get:2 http://azure.archive.ubuntu.com/... libjavascriptcoregtk...
  17:39:12  Package installation did not finish (status 124); switching...
  17:39:12  Hit:2 http://azure.archive.ubuntu.com/ubuntu noble InRelease
  17:39:14  Get:2 http://azure.archive.ubuntu.com/... (same packaging, 145 s)

The endpoint never moved, so the second 180 s budget went to the same
~50 kB/s transfer. The mirror itself is not inherently slow - a sibling job in
the same run (`Rust Linux test / desktop`, 17:25) fetched the same 59 MB from
azure in 19 s.

What changed:

- `switch_to_public_archive` rewrites every file that can name the endpoint:
  sources.list, sources.list.d/*.sources|*.list and the file each
  `mirror+file:`/`file:` URI defers to (the mirror list). It reports each file
  it rewrote and *fails* when nothing matched, instead of claiming a switch.
- Every attempt prints the archive host and one sample URI apt would actually
  fetch, taken from `apt-get --print-uris` rather than from the source files,
  so the log shows whether a switch moved the endpoint.
- Download and unpack are separate phases with separate budgets; the download
  budget follows the payload from `--print-uris` (90 s + 4 s/MB, 180-480 s)
  instead of a flat 180 s. A failure names the phase that ran out, the host it
  was using and the archives still outstanding.
- `--self-test` exercises the rewrite against a runner-shaped fixture tree
  (mirror-list layout, classic sources.list, arm64 ports list, and a no-op that
  must not claim success); `scripts/tests/ci-plan.test.mjs` runs it.

Refs #1309

* chore(skills): ship the future-goal dispatch rule

Bump the skills submodule to future-skills 9b5e98c, which teaches future-goal
that a bare `/future-goal` is a full invocation: the token carries a request to
run the accompanying work as a supervised goal, so the session dispatches at
least one worker instead of answering inline. Previously the same task ending in
just the token produced no goal and no worker, while the same task ending in
"使用 /future-goal 技能启动多个 worker" dispatched reliably.

The installed copy under ~/.future/agent/skills was updated in place; this
pointer is what makes a fresh checkout and `future skills install` ship 5.3.0.

* fix(ci): resolve the mirror list in the apt plan, not the pseudo-URI

`apt-get --print-uris` does not resolve a `mirror+file:` source. The first CI
run of #1309's follow-up printed, in the very line meant to prove which archive
the job would use:

  APT sample URI: mirror+file:/etc/apt/apt-mirrors.txt/pool/main/b/...deb
  APT download: 2.4 MB from apt

`apt` was the third field of the mirror-list path, not a host. The same pseudo-
URI comes back before and after a switch, so that comparison would have
reported "nothing changed" for a switch that did move the endpoint.

Resolve it the way apt does: the `mirror+file:` target's lowest priority number
wins and the rest are failover, substituted back into the plan line, so host,
sample URI and byte budget all describe the archive the transfer will really
touch. The attempt line now reads, on the same plan line:

  before: APT mirror list /etc/apt/apt-mirrors.txt: 3 entries, using http://azure.archive.ubuntu.com/ubuntu/
  after:  APT mirror list /etc/apt/apt-mirrors.txt: 3 entries, using http://archive.ubuntu.com/ubuntu/

The self-test asserts the resolution on both sides of the switch, on an
identical plan line.

* feat(mobile): open the recency row's under-line with the machine

On the recency page every row says where it lives under its title, and the
machine's glyph trailed the workspace name — so the under-line started with a
word whose length decided where the device icon sat, and nothing in that line
shared the title's left edge.

The glyph now leads the line, on the row's own left edge, so its column lines
up with the title above it: measured in the mobile harness at x=24 for both,
with the workspace name opening at x=48. The 4px margin it carried as a
follower would read as an indent against that edge, so it moves to the glyph's
right and the pair keeps its 8px separation.

The other two places a merged row draws its glyph (a workspace heading and a
flat/chat row) are untouched: they are single-line rows where the icon does sit
after the text it labels.

Verified: tsc --noEmit, eslint on both files, and SessionList + SessionsScreen
suites (150 tests) pass; the new test fails with the old order restored.

* test(agent): reopen the forked store after closing it, not beside it

`forked_checkpoint_evidence_resolves_through_history_after_restart` failed once
on CI (run 39828434841, job `Rust Linux test / agent`):

  session::fork::tests::forked_checkpoint_evidence_resolves_through_history_after_restart
  panicked at agent/src/session/fork.rs:497:51:
  called `Result::unwrap()` on an `Err` value: database is locked
  Caused by: Error code 5: database is locked

That line is `restarted.load(&child.id)`, not the summary assertion. The test
wrote the child through one store and then read it through a second store it
opened *beside* the first, so two live connections shared agent.db:

- the first store's worker keeps an idle space reclaimer (128 single-page
  `PRAGMA incremental_vacuum(1)` commits, then `wal_checkpoint(TRUNCATE)`,
  `synchronous=FULL`), and
- the reopened store's load is a read that has to take the same write lock
  (SQLite blocks readers on the wal-index write lock while a writer commits).

Measured on an idle disk with the real code paths: one reclaimer slice is
133 ms (1.04 ms per single-page commit) and a concurrent store's load fails
3 of 4 attempts with `database is locked` / SQLITE_BUSY_SNAPSHOT. On a runner
whose commits are slower than that, the slice outlasts the 5 s busy timeout and
the failure surfaces as plain SQLITE_BUSY — what CI reported. Nothing is wrong
with the fork, the checkpoint or its evidence; the extra connection is the
problem.

A restart ends the store that wrote the child, so close it before reopening.
The test still forks twice through a freshly opened store with a rebuilt
history index — the property it asserts - but it no longer races its own
predecessor, and the agent keeps one store per process anyway.

Verified: the test passes in 12 consecutive runs and inside a full parallel
2483-test lib run; `session::fork` 21/21; fmt and clippy clean. The local full
suite still reports unrelated failures that reproduce on the unmodified branch
here (`grpc::tests::the_public_serve_wrappers_bind_serve_and_report_bind_failures`
fails on dev-huichen too, and `service::tests::*` flake under this machine's
load), so they are not evidence about this change.

* chore(skills): bump future-versioning to record the repository convention by default

Picks up future-skills#107 (dee9352): the skill now writes a repository's
delivery convention into its AGENTS.md as part of the work, in a commit of
its own, instead of offering to and waiting for an answer. The consent gate
remains where the file is not the user's to set and for initializing a
repository.

Without this bump the shipped skill keeps the old wording, which is what let
a session skip the AGENTS.md entirely.
huichen added a commit that referenced this pull request Oct 22, 2026
Audited every failed `ci.yml` job in the last 200 runs (48 runs, 144 failed
jobs) and grouped the failures by test. Most were already fixed by #1293,
#1305 and #1309; this is the residual set with an established cause.

remote/host: an expired reply slot is replaced on read, not only by its timer.
The single-flight cache scheduled retirement through the Host executor, and
that path is best-effort: `runtime::spawn` drops the future outright when task
admission is closed, and the registry's timer can be cancelled by a fixture in
the same binary. A lost timer then served a cached reply forever — the test
that waits on the real eviction reported `Elapsed(())` on `Shared host (Windows)`
in runs 39437825835, 39440217807, 39526548081 and 39540018985. `CachedReply`
now carries its own deadline: a read past it replaces the entry, so a retry
executes instead of receiving a retired reply, and the timer is only
reclamation. A slot still executing is never replaced (`prompt` runs for its
600 s TTL), so single-flight is unchanged. The two host fixtures assert the
contract — an expired id re-executes — instead of waiting on the process-global
task registry.

host/remote: the two bridge fixtures that took no lock now hold the HOME
fixture. The control gate consults the process-global `SUPERVISOR`, which every
bridge fixture start re-points at its own pairing, so a fixture with no lock at
all clobbered whichever test was mid-command:
`declared_capability_reaches_the_running_command_loop` received
`{"success":false,"error":"superseded"}` in runs 39724323762 and 39540018985.
With both fixtures holding the lock every bridge test in the binary serialises
on it (the rest already did).

channels/qq: ack the gateway heartbeat when the first heartbeat is *recorded*
rather than after a fixed 130 ms. With a 90 ms interval the ack raced the next
interval on a loaded runner and the gateway reported "not acknowledged" (run
39742523871). The interval is 300 ms and the ack is ordered on the frame, so the
ack has a whole interval to be read.

agent: the no-progress journal failure is eventual (batch window + worker
thread), not synchronous; its 500 ms poll failed once on main (run 39767494038).
Five seconds still fails a journal that never reports.

cli (Windows): a console that goes away with the child is not a delivery fault.
`SetConsoleCtrlHandler(NULL, TRUE)` fails once the target's console is gone, and
the old assertion reported that as a broken Ctrl+C (runs 39576790228,
39474870891). Both calls now treat an already-exited target as "interrupt moot"
— the same rule the attach above them already uses — and still fail loudly while
the child is alive.

mobile: the `SessionList` setup hook renders once and flushes one microtask; the
5 s Jest default measured the machine (`Exceeded timeout of 5000 ms for a hook`,
run 39742523871) while the whole suite runs in one worker. A 30 s budget only
keeps a real hang from wedging the suite.

desktop: `acquire_transaction_lease` reported every `try_lock_exclusive` error
as "Another update transaction is active". Only `WouldBlock` is a concurrent
transaction now; anything else surfaces its own message, which is what the
unexplained first-`begin` failure in a fresh directory (run 39767494038, 1 round
in 6 measured in #1305) needed to be diagnosed.
huichen added a commit that referenced this pull request Oct 22, 2026
…sources (#1311)

* fix(tests): stop recurring CI flakes at their causes

Audited every failed `ci.yml` job in the last 200 runs (48 runs, 144 failed
jobs) and grouped the failures by test. Most were already fixed by #1293,
#1305 and #1309; this is the residual set with an established cause.

remote/host: an expired reply slot is replaced on read, not only by its timer.
The single-flight cache scheduled retirement through the Host executor, and
that path is best-effort: `runtime::spawn` drops the future outright when task
admission is closed, and the registry's timer can be cancelled by a fixture in
the same binary. A lost timer then served a cached reply forever — the test
that waits on the real eviction reported `Elapsed(())` on `Shared host (Windows)`
in runs 39437825835, 39440217807, 39526548081 and 39540018985. `CachedReply`
now carries its own deadline: a read past it replaces the entry, so a retry
executes instead of receiving a retired reply, and the timer is only
reclamation. A slot still executing is never replaced (`prompt` runs for its
600 s TTL), so single-flight is unchanged. The two host fixtures assert the
contract — an expired id re-executes — instead of waiting on the process-global
task registry.

host/remote: the two bridge fixtures that took no lock now hold the HOME
fixture. The control gate consults the process-global `SUPERVISOR`, which every
bridge fixture start re-points at its own pairing, so a fixture with no lock at
all clobbered whichever test was mid-command:
`declared_capability_reaches_the_running_command_loop` received
`{"success":false,"error":"superseded"}` in runs 39724323762 and 39540018985.
With both fixtures holding the lock every bridge test in the binary serialises
on it (the rest already did).

channels/qq: ack the gateway heartbeat when the first heartbeat is *recorded*
rather than after a fixed 130 ms. With a 90 ms interval the ack raced the next
interval on a loaded runner and the gateway reported "not acknowledged" (run
39742523871). The interval is 300 ms and the ack is ordered on the frame, so the
ack has a whole interval to be read.

agent: the no-progress journal failure is eventual (batch window + worker
thread), not synchronous; its 500 ms poll failed once on main (run 39767494038).
Five seconds still fails a journal that never reports.

cli (Windows): a console that goes away with the child is not a delivery fault.
`SetConsoleCtrlHandler(NULL, TRUE)` fails once the target's console is gone, and
the old assertion reported that as a broken Ctrl+C (runs 39576790228,
39474870891). Both calls now treat an already-exited target as "interrupt moot"
— the same rule the attach above them already uses — and still fail loudly while
the child is alive.

mobile: the `SessionList` setup hook renders once and flushes one microtask; the
5 s Jest default measured the machine (`Exceeded timeout of 5000 ms for a hook`,
run 39742523871) while the whole suite runs in one worker. A 30 s budget only
keeps a real hang from wedging the suite.

desktop: `acquire_transaction_lease` reported every `try_lock_exclusive` error
as "Another update transaction is active". Only `WouldBlock` is a concurrent
transaction now; anything else surfaces its own message, which is what the
unexplained first-`begin` failure in a fresh directory (run 39767494038, 1 round
in 6 measured in #1305) needed to be diagnosed.

* fix(tests): count supervisor retries at the retry seam, not accepted sockets

`a_supervisor_gives_up_after_its_window` asserted that the fake broker had
accepted exactly 18 connections. The broker counts sockets, not retries: a
leftover loop reaching the listener, a reused ephemeral port or any extra
dialling source moves that number without moving the retry policy, and a CI run
reported 34 accepted for an 18-attempt budget.

Count the retry itself: the supervisor records one increment immediately before
each `resume`, in the test-only `retry_attempts` map (per host, so two loops for
one host would exceed the budget instead of agreeing with it), and the test
asserts `dispatched == reconnect_attempt_budget()` with the budget's value pinned
at 18. The socket counter stays as a diagnostic and as proof the loop reached the
broker.

Also retire a superseded loop in `install_supervisor_for_test`: overwriting the
map entry left the old loop running with no owner to abort it, which is how a
host could be dialled by two loops. Pinned by
`a_second_install_retires_the_first_retry_loop`.

* docs: reconcile the documentation corpus with the code

A full pass over every live document, checking three things: does it match
the code, does it still carry narration about states that no longer exist,
and is anything shipped but undocumented.

Against the code: the approval tier is four values (off/manual/sandbox/auto),
not three, in README, SECURITY, the wiki and desktop/CLAUDE.md;
desktop/CLAUDE.md's Store, Shadow Review and provider-validation paths moved
to host/; `make test` is eight suites and `make fmt` does not format mobile;
the architecture docs gave the task executor to the desktop when it lives in
future-host; the goal CLI has 43 commands in 7 groups, not 41 in 5; the
protocol is 2 and the agent schema 7, not 1 and 6; the rpc crate's module list
was missing twelve modules; auto_connect_remote and skill_recommend defaults
were inverted; the TUI now hosts the agent in-process and the supervision doc
still called that undecided; the wiki's Settings/Remote/Sandbox pages described
a Phone Control tab and a "Pair and start" button that no longer exist;
Bubblewrap compatibility is a runtime probe, not a 0.9.0 floor; the channel and
schema-inventory docs had drifted from their tables.

Against historical pollution: dropped the loop group (removed from the CLI),
the TypeScript RPC client and its npm package, migration notes for
long-finished refactors, "this branch"/"this pass"/PR-time narration, and the
old-layout breadcrumbs in the docs index.

New documents for real gaps: future data backup and recovery had only a
section inside the storage-migration doc; agent/ and host/ had no module map;
scheduled tasks shipped with no wiki page at all. Also added the missing
Models navigation and the testing-record index entries.

* docs: index the gaps the documentation audit left open

- CLI wiki page (en/zh): `## See also` now links the guides behind
  `future host`, `future relay`, `future task` and `future data` — host mode,
  the self-hosted relay, `architecture/tasks.md` and
  `architecture/sqlite-migration.md`. The seven missing command entries and the
  removal of the deleted `loop` group were already in place on the branch.
- Root README (en/zh): one feature-table row states that `future relay
  init|serve` runs the relay behind remote control without a FutureOS account in
  the path (evidence: `cli/src/main.rs:44`, `cli/src/help.rs:36`,
  `cli/src/relay/cli.rs:77-78`, `docs/guide/self-hosted-relay.md`).
- `docs/testing/README.md` + `.zh-CN.md`: the `headless-*.json` row described
  only the two CI/baseline payloads, while 57 of the 63 `headless-*.json` files
  are per-change acceptance payloads (`baseCommit`, `change`, `testOwnership`,
  `localTests`, `limits`); the row now says so.
- `cli/src/main.rs`: the module comment claimed the standalone binaries "remain
  installed and usable directly". `Makefile` `install`/`install-cli`/
  `install-desktop` place only `future` and `futureos`, so it now says they stay
  `cargo build -p <crate>` targets. Comment only, no logic change.
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