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.
Executor instructions — Job Operation Batching v2 (for Opus)
You are executing a fully-planned feature. All design decisions are made and locked; your job is mechanical execution with verification. Do not redesign, do not re-litigate decisions, do not improvise around blockers.
Mission
Implement Job Operation Batching on branch feat/job-operation-batching-v2
by following .ai/plans/2026-08-21-job-operation-batching.md task by task.
Read these three files completely before touching any code:
.ai/plans/2026-08-21-job-operation-batching.md— the 13 tasks. This is your script. Its "Executor ground rules" and "Conflict watch" sections are binding..ai/specs/2026-08-21-job-operation-batching.md— the design. Consult it when a task's intent is unclear. Spec wins over plan; code wins over both — if they disagree, stop and report the conflict instead of picking one..ai/research/job-operation-batching.md— background only; no action items.
Context you need (30 seconds of history)
- This is the third attempt at this feature (issue #1010). Two prior
implementations exist and BOTH are salvage sources, not ancestors:
feat/job-operation-batching(git ref$SRC, tip8f7fc8a67) — most of the code comes from here, including the already-built two-phase completion.origin/loop/1010-20260714010219(PR #1137, closed) — one test file only.
- The branch you are on was cut fresh from
mainon 2026-08-21. Three doc commits are already on it.mainhas moved a month past both salvage sources, so ported hunks WILL conflict in places — the plan tells you how to resolve each one (every modified file has an "intent" line; resolve toward the intent, keep main's surrounding code). - A large open PR (#1151, capacity planning) overlaps this feature. You do NOT handle the overlap — the plan's Task 2 pre-flight detects if it merged and tells you to stop. If that happens, stop.
Hard rules (violating any of these is failure)
- Never
git merge,git rebase, orgit cherry-pickfrom the salvage refs. Port files exactly as the plan's ground rules 2–3 describe (git showfor new files,git diff | git apply --3wayfor modified ones). - Never rebuild, reset, or re-seed the database.
pnpm db:migrate(apply pending) is allowed and required. If the DB is unreachable, stop and ask. - Never push. Commit locally per task; pushing needs the user's explicit per-push approval.
- Never run a whole-repo typecheck (it OOMs). Only
pnpm exec turbo run typecheck --filter=erp/--filter=mes/--filter=@carbon/utils. - Never hand-edit generated files:
packages/database/src/types.ts,packages/database/supabase/functions/lib/types.ts,*.pocatalogs, swagger. Regenerate them. - Working-tree hygiene: the tree carries uncommitted files from unrelated
licensing work (
.ai/specs/2026-08-19-licensing-*,.ai/research/2026-08-19-*, and local edits to both generated types files andtool-metadata.json). NEVER commit, revert, or delete them. Commit only files your current task touched, listed explicitly in thegit commitcommand — nogit add -A, nogit commit -a. - Evidence before assertions. Run every Verify block, read the output, and only then state the result. Never claim green without output. If a verify fails, fix and re-run; do not proceed on red.
- Banned term: the pattern
st[i]tch(case-insensitive) must not appear in anything you write — code, SQL, comments, commit messages. - No new dependencies, no schema beyond the plan's migration, no scope changes. Anything that seems to need one → stop and ask.
Execution loop
For each task N in the plan's Progress list, in dependency order:
- Re-read the full task text.
- Do the steps exactly. Where a step says "STOP and report", that is a real instruction — end the task, describe the situation, and wait.
- Run the Verify block; paste its real output into the run log (see below).
- Check the task off in the plan file's Progress list (edit the
- [ ]to- [x]). - Commit via the
/check-and-commitskill (it runs the right gates and commits only when green). Conventional commit message, e.g.feat(production): <what task N added>. No AI attribution lines. - Append a short entry to the run log.
Run log: create .ai/runs/2026-08-21-job-operation-batching.md at start with
a heading per task; per task record: what was ported/created, conflicts hit
and how resolved (file + one line), verify output tail, commit SHA.
Tasks 4 and 5 are independent of each other; everything else follows the plan's dependency graph. Doing them sequentially is fine.
Known traps (each has burned a previous attempt — do not rediscover them)
productionEvent.durationis a GENERATED column. Never write it. Slices write start/end windows only; cost follows automatically.- Importing from a new directory barrel (
~/modules/.../Batching) crashes Vite SSR with a cached resolution miss. Routes import concrete files (./BatchingBoard,./types). The salvage already does this — keep it. - Components must not import types from route files (breaks tsgo whole-program
inference in unrelated files). Shared UI types live in
ui/Schedule/Batching/types.ts. - RVF only coerces a repeated form field to an array at ≥2 values. Array
fields use
zfd.repeatable/zfd.repeatableOfType, neverz.array. - MES completion pre-fill:
targetQuantityis 0 (not null), sotargetQuantity ?? operationQuantitypre-fills 0. Pre-fill fromoperationQuantity. Per-member number fields useNumberControlled. production.models.tscontains"Cancelled"in JOB status consts — those are correct. Only thejobOperationBatchStatusconst must be exactly["Active", "Completing", "Completed"].- After
pnpm run generate:types, checkgit diff --staton the types file. Mass deletions of unrelated tables = stale local DB → stop and ask; do not commit deletions. pnpmonly, nevernpm. The ERP package filter name iserp, not@carbon/erp.- No JavaScript
Datefor parsing/formatting/arithmetic in app code — the salvage code already follows this; keep it that way in any glue you write.
Blockers — stop and ask instead of working around
- Task 2 pre-flight expectations fail (capacity planning or anything else redefined the view/RPC on main).
- The local dev DB is unreachable, or
pnpm db:migrateerrors. - Generated types diff shows mass unrelated deletions.
- A salvage file references a function/component that no longer exists on main and the fix is not obvious from the task's intent line.
- Anything in Ask-First territory: schema beyond the plan's migration, auth/RBAC/tenancy logic, public contracts, new dependencies.
- Task 13 needs the user's running dev stack; if it is not up, finish Task 12, report, and ask — do not start servers yourself and do not skip the task silently.
Definition of done
- All 13 Progress boxes checked in the plan file.
- Every Verify block ran green with output captured in the run log.
- One commit per task (13 commits, plus fixes), nothing pushed.
- Spec changelog updated (Task 11).
- Final message to the user: two-line summary, list of commit SHAs, any deviations from the plan (there should be none that weren't reported), and the Task 13 browser-verification evidence or the reason it is pending.