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.
Invariants
Section titled “Invariants”resourcesowns canonical content metadata, lifecycle state, and nullable monitored-source provenance throughsource_id. Product semantics live inkind, special platform identity inresource_platform, and representation format/blob presence infile_type/storage_key.- The only valid
(kind, resource_platform)pairs areblog/null,forum/hackernews,post/twitter,video/youtube,paper/null,image/null, andfile/null. resource_translationsowns localized title, summary, and content. Resource-level tags and keywords belong toresources.user_resourcesis the stable user-to-Resource fact; nullableprofile_saved_atrecords an explicit profile save.resource_placementsoptionally locates that fact in one collection or workspace and enforces common ownership. Workspaceroledistinguishes sources from results independently of file origin.user_filesowns private raw-blob attachment and filename;resources.byte_sizeowns quota size.sourcesowns monitored feed configuration. Itskind(blog | news) is a separate feed/editorial classification; both source kinds produce the canonicalblogResource after successful processing.resources.source_idis the stable relation; non-monitored resources may keepsource_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.
Schema and database-only objects
Section titled “Schema and database-only objects”| 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.
App Worker: canonical reads
Section titled “App Worker: canonical reads”| 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 |
App Worker: authoritative writes
Section titled “App Worker: authoritative writes”| 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 |
Core Worker: engine reads and writes
Section titled “Core Worker: engine reads and writes”| 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 |
Think Worker consumers
Section titled “Think Worker consumers”| 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 |
Frontend consumers
Section titled “Frontend consumers”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.tsxweb-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.tsxweb-tanstack/src/components/collections/*web-tanstack/src/components/chat/*web-tanstack/src/lib/resource/{model,feed,save,toc}.ts
Completion searches
Section titled “Completion searches”Run these from the repository root and classify every new match before marking the resource refactor complete:
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 packagesHistorical SQL and documentation matches are not runtime touchpoints, but must remain clearly labeled so stale models are not copied back into production code.
Completion audit
Section titled “Completion audit”- 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.sqlare present in the live database. - Final verification uses the web
check,typecheck, and productionbuild; core database contract,typecheck, and lint; Thinktypecheckand lint; plus real workflow, scheduled cron, AI Search, search RPC, related-resource, and PostgreSQL smoke checks.