Skip to content

refactor(core): own the command submit deadline in one place - #5255

Merged
tyler-dane merged 1 commit into
mainfrom
claude/kind-dirac-6qo7vm
Nov 13, 2026
Merged

tyler-dane merged 1 commit into
mainfrom
claude/kind-dirac-6qo7vm

Conversation

@tyler-dane

Copy link
Copy Markdown
Contributor

No issue: scheduled tech-debt sweep finding (2026-11-13 window, the 8 merges after #5240).

What and why

COMMAND_TIMEOUT_MS = 30_000 (the deadline the backend's Sync HTTP client puts on POST /internal/commands) lived in packages/backend/.../sync-service.client.ts, while packages/sync/.../provider-inline-request-budget.ts hardcoded the inline provider budget that has to fit inside it as a bare 24_000, with the relationship stated only in a prose comment ("times out at COMMAND_TIMEOUT_MS (30s)"). Nothing coupled the two numbers and no test touched both, so lowering the client deadline would silently leave Sync spending up to 24s on provider requests inside a request the caller had already abandoned. The backend then returns a command failure while Sync is still applying the mutation to the provider, which is exactly the staging symptom the 30s deadline was raised for ("DELETE appeared to fail with 5xx while the event was gone") and the one the inline budget in #5249 was added to prevent.

This moves the deadline into packages/core/src/types/sync/command.contracts.ts, which already owns the CommandSubmitRequest/CommandSubmitResponse schemas that both ends of that call import, and derives the inline budget from it with an explicit response margin: INLINE_COMMAND_REQUEST_BUDGET_MS = COMMAND_SUBMIT_TIMEOUT_MS - COMMAND_SUBMIT_RESPONSE_MARGIN_MS. 24_000 === 30_000 - 6_000, so no timing behavior changes; the budget can no longer outlive the caller's deadline by construction, and a core test pins the invariant. COMMAND_TIMEOUT_MS stays exported from the backend client under its own name so the call site reads unchanged.

Also appends the sweep's judged-fine.md entry, recording the eight areas examined and deliberately kept (the provider-transient-error.util.ts fan-out in #5244, the job.repository.ts candidate probes in #5251, the map→flatMap filter in #5254, the two provider-name copy maps in #5248, the macOS shift+arrow nudge in #5236, and the .github/scripts/ XCTest exit detection in #5239), so the next sweep does not re-read them.

Verify

VERDICT: FAIL from bun run verify --strict — checks run: type-check, lint, knip (all pass), test:core, test:sync:fast, test:backend:fast. None skipped.

The verdict is FAIL only because verify baselines against origin/main for test:web, test:a11y and test:e2e, and these three suites are not in that set, so it cannot classify their failures itself. Baselined by hand instead: all three suites were run on this branch and on a clean tree, and the failure lists are byte-identical — 15 pre-existing failures, 0 NEW. They are sandbox-environmental (no compass.yaml, so no Mongo or SSE infra, and no outbound provider network).

PRE-EXISTING (identical on origin/main):

(fail) configureHttpServer > does not reject a request that exceeds maxHeadersCount
(fail) microsoftGraphRequest > attaches HTTP status and content-type when the JSON body is not parseable
(fail) GET /api/config > exposes Sync cutover posture
(fail) GET /api/config > returns 200 with a schema-valid hoisted payload
(fail) GET /api/config > returns the same payload across two requests
(fail) SSE Server > Publish-site conformance (A27): every `publish*` helper's written frame is a ServerMessage > publishCalendarsChanged's written frame parses with ServerMessageSchema
(fail) SSE Server > Publish-site conformance (A27): every `publish*` helper's written frame is a ServerMessage > publishEventsChanged's written frame parses with ServerMessageSchema
(fail) SSE Server > Publish-site conformance (A27): every `publish*` helper's written frame is a ServerMessage > publishImportCompleted's written frame parses with ServerMessageSchema
(fail) SSE Server > Publish-site conformance (A27): every `publish*` helper's written frame is a ServerMessage > publishSyncStatus's written frame parses with ServerMessageSchema
(fail) SSE Server > Publish-site conformance (A27): every `publish*` helper's written frame is a ServerMessage > publishUserMetadata's written frame parses with ServerMessageSchema
(fail) SSE Server > Subscription and events (B10 — single `message` event, dispatched by payload.type): > delivers calendarsChanged to a subscribed user
(fail) SSE Server > Subscription and events (B10 — single `message` event, dispatched by payload.type): > delivers eventsChanged to a subscribed user
(fail) SSE Server > Subscription and events (B10 — single `message` event, dispatched by payload.type): > does not deliver events to unsubscribed users
(fail) SSE Server > Subscription and events (B10 — single `message` event, dispatched by payload.type): > does not replay userMetadataChanged to existing tabs when a new tab opens
(fail) SSE Server > Subscription and events (B10 — single `message` event, dispatched by payload.type): > replays userMetadataChanged on connection (cold start)

FLAKY: none.


Generated by Claude Code

The backend's Sync HTTP client deadline (COMMAND_TIMEOUT_MS, 30s) lived in
sync-service.client.ts, while packages/sync hardcoded the inline provider
budget it has to fit inside as a bare 24_000 with the relationship stated
only in a prose comment. Nothing coupled the two numbers, so lowering the
client deadline would silently leave Sync spending up to 24s on provider
requests inside a request the caller had already abandoned: the backend
returns a command failure while Sync keeps applying the mutation, which is
the staging symptom COMMAND_TIMEOUT_MS was raised for and the one #5249
added the budget to prevent.

Move the deadline to core's command contracts, where both ends of
POST /internal/commands already import the request and response schemas,
and derive the inline budget from it with an explicit response margin.
24_000 === 30_000 - 6_000, so no timing changes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmwVQHAdQAAEmLUrXSSDUA
@tyler-dane
tyler-dane enabled auto-merge November 13, 2026 11:12
@github-actions

Copy link
Copy Markdown
Contributor

Boot bundle: 577.1 KB gzip (+0.0 KB vs main)

@tyler-dane
tyler-dane added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit b2b7e28 Nov 13, 2026
34 checks passed
@tyler-dane
tyler-dane deleted the claude/kind-dirac-6qo7vm branch November 13, 2026 11:28
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.

2 participants