@1aboveio/skills 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +8 -2
  2. package/package.json +1 -1
  3. package/runtime/skills/distribution/generated/recipes.json +178 -34
  4. package/runtime/skills/distribution/scripts/bundles.mjs +11 -3
  5. package/runtime/skills/engineering/engineering-runtime/scripts/workflow-policy.mjs +1 -1
  6. package/skills/data-science/pyspark/SKILL.md +126 -0
  7. package/skills/{backend → data-science}/pyspark/assets/templates/etl.py +51 -0
  8. package/skills/{backend → data-science}/pyspark/references/diagnosis-and-profiling.md +38 -14
  9. package/skills/{backend → data-science}/pyspark/references/etl-contract.md +19 -0
  10. package/skills/data-science/pyspark/references/production-validation.md +131 -0
  11. package/skills/data-science/pyspark/references/reconciliation.md +38 -0
  12. package/skills/{backend → data-science}/pyspark/references/transformation-design.md +30 -2
  13. package/skills/engineering/engineering-runtime/coherence/workflow.json +14 -14
  14. package/skills/engineering/engineering-runtime/scripts/workflow-policy.mjs +1 -1
  15. package/skills/engineering/resolve-issues/generated/workflow-repair-policy.json +11 -11
  16. package/skills/engineering/resolve-issues/scripts/run-state.mjs +1 -1
  17. package/skills/payment/fraud-analysis/LICENSE +3 -0
  18. package/skills/payment/fraud-analysis/SKILL.md +113 -0
  19. package/skills/payment/fraud-analysis/evals/evals.json +40 -0
  20. package/skills/payment/fraud-analysis/references/archetypes/authorized-payment-scam.md +41 -0
  21. package/skills/payment/fraud-analysis/references/archetypes/first-party-fraud.md +44 -0
  22. package/skills/payment/fraud-analysis/references/archetypes/third-party-fraud.md +27 -0
  23. package/skills/payment/fraud-analysis/references/contexts/bank-transfer.md +24 -0
  24. package/skills/payment/fraud-analysis/references/contexts/card-payment.md +30 -0
  25. package/skills/payment/fraud-analysis/references/contexts/payment-collection.md +20 -0
  26. package/skills/payment/fraud-analysis/references/contexts/payout.md +20 -0
  27. package/skills/payment/fraud-analysis/references/feature-engineering.md +158 -0
  28. package/skills/payment/fraud-analysis/references/mechanisms/account-takeover.md +36 -0
  29. package/skills/payment/fraud-analysis/references/report-rationale.md +45 -0
  30. package/skills/payment/fraud-analysis/references/report-template.md +190 -0
  31. package/skills/payment/fraud-analysis/references/review-checklist.md +175 -0
  32. package/skills/payment/fraud-analysis/references/taxonomy.md +79 -0
  33. package/skills/payment/fraud-analysis/references/terminology.md +108 -0
  34. package/skills/payment/fraud-analysis/references/workflow.md +175 -0
  35. package/skills/payment/payment-analysis/LICENSE +3 -0
  36. package/skills/payment/payment-analysis/SKILL.md +127 -0
  37. package/skills/payment/payment-analysis/references/auth-rate-actions.md +30 -0
  38. package/skills/payment/payment-analysis/references/chargebacks.md +88 -0
  39. package/skills/payment/payment-analysis/references/event-layers.md +79 -0
  40. package/skills/payment/payment-analysis/references/fx.md +59 -0
  41. package/skills/payment/payment-analysis/references/journey.md +78 -0
  42. package/skills/payment/payment-analysis/references/metrics.md +62 -0
  43. package/skills/payment/payment-analysis/references/report-template.md +98 -0
  44. package/skills/payment/payment-analysis/references/terminology.md +85 -0
  45. package/skills/payment/payment-analysis/references/visualization.md +47 -0
  46. package/skills/backend/pyspark/SKILL.md +0 -116
  47. package/skills/backend/pyspark/references/parity-testing.md +0 -83
  48. package/skills/backend/pyspark/references/production-validation.md +0 -166
  49. /package/skills/{backend → data-science}/airflow-dag-develop/LICENSE +0 -0
  50. /package/skills/{backend → data-science}/airflow-dag-develop/SKILL.md +0 -0
  51. /package/skills/{backend → data-science}/pyspark/LICENSE +0 -0
  52. /package/skills/{backend → data-science}/pyspark/assets/templates/utils/__init__.py +0 -0
  53. /package/skills/{backend → data-science}/pyspark/assets/templates/utils/hudi_metadata.py +0 -0
  54. /package/skills/{backend → data-science}/pyspark/references/velocity-feature-calculation.md +0 -0
  55. /package/skills/{backend → data-science}/pyspark/scripts/spark_eventlog_summary.py +0 -0
