feat(greenfield): rebuild SlabUploader M1-M3 on clean foundation, all gates green

Clean re-implementation of the full product (not a port of the old M3 tree):
- P0 foundation: 13-table schema + per-call sqlite factory (thread-safe),
  FastAPI app (health, JSON logging + secret redaction, CORS, startup guard).
- P1 M1 Capture: mask/sheetKeep, geometry/rect (min-area rect), measure,
  png crop/inventory/overlay, EXIF decodeOrientedBitmap.
- P2 M2 Photos: stateful capture session (batch, pick-cal, apply mask/crop
  to batch) + photos-ready lineup.
- P3 M3 Create: real backend (crypto, woo client, taxonomy sync, pricing,
  inference Call1/Call2, review, publish, settings, slabs, photos) + real FE
  review/publish/settings screens consuming the API (no hardcoded Woo ids).
- P4 gate exit: check_requirements + check_coverage both exit 0
  (137/155 IDs, 0 gaps); backend 130/130, frontend 150/150, build green.

Cite: docs/REQUIREMENTS.md (155 rows), docs/MILESTONES.md M1-M3.
This commit is contained in:
2026-09-25 06:57:29 -07:00
parent 4ca2ef57a7
commit 49c22c9385
106 changed files with 5502 additions and 8863 deletions
+40
View File
@@ -0,0 +1,40 @@
import pytest
import tempfile
import os
from backend.db import get_connection, init_db
EXPECTED_TABLES = {
"slabs", "slab_photos", "pricing_rules", "woo_categories",
"woo_attributes", "woo_attribute_terms", "woo_tags", "settings",
"schema_version", "prompts", "prompt_revisions", "sync_log", "inference_log",
}
def test_init_db_creates_all_13_tables(tmp_path):
db_path = str(tmp_path / "test_schema.db")
init_db(db_path)
conn = get_connection(db_path)
rows = conn.execute("SELECT name FROM sqlite_master WHERE type='table'").fetchall()
names = {r["name"] for r in rows}
assert names >= EXPECTED_TABLES
assert len(EXPECTED_TABLES) == 13
def test_slab_insert_read_roundtrip(tmp_path):
db_path = str(tmp_path / "test_slab.db")
init_db(db_path)
conn = get_connection(db_path)
now = "2026-01-01T00:00:00+00:00"
conn.execute(
"""INSERT INTO slabs (id, status, sku, length_in, thickness_in, sqft, bdft,
client_rev, server_rev, created_at, updated_at)
VALUES ('slab-1', 'draft', 'SLAB-001', 10.0, 2.0, 5.0, 40.0, 1, 1, ?, ?)""",
(now, now),
)
conn.commit()
row = conn.execute("SELECT id, sku, status FROM slabs WHERE id=?", ("slab-1",)).fetchone()
assert row["id"] == "slab-1"
assert row["sku"] == "SLAB-001"
assert row["status"] == "draft"