Skip to content

Reuse audit after #841: what URLCode still owns and what a package or a cut could remove #1041

Closed

Description

@jimhoyd

Follow-up to #841. #841 cut owned package source from 45,056 to 24,521 lines by adopting Better Auth, the MCP SDK and Ajv. Since then owned source grew to about 29.8k lines through the declarative store features and the hardening in #902 and #927–#1034. This audit asks, for every owned component, whether an existing package should own it instead. Four read-only audits ran against origin/main on 2026-09-30. Line counts are physical wc -l, and package facts come from npm view on that date. Host-lease code is excluded because it is being removed ("one server per database", in progress).

Verdict

The remaining owned code is mostly URLCode's contract: the declarative vocabulary, bounded parsers with exact refusals, request-smuggling and encoding guards, and sandbox isolation. Swapping in libraries would save about 2% (roughly 200 of 9,000 runtime lines, 150 of 7,560 tooling lines, and almost nothing in the store). Several obvious candidates would silently weaken guarantees:

  • Hono and the WHATWG Request normalize ../%2e/\ and merge repeated headers, which defeats RIM-INPUT-001 and the header-count refusals.
  • Kysely is async-only, which weakens the synchronous BEGIN IMMEDIATE transactions.
  • helmet, pino, http-cache-semantics and rate-limiter-flexible conflict with documented behaviour, or would not run in the Worker target.

Real reductions come from redesigns, tool swaps and scope cuts.

Ranked options

# Change Est. lines Kind What is lost
1 One serving process per database (in progress) large cut several servers sharing one database
2 Write audit rows in the store's own transaction; remove the audit outbox, drain, peek/ack and backoff; merge the two SQLite backup modules 500–700 redesign separate audit file and retention, and the generic audit producer API for third-party extensions
3 release-please (SHA-pinned) in place of release-bump.ts and the prepare step; dorny/paths-filter v4 (SHA-pinned) in place of most of ci-plan.ts, keeping fail-closed if: guards ~700 incl. tests package custom lane logic; adds third-party action supply-chain risk
4 remark-validate-links for local links and fragments; about 80 lines stay for the pinned blob/v<version> rules ~200 package (dev) none
5 Cut urlcode import/export (provider formats) ~235 + tests cut migrating from Netlify, Cloudflare or Vercel config
6 Cut urlcode-store ownerless-* ~60 + ~100 tests cut switching a populated shared collection to owned
7 Cut urlcode benchmark ~50 + flags cut the p95 CI gate
8 Cut verify --online and the tarball reader ~35 cut re-hashing the published tarball (lockfile hashes remain)
9 tough-cookie for the fixture cookie jar, after confirming it is Worker-safe ~75 package none if parity holds
10 ipaddr.js for CIDR matching in client-address.ts, with parity tests; keep egress.ts isPublicAddress owned ~50 package none if parity holds
11 Internal dedup: readBody in server.ts and vercel.ts; the reserved-header set in security.ts and http-policy.ts ~40 dedup none
12 McpServer high-level API in packages/mcp 60–120 package risk of leaking error messages and changed error semantics; not recommended

Rejected, with reasons in the audit reports:

  • store: Kysely, Drizzle, umzug, PocketBase, idempotency and etag libraries;
  • CLI: commander, citty and yargs; Hurl (binary postinstall) and newman;
  • runtime: Hono and @hono/node-server as the core; find-my-way/rou3, helmet, pino, prom-client, http-cache-semantics, negotiator, piscina (sandbox isolation must stay exact), the Better Auth admin and organization plugins, @better-auth/cli, size-limit and changesets.

Record in docs/FRAMEWORK.md "Ownership" that these were evaluated, so the question is not reopened each time.

