Skip to content
Source
Sign inSign up
pingdotgg/t3code

refactor(provider-cursor): follow the Effect service conventions #17545

Mergedjuliusmarmingemerged 2 commits intomain fromrefs/pull/17545/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Part of the provider-package audit. Every module in provider-cursor should now follow docs/internals/effect-services.md.

Module state becomes service-owned

  • The shell-spawn unhandledRejection guard used to be installed globally behind a module-level flag the first time sdk.ts was imported.
    • It now belongs to a CursorSdk service. Its layer adds the listener with Effect.acquireRelease and removes it on release.
    • The "another handler owns the decision" logic and the stderr output are unchanged.
    • The runner and text generation reach Agent and createAgentPlatform through this service, so the guard is armed whenever they are in use.
  • The server provides CursorSdk.layer once, next to the runner layer in ProviderOrchestrationAdapterInfrastructure. The guard is now armed when that layer builds instead of on first import, and there is still exactly one guard while the server runs.
  • The sandbox-support warm-up used to be a module-level memoized promise. It's now a Ref and Deferred owned by the runner. It still warms at most once, later callers wait for that attempt, and failures are ignored.

Conventions

  • CursorSdkCatalogShape and CursorAgentSdkRunnerShape are inlined into their services.
  • effect/http modules are imported as subpath namespaces.
  • makeCursorAgentSdkRunner is an Effect.fn that yields CursorSdk.
  • The snapshot error's detail no longer copies cause.message.
  • An unused default adapter layer is removed.

Left for a follow-up: keychainToken.ts still memoizes the macOS keychain read in module state, and its timeout error extends Error. Its main consumer, the Promise-based Cursor usage reader in apps/server, moves into the package with the usage-reader work, so it'll be converted there.

Tests: provider-cursor 102 passed. Server ProviderInstanceRegistry 8 passed. Typecheck is clean for provider-cursor and apps/server.

Model: Claude Opus 5.5 via Claude Code in T3 Code.

🤖 Generated with Claude Code


Devin Review
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This refactor moves Cursor process state and its unhandled-rejection guard into a scoped Effect service, changing production layer wiring and listener lifetime. It also adds a file-level globalConsole:off static-analysis suppression, which requires human review under the configured criteria.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiB✅
      CodexLive turn messages220 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB−24 B (−0.5%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB−24 B (−2.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB−41 B (−0.2%)29.3 KiB✅
      ClaudeLive turn messages21−1 (−50.0%)8✅

      Baseline: f853d51 · PR result: 2c41887 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    5. juliusmarminge merged this33806e7

    6. juliusmarminge closed this

Sign in to join this conversation.