Repository navigation
Conversation
transactSerializable runs a postgres.js transaction at SERIALIZABLE and re-executes the callback on SQLSTATE 40001/40P01 with jittered backoff, layered on the existing connection-level withRetry (which only covers 08/57P/53-class transient errors). This is write-constitution rule 1 of the 0.5 Postgres backend: every mutation-shaped handler goes through it, so callbacks must stay pure apart from their database writes.
The Convex-to-Postgres port, increments 01-05 on the campaign ledger (services/platform/backend/MIGRATION.md): - Runtime: the platform image gains TALE_ROLE api/worker/all dispatch (Node runs backend/*.ts directly; compose profile 'backend'); a Node resolve hook + --experimental-transform-types let the backend import runtime-clean 0.4 modules unchanged instead of fork-copying them. - Constitution: serializable writes, pg-boss 12 jobs enqueued inside the caller's transaction (LISTEN/NOTIFY wake, singletonKey dedupe, per-job batch results), and the Tier-2 hint outbox fanned out over SSE with Last-Event-ID replay. postgres.js json/jsonb serialization is aligned with node-postgres semantics (strings pass through) so pg-boss's pre-stringified parameters are not double-encoded. - App DB: tale_app + an advisory-lock-guarded boot migrator; Better Auth and pg-boss own their schemas. - Auth at 0.4 parity: email+password with the login-throttle gate (per-IP flood guard, per-account exponential lockout, timing jitter), the organization plugin (teams, access-control role matrix, slug/name hooks, scaffold-on-create), apiKey (+suffix column), twoFactor and passkey plugins; membership reads are direct SQL - the 0.4 mirror apparatus is gone. - Ported domains: audit_logs (per-org chain head locked FOR UPDATE replaces the OCC genesis trick), login_attempts, notifications (the org-audience bell at the 0.4 shape), users, user_preferences, organizations (reads, org-switch record, deletion door, scaffold and cleanup jobs), members (list/context + guarded mutations), the PG rate limiter carrying the full 0.4 rule catalog, and file-direct org config reads (the configCache mirror dies). - Proof: backend/integration-check.ts runs 22 checks against a real throwaway Postgres, including lockout flow and audit-chain re-verification.
Core CRUD, settings (identity/sharing/instructions/knowledge/agents/ models/connectors), pin/archive/restore/delete (confirm-gated cascade mode), duplicate, project agents (create/update/delete with the 0.4 validation caps and admin-only secret grants), search, sidebar and overview reads. The pure access matrix, key derivation, and audit action constants are reused from 0.4 unchanged; per-org key/externalItemId uniqueness moves into partial unique indexes. Cross-domain touchpoints (document attach, delete-cascade walks, overdue rollups, automations guard, REST v1 surface) land with their domains - tracked in MIGRATION.md. Also fixes the token-bucket rate limiter's ratePerMs parameter type under bigint expression context (::float8).
Tier A of the tasks domain: create/update with label resolution and per-project numbering, status choreography with the subtask close-guard and completedAt semantics, polymorphic assignee validation (humans need project access, agents must be instances of the project), claim, board drag moves on the reused LexoRank module, the label catalog (create/rename/delete with task detach), advisory dependencies with write-time cycle rejection, saved board views, the per-task activity timeline, and the denormalized project rollup transitions. Project creation now seeds the default labels in the same transaction (0.4 parity). Tier B (agent runs, review arc, comments/mentions, notify and event fan-outs, REST, crons) lands with its infrastructure - tracked in MIGRATION.md.
S3-compatible object storage becomes THE blob backend (Convex _storage dies with the component): resolution prefers the org's BYO object-storage/connection.json and falls back to the deployment default under the 'default' config tree, failing closed when neither exists. The aws4fetch signing, presign lanes, and key scheme are reused from 0.4 unchanged, so existing BYO-org configs work verbatim. Adds the app.file_metadata ledger (RAG/transcription pipeline columns shipped nullable for the knowledge/tts ports) and the files surface: a two-step upload handshake with server-minted keys and HEAD-verified registration, presigned GET serving, and org-scoped delete. Integration exercises the full lane against a real MinIO (gated on ITEST_S3_ENDPOINT, visibly skipped otherwise).
pg-boss schedule() registry (worker-boot idempotent upsert, UTC) with the first maintenance sweeps - idle rate-limit rows (7d) and the loginAttempts 30-day TTL plus 90-day block counters. Ports the platform event seam at its exact 0.4 contract: dispatch stays a deliberate no-op until the automations domain rebuilds the subscription fan-out, and the producing domains (task created/status changed, project created) call it inside their transactions so the swap-in is one function body.
Documents Tier A: bind a registered upload as a document, hub vs project scoping with the 0.4 access-module semantics (project docs never surface in hub listings; team rules with org-wide default), rename/move/team edits, trash/restore soft lifecycle, project attach/detach with the mutual-exclusivity rule (closing the projects ledger gap), mention search, and presigned serving. Folders: tree CRUD with the depth cap, sibling-name uniqueness, scope inheritance and conflict rules, breadcrumbs - deleting refuses while any document lives in the subtree until the trash-cascade lands. Integration drives the whole vertical against real MinIO including the hub-visibility flips on attach/trash.
The 0.5 replacement for the @convex-dev/agent component's thread and message tables: app.threads + app.messages with the component's (order, step_order) turn model, AI-SDK-shaped jsonb parts plus derived plain text, and the thread_metadata sidecar (generation lifecycle columns shipped for the chat engine). Task discussion comments ride it end to end - lazily minted task_discussion threads, lockstep meta rows (author, mentions, editedAt, locale snapshots), comment counts, activity and audit trails, author-or-admin edit/delete. The mention directory and its fan-outs land with collab/agents/automations.
Contacts: the per-org correspondent directory with role-matrix gating, normalized emails, filterable keyset listing, find-or-create for the conversations lane, soft trash, and contact.* events. Message feedback: per-(message,user) upsert votes with toggle semantics and the org insights feed with rating stats. Support cases: the org-scoped ticket lifecycle with status timestamps, escalation levels, SLA fields, comments that stamp first response, the activity feed, and archive. Integration exercises all three verticals; the audit chain now verifies 36 rows across nine domains.
CRUD with the 0.4 field caps and role-matrix gating, per-org case-insensitive name uniqueness as a real expression index (the 0.4 full-table probe becomes a constraint, kept only for the friendly error), per-language translation upserts, and a filterable keyset listing. REST and connector ingest lanes land with the machine door.
The credential RESOLUTION path - api-key decryption via secret_box, the TALE_PROVIDER_KEY_ env gate re-checked at read time, and the subscription-broker pool fetch/pick - reuses the 0.4 module verbatim: a new ctx shim (lib/convex-shim.ts) re-points its two row lookups at app.provider_credentials by function name and fails loud on any un-shimmed ctx call. Admin surface: create (encrypt + masked preview, first row becomes the default), status/default/allowlist edits with the default swap enforced by a partial unique index, delete - all audit-trailed, secrets never leaving the server. The node loader also learns bare-specifier .js retries for CJS deep paths (validator/lib/*).
Search and fetch reuse the 0.4 modules verbatim - the ctx shim re-points their three seams (the org-row lookup, credential loads, and the retrievable-file access filter) at Postgres; the Tier-A filter covers document and chat-thread scopes and denies conversation refs until that domain lands. Ingest composes the same exported pieces (extractText, the org embedder behind provider credentials, indexDocument with the PII gate and scope stamps) into the rag.index_file job, enqueued transactionally when an upload binds as a document, with status writes on file_metadata. The deployment-default corpus bootstraps at worker boot. Integration drives the full loop against the real corpus database with a local OpenAI-compatible embedding endpoint (base64 Float32, the SDK default).
This was referenced Aug 31, 2026
Closed
This was referenced Sep 3, 2026
larryro
added a commit
that referenced
this pull request
Sep 4, 2026
KNOWLEDGE_ENTRIES_FOLDER ("Knowledge entries") has had no importer since
the 0.5 rewrite (#3107): knowledge-entry backing documents are listed at
the Documents root, not filed into a reserved folder. knip never flagged
it because every backend/**/*.ts file is a knip entry for the platform
workspace, so backend exports are never reported unused. No message key,
helper, test, or docs sentence existed only for it.
larryro
added a commit
that referenced
this pull request
Sep 5, 2026
`.github/workflows/checks.yml` sets `YOUTUBE_LIVE_TEST=1` plus a bgutil PO-token provider and turbo keys its cache on the variable, all so the live YouTube ingestion test proves the shipped anti-bot stack from a datacenter IP — but that suite went with the Convex tree in #3107 and nothing has read the variable since. The CI job claimed a proof no test made, and the manual QA doc pointed testers at a file that did not exist. The suite is back at `backend/core/video_links/ytdlp_live.test.ts`, byte-identical to the deleted one (skipped unless `YOUTUBE_LIVE_TEST=1`; `beforeAll` self-provisions yt-dlp/deno/ffmpeg/bgutil via `ensureVideoToolchain`; a bot wall self-skips, anything else fails), and the manual QA rows F6/F7 name the new path. Finding: websites-video-6.
This was referenced Sep 6, 2026
This was referenced Sep 14, 2026
This was referenced Sep 27, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the Convex runtime with a Node + Hono + Postgres backend. The
running stack has no Convex process, service, control channel, or client
runtime; the app has its own wire contract; the reused 0.4 handler bodies
run against a SQL-backed ctx shim.
services/platform/backend/MIGRATION.mdis the campaign's source oftruth — one row per domain, one row per teardown step, each naming what
landed and what was found en route. 94 done / 5 dropped / 1 pending.
What this is
backend/, 57 SQL migrations applied at boot under an advisory lockconvex/tree.ts.ts— the reused handler bodies and what they reachThe port is domain-by-domain, not a rewrite: where a 0.4 handler body was
correct, it is REUSED verbatim behind a ctx shim that dispatches a
function NAME to a SQL handler. That is why the diff deletes twice what
it adds — the decision logic mostly survives; the runtime under it does
not.
Gates
Run on the tip, each with its own exit code checked:
tsc --noEmit— 0oxlint --type-aware— 0The integration run is the one that matters: it exercises every door
end-to-end against a throwaway database, including the machine journey
(presigned upload → bind → listing → content roundtrip), the automation
stepper, the task-agent arc, SSO/SCIM, governance holds and retention,
the WebDAV lane, and the in-sandbox bridges.
What is deliberately NOT done
The one
pendingrow.convexis still inpackage.json, used as aLIBRARY, not a runtime:
v/Infer/GenericIdfromconvex/valuestype the reused handlers' argument contracts across 32 modules. Nothing
imports it from
backend/orlib/. Those validators become plainTypeScript or zod as each domain ports, and then the reuse set moves out
of
convex/and the package leaves.Also priced rather than hidden, in the ledger:
WebDAVBackend's threemethods return
any— exactly what the retired client's genericresolved to for a name-addressed call, so nothing about strictness
changed here. Tightening it means declaring shapes at 66 call sites and
updating handler stubs that return partial ones; that is its own change.
Review notes
The ledger rows carry the reasoning, including the traps worth knowing
before touching this code:
through the shim (
internal.x.y.z) with no import to follow. Anyclosure analysis must walk static imports, dynamic
await import(),AND api-object references — a naive import closure was wrong by 350
files.
found and fixed this way: the connectors bridge's forensic audit lived
in the 0.4 wrapper, and the 0.5 door calls the impl directly.
_generated/is hand-maintained now. Adding a name there withoutgiving the shim a handler for it is a runtime refusal waiting to
happen.