feat(effect): add Effect bridge spike package - #145
Conversation
Change-Id: I848f10cb6eb2d03e8f39c0ffb1aa813c6264a797 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I3855ff7f38213b954d3fd375ebd797ec48f84e20 Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
|
@codex security review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bd74e7ec5d
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Change-Id: Idb5cd17a17155b9a717ccc11761a36e8e48ba472 Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
|
@codex security review |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7c27e84575
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Change-Id: I33abee1aa6bd669a0bc53db79f541f14e5d6010b Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I8c0153dc7019315ae73ad8a50246aafd4363d42c Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
|
@codex security review |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4e7f24a66a
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Change-Id: Ia9c2a5c63ffe6795d2cd67c2d4375911ac9763fb Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Part of #144 (Phase 1 spike — do not close the tracking issue).
Adds
packages/effect(@coder/ai-sdk-effect): an experimental Effect bridge over the existing SDK packages. The package isprivate: true, is not published, is not in the release-please config/manifest (verified: configpackagesmap and manifest list only sandbox/agent/provider), and is automatically excluded from the publint/attw publish-hygiene scripts (they filter to sandbox+provider).What's in the spike
LanguageModelover Coder AI Gateway (CoderLanguageModel): implements@effect/ai'sLanguageModel.makecontract on top of@coder/ai-sdk-provider.generateText,generateObject, andstreamTextwork; construct fromCoderProviderSettingsor an existingCoderProvider(both auth modes preserved). The bridge corefromModel(model: LanguageModelV4)adapts any AI SDK v4-spec model, which is how the unit tests drive it with fakes.@effect/ai'sAiErrorunion (status/headers/body preserved onHttpResponseError);classifyErrorrecoversauth | rate-limit | provider-unavailable | malformed-response | transport | unknown, andisTransientplugs intoEffect.retry.toAiSdkSchema,toJsonSchema): Effect Schema → the AI SDK'sSchemacontainer (JSON schema derived via the same helper@effect/aiuses + validation through Effect Schema decode), accepted bytool()/generateObject.acquireWorkspace/layerWorkspace,acquireSession/layerSession):ensureCoderWorkspaceandcreateCoderWorkspace().createSession()asEffect.acquireRelease, with teardown policies that never delete a workspace the acquisition merely attached to, and release on scope close including interruption.Exact pins:
effect@3.22.1,@effect/ai@0.37.0,@ai-sdk/provider@4.0.8.API deltas vs. the issue sketch (implemented against @effect/ai 0.37.0 reality)
AiErroris a closed union (HttpRequestError | HttpResponseError | MalformedInput | MalformedOutput | UnknownError) andLanguageModel.makeimplementations must fail with exactly those types — the sketch's "typed AiError hierarchy (auth, quota, provider-unavailable, malformed-response)" cannot be expressed as subclasses. Instead the bridge maps into the standard union without losing information and shipsclassifyError/isTransientto recover that taxonomy (unit-tested both directions).tool():Schema.standardSchemaV1emits no~standard.jsonSchemaconverter, and AI SDK v7 throwsStandard schema vendor 'effect' does not support JSON Schema conversionfor it (pinned by a test). The bridge therefore emits the AI SDK's ownSchemacontainer viajsonSchema()+ Effect decode instead of a bare Standard Schema.@coder/ai-sdk-*releases (exact pins), notworkspace:*: this would be the repo's first cross-package workspace dependency, and CI runstypecheck/testbeforebuild, soworkspace:*would break fresh-clonepnpm check. Moving toworkspace:*is part of the Phase 2 publishing decision (noted in the README).json_object(rejects requests whose messages don't mention JSON). Discovered in live validation; the bridge injects the schema as a leading system instruction, the same strategy the AI SDK's owngenerateObjectuses.MalformedInput(provider-defined tools,oneOftool choice); response parts with no@effect/aiequivalent are dropped (custom, reasoning-file, tool-approval-request, non-data file payloads). Documented in the README.Verification tiers
issue-144-live, created and expired per run):generateText(text +finishReason=stop+ usage),generateObject(schema-decoded object round-trip),streamText(text deltas + finish part), and error taxonomy (bogus token → real 401 →HttpResponseErrorclassifiedauth).errorparts, abort-signal firing on fiber interruption, schema round-trips, and sandbox acquire/release semantics including release-on-interrupt.CoderTransportfake, not a live workspace — live provisioning costs minutes of workspace churn on dev.coder.com and the acquisition path is the sandbox package's own (already-released)ensureCoderWorkspace.Repo touches outside
packages/effect.github/workflows/pr-title.yml: addedeffectto the allowed scopes (this PR's own title uses it).pnpm-workspace.yaml: explicitmsgpackr-extract: falsebuild-script denial (optional native accelerator pulled in transitively by@effect/ai's type peers; never loaded at runtime).README.md: one experimental-package pointer line.📋 Phase 1 checklist mapping (issue #144)
packages/effectscaffold (private, excluded from release-please until graduation)LanguageModelimplementation over@coder/ai-sdk-provider(AI Gateway): Prompt/Response mapping + typedAiErrormapping for HTTP errors (closed-union delta above)Layers for workspace sandbox lifecycle (ensureCoderWorkspace+ session asEffect.acquireRelease)Generated with
mux• Model:anthropic:claude-fable-5• Thinking:xhigh