Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
revert: an export refuses again when a company's rows escape its scope
aashu5a7e879174a3
diff --git a/.ai/plans/2026-08-25-backup-durability.md b/.ai/plans/2026-08-25-backup-durability.mdindex 4e1146db62..a407e24f18 100644--- a/.ai/plans/2026-08-25-backup-durability.md+++ b/.ai/plans/2026-08-25-backup-durability.md@@ -21,15 +21,24 @@ being asked, and the dated manifest vintages depended on a person remembering.Tasks 22–29 remove them and replace the vintages with one self-maintaining`packages/jobs/manifests/schema.json`. The whole nightly cron is gone.+**Reversal pass, 2026-08-26 (PR review feedback).** Tasks 4, 6 and 20 are REVERTED and+their code deleted. The export refusing an out-of-scope row is a tenant-leak detector,+not a backup defect, so the hard refusal is back and the exclusion path is gone; the+nightly monitor only logged, so it fails this repo's own "no detection without a+consumer" rule; and the SQL migration guarded three functions that only READ the bad+rows, so it tolerated the problem instead of preventing it. The edge-function fixes+(Tasks 2 and 3) SURVIVE — they are the actual write path. Full reasoning:+`.ai/reviews/2026-08-26-tenant-leak-feedback.md`, and the banner atop the spec.+## Progress- [x] Task 1: Confirm the cross-tenant write path at the `schedule` call sites- [x] Task 2: Verify job ownership inside the `schedule` edge function- [x] Task 3: Verify job ownership inside the `trigger-rework` edge function and scope its dependency read-- [x] Task 4: Scheduled cross-tenant reference monitor+- [~] Task 4: Scheduled cross-tenant reference monitor — **REVERTED 2026-08-26**, deleted: it only logged (spec D10)- [~] Task 5: Capture evidence and clean up the four bad rows — **SKIPPED by decision (2026-08-25)**-- [x] Task 6: Harden `check_operation_dependencies` and `finish_job_operation` — dependency on Task 5 **removed**, see note-- [x] Task 7: Export skips unrestorable rows instead of refusing+- [~] Task 6: Harden `check_operation_dependencies` and `finish_job_operation` — **REVERTED 2026-08-26**, migration deleted: those functions only READ the bad rows+- [~] Task 7: Export skips unrestorable rows instead of refusing — **REVERTED 2026-08-26**: the refusal is a tenant-leak detector (spec D3)- [x] Task 8: Rewrite export failure and partial-success copy- [x] Task 9: Report-mode compatibility API- [x] Task 10: Shared table → product-area mapdiff --git a/.ai/specs/2026-08-25-backup-durability.md b/.ai/specs/2026-08-25-backup-durability.mdindex 38db98d2a3..35903d2920 100644--- a/.ai/specs/2026-08-25-backup-durability.md+++ b/.ai/specs/2026-08-25-backup-durability.md@@ -12,6 +12,42 @@ replaced, and the changes are folded into the text below rather than left as errwhat you read here is what shipped. The corrected decisions and the reasoning behind themare in the table below and under Rejected alternatives.+> ## ⚠ REVERSED 2026-08-26 — read this before Part 3 or D3/D10+>+> Review feedback on the PR overturned this spec's reading of the cross-tenant rows.+> **Three things below no longer describe the branch**, and the reasoning that produced+> them was wrong. Full write-up: `.ai/reviews/2026-08-26-tenant-leak-feedback.md`.+>+> **D3 (export skips unrestorable rows) is REVERTED.** The export refusing was never a+> backup defect — it was a tenant leak surfacing. RLS hides another tenant's rows from+> every ordinary read, so an export, which runs without RLS, is the only thing wide+> enough to see one. Excluding the rows and finishing the backup silenced the sole+> detector in exchange for a friendlier error on a company whose data was already wrong.+> The hard refusal is back. `manifest.excludedRows`, `CompanyBackupSummary.excludedRows`,+> the list-row count and the disclosure's `ExcludedRows` block are all gone.+>+> **D10 (nightly `findExportScopeViolations` monitor) is REVERTED.** `tenant-integrity.ts`+> only wrote a log line. By this repo's own rule — no detection without a consumer that+> acts — that is not monitoring. Deleted rather than dressed up.+>+> **Part 3's SQL migration is REVERTED.** `20260825075035_harden-operation-dependency-scope.sql`+> added a same-company guard to `check_operation_dependencies`,+> `set_initial_dependency_status` and `finish_job_operation`. Those three functions only+> READ dependency rows; none of them writes one, so none could have produced the+> mis-stamped data, and this spec's claim that they did was unsupported. The guard was+> tolerating bad rows rather than preventing them, at the cost of rewriting three live+> job-completion functions. Dropped.+>+> **What SURVIVES from Part 3, and matters most:** the edge-function fixes in+> `trigger-rework/index.ts` and `schedule/index.ts`. Those are the write path. Before+> them, `trigger-rework` had NO authorization gate at all, and its convergence read of+> `jobOperationDependency` carried no `jobId` filter — so it swept in EVERY tenant's+> dependency edges and re-inserted them under the caller's company. That is how the rows+> got mis-stamped. Both functions now verify the job belongs to the caller's company and+> 404 on a miss, and the read is scoped.+>+> Everything else in this spec — D1, D2, D4–D9, D11–D14 — is unaffected.+Per-company backups are currently close to unusable, for two unrelated reasonsthat both surface to the user as "the backup is broken". This spec covers themechanism, both defects, every decision taken, and — new in this revision — the@@ -26,14 +62,14 @@ tell the person at each step.|---|---|---|| D1 | A new NOT NULL column must ship a DEFAULT (conformance check over migration SQL) | Makes the gate's main refusal branch unreachable. Cheapest fix in this document. || D2 | Restore **discloses and proceeds** instead of refusing, except where data would be silently lost | The loader is already drift-tolerant; the gate is what refuses. |-| D3 | Export **skips and discloses** unrestorable rows instead of refusing the whole backup | Four junk rows must not block a company's only backup. |+| D3 | ~~Export **skips and discloses** unrestorable rows~~ **REVERTED 2026-08-26** — the export still refuses | The refusal is a tenant-leak detector, not a backup defect. See the banner above. || D4 | A committed map of renamed/dropped tables, appended by the migration that renames | "Missing" means two different things and guessing wrong loses data quietly. || D5 | A LOCAL pre-commit check, not a CI gate | Moves discovery to the moment fixing it is free. The CI design was abandoned on contact — a bare Postgres has no `auth`/`storage` schema, so it needed most of the compose stack. || D6 | ONE self-maintaining schema baseline, `packages/jobs/manifests/schema.json`, regenerated and staged by the pre-commit hook | *(replaced the original D6, dated vintages: nothing forced anyone to add one, and the directory grew forever)* || D7 | Backups have NO shelf life, NO scheduled creation, and NO revalidation pass | *(replaced the original D7, which had all three)* Revalidation had no consumer that acted on a finding; the other two acted on customer data without being asked. || D8 | One shared status vocabulary across every backup surface | Five states, one word each, no synonyms. || D9 | All user-facing copy names the affected product areas, never "the system" | The current message blames the product for a data-integrity finding. |-| D10 | `findExportScopeViolations` runs on a schedule as monitoring | It is already the right query; it just only runs when someone clicks a button. |+| D10 | ~~`findExportScopeViolations` runs on a schedule as monitoring~~ **REVERTED 2026-08-26** | It only logged. No detection without a consumer that acts. || D11 | The baseline is the copy on `main`, fetched from `raw.githubusercontent.com`, slug from the `origin` remote | The last shipped schema is what customer backups were taken against; a file that regenerates itself cannot be its own baseline. || D12 | A fetch failure warns — naming the STALENESS, not just the failure — and falls back to `git show origin/main:…`; a baseline found in NEITHER place is a hard failure | Offline work must not be blocked; a missing baseline skipped quietly is indistinguishable from a passing check. |diff --git a/apps/erp/app/modules/settings/backups.service.ts b/apps/erp/app/modules/settings/backups.service.tsindex 0502b32c61..26c3feab89 100644--- a/apps/erp/app/modules/settings/backups.service.ts+++ b/apps/erp/app/modules/settings/backups.service.ts@@ -62,25 +62,6 @@ export type CompanyBackupSummary = {rows: number;/** Total bundled asset bytes (the bulk of a backup's footprint). */sizeBytes: number;- /**- * Rows the export deliberately left out because a NOT-NULL reference escaped- * company scope. The backup is still restorable — these rows could never have- * been. Surfaced so the omission is disclosed rather than silent. Empty for- * manifests written before the field existed.- *- * Carried in FULL, not as a bare count: a restore deletes today's data and- * replaces it with the backup, so these rows exist right now and will be gone- * afterwards. `RestoreDisclosure` needs the table to name the product area, and- * "4 rows excluded" cannot tell anyone which part of their company that is.- */- excludedRows: Array<{- table: string;- column: string;- refTable: string;- rows: number;- }>;- /** Sum of `excludedRows[].rows` — the list row shows the number alone. */- excludedRowCount: number;/*** The verdict from `compatibility.json`, written beside the manifest by the* export job and never refreshed — so `checkedAt` is the export date, and the@@ -136,8 +117,6 @@ export async function listCompanyBackups(label: null,rows: 0,sizeBytes: 0,- excludedRows: [],- excludedRowCount: 0,compatibility: { checkedAt: null, status: "ready", findings: [] }};// Both objects are tiny and independent — fetch them together so adding the@@ -171,12 +150,6 @@ export async function listCompanyBackups(label?: string | null;tables?: Array<{ rows?: number }>;storage?: Array<{ size?: number; included?: boolean }>;- excludedRows?: Array<{- table?: string;- column?: string;- refTable?: string;- rows?: number;- }>;};summary.status = "ready";summary.exportedAt = m.exportedAt ?? null;@@ -188,26 +161,6 @@ export async function listCompanyBackups(summary.sizeBytes = (m.storage ?? []).filter((x) => x.included).reduce((sum, x) => sum + (x.size ?? 0), 0);- // Absent on manifests predating the field — read as empty, never as- // "unknown", so an older backup does not display a scary blank. An- // entry with no table name is dropped rather than rendered as a- // mystery row: it could not be assigned to a product area anyway.- summary.excludedRows = (m.excludedRows ?? []).flatMap((x) =>- x.table- ? [- {- table: x.table,- column: x.column ?? "",- refTable: x.refTable ?? "",- rows: x.rows ?? 0- }- ]- : []- );- summary.excludedRowCount = (m.excludedRows ?? []).reduce(- (sum, x) => sum + (x.rows ?? 0),- 0- );} catch {// Manifest present but unreadable — treat as a partial/aborted export// (stays "pending"); still listed by name so the user can delete it.diff --git a/apps/erp/app/modules/settings/ui/Backups/RestoreDisclosure.tsx b/apps/erp/app/modules/settings/ui/Backups/RestoreDisclosure.tsxindex b19daec8de..33799258dd 100644--- a/apps/erp/app/modules/settings/ui/Backups/RestoreDisclosure.tsx+++ b/apps/erp/app/modules/settings/ui/Backups/RestoreDisclosure.tsx@@ -19,7 +19,6 @@ import { CONFIRM_WORD, disclosureState } from "./disclosure-state";import { formatBackupDate, formatBackupName } from "./format";type Finding = CompanyBackupSummary["compatibility"]["findings"][number];-type Excluded = CompanyBackupSummary["excludedRows"][number];/*** What the person is told before their company's data is replaced.@@ -53,7 +52,6 @@ export function RestoreDisclosure({// unknown, which the screen says rather than implying a clean bill of health.const findings = backup?.compatibility.findings ?? [];const checkedAt = backup?.compatibility.checkedAt ?? null;- const excluded = backup?.excludedRows ?? [];const { blocked, discards, canConfirm } = disclosureState(backup, typed);const close = () => {@@ -109,10 +107,6 @@ export function RestoreDisclosure({</p>)}- {excluded.length > 0 ? (- <ExcludedRows excluded={excluded} />- ) : null}-{findings.length > 0 ? (<FindingGroups findings={findings} checkedAt={checkedAt} />) : null}@@ -167,57 +161,6 @@ export function RestoreDisclosure({);}-/**- * Rows the export left out, by product area.- *- * Distinct from a `discarded` finding and shown separately: a finding is about- * the SCHEMA drifting since the backup was taken, this is about rows that were- * never written to the backup in the first place, and the two have different- * causes and different fixes. Both are losses, so both gate the typed- * confirmation.- *- * Rendered ABOVE the findings because it is unconditional: a schema finding may- * not apply to the reader's data, but an excluded row is a row that measurably- * exists today and will not exist after.- */-function ExcludedRows({ excluded }: { excluded: Excluded[] }) {- const total = excluded.reduce((sum, x) => sum + x.rows, 0);- const areas = [...new Set(excluded.map((x) => tableArea(x.table)))];-- return (- <VStack spacing={1}>- <span className="flex items-center gap-1.5 text-sm font-medium">- <LuTriangleAlert className="h-4 w-4 shrink-0" />- <Trans>Not in this backup</Trans>- </span>- <span className="text-sm text-muted-foreground">- <Trans>- {total} records couldn't be backed up and won't be here afterwards.- </Trans>- </span>- {/* The area, not the table — same rule as the findings below. */}- <span className="text-sm text-muted-foreground">{areas.join(", ")}</span>- <details className="text-xs text-muted-foreground">- <summary className="cursor-pointer">- <Trans>Details</Trans>- </summary>- <ul className="mt-1 flex flex-col gap-0.5 pl-4">- {excluded.map((x) => (- <li key={`${x.table}.${x.column}`}>- <span className="font-mono">- {x.table}.{x.column}- </span>- {" → "}- <span className="font-mono">{x.refTable}</span>- {` — ${x.rows}`}- </li>- ))}- </ul>- </details>- </VStack>- );-}-const KIND_ORDER: Finding["kind"][] = ["blocked", "discarded", "defaulted"];const KIND_ICON = {diff --git a/apps/erp/app/modules/settings/ui/Backups/disclosure-state.test.ts b/apps/erp/app/modules/settings/ui/Backups/disclosure-state.test.tsindex 5ec4941ddb..edb529000b 100644--- a/apps/erp/app/modules/settings/ui/Backups/disclosure-state.test.ts+++ b/apps/erp/app/modules/settings/ui/Backups/disclosure-state.test.ts@@ -3,39 +3,23 @@ import type { CompanyBackupSummary } from "../../backups.service";import { CONFIRM_WORD, disclosureState } from "./disclosure-state";type Finding = CompanyBackupSummary["compatibility"]["findings"][number];-type Excluded = CompanyBackupSummary["excludedRows"][number];const finding = (kind: Finding["kind"], table = "job"): Finding =>({ kind, table, column: "startDate", reason: "a reason" }) as Finding;-const excludedRow = (rows = 4): Excluded =>- ({- table: "jobOperationDependency",- column: "jobOperationId",- refTable: "jobOperation",- rows- }) as Excluded;--const backup = (over: {- findings?: Finding[];- excludedRows?: Excluded[];-}): CompanyBackupSummary =>+const backup = (findings: Finding[] = []): CompanyBackupSummary =>({name: "minimal",label: "minimal",exportedAt: "2026-08-25T20:06:00.000Z",- compatibility: {- checkedAt: "2026-08-25T20:06:00.000Z",- findings: over.findings ?? []- },- excludedRows: over.excludedRows ?? []+ compatibility: { checkedAt: "2026-08-25T20:06:00.000Z", findings }}) as unknown as CompanyBackupSummary;// The five states the disclosure screen can be in. Named here the way they are// described to a reader, so a future change that collapses two of them fails.describe("disclosureState", () => {it("a clean backup asks for nothing", () => {- expect(disclosureState(backup({}), "")).toEqual({+ expect(disclosureState(backup(), "")).toEqual({unchecked: false,blocked: false,discards: false,@@ -53,48 +37,35 @@ describe("disclosureState", () => {});it("a default-only finding is information, not a gate", () => {- const state = disclosureState(- backup({ findings: [finding("defaulted")] }),- ""- );+ const state = disclosureState(backup([finding("defaulted")]), "");expect(state.discards).toBe(false);expect(state.canConfirm).toBe(true);});it("a discarded finding requires the typed word", () => {- const b = backup({ findings: [finding("discarded")] });+ const b = backup([finding("discarded")]);expect(disclosureState(b, "").canConfirm).toBe(false);expect(disclosureState(b, CONFIRM_WORD).canConfirm).toBe(true);});it("a blocked finding can never be confirmed, typed word or not", () => {- const b = backup({ findings: [finding("blocked")] });+ const b = backup([finding("blocked")]);expect(disclosureState(b, "").blocked).toBe(true);expect(disclosureState(b, CONFIRM_WORD).canConfirm).toBe(false);});-});-// Rows the export never wrote are a loss in their own right: they exist in the-// company today and a restore deletes today's data.-describe("excluded rows gate the confirmation on their own", () => {- it("counts as a discard with no findings at all", () => {- const b = backup({ excludedRows: [excludedRow()] });+ it("mixed findings take the strictest one", () => {+ const b = backup([+ finding("defaulted"),+ finding("discarded", "salesOrder")+ ]);expect(disclosureState(b, "").discards).toBe(true);- expect(disclosureState(b, "").canConfirm).toBe(false);expect(disclosureState(b, CONFIRM_WORD).canConfirm).toBe(true);});-- it("still cannot rescue a blocked backup", () => {- const b = backup({- findings: [finding("blocked")],- excludedRows: [excludedRow()]- });- expect(disclosureState(b, CONFIRM_WORD).canConfirm).toBe(false);- });});describe("the typed word", () => {- const b = backup({ findings: [finding("discarded")] });+ const b = backup([finding("discarded")]);it("ignores case and surrounding space", () => {expect(disclosureState(b, " ReStOrE ").canConfirm).toBe(true);diff --git a/apps/erp/app/modules/settings/ui/Backups/disclosure-state.ts b/apps/erp/app/modules/settings/ui/Backups/disclosure-state.tsindex 6c676157bd..8bed7bde72 100644--- a/apps/erp/app/modules/settings/ui/Backups/disclosure-state.ts+++ b/apps/erp/app/modules/settings/ui/Backups/disclosure-state.ts@@ -25,14 +25,8 @@ export function disclosureState(typed: string): DisclosureState {const findings = backup?.compatibility.findings ?? [];- const excluded = backup?.excludedRows ?? [];const blocked = findings.some((f) => f.kind === "blocked");- // Excluded rows count as a discard. They are not in the backup, they DO exist- // in the company today, and a restore deletes today's data — so confirming- // this restore loses them for good. That they were unrestorable junk does not- // make their disappearance something to find out about afterwards.- const discards =- findings.some((f) => f.kind === "discarded") || excluded.length > 0;+ const discards = findings.some((f) => f.kind === "discarded");return {unchecked: !backup,diff --git a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.jsonindex f6851f196b..9157853b6a 100644--- a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json@@ -1,5 +1,5 @@{- "generated": "2026-08-25T14:32:40.041Z",+ "generated": "2026-08-26T10:39:33.887Z","totalTools": 1443,"modules": 15,"tools": [diff --git a/apps/erp/app/routes/x+/settings+/backups.tsx b/apps/erp/app/routes/x+/settings+/backups.tsxindex fb9aea6ce9..3a47e28e03 100644--- a/apps/erp/app/routes/x+/settings+/backups.tsx+++ b/apps/erp/app/routes/x+/settings+/backups.tsx@@ -643,16 +643,6 @@ function BackupRow({ file }: { file: CompanyBackupSummary }) {{convertKbToString(Math.round(file.sizeBytes / 1024))}</>) : null}- {/* A number, not an adjective. These rows referenced another- company's data, so they could never have been restored —- the backup is complete without them, and saying so beats- silence. */}- {file.excludedRowCount > 0 ? (- <>- {" · "}- {file.excludedRowCount.toLocaleString()} rows excluded- </>- ) : null}</>)}</span>diff --git a/packages/database/supabase/migrations/20260825075035_harden-operation-dependency-scope.sql b/packages/database/supabase/migrations/20260825075035_harden-operation-dependency-scope.sqldeleted file mode 100644index 0907ac4d25..0000000000--- a/packages/database/supabase/migrations/20260825075035_harden-operation-dependency-scope.sql+++ /dev/null@@ -1,264 +0,0 @@--- Operation-dependency readiness must not be decided by another tenant's rows.------ `jobOperationDependency` carries its own "companyId", but its FKs to--- "jobOperation" and "job" are single-column, so Postgres only guarantees the--- referenced row exists SOMEWHERE. A write path that pairs one company's id with--- another company's job therefore produces rows attributed to the wrong tenant,--- and all three readiness functions below counted them, because none filtered by--- company at all.------ The guard is deliberately `jo."companyId" = self."companyId"` — the two--- operations in a dependency must belong to the same company — and NOT a filter--- on `dep."companyId"`. That distinction is load-bearing: a mis-stamped row still--- describes a real dependency between two real operations, so keying off the--- operations keeps it counted, while keying off the row's own label would make it--- vanish and flip a genuinely-waiting operation to Ready.------ Each function is REPLACED WHOLE, so each body below is copied verbatim from its--- own LATEST definition, with only the guard added:--- check_operation_dependencies <- 20250429130223_operation-dependencies.sql--- set_initial_dependency_status <- 20250429130223_operation-dependencies.sql--- finish_job_operation <- 20260417000300_storage-unit-recreate-dependents.sql--- Taking finish_job_operation from the 2025 file instead would silently drop the--- released-job guard (20251214180817) and the whole last-operation block that--- completes the job, posts finished goods to inventory and notifies — do not.------ See .ai/specs/2026-08-25-backup-durability.md Part 3.--CREATE OR REPLACE FUNCTION check_operation_dependencies(operation_id TEXT)-RETURNS BOOLEAN-SECURITY DEFINER-SET search_path = public-LANGUAGE plpgsql-AS $$-DECLARE- incomplete_deps INTEGER;-BEGIN- SELECT COUNT(*)- INTO incomplete_deps- FROM "jobOperationDependency" dep- JOIN "jobOperation" self ON self.id = dep."operationId"- JOIN "jobOperation" jo ON jo.id = dep."dependsOnId"- WHERE dep."operationId" = operation_id- AND jo."companyId" = self."companyId"- AND jo.status != 'Done';-- RETURN incomplete_deps = 0;-END;-$$;---- Same guard. This is the one that can set an operation to Waiting, so without it--- another tenant's row can hold a real operation back the moment its dependencies--- are created.-CREATE OR REPLACE FUNCTION set_initial_dependency_status()-RETURNS TRIGGER-SECURITY DEFINER-SET search_path = public-LANGUAGE plpgsql-AS $$-BEGIN- -- Don't update if operation is already Done or In Progress- IF EXISTS (- SELECT 1- FROM "jobOperation"- WHERE id = NEW."operationId"- AND status IN ('Done', 'In Progress', 'Canceled')- ) THEN- RETURN NEW;- END IF;-- -- Check if there are any incomplete dependencies- IF EXISTS (- SELECT 1- FROM "jobOperationDependency" dep- JOIN "jobOperation" self ON self.id = dep."operationId"- JOIN "jobOperation" jo ON jo.id = dep."dependsOnId"- WHERE dep."operationId" = NEW."operationId"- AND jo."companyId" = self."companyId"- AND jo.status != 'Done'- ) THEN- -- Set status to Waiting if there are incomplete dependencies- UPDATE "jobOperation"- SET status = 'Waiting'- WHERE id = NEW."operationId";- ELSE- -- Set status to Ready if all dependencies are done or there are no dependencies- UPDATE "jobOperation"- SET status = 'Ready'- WHERE id = NEW."operationId";- END IF;-- RETURN NEW;-END;-$$;---- Body verbatim from 20260417000300; the ONLY change is the companyId guard in--- the NOT EXISTS.-CREATE OR REPLACE FUNCTION finish_job_operation()-RETURNS TRIGGER AS $$-DECLARE- job_status TEXT;-BEGIN- -- Get current job status- SELECT status INTO job_status FROM "job" WHERE id = NEW."jobId";-- -- Only process job completion logic if job is in active state (has been released)- -- Jobs in Draft or Planned status should not trigger completion since dependencies- -- are only created during scheduling- IF job_status NOT IN ('Ready', 'In Progress', 'Paused') THEN- RETURN NEW;- END IF;-- -- Set endTime for all open production events- UPDATE "productionEvent"- SET "endTime" = NOW()- WHERE "jobOperationId" = NEW.id AND "endTime" IS NULL;-- -- Find all operations that depend on this one and might be ready- UPDATE "jobOperation" op- SET status = 'Ready'- WHERE EXISTS (- SELECT 1- FROM "jobOperationDependency" dep- WHERE dep."operationId" = op.id- AND dep."dependsOnId" = NEW.id- AND op.status = 'Waiting'- )- AND NOT EXISTS (- -- Check no other dependencies are incomplete- SELECT 1- FROM "jobOperationDependency" dep2- JOIN "jobOperation" jo2 ON jo2.id = dep2."dependsOnId"- WHERE dep2."operationId" = op.id- AND jo2."companyId" = op."companyId"- AND jo2.status != 'Done'- AND jo2.id != NEW.id- );-- -- Set the job operation status to Done- NEW.status = 'Done';-- -- If this is the last operation, mark the job as Done- IF is_last_job_operation(NEW.id) THEN- DECLARE- request_id TEXT;- notify_url TEXT;- api_url TEXT;- anon_key TEXT;- group_ids TEXT[];- assigned_to TEXT;- sales_order_id TEXT;- BEGIN- -- Get job details- DECLARE- job_item_id TEXT;- job_quantity_to_produce INTEGER;- job_location_id TEXT;- job_storage_unit_id TEXT;- job_quantity INTEGER;- quantity_complete INTEGER;-- BEGIN--- SELECT "locationId", "storageUnitId", "quantity"- INTO job_location_id, job_storage_unit_id, job_quantity- FROM "job"- WHERE "id" = NEW."jobId";-- -- Use full job quantity if quantityComplete is 0- quantity_complete := CASE- WHEN NEW."quantityComplete" = 0 THEN job_quantity- ELSE NEW."quantityComplete"- END;---- -- Get sales order info- SELECT "salesOrderId" INTO sales_order_id FROM "job" WHERE "id" = NEW."jobId";-- IF sales_order_id IS NOT NULL THEN- -- Make-to-order: just update job status with quantityComplete- UPDATE "job"- SET status = 'Completed',- "completedDate" = NOW(),- "quantityComplete" = quantity_complete,- "updatedAt" = NOW(),- "updatedBy" = NEW."updatedBy"- WHERE id = NEW."jobId";- ELSE- -- Make-to-stock: update job status to Done and invoke edge function for inventory- UPDATE "job"- SET status = 'Completed',- "completedDate" = NOW(),- "updatedAt" = NOW(),- "updatedBy" = NEW."updatedBy"- WHERE id = NEW."jobId";-- -- Invoke the issue edge function to handle inventory- PERFORM util.invoke_edge_function(- name => 'issue',- body => CASE- WHEN job_storage_unit_id IS NOT NULL THEN- jsonb_build_object(- 'type', 'jobCompleteInventory',- 'jobId', NEW."jobId",- 'companyId', NEW."companyId",- 'userId', NEW."updatedBy",- 'quantityComplete', quantity_complete,- 'locationId', job_location_id,- 'shelfId', job_storage_unit_id- )- ELSE- jsonb_build_object(- 'type', 'jobCompleteInventory',- 'jobId', NEW."jobId",- 'companyId', NEW."companyId",- 'userId', NEW."updatedBy",- 'quantityComplete', quantity_complete,- 'locationId', job_location_id- )- END- );- END IF;- END;-- SELECT "apiUrl", "anonKey" INTO api_url, anon_key FROM "config" LIMIT 1;- notify_url := api_url || '/functions/v1/trigger';-- SELECT "assignee", "salesOrderId" INTO assigned_to, sales_order_id FROM "job" WHERE "id" = NEW."jobId";-- IF sales_order_id IS NULL THEN- SELECT "inventoryJobCompletedNotificationGroup" INTO group_ids FROM "companySettings" WHERE "id" = NEW."companyId";- ELSE- SELECT "salesJobCompletedNotificationGroup" INTO group_ids FROM "companySettings" WHERE "id" = NEW."companyId";- END IF;-- IF assigned_to IS NOT NULL THEN- SELECT array_append(group_ids, assigned_to) INTO group_ids;- END IF;-- IF array_length(group_ids, 1) > 0 THEN- SELECT net.http_post(- notify_url,- jsonb_build_object(- 'type', 'notify',- 'event', 'job-completed',- 'documentId', NEW."jobId",- 'companyId', NEW."companyId",- 'recipient', jsonb_build_object(- 'type', 'group',- 'groupIds', group_ids- )- )::jsonb,- '{}'::jsonb,- jsonb_build_object('Content-Type', 'application/json', 'Authorization', 'Bearer ' || anon_key)- ) INTO request_id;- END IF;-- END;- END IF;-- RETURN NEW;-END;-$$ LANGUAGE plpgsql SECURITY DEFINER;diff --git a/packages/jobs/src/inngest/functions/scheduled/index.ts b/packages/jobs/src/inngest/functions/scheduled/index.tsindex 1742c89bae..04e07d1ad6 100644--- a/packages/jobs/src/inngest/functions/scheduled/index.ts+++ b/packages/jobs/src/inngest/functions/scheduled/index.ts@@ -7,7 +7,6 @@ export {export { mrpFunction } from "./mrp";export { notificationDigestFunction } from "./notification-digest";export { notificationPurgeFunction } from "./notification-purge";-export { tenantIntegrityFunction } from "./tenant-integrity";export { updateExchangeRatesFunction } from "./update-exchange-rates";export { weeklyFunction } from "./weekly";export { workflowRunRetentionFunction } from "./workflow-run-retention";diff --git a/packages/jobs/src/inngest/functions/scheduled/tenant-integrity.test.ts b/packages/jobs/src/inngest/functions/scheduled/tenant-integrity.test.tsdeleted file mode 100644index c5cd6402ec..0000000000--- a/packages/jobs/src/inngest/functions/scheduled/tenant-integrity.test.ts+++ /dev/null@@ -1,164 +0,0 @@-import {- type DatabaseConnection,- type Driver,- DummyDriver,- Kysely,- PostgresAdapter,- PostgresIntrospector,- PostgresQueryCompiler,- type QueryResult-} from "kysely";-import { describe, expect, it } from "vitest";-import type { JobDatabase } from "../../../db";-import type { Catalog, ColumnInfo, TableInfo } from "../tasks/company-backup";-import { findExportScopeViolations } from "../tasks/company-backup";-import { exportScope } from "./tenant-integrity";--/** Compiles SQL without a connection; every query returns no rows. */-const emptyDb = new Kysely<never>({- dialect: {- createAdapter: () => new PostgresAdapter(),- createDriver: () => new DummyDriver(),- createIntrospector: (i) => new PostgresIntrospector(i),- createQueryCompiler: () => new PostgresQueryCompiler()- }-}) as unknown as JobDatabase;--/** Same, but every count query answers with `n` rows out of scope. */-function dbReturningCount(n: number): JobDatabase {- const connection: DatabaseConnection = {- executeQuery: async <R>(): Promise<QueryResult<R>> => ({- rows: [{ n: String(n) } as unknown as R]- }),- // biome-ignore lint/correctness/useYield: never streamed in these tests- streamQuery: async function* () {}- };- const driver: Driver = {- init: async () => {},- acquireConnection: async () => connection,- beginTransaction: async () => {},- commitTransaction: async () => {},- rollbackTransaction: async () => {},- releaseConnection: async () => {},- destroy: async () => {}- };- return new Kysely<never>({- dialect: {- createAdapter: () => new PostgresAdapter(),- createDriver: () => driver,- createIntrospector: (i) => new PostgresIntrospector(i),- createQueryCompiler: () => new PostgresQueryCompiler()- }- }) as unknown as JobDatabase;-}--const col = (name: string, isNullable = false): ColumnInfo => ({- name,- dataType: "text",- udtName: "text",- isNullable,- isGenerated: false,- hasDefault: false-});--const table = (- name: string,- columns: ColumnInfo[],- foreignKeys: TableInfo["foreignKeys"] = []-): TableInfo => ({- name,- columns,- scope: { kind: "direct", column: "companyId" },- scopeColumn: "companyId",- pkColumns: ["id", "companyId"],- uniqueColumns: [],- hasId: false,- foreignKeys-});--/** A child with a NOT-NULL FK to a scoped parent — the shape the guard checks. */-const catalogWithOneNotNullFk = (): Catalog => ({- schemaVersion: "test",- tables: [- table("job", [col("id"), col("companyId")]),- table(- "jobOperationDependency",- [col("jobId"), col("companyId")],- [{ column: "jobId", refTable: "job", refColumn: "id" }]- )- ]-});--describe("exportScope", () => {- it("excludes secret tables and indexes every table by name", () => {- const catalog: Catalog = {- schemaVersion: "test",- tables: [- table("job", [col("id"), col("companyId")]),- table("apiKey", [col("id"), col("companyId")])- ]- };- const { exportable, byName } = exportScope(catalog);-- // apiKey is in SECRET_TABLES: it must never be exported...- expect(exportable.map((t) => t.name)).toEqual(["job"]);- // ...but it stays in the name index, because another table's FK may still- // resolve through it.- expect([...byName.keys()].sort()).toEqual(["apiKey", "job"]);- });-});--describe("findExportScopeViolations", () => {- it("reports nothing when every reference resolves in scope", async () => {- const { exportable, byName } = exportScope(catalogWithOneNotNullFk());-- const violations = await findExportScopeViolations(- emptyDb,- exportable,- byName,- "company-a",- "group-a"- );-- expect(violations).toEqual([]);- });-- it("names the table and column when a NOT-NULL reference escapes scope", async () => {- const { exportable, byName } = exportScope(catalogWithOneNotNullFk());-- const violations = await findExportScopeViolations(- dbReturningCount(3),- exportable,- byName,- "company-a",- "group-a"- );-- expect(violations).toEqual(["jobOperationDependency.jobId → job (3 rows)"]);- });-- it("ignores a nullable reference, which a restore nulls rather than dangles", async () => {- const catalog: Catalog = {- schemaVersion: "test",- tables: [- table("job", [col("id"), col("companyId")]),- table(- "jobOperationDependency",- [col("jobId", true), col("companyId")],- [{ column: "jobId", refTable: "job", refColumn: "id" }]- )- ]- };- const { exportable, byName } = exportScope(catalog);-- const violations = await findExportScopeViolations(- dbReturningCount(3),- exportable,- byName,- "company-a",- "group-a"- );-- expect(violations).toEqual([]);- });-});diff --git a/packages/jobs/src/inngest/functions/scheduled/tenant-integrity.ts b/packages/jobs/src/inngest/functions/scheduled/tenant-integrity.tsdeleted file mode 100644index 18ae688353..0000000000--- a/packages/jobs/src/inngest/functions/scheduled/tenant-integrity.ts+++ /dev/null@@ -1,90 +0,0 @@-import { getJobDatabaseClient, type JobDatabase } from "../../../db";-import { inngest } from "../../client";-import type { Catalog, TableInfo } from "../tasks/company-backup";-import {- findExportScopeViolations,- getCompanyTableCatalog,- SECRET_TABLES-} from "../tasks/company-backup";--/**- * Cross-tenant reference monitor.- *- * `findExportScopeViolations` already finds NOT-NULL foreign keys that escape a- * company's scope — it is the guard that refuses to produce an unrestorable- * backup. The problem is that it only runs when somebody clicks "Create backup",- * so a cross-tenant write can sit undetected until a customer's export fails.- * This runs the same query nightly, for every company, and logs what it finds.- *- * Internal monitoring only: a cross-tenant reference is an engineering- * escalation, not a message for the customer. Nothing is written and no marker- * row is created — a finding here means a write path is attributing rows to the- * wrong tenant, and that needs a human.- *- * 05:00 keeps it clear of workflow-run-retention at 04:00 and backup-maintenance- * at 03:00, so the three never contend for the connection pool.- */-export const tenantIntegrityFunction = inngest.createFunction(- { id: "tenant-integrity", retries: 2 },- { cron: "0 5 * * *" },- async ({ step, logger }) => {- return await step.run("scan-cross-tenant-refs", async () => {- const db = getJobDatabaseClient(1);- const catalog = await getCompanyTableCatalog(db);- const { exportable, byName } = exportScope(catalog);-- const companies = await db- .selectFrom("company")- .select(["id", "companyGroupId"])- .execute();-- let companiesWithViolations = 0;- let totalViolations = 0;-- for (const company of companies) {- const violations = await findExportScopeViolations(- db,- exportable,- byName,- company.id,- company.companyGroupId ?? null- );- if (violations.length === 0) continue;-- companiesWithViolations++;- totalViolations += violations.length;- logger.error("Cross-tenant references found", {- companyId: company.id,- count: violations.length,- violations- });- }-- const result = {- companiesScanned: companies.length,- companiesWithViolations,- totalViolations- };- logger.info("tenant-integrity scan complete", result);- return result;- });- }-);--/**- * The exportable table set and name index, built exactly as `buildCompanyBackup`- * builds them. Shared shape rather than a second definition, so the monitor and- * the export can never disagree about what counts as a violation.- */-export function exportScope(catalog: Catalog): {- exportable: TableInfo[];- byName: Map<string, TableInfo>;-} {- const secretTables = new Set<string>(SECRET_TABLES);- return {- exportable: catalog.tables.filter((t) => !secretTables.has(t.name)),- byName: new Map(catalog.tables.map((t) => [t.name, t]))- };-}--export type { JobDatabase };diff --git a/packages/jobs/src/inngest/functions/tasks/company-export.exclusions.test.ts b/packages/jobs/src/inngest/functions/tasks/company-export.exclusions.test.tsdeleted file mode 100644index 1f70eeb499..0000000000--- a/packages/jobs/src/inngest/functions/tasks/company-export.exclusions.test.ts+++ /dev/null@@ -1,153 +0,0 @@-import {- DummyDriver,- Kysely,- PostgresAdapter,- PostgresIntrospector,- PostgresQueryCompiler,- sql-} from "kysely";-import { describe, expect, it } from "vitest";-import type { ColumnInfo, ForeignKey, TableInfo } from "./company-backup";-import {- closureCheckedForeignKeys,- formatScopeViolation,- outOfScopeRefPredicate-} from "./company-backup";--/** Compiles SQL without a connection. */-const db = new Kysely<never>({- dialect: {- createAdapter: () => new PostgresAdapter(),- createDriver: () => new DummyDriver(),- createIntrospector: (i) => new PostgresIntrospector(i),- createQueryCompiler: () => new PostgresQueryCompiler()- }-});--const col = (name: string, isNullable = false): ColumnInfo => ({- name,- dataType: "text",- udtName: "text",- isNullable,- isGenerated: false,- hasDefault: false-});--const table = (- name: string,- columns: ColumnInfo[],- foreignKeys: ForeignKey[] = []-): TableInfo => ({- name,- columns,- scope: { kind: "direct", column: "companyId" },- scopeColumn: "companyId",- pkColumns: ["id", "companyId"],- uniqueColumns: [],- hasId: false,- foreignKeys-});--const job = table("job", [col("id"), col("companyId")]);-const byName = new Map([["job", job]]);-const exportableNames = new Set(["job", "jobOperationDependency"]);--describe("closureCheckedForeignKeys", () => {- it("keeps a NOT-NULL id reference to another exportable scoped table", () => {- const t = table(- "jobOperationDependency",- [col("jobId"), col("companyId")],- [{ column: "jobId", refTable: "job", refColumn: "id" }]- );- expect(- closureCheckedForeignKeys(t, exportableNames).map((f) => f.column)- ).toEqual(["jobId"]);- });-- it("skips a nullable reference — a restore nulls it rather than dangling", () => {- const t = table(- "jobOperationDependency",- [col("jobId", true), col("companyId")],- [{ column: "jobId", refTable: "job", refColumn: "id" }]- );- expect(closureCheckedForeignKeys(t, exportableNames)).toEqual([]);- });-- it("skips a reference to a retained global table", () => {- const t = table(- "jobOperationDependency",- [col("createdBy"), col("companyId")],- [{ column: "createdBy", refTable: "user", refColumn: "id" }]- );- expect(closureCheckedForeignKeys(t, exportableNames)).toEqual([]);- });-- it("skips a reference to a table that is not exported at all", () => {- const t = table(- "apiKeyRateLimit",- [col("apiKeyId"), col("companyId")],- [{ column: "apiKeyId", refTable: "apiKey", refColumn: "id" }]- );- expect(closureCheckedForeignKeys(t, exportableNames)).toEqual([]);- });-});--describe("outOfScopeRefPredicate", () => {- const fk: ForeignKey = { column: "jobId", refTable: "job", refColumn: "id" };- const compiled = () =>- outOfScopeRefPredicate(fk, job, byName, "company-a", "group-a").compile(db)- .sql;-- it("matches only rows whose reference is set and resolves nowhere in scope", () => {- const s = compiled();- expect(s).toContain(`"jobId" IS NOT NULL`);- expect(s).toContain(`"jobId" NOT IN`);- expect(s).toContain(`FROM "job"`);- });-- it("widens the parent set to companyId IS NULL — shared seeded substrate", () => {- // Global material/currency rows live in every target, so a reference to one- // is never a closure gap. A reference to ANOTHER company's row still is.- expect(compiled()).toContain(`"companyId" IS NULL`);- });-- it("is the exact expression the dump negates, so guard and exclusion cannot drift", () => {- // The whole point of exporting this predicate: the guard counts rows it- // matches and the dump drops those same rows with NOT (...). If these two- // ever came from separate expressions, a backup could claim to have excluded- // unrestorable rows while still carrying some.- const predicate = outOfScopeRefPredicate(- fk,- job,- byName,- "company-a",- "group-a"- );- const inner = predicate.compile(db).sql;- const negated = sql`true AND NOT (${predicate})`.compile(db).sql;-- expect(negated).toContain(`NOT (${inner})`);- });-});--describe("formatScopeViolation", () => {- it("reads like the message operators already know, and gets plurals right", () => {- expect(- formatScopeViolation({- table: "pickMethod",- column: "itemId",- refTable: "item",- rows: 1- })- ).toBe("pickMethod.itemId → item (1 row)");-- expect(- formatScopeViolation({- table: "jobOperationDependency",- column: "jobId",- refTable: "job",- rows: 3- })- ).toBe("jobOperationDependency.jobId → job (3 rows)");- });-});diff --git a/packages/jobs/src/inngest/functions/tasks/company-export.ts b/packages/jobs/src/inngest/functions/tasks/company-export.tsindex c44af65575..f0f13b04a3 100644--- a/packages/jobs/src/inngest/functions/tasks/company-export.ts+++ b/packages/jobs/src/inngest/functions/tasks/company-export.ts@@ -2,12 +2,7 @@ import { getCarbonServiceRole } from "@carbon/auth/client.server";import { sql } from "kysely";import { getJobDatabaseClient, type JobDatabase } from "../../../db";import { inngest } from "../../client";-import type {- Catalog,- ForeignKey,- Manifest,- ScopeViolation-} from "./company-backup";+import type { Catalog, Manifest } from "./company-backup";import {BACKUP_INTEGRATION,BACKUP_KIND,@@ -15,15 +10,12 @@ import {backupAssetsDir,backupTablePath,buildScopeFilter,- closureCheckedForeignKeys,copyAssetsToBackup,encodeValue,exportableColumns,- findExportScopeViolationDetails,- formatScopeViolation,+ findExportScopeViolations,getCompanyTableCatalog,mapWithConcurrency,- outOfScopeRefPredicate,STORAGE_BUCKET,selectExportableTables,serializeTable,@@ -76,8 +68,6 @@ export async function buildCompanyBackup(rows: number;/** `private`-bucket paths to copy into the backup's `assets/` folder. */assetSourcePaths: string[];- /** Rows omitted because a NOT-NULL reference escaped company scope. */- excludedRows: ScopeViolation[];}> {const { companyId, userId, includeStorage } = opts;const label = opts.label ?? null;@@ -119,34 +109,28 @@ export async function buildCompanyBackup(// Closure guard — never write a backup that couldn't be restored. A NOT-NULL FK// pointing outside the company's scope (cross-company / out-of-scope) would dump- // the child but not its parent, dangling on restore.+ // the child but not its parent, dangling on restore. Fail BEFORE writing any+ // table file, listing every offending FK.//- // These rows are EXCLUDED rather than fatal. Refusing the whole export left a- // company with no backup at all over a handful of rows that are meaningless- // without the parent they point at — and reported it as "the system created an- // invalid backup", blaming the product for a data-integrity finding. The- // exclusion is recorded in the manifest and surfaced in the UI so it is a- // disclosed omission, not a silent one.- const scopeViolations = await findExportScopeViolationDetails(+ // This refusal is DELIBERATE and is not a backup bug to route around. Row-level+ // security hides another tenant's rows from every ordinary read, so an export —+ // which runs without it — is the first thing in the system wide enough to see a+ // cross-tenant reference at all. Excluding the rows and carrying on would make+ // the only detector we have go quiet.+ const scopeViolations = await findExportScopeViolations(db,exportable,byName,companyId,companyGroupId);- // table → the FK edges whose out-of-scope rows must be excluded from its dump.- const exclusionsByTable = new Map<string, ForeignKey[]>();- const exportableNames = new Set(exportable.map((t) => t.name));- for (const v of scopeViolations) {- const table = byName.get(v.table)!;- const fk = closureCheckedForeignKeys(table, exportableNames).find(- (f) => f.column === v.column && f.refTable === v.refTable+ if (scopeViolations.length > 0) {+ throw new Error(+ `Refusing to export ${companyId}: ${scopeViolations.length} NOT-NULL reference(s) ` ++ `escape company scope, so the backup could never be restored:\n ${scopeViolations.join(+ "\n "+ )}`);- if (!fk) continue;- exclusionsByTable.set(v.table, [- ...(exclusionsByTable.get(v.table) ?? []),- fk- ]);}// Dump each non-empty table to its own `tables/<table>.ndjson.gz`, in parallel.@@ -159,28 +143,13 @@ export async function buildCompanyBackup(table.name === "externalIntegrationMapping"? sql` AND ${sql.id("integration")} != ${BACKUP_INTEGRATION}`: sql``;- // Rows whose NOT-NULL reference escapes company scope are dropped here, using- // the SAME predicate the guard above counted them with, negated. One- // expression, two uses — the guard's count and the dump's omission cannot- // drift apart.- const exclusionFilter = (exclusionsByTable.get(table.name) ?? []).reduce(- (acc, fk) =>- sql`${acc} AND NOT (${outOfScopeRefPredicate(- fk,- byName.get(fk.refTable)!,- byName,- companyId,- companyGroupId- )})`,- sql``- );// Direct-scoped tables filter by their companyId/companyGroupId column;// transitively-scoped child tables (contacts, line prices, …) filter through// their parent FK — see buildScopeFilter.const result = await sql<Record<string, unknown>>`SELECT ${sql.join(columns.map((c) => sql.id(c.name)))}FROM ${sql.id(table.name)}- WHERE ${buildScopeFilter(table, byName, companyId, companyGroupId)}${ledgerFilter}${exclusionFilter}+ WHERE ${buildScopeFilter(table, byName, companyId, companyGroupId)}${ledgerFilter}`.execute(db);if (result.rows.length === 0) {@@ -260,21 +229,13 @@ export async function buildCompanyBackup(includeStorage,tables: tableManifest,storage: storageManifest,- excludedTables,- excludedRows: scopeViolations+ excludedTables};// The manifest is NOT written here — the caller writes it LAST (after assets)// via writeBackupManifest, so its presence marks the backup as complete.const rows = tableManifest.reduce((sum, t) => sum + t.rows, 0);- return {- name,- manifest,- catalog,- rows,- assetSourcePaths,- excludedRows: scopeViolations- };+ return { name, manifest, catalog, rows, assetSourcePaths };}// One company-scoped progress marker (exports run one-at-a-time, so no run id).@@ -371,36 +332,14 @@ export const companyExportFunction = inngest.createFunction(};try {- const {- name,- manifest,- catalog,- rows,- assetSourcePaths,- excludedRows- } = await buildCompanyBackup(client, db, {- companyId,- userId,- label,- includeStorage,- onProgress: report- });-- // One line per excluded edge. A cross-tenant reference is an engineering- // escalation even though the export now succeeds — the nightly- // tenant-integrity monitor is the systematic detector, this is the- // in-context record of what this particular backup left out.- for (const v of excludedRows) {- logger.warn("Company export excluded out-of-scope rows", {+ const { name, manifest, catalog, rows, assetSourcePaths } =+ await buildCompanyBackup(client, db, {companyId,- name,- table: v.table,- column: v.column,- refTable: v.refTable,- rows: v.rows,- detail: formatScopeViolation(v)+ userId,+ label,+ includeStorage,+ onProgress: report});- }// Copy the in-scope assets server-side into the backup's `assets/` folder.// Best-effort (matches restore/import): the table files are alreadydiff --git a/packages/jobs/src/inngest/index.ts b/packages/jobs/src/inngest/index.tsindex 84c03b70ea..e39842b5d3 100644--- a/packages/jobs/src/inngest/index.ts+++ b/packages/jobs/src/inngest/index.ts@@ -61,7 +61,6 @@ import {mrpFunction,notificationDigestFunction,notificationPurgeFunction,- tenantIntegrityFunction,updateExchangeRatesFunction,weeklyFunction,workflowRunRetentionFunction@@ -148,7 +147,6 @@ export const functions = [notificationDigestFunction,notificationPurgeFunction,workflowRunRetentionFunction,- tenantIntegrityFunction,// IntegrationsjiraSyncFunction,linearSyncFunction,diff --git a/packages/jobs/src/scripts/check-backups.ts b/packages/jobs/src/scripts/check-backups.tsindex a0064ecae1..c65913cc5a 100644--- a/packages/jobs/src/scripts/check-backups.ts+++ b/packages/jobs/src/scripts/check-backups.ts@@ -151,8 +151,7 @@ function catalogAsManifest(catalog: Catalog, exportedAt: string): Manifest {columns: exportableColumns(t).map((c) => c.name)})),storage: [],- excludedTables,- excludedRows: []+ excludedTables};}diff --git a/packages/locale/locales/de/erp.po b/packages/locale/locales/de/erp.poindex 9b6dbc0389..2f71317fda 100644--- a/packages/locale/locales/de/erp.po+++ b/packages/locale/locales/de/erp.po@@ -210,9 +210,6 @@ msgstr "{total} Phasen, um Ihr Unternehmen auf Carbon live zu schalten. Jede endmsgid "{total} phases to go live"msgstr "{total} Phasen bis zur Live-Schaltung"-msgid "{total} records couldn't be backed up and won't be here afterwards."-msgstr ""-msgid "{totalQuantity, plural, one {# unit} other {# units}}"msgstr "{totalQuantity, plural, one {# Einheit} other {# Einheiten}}"@@ -10186,9 +10183,6 @@ msgstr "Nicht zertifiziert"msgid "Not enough jobs to cover quantity"msgstr "Nicht genug Aufträge zur Deckung der Menge"-msgid "Not in this backup"-msgstr ""-msgid "Not reached"msgstr "Nicht erreicht"diff --git a/packages/locale/locales/en/erp.po b/packages/locale/locales/en/erp.poindex e174d5f76a..1731aafd35 100644--- a/packages/locale/locales/en/erp.po+++ b/packages/locale/locales/en/erp.po@@ -210,9 +210,6 @@ msgstr "{total} phases to get your company live on Carbon. Each one ends at a chmsgid "{total} phases to go live"msgstr "{total} phases to go live"-msgid "{total} records couldn't be backed up and won't be here afterwards."-msgstr "{total} records couldn't be backed up and won't be here afterwards."-msgid "{totalQuantity, plural, one {# unit} other {# units}}"msgstr "{totalQuantity, plural, one {# unit} other {# units}}"@@ -10186,9 +10183,6 @@ msgstr "Not certified"msgid "Not enough jobs to cover quantity"msgstr "Not enough jobs to cover quantity"-msgid "Not in this backup"-msgstr "Not in this backup"-msgid "Not reached"msgstr "Not reached"diff --git a/packages/locale/locales/es/erp.po b/packages/locale/locales/es/erp.poindex 85c5945fb4..f727c80244 100644--- a/packages/locale/locales/es/erp.po+++ b/packages/locale/locales/es/erp.po@@ -210,9 +210,6 @@ msgstr "{total} fases para poner tu empresa en vivo en Carbon. Cada una terminamsgid "{total} phases to go live"msgstr "{total} fases para activar"-msgid "{total} records couldn't be backed up and won't be here afterwards."-msgstr ""-msgid "{totalQuantity, plural, one {# unit} other {# units}}"msgstr "{totalQuantity, plural, one {# unidad} other {# unidades}}"@@ -10186,9 +10183,6 @@ msgstr "No certificado"msgid "Not enough jobs to cover quantity"msgstr "No hay suficientes trabajos para cubrir la cantidad"-msgid "Not in this backup"-msgstr ""-msgid "Not reached"msgstr "No alcanzado"diff --git a/packages/locale/locales/fr/erp.po b/packages/locale/locales/fr/erp.poindex 505c4a6dd3..c52f35d72a 100644--- a/packages/locale/locales/fr/erp.po+++ b/packages/locale/locales/fr/erp.po@@ -210,9 +210,6 @@ msgstr "{total} phases pour mettre votre entreprise en ligne sur Carbon. Chacunemsgid "{total} phases to go live"msgstr "{total} phases pour être en direct"-msgid "{total} records couldn't be backed up and won't be here afterwards."-msgstr ""-msgid "{totalQuantity, plural, one {# unit} other {# units}}"msgstr "{totalQuantity, plural, one {# unité} other {# unités}}"@@ -10186,9 +10183,6 @@ msgstr "Non certifié"msgid "Not enough jobs to cover quantity"msgstr "Pas assez de tâches pour couvrir la quantité"-msgid "Not in this backup"-msgstr ""-msgid "Not reached"msgstr "Non atteint"diff --git a/packages/locale/locales/hi/erp.po b/packages/locale/locales/hi/erp.poindex 42f6e300c4..80f2138490 100644--- a/packages/locale/locales/hi/erp.po+++ b/packages/locale/locales/hi/erp.po@@ -210,9 +210,6 @@ msgstr "{total} phases to get your company live on Carbon. Each one ends at a chmsgid "{total} phases to go live"msgstr "{total} चरण लाइव होने के लिए"-msgid "{total} records couldn't be backed up and won't be here afterwards."-msgstr ""-msgid "{totalQuantity, plural, one {# unit} other {# units}}"msgstr "{totalQuantity, plural, one {# इकाई} other {# इकाइयाँ}}"@@ -10186,9 +10183,6 @@ msgstr "प्रमाणित नहीं"msgid "Not enough jobs to cover quantity"msgstr "पर्याप्त नौकरियां नहीं हैं मात्रा को कवर करने के लिए"-msgid "Not in this backup"-msgstr ""-msgid "Not reached"msgstr "प्राप्त नहीं"diff --git a/packages/locale/locales/it/erp.po b/packages/locale/locales/it/erp.poindex 63d9d31010..a57c18a70b 100644--- a/packages/locale/locales/it/erp.po+++ b/packages/locale/locales/it/erp.po@@ -210,9 +210,6 @@ msgstr "{total} fasi per mettere la tua azienda online su Carbon. Ognuna terminamsgid "{total} phases to go live"msgstr "{total} fasi per andare live"-msgid "{total} records couldn't be backed up and won't be here afterwards."-msgstr ""-msgid "{totalQuantity, plural, one {# unit} other {# units}}"msgstr "{totalQuantity, plural, one {# unità} other {# unità}}"@@ -10186,9 +10183,6 @@ msgstr "Non certificato"msgid "Not enough jobs to cover quantity"msgstr "Non ci sono abbastanza lavori per coprire la quantità"-msgid "Not in this backup"-msgstr ""-msgid "Not reached"msgstr "Non raggiunto"diff --git a/packages/locale/locales/ja/erp.po b/packages/locale/locales/ja/erp.poindex 73dfa5472e..772033e516 100644--- a/packages/locale/locales/ja/erp.po+++ b/packages/locale/locales/ja/erp.po@@ -210,9 +210,6 @@ msgstr "{total}個のフェーズでお客様の企業をCarbonで稼働させmsgid "{total} phases to go live"msgstr "{total}個のフェーズをライブにする"-msgid "{total} records couldn't be backed up and won't be here afterwards."-msgstr ""-msgid "{totalQuantity, plural, one {# unit} other {# units}}"msgstr "{totalQuantity, plural, one {# 個} other {# 個}}"@@ -10186,9 +10183,6 @@ msgstr "認定されていない"msgid "Not enough jobs to cover quantity"msgstr "数量をカバーするのに十分なジョブがありません"-msgid "Not in this backup"-msgstr ""-msgid "Not reached"msgstr "未到達"diff --git a/packages/locale/locales/ko/erp.po b/packages/locale/locales/ko/erp.poindex 0387aaead3..87bdd2057e 100644--- a/packages/locale/locales/ko/erp.po+++ b/packages/locale/locales/ko/erp.po@@ -210,9 +210,6 @@ msgstr "귀사가 Carbon을 도입하기까지 {total}단계가 있습니다.msgid "{total} phases to go live"msgstr "도입까지 {total}단계"-msgid "{total} records couldn't be backed up and won't be here afterwards."-msgstr ""-msgid "{totalQuantity, plural, one {# unit} other {# units}}"msgstr "{totalQuantity, plural, one {# 단위} other {# 단위}}"@@ -10186,9 +10183,6 @@ msgstr "인증되지 않음"msgid "Not enough jobs to cover quantity"msgstr "수량을 충족할 만큼 작업이 충분하지 않습니다"-msgid "Not in this backup"-msgstr ""-msgid "Not reached"msgstr "도달하지 않음"diff --git a/packages/locale/locales/pl/erp.po b/packages/locale/locales/pl/erp.poindex 7ec7dde795..59c224a513 100644--- a/packages/locale/locales/pl/erp.po+++ b/packages/locale/locales/pl/erp.po@@ -210,9 +210,6 @@ msgstr "{total} faz do uruchomienia Twojej firmy na Carbon. Każda kończy sięmsgid "{total} phases to go live"msgstr "{total} faz do uruchomienia"-msgid "{total} records couldn't be backed up and won't be here afterwards."-msgstr ""-msgid "{totalQuantity, plural, one {# unit} other {# units}}"msgstr "{totalQuantity, plural, one {# jednostka} other {# jednostek}}"@@ -10186,9 +10183,6 @@ msgstr "Nie certyfikowany"msgid "Not enough jobs to cover quantity"msgstr "Niewystarczająca liczba zadań do pokrycia ilości"-msgid "Not in this backup"-msgstr ""-msgid "Not reached"msgstr "Nieosiągnięty"diff --git a/packages/locale/locales/pt/erp.po b/packages/locale/locales/pt/erp.poindex d8e85f95a8..0c22ee58a2 100644--- a/packages/locale/locales/pt/erp.po+++ b/packages/locale/locales/pt/erp.po@@ -210,9 +210,6 @@ msgstr "{total} fases para colocar sua empresa ao vivo no Carbon. Cada uma termimsgid "{total} phases to go live"msgstr "{total} fases para entrar em produção"-msgid "{total} records couldn't be backed up and won't be here afterwards."-msgstr ""-msgid "{totalQuantity, plural, one {# unit} other {# units}}"msgstr "{totalQuantity, plural, one {# unidade} other {# unidades}}"@@ -10186,9 +10183,6 @@ msgstr "Não certificado"msgid "Not enough jobs to cover quantity"msgstr "Não há trabalhos suficientes para cobrir a quantidade"-msgid "Not in this backup"-msgstr ""-msgid "Not reached"msgstr "Não atingido"diff --git a/packages/locale/locales/ru/erp.po b/packages/locale/locales/ru/erp.poindex efc7834cb1..c266abe786 100644--- a/packages/locale/locales/ru/erp.po+++ b/packages/locale/locales/ru/erp.po@@ -210,9 +210,6 @@ msgstr "{total} этапов, чтобы ваша компания началаmsgid "{total} phases to go live"msgstr "{total} этапов до запуска"-msgid "{total} records couldn't be backed up and won't be here afterwards."-msgstr ""-msgid "{totalQuantity, plural, one {# unit} other {# units}}"msgstr "{totalQuantity, plural, one {# единица} other {# единиц}}"@@ -10186,9 +10183,6 @@ msgstr "Не сертифицировано"msgid "Not enough jobs to cover quantity"msgstr "Недостаточно заданий для покрытия количества"-msgid "Not in this backup"-msgstr ""-msgid "Not reached"msgstr "Не достигнуто"diff --git a/packages/locale/locales/tr/erp.po b/packages/locale/locales/tr/erp.poindex 8a459ca684..aa18757518 100644--- a/packages/locale/locales/tr/erp.po+++ b/packages/locale/locales/tr/erp.po@@ -210,9 +210,6 @@ msgstr "{total} aşama şirketinizi Carbon'da canlı hale getirmek için. Her bimsgid "{total} phases to go live"msgstr "{total} aşama canlı yayına alınacak"-msgid "{total} records couldn't be backed up and won't be here afterwards."-msgstr ""-msgid "{totalQuantity, plural, one {# unit} other {# units}}"msgstr "{totalQuantity, plural, one {# birim} other {# birimler}}"@@ -10186,9 +10183,6 @@ msgstr "Sertifikalı değil"msgid "Not enough jobs to cover quantity"msgstr "Miktarı karşılayacak yeterli iş yok"-msgid "Not in this backup"-msgstr ""-msgid "Not reached"msgstr "Ulaşılmadı"diff --git a/packages/locale/locales/zh/erp.po b/packages/locale/locales/zh/erp.poindex a62d67825c..5c9deee499 100644--- a/packages/locale/locales/zh/erp.po+++ b/packages/locale/locales/zh/erp.po@@ -210,9 +210,6 @@ msgstr "{total}个阶段让您的公司在Carbon上线。每个阶段都以检msgid "{total} phases to go live"msgstr "{total} 个阶段即可上线"-msgid "{total} records couldn't be backed up and won't be here afterwards."-msgstr ""-msgid "{totalQuantity, plural, one {# unit} other {# units}}"msgstr "{totalQuantity, plural, one {# 件} other {# 件}}"@@ -10186,9 +10183,6 @@ msgstr "未认证"msgid "Not enough jobs to cover quantity"msgstr "工作数量不足以覆盖数量"-msgid "Not in this backup"-msgstr ""-msgid "Not reached"msgstr "未到达"