SRS: UC_9.12 — Flow 35: Rippling PTO Ledger Sync
| Field | Value |
|---|---|
| UC_ID | UC_9.12 |
| Version | v1.2 |
| Last Updated | 2026-11-05 (v1.2 — client sheet 2026-11-04: integer days only; no corrective entry on cancel) |
| BA PiC | linh.nguyen34 |
| Category | BACKGROUND MECHANISMS & CRON JOBS |
| Module | Flow 35 (UC_4.15.2) |
| Function | Rippling PTO Ledger Sync |
| Document References | CR-20261027-001 (Flow 13 hybrid — W-2 requests time off in Rippling) · Zapier Integration V7.pdf (§Flow 35; §Flow 13 Time-Off Management) · RFQ_ Stack Trading Prop Tech V7.pdf (§Record Immutable Ledger POST /api/ledger/record; §3.6.1 Smart Contract Architecture; §Audit Requirements) |
1. UC Index
| UC_ID | Function | Description |
|---|---|---|
| UC_9.12 | Flow 35 — Rippling PTO Ledger Sync | When Rippling approves a W-2 trader's time-off request, Zapier calls POST /api/ledger/record to mint a Corporate Benefits event ([Days_Approved] Days PTO Approved (Paid Time Off)) on Polygon PoS. Ledger logging only — stagnation extension and account lock belong to Flow 13 (UC_9.2). |
UC_9.12 — Flow 35: Rippling PTO Ledger Sync
| Field | Value |
|---|---|
| Use Case | Rippling PTO Ledger Sync |
| Description | Publishes proof of paid time-off (corporate benefit) to the Immutable Ledger. Each approved Rippling time-off request for an active W-2 trader produces exactly one CorporateMetricVerified event with the Rippling Request ID as verificationHash. |
| Actor | System (Rippling → Zapier → Middleware Hub → Polygon PoS) |
| Zapier Flow | Flow 35 |
| Trigger Source | Rippling webhook — Time Off Request Approved |
| 3rd Party | Rippling · Zapier · Alchemy RPC · Polygon PoS |
| Middleware Endpoint | POST /api/ledger/record |
| Related UCs | UC_9.2 Flow 13 Time-Off Management (Path A is triggered by the same Rippling webhook) · UC_9.11 · UC_4.15.2 |
2. Trigger
Event: Rippling Time Off Request Approved webhook → Zapier Flow 35 catch hook.
Upstream: the W-2 trader requests time off inside Rippling and Rippling approves it (CR-20261027-001). The same webhook fans out to two independent Zaps: Flow 35 (this UC — ledger) and Flow 13 Path A (UC_9.2 — extend stagnation_deadline, lock account, notify). Stack Trading does not create time-off records in Rippling.
(Source: Zapier Integration V7.pdf §Flow 35 · CR-20261027-001 · UC_9.2 §2.1)
3. Pre-conditions
| ID | Pre-condition |
|---|---|
| P1 | Rippling webhook subscription for Time Off Request Approved targets Zapier Flow 35. |
| P2 | Payload contains Rippling Request ID and approved day count (Days_Approved). |
| P3 | Worker maps to an active Stack Trading W-2 trader (Employment_Type = 'W-2'). |
| P4 | StackTradingLedger contract and owner wallet are available (see UC_9.11 P4). |
4. Post-conditions
| # | Post-condition |
|---|---|
| 1 | One CorporateMetricVerified event with metricCategory = "Corporate Benefits". |
| 2 | tx_hash stored in PostgreSQL; execution logged to BPS_Audit_Log. |
| 3 | Rippling Request ID marked processed (no duplicate mint). |
| 4 | Zap terminates. No change to stagnation_deadline or trading state by this flow. |
5. Basic Flow
Step 1 — Receive webhook (Zapier).
Step 2 — Filter: active W-2 trader. Continue only if payload corresponds to an active Stack Trading W-2 trader; otherwise stop (Alt-2).
(Source: Zapier Integration V7.pdf §Flow 35)
Step 3 — Dedup check on Rippling Request ID. If processed → Alt-1.
Step 4 — Call POST /api/ledger/record
| Field | Value |
|---|---|
trader_id | Global trader UUID |
metric_category | "Corporate Benefits" (fixed) |
metric_value | "[Days_Approved] Days PTO Approved (Paid Time Off)" — Days_Approved is a whole integer (full days only), e.g. "3 Days PTO Approved (Paid Time Off)" |
date | Today (ISO 8601 UTC) |
receipt_hash | Rippling Request ID |
(Source: Zapier Integration V7.pdf §Flow 35)
Step 5 — Middleware mints on Polygon — identical to UC_9.11 Step 5 (JWT validation → Ethers.js wallet → recordMetric() via Alchemy → await confirmation → store tx_hash → HTTP 200).
(Source: RFQ_ Stack Trading Prop Tech V7.pdf §Record Immutable Ledger)
Step 6 — Terminate Zap.
6. Alternative Flows
Alt-1 — Duplicate delivery: return HTTP 200 with stored tx_hash; no second mint.
Alt-2 — Not an active W-2 trader: Zap stops at filter; no ledger call.
7. Exceptional Flows
Exc-1 (invalid JWT → HTTP 401) and Exc-2 (Polygon RPC failure → non-2xx, not marked processed, Zapier retry) — same as UC_9.11 §7.
Exc-3 — Time-off later cancelled in Rippling
- The on-chain event is immutable and cannot be reversed. No corrective ledger entry is written.
- Re-enabling the trading account and adjusting
stagnation_deadlineare handled manually by Ops — see UC_9.2 Alt-5.
(Source: QnA_BACKGROUND_MECHANISMS_CRON.md [BG-017], [BG-002] — client sheet 2026-11-04)
8. Business Rules
BR_9.12.1: Ledger Logging Only
Flow 35 only writes the PTO event to the Immutable Ledger. stagnation_deadline extension, TRIM_TO_COMPLIANCE, and execution lock (Rithmic / MT5 / TraderEvolution) are owned by Flow 13 (UC_9.2 Steps A-3+) and must not be re-executed here.
(Source: Zapier Integration V7.pdf §Flow 35 — only action is POST /api/ledger/record then "Terminate Zap"; §Flow 13)
BR_9.12.2: Fixed Ledger Mapping
metric_category = "Corporate Benefits"; metric_value = "[Days_Approved] Days PTO Approved (Paid Time Off)", with Days_Approved as a whole integer — PTO is measured in full days only (no half days); receipt_hash = Rippling Request ID.
(Source: Zapier Integration V7.pdf §Flow 35; QnA_BACKGROUND_MECHANISMS_CRON.md [BG-018] — client sheet 2026-11-04)
BR_9.12.3: Scope — Active W-2 Only
International contractor hiatus is unpaid and is not logged by Flow 35.
(Source: Zapier Integration V7.pdf §Flow 35; §Flow 13 Path B)
BR_9.12.4: One Approval = One Ledger Event
Rippling Request ID is the idempotency key. Same as BR_9.11.3.
BR_9.12.5: Audit Retention
Same as BR_9.11.7 (5 years + 1 month; > 25 months → cold storage).
(Source: RFQ_ Stack Trading Prop Tech V7.pdf §Audit Requirements)
9. Acceptance Criteria
| AC_ID | Flow | Given | Then | Type |
|---|---|---|---|---|
| AC-9.12-01 | Happy path | Rippling approves 3 days PTO for active W-2 trader | One event: metricCategory = "Corporate Benefits", metricValue = "3 Days PTO Approved (Paid Time Off)", verificationHash = Request ID; tx_hash stored | Integration |
| AC-9.12-02 | Duplicate | Same Request ID delivered twice | One on-chain event only; second call HTTP 200 with original tx_hash | Integration |
| AC-9.12-03 | Contractor | Payload for international contractor | Zap stops; no ledger call | Integration |
| AC-9.12-04 | No side effects | AC-9.12-01 completed | stagnation_deadline and broker trading state unchanged by Flow 35 (changes, if any, come only from Flow 13) | Integration |
| AC-9.12-05 | Bad JWT | Invalid signature | HTTP 401; no mint | Security |
| AC-9.12-06 | Integer days | Rippling approves 2 days PTO for active W-2 trader | metricValue = "2 Days PTO Approved (Paid Time Off)" — integer value, no decimals | Integration |
10. API Reference
POST /api/ledger/record — schema as UC_9.11 §10.
{
"trader_id": "94a2b1c8-3f4e-4b21-a123-890abcdef123",
"metric_category": "Corporate Benefits",
"metric_value": "3 Days PTO Approved (Paid Time Off)",
"date": "2026-03-15T18:00:00Z",
"receipt_hash": "rip_pto_99120482"
}11. Open Questions
| ID | Priority | Question | Assumption |
|---|---|---|---|
| Q1 | M | If an approved PTO is later cancelled/shortened in Rippling, should a corrective ledger event be minted (e.g. "PTO Cancelled")? | ✅ Answered 2026-11-04 — no corrective ledger entry; Ops handles manually (Exc-3, [BG-017]). |
| Q2 | — | ✅ Closed by CR-20261027-001 — all W-2 PTO is requested directly in Rippling; Flow 35 logs every approval. | |
| Q3 | L | Days_Approved can be fractional (half-day)? Format? | ✅ Answered 2026-11-04 — full integer days only, no half days (BR_9.12.2, [BG-018]). |
12. Changelog
| Date | Version | Change | Previous | After | Source |
|---|---|---|---|---|---|
| 2026-11-05 | v1.2 | Header; §5 metric_value row; §7 Exc-3; §8 BR_9.12.2; §9 AC-9.12-06 (new); §11 Q1, Q3 | Half-day assumed possible (0.5 Days…); corrective entry on cancel open | Integer days only; no corrective ledger entry, Ops manual (UC_9.2 Alt-5) | Client sheet 2026-11-04 [BG-017] [BG-018] [BG-002] |
| 2026-10-27 | v1.1 | §1 Document References, Related UCs; §2 Trigger upstream; Q2 closed | Upstream described as "Flow 13 Step A-2 logs the leave in Rippling" | W-2 requests in Rippling; same webhook triggers Flow 35 and Flow 13 Path A | CR-20261027-001 |
| 2026-10-27 | v1.0 | Initial document creation | — | Full spec: trigger, W-2 filter, dedup, ledger mint, BR_9.12.1–5, AC-9.12-01–05 | Zapier Integration V7.pdf §Flow 35, §Flow 13; RFQ_ Stack Trading Prop Tech V7.pdf §Record Immutable Ledger |