Skip to content

feat: add structured diagnostics and actionable POS failure feedback - #1032

Merged
khaira777 merged 29 commits into
mainfrom
feat/diagnostics-and-singapore-integration
Oct 11, 2026
Merged

khaira777 merged 29 commits into
mainfrom
feat/diagnostics-and-singapore-integration

Conversation

@khaira777

@khaira777 khaira777 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Resolve cashier order rejection rejections with specific actionable error messages, synchronize structured operation failure registry with 119 capture points, and complete Singapore community tax pack verification

What Changed

  • Return structured order, payment, discount, and charge failures so cashiers receive specific, localized guidance and next steps for rejected or uncertain operations.
  • Add typed operation-failure capture and bounded, consent-gated diagnostics delivery, with delivery-health visibility and failure context for support tickets.
  • Update the Singapore community GST profile to use 9% GST from 2024-01-01, inclusive default pricing, and expanded registration-number formats; document its limitations and add verification coverage.

Risk Assessment

⚠️ Medium: The diagnostics flow crosses renderer, API, persistence, and outbound delivery boundaries, creating meaningful regression surface, though I found no source-backed defect in the reviewed paths.

Testing

Built the backend and desktop frontend, drove the POS rejection through a real isolated browser and API, and exercised diagnostics and Singapore tax-pack routes with disposable databases. The first diagnostics run hit its 30-write/minute limit; pacing the client allowed the real limiter to reset and the integration run to complete. Evidence was captured and transient worktree artifacts were cleaned up.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
A cashier submits an order with an invalid quantity; the real API returns a structured rejection, the POS shows a specific correction, and no order is saved. ✅ pass live POS quantity rejection with actionable correction; live cashier rejection and persisted-order check
A rejected backend operation returns a safe registered failure tuple, while invalid diagnostic captures are rejected and covered API failure paths preserve their behavior. ✅ pass live Diagnostics registry integration run; Diagnostics feature coverage
An owner validates and activates the Singapore community tax pack; GST calculations and registration formats are checked, and an existing order's tax snapshot remains preserved. ✅ pass live Singapore community tax pack verification

POS quantity rejection with actionable correction

Evidence: Live cashier rejection and persisted-order check
[WebServer] (node:26387) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
[WebServer] (Use `node --trace-warnings ...` to show where the warning was created)


Running 1 test using 1 worker

(node:26400) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
(Use `node --trace-warnings ...` to show where the warning was created)


[1/1] [chromium] › e2e/codex-live-order-rejection.spec.ts:5:5 › cashier sees an actionable message for a real backend quantity rejection
[WebServer] [Orders] Create error: Error: Invalid quantity for E2E Coffee: must be a positive number
[WebServer]     at validateProductQuantity (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/dist/main/routes/orders-validation.js:101:29)
[WebServer]     at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/dist/main/routes/orders.js:917:65
[WebServer]     at sqliteTransaction (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)
[WebServer]     at withTxn (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/dist/main/db.js:1327:30)
[WebServer]     at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/dist/main/routes/orders.js:820:41
[WebServer]     at Layer.handleRequest (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/layer.js:152:17)
[WebServer]     at next (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/route.js:157:13)
[WebServer]     at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/dist/main/services/authorization.js:129:9
[WebServer]     at Layer.handleRequest (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/layer.js:152:17)
[WebServer]     at next (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/route.js:157:13)
[WebServer]     at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/express-rate-limit/dist/index.cjs:1061:7
[WebServer]     at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
[WebServer]     at async ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/express-rate-limit/dist/index.cjs:879:5 {
[WebServer]   statusCode: 400,
[WebServer]   diagnosticCode: 'quantity_invalid'
[WebServer] }

