POC 4 Step 1: order workflow data layer + state machine#15
Draft
Dev-Ray-Hunt wants to merge 4 commits into
Draft
POC 4 Step 1: order workflow data layer + state machine#15Dev-Ray-Hunt wants to merge 4 commits into
Dev-Ray-Hunt wants to merge 4 commits into
Conversation
Captures the 2026-06-12 workflow grilling. Adds an authoritative "Workflow Confirmation & Refinements" section to the order-management PRD (per-line status, color-up match key, production-batch trim sheet, satellite intake, DST-parse over Wilcom, new Awaiting Logo / Phone Call / Needs Approver states) and a matching POC 4 build plan in NEXT.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
SQLite schema (migration-ready for PostgreSQL), dataclass models, CRUD, 12-state per-line-item state machine with full audit logging, match-key logic (logo+style+color), approval cascade, production-batch query. DST/editor integration stubbed behind DSTNotAvailableError. No network or DST files required — runs fully in the cloud. https://claude.ai/code/session_01Bkyax7szsqDeCuBygBk8M5
Review fixes on PR #15: 1. (Option A) Remove Needs Approver from the approval cascade. Those line items were never sent to the customer, and the state machine forbids Needs Approver -> Approved, so cascading one raised InvalidTransitionError mid-loop. The cascade now only advances Sent for Approval / Phone Call; Needs Approver items are left untouched. Regression test added. 2. (Option B) Add the production-approval gate as a real state. Cleared line items (customer-approved OR exact-match repeats) now land in "Pending Production Approval" and require production.production_approve() to reach Production Ready. Nothing skips straight to runnable. The exact-match fast path skips the customer, not the production sign-off. 67 tests pass; ruff clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this builds
Step 1 of POC 4 (per
pocs/poc4_order_workflow/NEXT.md): the pure data layer and state machine. No DST files, no network, runs fully in the cloud.Files added under
pocs/poc4_order_workflow/src/schema.pydatabase.pymodels.pystate_machine.pytransition()/bulk_transition()+ audit log writercrud.pymatch_key.pyfind_approved_color_up(),cascade_approval(),resolve_logo_for_line_item()production.pyget_production_batches()+production_approve()(the production gate)dst_stub.pyparse_dst()+open_color_up_editor()stub interface; both raiseDSTNotAvailableErrorSchema highlights
ordershas nostatuscolumn — status lives onorder_line_items.statusper spec decision 1.(logo_id, style_number, color_code)exact — UNIQUE constraint oncolor_ups(logo_id, style_number, color_code, version).status_historyis append-only; everytransition()call writes an entry with actor, team_proxy flag, and timestamp.logosare all nullable — populated only when POC 1 integration is wired locally.schema.py).State machine (13 states)
Approval cascade
cascade_approval(db, colorup_id, actor):Approved.Sent for ApprovalorPhone Call.Approved → Pending Production Approvaland logs both transitions.Does not cross customers (each color-up FK-chains to one logo → one customer).
Needs Approverline items are deliberately excluded — they were never sent to the customer.Production batch query
Groups
Production Readyline items withApprovedcolor-ups by(customer_id, logo_id, placement, thread_sequence_canonical). Thread sequences are normalised withsort_keys=Trueso key-insertion-order differences don't create phantom splits.Review fixes applied
Two issues found in review and fixed on this branch:
Needs Approverwas previously in the cascade set, but the state machine forbidsNeeds Approver → Approved, so cascading such an item raisedInvalidTransitionErrormid-loop. It is now excluded; a regression test covers it.Pending Production Approvalstate. Cleared items (customer-approved and exact-match repeats alike) now stop at the gate and requireproduction_approve()to reachProduction Ready; nothing skips straight to runnable.Test results
Tests cover: all state transitions + invalid-transition guards (incl. the now-mandatory production gate), full happy-path / revision / phone-call workflows, CRUD round-trips, FK enforcement, match-key exact-match semantics, approval cascade (incl. the Needs-Approver exclusion), the production gate, production batch grouping, and the DST stub contract.
What is stubbed / skipped and why
DSTNotAvailableErrorDSTNotAvailableErrorStubbed/skipped DST work is expected, not a failure (per brief and
CLOUD_AGENTS.md).Known follow-up
The production gate is currently one-directional (
Pending Production Approval → Production Ready). No production-rejection path yet — that transition is deferred until the rejection behaviour is decided.Branch
Created from
claude/poc4-foundation(which carries the spec). Target:main. Do not merge.