Files
order-notification-automation/docs/superpowers/plans/2026-10-19-order-rules.md
T

3.4 KiB

Order Rules Implementation Plan

For agentic workers: Use subagent-driven-development for independent domain and Web tasks; integrate and review in this session.

Goal: Create a usable first Web version of Excel category rules, explicit field mapping, deterministic preview and stateful order/batch records.

Architecture: Isolated order-rules module consumes verified form adapters and reusable mailbox/calendar infrastructure. Local encrypted storage holds business data; capabilities block unverified external execution.

Tech Stack: Node >=22.13, CommonJS, node:sqlite, existing BpmVault, Tabler/vanilla JS, node:test.

Spec: docs/superpowers/specs/2026-10-19-order-rules-design.md

Global Constraints

15 Excel categories; one mail per category per slot; manual BPM handling; no private recipient lists committed; no live sends during construction; default paused; unverified production providers explicit; modules separated.

Task 1: Catalog and field adapters

  • Read Excel locally, preserve raw business intent, import private values only into encrypted local store.
  • Write failing matching tests: target node exactness, zero quantity, no unsupported adapter, multiple matches.
  • Implement catalog.cjs and matching.cjs per spec, then run tests.

Task 2: State and version persistence

  • Write state tests for duplicate events, conflicting drafts, transition legality, blocked category, cutoff and full aggregation, recovery.
  • Implement store.cjs, state.cjs and batch.cjs with encrypted persistent evidence/snapshots.
  • Add API, application lifecycle integration and HTTP role/origin tests.

Task 3: Web editor and workbench

  • Implement focused view/editor/preview modules under web/modules/order-rules.
  • Add scripts/assets/nav and isolated preview runtime with first-run catalog.
  • Exercise save/reload, readable execution summary, field trace, paused state and unsupported capability feedback.

Task 4: Integration and review

  • Integrate scheduled dispatch gate with existing mail service; keep provider limitations explicit and no arbitrary archive attestations.
  • Run targeted domain/state/HTTP checks, complete npm test and browser workflow.
  • Review spec and code for false readiness, privacy leakage, retry/duplicate errors; fix findings and document verified scope.

Task 5: Confirmed title extraction and read-only historical evidence

  • User example red/green regression: retain both ordinary and HA order paragraphs, remove metadata, preserve raw title; Chinese colons/zero quantity and missing order checks.
  • Expose title input and original/result comparison with Huizhou evidence marked pending, without automatic extra email.
  • Add IMAP-only local configuration and bounded sent-folder history search/detail with admin/origin gates, no SMTP, no seen/flag/cursor changes, no remote content loading.
  • Verify service/API/preview/browser paths with simulated mailbox and no external SMTP/BPM calls.
  • Finish combined full regression and live preview check; document pending real mailbox evidence.

Validation: combined full regression 282 tests, 281 passed, 0 failed, 1 expected skip (official ZCode CLI not configured). Local browser verified exact two-order title extraction and empty IMAP-only configuration form. Real mailbox history and production BPM/PDF/archive providers remain pending integration.