[WebServer] [API] Internal error: Error: Invalid quantity for E2E Coffee: must be a positive number
[WebServer]     at validateProductQuantity (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/dist/main/routes/orders-validation.js:101:29)
[WebServer]     at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/dist/main/routes/orders.js:917:65
[WebServer]     at sqliteTransaction (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)
[WebServer]     at withTxn (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/dist/main/db.js:1327:30)
[WebServer]     at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/dist/main/routes/orders.js:820:41
[WebServer]     at Layer.handleRequest (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/layer.js:152:17)
[WebServer]     at next (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/route.js:157:13)
[WebServer]     at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/dist/main/services/authorization.js:129:9
[WebServer]     at Layer.handleRequest (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/layer.js:152:17)
[WebServer]     at next (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/route.js:157:13)
[WebServer]     at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/express-rate-limit/dist/index.cjs:1061:7
[WebServer]     at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
[WebServer]     at async ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/express-rate-limit/dist/index.cjs:879:5 {
[WebServer]   statusCode: 400,
[WebServer]   diagnosticCode: 'quantity_invalid'
[WebServer] }

[chromium] › e2e/codex-live-order-rejection.spec.ts:5:5 › cashier sees an actionable message for a real backend quantity rejection
{"status":400,"reason_code":"order.quantity_invalid","operation":"order.create","stage":"validation","classification":"expected_rejection","outcome":"not_applied","cashier_message":"Order not created. Check the item quantity.","saved_order_count_before":0,"saved_order_count_after":0}

  1 passed (4.2s)
Evidence: Diagnostics registry integration run

> [email protected] test:diagnostics-event
> node tests/run-electron-node-test.cjs tests/diagnostics-event.test.ts

Diagnostics Event Ingestion Tests
========================================================
[DB] Opening database at: ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/.test-tmp/flo-diagnostics-event-GdeR5n/flo.db
[DB] Schema: v0 → v112
[DB] Triggering auto-backup before migrating v0 → v112...
[DB] Auto-backup before migrating v0 → v112 created at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/.test-tmp/flo-diagnostics-event-GdeR5n/backups/flo-backup-2026-10-11T19-09-22-607Z-pre-v0-to-v112.db
[DB] Install defaults loaded; first-run setup pending
[MIGRATION v23] normalized: 0, unparseable: 0
[MIGRATION v23] merged 0 duplicate customer(s)
[MIGRATION v23] verification: 0 customers, 0 still non-E.164
[MIGRATION v24] normalized: 0, unparseable: 0
[MIGRATION v25] backfilled addons for 0 order items (0 unparseable, skipped)
[MIGRATION v30] backfilled 0 order_item(s) still missing a normalized addons snapshot
[MIGRATION v30] Dropped order_items.addons — order_item_addons is now the only place selected addons live.
[MIGRATION v73] normalized 0 merchant template payload(s); 0 already canonical or left untouched
[DB] integrity_check: ok
[DB] foreign_key_check: clean
[Auth] Generated new JWT secret for this install

1. Legacy event ingestion keeps derived evidence local
  ✓ a supported legacy event is accepted
  ✓ the event is available in the local diagnostics log
  ✓ legacy free-form events never enter the automatic outbox
  ✓ event-specific safe metadata survives local projection
  ✓ unapproved free-form metadata is removed

1b. Event authentication, schema, severity, code, and metadata bounds remain enforced
  ✓ unauthenticated event writes are rejected
SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2)
    at JSON.parse (<anonymous>)
    at parse (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/body-parser/lib/types/json.js:91:21)
    at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/body-parser/lib/read.js:162:18
    at AsyncResource.runInAsyncScope (node:async_hooks:227:14)
    at invokeCallback (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/raw-body/index.js:238:16)
    at done (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/raw-body/index.js:227:7)
    at IncomingMessage.onEnd (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/raw-body/index.js:287:7)
    at IncomingMessage.emit (node:events:514:28)
    at IncomingMessage.emit (node:domain:489:12)
    at endReadableNT (node:internal/streams/readable:1764:12)
    at processTicksAndRejections (node:internal/process/task_queues:90:21)
  ✓ malformed JSON is rejected
  ✓ malformed event contract is rejected
  ✓ malformed event contract is rejected
  ✓ malformed event contract is rejected
  ✓ malformed event contract is rejected
  ✓ malformed event contract is rejected
  ✓ malformed event contract is rejected
  ✓ malformed event contract is rejected
  ✓ malformed event contract is rejected
  ✓ malformed event contract is rejected
  ✓ long correlation identifiers are capped before normalization
  ✓ long diagnostic messages are capped before normalization
  ✓ metadata beyond the byte cap is rejected
  ✓ rejected event payloads do not create local rows
  ✓ metadata array contents share the cumulative entry budget
  ✓ nested fan-out metadata keeps a bounded event instead of rejecting after full traversal
  ✓ arrays and objects share one cumulative metadata entry budget
  ✓ deep metadata is trimmed to its safe event-specific projection
  ✓ projected metadata is available locally
  ✓ the allowlisted route field survives
  ✓ the allowlisted method field survives
  ✓ the allowlisted status field survives
  ✓ unapproved metadata is removed
  ✓ nested unapproved metadata is removed
  ✓ prototype-shaped metadata does not break valid event capture
  ✓ prototype-shaped metadata is processed
  ✓ safe print metadata remains
  ✓ the prototype key is not persisted

