Skip to content

Canonical resource access inventory

This inventory tracks code that reads or writes the canonical resource graph. It is intentionally organized by ownership and data flow rather than by table name alone. Keep it current when a resource access path is added, removed, or moved.

Canonical schema: web-tanstack/prisma/schema.prisma.

  • resources owns canonical content metadata, lifecycle state, and nullable monitored-source provenance through source_id. Product semantics live in kind, special platform identity in resource_platform, and representation format/blob presence in file_type / storage_key.
  • The only valid (kind, resource_platform) pairs are blog/null, forum/hackernews, post/twitter, video/youtube, paper/null, image/null, and file/null.
  • resource_translations owns localized title, summary, and content. Resource-level tags and keywords belong to resources.
  • user_resources is the stable user-to-Resource fact; nullable profile_saved_at records an explicit profile save.
  • resource_placements optionally locates that fact in one collection or workspace and enforces common ownership. Workspace role distinguishes sources from results independently of file origin.
  • user_files owns private raw-blob attachment and filename; resources.byte_size owns quota size.
  • sources owns monitored feed configuration. Its kind (blog | news) is a separate feed/editorial classification; both source kinds produce the canonical blog Resource after successful processing. resources.source_id is the stable relation; non-monitored resources may keep source_id = NULL.
  • The app Worker owns user-facing save/file/container and blob lifecycle writes. Core owns acquisition, enrichment, translations, entities, and AI Search synchronization. Think uses app/core service bindings and does not query product-owned resource tables directly.
Path Role Audit status
web-tanstack/prisma/schema.prisma Canonical Prisma schema audited
web-tanstack/prisma/manual-indexes.sql Constraints, indexes, and triggers audited; canonical source/effective-date indexes back keyset reads, while obsolete publication-only and JSON source-name indexes are explicitly removed
workers/core-worker/scripts/check-resource-identity.mjs Resource processing and identity contract checks the Core kind/platform vocabulary against the database identity constraint; schema history is verified by migration replay and drift checks

Completed cutovers and one-shot data repairs live in git history, not beside the current schema where they could be mistaken for repeatable operator work.

Path Surface
web-tanstack/src/server/resource-model.server.ts Shared Prisma projections, access predicates, localization, and persisted Resource identity mapping
web-tanstack/src/server/resource-query.server.ts Resource detail, feed/search, ranked hydration, collection-preview, and validated media read queries
web-tanstack/src/server/knowledge-service.ts Authorized and byte-bounded knowledge search/read plus flattened workspace context shared by Think Domain RPC and HTTP MCP
web-tanstack/src/server/profile.functions.ts Current/public profile and paginated profile-resource Server Functions
web-tanstack/src/server/collection.functions.ts Collection CRUD, detail, and paginated Resource-list Server Functions
web-tanstack/src/server/resource-ingest.functions.ts Resource relationship, URL import, and Workflow-status Server Functions
web-tanstack/src/server/resource-read.functions.ts Public feed, Resource detail rendering, and related-resource Server Functions
web-tanstack/src/server/docs.ts Document/workspace persistence, Markdown conversion, versioning/sharing, and its TanStack Server Function surface
web-tanstack/src/routes/api.mcp.ts Anonymous, stateless, read-only MCP boundary over the shared knowledge service
web-tanstack/src/routes/api.media.asset.$.ts, web-tanstack/src/routes/api.media.image.$id.ts Authorized app-owned blob and Hosted Images delivery
web-tanstack/src/lib/resource/{model,feed,save,toc}.ts Domain-owned browser/server Resource DTOs, feed vocabulary, save state, and reader navigation types
Path Surface
web-tanstack/src/server/resource-write.server.ts Resource-save, collection/workspace relationship, existing-URL admission, failure, and access transactions
web-tanstack/src/server/collection.functions.ts Collection CRUD and atomic collection-plus-Resource creation
web-tanstack/src/server/resource-ingest.functions.ts Resource relationship mutations, URL draft admission, and Workflow status reads
web-tanstack/src/server/resource-workflow.server.ts Server-only signing and verification for user-bound Resource Workflow status tokens
web-tanstack/src/server/billing.functions.ts Authenticated Autumn customer, checkout, and billing-portal endpoints
web-tanstack/src/server/podcast.functions.ts Authorized workspace podcast reads
web-tanstack/src/server/user-file.functions.ts User-file listing, reference guards, and deletion
web-tanstack/src/server/user-file-persistence.server.ts Upload validation, quota, deduplication, and resource persistence
web-tanstack/src/server/blob-lifecycle.server.ts Hosted Images/R2 provider operations and scheduled durable cleanup reconciliation
web-tanstack/src/lib/media/upload.ts The one browser upload call: native FormData, shared admission constants, and the direct success payload
web-tanstack/src/server/docs.ts Workspace/document creation, edits, optimistic versioning, sharing, and deletion
web-tanstack/src/server/chat-sessions.ts Chat allocation, ownership, action receipts, metadata, deletion fencing, and reconciliation
web-tanstack/src/server/domain-rpc.ts Request-scoped Domain RPC boundary used by Core and Think
web-tanstack/src/server/podcast.server.ts Podcast creation, completion, failure, and durable object cleanup admission
web-tanstack/src/server/chat-agent-proxy.server.ts Authenticated same-origin Think Agent HTTP/WebSocket proxy
web-tanstack/src/server/maintenance.server.ts Scheduled blob and chat-session reconciliation orchestration
web-tanstack/src/server.ts Thin Cloudflare Worker composition root
web-tanstack/src/routes/api.upload.ts Authenticated native FormData admission into the shared media/resource boundaries
Path Role Audit status
workers/core-worker/src/ingest/stored-resource.ts Stored-blob and explicit-reacquisition reads validates persisted identity and projects database rows into Core processing input
workers/core-worker/src/ingest/analysis.ts Resource AI analysis and entity normalization deterministic analysis output crosses the persistence boundary with the processed resource graph
workers/core-worker/src/ingest/translation-workflow.ts Revision-fenced translation reads/writes translation input loading and guarded persistence are colocated with their only Workflow consumer
workers/core-worker/src/ingest/platforms/{rss,twitter}.ts Source discovery, dedup, provenance, and enqueue each monitor owns its provider polling and draft admission
workers/core-worker/src/ingest/workflow.ts Draft/stored-target acquisition, enrichment, and persist-last orchestration URL/source/subject drafts finalize through one create-or-merge transaction; uploaded blobs and resyncs load stored rows explicitly
workers/core-worker/src/ingest/acquisition.ts, workers/core-worker/src/ingest/platforms/web.ts Acquisition routing and generic web extraction platform detection selects the dedicated acquisition path before canonical persistence
workers/core-worker/src/search-index.ts Runtime AI Search projection, synchronization, deletion, and candidate ranking newsence-corpus-v6 stores only effective date, source ID, kind, and resource platform as custom metadata; grouped searches give direct kind matches and HN expansion independent native 50-candidate budgets
workers/core-worker/src/operations/search-index-rebuild.ts Operator-triggered full-index rebuild and readiness the durable Workflow uploads the live corpus plus delta, prunes stale items, and verifies native item counts
workers/core-worker/src/index.ts RPC/workflow entrypoints bounded batch RPCs wrap native Workflow createBatch, status fan-out, and grouped AI Search without moving product writes into Core
Path Role Audit status
workers/think-worker/src/agent.ts Native Think knowledge tool and app Domain RPC consumer one typed action surface covers public search, typed reads, and current-workspace sources; RPC values are cloned and disposed
workers/think-worker/src/tools/create-document.ts Document edit/create and generated-image actions visible product mutations cross the app Domain boundary; Computer files remain scratch only
web-tanstack/src/server/knowledge-service.ts App-owned read authority validates Think and MCP requests and executes authorized, bounded knowledge reads

