Skip to content

BE-DP-42 · How many loaded inspections D94's constraints would refuse

ID BE-DP-42 · Level L0 · Pack Pack 0l · D94's inspection constraints · Run order row 0l, before the constraints and their tests · Issue #588

D94 puts two check constraints on public.inspections: an outcome on every preparation inspection and on no other kind, and a work_order_id only on a return or a preparation inspection. Before they go on, this step counts the inspections a local night loads that each would refuse. A count above 0 is a rule question for zuki, never a reason to drop a constraint.

The operations step as written should give 0 on all three: it fills outcome and work_order_id only on the preparation rows, and v1's outcome goes through value_map, where an empty one has no row and stops the night (R-MIG-02). This step proves it on the loaded rows.

It prints counts by kind only, never a plate, a name or v1's text (D15). It changes nothing.

  • You are at the root of your clone, on team/584-v1-workflow-review or integration, after pnpm supabase db reset and BE-DP-07.
  • docker ps --filter name=v1copy lists the copy as Up.
Terminal window
python3 tools/migration/night.py local be-dp-40

Only that it ran through its steps matters here; a changed count is for #306, not this step.

Terminal window
docker exec -i supabase_db_opleet psql -qX -U postgres -d postgres -v ON_ERROR_STOP=1 <<'SQL'
select kind,
count(*) as inspections,
count(*) filter (where kind <> 'preparation' and outcome is not null) as outcome_not_preparation,
count(*) filter (where kind = 'preparation' and outcome is null) as preparation_no_outcome,
count(*) filter (where work_order_id is not null and kind not in ('return', 'preparation')) as work_order_wrong_kind
from public.inspections group by 1 order by 1;
SQL

Four lines, one per kind, with the last three columns 0. The inspections column matches be-dp-40.expect (checkpoint 4711, handover 2131, preparation 1073, return 1537 on 2026-11-06; v1 moves).

Block 2's output is the check.

A number above 0 in the last three columns: post block 2's output on #588 and stop. It goes to zuki as a rule question (D94).

Nothing to undo: block 2 only reads. pnpm supabase db reset clears the night.

One comment per run on #588: date · who · result · notes.