Skip to content

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.

2.4 KB
Raw Blame

Model raw retention: decoupled compact + xbf mode + orphan-only prune

Problem: STEP raws >50MB get lost. Compact (raw → .zst) only runs inside the optimize success path (best-effort), and the nightly prune deletes any non-.zst temp-staging raw >50MB older than 7 days — including raws whose optimize failed/was skipped, legacy pre-pipeline raws, and compact-failed raws. Result: modelUpload.modelPath points at a deleted object → assemblies say "no model".

Decisions (user-approved 2026-07-22):

  • Compact STEP raws to xbf (STEP → OCCT BinXCAF → zstd, mode xbf) — far smaller than zstd'd ASCII STEP. Mesh raws keep mode zstd.
  • xbf raws are not downloadable (OCCT-internal format) — hide the download action in the files lists.
  • Compact is decoupled from optimize success; prune becomes orphan-only.

Tasks

    1. packages/lib/src/events.ts — add carbon/model-compact event { modelUploadId, companyId }.
    1. packages/utils/src/file.ts — add isModelRawDownloadable(modelPath): false when the .zst-peeled path ends .xbf. Export via utils barrel.
    1. New packages/jobs/src/inngest/functions/tasks/model-compact.ts — standalone Inngest function (retries 3): load row; skip if already .zst, non-temp-staging bucket, no optimizable format, or assembler disabled; mode xbf for step (output {id}.xbf.zst) else zstd (output {id}.{format}.zst); persist repoint (freeze originalSize, rewrite size), delete fat original.
    1. model-optimize.ts — remove inline compact block; fire carbon/model-compact on success, on alreadyOptimized (heals legacy fat raws), and in onFailure.
    1. Register function in tasks/index.ts + inngest/index.ts.
    1. cleanup.ts prune — exclude any candidate still referenced by a modelUpload.modelPath (orphan-only delete).
    1. production.models.ts getAssemblyModelState — accept .xbf.
    1. Hide download for non-downloadable raws in Documents.tsx, OpportunityLineDocuments.tsx, JobDocuments.tsx, ItemDocuments.tsx.
    1. Update stale comments (const.ts prune note, model-optimize header).

Verification

  • pnpm exec turbo run typecheck --filter=@carbon/utils --filter=@carbon/jobs --filter=erp
  • Existing behavior preserved: already-compacted .step.zst rows still read (assembler content-sniffs; state check peels .zst).