Repository navigation
Make packages.invokeChecked an edge case; bound per-call platform overhead - #1040
Closed
kentcdodds wants to merge 4 commits into
Closed
kentcdodds wants to merge 4 commits into
kentcdodds wants to merge 4 commits into
Conversation
Flip agent-facing defaults so ordinary package reuse goes through static imports. Dynamic invokeChecked stays for fresh-version and target-runtime edge cases across MCP instructions, search entity detail, and usage docs. Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Cut sequential D1/KV work on the remaining dynamic path: kind-aware package resolve, short-TTL source-row cache, published-artifact isolate cache, insert-first idempotency claims, and waitUntil metering. Add the systemic per-call overhead recommendation for multi-user growth. Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Cache only successful KV artifact payloads by kvKey, invalidate on persist and identity mismatch, and keep D1 identity rows authoritative for commit checks. Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Revert the source-row cache (published_commit freshness is the current-version contract), scope insert-first idempotency claims to fresh execute-origin UUID keys so replay-heavy callers keep read-first, restore invokeChecked as the post-approval secret smoke test, and add trust-boundary framing plus a trade-off analysis to the overhead doc. Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
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.
Summary
Live probes after #1035 still show ~600–1100 ms of platform overhead per
packages.invoke/invokeCheckedcall for a trivial export, while a statickody:@scope/pkg/exportimport costs ~0 ms per call after bundling. Month-to-date Analytics Engine (kody_usage_events) showspackage_exportaveraging ~4.3 s with ~75% of samples ≥ 700 ms — nested dynamic runs are expensive at scale.This PR flips agent-facing defaults to static imports first, cheapens the remaining warm dynamic path, and documents systemic D1/observability budgets so overhead does not multiply unchecked as user count grows.
Measurements (part 1)
In-sandbox probe (
github/accounts, heykody.dev, this session):packages.invokepackages.invokeCheckedAnalytics Engine (UTC month-to-date, success, weighted by
_sample_interval):executepackage_exportUse dynamic invoke only when you need: fresh published-export semantics without republishing the caller; target-package runtime (
packageContext/packageSecrets/ nestedpackages); or mediated cross-package storage. Otherwise static import is equivalent for library-like reuse (andpackageStorage()still works via bundler provenance).Guidance flip (part 2)
## Import vs invoke(static first) + per-exportPrefer:static snippetdocs/use/execute.md,docs/use/packages.md, package lifecycle/authoring/integration guidesCheapening (part 3)
resolveSavedPackage(one D1 hit forkodyId)package_exportmetering viawaitUntilwhen availableSystemic recommendation
See
docs/contributing/per-call-platform-overhead.md:invoke*kody_usage_eventspackage_exportavg and ≥700 ms share, and theexecute:package_exportvolume ratiousers × calls— require a budget note in PRsSystem recap — extends existing primitives (medium risk)
Mode: recap · Base:
main@05e1f2f5· Head:b2a974c8Classification: extends — agent-facing MCP/search guidance and warm
package-invoke hot-path caching/claim ordering change; no new primitives.
Primitives touched
mcp-serversaved-packagesbundle-artifacts-kvcapabilities-executeSystem map
Agents discover packages through MCP search/execute; this PR steers them to
static
kody:@imports and cheapens the remaining dynamic invoke path's D1/KVhops.
Legend: green = composes (wiring only) · amber = extended by this PR · red =
new primitive · gray = context (unchanged, included only when an edge crosses
it).
Before / after
Agent default
Warm invokeChecked
Invariants
Per-user isolation unchanged: package resolve, idempotency rows, artifact KV
keys, and usage events remain scoped by
userId.