@@ -0,0 +1,175 @@
1
+ # Fraud-analysis workflow (steps 0–9)
2
+
3
+ Called from [SKILL.md](../SKILL.md). Paths below are relative to the skill root.
4
+
5
+ ## 0 — Pre-flight
6
+
7
+ Inspect the input, requested target, and label provenance before planning a
8
+ supervised analysis. Record:
9
+
10
+ ```yaml
11
+ label_provenance: file-column | user-defined | absent
12
+ positive_definition: ""
13
+ negative_definition: ""
14
+ unlabeled_definition: ""
15
+ preflight_status: pass | needs-user-input | descriptive-only | blocked
16
+ ```
17
+
18
+ - Confirm the file is readable and identify its row grain, candidate time field,
19
+ outcome/label fields, and requested positive definition.
20
+ - When the positive label comes from an existing row-level outcome column, map
21
+ its positive value(s). Assume the rest of the mature analysis population is
22
+ negative, except explicit missing, pending, unknown, or unlabeled states.
23
+ State this assumption and show the observed values to the user when ambiguous.
24
+ - When the user defines the positive label as a condition or derived rule,
25
+ require the user to define the negative condition during pre-flight. Do not
26
+ infer `NOT positive` as negative. Ask one focused clarification and set status
27
+ to `needs-user-input` until answered.
28
+ - Rows matching neither class, both classes, explicit unknown states, or an
29
+ immature outcome window are unlabeled.
30
+ - If no usable positive and negative definitions exist, offer descriptive
31
+ segmentation without precision/recall, or block supervised analysis.
32
+
33
+ Do not proceed to the supervised workflow until pre-flight passes. A
34
+ `descriptive-only` analysis may select a profile and explore segments, but it
35
+ must not compute precision, recall, lift, or supervised strategy performance.
36
+ Profile clarification may be grouped into the same user question when both
37
+ label and attribution inputs are missing.
38
+
39
+ ## 1 — Select analysis profile
40
+
41
+ Read [taxonomy.md](taxonomy.md). Record:
42
+
43
+ ```yaml
44
+ archetype: third-party-fraud | first-party-fraud | authorized-payment-scam | unclassified
45
+ customer_role: victim | perpetrator | knowing-participant | facilitator | unknown
46
+ customer_consent: present | absent | disputed | unknown
47
+ technical_authentication: passed | failed | not-applicable | unknown
48
+ mechanisms: []
49
+ contexts: []
50
+ subtype: null
51
+ attribution_confidence: confirmed | probable | proxy | unknown
52
+ event_grain: ""
53
+ decision_point: ""
54
+ ```
55
+
56
+ - Select exactly one primary archetype. Select one or more mechanisms and
57
+ contexts when the data supports them.
58
+ - Customer consent and technical authentication are separate facts. Passed
59
+ login, MFA, or session checks do not prove genuine-customer consent.
60
+ - `APP scam` is a subtype of `authorized-payment-scam` in a `bank-transfer`
61
+ context; it is not a synonym for first-party fraud.
62
+ - If victimization versus knowing participation is unresolved, use
63
+ `unclassified`. Do not silently force attribution.
64
+ - If multiple archetypes are confirmed, run separate labels, rules, metrics,
65
+ and impact sections. Never blend them into one positive class.
66
+
67
+ Read the selected archetype, mechanism, and context references before Step 2.
68
+
69
+ ## 2 — Formalize label
70
+
71
+ - One primary label per archetype analysis. Confirmed outcomes are ground truth;
72
+ proxies must be identified as proxies.
73
+ - Carry forward the pre-flight provenance and class definitions; do not discover
74
+ the negative class here.
75
+ - Validate the pre-flight mapping against observed rows and record the resulting
76
+ positive, negative, and unlabeled counts.
77
+ - If the mapping is incomplete or contradictory, return to pre-flight with
78
+ `needs-user-input`; do not ask for or invent a negative class in this step.
79
+ - Derive labels only from supplied data and documented business meaning. Positive
80
+ and negative conditions must be disjoint. Rows matching neither, both, or an
81
+ immature/pending state are unlabeled and excluded from supervised metrics.
82
+ - Record positive definition/count, negative definition/count, unlabeled
83
+ definition/count, base rate among labeled rows, maturity window, exclusions,
84
+ and attribution confidence.
85
+ - Exclude the label, synonyms, investigations, recalls, disputes, or other later
86
+ outcomes from features when unavailable at the selected decision point.
87
+ - For delayed outcomes, ensure enough observation time or mark recent rows as
88
+ immature rather than negative.
89
+ - Do not continue to precision, recall, or supervised rule scoring until both
90
+ positive and negative classes are defined.
91
+
92
+ ## 3 — Freeze temporal validation
93
+
94
+ - Freeze the cut before feature work. Train is earlier; holdout is later.
95
+ - Do not random-shuffle rows or use random k-fold as headline validation.
96
+ - History and graph snapshots contain prior events only.
97
+ - No time column means full-sample descriptive analysis; mark metrics
98
+ **unvalidated**.
99
+
100
+ ## 4 — Engineer candidates
101
+
102
+ Read [feature-engineering.md](feature-engineering.md) and all selected
103
+ profile packs.
104
+
105
+ - Declare event grain and decision point before assessing columns.
106
+ - Classify fields as allowed now, excluded for zero variance, excluded for
107
+ timing, excluded for leakage, or context-only.
108
+ - Build thresholds, rate lists, graph lists, and watchlists on train only.
109
+ - Prefer interpretable conditions with explicit units and windows.
110
+ - Do not invent columns, identity links, consent, intent, or actor attribution.
111
+
112
+ ## 5 — Select shortlist
113
+
114
+ Use train only: lift, support, stability, operability, and meaningful
115
+ interactions. Keep tiny or attribution-uncertain spikes for monitoring.
116
+
117
+ ## 6 — Score rules
118
+
119
+ State explicit conditions, event grain, units, windows, and decision point.
120
+ Headline holdout metrics use this order:
121
+
122
+ **occurrence → precision → recall**
123
+
124
+ Train metrics are debugging evidence only. If outcomes are value-bearing, also
125
+ measure captured positive amount without replacing count-based metrics.
126
+
127
+ ## 7 — Map actions and packages
128
+
129
+ Use actions from the selected context packs; there is no universal 3DS action.
130
+
131
+ | Metric and evidence profile | Shared guidance |
132
+ |---|---|
133
+ | High precision, stable, severe impact | Consider the context's strongest preventive action |
134
+ | Higher recall, moderate precision | Add verification, review, warning, hold, or friction |
135
+ | Weak, unstable, small-N, uncertain attribution | Monitor or investigate |
136
+
137
+ - Legal, regulatory, policy, and operational authority constrain account holds,
138
+ freezes, rejects, beneficiary blocks, and reporting.
139
+ - Keep individual rules separate from multi-rule **strategy packages**.
140
+ - Freeze default and comparison packages before report writing.
141
+ - For each package compute triggered count/rate and amount/share, then precision
142
+ and recall, plus the context-specific customer, operations, conversion, delay,
143
+ and loss measures required by its pack.
144
+
145
+ ## 8 — Write business report
146
+
147
+ Read [report-template.md](report-template.md),
148
+ [terminology.md](terminology.md), and selected profile packs.
149
+
150
+ Use reader order:
151
+
152
+ 执行摘要 → 抽样、分析画像与标签 → 规则发现 → 策略整体影响 → 特征 → 附录
153
+
154
+ - Include the analysis profile and actor attribution near the start.
155
+ - Report only domain-appropriate actions, denominators, and impact KPIs.
156
+ - Strategy impact always includes count/rate and amount/share, then precision
157
+ and recall. Add only the selected contexts' required impact measures.
158
+ - Do not present scenario estimates or proxy-label value as measured loss saved.
159
+ - Save to a path such as `reports/fraud-analysis/<scope>.md`.
160
+ - Before finishing: grep the report for banned strings in
161
+ [terminology.md](terminology.md) and fix language only (not numbers,
162
+ BIN lists, or thresholds).
163
+
164
+ ## 9 — Independent review
165
+
166
+ Read [review-checklist.md](review-checklist.md) and selected packs.
167
+
168
+ - Review the common method and presentation contract.
169
+ - Apply checks from every selected archetype, mechanism, and context pack.
170
+ - Auto-fix mechanical issues only. Do not silently change attribution, label,
171
+ customer role, or action severity.
172
+ - Prefer a fresh independent reviewer. If unavailable, use a fresh same-session
173
+ checklist and disclose that only in the chat delivery note.
174
+ - Deliver the business report plus a short note with verdict, fixes, and open
175
+ judgment issues. Keep review process details out of the report.
@@ -0,0 +1,3 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 1AboveIO
@@ -0,0 +1,127 @@
1
+ ---
2
+ name: payment-analysis
3
+ description: >
4
+ Produce a visualized payment overview from authorization + settlement
5
+ extracts (optional chargebacks): executive summary, top statistics, payment
6
+ journey Sankey, and topics (volume, WoW trend, auth rate, BIN-country
7
+ contribution, decline-by-reason, decline-by-country). Amounts report in USD
8
+ (Forex Service daily conversion). Chargebacks use Visa same-month and
9
+ Mastercard lagged 拒付率. 运营影响 is 3DS / 风控拦截 / soft-decline retry
10
+ only. Use whenever the user asks for payment overview, auth-rate analysis,
11
+ decline mix, BIN/issuer-country contribution, settlement GMV, payment journey,
12
+ Sankey funnel, FX-to-USD, chargeback rate, 运营影响, or "business analysis of
13
+ transactions" — even if they do not say payment-analysis. Do NOT use for
14
+ supervised fraud-rule mining (that is fraud-analysis).
15
+ ---
16
+
17
+ # Payment Analysis
18
+
19
+ Descriptive payment-funnel analytics with charts. Explains what happened in the
20
+ book. Does not invent fraud rules or claim loss saved.
21
+
22
+ Use authorization **and** settlement when both files exist. Chargebacks are
23
+ optional topic fuel, not required for the journey core.
24
+
25
+ | Layer | Typical file | Row grain |
26
+ |---|---|---|
27
+ | Authorizations | `Authorizations_*.csv` | one auth attempt |
28
+ | Settlements | `Sales-and-refunds_*settlements*.csv` | one sale or refund |
29
+ | Chargebacks | `Chargebacks_*.csv` | one dispute (optional) |
30
+
31
+ **Produce:** Markdown + preferred Chinese/bilingual HTML under
32
+ `reports/payment-analysis/`.
33
+ **Do not produce:** supervised precision/recall packages (`fraud-analysis`).
34
+
35
+ Read the playbook for the step you are on. Paths under `references/` are
36
+ relative to this skill.
37
+
38
+ ## Workflow
39
+
40
+ Follow these steps in order.
41
+
42
+ ### 0 — Pre-flight
43
+
44
+ Read [event-layers.md](references/event-layers.md). Record layers present and
45
+ missing, paths, time fields, currencies, and which journey checkpoints have
46
+ usable columns. Amount reporting is USD: read [fx.md](references/fx.md) before
47
+ any amount KPI (all-USD books still write `金额均为 USD` and do not call Forex).
48
+
49
+ ### 1 — Window and segments
50
+
51
+ Freeze the analysis window (defaults in event-layers.md). Segment by BIN
52
+ country, card product, response message/code, settlement type when present.
53
+
54
+ ### 2 — KPIs
55
+
56
+ Compute auth + settlement metrics from [metrics.md](references/metrics.md).
57
+ Convert non-USD amounts per [fx.md](references/fx.md) before any sum or share.
58
+ If chargebacks are present, monthly 拒付率 follows
59
+ [chargebacks.md](references/chargebacks.md) (Visa same-month, Mastercard lagged,
60
+ skip empty brand-months, no blended Visa+Mastercard ratio).
61
+
62
+ ### 3 — Journey Sankey
63
+
64
+ Build **count** flows with [journey.md](references/journey.md). Join sales to
65
+ approved auths on `Order ID`. Footnote unjoined refunds. Skip risk/3DS nodes
66
+ when authentication fields are empty; caption the skips.
67
+
68
+ ### 4 — Write outputs
69
+
70
+ Structure and chapter minima:
71
+ [report-template.md](references/report-template.md). Chart marks:
72
+ [visualization.md](references/visualization.md). English/Chinese terms:
73
+ [terminology.md](references/terminology.md). 运营影响 only from
74
+ [auth-rate-actions.md](references/auth-rate-actions.md) when the extract
75
+ supports the trigger.
76
+
77
+ ```text
78
+ reports/payment-analysis/<scope>_overview.md
79
+ reports/payment-analysis/<scope>_overview.zh.md
80
+ reports/payment-analysis/<scope>_overview.zh.html
81
+ ```
82
+
83
+ HTML is preferred when there are charts. Glossary applies to headings, KPI
84
+ labels, legends, and Sankey skip chips.
85
+
86
+ ### 5 — Language proofread
87
+
88
+ Grep every report file for the banned strings in
89
+ [terminology.md](references/terminology.md). Replace hits using that table.
90
+ Do not change numbers, joins, or chart data.
91
+
92
+ ### 6 — Sanity check
93
+
94
+ - [ ] Structure is summary → top stats → Sankey → topics → 运营影响
95
+ - [ ] Auth + settlement both used when both files exist
96
+ - [ ] Sankey skips unavailable risk/3DS checkpoints and says so
97
+ - [ ] Count/amount are bars; rate is a line; dual axes when combined
98
+ - [ ] Amount axes/legends include currency (`授权尝试金额 USD`, …)
99
+ - [ ] No supervised fraud-rule metrics
100
+ - [ ] Non-USD amounts converted per fx.md; all-USD books say 金额均为 USD
101
+ - [ ] Chargeback monthly rates skip empty brand-months; no blended Visa+MC ratio
102
+ - [ ] 运营影响 only from auth-rate-actions.md when triggered
103
+ - [ ] Language matches terminology.md; banned strings have no unexplained hits
104
+
105
+ ## Boundary with fraud-analysis
106
+
107
+ | Need | Skill |
108
+ |---|---|
109
+ | Volume, journey Sankey, auth rate, decline mix, settlement overview, 运营影响 routing | `payment-analysis` |
110
+ | Proxy/confirmed fraud labels, holdout precision/recall, 3DS/block **packages** | `fraud-analysis` |
111
+
112
+ Routing 3DS / 风控拦截 / retry from this extract is not a fraud-analysis rule
113
+ package.
114
+
115
+ ## Reference index
116
+
117
+ | Need | Read |
118
+ |---|---|
119
+ | Grains, joins, windows | [event-layers.md](references/event-layers.md) |
120
+ | USD conversion | [fx.md](references/fx.md) |
121
+ | KPI formulas | [metrics.md](references/metrics.md) |
122
+ | Visa / Mastercard 拒付率 | [chargebacks.md](references/chargebacks.md) |
123
+ | Sankey checkpoints | [journey.md](references/journey.md) |
124
+ | Chart marks | [visualization.md](references/visualization.md) |
125
+ | Report chapters | [report-template.md](references/report-template.md) |
126
+ | 运营影响 | [auth-rate-actions.md](references/auth-rate-actions.md) |
127
+ | Language / banned strings | [terminology.md](references/terminology.md) |
@@ -0,0 +1,30 @@
1
+ # Actions that often lift auth rate
2
+
3
+ Use this list when writing **运营影响**. Pick only items the extract
4
+ supports. Do not dump the whole list. These are routing / retry operations,
5
+ not a `fraud-analysis` rule package (no precision/recall, no “loss saved”).
6
+
7
+ Auth rate = 授权成功 / 授权尝试. BIN country = 发卡行国家.
8
+
9
+ | # | When the data shows | Action | Do not write |
10
+ |---|---|---|---|
11
+ | 1 | BIN countries under SCA (e.g. UK, Spain, Italy) and Authentication method is empty / None | Route **3DS** for those 发卡行国家 | 强客户认证 as the standing term (use SCA); claiming 3DS will raise conversion |
12
+ | 2 | A country (or book) where 疑似欺诈 is a large share of 授权拒绝 | **风控拦截** and/or **3DS** on that 发卡行国家 | Calling 疑似欺诈 “confirmed fraud”; putting this in the 3DS 与风控 exec slot as a decline mix |
13
+ | 3 | Material **软性拒绝** (issuer soft: 余额不足, Do not honor, 超限, …) | **Retry** the authorization (same or later attempt, per acquirer retry rules) | Treating 无效卡 / 账户关闭 as retry-eligible |
14
+ | 4 | 余额不足, 安全码无效, 有效期无效, Do not honor 等可解释的拒绝 | On the **payment page**, show the matching reason (余额不足 / 安全码错误 / 有效期错误), not a generic “支付失败” | Inventing copy the issuer did not return; hiding the reason |
15
+
16
+ ## How to cite in the report
17
+
18
+ One short 运营影响 bullet per action, with the evidence already in the
19
+ report (country, share, 软性拒绝 count). Example shapes:
20
+
21
+ - SCA:英国、西班牙、意大利受 SCA 约束,当前分析时段内无 3DS,建议对这些发卡行国家路由 3DS。
22
+ - 疑似欺诈:某国疑似欺诈占授权拒绝 X%,建议风控拦截或 3DS。
23
+ - 软性拒绝:软性拒绝 N 笔(余额不足 / Do not honor / …),可按收单行规则重试。
24
+ - 支付页提示:余额不足、安全码无效、有效期无效应在支付页给出对应提示,便于用户换卡或改卡号、有效期、安全码。
25
+
26
+ ## Out of scope
27
+
28
+ - Supervised thresholds, holdout, 3DS/block “packages” → `fraud-analysis`
29
+ - Inventing retry counts or expected auth-rate lift
30
+ - Mixing portfolio and merchant grains in one file
@@ -0,0 +1,88 @@
1
+ # Chargeback / dispute rate (Visa vs Mastercard)
2
+
3
+ Topic **4.8 拒付 / 争议**. Put the Visa / Mastercard formulas as a **note
4
+ under the monthly rate chart**. Count rates follow card-network monitoring
5
+ programmes, **not** origination-month vintage and **not** a blended
6
+ Visa+Mastercard ratio.
7
+
8
+ Official Visa and Mastercard rulebooks are acquirer-gated. The formulas
9
+ below are the processor restatements used in production monitoring
10
+ (Stripe, Braintree). Caption the report as **network-style estimates
11
+ from this extract**, not as a Visa/Mastercard identification notice.
12
+
13
+ ## When a point is drawn
14
+
15
+ A monthly point for a card brand is drawn **only if**
16
+
17
+ - numerator (chargebacks **received** that calendar month for that brand) > 0, and
18
+ - denominator (sales count for that brand, month as defined below) > 0.
19
+
20
+ Otherwise **omit the point**. Do not plot `0`. Do not invent a prior-month
21
+ sale count. If a brand has no drawable points, omit the series. If no
22
+ series remain, omit the rate chart (keep the reason-category bars if CBs
23
+ exist).
24
+
25
+ ## Formulas (count)
26
+
27
+ Numerator for both brands: chargebacks **received** in calendar month `M`
28
+ (`Chargeback date`), `Payment method` = that brand. Not original
29
+ transaction month. Inquiries / RDR-cleared cases are not in this extract;
30
+ count every CB row.
31
+
32
+ | Brand | Programme (current) | Rate |
33
+ |---|---|---|
34
+ | Visa | VAMP dispute/sales count (same month) | `CB_Visa(M) / Sales_Visa(M)` |
35
+ | Mastercard | ECP / ECM chargeback rate (lagged sales) | `CB_MC(M) / Sales_MC(M−1)` |
36
+
37
+ `Sales_*` = settlement type Sale, that brand, **transaction/capture month**.
38
+ Do not mix refunds into the denominator.
39
+
40
+ Mastercard **must** use the previous calendar month’s sales. If `M−1`
41
+ sales are missing from the extract, skip Mastercard for month `M`.
42
+
43
+ ## Visa notes (do not over-claim VAMP)
44
+
45
+ Since 2025-04 Visa folded VDMP/VFMP into **VAMP**. Full VAMP Count is
46
+ `opened Visa chargebacks (TC15) + reported fraud (TC40 EFW)`, same-month
47
+ sales in the denominator. This skill’s extract usually has chargebacks
48
+ only → report **Visa 拒付率 = Visa CB count / Visa same-month sales**.
49
+ Do not label it “VAMP ratio” unless TC40/EFW is in the file.
50
+
51
+ VAMP also has volume and enumeration legs; those are out of scope here.
52
+
53
+ ## Mastercard notes
54
+
55
+ ECP (ECM / HECM) uses **both** a count threshold and the lagged rate.
56
+ This report draws the **rate** series only. Do not say the merchant is
57
+ “in ECM” from the extract.
58
+
59
+ EFM is a different (fraud-reason + 3DS mix) programme; do not substitute
60
+ it for ECP.
61
+
62
+ ## Amount rate (optional footnote)
63
+
64
+ `abs(dispute amount) / sale amount` with the **same month alignment as
65
+ the count rate** for that brand. Secondary; the line chart is count %.
66
+
67
+ ## Window caveat
68
+
69
+ A short extract (e.g. 22 days of August plus a handful of July sales)
70
+ cannot produce a Mastercard lagged rate for August unless July Mastercard
71
+ sales exist, and cannot produce Visa July if July CBs are absent. Follow
72
+ the skip rules; do not pad.
73
+
74
+ ## Sources
75
+
76
+ - Stripe, *Dispute and fraud card monitoring programs*: Visa uses
77
+ disputes/fraud vs **same-month** payments; Mastercard uses
78
+ disputes/fraud vs **previous-month** payments; both assign the CB to
79
+ the month it was **received**.
80
+ https://docs.stripe.com/disputes/monitoring-programs
81
+ - Braintree, *Visa Acquirer Monitoring Program (VAMP)*: VAMP ratio =
82
+ VAMP Count / **same-month** Visa sales count
83
+ (example: August count / August sales).
84
+ https://developer.paypal.com/braintree/articles/risk-and-security/card-brand-monitoring-programs/visa-programs/visa-dispute-monitoring-program
85
+ - Chargebacks911 primer on Mastercard ECM rate: chargebacks in the
86
+ **current** month / Mastercard transactions in the **previous** month
87
+ (April 10,000 sales and May 90 CBs → May rate 1%).
88
+ https://chargebacks911.com/mastercard-chargebacks/mastercard-excessive-fraud-chargeback-monitoring-programs/mastercard-ecm-program-how-to-calculate-your-mastercard-chargeback-rate/
@@ -0,0 +1,79 @@
1
+ # Event layers, grains, and joins
2
+
3
+ ## Layers
4
+
5
+ | Layer | Example filename pattern | Default grain | Usual time field |
6
+ |---|---|---|---|
7
+ | Authorizations | `Authorizations_*authorizations.csv` | one auth attempt | `Timestamp` |
8
+ | Settlements | `Sales-and-refunds_*settlements.csv` | one sale or refund | `Timestamp` or `Settlement date` |
9
+ | Chargebacks | `Chargebacks_*chargebacks.csv` | one dispute | `Chargeback date`; origination via `Original transaction timestamp` |
10
+
11
+ A run may use one, two, or all three layers. Name every layer used and every layer
12
+ missing.
13
+
14
+ ## Portfolio constants to record
15
+
16
+ When columns exist and are near-constant, state them once (do not treat as
17
+ drivers):
18
+
19
+ - MID / Gateway MID
20
+ - MCC
21
+ - Provider / acquirer path
22
+ - Transaction source / entry method
23
+ - Billing descriptor / sub merchant
24
+
25
+ ## Keys and joins
26
+
27
+ | Join | Left | Right | Notes |
28
+ |---|---|---|---|
29
+ | Auth ↔ Chargeback | `Order ID` | `Original transaction order ID` | Primary for this Pazien-style extract |
30
+ | Auth ↔ Settlement | `Order ID` | `Order ID` | May be 1:n if capture/refund splits |
31
+ | Weak identity | masked `Account`, `IIN` | same | Collisions possible; fine for contribution tables, not unique-customer claims |
32
+
33
+ Report match rates whenever a join supports a claim (“N of M chargebacks match an
34
+ auth in file”).
35
+
36
+ ## Currency
37
+
38
+ Reporting amounts are USD. Conversion rules: [fx.md](fx.md).
39
+
40
+ 1. Prefer native USD rows; convert every non-USD amount before summing.
41
+ 2. Never add USD + EUR (etc.) into one total without FX and a disclosure.
42
+ 3. Count KPIs never need FX.
43
+
44
+ ## Window selection
45
+
46
+ | User ask | Default |
47
+ |---|---|
48
+ | Full extract | min→max of chosen time field |
49
+ | Most recent week / last 7 days | `(max_ts - 7d, max_ts]` |
50
+ | Calendar week | dates in that Mon–Sun (or local week rule; state it) |
51
+ | Compare recent vs prior | split at the same cut; show both |
52
+
53
+ Chargeback **programme 拒付率** uses received month (`Chargeback date`) per
54
+ [chargebacks.md](chargebacks.md). If you also show origination-month incidence,
55
+ label that separately so it is not mistaken for the Visa/Mastercard rate.
56
+
57
+ ## Decline taxonomy (auth)
58
+
59
+ Map with both code and message when present (example Pazien-style):
60
+
61
+ | Code | Message (typical) | Class |
62
+ |---|---|---|
63
+ | A001 | Approval - generic | approval |
64
+ | D102 | Suspected fraud | hard / fraud-coded |
65
+ | D104 | Insufficient funds | soft / funds |
66
+ | D387 | Policy reasons | hard / policy |
67
+ | D202 | Security code invalid | hard / data |
68
+ | D204 | Invalid Expiration date | hard / data |
69
+ | D210 | Do not honor | soft / issuer |
70
+ | R014 | Invalid transaction | reject |
71
+
72
+ Always recompute from the file; do not assume codes are portable across gateways.
73
+
74
+ ## What not to infer
75
+
76
+ - BIN country ≠ shipping or billing country
77
+ - Approval ≠ settled funds
78
+ - Suspected-fraud decline ≠ confirmed fraud loss
79
+ - Chargeback reason Fraud ≠ first-party vs third-party adjudication
@@ -0,0 +1,59 @@
1
+ # Amount currency → USD (Forex Service)
2
+
3
+ Reporting amounts are **USD**. Count KPIs never need FX.
4
+
5
+ Use the Forex Service (`~/projects/forex`), not a provider SDK, not a
6
+ spreadsheet rate, not realtime quotes for historical windows.
7
+
8
+ ## Which amount
9
+
10
+ | Layer | Amount | Currency |
11
+ |---|---|---|
12
+ | Authorization | `Transaction amount` | `Transaction amount currency` |
13
+ | Settlement | `Settlement amount` (fallback `Transaction amount`) | `Settlement amount currency` |
14
+ | Chargeback | `Dispute amount` | `Dispute amount currency` |
15
+
16
+ Ignore empty `Pre-DCC amount` (often `0` with blank currency). Do not treat BIN
17
+ country as the transaction currency.
18
+
19
+ ## Rules
20
+
21
+ 1. If every used currency field is `USD`, keep native amounts. Write
22
+ `金额均为 USD`. Do **not** call Forex Service and do **not** write
23
+ `未做汇率折算`.
24
+ 2. If any row is not USD, convert **that row** to USD before any amount sum,
25
+ share, ticket size, or dual-axis amount chart.
26
+ 3. Historical / windowed reports use **daily** conversion, not realtime:
27
+
28
+ `POST {FOREX_BASE_URL}/api/v1/conversions/daily`
29
+
30
+ Body:
31
+
32
+ ```json
33
+ {
34
+ "quoteCurrency": "USD",
35
+ "date": "<UTC Rate Date = transaction date in the extract>",
36
+ "items": [{ "currency": "EUR", "amount": "100.00" }]
37
+ }
38
+ ```
39
+
40
+ Prefer one request per Rate Date: either `conversions/daily` for the day's
41
+ distinct currencies, or `POST /api/v1/rates/daily` then multiply locally
42
+ (`converted = native × rate`, decimal strings).
43
+ 4. Fail closed if a non-USD row has no daily rate. Do not drop it silently and
44
+ do not mix native EUR with USD in one total.
45
+ 5. Auth: `forex:read` bearer token, audience `forex-service`. Base URL default
46
+ `https://forex.1above.io`. Contract: `GET /integration/agent.json`.
47
+ 6. Footnote converted reports: Rate Date rule, quote USD, Forex Service daily
48
+ conversion (not realtime). Mark `realtimeFallback` if a current UTC day was
49
+ served as provisional.
50
+
51
+ ## Env
52
+
53
+ | Variable | Role |
54
+ |---|---|
55
+ | `FOREX_BASE_URL` | Default `https://forex.1above.io` |
56
+ | `FOREX_TOKEN` | Bearer with scope `forex:read` |
57
+
58
+ Mint the token from Identity (`client_credentials`, audience `forex-service`,
59
+ scope `forex:read`) as in the Forex Service integration guide.
@@ -0,0 +1,78 @@
1
+ # Payment journey (Sankey)
2
+
3
+ The journey is a **count** Sankey across checkpoints. Prefer ECharts (or
4
+ equivalent). Do not mix count and amount on one Sankey.
5
+
6
+ ## Checkpoint order
7
+
8
+ ```text
9
+ start → risk decision → 3DS → authorization → settlement
10
+ ```
11
+
12
+ ## Canonical state transitions
13
+
14
+ Use these edge names when the underlying fields exist:
15
+
16
+ | From | To |
17
+ |---|---|
18
+ | risk decision | accept |
19
+ | risk review | 3DS init |
20
+ | accept | non-3DS authorization |
21
+ | non-3DS authorization | non-3DS authorization approved |
22
+ | non-3DS authorization | non-3DS authorization declined |
23
+ | 3DS init | 3DS challenge |
24
+ | 3DS init | 3DS frictionless |
25
+ | 3DS init | 3DS reject |
26
+ | 3DS challenge | 3DS authenticated |
27
+ | 3DS challenge | 3DS authentication failed |
28
+ | 3DS authenticated | 3DS authorization |
29
+ | 3DS authorization | 3DS authorization approved |
30
+ | 3DS authorization | 3DS authorization declined |
31
+
32
+ Settlement edges (when settlement layer present), from approved authorization
33
+ nodes only:
34
+
35
+ | From | To |
36
+ |---|---|
37
+ | non-3DS / 3DS authorization approved | settled sale |
38
+ | non-3DS / 3DS authorization approved | approved not settled |
39
+ | settled sale | refund (only if Order ID joins cleanly) |
40
+ | settled sale | chargeback fraud / non-fraud (optional) |
41
+
42
+ ## Skip unavailable checkpoints
43
+
44
+ If a checkpoint has no usable field in the extract, **omit its nodes and edges**.
45
+ Do not invent risk decisions or 3DS outcomes.
46
+
47
+ Examples:
48
+
49
+ - `Authentication method` / 3DS result all null → skip risk decision, risk
50
+ review, and every 3DS node. Collapse to:
51
+
52
+ ```text
53
+ start → authorization → authorization approved / declined → settlement…
54
+ ```
55
+
56
+ - Settlement file absent → stop after authorization approved/declined.
57
+ - Refunds with Order IDs that do not join auth approvals → footnote only; do not
58
+ force a refund edge.
59
+
60
+ Caption must list skipped checkpoints.
61
+
62
+ ## Mapping hints (when fields exist)
63
+
64
+ | Journey node | Typical source |
65
+ |---|---|
66
+ | risk decision / risk review | gateway risk action, review queue, step-up flag |
67
+ | accept | risk allow / no step-up |
68
+ | 3DS init / challenge / frictionless / reject | 3DS status / ECI / transStatus |
69
+ | 3DS authenticated / failed | challenge result |
70
+ | non-3DS / 3DS authorization approved | auth response = approval |
71
+ | non-3DS / 3DS authorization declined | auth response ≠ approval |
72
+ | settled sale | settlement type = Sale joined on Order ID |
73
+
74
+ ## Anti-patterns
75
+
76
+ - Drawing 3DS branches when authentication fields are empty
77
+ - Using amount on the journey Sankey
78
+ - Putting decline-reason fan-out on the journey (keep that in Topics charts)