Implementation TODO / gates

Verae Zapier Platform — Implementation TODO

Workspace: /Users/marchon/apps/zapier (imported 2026-09-09). Packages live under packages/. Commercial billing is packages/zappier — do not reimplement it in middleware. Composition waves: see docs/02-architecture/composition.md.

Product goal: Hybrid HTTP edge + NATS workers middleware between Zapier servers and https://api.veraetime.net.

Architecture bottom line:

How to use this file

  1. Work top to bottom. Phases are dependency-ordered.
  2. Every phase ends with a GATE (tests must pass) before the next phase starts.
  3. Mark items [x] only after the gate command succeeds and results are recorded under Gate log.
  4. Do not skip gates. Parallel work is only allowed within a phase when items share no dependency.

Runtime debug

Primary docs

Doc Purpose
README.md Repo overview and quick start
docs/architecture/overview.md System diagram and data flows
docs/architecture/nats-subjects.md Subject topology and payloads
docs/developer/modules/ Per-module function reference
docs/plans/phase-gates.md Gate commands and acceptance criteria
docs/api/middleware-openapi.yaml Zapier-facing OpenAPI

Legend

Marker Meaning
[ ] Not started
[~] In progress
[x] Done and gate passed
BLOCKED Waiting on listed dependency
GATE Mandatory test validation — no next phase until green

Phase 0 — Repository baseline and documentation contract

Depends on: nothing
Unblocks: Phase 1+

Tasks

GATE 0 — Documentation and structure

cd /Users/marchon/datacubes/verae-zapier-api
npm run gate:0

Pass criteria

Gate log

Date Result Notes
2026-08-11 pass structure + docs gate

Phase 1 — Debug runtime facility

Depends on: Phase 0 GATE
Unblocks: All code phases (debug used everywhere)

Tasks

GATE 1 — Debug facility

npm run gate:1
# equivalent: node --test verae-zapier-middleware/test/unit/debug*.test.js

Pass criteria

Gate log

Date Result Notes
2026-08-11 pass 11/11 unit tests

Phase 2 — Config, errors, and core HTTP shell

Depends on: Phase 1 GATE
Unblocks: Auth, clients, routes

Tasks

GATE 2 — HTTP shell

npm run gate:2

Pass criteria

Gate log

Date Result Notes
2026-08-11 pass health + config unit tests; /zapier returns 501 until Phase 5–6 routes

Phase 3 — Persistence stores (tenants, usage, webhooks)

Depends on: Phase 2 GATE
Unblocks: Auth bridge, billing, webhook subscribe API

Tasks

GATE 3 — Stores

npm run gate:3

Pass criteria

Gate log

Date Result Notes
2026-08-11 pass store unit tests

Phase 4 — Tokens and Verae HTTP client

Depends on: Phase 3 GATE
Unblocks: Auth service, timestamp/verify services

Tasks

GATE 4 — Client + tokens

npm run gate:4

Pass criteria

Gate log

Date Result Notes
2026-08-11 pass tokens + mock client

Phase 5 — Auth bridge and entitlements (HTTP, no NATS yet)

Depends on: Phase 4 GATE
Unblocks: Timestamp/verify routes, Zapier custom auth

Tasks

GATE 5 — Auth + billing gates

npm run gate:5

Pass criteria

Gate log

Date Result Notes
2026-08-11 pass auth me + quota

Phase 6 — Sync HTTP API path (in-process poller fallback)

Depends on: Phase 5 GATE
Unblocks: NATS swap-in (Phase 7+), Zapier app wiring

Note: Implements full product behavior with NATS_ENABLED=false so Zapier can work before NATS.

Tasks

GATE 6 — Full HTTP middleware (no NATS)

npm run gate:6

Pass criteria

Gate log

Date Result Notes
2026-08-11 pass full HTTP mock path

Phase 7 — NATS connection, streams, and publishers

Depends on: Phase 6 GATE
Unblocks: Workers, production multi-instance

Tasks

GATE 7 — NATS infrastructure

npm run gate:7
# starts NATS if needed, ensures streams, runs nats tests

Pass criteria

Gate log

Date Result Notes
2026-08-11 pass nats-server JetStream

Phase 8 — NATS workers (job poller + webhook deliver)

Depends on: Phase 7 GATE
Unblocks: Hybrid production path

