[codex] prototype default global scope#183
Conversation
…scope-prototype # Conflicts: # src/Abort.test.ts # src/Abort.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 626a37a5e8
ℹ️ 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".
| (_: infer A): void | ||
| (_: infer B): void | ||
| (_: infer C): void | ||
| (_: infer D): void | ||
| } ? A | B | C | D |
There was a problem hiding this comment.
Remove four-signature cap in YieldOutput union extraction
YieldOutputUnion only infers up to four callable signatures, so scopes composed from five or more Yielding<...> protocols silently lose at least one output variant at the type level. In practice this makes yieldFrom(scope, value) reject valid payloads (or mis-type handlers) once a scope carries >4 protocols, even though runtime behavior still supports them. This regression is introduced by the fixed-arity conditional and can be reproduced with a string & Yielding<A> & ... & Yielding<E> scope where one member drops from YieldOutput.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 290535c11c
ℹ️ 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".
| */ | ||
| export const collectFrom = <const Scope extends string & Yielding<unknown, void>>(scope: Scope) => | ||
| export const collectFrom = <const Scope extends string & AnyYielding>( | ||
| scope: YieldInput<Scope> extends void ? Scope : never |
There was a problem hiding this comment.
Reject bidirectional scopes in collectFrom
collectFrom is now gated by YieldInput<Scope> extends void, but YieldInput for multi-protocol scopes is computed as an intersection, so a mixed scope like Yielding<..., void> & Yielding<..., {reply: ...}> collapses to never and still passes this check (never extends void). In that case collectFrom will handle YieldFrom requests that actually require a response and return undefined at runtime, violating the typed request/response contract and causing downstream failures when the yielded result is used.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: efce671ed2
ℹ️ 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".
| export type YieldValue<E, Scope extends string & AnyYielding> = | ||
| E extends YieldFrom<Scope> ? YieldOutput<Scope> : never |
There was a problem hiding this comment.
Match YieldFrom by exact protocol set, not subtype scope
Using E extends YieldFrom<Scope> here lets a scope with extra Yielding<...> protocols be treated as the same scope because those branded types are structural supersets. In practice, collectFrom(oneProtocolScope) will also intercept YieldFrom effects emitted with a multi-protocol scope that shares the same runtime scope string, but the returned tuple is typed as if only YieldOutput<oneProtocolScope> can appear. That drops valid output variants from types and can break downstream exhaustive handling when multi-protocol scopes are composed on one runtime scope.
Useful? React with 👍 / 👎.
Summary
Prototype a default global scope as a real exported scope value rather than ambient runtime machinery.
Changes
GlobalScopeand export it from the public API, including the./GlobalScopepackage subpath.scope(),abort(),orReturn(value), andreturnFrom(value)while preserving explicit scoped forms.Yieldingphantom output typing so multiple protocols on the same runtime scope extract outputs as a union and inputs as an intersection.Validation
pnpm testpnpm typecheckpnpm buildpnpm lint