-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(core): BaseContext.ext / RequestEnv.ext plugin slot (SEP-2133 mechanism) #2061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
felixweinberger
wants to merge
3
commits into
fweinberger/s1-sessionid-opt
from
fweinberger/s2-ext-slot
+12
−2
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
b2c7792
feat(core): BaseContext.ext / RequestEnv.ext plugin slot (SEP-2133 me…
felixweinberger 6879b2f
chore(core): drop unused readExt helper and its public export
felixweinberger 06673f2
docs(core): fix typedoc link to private Protocol.use in BaseContext.ext
felixweinberger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 nit: per CLAUDE.md "JSDoc @example Code Snippets",
@exampleblocks should use```ts source="./file.examples.ts#region"fences sopnpm sync:snippetskeeps them type-checked — every other@exampleinpackages/core/srcfollows this, but this one is an inline fence referencing symbols (env,id,store,taskContext) that do not exist yet (tasksPlugin ships in F3). Consider either rewriting the example aroundreadExt()(which this PR does export) in acontext.examples.ts//#region, or dropping the@exampletag until F3 lands so the snippet can be sourced and type-checked.Extended reasoning...
What this is
CLAUDE.md:44-48 documents the repo's
@exampleconvention:The new
@exampleonBaseContext.ext(context.ts:188-194) uses a bare```tsfence with nosource=attribute and no companionpackages/core/src/shared/context.examples.tsfile, sosync:snippetscan never validate it.Why it matters here specifically
Grepping
packages/core/srcfor@exampleshows this is the only un-sourced example in the core package —sdkErrors.ts,index.ts,protocol.ts,specTypeSchema.ts, and everyvalidators/*.tsexample all usesource="./*.examples.ts#region"with a matching companion file (8.examples.tsfiles exist underpackages/core/src). So within core the convention is uniformly followed today, and this PR introduces the first divergence.More substantively, the snippet references
env,id,store, andtaskContext(ctx). Per the PR description,tasksPlugin/taskContextship in F3, not this PR — so the example is forward-referencing API that doesn't exist yet and cannot be type-checked today even if a.examples.tswere added. That is exactly the drift the sourced-example convention is meant to prevent: if F3's eventual API differs (different key, different accessor name), this doc comment silently rots.Step-by-step
@examplefences should carrysource="./file.examples.ts#regionName".ls packages/core/src/shared/*.examples.ts→ onlyprotocol.examples.ts; nocontext.examples.ts.grep -r "@example" packages/core/src→ every hit (sdkErrors.ts:46, validators/types.ts:38, validators/cfWorkerProvider.ts:22/27, validators/fromJsonSchema.ts:18, validators/ajvProvider.ts:25/30/46+, index.ts:44/49, shared/protocol.ts) hassource=on the next line. context.ts:188 does not.taskContext(ctx);grep -r "export function taskContext" packages/→ no matches (it's slated for F3).pnpm sync:snippetsignores, and it references not-yet-existing API.Addressing the "there are other inline examples" objection
It's true a handful of inline
@exampleblocks exist elsewhere in the monorepo (packages/server/src/validators/cfWorker.ts:4,packages/middleware/express/src/auth/metadataRouter.ts:143,packages/server/src/experimental/tasks/server.ts:84/181). However: (a) none of those are inpackages/core, where the convention is currently 100% consistent, and (b) those stragglers reference real, in-tree symbols, whereas this snippet references API from a future PR. The combination of "first inline example in core" + "references unshipped symbols" is what makes it worth a nit — not the bare style point on its own.Suggested fix
Either:
packages/core/src/shared/context.examples.ts:```ts source="./context.examples.ts#BaseContext_ext_read"; or@exampleblock until F3 landstaskContext, then add a sourced example.Severity
nit — this is a documentation-convention issue, not a runtime or type-correctness bug.
sync:snippets --checkignores fences withoutsource=, so CI does not fail on it.