Repository navigation
Description
Problem or use case
A route that must answer differently depending on live, operator-owned application state currently has no native path in URLCode — only the sandboxed-function/bounded-HTTPS-proxy path, which means "proxy the whole request to a real backend," never "URLCode answers it directly." This shows up as the same wall across three independent projects sketched for a URLCode port:
peer-camera's/resolveroute: share-token resolution against Postgres, where "what it resolves to depends on the moment it is opened" (a standing-invite's answer changes based on whether the host is live right now).peer-eyes's port-spike row 7 (share tokens / "Window bearer link"): the same token-validity/rotation lookup, same wall.place-page'sbackend/app/routers/public.py: unauthenticated, cached, read-only lookups of a Place/Page by id — architecturally a hand-rolled version of exactly this pattern (cache.get_or_set, 60s TTL, "cached... since this is open to unauthenticated traffic").
Three unrelated products hitting the identical requirement is the actual signal here, not a single feature ask.
This is not starting from zero. URLCode already built almost exactly this, scoped to one record shape: the link/linkStore subsystem (docs/DYNAMIC-LINKS.md, src/link-store.ts, src/link-records.ts). A link route does a read-through lookup against operator-owned SQLite (or any LinkReader) at native speed, outside the sandbox entirely, with separate reader/writer pools, record caps, backups, an authenticated management API, audit logging, and an explicit dynamicLinks: true opt-in. The LinkReader/LinkLookup interface in src/runtime.ts is:
interface LinkReader { get(collection: string, code: string): Promise<LinkLookup | null | undefined>; readonly readHealthy?: boolean }
interface LinkLookup { url?: unknown; status?: unknown; enabled?: unknown; expires?: unknown }The gap is that LinkLookup is hardcoded to a redirect-target shape. The three use cases above need the same read-through mechanism with a different, operator-defined bounded-JSON payload — not a redirect every time.
Proposed behavior and alternatives
Not proposing a specific final design yet — this needs a scoping decision before it's implementable, and I'd rather name the open questions than invent an answer:
- What does a lookup produce? A
linkroute always yields a redirect. The three real cases need different shapes: a full rendered response (peer-camera's resolve, which has valid/expired/different-state outcomes), cached JSON (place-page's public API), a validity check a function then branches on (peer-eyes bearer link). Does this become a new handler type, a bindingfunctionroutes can read from, or a family of the two? - Where does it belong? Given the auth/admin/ui extension model (trusted, revision-pinned doors to operator infrastructure), this may fit better as an extension capability than core routing — core's
link/linkStoreis already somewhat separate, gated machinery inside core rather than a general route feature. - How does it stay a security boundary, not a backdoor. The sandbox having no filesystem/DB/network is a stated hard invariant (never a host-code execution fallback). Whatever this becomes must stay strictly read-only, bounded, and schema-constrained per binding — the discipline
linkStorealready has (fixed shape, explicit opt-in, its own management API) — not slide into "functions can query a database."
Alternatives: leave this permanently out of scope and require every such case to proxy to a real backend (the status quo). Reasonable as a deliberate answer, but worth deciding explicitly given three independent projects now hit it, rather than leaving it an unstated gap each time.
Portability/security: whatever shape this takes should preserve everything linkStore already guarantees — operator-owned storage only, explicit per-project opt-in, bounded record/response size, no relaxation of the "application code is untrusted" boundary.
Activity
jimhoyd commentedon Sep 19, 2026
Revisiting after two changes on
mainthat both undercut this issue's premise:link/linkStore(src/link-store.ts,LinkReader/LinkLookup) no longer exists in core — it's been removed as Phase 1 of the dynamic-link extraction (per the referenced spike work). There's no more in-core "native read-through lookup" mechanism to generalize.function/middlewareexecution (Trusted-by-default function/middleware execution, sandbox as opt-in #127,docs/SPIKE-DEFAULT-TRUST-MODEL.md), a route can just be ordinary Node code with a real database driver (e.g.pg), granted aDATABASE_URL-style secret through the existing operator binding-grant mechanism — the same shape as any other trusted function. That covers thepeer-camera/peer-eyes/place-pagecases this issue cited as evidence, without a new binding-type/handler-type concept.So the specific ask (generalize
LinkLookupinto a bounded read-through data binding) is superseded rather than still needed — closing as not planned. If a narrower, still-relevant version of this surfaces (e.g. somethinglink-extraction-specific once that lands as its own package), it's probably a fresh issue against the dynamic-link extension rather than a reopen of this one, since the core mechanism it was about no longer exists.Generated by Claude Code