2. The frontend capture boundary accepts only its closed safe contract
  ✓ a registered frontend transport failure is accepted
  ✓ the response gives a stable reason code
  ✓ the operation comes from the server registry
  ✓ the stage comes from the server registry
  ✓ the response includes the closed failure class
  ✓ the supplied allowlisted outcome is echoed
  ✓ the caller operation UUID is retained for recovery
  ✓ a confirmed order retry-state persistence failure is accepted
  ✓ retry-state failure has its own stable reason
  ✓ retry-state failure reports the confirmed order outcome
  ✓ retry-state capture preserves the order operation UUID
  ✓ fc.client.payment.create.retry_state_update is accepted as a client-owned occurrence
  ✓ fc.client.payment.create.retry_state_update has its registered reason
  ✓ fc.client.payment.create.retry_state_update has its registered operation
  ✓ fc.client.payment.create.retry_state_update has its registered stage
  ✓ fc.client.payment.create.retry_state_update retains the operation UUID
  ✓ fc.frontend.pos.order.create.held_cleanup is accepted as a client-owned occurrence
  ✓ fc.frontend.pos.order.create.held_cleanup has its registered reason
  ✓ fc.frontend.pos.order.create.held_cleanup has its registered operation
  ✓ fc.frontend.pos.order.create.held_cleanup has its registered stage
  ✓ fc.frontend.pos.order.create.held_cleanup retains the operation UUID
  ✓ fc.frontend.pos.payment.create.held_cleanup is accepted as a client-owned occurrence
  ✓ fc.frontend.pos.payment.create.held_cleanup has its registered reason
  ✓ fc.frontend.pos.payment.create.held_cleanup has its registered operation
  ✓ fc.frontend.pos.payment.create.held_cleanup has its registered stage
  ✓ fc.frontend.pos.payment.create.held_cleanup retains the operation UUID
  ✓ fc.frontend.pos.order.append.transport is accepted as a client-owned occurrence
  ✓ fc.frontend.pos.order.append.transport has its registered reason
  ✓ fc.frontend.pos.order.append.transport has its registered operation
  ✓ fc.frontend.pos.order.append.transport has its registered stage
  ✓ fc.frontend.pos.order.append.transport retains the operation UUID
  ✓ fc.frontend.pos.order.append.recovery is accepted as a client-owned occurrence
  ✓ fc.frontend.pos.order.append.recovery has its registered reason
  ✓ fc.frontend.pos.order.append.recovery has its registered operation
  ✓ fc.frontend.pos.order.append.recovery has its registered stage
  ✓ fc.frontend.pos.order.append.recovery retains the operation UUID
  ✓ an invalid UUID, point, outcome, fact, or extra field is rejected
  ✓ an invalid UUID, point, outcome, fact, or extra field is rejected
  ✓ an invalid UUID, point, outcome, fact, or extra field is rejected
  ✓ an invalid UUID, point, outcome, fact, or extra field is rejected
  ✓ an invalid UUID, point, outcome, fact, or extra field is rejected
  ✓ an invalid UUID, point, outcome, fact, or extra field is rejected
  ✓ an invalid UUID, point, outcome, fact, or extra field is rejected
  ✓ an invalid UUID, point, outcome, fact, or extra field is rejected
  ✓ an invalid UUID, point, outcome, fact, or extra field is rejected
  ✓ an invalid UUID, point, outcome, fact, or extra field is rejected
  ✓ an invalid UUID, point, outcome, fact, or extra field is rejected
  ✓ an invalid UUID, point, outcome, fact, or extra field is rejected
  ✓ an invalid UUID, point, outcome, fact, or extra field is rejected
  ✓ capture remains local while both delivery gates are off