The frontend must consume server-owned DTOs and must not reconstruct database ownership rules. These consumers were audited during the read-layer refactor; resource/card identity is explicit, source filter state stores Source UUIDs rather than display names, duplicate profile/collection adapters and localization wrappers were removed, and effective dates now come from server policy. Direct consumers live in:

  • web-tanstack/src/lib/queries/* (including the single server-owned viewer save-state projection)
  • web-tanstack/src/routes/_workspaceApp._noResources.index.tsx
  • web-tanstack/src/components/feed/*
  • web-tanstack/src/components/resource/*
  • web-tanstack/src/lib/resource-workflow.ts (one normalized result list for URL/upload invalidation and polling)
  • web-tanstack/src/components/workspace/ResourcesRail.tsx
  • web-tanstack/src/components/collections/*
  • web-tanstack/src/components/chat/*
  • web-tanstack/src/lib/resource/{model,feed,save,toc}.ts

Run these from the repository root and classify every new match before marking the resource refactor complete:

Terminal window
rg -n --glob '!**/generated/**' \
'\b(prisma|tx)\.(resource|resourceTranslation|userResource|resourcePlacement|userFile|source)\.' \
web-tanstack/src
rg -n -i --glob '!**/generated/**' \
'(from|join|update|into|delete from)[[:space:]]+"?resources"?|resource_translations|user_resources|resource_placements|user_files' \
web-tanstack/src workers packages

Historical SQL and documentation matches are not runtime touchpoints, but must remain clearly labeled so stale models are not copied back into production code.

  • The completion searches above were rerun after round 9 and every runtime match maps to an inventory entry; remaining SQL matches are canonical schema, operator migrations, or documentation.
  • Live read-only invariant checks found no enriched corpus row missing its original translation, URL, title, or source; no duplicate normalized URL, invalid kind/platform pair, invalid library item, ownerless private resource, or user-file row without a storage key.
  • All resource, translation, profile-item/placement, and user-file indexes declared in manual-indexes.sql are present in the live database.
  • Final verification uses the web check, typecheck, and production build; core database contract, typecheck, and lint; Think typecheck and lint; plus real workflow, scheduled cron, AI Search, search RPC, related-resource, and PostgreSQL smoke checks.