Repository navigation
Open
Labels
area:backendBackend (Express/SQLite)enhancementNew feature or requestpriority:highHigh priority against the backlogstate:needs-designNeeds a design/scope decision before work startstype:designArchitecture/design decision needed before implementation
Milestone
Description
Problem
FloCafe currently records security and financial history across four fragmented tables (order_audit_log, auth_audit_log, authorization_audit_log, tax_config_audit), while several high-risk operational actions still lack unified append-only audit coverage (e.g., item voids in main/routes/order-items.ts, manual price/discount overrides, cash-drawer no-sale opens, shift start/end, and future closed-session amendments). Furthermore, every existing audit table assumes a human users.id (user_id / actor_user_id), leaving no clean actor-attribution model for non-human callers such as scoped Integration API keys (Open Integration Platform RFC) or Kiosk tokens (#367).
Codebase Anchor
- Existing audit tables in
main/db.ts:order_audit_log(main/db.ts:11688),auth_audit_log,authorization_audit_log,tax_config_audit. - High-risk mutation surfaces:
main/routes/order-items.ts:259-362(voids),main/routes/bills.ts(discounts & payment-method corrections),main/services/refund.ts(refunds),main/routes/cash-sessions.ts&main/routes/cash-closures.ts(drawer opens, shifts, Z-reports),main/routes/database.ts&main/routes/database-tools.ts(backup/restore/reset).
Core Invariants & Constraints
- Append-only integrity: Audit rows must never be updated or deleted by ordinary application routes (with documented retention/export policy only under explicit owner maintenance).
- Backup & privacy safety: Never log raw passwords, PINs, JWTs, API keys, or webhook secrets in
payload_json; scrub sensitive fields before persistence. - No ownership gating (Core Invariant feat: POS UI improvements — dev-server, frontend submodule update #6): Audit attribution is for accountability and compliance, never for hiding orders between staff.
Scope / Acceptance Criteria
- Design and implement a unified append-only
audit_eventstable (id,actor_type: 'user'|'integration'|'kiosk'|'system',actor_id,actor_label,action,resource_type,resource_id,payload_json,ip_address,created_at) and helper modulemain/services/audit.ts(SQLite triggers or service guard rejectingUPDATE/DELETE). - Emit structured events for highest-risk actions:
ORDER_VOID,ITEM_VOID,DISCOUNT_APPLIED,REFUND_ISSUED,CASH_DRAWER_OPEN,SHIFT_OPEN,SHIFT_CLOSE,CASH_CLOSE_AMENDED,MASTER_PIN_ACTION,API_KEY_MUTATION. - Add owner-only read/filter API (
GET /api/audit-eventsgated on dedicatedaudit.viewpermission) with pagination and CSV/JSON export. - Add tests wired into
package.jsonverifying append-only guarantees, secret redaction, anduservsintegrationactor attribution.
Concrete Design Decisions to Lock Before Coding
- Consolidation vs coexistence: Confirm whether existing
order_audit_log/tax_config_auditremain intact for backward compatibility while new/high-risk events write to unifiedaudit_events(recommended to avoid risky legacy migrations). - Actor schema alignment: Lock
actor_type+actor_idcolumns jointly with the Open Integration Platform RFC and#367(Kiosk) so all three share one attribution contract. - Retention policy: Define whether audit logs are retained indefinitely by default (matching
#1450purge boundary and#703void/archive rules).
Out of Scope
- Tamper-evident external blockchain/cloud hash anchoring or real-time SIEM streaming (can be layered via outbound webhooks later).
Metadata
Metadata
Assignees
Labels
area:backendBackend (Express/SQLite)enhancementNew feature or requestpriority:highHigh priority against the backlogstate:needs-designNeeds a design/scope decision before work startstype:designArchitecture/design decision needed before implementation
Activity
khaira777 commentedon Aug 16, 2026
Verdict: VALID ENHANCEMENT — needs product/security review and rescoping
Findings:
tax_config_audit(main/db.ts:4351),loyalty_ledger(:4244),print_logs(:2305),payment_idempotency/order_idempotency(:3292,:3347), and support/diagnostics outboxes. Voids mutateorder_items.status(main/routes/order-items.ts:116) without an actor/action record.tax_config_audit+ audit route inmain/routes/tax-packs.ts), so an audit subsystem fits FloCafe's compliance direction.Suggested scope: minimal append-only
audit_eventstable + recorder for the highest-risk actions (item void, price override, discount, refund, master-PIN actions), owner-only read API, and retention policy. Coordinate with #278 (refunds), #279 (shift events), #280 (inventory ledger) so we don't build four parallel ledgers. Maintainer decision needed: event list + retention.feat(orders): record who performed each order/item mutation
fix: orders are never ownership-gated (product decision) (#725)