3. Health returns typed delivery state without failure text
  ✓ support staff can read diagnostics health
  ✓ consent is an explicit boolean
  ✓ the local transmission gate is

... [77143 bytes truncated] ...

  at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/main/routes/bills.ts:3397:7
    at sqliteTransaction (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)
    at withTxn (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/main/db.ts:1334:28)
    at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/main/routes/bills.ts:3396:27
    at Layer.handleRequest (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/layer.js:152:17)
    at next (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/route.js:157:13)
    at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/main/services/authorization.ts:167:5
    at Layer.handleRequest (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/layer.js:152:17)
    at next (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/route.js:157:13)
    at Route.dispatch (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/route.js:117:3)
    at handle (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/index.js:435:11)
    at Layer.handleRequest (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/layer.js:152:17)
    at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/index.js:295:15 {
  statusCode: 409,
  diagnosticCode: 'cash_session_required'
}
  ✓ cash_session_required remains a payment validation response
  ✓ cash_session_required is assigned by its payment branch
  ✓ cash_session_required is captured as a safe local fact
  ✓ the cashier trusts a structured batch cash-session rejection
  ✓ the batch cash-session code reaches the cashier failure classifier
[API] Bill payment failed: Error: No open shift: open a shift before taking cash
    at httpError (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/main/services/shift-session-gate.ts:9:24)
    at requireOpenSessionForCashTender (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/main/services/shift-session-gate.ts:87:11)
    at applyPaymentBatch (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/main/routes/bills.ts:3146:34)
    at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/main/routes/bills.ts:3317:7
    at sqliteTransaction (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)
    at withTxn (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/main/db.ts:1334:28)
    at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/main/routes/bills.ts:3316:27
    at Layer.handleRequest (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/layer.js:152:17)
    at next (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/route.js:157:13)
    at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/main/services/authorization.ts:167:5
    at Layer.handleRequest (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/layer.js:152:17)
    at next (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/route.js:157:13)
    at Route.dispatch (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/route.js:117:3)
    at handle (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/index.js:435:11)
    at Layer.handleRequest (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/layer.js:152:17)
    at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/index.js:295:15 {
  statusCode: 409,
  diagnosticCode: 'cash_session_required'
}
  ✓ cash_session_required remains a payment validation response
  ✓ cash_session_required is assigned by its payment branch
  ✓ cash_session_required is captured as a safe local fact
  ✓ the cashier trusts a structured single cash-session rejection
  ✓ the single cash-session code reaches the cashier failure classifier
  ✓ payment captures never include customer identifiers
  ✓ payment captures never include transaction references
  ✓ payment captures never include wallet balance text
[API] Batch bill payment failed: Error: private notification failure
    at kds.notifyOrderUpdated (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/tests/diagnostics-event.test.ts:1809:13)
    at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/main/routes/bills.ts:3414:28
    at Layer.handleRequest (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/layer.js:152:17)
    at next (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/route.js:157:13)
    at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/main/services/authorization.ts:167:5
    at Layer.handleRequest (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/layer.js:152:17)
    at next (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/route.js:157:13)
    at Route.dispatch (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/route.js:117:3)
    at handle (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/index.js:435:11)
    at Layer.handleRequest (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/lib/layer.js:152:17)
    at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/index.js:295:15
    at param (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/index.js:600:14)
    at param (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/index.js:610:14)
    at processParams (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/index.js:664:3)
    at next (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/index.js:291:5)
    at router.handle (~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/node_modules/router/index.js:186:3)
  ✓ a post-commit notification error is surfaced
  ✓ post-commit errors have a completion reason
  ✓ the response distinguishes completion from persistence
  ✓ the response reports the proven committed payment
  ✓ the committed payment remains persisted
  ✓ a failed diagnostics sink does not alter post-commit handling

5. No raw request or exception contents enter the v2 queue
  ✓ customer text is absent from every automatic diagnostic payload
  ✓ payment customer data is absent from automatic diagnostics
  ✓ unapproved event metadata is absent from automatic diagnostics
  ✓ no raw diagnostic payload was queued