Activity

  1. jimhoyd commented on Sep 30, 2026

    @jimhoyd
    CollaboratorAuthor

    Additional compatibility gaps from a source/doc review of main df0cfd5; keep these in this existing audit rather than opening a new umbrella:

    1. The default Better Auth adapter remains deliberately SQLite/password opinionated: betterAuthOptions spreads extra options then overwrites database with openAuthDatabase and forces emailAndPassword.enabled=true. Better Auth itself supports other database adapters. A caller cannot select those merely through betterAuth options today. Evaluate an explicitly separate bring-your-own-instance integration when needed; do not pretend the SQLite CLI, backups, leases or hermetic initialization work unchanged for arbitrary databases. Current local default remains valid.
    2. Embedded-host operational coverage is narrower than urlcode serve: proofs/ecosystem/README.md documents absent readiness/drain, admission/timeouts, request-event logging and StreamHost limits. These are hosting responsibilities, not automatically defects. Make the split visible in integration/review evidence and test a host implementing the necessary limits rather than assuming Request/Response compatibility supplies them.
    3. Provider replacement proves identity handoff, not feature equivalence. The Auth.js credentials proof explicitly lacks server-side session revocation and does not inventory all upstream endpoints. Any adoption decision must show supported/rejected capabilities and native provider operation metadata; do not silently infer revocation or full endpoint inspection from providesPrincipal=true.
    4. OpenAPI still models every principal provider as a placeholder cookie; a separate focused follow-up was filed because that is a concrete interoperability contract problem.

    These are remaining limits/design decisions, not a claim of new runtime security regressions. Direct npm compatibility, Hono hosting and alternate-principal integration already work. The just-merged #1042/#1043 address body-format compatibility and bounded dependency-review evidence; they do not claim complete installed-code attestation or a generic database backend.

  2. jimhoyd commented on Sep 30, 2026

    @jimhoyd
    CollaboratorAuthor

    Maintainer follow-up asks whether the contract is solid and how PostgreSQL projects will work. Current main df0cfd5 supports normal PostgreSQL libraries in trusted Node application code, but the bundled auth/store/audit persistence is SQLite-specific; there is no connection-string switch for declarative store parity.

    Recommended next portability proof, before freezing storage contracts: run the same owner-private records + reviewer transition + retry/idempotency scenario against real PostgreSQL, including concurrent connections, rollback and audit evidence. Keep identity/HTTP/schema contracts intact and database credentials/pools in operator configuration. Use existing upstream PostgreSQL support for Better Auth (it accepts pg.Pool); separate a bring-your-own auth-instance integration from the local SQLite initializer/CLI. Specify ownership of pool startup/shutdown, migrations and isolated test databases. Tests must never fall back to live application databases when isolation is unavailable.

    Distinguish native application-owned PostgreSQL/ORM use (already an ordinary trusted-code path) from promising URLCode store declarations on PostgreSQL (not implemented). Retain application vocabulary only where a backend can enforce its semantics; declare/refuse unsupported behavior rather than emulate SQLite internals or force every database through a raw CRUD facade. Do not promise cross-provider atomicity just because auth and app data share a PostgreSQL server.

    Also qualify the audit's rejection of Kysely: an asynchronous API does not by itself weaken transaction atomicity. The actual obstacle is integrating an asynchronous driver with today's synchronous store API and re-establishing the required isolation/locking/retry contract. PostgreSQL's default READ COMMITTED is not automatically equivalent to the current SQLite BEGIN IMMEDIATE behavior. A query builder alone does not solve that difference; evaluate with behavioral tests, not synchronous-versus-asynchronous syntax alone.

    Sources: https://better-auth.com/docs/adapters/postgresql and https://www.postgresql.org/docs/current/transaction-iso.html . This is proposed follow-up scope, not a PostgreSQL support claim or authorization for a broad implementation in this comment.

  3. jimhoyd commented on Sep 30, 2026

    @jimhoyd
    CollaboratorAuthor

    The maintainer clarified that storage belongs to the project owner; PostgreSQL was an example, not the next required backend. Dedicated scope is now #1052: native storage tools, optional integrations for declared behavior, and explicit supported guarantees. This supersedes the earlier PostgreSQL-first recommendation in this discussion. #837 remains on hold.

  4. jimhoyd commented on Sep 30, 2026

    @jimhoyd
    CollaboratorAuthor

    Maintainer clarification: owner choice applies to ALL extensions and integrations, not only storage. #1052 has been broadened into the consistent architecture requirement: optional bundled defaults, native upstream APIs, focused integrations only where URLCode semantics require them, independent packages, and explicit behavioral guarantees. SQLite/PostgreSQL/auth/framework examples are not a mandated shortlist. This does not resume #837 or require rebuilding retired extensions.

  5. jimhoyd commented on Oct 1, 2026

    @jimhoyd
    CollaboratorAuthor

    Follow-up bespoke-functionality audit on 2026-10-01, pinned to main 96543b7. This is fresh source/reproduction evidence, not a request to repeat the rejected library swaps in this issue.

    Physical source lines (comments/blanks included): core 23,955; auth 641; store 4,120; MCP 607; total 29,323. Separately, scripts contains 6,769 .ts/.js/.mjs lines. These are ownership/maintenance counts, not executable complexity, dead-code estimates or a deletion target.

    Current main already has the audit-package removal, shared incoming-body reader and operator lock helper, generated middleware copies, shared skill sections and shared fixture execution core. Do not reopen those completed cuts.

    New actionable findings:

    Remaining ownership decisions for the existing #1098 application-workflow evaluation:

    1. Add-on install/manifest/file verification plus source staging and artifact inspection total 2,743 physical lines across addon-install.ts, addon-manifest.ts, package-files.ts, source-stage.ts and artifact-inspect.ts. npm already does package installation; this code owns rollback, exact pins, inert inspection and application edits. A generic installer/dereferencer cannot be substituted blindly because execution, external refs and overwrite behavior differ. Measure whether offline shadcn/skill staging and artifact inspection materially help current application tasks; if not, consider an explicit public-surface scope cut with migration guidance. No unused-feature claim or removal decision established here.
    2. Five documentation guards (local links, YAML blocks, agent facts, guidance claims and trust-model prose) total 1,991 physical lines. The repeated Markdown walkers/fence semantics are a better consolidation target than removing the project-specific assertions. [Bug]: Bespoke Markdown readers disagree on fences and skip titled links #1118 supplies new correctness evidence; preserve exemptions, line numbers, scope and generated-resource checks. The previously rejected full dependency stack remains rejected unless new measured evidence changes that tradeoff.
    3. The store's 4,120 lines include 1,735 in collection.ts. Its ownership, reviewer permissions, transitions, transfers, intervals, idempotency and audit transaction behavior are the declarative product, not machinery an ORM automatically replaces. Freeze expansion pending repeated application evidence; any cut must name the behavior lost. The auth adapter's 641 lines are mostly endpoint admission, principal mapping, local database lifecycle and hermetic setup. Its exact 'begin' interception and Better Auth endpoint-context/internal-adapter seeding are upstream-coupling hotspots to keep covered on dependency upgrades, not evidence of a replacement identity implementation.
    4. The cookie jar, format validators, client-address handling, regex admission, egress transport and sandbox guest APIs are intentionally bounded subsets with observable contracts. A library substitution needs parity and total dependency-cost evidence; no drop-in replacement was established in this pass. In particular, a full Fetch implementation or worker pool must not broaden the sandbox bridge.

    No source or test deletion was made. Distinct packed-consumer, platform, sandbox and provider proofs are not redundant merely because they repeat application shapes. The identified reductions are narrow consolidation/correctness work and evidence-led scope choices, not a supported claim that thousands of lines can safely be deleted today.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions