forgecraft-mcp 1.2.0 → 1.3.2
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.
- package/README.md +525 -525
- package/dist/cli/help.js +44 -44
- package/dist/registry/renderer-skeletons.js +92 -92
- package/dist/shared/gs-score-logger.js +6 -6
- package/dist/tools/add-module.js +123 -123
- package/dist/tools/advice-registry.js +18 -18
- package/dist/tools/check-cascade-report.js +64 -64
- package/dist/tools/configure-mcp.d.ts +3 -0
- package/dist/tools/configure-mcp.d.ts.map +1 -1
- package/dist/tools/configure-mcp.js +10 -0
- package/dist/tools/configure-mcp.js.map +1 -1
- package/dist/tools/forgecraft-dispatch.d.ts.map +1 -1
- package/dist/tools/forgecraft-dispatch.js +3 -0
- package/dist/tools/forgecraft-dispatch.js.map +1 -1
- package/dist/tools/forgecraft-schema-params.d.ts +9 -0
- package/dist/tools/forgecraft-schema-params.d.ts.map +1 -1
- package/dist/tools/forgecraft-schema-params.js +21 -0
- package/dist/tools/forgecraft-schema-params.js.map +1 -1
- package/dist/tools/forgecraft-schema.d.ts +9 -0
- package/dist/tools/forgecraft-schema.d.ts.map +1 -1
- package/dist/tools/refresh-output.js +14 -14
- package/dist/tools/scaffold-spec-stubs.js +115 -115
- package/dist/tools/scaffold-templates.js +62 -62
- package/dist/tools/setup-artifact-writers.d.ts +30 -0
- package/dist/tools/setup-artifact-writers.d.ts.map +1 -1
- package/dist/tools/setup-artifact-writers.js +120 -8
- package/dist/tools/setup-artifact-writers.js.map +1 -1
- package/dist/tools/setup-phase1.d.ts +3 -0
- package/dist/tools/setup-phase1.d.ts.map +1 -1
- package/dist/tools/setup-phase1.js +79 -35
- package/dist/tools/setup-phase1.js.map +1 -1
- package/dist/tools/setup-phase2.d.ts +2 -0
- package/dist/tools/setup-phase2.d.ts.map +1 -1
- package/dist/tools/setup-phase2.js +10 -1
- package/dist/tools/setup-phase2.js.map +1 -1
- package/dist/tools/setup-project.d.ts +18 -0
- package/dist/tools/setup-project.d.ts.map +1 -1
- package/dist/tools/setup-project.js +77 -1
- package/dist/tools/setup-project.js.map +1 -1
- package/dist/tools/spec-parser-tags.d.ts +9 -0
- package/dist/tools/spec-parser-tags.d.ts.map +1 -1
- package/dist/tools/spec-parser-tags.js +92 -0
- package/dist/tools/spec-parser-tags.js.map +1 -1
- package/package.json +89 -86
- package/templates/analytics/instructions.yaml +37 -37
- package/templates/analytics/mcp-servers.yaml +11 -11
- package/templates/analytics/structure.yaml +25 -25
- package/templates/api/instructions.yaml +231 -231
- package/templates/api/mcp-servers.yaml +22 -13
- package/templates/api/nfr.yaml +23 -23
- package/templates/api/review.yaml +103 -103
- package/templates/api/structure.yaml +34 -34
- package/templates/api/verification.yaml +132 -132
- package/templates/cli/instructions.yaml +31 -31
- package/templates/cli/mcp-servers.yaml +11 -11
- package/templates/cli/review.yaml +53 -53
- package/templates/cli/structure.yaml +16 -16
- package/templates/data-lineage/instructions.yaml +28 -28
- package/templates/data-lineage/mcp-servers.yaml +22 -22
- package/templates/data-pipeline/instructions.yaml +84 -84
- package/templates/data-pipeline/mcp-servers.yaml +13 -13
- package/templates/data-pipeline/nfr.yaml +39 -39
- package/templates/data-pipeline/structure.yaml +23 -23
- package/templates/fintech/hooks.yaml +55 -55
- package/templates/fintech/instructions.yaml +112 -112
- package/templates/fintech/mcp-servers.yaml +13 -13
- package/templates/fintech/nfr.yaml +46 -46
- package/templates/fintech/playbook.yaml +210 -210
- package/templates/fintech/verification.yaml +239 -239
- package/templates/game/instructions.yaml +289 -289
- package/templates/game/mcp-servers.yaml +38 -38
- package/templates/game/nfr.yaml +64 -64
- package/templates/game/playbook.yaml +214 -214
- package/templates/game/review.yaml +97 -97
- package/templates/game/structure.yaml +67 -67
- package/templates/game/verification.yaml +174 -174
- package/templates/healthcare/instructions.yaml +42 -42
- package/templates/healthcare/mcp-servers.yaml +13 -13
- package/templates/healthcare/nfr.yaml +47 -47
- package/templates/hipaa/instructions.yaml +41 -41
- package/templates/hipaa/mcp-servers.yaml +13 -13
- package/templates/infra/instructions.yaml +104 -104
- package/templates/infra/mcp-servers.yaml +20 -20
- package/templates/infra/nfr.yaml +46 -46
- package/templates/infra/review.yaml +65 -65
- package/templates/infra/structure.yaml +25 -25
- package/templates/library/instructions.yaml +36 -36
- package/templates/library/mcp-servers.yaml +20 -20
- package/templates/library/review.yaml +56 -56
- package/templates/library/structure.yaml +19 -19
- package/templates/medallion-architecture/instructions.yaml +41 -41
- package/templates/medallion-architecture/mcp-servers.yaml +22 -22
- package/templates/ml/instructions.yaml +85 -85
- package/templates/ml/mcp-servers.yaml +11 -11
- package/templates/ml/nfr.yaml +39 -39
- package/templates/ml/structure.yaml +25 -25
- package/templates/ml/verification.yaml +156 -156
- package/templates/mobile/instructions.yaml +44 -44
- package/templates/mobile/mcp-servers.yaml +11 -11
- package/templates/mobile/nfr.yaml +49 -49
- package/templates/mobile/structure.yaml +27 -27
- package/templates/mobile/verification.yaml +121 -121
- package/templates/observability-xray/instructions.yaml +40 -40
- package/templates/observability-xray/mcp-servers.yaml +15 -15
- package/templates/realtime/instructions.yaml +42 -42
- package/templates/realtime/mcp-servers.yaml +13 -13
- package/templates/soc2/instructions.yaml +41 -41
- package/templates/soc2/mcp-servers.yaml +24 -24
- package/templates/social/instructions.yaml +43 -43
- package/templates/social/mcp-servers.yaml +24 -24
- package/templates/state-machine/instructions.yaml +42 -42
- package/templates/state-machine/mcp-servers.yaml +11 -11
- package/templates/tools-registry.yaml +164 -164
- package/templates/universal/hooks.yaml +531 -531
- package/templates/universal/instructions.yaml +1692 -1692
- package/templates/universal/mcp-servers.yaml +50 -50
- package/templates/universal/nfr.yaml +197 -197
- package/templates/universal/reference.yaml +326 -326
- package/templates/universal/review.yaml +204 -204
- package/templates/universal/skills.yaml +262 -262
- package/templates/universal/structure.yaml +67 -67
- package/templates/universal/verification.yaml +416 -416
- package/templates/web-react/hooks.yaml +44 -44
- package/templates/web-react/instructions.yaml +207 -207
- package/templates/web-react/mcp-servers.yaml +20 -20
- package/templates/web-react/nfr.yaml +27 -27
- package/templates/web-react/review.yaml +94 -94
- package/templates/web-react/structure.yaml +46 -46
- package/templates/web-react/verification.yaml +126 -126
- package/templates/web-static/instructions.yaml +115 -115
- package/templates/web-static/mcp-servers.yaml +20 -20
- package/templates/web3/instructions.yaml +44 -44
- package/templates/web3/mcp-servers.yaml +11 -11
- package/templates/web3/verification.yaml +159 -159
- package/templates/zero-trust/instructions.yaml +41 -41
- package/templates/zero-trust/mcp-servers.yaml +15 -15
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
tag: FINTECH
|
|
2
|
-
section: hooks
|
|
3
|
-
hooks:
|
|
4
|
-
- name: vol-unit-convention
|
|
5
|
-
trigger: pre-commit
|
|
6
|
-
description: "Block double-scaling of volatility fields already stored as percentage-per-period"
|
|
7
|
-
filename: pre-commit-vol-units.sh
|
|
8
|
-
script: |
|
|
9
|
-
#!/bin/bash
|
|
10
|
-
# Volatility unit confusion is the single most common source of false crash triggers
|
|
11
|
-
# and missed recovery conditions in financial simulations.
|
|
12
|
-
#
|
|
13
|
-
# This hook catches the two double-scaling patterns:
|
|
14
|
-
# / sqrt(N) applied to a field already stored as percentage-per-period
|
|
15
|
-
# * 100 applied to a field already stored as percentage-per-period
|
|
16
|
-
#
|
|
17
|
-
# CUSTOMIZE: replace VOL_FIELD_PATTERNS with the actual field names used in
|
|
18
|
-
# this codebase (e.g. vol_pct_per_day, sigma_stored, realised_vol_pct).
|
|
19
|
-
# The generic pattern below catches common naming conventions.
|
|
20
|
-
#
|
|
21
|
-
# Label: customize VOL_FIELD_PATTERNS for this project's field names.
|
|
22
|
-
|
|
23
|
-
STAGED=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(py|ts|tsx|js|jsx|go|rs)$')
|
|
24
|
-
if [ -z "$STAGED" ]; then exit 0; fi
|
|
25
|
-
|
|
26
|
-
# Generic vol field patterns — override with project-specific names
|
|
27
|
-
VOL_FIELD_PATTERNS="vol_pct|sigma_pct|realized_vol|implied_vol|vol_stored|pct_vol|annualized_vol"
|
|
28
|
-
|
|
29
|
-
VIOLATIONS=0
|
|
30
|
-
|
|
31
|
-
for file in $STAGED; do
|
|
32
|
-
# Pattern 1: double sqrt-annualization on a _pct / stored vol field
|
|
33
|
-
if grep -nE "($VOL_FIELD_PATTERNS).*/ ?sqrt\(|sqrt\(.*\).*($VOL_FIELD_PATTERNS)" "$file" 2>/dev/null | grep -v "^[[:space:]]*//" | grep -q .; then
|
|
34
|
-
echo " ❌ $file — possible double sqrt-scaling on a percentage-per-period vol field"
|
|
35
|
-
echo " Vol fields stored as pct-per-period must not be divided by sqrt(N) again."
|
|
36
|
-
grep -nE "($VOL_FIELD_PATTERNS).*/ ?sqrt\(|sqrt\(.*\).*($VOL_FIELD_PATTERNS)" "$file" | grep -v "^[[:space:]]*//"
|
|
37
|
-
VIOLATIONS=$((VIOLATIONS + 1))
|
|
38
|
-
fi
|
|
39
|
-
|
|
40
|
-
# Pattern 2: *100 on a field already stored as percentage
|
|
41
|
-
if grep -nE "($VOL_FIELD_PATTERNS).*\* ?100[^.]|[^.]100 ?\* ?.*($VOL_FIELD_PATTERNS)" "$file" 2>/dev/null | grep -v "^[[:space:]]*//" | grep -q .; then
|
|
42
|
-
echo " ❌ $file — possible *100 rescaling on a percentage-per-period vol field"
|
|
43
|
-
echo " Vol fields stored as pct-per-period must not be multiplied by 100 again."
|
|
44
|
-
grep -nE "($VOL_FIELD_PATTERNS).*\* ?100[^.]|[^.]100 ?\* ?.*($VOL_FIELD_PATTERNS)" "$file" | grep -v "^[[:space:]]*//"
|
|
45
|
-
VIOLATIONS=$((VIOLATIONS + 1))
|
|
46
|
-
fi
|
|
47
|
-
done
|
|
48
|
-
|
|
49
|
-
if [ $VIOLATIONS -gt 0 ]; then
|
|
50
|
-
echo ""
|
|
51
|
-
echo "❌ Vol unit convention violation(s) found."
|
|
52
|
-
echo " Check that the field is stored as a raw ratio (0.03 = 3%), not already as percentage."
|
|
53
|
-
echo " To suppress a false positive: add a comment '# vol-unit: raw-ratio' on the same line."
|
|
54
|
-
exit 1
|
|
55
|
-
fi
|
|
1
|
+
tag: FINTECH
|
|
2
|
+
section: hooks
|
|
3
|
+
hooks:
|
|
4
|
+
- name: vol-unit-convention
|
|
5
|
+
trigger: pre-commit
|
|
6
|
+
description: "Block double-scaling of volatility fields already stored as percentage-per-period"
|
|
7
|
+
filename: pre-commit-vol-units.sh
|
|
8
|
+
script: |
|
|
9
|
+
#!/bin/bash
|
|
10
|
+
# Volatility unit confusion is the single most common source of false crash triggers
|
|
11
|
+
# and missed recovery conditions in financial simulations.
|
|
12
|
+
#
|
|
13
|
+
# This hook catches the two double-scaling patterns:
|
|
14
|
+
# / sqrt(N) applied to a field already stored as percentage-per-period
|
|
15
|
+
# * 100 applied to a field already stored as percentage-per-period
|
|
16
|
+
#
|
|
17
|
+
# CUSTOMIZE: replace VOL_FIELD_PATTERNS with the actual field names used in
|
|
18
|
+
# this codebase (e.g. vol_pct_per_day, sigma_stored, realised_vol_pct).
|
|
19
|
+
# The generic pattern below catches common naming conventions.
|
|
20
|
+
#
|
|
21
|
+
# Label: customize VOL_FIELD_PATTERNS for this project's field names.
|
|
22
|
+
|
|
23
|
+
STAGED=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(py|ts|tsx|js|jsx|go|rs)$')
|
|
24
|
+
if [ -z "$STAGED" ]; then exit 0; fi
|
|
25
|
+
|
|
26
|
+
# Generic vol field patterns — override with project-specific names
|
|
27
|
+
VOL_FIELD_PATTERNS="vol_pct|sigma_pct|realized_vol|implied_vol|vol_stored|pct_vol|annualized_vol"
|
|
28
|
+
|
|
29
|
+
VIOLATIONS=0
|
|
30
|
+
|
|
31
|
+
for file in $STAGED; do
|
|
32
|
+
# Pattern 1: double sqrt-annualization on a _pct / stored vol field
|
|
33
|
+
if grep -nE "($VOL_FIELD_PATTERNS).*/ ?sqrt\(|sqrt\(.*\).*($VOL_FIELD_PATTERNS)" "$file" 2>/dev/null | grep -v "^[[:space:]]*//" | grep -q .; then
|
|
34
|
+
echo " ❌ $file — possible double sqrt-scaling on a percentage-per-period vol field"
|
|
35
|
+
echo " Vol fields stored as pct-per-period must not be divided by sqrt(N) again."
|
|
36
|
+
grep -nE "($VOL_FIELD_PATTERNS).*/ ?sqrt\(|sqrt\(.*\).*($VOL_FIELD_PATTERNS)" "$file" | grep -v "^[[:space:]]*//"
|
|
37
|
+
VIOLATIONS=$((VIOLATIONS + 1))
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
# Pattern 2: *100 on a field already stored as percentage
|
|
41
|
+
if grep -nE "($VOL_FIELD_PATTERNS).*\* ?100[^.]|[^.]100 ?\* ?.*($VOL_FIELD_PATTERNS)" "$file" 2>/dev/null | grep -v "^[[:space:]]*//" | grep -q .; then
|
|
42
|
+
echo " ❌ $file — possible *100 rescaling on a percentage-per-period vol field"
|
|
43
|
+
echo " Vol fields stored as pct-per-period must not be multiplied by 100 again."
|
|
44
|
+
grep -nE "($VOL_FIELD_PATTERNS).*\* ?100[^.]|[^.]100 ?\* ?.*($VOL_FIELD_PATTERNS)" "$file" | grep -v "^[[:space:]]*//"
|
|
45
|
+
VIOLATIONS=$((VIOLATIONS + 1))
|
|
46
|
+
fi
|
|
47
|
+
done
|
|
48
|
+
|
|
49
|
+
if [ $VIOLATIONS -gt 0 ]; then
|
|
50
|
+
echo ""
|
|
51
|
+
echo "❌ Vol unit convention violation(s) found."
|
|
52
|
+
echo " Check that the field is stored as a raw ratio (0.03 = 3%), not already as percentage."
|
|
53
|
+
echo " To suppress a false positive: add a comment '# vol-unit: raw-ratio' on the same line."
|
|
54
|
+
exit 1
|
|
55
|
+
fi
|
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
tag: FINTECH
|
|
2
|
-
section: instructions
|
|
3
|
-
blocks:
|
|
4
|
-
- id: transaction-integrity
|
|
5
|
-
tier: recommended
|
|
6
|
-
title: "Transaction Integrity & Data Precision"
|
|
7
|
-
content: |
|
|
8
|
-
## Transaction Integrity & Financial Data Precision
|
|
9
|
-
|
|
10
|
-
- Never use floating-point types for monetary values. Use fixed-precision decimal types (e.g., `Decimal`, `BigDecimal`, `NUMERIC(19,4)`) or integer minor units (cents/pips) throughout the entire stack.
|
|
11
|
-
- Ensure all financial operations are ACID-compliant. Use database transactions with appropriate isolation levels (at minimum READ COMMITTED; use SERIALIZABLE for balance mutations).
|
|
12
|
-
- Implement double-entry bookkeeping: every transaction creates at least two ledger entries (debit and credit) that sum to zero. Validate this invariant on every write.
|
|
13
|
-
- Make all transaction processing idempotent using client-supplied idempotency keys. Retry-safe APIs prevent duplicate charges or transfers.
|
|
14
|
-
- Record immutable transaction history. Financial records are append-only; corrections are modeled as reversing entries, never as in-place updates or deletes.
|
|
15
|
-
- Perform end-of-day reconciliation between internal ledgers and external payment processor/bank records. Alert immediately on any discrepancy.
|
|
16
|
-
- Store and display all monetary amounts with their ISO 4217 currency code. Never assume a default currency.
|
|
17
|
-
|
|
18
|
-
- id: audit-compliance
|
|
19
|
-
tier: recommended
|
|
20
|
-
title: "Audit Trails & Regulatory Compliance"
|
|
21
|
-
content: |
|
|
22
|
-
## Audit Trails & Regulatory Compliance
|
|
23
|
-
|
|
24
|
-
- Maintain a tamper-evident, append-only audit log for every state change to accounts, transactions, and user permissions. Include actor, timestamp, old value, new value, and IP address.
|
|
25
|
-
- Implement PCI-DSS controls if handling cardholder data: network segmentation, encryption, access logging, vulnerability scanning, and annual compliance assessments.
|
|
26
|
-
- Mask or tokenize sensitive financial identifiers (account numbers, SSNs, card PANs) in logs, error messages, and non-production environments.
|
|
27
|
-
- Enforce KYC/AML checks at onboarding and on an ongoing basis. Integrate with identity verification and sanctions screening providers via well-defined service boundaries.
|
|
28
|
-
- Retain financial records and audit logs for the period required by applicable regulations (typically 5-7 years). Automate archival and ensure archived data remains queryable for audits.
|
|
29
|
-
- Design for regulatory reporting: build data models and pipelines that can produce required reports (SAR, CTR, regulatory filings) with minimal manual intervention.
|
|
30
|
-
|
|
31
|
-
- id: security-resilience
|
|
32
|
-
tier: recommended
|
|
33
|
-
title: "Security & Operational Resilience"
|
|
34
|
-
content: |
|
|
35
|
-
## Security & Operational Resilience
|
|
36
|
-
|
|
37
|
-
- Implement multi-factor authentication for all user-facing financial operations above a configurable threshold (e.g., transfers > $500).
|
|
38
|
-
- Apply velocity checks and fraud detection rules: flag unusual transaction volumes, amounts, geographies, or timing patterns for review before processing.
|
|
39
|
-
- Use cryptographic signing (HMAC or asymmetric signatures) for all webhook payloads, inter-service financial messages, and API requests to prevent tampering.
|
|
40
|
-
- Design for graceful degradation: if an external payment provider is unavailable, queue transactions for retry rather than failing the user experience entirely.
|
|
41
|
-
- Maintain a disaster recovery plan with RPO < 1 hour and RTO < 4 hours for critical financial services. Test failover procedures quarterly.
|
|
42
|
-
- Separate read and write paths for high-throughput systems. Use CQRS to ensure reporting queries never contend with transaction processing.
|
|
43
|
-
|
|
44
|
-
- id: simulation-invariants
|
|
45
|
-
tier: recommended
|
|
46
|
-
title: "Financial Simulation & Backtesting Invariants"
|
|
47
|
-
content: |
|
|
48
|
-
## Financial Simulation & Backtesting Invariants
|
|
49
|
-
|
|
50
|
-
Financial simulations fail in two directions, both silently. Name them explicitly
|
|
51
|
-
so every engineer on the team recognizes the pattern immediately.
|
|
52
|
-
|
|
53
|
-
### Category A — Silent Loss Bugs (strategy runs, earns nothing)
|
|
54
|
-
|
|
55
|
-
These bugs produce flat or zero P&L while the simulation completes without error.
|
|
56
|
-
The strategy appears to have run. It did not.
|
|
57
|
-
|
|
58
|
-
**1. P&L decomposition invariant**
|
|
59
|
-
At finalize: `fee_income + price_income == total_pnl ± 1%`.
|
|
60
|
-
A gap larger than 1% means an accounting component is unlinked — it exists
|
|
61
|
-
in the ledger but never flows into the reported total.
|
|
62
|
-
|
|
63
|
-
**2. Fee-time ratio**
|
|
64
|
-
Fees must be proportional to active simulation time. Near-zero fees after
|
|
65
|
-
1000 hours of "running" means the instrument was never created. The strategy
|
|
66
|
-
ran against nothing. Check: `total_fees / active_hours < threshold` → flag.
|
|
67
|
-
|
|
68
|
-
**3. State concentration**
|
|
69
|
-
If >80% of simulation time is spent in a single non-productive state
|
|
70
|
-
(e.g. `crash_short`, `emergency`, `waiting`), the state machine is stuck.
|
|
71
|
-
A stuck machine is not a conservative strategy — it is a broken one.
|
|
72
|
-
Surface this in finalize as a warning, not a footnote.
|
|
73
|
-
|
|
74
|
-
### Category B — Silent Gain Bugs (inflated returns from accounting errors)
|
|
75
|
-
|
|
76
|
-
These bugs produce plausible-looking positive returns. They are harder to catch
|
|
77
|
-
because the output looks like a win.
|
|
78
|
-
|
|
79
|
-
**4. Return plausibility**
|
|
80
|
-
For a market-neutral strategy: annual return >200% or `total_pnl / fee_income >10×`
|
|
81
|
-
is almost certainly a bug, not alpha. Fee income is ground truth of actual activity.
|
|
82
|
-
A strategy that earns 10× its fees in price income has a broken hedge or look-ahead leak.
|
|
83
|
-
|
|
84
|
-
**5. Delta neutrality**
|
|
85
|
-
Track `avg |net_delta|` while in the primary running state.
|
|
86
|
-
High average delta = the hedge is broken, bootstrapped incorrectly, or bypassed.
|
|
87
|
-
This check surfaces bootstrap order bugs that only appear mid-simulation.
|
|
88
|
-
|
|
89
|
-
**6. Instrument balance**
|
|
90
|
-
Sub-strategies should be sized proportionally per the allocation spec.
|
|
91
|
-
If one instrument is 5× larger than another at finalize, allocation logic failed.
|
|
92
|
-
Check: `max(instrument_notionals) / min(instrument_notionals) > 3× → warn`.
|
|
93
|
-
|
|
94
|
-
### Integration requirements
|
|
95
|
-
|
|
96
|
-
- All 6 checks run in the harness `finalize()` step, printing alongside standard metrics.
|
|
97
|
-
- Failed invariants logged as `[INVARIANT FAIL]` — not swallowed as warnings.
|
|
98
|
-
- Checks are parameterized: thresholds in config, not hardcoded.
|
|
99
|
-
- All 6 checks have unit tests with synthetic data that triggers each failure mode.
|
|
100
|
-
|
|
101
|
-
### Volatility unit convention
|
|
102
|
-
|
|
103
|
-
Unit confusion in vol calculations is the single most common source of both false crash
|
|
104
|
-
triggers and missed recovery conditions in DeFi and market-neutral strategies.
|
|
105
|
-
|
|
106
|
-
- Vol fields stored as `percentage_per_period` must never be re-transformed with
|
|
107
|
-
`/ sqrt(N)` or `* 100` after storage. Storing already-scaled vol and scaling again
|
|
108
|
-
= off by 10×–100× with no runtime error.
|
|
109
|
-
- Label every vol field with its unit in the variable name or type alias:
|
|
110
|
-
`vol_pct_per_day`, `sigma_annual` — never just `vol` or `sigma`.
|
|
111
|
-
- Annualization convention must be a named constant: `TRADING_DAYS_PER_YEAR = 252`
|
|
112
|
-
(or 365, or actual — choose one, name it, use it everywhere).
|
|
1
|
+
tag: FINTECH
|
|
2
|
+
section: instructions
|
|
3
|
+
blocks:
|
|
4
|
+
- id: transaction-integrity
|
|
5
|
+
tier: recommended
|
|
6
|
+
title: "Transaction Integrity & Data Precision"
|
|
7
|
+
content: |
|
|
8
|
+
## Transaction Integrity & Financial Data Precision
|
|
9
|
+
|
|
10
|
+
- Never use floating-point types for monetary values. Use fixed-precision decimal types (e.g., `Decimal`, `BigDecimal`, `NUMERIC(19,4)`) or integer minor units (cents/pips) throughout the entire stack.
|
|
11
|
+
- Ensure all financial operations are ACID-compliant. Use database transactions with appropriate isolation levels (at minimum READ COMMITTED; use SERIALIZABLE for balance mutations).
|
|
12
|
+
- Implement double-entry bookkeeping: every transaction creates at least two ledger entries (debit and credit) that sum to zero. Validate this invariant on every write.
|
|
13
|
+
- Make all transaction processing idempotent using client-supplied idempotency keys. Retry-safe APIs prevent duplicate charges or transfers.
|
|
14
|
+
- Record immutable transaction history. Financial records are append-only; corrections are modeled as reversing entries, never as in-place updates or deletes.
|
|
15
|
+
- Perform end-of-day reconciliation between internal ledgers and external payment processor/bank records. Alert immediately on any discrepancy.
|
|
16
|
+
- Store and display all monetary amounts with their ISO 4217 currency code. Never assume a default currency.
|
|
17
|
+
|
|
18
|
+
- id: audit-compliance
|
|
19
|
+
tier: recommended
|
|
20
|
+
title: "Audit Trails & Regulatory Compliance"
|
|
21
|
+
content: |
|
|
22
|
+
## Audit Trails & Regulatory Compliance
|
|
23
|
+
|
|
24
|
+
- Maintain a tamper-evident, append-only audit log for every state change to accounts, transactions, and user permissions. Include actor, timestamp, old value, new value, and IP address.
|
|
25
|
+
- Implement PCI-DSS controls if handling cardholder data: network segmentation, encryption, access logging, vulnerability scanning, and annual compliance assessments.
|
|
26
|
+
- Mask or tokenize sensitive financial identifiers (account numbers, SSNs, card PANs) in logs, error messages, and non-production environments.
|
|
27
|
+
- Enforce KYC/AML checks at onboarding and on an ongoing basis. Integrate with identity verification and sanctions screening providers via well-defined service boundaries.
|
|
28
|
+
- Retain financial records and audit logs for the period required by applicable regulations (typically 5-7 years). Automate archival and ensure archived data remains queryable for audits.
|
|
29
|
+
- Design for regulatory reporting: build data models and pipelines that can produce required reports (SAR, CTR, regulatory filings) with minimal manual intervention.
|
|
30
|
+
|
|
31
|
+
- id: security-resilience
|
|
32
|
+
tier: recommended
|
|
33
|
+
title: "Security & Operational Resilience"
|
|
34
|
+
content: |
|
|
35
|
+
## Security & Operational Resilience
|
|
36
|
+
|
|
37
|
+
- Implement multi-factor authentication for all user-facing financial operations above a configurable threshold (e.g., transfers > $500).
|
|
38
|
+
- Apply velocity checks and fraud detection rules: flag unusual transaction volumes, amounts, geographies, or timing patterns for review before processing.
|
|
39
|
+
- Use cryptographic signing (HMAC or asymmetric signatures) for all webhook payloads, inter-service financial messages, and API requests to prevent tampering.
|
|
40
|
+
- Design for graceful degradation: if an external payment provider is unavailable, queue transactions for retry rather than failing the user experience entirely.
|
|
41
|
+
- Maintain a disaster recovery plan with RPO < 1 hour and RTO < 4 hours for critical financial services. Test failover procedures quarterly.
|
|
42
|
+
- Separate read and write paths for high-throughput systems. Use CQRS to ensure reporting queries never contend with transaction processing.
|
|
43
|
+
|
|
44
|
+
- id: simulation-invariants
|
|
45
|
+
tier: recommended
|
|
46
|
+
title: "Financial Simulation & Backtesting Invariants"
|
|
47
|
+
content: |
|
|
48
|
+
## Financial Simulation & Backtesting Invariants
|
|
49
|
+
|
|
50
|
+
Financial simulations fail in two directions, both silently. Name them explicitly
|
|
51
|
+
so every engineer on the team recognizes the pattern immediately.
|
|
52
|
+
|
|
53
|
+
### Category A — Silent Loss Bugs (strategy runs, earns nothing)
|
|
54
|
+
|
|
55
|
+
These bugs produce flat or zero P&L while the simulation completes without error.
|
|
56
|
+
The strategy appears to have run. It did not.
|
|
57
|
+
|
|
58
|
+
**1. P&L decomposition invariant**
|
|
59
|
+
At finalize: `fee_income + price_income == total_pnl ± 1%`.
|
|
60
|
+
A gap larger than 1% means an accounting component is unlinked — it exists
|
|
61
|
+
in the ledger but never flows into the reported total.
|
|
62
|
+
|
|
63
|
+
**2. Fee-time ratio**
|
|
64
|
+
Fees must be proportional to active simulation time. Near-zero fees after
|
|
65
|
+
1000 hours of "running" means the instrument was never created. The strategy
|
|
66
|
+
ran against nothing. Check: `total_fees / active_hours < threshold` → flag.
|
|
67
|
+
|
|
68
|
+
**3. State concentration**
|
|
69
|
+
If >80% of simulation time is spent in a single non-productive state
|
|
70
|
+
(e.g. `crash_short`, `emergency`, `waiting`), the state machine is stuck.
|
|
71
|
+
A stuck machine is not a conservative strategy — it is a broken one.
|
|
72
|
+
Surface this in finalize as a warning, not a footnote.
|
|
73
|
+
|
|
74
|
+
### Category B — Silent Gain Bugs (inflated returns from accounting errors)
|
|
75
|
+
|
|
76
|
+
These bugs produce plausible-looking positive returns. They are harder to catch
|
|
77
|
+
because the output looks like a win.
|
|
78
|
+
|
|
79
|
+
**4. Return plausibility**
|
|
80
|
+
For a market-neutral strategy: annual return >200% or `total_pnl / fee_income >10×`
|
|
81
|
+
is almost certainly a bug, not alpha. Fee income is ground truth of actual activity.
|
|
82
|
+
A strategy that earns 10× its fees in price income has a broken hedge or look-ahead leak.
|
|
83
|
+
|
|
84
|
+
**5. Delta neutrality**
|
|
85
|
+
Track `avg |net_delta|` while in the primary running state.
|
|
86
|
+
High average delta = the hedge is broken, bootstrapped incorrectly, or bypassed.
|
|
87
|
+
This check surfaces bootstrap order bugs that only appear mid-simulation.
|
|
88
|
+
|
|
89
|
+
**6. Instrument balance**
|
|
90
|
+
Sub-strategies should be sized proportionally per the allocation spec.
|
|
91
|
+
If one instrument is 5× larger than another at finalize, allocation logic failed.
|
|
92
|
+
Check: `max(instrument_notionals) / min(instrument_notionals) > 3× → warn`.
|
|
93
|
+
|
|
94
|
+
### Integration requirements
|
|
95
|
+
|
|
96
|
+
- All 6 checks run in the harness `finalize()` step, printing alongside standard metrics.
|
|
97
|
+
- Failed invariants logged as `[INVARIANT FAIL]` — not swallowed as warnings.
|
|
98
|
+
- Checks are parameterized: thresholds in config, not hardcoded.
|
|
99
|
+
- All 6 checks have unit tests with synthetic data that triggers each failure mode.
|
|
100
|
+
|
|
101
|
+
### Volatility unit convention
|
|
102
|
+
|
|
103
|
+
Unit confusion in vol calculations is the single most common source of both false crash
|
|
104
|
+
triggers and missed recovery conditions in DeFi and market-neutral strategies.
|
|
105
|
+
|
|
106
|
+
- Vol fields stored as `percentage_per_period` must never be re-transformed with
|
|
107
|
+
`/ sqrt(N)` or `* 100` after storage. Storing already-scaled vol and scaling again
|
|
108
|
+
= off by 10×–100× with no runtime error.
|
|
109
|
+
- Label every vol field with its unit in the variable name or type alias:
|
|
110
|
+
`vol_pct_per_day`, `sigma_annual` — never just `vol` or `sigma`.
|
|
111
|
+
- Annualization convention must be a named constant: `TRADING_DAYS_PER_YEAR = 252`
|
|
112
|
+
(or 365, or actual — choose one, name it, use it everywhere).
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
tag: FINTECH
|
|
2
|
-
section: mcp-servers
|
|
3
|
-
servers:
|
|
4
|
-
- name: stripe
|
|
5
|
-
description: "Stripe API integration — payments, subscriptions, invoices, and customer management"
|
|
6
|
-
command: npx
|
|
7
|
-
args: ["-y", "@stripe/mcp-server"]
|
|
8
|
-
tags: [FINTECH]
|
|
9
|
-
category: general
|
|
10
|
-
tier: recommended
|
|
11
|
-
env:
|
|
12
|
-
STRIPE_SECRET_KEY: ""
|
|
13
|
-
url: "https://github.com/stripe/agent-toolkit"
|
|
1
|
+
tag: FINTECH
|
|
2
|
+
section: mcp-servers
|
|
3
|
+
servers:
|
|
4
|
+
- name: stripe
|
|
5
|
+
description: "Stripe API integration — payments, subscriptions, invoices, and customer management"
|
|
6
|
+
command: npx
|
|
7
|
+
args: ["-y", "@stripe/mcp-server"]
|
|
8
|
+
tags: [FINTECH]
|
|
9
|
+
category: general
|
|
10
|
+
tier: recommended
|
|
11
|
+
env:
|
|
12
|
+
STRIPE_SECRET_KEY: ""
|
|
13
|
+
url: "https://github.com/stripe/agent-toolkit"
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
tag: FINTECH
|
|
2
|
-
section: nfr
|
|
3
|
-
blocks:
|
|
4
|
-
- id: fintech-transaction-integrity
|
|
5
|
-
tier: recommended
|
|
6
|
-
title: "Transaction Integrity"
|
|
7
|
-
content: |
|
|
8
|
-
## NFR: Transaction Integrity
|
|
9
|
-
|
|
10
|
-
### ACID Compliance
|
|
11
|
-
- All financial operations wrapped in database transactions.
|
|
12
|
-
- Double-entry bookkeeping: every debit has a corresponding credit. Ledger always balances.
|
|
13
|
-
- Idempotency keys on all payment operations — retries must not duplicate charges.
|
|
14
|
-
|
|
15
|
-
### Precision
|
|
16
|
-
- NO floating-point arithmetic for monetary values. Use integer cents, BigDecimal, or Decimal types.
|
|
17
|
-
- Currency stored alongside amount. No implicit currency assumptions.
|
|
18
|
-
- Rounding rules documented and consistent with regulatory requirements.
|
|
19
|
-
|
|
20
|
-
### Reconciliation
|
|
21
|
-
- Automated reconciliation between internal ledger and external payment providers.
|
|
22
|
-
- Reconciliation frequency: {{reconciliation_frequency | default: daily}}.
|
|
23
|
-
- Discrepancies alerted within 1 hour. Unresolved discrepancies escalated.
|
|
24
|
-
|
|
25
|
-
- id: fintech-compliance
|
|
26
|
-
tier: recommended
|
|
27
|
-
title: "Financial Compliance"
|
|
28
|
-
content: |
|
|
29
|
-
## NFR: Financial Compliance
|
|
30
|
-
|
|
31
|
-
### Regulatory
|
|
32
|
-
- PCI DSS compliance for card data handling. No raw card numbers stored — tokenize.
|
|
33
|
-
- KYC/AML processes integrated where required. Document which regulations apply.
|
|
34
|
-
- SOC 2 Type II audit trail: all access to financial data logged and retained.
|
|
35
|
-
|
|
36
|
-
### Audit Trail
|
|
37
|
-
- Immutable audit log for every financial transaction.
|
|
38
|
-
- Log contains: timestamp, actor, operation, before/after state, correlation ID.
|
|
39
|
-
- Retention: minimum {{audit_retention | default: 7 years}} per regulatory requirements.
|
|
40
|
-
- Audit logs stored separately, tamper-evident (append-only, hashed).
|
|
41
|
-
|
|
42
|
-
### Disaster Recovery
|
|
43
|
-
- RPO for financial data: < {{fintech_rpo | default: 5 minutes}}.
|
|
44
|
-
- RTO: < {{fintech_rto | default: 1 hour}}.
|
|
45
|
-
- Point-in-time recovery to any second within retention window.
|
|
46
|
-
- DR drill: quarterly, documented, measured.
|
|
1
|
+
tag: FINTECH
|
|
2
|
+
section: nfr
|
|
3
|
+
blocks:
|
|
4
|
+
- id: fintech-transaction-integrity
|
|
5
|
+
tier: recommended
|
|
6
|
+
title: "Transaction Integrity"
|
|
7
|
+
content: |
|
|
8
|
+
## NFR: Transaction Integrity
|
|
9
|
+
|
|
10
|
+
### ACID Compliance
|
|
11
|
+
- All financial operations wrapped in database transactions.
|
|
12
|
+
- Double-entry bookkeeping: every debit has a corresponding credit. Ledger always balances.
|
|
13
|
+
- Idempotency keys on all payment operations — retries must not duplicate charges.
|
|
14
|
+
|
|
15
|
+
### Precision
|
|
16
|
+
- NO floating-point arithmetic for monetary values. Use integer cents, BigDecimal, or Decimal types.
|
|
17
|
+
- Currency stored alongside amount. No implicit currency assumptions.
|
|
18
|
+
- Rounding rules documented and consistent with regulatory requirements.
|
|
19
|
+
|
|
20
|
+
### Reconciliation
|
|
21
|
+
- Automated reconciliation between internal ledger and external payment providers.
|
|
22
|
+
- Reconciliation frequency: {{reconciliation_frequency | default: daily}}.
|
|
23
|
+
- Discrepancies alerted within 1 hour. Unresolved discrepancies escalated.
|
|
24
|
+
|
|
25
|
+
- id: fintech-compliance
|
|
26
|
+
tier: recommended
|
|
27
|
+
title: "Financial Compliance"
|
|
28
|
+
content: |
|
|
29
|
+
## NFR: Financial Compliance
|
|
30
|
+
|
|
31
|
+
### Regulatory
|
|
32
|
+
- PCI DSS compliance for card data handling. No raw card numbers stored — tokenize.
|
|
33
|
+
- KYC/AML processes integrated where required. Document which regulations apply.
|
|
34
|
+
- SOC 2 Type II audit trail: all access to financial data logged and retained.
|
|
35
|
+
|
|
36
|
+
### Audit Trail
|
|
37
|
+
- Immutable audit log for every financial transaction.
|
|
38
|
+
- Log contains: timestamp, actor, operation, before/after state, correlation ID.
|
|
39
|
+
- Retention: minimum {{audit_retention | default: 7 years}} per regulatory requirements.
|
|
40
|
+
- Audit logs stored separately, tamper-evident (append-only, hashed).
|
|
41
|
+
|
|
42
|
+
### Disaster Recovery
|
|
43
|
+
- RPO for financial data: < {{fintech_rpo | default: 5 minutes}}.
|
|
44
|
+
- RTO: < {{fintech_rto | default: 1 hour}}.
|
|
45
|
+
- Point-in-time recovery to any second within retention window.
|
|
46
|
+
- DR drill: quarterly, documented, measured.
|