========================================================
471 passed, 0 failed
[DB] Database closed
Evidence: Diagnostics feature coverage

> [email protected] test:diagnostics-feature-coverage
> node tests/run-electron-node-test.cjs tests/diagnostics-feature-coverage.test.ts

[DB] Opening database at: ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/.test-tmp/flo-diagnostics-feature-coverage-rMfbst/flo.db
[DB] Schema: v0 → v112
[DB] Triggering auto-backup before migrating v0 → v112...
[DB] Auto-backup before migrating v0 → v112 created at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/.test-tmp/flo-diagnostics-feature-coverage-rMfbst/backups/flo-backup-2026-10-11T19-07-01-970Z-pre-v0-to-v112.db
[DB] Install defaults loaded; first-run setup pending
[MIGRATION v23] normalized: 0, unparseable: 0
[MIGRATION v23] merged 0 duplicate customer(s)
[MIGRATION v23] verification: 0 customers, 0 still non-E.164
[MIGRATION v24] normalized: 0, unparseable: 0
[MIGRATION v25] backfilled addons for 0 order items (0 unparseable, skipped)
[MIGRATION v30] backfilled 0 order_item(s) still missing a normalized addons snapshot
[MIGRATION v30] Dropped order_items.addons — order_item_addons is now the only place selected addons live.
[MIGRATION v73] normalized 0 merchant template payload(s); 0 already canonical or left untouched
[DB] integrity_check: ok
[DB] foreign_key_check: clean
[DB] Database closed
Diagnostics C6 feature boundary tests passed
Evidence: Singapore community tax pack verification

> [email protected] test:community-tax-packs
> node tests/run-electron-node-test.cjs tests/community-tax-packs.test.ts

Community Tax Pack Validation
========================================================
[DB] Opening database at: ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/.test-tmp/flo-community-tax-packs-bqryit/flo.db
[DB] Schema: v0 → v112
[DB] Triggering auto-backup before migrating v0 → v112...
[DB] Auto-backup before migrating v0 → v112 created at ~/.no-mistakes/worktrees/de2296f2e6f8/01M4NY4C53Z6HCQVW5RQ1MKQA4/.test-tmp/flo-community-tax-packs-bqryit/backups/flo-backup-2026-10-11T19-07-02-377Z-pre-v0-to-v112.db
[DB] Install defaults loaded; first-run setup pending
[MIGRATION v23] normalized: 0, unparseable: 0
[MIGRATION v23] merged 0 duplicate customer(s)
[MIGRATION v23] verification: 0 customers, 0 still non-E.164
[MIGRATION v24] normalized: 0, unparseable: 0
[MIGRATION v25] backfilled addons for 0 order items (0 unparseable, skipped)
[MIGRATION v30] backfilled 0 order_item(s) still missing a normalized addons snapshot
[MIGRATION v30] Dropped order_items.addons — order_item_addons is now the only place selected addons live.
[MIGRATION v73] normalized 0 merchant template payload(s); 0 already canonical or left untouched
[DB] integrity_check: ok
[DB] foreign_key_check: clean

community-argentina.json
  ✓ passes all 26 activation checks
  ✓ every category produces a sane, non-negative calculation

community-france.json
  ✓ passes all 26 activation checks
  ✓ every category produces a sane, non-negative calculation

community-ghana.json
  ✓ passes all 26 activation checks
  ✓ every category produces a sane, non-negative calculation

community-indonesia.json
  ✓ passes all 26 activation checks
  ✓ every category produces a sane, non-negative calculation

community-japan.json
  ✓ passes all 26 activation checks
  ✓ every category produces a sane, non-negative calculation

community-mexico.json
  ✓ passes all 26 activation checks
  ✓ every category produces a sane, non-negative calculation

community-nepal.json
  ✓ passes all 26 activation checks
  ✓ every category produces a sane, non-negative calculation

community-pakistan.json
  ✓ passes all 26 activation checks
  ✓ every category produces a sane, non-negative calculation

community-philippines.json
  ✓ passes all 26 activation checks
  ✓ every category produces a sane, non-negative calculation

community-saudi-arabia.json
  ✓ passes all 26 activation checks
  ✓ every category produces a sane, non-negative calculation

