feat(gate-b): Gate B mask + BDFT + length axis (#21–#23) #31

Closed
grokbot_ty wants to merge 41 commits from gate-b into main

41 Commits

Author SHA1 Message Date
grokbot_ty 77b943822d results(gate-b): pass6 UI-MASK cutout-on-checkerboard — 3 pass / 0 fail / 2 blocked; Gate B not green 2026-09-08 14:41:02 +00:00
grokbot_ty 2586fdb135 test(gate-b): update Playwright assertions for cutout-on-checkerboard (#55)
- live-mask.spec.ts: replace green-overlay avgAlpha assertions with
  checkerboard + slab pixel detection; add green-overlay color rejection
  check; fix hasColorVariance false-positive with monochrome test image
- mask-ux.spec.ts: rename test to match new rendering (no green overlay)
- playwright.config.ts: set baseURL when webServer is used so page.goto('/')
  resolves correctly in local dev

Fixes: issue #55 mask preview
2026-09-08 00:35:08 +00:00
grokbot_ty 83171fab6e fix(gate-b): drawMaskOverlay — cutout on checkerboard, no green overlay (#55)
Replace green overlay rendering with cutout-on-checkerboard preview:
- Slab pixels show actual photo RGB with mask-based alpha
- Removed background area shows 10px checkerboard (224/192 gray)
- Knob debounce from a1d4a96 preserved unchanged

Update Playwright test to assert checkerboard + slab pixels
visible, not green overlay avgAlpha.
2026-09-08 00:30:24 +00:00
grokbot_ty 3496670045 results(gate-b): pass5 evidence — 28 rows, 23 pass / 0 fail / 5 blocked; live-host mask fundamentals e2e pass on Tailscale; Gate B not green 2026-09-07 22:02:32 +00:00
grokbot_ty 8deb18de1b docs(test-spec): encode PRODUCT GATE vs REPORTING locks
Separate fail-closed Results reporting from product-gate readiness.
Thin BVTs and tip/paperwork cross-checks do not unlock UI, walkable, or UAT.
2026-09-07 21:57:12 +00:00
grokbot_ty 247b6b9a06 results(gate-b): LIVE mask fundamentals verification — all 3 checks pass on 100.64.0.9
- overlay translucent: avgAlpha 16.0, maxAlpha 80, green fraction 20%
- knobs respond fast: sensitivity 42-71ms, edge offset 18-24ms
- auto sheet: slab fraction 0.200, not entire frame marked as slab

Playwright tests run against deployed host with ignoreHTTPSErrors.
Evidence: test-results/gate-b-2026-09-07-live-verify/
Test suite: frontend/test/bvt/live-mask.spec.ts
2026-09-07 21:56:44 +00:00
grokbot_ty 5a35dbf1df results(gate-b): note issue #55 needs manual update 2026-09-07 21:33:38 +00:00
grokbot_ty adc505418a results(gate-b): mask UX fix evidence — translucent overlay, 38ms knob response
- Updated RESULTS.md with mask UX fix section
- Screenshot shows translucent light green overlay, photo visible
- Playwright timing: sensitivity 38ms, edge offset 38ms, sheet switch 21ms
- Tip: 866de43 (fix + tests committed and deployed)

Fixes: issue #55
2026-09-07 21:33:00 +00:00
grokbot_ty 866de43541 gate-b: add mask UX Playwright tests — overlay visual + knob timing
- mask-ux.spec.ts: 4 tests — translucent overlay visual, sensitivity knob
  (38ms), edge offset knob (38ms), sheet switch (21ms)
- playwright.config.ts: allow PLAYWRIGHT_BASE_URL env override for remote testing

Evidence: mask-overlay-translucent.png shows translucent green overlay
with photo visible underneath.

Fixes: issue #55 — mask overlay usability evidence
2026-09-07 21:32:31 +00:00
grokbot_ty a1d4a96a0a gate-b: fix mask overlay opacity, auto-sheet fallback, and knob debounce
- drawMaskOverlay: reduce green overlay max alpha 140→80 (~31% opacity),
  lighten green from (0,200,0) to (60,220,60) so photo stays visible
- resolveSheet: when auto-detect is ambiguous, try both green and black
  sheet modes, pick whichever produces non-trivial slab area (1%-99%)
- Knob sliders: debounce full remask to 150ms; oninput redraws with
  previous mask (cheap), onchange triggers immediate full remask
- Add onDestroy cleanup for debounce timeout

Fixes: issue #55 — iPad mask preview nearly solid green, knobs laggy
2026-09-07 21:26:50 +00:00
grokbot_ty 4cebdc4b70 results(gate-b): pass4 evidence — 24 rows, 20 pass / 0 fail / 4 blocked; TV-3/6/7/10 product-state blocked; UI-BVT-1 Select Photos e2e; Gate B not green 2026-09-07 19:49:59 +00:00
grokbot_ty 18a453a171 results(gate-b): Playwright BVT evidence — Select Photos click path verified
Local + remote tests pass. Fix deployed on ubuDual5060.
2026-09-07 19:44:51 +00:00
grokbot_ty 17b6e6ccd6 fix(gate-b): Svelte 5 event directives + label/input association for Select Photos
- Add id='photo-file-input' to file input and for='photo-file-input' to label
- Convert on:change → onchange, on:click → onclick, on:input → oninput
  (Svelte 5 requires native DOM event properties, not on: directives)
- Add Playwright BVT suite confirming file selection → mask step advance
- Test image: 100x60 PNG with green border (hue=66°) and white interior
2026-09-07 19:38:46 +00:00
grokbot_ty 2a8b0e5518 Gate B: pass 3 RESULTS.md — 19 rows, 13 pass / 6 blocked / 0 fail; TV-3/6/7/10 product-state blocked; Gate B not green 2026-09-07 19:04:54 +00:00
grokbot_ty 8d8b3a2ff1 Gate B: SvelteKit capture→mask→numbers→review UI with deterministic pipeline
- Scaffold SvelteKit app (svelte.config.js, vite.config.ts, app.html, app.d.ts)
- Build full capture flow: photo input → mask overlay + 4 knobs → axis overlay
  + rotation → length/thickness/SKU inputs → review + upload to /api/v1/slabs
- Uses existing lib/pipeline/* pure modules (mask, axis, units, crop, pricing, types)
- Uses existing validation/sku.ts for SKU validation
- Svelte 5 runes ($state, $effect, $derived) for reactive state
- Canvas-based rendering for mask overlay, axis visualization, and 3:4 crop preview
- Dockerfile updated for Vite production build with static Node server on :80
- All 54 existing tests pass, build succeeds
2026-09-07 18:53:35 +00:00
grokbot_ty f82287db78 fix(gate-b): IP-based TLS — :443 catch-all + IP SANs on cert
- Caddyfile: switch slab.local site block to :443 catch-all so
  any SNI (IP or hostname) reaches the reverse proxy. Bare IP
  HTTPS no longer fails with SSL_ERROR_INTERNAL_ERROR_ALERT.
- Cert: regenerate self-signed cert with SANs: DNS:slab.local,
  IP:192.168.1.202, IP:100.64.0.9. IP SANs ensure cert is presented
  for IP-based connections; :443 catch-all ensures Caddy routes
  the request regardless of SNI.
- INVENTORY.md: document IP SANs, :443 catch-all, phone access
  steps, and bare-IP test results.

Verified on ubuDual5060:
- curl -sk https://192.168.1.202/api/health → 200 ok
- curl -sk https://192.168.1.202/ → 200, frontend HTML
- curl -sk https://100.64.0.9/api/health → 200 ok
- curl -skI http://192.168.1.202/ → 308 redirect to HTTPS
- openssl s_client to 192.168.1.202:443 → TLS 1.3 handshake OK
2026-09-07 18:40:24 +00:00
grokbot_ty adb50d971a fix(gate-b): restore TLS for slab.local with file-based certs
- Caddyfile: switch from :80 catch-all to slab.local with file-based TLS
  using self-signed cert from deploy/certs/
- docker-compose.yml: publish 443, mount certs volume read-only
- INVENTORY.md: update smoke section with HTTPS results, note phone CA TBD

Host fix: added slab.local → 192.168.1.202 to /etc/hosts,
Caddy now serves HTTPS with HTTP→HTTPS redirect,
curl -k https://slab.local/api/health returns 200 ok.
2026-09-07 18:29:39 +00:00
grokbot_ty fb892e4a32 feat(gate-b): add product-state fixture harness for TV-3/6/7/10
Real-fixture path and harness for product-state evidence on TV-3 bdft identity,
TV-6 crop/PNG rules, TV-7 undersized warn/retake, and TV-10 rounding.

- fixtures/real/: acquisition README, placeholder metadata JSON templates
- fixtures/real-fixtures.ts: loader that decodes real PNGs, generates masks,
  runs the pipeline, fails-closed when absent or unmarked
- tv3-real.test.ts / tv6-real.test.ts / tv7-real.test.ts / tv10-real.test.ts:
  product-state tests that skip when real fixtures are absent
- Updated RESULTS.md with real-fixture harness note
- Added pngjs devDependency for PNG decoding in Node.js

Dual-proof preserved: proxy-synthetic unit rows remain separate and unchanged.
Gate B is not green; product-state rows are blocked pending Ty-supplied photos.
2026-09-07 18:23:04 +00:00
grokbot_ty d5d5cded62 fix(D-1): python-multipart install fix for TestCreateSlab (#29)
D-1 contract tests now pass (8/8). The python-multipart>=0.0.30,<1
dependency was already in requirements.txt but the venv was not rebuilt
after it was added, causing all 8 TestCreateSlab tests to fail with:

  AssertionError: The python-multipart library must be installed

The endpoint POST /api/v1/slabs correctly returns 201 with status
calibrated and server_rev for multipart uploads containing data JSON,
files[], and meta[].

Evidence: test-results/d1-fix-2026-09-07/pytest.txt (8 passed)
2026-09-07 18:19:23 +00:00
grokbot_ty 699b6a07d6 Fix Gate B pass2 counts: 18 pass / 1 fail / 5 blocked (24 total) 2026-09-07 18:07:15 +00:00
grokbot_ty c591ff1629 Gate B pass2: evidence + RESULTS.md (17 pass / 1 fail / 5 blocked; Gate B not green)
- TV-1/2/4/5/8/9: proxy-synthetic pass
- TV-3/6/7/10: product-state blocked; proxy-synthetic pass
- V-1/2/3: proxy-synthetic pass
- AES-1: api-contract pass (settings leak) + proxy-synthetic pass (encrypt roundtrip)
- AES-2: proxy-synthetic pass
- H-1: api-contract pass
- D-1: api-contract fail (python-multipart missing) → #29
- OPS-1: deploy blocked (health endpoints all unreachable)
- GC-5: proxy-synthetic pass

Gate B is not green. UAT not ready.
2026-09-07 18:05:45 +00:00
grokbot_ty 302d69463b docs(test-spec): encode evidence-class and fail-closed gate process locks
Gate B reports treated synthetic TV passes as if they satisfied product-state
exit. Soft result words like "not run" also blurred fail-closed reporting.

Encode the seven evidence and process locks in docs/TEST-SPEC.md as closed
vocab tables, required columns, Gate B exit checklist, Build brief refusal
fields, and SoT mutation permit-before-write. Add Evidence class to every
case table. Reclassify gate-b RESULTS so TV-3/6/7/10 vitest passes stay
proxy-synthetic, Gate exit product-state rows are blocked, and "not run"
becomes blocked. Gate B remains not green.
2026-09-07 17:58:27 +00:00
grokbot_ty a3addc699f Fix evidence line citations in Gate B results
Corrected all 19 evidence line references in RESULTS.md to point at
the actual PASS/FAIL lines verified by nl -ba:

- TV-1: 25-26 → 33-34 (green-sheet pass)
- TV-2: 27-28 → 35-36 (black-sheet pass)
- TV-3: 15-16 → 22-23 (bdft identity pass)
- TV-4: 21-24 → 31 (width samples pass)
- TV-5: 25-26 → 32 (angled-end pass)
- TV-6: 123-127 → 142-145 (3:4 crop pass)
- TV-7: 128-132 → 146-148 (undersized source pass)
- TV-8: 6-11 → 4-9 (pricing pass)
- TV-9: 12-14 → 10-15 (thickness band pass)
- TV-10: 15-16 → 24 (rounding pass)
- V-1: 36-57 → 96-104 (SKU validation pass)
- V-2: 66-87 → 105-115 (content maxLength pass)
- V-3: 88-95 → 116-120 (version hash pass)
- AES-1: 36-43 → 30-43 (roundtrip pass)
- AES-2: 51-52 → 44-45 (missing key pass)
- H-1: 5-9 → 9-13 (health endpoint pass)
- D-1: 11-35 → 14-21 (CreateSlab fail)
- OPS-1: 15-47 → 18-26 (HTTPS not run)
- GC-5: 22-28 → 22-29 (woo_base_url pass)
2026-09-07 17:22:06 +00:00
grokbot_ty 8d4a65438e docs(Gate B): add mill-owner RESULTS.md report for 2026-09-07 test pass
17 pass, 1 fail (D-1, #29 python-multipart), 1 not run (OPS-1, HTTPS broken).
No walkable UI, no HTTPS, no E2E, no real draft create.
2026-09-07 17:18:01 +00:00
grokbot_ty b3e2faf690 test: Gate B pass evidence 2026-09-07 (vitest/pytest/health)
Evidence for Test Bar report: 16 pass / 1 fail (D-1) / 1 not run (OPS-1).
Fail logged on issue #29.
2026-09-07 17:06:14 +00:00
grokbot_ty 48b64382f8 docs(INVENTORY): phone hang fix — HTTP interim verified
Record phone LAN hang root cause (308 HTTPS redirect + TLS handshake fail),
HTTP-only Caddy fix, and verified smoke results for 100.64.0.9 and
192.168.1.202. Caddy :80 catch-all returns 200, /api/health ok.
2026-09-07 16:41:59 +00:00
grokbot_ty e13bbedda8 fix: HTTP-only Caddy for Gate B LAN phone hang
Root cause: Caddy on :80 returned 308 → HTTPS, and TLS handshake failed
(Go/OpenSSL compat). Phones hung on HTTPS redirect loop.

Fix: Caddyfile serves all HTTP on :80 without TLS/redirect. Docker
compose drops port 443 and cert mount. Interim — post-POC restores
proper TLS.
2026-09-07 16:40:51 +00:00
grokbot_ty 6c62b506d4 docs: update INVENTORY smoke results with LAN bind fix 2026-09-07 16:30:46 +00:00
grokbot_ty b4a702318d fix: bind 0.0.0.0 for LAN reachability (Gate B) 2026-09-07 16:29:58 +00:00
grokbot_ty c62f0329f6 gate-b: smoke results, INVENTORY complete 2026-09-07 16:19:31 +00:00
grokbot_ty f966fbe690 gate-b: Caddy TLS fix, self-signed RSA cert, SLAB_WOO_BASE_URL, absolute DB path 2026-09-07 16:13:29 +00:00
grokbot_ty 68d236961a feat(#30): Gate B [10/10]: Deploy compose + WOO_BASE_URL (OPS-1, GC-5)
- deploy/.env.example: placeholders only (no real URLs, proper comments)
- frontend/Dockerfile: Node 20 stub server for compose build
- deploy/tests/test-compose-health.sh: OPS-1 compose health smoke test
- deploy/tests/test-woo-base-url.sh: GC-4/5/FUND-25 validation suite
- backend/app/api/settings.py: PUT rejects woo_base_url (422), consumer keys (422),
  text() wrapping for SQLAlchemy 2.x, key primary key fix
- backend/tests/contract/test_woo_base_url.py: 8 contract tests for GC-4/GC-5

Tests: 39/39 backend tests pass (8 new, 31 existing green)
Deploy: 5/5 shell tests pass (Docker unavailable for compose-up path)
2026-09-07 08:18:25 +00:00
grokbot_ty 5019b10584 Gate B [09/10]: Draft store stub D-1 — POST /api/v1/slabs (#29)
POST /api/v1/slabs accepts multipart/form-data with:
- data: JSON-encoded SlabCreate payload
- files[]: original image files (1-5 photos)
- meta[]: JSON-encoded photo metadata objects

Returns 201 with status: calibrated and server_rev: 1.

Server stores client-sent numbers only (sqft, bdft, widths) without
server-side recompute. Client is authoritative for deterministic math.

Includes:
- SlabCreateData Pydantic model mirroring OPENAPI.md SlabCreate schema
- PhotoMeta model for photo metadata validation
- SlabRead/PhotoRead response models
- File storage with configurable images directory (temp fallback for tests)
- Duplicate SKU detection (409)
- python-multipart added to requirements.txt

D-1 test coverage (8 tests, all green):
- 201 response on valid multipart upload
- status: calibrated in response
- server_rev: 1 in response
- Full response shape assertion
- Multiple photos handling
- Missing data field returns 400
- Duplicate SKU returns 409
- TestClient lifespan management (FUND-9)

Evidence: pytest tests/ -v → 31 passed, 0 failed
2026-09-07 08:08:39 +00:00
grokbot_ty 82219fe5ad feat(#28): Gate B [08/10]: AES-GCM settings round-trip (AES-1, AES-2)
- AES-GCM encrypt/decrypt module (app/security/aes.py):
  - get_aes_key: decode base64 AES master key to 32 bytes
  - encrypt_setting: AES-256-GCM with fresh 12-byte nonce per call, returns nonce||ciphertext
  - decrypt_setting: decrypts ciphertext, raises AuthenticationError on tamper/wrong key
- Settings endpoint (app/api/settings.py):
  - GET /api/v1/settings: returns SettingsView with decrypted values, secrets masked
    (woo_app_password never returned, only woo_credentials_configured boolean)
  - PUT /api/v1/settings: encrypts all setting values AES-GCM, stores in settings table
  - Rejects woo_consumer_key/woo_consumer_secret fields
  - Validates woo_create_status (draft|publish)
- App factory (app/main.py): stores settings on app.state for dependency injection
- Unit tests (tests/unit/test_aes.py): 18 tests covering AES-1 (round-trip), AES-2
  (missing key refusal), FUND-17 (fresh nonce, tamper rejection), FUND-19
  (no plaintext fallback)

Test results: 23/23 passed (18 new AES + 5 existing health tests)
2026-09-07 08:00:29 +00:00
grokbot_ty e5514fe3bf feat(#27): Gate B [07/10]: FastAPI health endpoint + app factory (H-1)
- App factory pattern (FUND-8): create_app() produces fresh app per test
- Logging config (structured, no secrets)
- Config validation: SLAB_AES_KEY required, WOO_BASE_URL HTTPS-only
- GET /api/health returns 200 {status: ok, version, woo_reachable: false}
- SQLite + alembic skeleton: full DATA-MODEL schema, initial migration
- API contract tests via httpx TestClient: 5 cases all green
  - test_returns_200, test_returns_ok_status, test_woo_reachable_false
  - test_response_shape, test_with_test_client_lifespan (FUND-9/10)
2026-09-07 07:53:36 +00:00
grokbot_ty d5d8c49e04 Gate B #26: shared validation module (V-1, V-2, V-3)
- V-1: SKU charset [A-Z0-9-]{3,24}, accepted/rejected with specific error codes
- V-2: title/short_title/description UTF-8 within WooCommerce maxLength,
  enforced at field-exit and submit (200/200/2500 chars, Unicode code-point counting)
- V-3: validation module version hash, client caches, submit carries hash,
  mismatch returns 412 with fresh module (not 409)

25 unit tests green, zero browser/DOM/network dependencies.
Re-exports through pipeline/index.ts for shared use.
2026-09-07 07:43:50 +00:00
grokbot_ty 34dbfa5d7d feat(#25): Gate B pricing and thickness band (TV-8, TV-9)
TV-8 pricing:
- computeRecommendedPrice(bdft, pricePerBdft) returns bdft × price/bdft rounded half-up to 2 decimals
  0.96 bdft × 12.50/bdft → 12.00
- computeSlabPrice handles three paths:
  1. Has rule, no override → recommended price, source 'recommendation'
  2. Has rule, override → override stored (150.00), source 'override'
  3. No rule, manual → manual stored (99.99), recommendedPrice null

TV-9 thickness band:
- findThicknessBand(thicknessIn, ranges) rounds to 1/8" then matches [min, max) half-open ranges
- 1" → 1"–1 1/2" (rounds up, label from synced Woo attribute, not hardcoded)

Test output (all 29 tests green, 6 new):
- tv8-pricing.test.ts: 6 passed (recommended, override, no-rule, rounding)
- tv9-thickness-band.test.ts: 6 passed (1"→1"–1 1/2", 0.75"→3/4"–1", 0.875"→3/4"–1", 1.5"→1 1/2"–2", null for out-of-range, rounding to 1/8")
2026-09-07 06:33:24 +00:00
grokbot_ty f7040f5947 feat(#24): Gate B 3:4 crop + no upscale (TV-6, TV-7)
TV-6: 3:4 portrait crop, 80% fill at extremes, transparent PNG, shorter side >= 1600px when source allows.
TV-7: undersized source warning, no upscaling, photo not publishable until retake.

Real fixture output:
- TV-6 large source (4000x3200, slab 1281x3000): crop target 1601x2135, shorter 1601 >= 1600, fill at limiting dim 0.80
- TV-7 small source (800x640, slab 400x300): crop target 281x375, shorter 281 < 1600, undersized
- No upscale property: output never exceeds source dimensions

New files:
- frontend/src/lib/pipeline/crop.ts: cropTo34(), findSlabBounds(), computeCropTarget(), checkSourceSize()
- frontend/src/__tests__/fixtures/crop.ts: tv6LargeSourceFixture, tv7SmallSourceFixture, simpleAxis
- frontend/src/__tests__/tv6-tv7-crop.test.ts: 7 tests (2 TV-6, 2 TV-7, 3 property)
2026-09-07 06:24:00 +00:00
grokbot_ty 08c463b8d8 feat(#23): Gate B length axis and 6" widths (TV-4, TV-5)
Pure client axis module: min-area length axis, rotate/confirm session,
scale, and perpendicular width samples every 6".
2026-09-07 06:07:07 +00:00
grokbot_ty 55d66b9644 feat(#22): Gate B BDFT identity and rounding (TV-3, TV-10)
Pure units module: bdft = sqft × thickness_in (no /12), half-up
rounding for sqft/bdft/price, length to nearest 1/8". Property
checks for monotonicity in thickness and sqft.

TDD: red evidence in test-results/tv3-tv10-red.txt, then minimum impl.

Results:
TV-3 | pass | test-results/tv3-tv10-green.txt
TV-10 | pass | test-results/tv3-tv10-green.txt
2026-09-07 06:02:08 +00:00
grokbot_ty 3c2f8871a8 feat(#21): Gate B green/black sheet mask (TV-1, TV-2)
Pure client modules for TECH-SPEC sheet detect, chroma-key / black
threshold with border flood-fill, four knobs (live re-run), and mask
confirm hooks. Synthetic fixtures. U2Net never invoked.

TDD: red evidence in test-results/tv1-tv2-red.txt, then minimum impl.

Results:
TV-1 | pass | test-results/tv1-tv2-green.txt
TV-2 | pass | test-results/tv1-tv2-green.txt
2026-09-07 05:53:43 +00:00