Tasks

GATE 8 — Async path with NATS

npm run gate:8

Pass criteria

Gate log

Date Result Notes
2026-08-11 pass workers watch→webhook

Phase 9 — /timestamp/wait via NATS events

Depends on: Phase 8 GATE
Unblocks: Efficient Zapier “Create and Wait” under multi-instance

Tasks

GATE 9 — Wait path

npm run gate:9

Pass criteria

Gate log

Date Result Notes
2026-09-09 pass wait via NATS + timeout pending; NS1 tunnel 70.88.205.138

Phase 10 — Tenant signup / admin provision

Depends on: Phase 6 GATE (can parallel Phase 7–9 after 6)
Unblocks: Self-serve and enterprise keys for Zapier

Tasks

GATE 10 — Tenancy

npm run gate:10

Pass criteria

Gate log

Date Result Notes
2026-08-11 pass signup + admin

Phase 11 — Zapier CLI app (verae-zapier)

Depends on: Phase 6 GATE minimum; Phase 8 recommended for triggers
Unblocks: Private invites on Zapier

Tasks

GATE 11 — Zapier package

npm run gate:11

Pass criteria

Gate log

Date Result Notes
2026-08-11 pass zapier package unit tests

Phase 12 — End-to-end validation (local stack)

Depends on: Gates 8, 10, 11
Unblocks: Remote deploy

Tasks

GATE 12 — E2E local

npm run gate:12

Pass criteria

Gate log

Date Result Notes
2026-09-09 pass harness/scripts/smoke.sh health + signup + wait

Phase 13 — Production wiring to api.veraetime.net

Depends on: Phase 12 GATE
Unblocks: Real customer traffic

Tasks

GATE 13 — Production smoke

npm run gate:13
# requires env: PRODUCTION_SMOKE=1 and real credentials

Pass criteria

Gate log

Date Result Notes

Phase 14 — Private Zapier push and invite

Depends on: Phase 13 GATE
Unblocks: Beta users

Tasks

GATE 14 — Human acceptance

Pass criteria

Gate log

Date Result Notes

Phase 15 — Hardening (post-beta)

Depends on: Phase 14
Unblocks: Public listing consideration

Tasks

GATE 15 — Hardening checklist

Pass criteria


Dependency graph (summary)

0 Docs/structure
 └─▶ 1 Debug facility
      └─▶ 2 HTTP shell
           └─▶ 3 Stores
                └─▶ 4 Tokens + Verae client
                     └─▶ 5 Auth + entitlements
                          └─▶ 6 Sync HTTP API (+ in-process poller)
                               ├─▶ 7 NATS infra ──▶ 8 Workers ──▶ 9 Wait-via-NATS
                               ├─▶ 10 Tenancy (parallel after 6)
                               └─▶ 11 Zapier app (after 6; triggers prefer 8)
                                        └─▶ 12 E2E local (needs 8,10,11)
                                             └─▶ 13 Production Verae
                                                  └─▶ 14 Private Zapier push
                                                       └─▶ 15 Hardening

npm gate commands (root)

Script Phase What it runs
npm run gate:0 0 Structure + doc presence
npm run gate:1 1 Debug unit tests
npm run gate:2 2 Config/errors/app tests
npm run gate:3 3 Store tests
npm run gate:4 4 Tokens + client tests
npm run gate:5 5 Auth + entitlement tests
npm run gate:6 6 HTTP integration (NATS off)
npm run gate:7 7 NATS stream tests
npm run gate:8 8 Worker integration
npm run gate:9 9 Wait path tests
npm run gate:10 10 Tenant tests
npm run gate:11 11 Zapier package tests
npm run gate:12 12 Compose E2E
npm run gate:13 13 Live smoke (opt-in)
npm run gate:all 0–12 All automated gates in order; stop on first failure

Definition of done (platform MVP)


Working rules for implementers

  1. No phase advancement without gate.
  2. Write tests first or with the code for that phase’s modules.
  3. Document every new export in docs/developer/modules/<name>.md and JSDoc in source.
  4. Instrument with debug at boundaries: auth resolve, outbound Verae, NATS publish/consume, webhook HTTP.
  5. Prefer failing a gate over merging incomplete behavior.
  6. Update the Gate log tables when a gate passes.