community-singapore.json
  ✓ passes all 26 activation checks
  ✓ every category produces a sane, non-negative calculation
  ✓ Singapore GST defaults, registration formats, and calculation cases

community-south-africa.json
  ✓ passes all 26 activation checks
  ✓ every category produces a sane, non-negative calculation

community-united-states.json
  ✓ passes all 26 activation checks
  ✓ every category produces a sane, non-negative calculation

community-uzbekistan.json
  ✓ passes all 26 activation checks
  ✓ every category produces a sane, non-negative calculation

Singapore signed installation, owner activation, and stored-data preservation
[Auth] Generated new JWT secret for this install
[DB] Database closed

========================================================
✅ All 14 community tax packs validated

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 4 issues found → auto-fixed (3) ✅
  • 🚨 frontend/src/app/(dashboard)/orders/page.tsx:504 - The required criterion is “Resolve cashier order rejection rejections with specific actionable error messages.” On a correlated postpaid append rejected by validation, the server returns an actionable error with a trusted validation.rejected tuple (main/routes/orders.ts:1690-1702,1984-2003), and the classifier retains it as failure.serverError (frontend/src/lib/order-attempt.ts:555-565). This handler discards that detail and shows only a generic correction prompt. The 6cb1b30e fix-round change clears the rejected retry state but leaves both this recovery path and the normal submit path generic (frontend/src/app/(dashboard)/orders/page.tsx:1302). Please preserve a safe, specific rejection message in both paths.
  • ⚠️ main/routes/diagnostics.ts:62 - Nested metadata arrays have no item limit: this loop sanitizes every element before the 4 KB serialized-size check at line 100. An authenticated caller with support.use can submit a large array in a request accepted by the API’s 50 MB JSON body limit, making the handler traverse and duplicate it before rejecting it. Bound array traversal or reject oversized arrays before sanitizing them.
  • ⚠️ main/routes/settings.ts:1746 - If the app starts with diagnostics transmission disabled, reload() does not start the diagnostics flusher (main/services/cloud-sync.ts:1001-1010). Turning transmission on later reaches this consent sync call, but it does not start a timer or flush existing aggregates (main/services/cloud-sync.ts:1645-1679). If no further failure is captured, queued diagnostics remain pending until a restart. Start or trigger the flusher when an effective opt-in is saved.
  • ⚠️ main/tax-packs/community-singapore.json:17 - The Singapore pattern rejects six-digit UENs, although the pack describes accepting UEN syntax. IRAS lists six-digit UENs for LLPs and local branches in its GST tax-reference instructions, and its invoice guidance recognizes a UEN as the GST registration number when they are the same. A Singapore business using such a UEN as its GST registration number is rejected when saving tax settings (main/services/tax.ts:121-135; main/routes/settings.ts:341-350,426-435). Include the valid six-digit form.

🔧 Fix applied.
2 errors still open:

  • 🚨 frontend/src/app/(dashboard)/orders/page.tsx:504 - The required criterion is “Resolve cashier order rejection rejections with specific actionable error messages.” On a correlated postpaid append rejected by validation, the server returns an actionable error with a trusted validation.rejected tuple (main/routes/orders.ts:1690-1702,1984-2003), and the classifier retains it as failure.serverError (frontend/src/lib/order-attempt.ts:555-565). This handler discards that detail and shows only a generic correction prompt. The 6cb1b30e fix-round change clears the rejected retry state but leaves both this recovery path and the normal submit path generic (frontend/src/app/(dashboard)/orders/page.tsx:1302). Please preserve a safe, specific rejection message in both paths.

  • 🚨 frontend/src/app/(dashboard)/orders/page.tsx:1302 - The required criterion “Resolve cashier order rejection rejections with specific actionable error messages” remains unmet for item appends. A confirmed validation rejection from /orders/:id/items returns an error with a trusted validation.rejected tuple (main/routes/orders.ts:1690-1702,1990-2003), and the classifier preserves the detail as failure.serverError (frontend/src/lib/order-attempt.ts:555-564). Both the automatic recovery and normal submit handlers discard it and show only a generic prompt (frontend/src/app/(dashboard)/orders/page.tsx:504,1302). The later append-state fix in 6cb1b30e left this detail undisplayed in both paths. Show the trusted rejection detail, with a generic fallback.

  • ⚠️ main/routes/diagnostics.ts:63 - The round 2 fix caps each container at 40 items, but the caps multiply: an authenticated caller with support.use can submit 40 array-valued metadata keys, each containing 40 objects with 40 strings of 300 characters. The handler copies this roughly 64,000-string tree and serializes it before rejecting it at line 101. Object key traversal at main/routes/diagnostics.ts:71 compounds the array fan-out at this site. Apply a cumulative node or byte budget during traversal.

