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.
Animated Work Instructions — Implementation Plan
Spec: .ai/specs/2026-07-04-animated-work-instructions-design.md
Research: .ai/research/animated-work-instructions.md
Conventions: .ai/rules/conventions-database.md, conventions-services.md,
conventions-forms.md, conventions-ui.md
Working name for the module: assembly.
Phase 0 — Foundations (assembly-aware viewer + manual animated instructions)
Goal: STEP upload → server-converted GLB with assembly hierarchy → new AssemblyPlayer component → manually authored animated steps, playable in ERP and MES. No planner yet. This phase is shippable on its own and de-risks the whole stack.
0.1 Geometry service skeleton
Files: create services/geometry/ (Dockerfile, pyproject.toml, FastAPI app)
- FastAPI app with
/health,/convert(accepts signed source URL + signed PUT URLs for artifacts, plus options: deflection, units), API-key auth via shared secret env. - Dependencies:
cadquery-ocp(OCCT),trimesh,pygltflib; pin versions. - Local dev: docker-compose entry; document
npm run devinterplay in README. - Commit.
0.2 STEP → GLB + graph.json conversion
Files: services/geometry/app/convert.py, tests with 2–3 sample STEP fixtures
STEPCAFControl_Reader→ XCAF doc → walk assembly tree: per-node name, local transform, product vs instance, color.BRepMesh_IncrementalMesh(configurable deflection) →RWGltf_CafWriterGLB.- Generate stable node IDs:
hash(geometryHash + parentPath + siblingOrdinal); write into glTF nodeextras(post-pass with pygltflib) and intograph.json(tree, transforms, bboxes, volume, unit). - Unit-normalize to mm; record source unit.
- Pytest over fixtures: node count, ID stability across two runs, GLB loads in
three.js (validate with
gltf-validatorin CI). - Commit.
0.3 Meshopt compression pass
Files: services/geometry/app/optimize.py (or Node sidecar step in the Inngest fn
using @gltf-transform/cli)
- Apply quantize +
EXT_meshopt_compression; preserve node extras. - Verify size reduction and round-trip of extras in test.
- Commit.
0.4 Database migration: processing columns + plan job table
Files: packages/database/supabase/migrations/<ts>_assembly-foundations.sql
- Follow
.ai/rules/conventions-database.md. AltermodelUpload: addprocessingStatus,processingError,glbPath,graphPath,partCount,processedAt. - Create
assemblyPlanJobper spec (kind: 'convert' now, 'plan' later) with RLS. npm run db:build; commit.
0.5 Inngest convert pipeline
Files: packages/jobs/src/inngest/tasks/assembly-convert.ts, event in
packages/jobs/src/events.ts
- Event
assembly/model.process{modelUploadId, companyId, userId}. - Function: mark queued → create signed URLs → POST geometry
/convert→ poll/await → updatemodelUpload+assemblyPlanJob→ emitassembly/model.processed. - Failure path writes
processingError; retries per existing Inngest patterns (mirrormodel-thumbnail.ts). - Trigger from the existing model upload path for
.step/.stpfiles (find the upload action that writesmodelUpload). - Commit.
0.6 packages/viewer: AssemblyPlayer
Files: create packages/viewer/ (package.json, tsup config) with
AssemblyViewer.tsx, AssemblyPlayer.tsx, useAssembly.ts, motion.ts
- Deps:
three(catalog),@react-three/fiber,@react-three/drei,three-stdlibmeshopt decoder. No imports from apps. useAssembly(glbUrl, graphUrl): loads GLB, indexes nodes by stable ID, exposes tree + setters (highlight, ghost/wireframe, hide, transform offset).motion.ts: build three.js KeyframeTracks from step motion JSON ({linear|L|helix|path}); reverse for insertion playback; per-step clip cache.AssemblyPlayer: props = {glbUrl, graphUrl, steps, activeStepIndex, onStepChange, readOnly}; renders canvas, step scrubber, play/pause, part highlight for active step, prior parts solid / future parts hidden or ghosted.- Storybook-style demo route or vite playground inside the package for development.
- Commit.
0.7 Instruction schema migration
Files: packages/database/supabase/migrations/<ts>_assembly-instructions.sql
assemblyInstruction,assemblyInstructionStepper spec (fractionalsortOrder, JSONB motion/camera/fastener/warnings,partNodeIds TEXT[],planConfidence), RLS, indexes on (companyId, modelUploadId) and (assemblyInstructionId, sortOrder).- Nullable
assemblyInstructionIdFK onjobOperationandmethodOperationStep. - New
assemblymodule permissions wired like existing modules (check howqualityor similar module registers permissions). npm run db:build; commit.
0.8 Assembly module: models + service
Files: apps/erp/app/modules/assembly/assembly.models.ts, assembly.service.ts
- Zod validators (instruction, step upsert with motion JSON schema) per
.ai/rules/conventions-forms.md; service CRUD perconventions-services.md(Kysely transaction for bulk step writes/reorder — seedatabase-transactionsskill notes). - Commit.
0.9 ERP routes: instruction editor (manual authoring MVP)
Files: apps/erp/app/routes/x+/assembly+/ (list, $id.tsx editor), path entries
in apps/erp/app/utils/path.ts
- List route: instructions table (status, item, model, updated).
- Editor route: three-pane layout — step list (drag reorder via fractional sortOrder), AssemblyPlayer center, step detail form right (title, text, partNodeIds via click-to-select in viewer, motion editor: direction gizmo + distance, helix params).
- "New instruction from model" action on item Model tab when
processingStatus = success. requirePermissionswithassemblymodule throughout.- Commit.
0.10 MES playback (read-only)
Files: apps/mes/app/routes/x+/operation.$operationId.tsx (+ JobOperation
component)
- If linked instruction exists, render AssemblyPlayer (readOnly) in/next to the Model tab; step next/prev controls sized for gloved touch.
- Commit.
0.11 Phase 0 verification
/login+/test: upload a multi-part STEP fixture, watch convert succeed, author 3 manual steps, play in editor, link to a job operation, view in MES.- Record findings; fix; commit.
Phase 1 — Auto-draft (the planner)
Goal: "Generate instructions" produces a complete draft: fastener groups, sequence, motions, text.
1.1 Contact/blocking graph
services/geometry/app/contacts.py: trimesh-based proximity/contact pairs (distance <
ε), per-pair contact normals + blocked direction cones; persisted into graph.json.
Tests on fixtures (stacked plates, pin-in-hole).
1.2 Fastener classification
services/geometry/app/fasteners.py:
- Name regex table (ISO/DIN/ANSI/McMaster patterns) over node names.
- Geometry heuristic: small bbox, ≥80% lateral surface from coaxial cylinders (OCCT face typing), hex/socket head detection; duplicate clustering by geometry hash.
- Axis + insertion direction from coaxial hole in contacting part; emit fastener groups {spec?, count, axis, targetNodeIds}.
- Tests: fixture with named + unnamed screws; false-positive guard (dowel pins classified as pins not screws is acceptable Phase 1).
1.3 Greedy disassembly sequencer
services/geometry/app/sequence.py:
- Candidate directions per part: ±XYZ, principal axes, hole/fastener axes.
- Removability: sample path (~100 poses × clearance ε) collision checks (trimesh.CollisionManager); fasteners removed first per group (analytic helix + retract).
- Greedy loop respecting XCAF subassembly boundaries; tie-break: top-down, outside-in, small-parts-last reversed to small-parts-first on assembly.
- Tier-4 "L" motions (lift-then-slide two-segment search) for failures.
- Unresolved parts → manual steps with reason codes.
- Output plan.json: ordered steps {partNodeIds, motion, confidence, warnings}.
- Budget caps + structured timing stats. Tests on 3 fixtures incl. one designed failure.
1.4 /plan endpoint + Inngest wiring
/planon geometry service (inputs: graph.json + GLB or mesh cache; output: plan.json to signed URL).- Inngest
assembly-plan.ts: chain after convert when user requests generation;assemblyPlanJobkind 'plan'; on success, transactional draft creation:assemblyInstruction+ steps from plan.json (motion, partNodeIds, fastener, warnings, confidence).
1.5 Step text generation
packages/jobs/src/inngest/tasks/assembly-step-text.ts: structured facts → existing AI
infra (small prompt, batch) with deterministic template fallback ("Install 4× M5 SHCS
into mounting plate (8 N·m)"). Editor regenerate button per step.
1.6 Editor: draft triage UX
Confidence filter (low-confidence/manual-needed queue), accept/fix flows, re-plan button (re-runs planner preserving user-edited steps by partNodeIds match).
1.7 Phase 1 verification
End-to-end on 3 real assemblies (find public STEP assemblies: gearbox, vise, enclosure) — measure: % steps auto-accepted, planner wall time. Target: >70% steps accepted unedited, <5 min for ≤200 parts.
Phase 2 — Editor depth + MES execution
- 2.1 Subassembly grouping UI (parentStepId tree; collapse groups into single steps).
- 2.2 Exploded view generation (offsets along removal directions; explode slider in player; per-step explode JSON).
- 2.3 Auto-camera: offscreen ID-buffer scoring of ~26 candidate views per step in the geometry service or client; temporal smoothness penalty; stored in step camera JSON.
- 2.4 Stability gate: pybullet drop-test per reversed step → hold/fixture warnings surfaced as step callouts.
- 2.5 MES execution: step-complete events, per-step durations on jobOperation, parts/ fastener pick callouts; gloved-touch UI polish.
- 2.6
share+public player route (signed, revocable) — the standalone wedge. - 2.7 Tool/torque libraries: link
methodOperationTool/resources; torque field on fastener JSON surfaced in player.
Phase 3 — Moats
- 3.1 Revision propagation: graph diff (name + geometry hash + position matching), step remap, "needs review" flags, instruction version bump flow.
- 3.2 Physics escalation tier (Assemble-Them-All-style force-guided search, MIT code as reference; budget-capped, behind a flag).
- 3.3 Onshape: pull mates + native glTF for connected tenants; mate axes feed the sequencer.
- 3.4 APS Model Derivative fallback for native formats (SLDASM/NX/CATIA) using existing AutodeskViewer/urn plumbing.
- 3.5 Operator feedback loop:
assemblyInstructionFeedbackfrom MES → editor inbox. - 3.6 PDF/static export via
packages/documents(per-step rendered frames). - 3.7 FTO review (US 11,813,756; US 9,053,258; US 7,295,201) before GA marketing.
Risks / open questions
- OCCT learning curve + dirty CAD — mitigate with per-part failure isolation and a fixture corpus collected from real customer files early.
- Planner quality on real assemblies is the product risk; Phase 1.7 metrics gate further investment in tiers vs. editor ergonomics.
- ECS sizing/cost for geometry workers (CPU/mem heavy, bursty) — start with one modest service + queue depth alarm; Modal/Fly escape hatch documented.
- Single new language in the monorepo (Python service) — CI, lint, deploy pipelines need an owner; keep the service API tiny.
- Naming: "assembly" module vs. product name (decide before routes ship).
Review
(to be filled in during execution)