Repository navigation
Remove link/dynamicLinks from core (Phase 1 of dynamic-link extraction) - #126
Merged
Merged
Conversation
Proposal only, nothing implemented. Sequences the two extractions (link first, middleware second) around the shared extension mechanism already in src/extensions.ts (mount ownership + authorize()), and flags the cross-repo dependency on urlcode-auth/-admin/-ui that a middleware contract change would introduce. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
License Apache-2.0 and repo settings mirror core's GOVERNANCE.md; both new extension repos publish public from the start rather than the private-until-reviewed pattern auth/admin/ui used. Adds a performance section (link's extensionResponse overhead on a latency-sensitive path; middleware's sandbox-vs-trusted-code tradeoff hiding inside what looks like a speed question) and rules out other core handlers as extraction candidates (proxy, policies, native routing, management/grants). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
Same spike doc: unlike link/middleware (which shrink core), a static compile target (S3/CloudFront) extends the progression below core without touching it, reusing the existing per-target capability refusal mechanism. Flags GitHub Pages' lack of server-side redirects as a real fidelity gap rather than promising parity it can't deliver. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
middleware is project-authored guest code in the same threat category as function (docs/FUNCTION-SECURITY.md), not a lighter-weight sibling of auth's trusted authorize() hook. urlcode-middleware keeps its own sandboxed execution; auth's trusted-extension model stays reserved for vetted, operator-installed packages. Reframes the sandbox's real performance cost (paid on every request, not once per route like function) as a reason to shrink how much needs to be guest code via native declarative primitives, not a reason to drop isolation. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
Maintainer decision, not yet implemented: sandboxing becomes opt-in (explicit sandbox: true) rather than the current unconditional default. Documents what this reverses (AGENTS.md, SECURITY.md, FUNCTION-SECURITY.md, SANDBOX-REVIEW.md, README.md all currently state the opposite as an absolute guarantee), what actually needs building (no in-process execution path exists today, it's fully hardwired to the sandbox), and the test/docs/capacity rework this requires before it ships. Recommends landing this ahead of the middleware extraction in SPIKE-CORE-LAYERING.md, since it changes that spike's assumptions. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
Express/Next.js/Django/Rails all serve AI-agent-generated code unsandboxed in production; the industry's actual sandboxing pattern for AI-written code is generation-time (E2B, Modal, Code Interpreter), not serve-time. Records this as supporting evidence for the decision already made, not a re-opening of it. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
Covers auth/admin/ui (contract unaffected, but their own docs/examples may need an audit for now-inaccurate sandboxing claims), versioning (this is a behavior change needing a major/minor bump and explicit peers.json pinning, not silent inheritance), dynamic-link (unaffected), and middleware (directly affected, with an open question on whether it should inherit trusted-by-default or deliberately stay sandboxed given it wraps every request through a route rather than one operation). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
Maintainer decision: no special case for middleware despite its wider per-request blast radius versus function — same rule, same opt-in sandbox mechanism. Marks SPIKE-DEFAULT-TRUST-MODEL.md's middleware question as resolved and corrects SPIKE-CORE-LAYERING.md's sections that still assumed middleware stays sandboxed by default (mechanism choice, sequencing, and the performance analysis), pointing them at the trust-model doc instead of re-arguing settled ground. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
Phase 1 of moving link/dynamic-links out of core, per docs/SPIKE-CORE-LAYERING.md: delete the native `link` route handler, the `dynamicLinks` project flag, the SQLite link store, its CLI, management API and observability wiring, with no deprecation shim (pre-1.0, 0.4.0-alpha.1, hard break). Stored short links move to a future `urlcode-dynamic-link` extension package (Phase 2, out of scope here). - src/types.ts, schemas/urlcode.schema.json, src/router.ts, src/config.ts: remove LinkConfig, RouteConfig.link, ProjectDocument.dynamicLinks and their compile-time/schema surface. - src/runtime.ts, src/server.ts: remove link-store binding options, the per-request route.link branch, and the link-event observer wiring. - Delete src/link-store.ts, src/link-store-worker.ts, src/link-api.ts, src/link-cli.ts, src/link-events.ts, src/link-records.ts, src/management-policy.ts, src/sqlite-version.ts (confirmed nothing else depends on them). - src/capabilities.ts: make extension/policies.extensions capability analysis extension-target-aware. decision() previously gave a blanket native/refused answer regardless of the specific registered extension's own `targets` (src/extensions.ts). analyzeProjectCapabilities/ analyzeCompiledCapabilities now accept an optional resolved extension registration set (the same shape --host-file loads) and report per-extension refusal from its actual targets; without one, they report conditional/unknown instead of a false native. Wired through runtime.ts (options.extensions), tooling.ts, explain.ts and manifest.ts. - Strip dead dynamicLinks/route.link branches from policy.ts, readiness.ts, compliance.ts, compliance-rules/*, manifest.ts, capability-query.ts, context.ts, cli.ts (including the `links` CLI dispatch and its options). - Bump MANIFEST_SCHEMA_VERSION and observability SNAPSHOT_VERSION (shape changed: link-store fields and link_* events are gone). - Docs: remove docs/DYNAMIC-LINKS.md, docs/links/*.md, docs/yaml/links.md, docs/MANAGEMENT-SECURITY.md; update YAML-REFERENCE.md (generated), SPECIFICATION.md, CAPABILITIES.md, EXTENSIONS.md, OPERATIONS.md, CAPACITY.md, README.md, ROADMAP.md and the authoring/operations skills to reflect the removal and note the future urlcode-dynamic-link package. - examples/live-links removed; starters/default/urlcode.yaml drops its explicit `dynamicLinks: false`. - CI: drop the live-links container smoke test and the disk-full-dir drill (both link-store specific); scripts/operational-drills.ts keeps its mixed native/function load, invalid-reload and rollback proof. - Tests: remove/rewrite test/links.test.ts, test/link-store-worker.test.ts, test/link-records.test.ts and every other test file referencing dynamicLinks/link-store; add a capabilities.test.ts case covering the new per-extension-target refusal logic (synthetic registration with targets: ['node'], refused on aws/vercel, native on self-hosted, conditional/unknown without a registration). Verified: npm run lint, npm run typecheck, npm run check, npm run build, npm test (464 tests, 462 pass, 2 skipped, 0 fail) and npm run test:package all pass. `urlcode capabilities --target cloudflare|aws|vercel` no longer lists link/dynamicLinks as capability names. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
…target Main gained PR #125 (static compile target for S3/CloudFront) while this branch was in flight; that work independently referenced link/dynamicLinks in several places (capability refusal reasons, recipe/example metadata, docs, exports). Resolved by keeping this branch's removal and combining it with the static-target additions: - src/capabilities.ts: kept the extension-target-aware decision() logic and added the target==='static' early-refusal branch (staticRefusals lookup) ahead of it; dropped link/dynamicLinks from staticRefusals. - src/build-static.ts: fixed a stale comment listing link/dynamicLinks among refused capabilities. - test/static.test.ts: removed the link-specific sub-test (dynamicLinks/link route no longer exist); kept the function/middleware refusal coverage. - test/exports.test.ts: kept buildStatic in the expected export list, dropped openLinkStore/startLinkApi. - recipes/authenticated-json-api, recipes/protected-download, examples/extensions: merged this branch's conditional/refused target verdicts (extension-target-aware, no host file) with main's added `static: refused` key. - docs/CAPABILITIES.md, docs/FRAMEWORK.md, docs/STATIC.md, llms.txt: merged the static-target documentation with this branch's link-removal notes; fixed the framework ladder's rung numbering after removing the "Live short links" rung; regenerated llms-full.txt. - README.md, docs/README.md: took main's urlcode-shortener -> urlcode-short rename and updated extension package versions, combined with this branch's note that the shortener demo predates the link-store removal. - examples/live-links/example.yaml: kept deleted (main only added a `static: refused` entry to a file this branch removes entirely). - schemas/recipe.schema.json: dropped the now-unused `link-store` grant kind from the recipe metadata schema (no recipe declares it after this removal). Verified after the merge: npm run lint, typecheck, check, build all pass; npm test passes 471 tests (469 pass, 2 skipped, 0 fail, including the new static-target tests from main). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
jimhoyd
pushed a commit
that referenced
this pull request
Sep 19, 2026
main advanced with the static target (#125) and link/dynamicLinks extraction (#126) while this branch was in progress. Resolved conflicts in src/capabilities.ts and src/runtime.ts by keeping this branch's trusted-by-default logic and dropping the now-removed link-store wiring; combined doc wording from both sides in README.md, docs/CAPACITY.md, docs/PROJECT-DIRECTION.md and docs/RELEASE-READINESS.md; regenerated the two generated files (starters/default/AGENTS.md via renderAgentsGuide, llms-full.txt via scripts/build-llms-full.ts) rather than hand-editing them; updated test/explain.test.ts to match. Also tightened the static target's middleware refusal reason ("no server, so no middleware execution", dropping the now-stale word "sandboxed") since it no longer applies uniquely under the new default. Verified post-merge: typecheck, lint, npm run check, full test suite (481 tests: 479 pass, 0 fail, 2 skipped), build, test:package all green. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
6 tasks done
jimhoyd
added a commit
that referenced
this pull request
Sep 19, 2026
…concile docs (#143) * Fix trusted function body buffering, deadline timers and HEAD length TrustedFunctions read a route's Response body via a single .arrayBuffer()/ skip-for-HEAD call, which: - Buffered the whole stream into memory before checking it against maxBytes, so a configured limit only ever rejected after an oversized body had already been fully read (#137). A deadline timeout left the stream being consumed in the background instead of cancelling it. - Left every call's setTimeout() running uncleared once the call's own promise won the race, unref()'d but never cleared, so completed calls accumulated live Timeout resources for the life of the configured timeout (#138). - Never read the body at all for HEAD requests, always reporting an empty body and therefore a false Content-Length: 0 even when the equivalent GET response had a real body (#139). execute() now threads an AbortController through the call: its signal aborts when the deadline timer fires, and the timer itself is cleared in a finally covering both race outcomes. invoke() reads the body through a new readBody() that pulls the stream incrementally via getReader(), counting bytes per chunk and cancelling the reader as soon as maxBytes is exceeded or the deadline's abort signal fires, on every path including HEAD. HEAD now measures the real body the same way GET does (matching the existing native/asset-path convention of always determining the full body+length and letting http-response.ts's prepareResponse decide not to put it on the wire for HEAD), rather than skipping the read and reporting zero. This surfaced a stale assumption in the cache-revalidation policy: it special-cased "a function's HEAD answer has no body to hash" to avoid asserting an ETag it couldn't actually verify — an assumption that only held because of the #139 bug. Now that HEAD carries the real measured body, it hashes to the same ETag as GET, consistent with how a respond route's HEAD already behaved; only the comment there needed correcting, the guard itself (skip when a HEAD answer genuinely has no body) is unchanged. Added regression tests reproducing each issue's exact repro shape and verified failing on unmodified code before the fix: incremental maxBytes cancellation (stream cut off after ~2 of 20 chunks, not all 20), deadline-triggered cancellation of an in-flight read, a node:async_hooks Timeout-leak check over 100 sequential calls (100 live timers before the fix, 0 after), and wire-level HEAD Content-Length coverage for both a plain and a middleware-transformed response. Fixes #137 Fixes #138 Fixes #139 Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr * Reconcile trusted-mode docs and release-readiness claims with reality No behavior change; precision/consistency fixes surfaced by an independent review of the trusted-by-default execution change: - SECURITY.md and docs/FUNCTION-SECURITY.md described env/secrets as route-granted in a way readable as an access-control guarantee on trusted Node code. Made explicit that this is a claim about what URLCode injects into context/context.secrets, not a restriction on what trusted (non-sandbox) code can independently do — that code has full Node access by design, so it can reach process.env, the filesystem or the network regardless of what its route was granted. The trust-model decision itself is unchanged; this only states its actual boundary precisely instead of implying a narrower one. - docs/FUNCTION-SECURITY.md said "every config/module change invalidates a grant" in one place while separately noting a trusted route's transitive dependencies are not hashed for grant-invalidation purposes — contradictory on a careful read. Made the entry-file-only scope for a trusted route (vs. full-dependency-graph for a sandboxed one) explicit and consistent everywhere grant invalidation is discussed. - docs/AI-AUTHORING.md's "Deciding when a route needs sandbox: true" led with "untrusted webhook data" as the motivating example, readable as implying webhooks specifically need sandboxing. Reframed: all public HTTP input is untrusted regardless of trust mode (a separate axis from whether the code processing it is trusted or sandboxed); sandboxing limits what the executing code can reach, it is not a substitute for validating/authenticating input. A route can receive webhooks and stay trusted if its own code is reviewed and handles input carefully. - docs/RELEASE-READINESS.md still listed store/persistence/management- queue functionality that PR #126 removed from core (link/dynamicLinks extraction), fixed the version reference (package.json is actually 0.4.0-alpha.2, not alpha.1), and corrected the npm-publish claim after actually checking: `npm view @jimhoyd/urlcode` shows 0.3.0 published as `latest` and 0.4.0-alpha.1 published under the `alpha` dist-tag, so "no published npm release" was flatly wrong, not just imprecise; Homebrew is a formula GitHub Releases attach for manual copy into a tap, not an automated publish, stated as such rather than lumped in with npm. - docs/OPERATIONAL-PROOF.md said CI covers six Node/OS combinations; checked .github/workflows/ci.yml and corrected to the actual matrix — nine combinations (3 Node x 3 OS) on a push to main, but a pull request runs only the three Node versions on Linux, with macOS/Windows deferred to the post-merge run. Regenerated llms-full.txt (npm run docs:llms) since it derives from the docs touched here. Fixes #140 Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr --------- Co-authored-by: Claude <[email protected]>
2 tasks done
jimhoyd
added a commit
that referenced
this pull request
Sep 19, 2026
SPIKE-BUSINESS-SUITE.md, SPIKE-EXTENSIONS.md and SPIKE-CORE-LAYERING.md were written before link/dynamicLinks was extracted from core to the separate urlcode-dynamic-link package (#126). Add brief update notes at each doc's top pointing stale link/LinkStore mentions to their new home, without rewriting the historical planning content. Fixes #128 (item 1). Items 2 and 3 from that issue were addressed elsewhere: urlcode-short was migrated to @jimhoyd/urlcode-dynamic-link in a separate PR, and urlcode-auth/urlcode-admin/urlcode-ui's targets declarations were already verified correct against origin/main. Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr Co-authored-by: Claude <[email protected]>
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.
Problem and change
Phase 1 of "move
link/dynamic-links out of core", per the layering plan indocs/SPIKE-CORE-LAYERING.md.Phase 1 is core-only: remove
linkas a native route handler entirely.Phase 2 (a new
urlcode-dynamic-linkextension package) is explicitly out ofscope — that repo does not exist yet.
This is a hard break (pre-1.0,
0.4.0-alpha.1, no backwards-compat shimper project ethos): a project declaring
link/dynamicLinkswill failschema validation until the future
urlcode-dynamic-linkextension ships.What changed
LinkConfig,RouteConfig.link,ProjectDocument.dynamicLinks,LinkStoreBinding/LinkReader,TestPlan.dynamicLinksfromsrc/types.ts; removedlinkfrom the routehandler
oneOfand the top-leveldynamicLinksproperty inschemas/urlcode.schema.json; removed the compile-timeconfig.linkblockfrom
src/router.ts; removed thedynamicLinksroute-requirement assertionand its fold into the project hash from
src/config.ts.per-request
route.linkbranch and the link-event observer wiring fromsrc/runtime.ts/src/server.ts. Deletedsrc/link-store.ts,src/link-store-worker.ts,src/link-api.ts,src/link-cli.ts,src/link-events.ts,src/link-records.ts,src/management-policy.ts,src/sqlite-version.ts— confirmed nothing else depends on them beforedeleting.
src/capabilities.ts'sdecision()used to give a blanket native/refusedanswer for
extension/policies.extensionswithout consulting the specificregistered extension's own
targets(RuntimeExtension.targets,src/extensions.ts).analyzeProjectCapabilities/analyzeCompiledCapabilitiesnow accept an optional resolved extension registration set (the same shape
--host-fileloads forinspectExtensions) and report per-extensionrefused/nativefrom its actual declared targets; without one, theyreport
conditional/unknowninstead of a falsenative. Wired throughruntime.ts(options.extensions),tooling.ts,explain.tsandmanifest.ts. Removed the now-deadlink/dynamicLinksspecial case.src/policy.ts,src/readiness.ts,src/compliance.ts,src/compliance-rules/*,src/manifest.ts,src/capability-query.ts,src/context.ts,src/cli.ts(including thelinksCLI dispatch and its--link-store/--link-readers/etc. options).MANIFEST_SCHEMA_VERSION1→2 and observabilitySNAPSHOT_VERSION1→2, since the manifest/metrics shape changed(link-store fields and
link_*/management_requestevents removed).docs/DYNAMIC-LINKS.md,docs/links/*.md,docs/yaml/links.md,docs/MANAGEMENT-SECURITY.md(all link-specific);updated
docs/YAML-REFERENCE.md(regenerated),docs/SPECIFICATION.md,docs/CAPABILITIES.md,docs/EXTENSIONS.md(notes the futureurlcode-dynamic-linkmount-based extension),docs/OPERATIONS.md,docs/CAPACITY.md,README.md,ROADMAP.md, plus a broad sweep of theother docs and the bundled authoring/operations skills that referenced the
removed handler, flag, CLI or events.
examples/live-links/*; dropped the explicitdynamicLinks: falsefromstarters/default/urlcode.yaml; regeneratedstarters/default/AGENTS.md.drill (both link-store specific) from
.github/workflows/ci.yml;scripts/operational-drills.tskeeps its mixed native/function load,invalid-reload and rollback proof, with the SQLite backup/restore and
disk-exhaustion sections removed (core no longer owns durable state).
test/links.test.ts,test/link-store-worker.test.ts,test/link-records.test.ts; rewrote every other test file that referenceddynamicLinks/link-store (capabilities,cloudflare,compliance-rules,compliance,config,context,exports,manifest,monitoring,route-diff,scaffold,vercel,capability-query,cli,explain,extensions,observability,recipes); added a new capabilities testcovering the per-extension-target refusal fix (a synthetic registration
with
targets: ['node']isrefusedon aws/vercel,nativeonself-hosted, and
conditional/unknownwithout a registration at all).Updated three recipe/example metadata files whose hand-written
targetsverdicts were stale under the new conditional-without-a-host-file behavior.
Verification
Confirmed
urlcode capabilities --target cloudflare|aws|vercelno longerlists
link/dynamicLinksas capability names, and the newcapabilities.test.tscase exercises the per-extension-target refusal logicdirectly.
Compatibility and security
Hard break, intentional per pre-1.0 project ethos: any project using
link/dynamicLinksfails schema validation until the futureurlcode-dynamic-linkextension package exists. No deprecation shim wasadded.
No new operator grants, bindings or capabilities are introduced. The
capability-analysis fix is additive reporting only — it does not change
what an extension implements, only what core reports about a target it
hasn't resolved a registration for.
urlcode-auth/urlcode-admin/urlcode-uiare unaffected in contractterms per
docs/SPIKE-CORE-LAYERING.md's analysis, but that analysis isreasoned from documented contract, not verified against their source in
this session (those repos are not attached here).
The
urlcode-short(shortener) demo repo referenced fromREADME.mdpredates this removal and will need to migrate once
urlcode-dynamic-linkships; flagged in the README rather than silentlyleft inaccurate.
Changes match the documented portable contract; docs/examples are updated where needed.
Relevant tests and package checks pass (see Verification above).
No credentials, customer data or private project material are included.
Runtime/starter changes remain aligned (starter
urlcode.yamland generatedAGENTS.mdupdated together).🤖 Generated with Claude Code
https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
Generated by Claude Code