feat(runtime): add generator-based runtime for the generator context pattern - #4
Merged
Conversation
…pattern Workflows request dependencies on demand via `yield*` instead of having them threaded through every function signature. `createRuntime<Context>()` returns `action` to define context-dependent operations, `call` and `provide` to compose workflows, and `run` to execute one against a real or mocked context. `Workflow<Return, Context>` carries the context type so the compiler keeps workflows from different runtimes apart, and `call`/`provide` operations are single-use since they own the generator instance they were given. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
jhnns
force-pushed
the
generator-context-toolkit
branch
from
August 3, 2026 09:19
3f5992c to
70132f1
Compare
These four failures predate this branch — `main` has been red on the "Test and Release" workflow since 94af6d7. `run-p` aborts siblings on the first failure, so only `test:jsr` surfaced in the logs. - test:jsr: `parseRetryAfter`'s `now` parameter had no explicit type, which JSR's no-slow-types check rejects for public API symbols. - test:types: `lib` lost `dom` when it moved to es2024, so `RequestInfo` (src/api/api.test.ts) and `VoidFunction` (@tanstack/query-core's .d.ts, checked because skipLibCheck is false) no longer resolved. Emitted output is byte-identical with and without `dom`, so this is typecheck-only. - test:lint: `no-redundant-type-constituents` fired on the unresolved `RequestInfo`; fixed by the same `lib` change. - test:build: `sleep` grew to 180 B in a6b60a3 without its limit or README claim being updated. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
Author
|
Closes #1 |
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.
Adds a new
runtimeutility implementing the generator context pattern:createRuntime<Context>()returnsactionto define context-dependent operations,call/provideto compose workflows, andrunto execute one against a real or mocked context, so workflows request dependencies viayield*instead of threading them through every signature.Workflow<Return, Context>carries the context type, so passing a workflow to a runtime that can't supply its dependencies is a compile error rather than a silentundefinedat runtime;call/provideoperations are single-use and throw on a secondyield*, since they own the generator instance they were given.Ships at 356 B brotli (375 B budget) with the usual README,
package.json/jsr.jsonexports,.size-limit.jsonentry, and 18 tests including@ts-expect-errorcases pinning the cross-runtime type checks.The single-use guard uses a small internal
singleUsehelper inruntime.lib.tsrather thanconcurrency/exactlyOnce, which is async-only and carries a passivepromiseproperty — more than this needs, and more bytes than the budget allows.🤖 Generated with Claude Code