🔧 Fix applied.
2 warnings still open:

  • ⚠️ main/routes/diagnostics.ts:63 - The round 2 fix caps each container at 40 items, but the caps multiply: an authenticated caller with support.use can submit 40 array-valued metadata keys, each containing 40 objects with 40 strings of 300 characters. The handler copies this roughly 64,000-string tree and serializes it before rejecting it at line 101. Object key traversal at main/routes/diagnostics.ts:71 compounds the array fan-out at this site. Apply a cumulative node or byte budget during traversal.
  • ⚠️ main/routes/diagnostics.ts:96 - Round 3 bounded recursive metadata traversal, but diagnostics still processes unbounded request fields: event_code is trimmed and regex-checked before a length guard, while severity, correlation_id, and message are also consumed without raw-length limits (lines 98-99, 116-122). An authenticated caller can submit a near-50 MB value under the API body limit and cause additional full-string scans. The sibling /capture path forwards unbounded facts at line 168; serializeOperationFailure materializes every entry before rejecting an unknown key (main/lib/operation-failure.ts:1408-1410). Add size and fact-count bounds before scanning or materializing these inputs.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 2 of 2 scenarios driven live against the product
Scenario Result Live Evidence
Cashier receives a specific correction after the server rejects an invalid quantity ✅ pass live Live cashier rejection; cashier-quantity-rejection.png
Owner installs and activates the Singapore community tax pack while existing tax history stays intact and checkout applies GST rules ✅ pass live Singapore tax-pack validation; npm run test:community-tax-packs
  • npm ci --ignore-scripts --no-audit --no-fund and node node_modules/electron/install.js to materialize worktree-local test dependencies after the first suite was blocked by missing Electron.
  • npm run test:community-tax-packs
  • npm run test:diagnostics-event && npm run test:diagnostics-feature-coverage && npm run test:diagnostic-signature
  • npm run build &amp;&amp; npm run build:frontend to prepare the E2E product runtime.
  • Started tests/e2e-server.cjs on isolated ports 3311-3313; used Playwright to log in, alter the outgoing order quantity while forwarding the request to the real API, assert the structured rejection and UI message, and capture a screenshot.
  • npm run test:issue-788-order-attempt-storage
  • Exploratory runtime registry-count/serialization probe; excluded from step judgment because that same count concern is recorded as declined on this branch.
  • git diff --check

✅ No issues found.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
A cashier submits an order with an invalid quantity; the real API returns a structured rejection, the POS shows a specific correction, and no order is saved. ✅ pass live POS quantity rejection with actionable correction; live cashier rejection and persisted-order check
A rejected backend operation returns a safe registered failure tuple, while invalid diagnostic captures are rejected and covered API failure paths preserve their behavior. ✅ pass live Diagnostics registry integration run; Diagnostics feature coverage
An owner validates and activates the Singapore community tax pack; GST calculations and registration formats are checked, and an existing order's tax snapshot remains preserved. ✅ pass live Singapore community tax pack verification
  • npm run build
  • npm run build:frontend
  • npx playwright test --config=playwright.config.ts --project=chromium e2e/codex-live-order-rejection.spec.ts --reporter=line against local API/KDS/Server App ports 39081–39083; request reached the real backend and evidence screenshot was captured.
  • npm run test:community-tax-packs
  • npm run test:diagnostics-feature-coverage
  • npm run test:diagnostics-event initially hit the diagnostics write limit; reran with NODE_OPTIONS=--require=$PWD/.test-tmp/rate-limit-paced-fetch.cjs so the real limiter could reset, and the suite completed.
  • curl health checks for the isolated Main API and Server App
  • git diff --check fd858b6eff7e0201a5144d185ce8c9407780c822 a7b2e67cadd819218ea7029763fc43ee26e587ee
