StackTrading Docs

SRS: UC_9.12 — Flow 35: Rippling PTO Ledger Sync

FieldValue
UC_IDUC_9.12
Versionv1.2
Last Updated2026-11-05 (v1.2 — client sheet 2026-11-04: integer days only; no corrective entry on cancel)
BA PiClinh.nguyen34
CategoryBACKGROUND MECHANISMS & CRON JOBS
ModuleFlow 35 (UC_4.15.2)
FunctionRippling PTO Ledger Sync
Document ReferencesCR-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_IDFunctionDescription
UC_9.12Flow 35 — Rippling PTO Ledger SyncWhen 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

FieldValue
Use CaseRippling PTO Ledger Sync
DescriptionPublishes 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.
ActorSystem (Rippling → Zapier → Middleware Hub → Polygon PoS)
Zapier FlowFlow 35
Trigger SourceRippling webhook — Time Off Request Approved
3rd PartyRippling · Zapier · Alchemy RPC · Polygon PoS
Middleware EndpointPOST /api/ledger/record
Related UCsUC_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

IDPre-condition
P1Rippling webhook subscription for Time Off Request Approved targets Zapier Flow 35.
P2Payload contains Rippling Request ID and approved day count (Days_Approved).
P3Worker maps to an active Stack Trading W-2 trader (Employment_Type = 'W-2').
P4StackTradingLedger contract and owner wallet are available (see UC_9.11 P4).

4. Post-conditions

#Post-condition
1One CorporateMetricVerified event with metricCategory = "Corporate Benefits".
2tx_hash stored in PostgreSQL; execution logged to BPS_Audit_Log.
3Rippling Request ID marked processed (no duplicate mint).
4Zap 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

FieldValue
trader_idGlobal 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)"
dateToday (ISO 8601 UTC)
receipt_hashRippling 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_deadline are 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_IDFlowGivenThenType
AC-9.12-01Happy pathRippling approves 3 days PTO for active W-2 traderOne event: metricCategory = "Corporate Benefits", metricValue = "3 Days PTO Approved (Paid Time Off)", verificationHash = Request ID; tx_hash storedIntegration
AC-9.12-02DuplicateSame Request ID delivered twiceOne on-chain event only; second call HTTP 200 with original tx_hashIntegration
AC-9.12-03ContractorPayload for international contractorZap stops; no ledger callIntegration
AC-9.12-04No side effectsAC-9.12-01 completedstagnation_deadline and broker trading state unchanged by Flow 35 (changes, if any, come only from Flow 13)Integration
AC-9.12-05Bad JWTInvalid signatureHTTP 401; no mintSecurity
AC-9.12-06Integer daysRippling approves 2 days PTO for active W-2 tradermetricValue = "2 Days PTO Approved (Paid Time Off)" — integer value, no decimalsIntegration

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

IDPriorityQuestionAssumption
Q1MIf 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—Does Rippling also fire Time Off Approved for PTO entered directly in Rippling (not via Flow 13)?✅ Closed by CR-20261027-001 — all W-2 PTO is requested directly in Rippling; Flow 35 logs every approval.
Q3LDays_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

DateVersionChangePreviousAfterSource
2026-11-05v1.2Header; §5 metric_value row; §7 Exc-3; §8 BR_9.12.2; §9 AC-9.12-06 (new); §11 Q1, Q3Half-day assumed possible (0.5 Days…); corrective entry on cancel openInteger 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-27v1.1§1 Document References, Related UCs; §2 Trigger upstream; Q2 closedUpstream 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 ACR-20261027-001
2026-10-27v1.0Initial document creation—Full spec: trigger, W-2 filter, dedup, ledger mint, BR_9.12.1–5, AC-9.12-01–05Zapier Integration V7.pdf §Flow 35, §Flow 13; RFQ_ Stack Trading Prop Tech V7.pdf §Record Immutable Ledger

On this page