Skip to content

[Request]: generalize dynamicLinks/linkStore into a read-through data binding beyond redirect targets #133

Closed as not planned

Description

@jimhoyd

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 /resolve route: 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's backend/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:

  1. What does a lookup produce? A link route 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 binding function routes can read from, or a family of the two?
  2. 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/linkStore is already somewhat separate, gated machinery inside core rather than a general route feature.
  3. 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 linkStore already 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

  1. added
    enhancement
    on Sep 19, 2026
  2. jimhoyd commented on Sep 19, 2026

    @jimhoyd
    CollaboratorAuthor

    Revisiting after two changes on main that both undercut this issue's premise:

    1. The precedent this issue was built on is gone. 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.
    2. The underlying problem (a route answering based on live, operator-owned state) is now solved a different way. With trusted-by-default function/middleware execution (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 a DATABASE_URL-style secret through the existing operator binding-grant mechanism — the same shape as any other trusted function. That covers the peer-camera/peer-eyes/place-page cases this issue cited as evidence, without a new binding-type/handler-type concept.

    So the specific ask (generalize LinkLookup into 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. something link-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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions