# 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 - [x] Read Excel locally, preserve raw business intent, import private values only into encrypted local store. - [x] Write failing matching tests: target node exactness, zero quantity, no unsupported adapter, multiple matches. - [x] Implement catalog.cjs and matching.cjs per spec, then run tests. ### Task 2: State and version persistence - [x] Write state tests for duplicate events, conflicting drafts, transition legality, blocked category, cutoff and full aggregation, recovery. - [x] Implement store.cjs, state.cjs and batch.cjs with encrypted persistent evidence/snapshots. - [x] Add API, application lifecycle integration and HTTP role/origin tests. ### Task 3: Web editor and workbench - [x] Implement focused view/editor/preview modules under web/modules/order-rules. - [x] Add scripts/assets/nav and isolated preview runtime with first-run catalog. - [x] Exercise save/reload, readable execution summary, field trace, paused state and unsupported capability feedback. ### Task 4: Integration and review - [x] Integrate scheduled dispatch gate with existing mail service; keep provider limitations explicit and no arbitrary archive attestations. - [x] Run targeted domain/state/HTTP checks, complete npm test and browser workflow. - [x] 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 - [x] 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. - [x] Expose title input and original/result comparison with Huizhou evidence marked pending, without automatic extra email. - [x] 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. - [x] Verify service/API/preview/browser paths with simulated mailbox and no external SMTP/BPM calls. - [x] 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.