✅ **Document** - passed

✅ No issues found.

✅ No issues found.

🔧 **Lint** - 1 issue found → no changes applied ✅
  • ⚠️ Configured tools are unavailable: markdownlint-cli2 and oxlint were not found, and the repository-local oxfmt module is missing. This blocked npm run docs:check, npm run lint, and the changed-file format check. Direct documentation link, index, and policy checks passed; git diff --check passed. No tests were run.

🔧 No changes applied.
✅ Re-checked - no issues remain.

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

✅ No issues found.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: FreeOpenSourcePOS/FloCafe/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 432a6170-8560-49d5-a715-22e5395bf105

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@khaira777

Copy link
Copy Markdown
Contributor Author

@greptile review

@greptile-apps

greptile-apps Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[High impact] Adds operation tracking and failure classification across order and payment flows.

Fix the append recovery lock before merging; retaining rejected gap counts is also worthwhile.

Findings

  1. P1 Rejected appends lock the page ▶
  2. P2 Undelivered failure counts disappear ▶

Summary

This PR adds correlated cashier failure messages, a closed diagnostics registry, aggregate delivery and delivery health, and Singapore GST profile corrections.

  • Cashiers see clearer order and payment results and can recover saved requests.
  • Registered failures feed local summaries, delivery, and support health details.
  • The Singapore community pack sets inclusive prices and applies 9% GST.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Cashier[Cashier request] --> Backend[Local backend]
  Backend --> DB[(Orders and payments)]
  Backend --> Registry[Registered failure tuple]
  Registry --> UI[Cashier guidance]
  Registry --> Aggregate[Hourly counts]
  Aggregate --> Queue[Diagnostics queue]
  Queue --> Gates{Consent and transport}
  Gates --> Remote[Diagnostics receiver]
  Remote --> Ack{Delivery result}
  Ack --> Delivered[Delivered]
  Ack --> Retry[Retry later]
  Ack --> Gaps[Local delivery gaps]
Loading

Reviews (1) · Last reviewed commit: "no-mistakes(lint): Format changed files ..." · Reviewed by Greptile

Comment thread main/services/cloud-sync.ts Resolved
@khaira777
khaira777 force-pushed the feat/diagnostics-and-singapore-integration branch from 375bb94 to 6cb1b30 Compare October 11, 2026 16:46
@khaira777 khaira777 changed the title fix(main): clarify cashier rejections and capture operation failures feat: add structured diagnostics and Singapore GST support Oct 11, 2026
…ency test state index, and Playwright recovery fixtures and assertions. Updated PaymentModal to preserve an applied equal share while its matching locked payment is awaiting replay confirmation. Verification passed: frontend build, lint, all 17 equal-share E2E tests, plus the focused first-run, currency-adapter, release-regression, and prepaid-reconciliation checks. `git diff --check` passed. An earlier broad browser run also had three unrelated `layout-integrity` failures; the aggregate E2E and required-check gate were not rerun because this assignment covers only the CI fix phase
…udSync stub records `captureOperationFailure()` and the startup-failure assertion expects diagnostics capture instead of the removed telemetry event. Removed the obsolete telemetry sender from the stub. `node --check` and `git diff --check` passed. `npm run test:shutdown-lifecycle` could not reach the test because repo-local `tsc` is missing
…y file flagged by CI. The Required Checks Gate failure was downstream of the formatting failure. `npx oxfmt --check` on the file, `node --check`, and `git diff --check` passed. The full changed-file checker could not run because repo-local `oxfmt` is missing, and `npm run test:shutdown-lifecycle` was blocked by missing `tsc`
@khaira777
khaira777 force-pushed the feat/diagnostics-and-singapore-integration branch from eb20c30 to cb2c5d3 Compare October 11, 2026 19:17
@khaira777 khaira777 changed the title feat: add structured diagnostics and Singapore GST support feat: add structured diagnostics and actionable POS failure feedback Oct 11, 2026
@khaira777
khaira777 merged commit a83cb7f into main Oct 11, 2026
23 checks passed
@khaira777
khaira777 deleted the feat/diagnostics-and-singapore-integration branch October 11, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant