Repository navigation
feat(mail): budgeted syncMail, per-message retry, cause_code in runs, 15 min for a sync - #2144
Merged
Merged
Conversation
… 15 min for a sync syncMail takes a RunBudget (WC-LIFE-16). It reads the window in rounds of source.listBatch messages, one request of the budget per call to the source, saves the resume point after every round so a 16,000-message folder finishes over several runs, and answers state partial with remaining and requests when the budget stops it. A message the source did not return or answered with an Error is asked for once more at the end of the run, and if it still fails it is counted in unreadable and left out of the resume point. A failed chunk now saves the resume point before it throws. A failed run's record keeps the transport's own code as error.cause_code. A cooperative command that declares partial (a resumable sync) gets 15 minutes at a terminal (DEFAULT_SYNC_MS); other cooperative commands keep 5 minutes and MCP keeps 45 seconds. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ync as partial Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task
Make a mail sync on Yandex 360 finish reliably (mail-cli on
@wirecat/cli-core/mail): spend a request budget, keep mid-folder progress, cope with a server that fails single messages and closes the connection, and say why a run failed.Why
Real runs on a 253,024-message INBOX: the server answers single messages with
* NO [UNAVAILABLE] UID FETCH ... failure due to backend errorand then closes the connection, so every later command failed. The sync also listed the whole window (a header FETCH per message) before saving anything, so a 16,000-message window never saved a resume point under a deadline.What
syncMail(..., { budget })(WC-LIFE-16): rounds ofsource.listBatchmessages, one request of the budget persearch,listandfetchRawcall, resume point saved after every round,state: "partial",stopped,remaining,requestsin the answer,maxdefaults to no limit.MailSourcegains the optionallistBatchandfetchBatch. Without a budget behaviour is unchanged, except that a failed chunk saves the resume point before it throws.list, or answers with an Error fromfetchRaw, is asked for once more at the end of the run; if it still fails it is inunreadableand not in the resume point, so the next run asks again.deletionsSkippedsays so), except when one round lists all of it. Known gap: a window larger than one round never proves a deletion under a budget.runs show:error.cause_codefromdetails.cause_code(plain codes only).DEFAULT_SYNC_MS(15 min): a cooperative command that declarespartialgets it at a terminal; other cooperative commands keep 5 min, MCP keeps 45 s. The calendarsyncis such a command, so it goes from 5 to 15 minutes. Owner's choice, see the cli-base draft.Testing
pnpm lint,pnpm typecheck,pnpm docs:check,pnpm test(622 files, 8,149 tests). New tests: budgeted slices and request count, stop and resume, one retry in the same run, a message that stays unreadable is not stored as done, the 15 minute class,cause_codein the run record.🤖 Generated with Claude Code