Skip to content

index source: a failed fs.scan is retried, and fs.scan gets a 120 s budget - #452

Merged
SSFSKIM merged 1 commit into
masterfrom
index-scan-retry
Nov 3, 2026
Merged

SSFSKIM merged 1 commit into
masterfrom
index-scan-retry

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 3, 2026

Copy link
Copy Markdown
Owner

The defect

On the owner's MacBook after the update to master 7594474, mawsd logged [index] fs.scan failed: engine-host did not answer fs.scan within 10 s. 3.6 s later it logged dropped engine-host's response to unknown request 36. The scan finished in about 13.6 s on a store of about 7,750 indexed sessions, but the supervisor's default deadline (REQUEST_TIMEOUT_MS, 10 s) had already failed the request and dropped the answer. IndexSessionSource.sync() only runs at the engine host's streaming, so a null scan left scanned false until the next host transition. Until then:

  • discoveryCurrent() and discoveryApplied() stayed false, which held the inactivity archive and mawsd's discovery wake;
  • transcripts the CLI wrote while the app was closed were not discovered.

The design and why

There are two parts. The budget stops a slow scan on a large store from failing in the first place. The retry stops any failed scan from leaving discovery stuck. Either part alone leaves one of those cases open.

  1. Budget. ENGINE_HOST_BUDGETS_MS = { 'fs.scan': 120_000 } (src/shared/host/host-supervisor.ts) is set as requestBudgetsMs on every engine-host spec whose supervisor the index source scans through:

    • mawsd's (src/mawsd/daemon.ts), the shape the defect was seen on;
    • main's embedded shape (src/main/hosts/index.ts), where the spine runs in main.

    Main's daemon-shape specs (daemonHostSpecs) are unchanged: on that shape main never sends fs.scan, and daemon.test.ts pins that the engine host gets no budget there.

    Why 120 s: the scan's time grows with the store. It lists every transcript, reads each one the index does not hold, and waits behind any scan the host is still running. Earlier measurements were 1.4–3 s for 3,100–5,100 transcripts; this one was 13.6 s for 7,750 just after an update. 120 s is about 9 times the worst seen. A long budget does not delay recovery from a lost host, because a request already sent fails with host_unavailable when the link drops (failSent). It also leaves the handover's wait for sent requests (HANDOVER_SENT_WAIT_MS) unchanged.

    fs.bind gets no budget. Its cost does not grow with the store: it only changes the in-memory binding table and re-follows the followed sessions whose engine id moved. It reads no transcripts.

  2. Bounded retry. When a sync's scan answers null, the sync runs again after SCAN_RETRY_MS (2 s, 10 s, 30 s), so a generation gets at most four attempts. After that, mawsd logs fs.scan failed N times; discovery waits for the engine host's next start. A waiting retry is dropped:

    • at a transition: the generation changed, and the next host's streaming syncs anyway;
    • at the stop;
    • when another sync's scan has answered in the same generation (scanned).

    One retry waits at most, and this.syncs already runs one sync at a time.

How the retry interacts with the rest of the source:

  • A late answer. After a timeout the supervisor drops the answer, but the late scan's fs.sessionChanged events still arrive and are applied. The retry's scan queues in the host behind the one still running, because FsService runs one scan at a time. It reads only what the index does not hold by then, so each retry has less to read. The invariant that a scan's discoveries arrive before its answer still holds for the retry's answer.
  • Search requeue. sessionSearch.retryFailures() now runs once per host start (attempt === 0), not on every retry, so a retry does not give text reads that failed since then a second round of three attempts. Stamps the retry's scan reports again are deduplicated by stamp in searchQueue, as before.
  • fs.state's holder fold. Each retry folds again from the registry as the host reports it at that moment. The fold is idempotent.
  • generation. The retry is tied to the generation its first sync ran in, and is checked both when it is scheduled and when it fires.

Tests

In src/services/index/source.test.ts, with the retry schedule injected through SourceOptions.scanRetryMs (the same way tickMs and searchDebounceMs are injected):

  • a scan that fails once is asked again with no host transition, and discovery is then current and applied. This failed on master: discovery stayed false. It also checks that the failed text reads are requeued once per generation.
  • a scan that keeps failing is asked again only as often as the schedule says, and afresh at the next transition. This failed on master: there was only one scan. It checks the bound, the give-up line in the log, and a fresh sync at the next transition.
  • a waiting retry asks nothing after a transition, after another sync's scan answered, or after the stop. This guards against retries that fire when they should not.

The budget has no new test. It is a constant on two specs, and the requestBudgetsMs mechanism is already tested in host-supervisor.test.ts ("a request's deadline"). A test of the wiring would only restate the edit.

Locally I ran only the focused file (52/52) and eslint, one changed file at a time.

Gates

  • Static (--gates static --class1a pool --runner macos --peer none): run 41549538392, success, 0 flaky lines.

  • Landing (--gates all --class1a pool --runner macos --lane hosted): run 41550088326, success on attempt 1. No hold was in force at launch, but the hosted lane kept the run out of CI-opt's 01:05Z mini hold. All jobs were green, with 2 flaky lines, both in specs this change does not reach:

    • e2e/connectors.spec.ts:304 (daemon restart, lease rebuilt): the MCP server's call count read n=1 after the restart. That is the connector lease's server reuse, not the index source.
    • e2e/supervisor.spec.ts:1047 (G4, terminals outlive the app on the daemon shape): the quit guard's line said 1 mid-turn, not asked without the busy terminals, because the quit raced the shells' busy report.

    The run logged no fs.scan failed line anywhere, so the retry path never ran in it.

Review

doperpowers:reviewer-medium reviewed 75944744d..cc607f69a and found no material issues, so there was no fix round.

Residue

None.

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)

…s, within its generation, never past an answered scan or the stop), and fs.scan gets a 120 s budget on every supervisor the index source scans through (mawsd's, main's embedded); the owner's 7,750-session store outran the 10 s default and left discovery unknown until the next host transition

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-03T01:01:17.356886Z
We couldn’t complete this review. Comment @codex review to try again.
cc607f6 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

SSFSKIM added a commit that referenced this pull request Nov 3, 2026
…cision Log 206; hosted flake signatures (12) and (26); a committed copy of a gitignored executor report leaves master

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
@SSFSKIM
SSFSKIM merged commit 71969ab into master Nov 3, 2026
SSFSKIM added a commit that referenced this pull request Nov 3, 2026
…3.23 regenerated from master's 3.22 manifest (master's 3.22 is O7 M5c's), O17's capabilities beside machine.delivery; the engine host's spawn keeps O17's spawner env beside #452's requestBudgetsMs; the endpoint services carry O17's browser beside O7 M5c's clientPort; the latency stub's header keeps both notes

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
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