Confirms SC#1, and the scheduler halves of SC#3/SC#4 via direct DB/log
access. Also documents the stale-Docker-image root cause found during
testing (image predated all PAX8 code; rebuilt and redeployed) and the
incidental fix needed to unblock the build. SC#2 and the manual-route
halves of SC#3/SC#4 still need a human with an authenticated browser
session — not bypassed via forged auth.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LHRgZqkzBHBbAbc3KHneuR
Note in Operator config / Integration disable that the pax8 toggle is
the first integration where the DB toggle stops an action (scheduler
skip + 403 on manual sync route) rather than only suppressing
health-check display.
- Extend ScheduleConfig.sync_type union with 'pax8-daily'
- Add dual-guarded branch in executeScheduledSync: skips with a
distinct log when PAX8 is not configured (isPax8Configured()) or
when integration_settings.key='pax8' is disabled, otherwise calls
getPax8SyncService().fullSync('scheduled')
- PAX8-only inline check per D-01 — no shared helper, no changes to
getDbDisabledKeys()/applyDisableOverlay() or other switch branches
- Return 403 when integration_settings.key='pax8' has disabled=true
- Check runs as the first statement, before isSyncInProgress()
- GET handler unchanged; no new imports (postgresClient already imported)
- Idempotent INSERT ... WHERE NOT EXISTS seed of the pax8-daily row
(cron 0 4 * * *, is_enabled false), mirroring migration 089's style
- Covers existing installs since createDefaultSchedules() only seeds
a virgin sync_schedules table
- Applied to running dev DB and verified idempotent (second run = 0 rows)
Registers AppGate as a checkConfigOnly integration-health row and public
sync route, matching the existing factory + is<Name>Configured() pattern.
Committed now so Phase 13's worktree-isolated executors fork from a HEAD
that includes this integration-health.ts entry, since Plan 13-02 inserts
the PAX8 row immediately after it.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LHRgZqkzBHBbAbc3KHneuR
Developer reviewed the SC#1-SC#4 verdict block and the auto-match sample
and responded "approved" — all four success criteria pass, auto-matches
are correct, no threshold/mapping changes needed. Marks PAX8-06, PAX8-10,
PAX8-11 complete in REQUIREMENTS.md.
- scripts/verify-pax8-orders-matching.ts: runs a real Pax8SyncService.fullSync()
twice, then asserts all four Phase 12 success criteria (order items
populated with company id + billing period, confident auto-matches exist,
no-match/ambiguous companies flagged for review, auto-match set stable
across two syncs). Never logs secrets/tokens.
- migrations/094_pax8_order_items_quantity_numeric.sql (Rule 1 auto-fix):
pax8_order_items.quantity was INTEGER but real PAX8 usage-based invoice
items (e.g. Azure per-unit bandwidth overage) report fractional
quantities, which aborted the entire orders/order_items sync loop on the
first such row and silently truncated SC#1's item coverage to ~123 rows
instead of the full ~56k-row history. Widened to NUMERIC(14,4); applied
directly to the dev DB (existing volume, not a fresh init).
- deferred-items.md: logged pre-existing out-of-scope failures (appgate
TS2307 type errors, itglue-search.test.ts) confirmed unchanged by this
plan's files.
- First unit tests for Pax8SyncService, mocking postgresClient.query and
pax8-company-matcher's matchPax8Companies (following
pax8-company-matcher.test.ts's mocking discipline)
- Asserts INSERT INTO pax8_orders / pax8_order_items with companyId bound
into pax8_company_id and amountDue into line_total
- Asserts resolveCostColumns' default (CONFIRM) mapping for both observed
item types (subscription, one-time) per 12-02-SUMMARY.md
- Asserts child-then-parent tombstone ordering (pax8_order_items before
pax8_orders)
- Asserts fullSync's entities include 'orders' and 'company_matches'
No TDD gate — plan is autonomous without a plan-level `type: tdd`
frontmatter; the implementation already existed from Tasks 1-2, so this
follows the same single-commit test-addition pattern established by
12-02-SUMMARY.md's Task 2.
- syncCompanyMatches() delegates to matchPax8Companies() (Plan 03),
shaping its result into the standard Pax8EntitySyncResult
- fullSync() now pushes ordersResult then matchResult after products,
so pax8_companies is fully populated before matching runs
- Both steps roll up into the existing success/status/totals reducer
and sync_history record unchanged
- Adds Pax8SyncService.syncOrders(): pages all invoice headers, then
per-header pages its items (12-RESEARCH.md Pattern 1 nested fetch)
- resolveCostColumns() branches on item.type per 12-02-SUMMARY.md's
live spot-check verdicts (all types CONFIRM -> single default branch,
kept as a named seam for future divergence)
- pax8_orders.pax8_company_id stays NULL (Pitfall 1); per-company data
lives on pax8_order_items.pax8_company_id
- Tombstones child (pax8_order_items) before parent (pax8_orders) to
respect the FK, using the existing id <> ALL($1::uuid[]) pattern