@teevee98/synapse-hub 4.3.1 → 4.4.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.
- package/.agents/agents/api-engineer.md +8 -0
- package/.agents/agents/perf-engineer.md +10 -2
- package/.agents/rules/performance_testing_rules.md +4 -3
- package/.agents/skills/01-web-automation/clean-pom-crafter/SKILL.md +6 -3
- package/.agents/skills/01-web-automation/e2e-testing-patterns/SKILL.md +3 -1
- package/.agents/skills/02-test-design/rbt-manual-testing/SKILL.md +11 -5
- package/.agents/skills/04-performance-and-load/backend-load-and-stress-patterns/SKILL.md +4 -1
- package/.agents/skills/04-performance-and-load/backend-load-and-stress-patterns/references/performance_test_plan_29119.md +106 -0
- package/.agents/skills/04-performance-and-load/web-vitals-and-performance-profiler/SKILL.md +75 -14
- package/.agents/skills/05-security-and-compliance/security-dast-sentinel/SKILL.md +13 -2
- package/.agents/skills/05-security-and-compliance/wcag-audit-patterns/SKILL.md +4 -1
- package/.agents/skills/07-data-and-state/file-and-report-validator/SKILL.md +8 -1
- package/.agents/skills/07-data-and-state/synthetic-test-data-generator/SKILL.md +4 -1
- package/.agents/skills/11-ai-and-prompting/mipro-prompt-compiler/SKILL.md +8 -0
- package/.agents/templates/performance-test-plan-template.md +106 -0
- package/README.en.md +2 -2
- package/README.md +2 -2
- package/agentskills.json +1 -1
- package/docs/ARCHITECTURE.en.md +95 -2
- package/docs/ARCHITECTURE.md +86 -2
- package/docs/TOOL_CATALOG.md +11 -2
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/skills_manifest.json +1 -1
- package/synapse.config.json +1 -1
- package/tools/.infer_baseline.json +44 -3
- package/tools/TOOLS_RUNBOOK.md +237 -0
- package/tools/TOOL_CATALOG.json +138 -3
- package/tools/__init__.py +1 -1
- package/tools/ai_eval_sentinel.py +403 -0
- package/tools/asvs_auditor.py +410 -0
- package/tools/browser_helpers.js +2 -2
- package/tools/chaos_resilience_probe.py +362 -0
- package/tools/cldr_l10n_verifier.py +309 -0
- package/tools/cli.py +187 -3
- package/tools/cvss_calculator.py +412 -0
- package/tools/dashboard_generator.py +8 -8
- package/tools/etl_data_reconciler.py +460 -0
- package/tools/generate_jmx_plan.py +12 -4
- package/tools/jtl_analyzer.py +23 -1
- package/tools/mcp_docx_server.py +1 -1
- package/tools/mcp_excel_server.py +1 -1
- package/tools/mcp_server.py +1 -1
- package/tools/mobile_resilience_sentinel.py +273 -0
- package/tools/observability_tester.py +235 -0
- package/tools/payment_interop_simulator.py +337 -0
- package/tools/pre_push_guard.py +306 -0
- package/tools/regulatory_compliance.py +336 -0
- package/tools/rules_router.py +1 -1
- package/tools/tmmi_auditor.py +172 -0
- package/tools/ui_server.py +1 -1
- package/tools/update_sentinel.py +3 -3
- package/tools/vpat_exporter.py +428 -0
- package/tools/welcome_page.py +1 -1
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 Thế Vị (@TeeVee98). All rights reserved.
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
# Project: Synapse-Hub (https://github.com/TeeVee98/Synapse-Hub)
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
tools/regulatory_compliance.py — Enterprise Regulatory & Compliance Audit Sentinel
|
|
8
|
+
-----------------------------------------------------------------------------------
|
|
9
|
+
Implements verification rules for international regulatory and industry standards:
|
|
10
|
+
1. GDPR / PDPA: Right to be Forgotten (Article 17), Consent Logging (Article 7),
|
|
11
|
+
and Data Portability (Article 20).
|
|
12
|
+
2. PCI-DSS v4.0: Requirement 3.4 (PAN Masking with Luhn validation), Requirement 3.2
|
|
13
|
+
(Sensitive Authentication Data / CVV exclusion), and Log Sanitization.
|
|
14
|
+
3. ISO 15489: Electronic Records Management (Retention Policies & Immutable Audit Trails).
|
|
15
|
+
|
|
16
|
+
Usage:
|
|
17
|
+
python tools/regulatory_compliance.py --scan-pci-file logs/access.log
|
|
18
|
+
python tools/regulatory_compliance.py --audit-gdpr-deletion user_export.json
|
|
19
|
+
python tools/regulatory_compliance.py --scan-text "Customer paid with 4111 1111 1111 1111, CVV: 123"
|
|
20
|
+
python tools/regulatory_compliance.py --audit-pci sample_data.json --gate
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
import os
|
|
24
|
+
import sys
|
|
25
|
+
import json
|
|
26
|
+
import re
|
|
27
|
+
import argparse
|
|
28
|
+
from datetime import datetime, timezone
|
|
29
|
+
from typing import Dict, List, Any, Optional
|
|
30
|
+
|
|
31
|
+
# Enforce UTF-8 stdout encoding for Windows console compatibility
|
|
32
|
+
if hasattr(sys.stdout, "reconfigure"):
|
|
33
|
+
try:
|
|
34
|
+
sys.stdout.reconfigure(encoding="utf-8")
|
|
35
|
+
sys.stderr.reconfigure(encoding="utf-8")
|
|
36
|
+
except Exception:
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# ==============================================================================
|
|
41
|
+
# PCI-DSS v4.0 IMPLEMENTATION (LUHN ALGORITHM & PAN MASKING)
|
|
42
|
+
# ==============================================================================
|
|
43
|
+
|
|
44
|
+
CARD_PATTERNS = [
|
|
45
|
+
# Visa: starts with 4, length 13, 16, or 19
|
|
46
|
+
re.compile(r"\b4[0-9]{12}(?:[0-9]{3})?(?:[0-9]{3})?\b"),
|
|
47
|
+
# Mastercard: starts with 51-55 or 2221-2720, length 16
|
|
48
|
+
re.compile(r"\b(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}\b"),
|
|
49
|
+
# American Express: starts with 34 or 37, length 15
|
|
50
|
+
re.compile(r"\b3[47][0-9]{13}\b"),
|
|
51
|
+
# Discover: starts with 6011, 622126-622925, 644-649, 65, length 16
|
|
52
|
+
re.compile(r"\b6(?:011|5[0-9]{2}|4[4-9][0-9]|22(?:12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[01][0-9]|92[0-5]))[0-9]{10,12}\b"),
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
# Patterns for spaced or dashed card numbers (e.g. 4111-1111-1111-1111 or 4111 1111 1111 1111)
|
|
56
|
+
CARD_SEPARATED_PATTERN = re.compile(r"\b(?:\d{4}[ -]){3}\d{4}\b|\b\d{4}[ -]\d{6}[ -]\d{5}\b")
|
|
57
|
+
|
|
58
|
+
# CVV / CVC sensitive authentication data pattern
|
|
59
|
+
CVV_PATTERN = re.compile(r"\b(?:cvv|cvc|cid|cvv2|cvc2)[\s:=]+([0-9]{3,4})\b", re.IGNORECASE)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def luhn_checksum_valid(card_number_str: str) -> bool:
|
|
63
|
+
"""Validates credit card number digits using ISO/IEC 7812 Luhn formula."""
|
|
64
|
+
digits = [int(c) for c in re.sub(r"\D", "", card_number_str)]
|
|
65
|
+
if len(digits) < 13 or len(digits) > 19:
|
|
66
|
+
return False
|
|
67
|
+
checksum = 0
|
|
68
|
+
parity = len(digits) % 2
|
|
69
|
+
for i, digit in enumerate(digits):
|
|
70
|
+
if i % 2 == parity:
|
|
71
|
+
digit *= 2
|
|
72
|
+
if digit > 9:
|
|
73
|
+
digit -= 9
|
|
74
|
+
checksum += digit
|
|
75
|
+
return (checksum % 10) == 0
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def mask_pan(pan_str: str) -> str:
|
|
79
|
+
"""Masks a card number according to PCI-DSS: First 6 and last 4 digits visible."""
|
|
80
|
+
digits_only = re.sub(r"\D", "", pan_str)
|
|
81
|
+
if len(digits_only) < 13:
|
|
82
|
+
return "****"
|
|
83
|
+
first6 = digits_only[:6]
|
|
84
|
+
last4 = digits_only[-4:]
|
|
85
|
+
masked_middle = "*" * (len(digits_only) - 10)
|
|
86
|
+
return f"{first6}{masked_middle}{last4}"
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def scan_text_for_pci_violations(text: str) -> List[Dict[str, Any]]:
|
|
90
|
+
"""Scans text for unmasked PANs and forbidden CVV data."""
|
|
91
|
+
violations = []
|
|
92
|
+
|
|
93
|
+
# 1. Check for raw contiguous card numbers
|
|
94
|
+
for pat in CARD_PATTERNS:
|
|
95
|
+
for match in pat.finditer(text):
|
|
96
|
+
candidate = match.group(0)
|
|
97
|
+
if luhn_checksum_valid(candidate):
|
|
98
|
+
violations.append({
|
|
99
|
+
"standard": "PCI-DSS v4.0 Req 3.4",
|
|
100
|
+
"severity": "CRITICAL",
|
|
101
|
+
"type": "UNMASKED_PAN_LEAK",
|
|
102
|
+
"found": candidate,
|
|
103
|
+
"masked_suggestion": mask_pan(candidate),
|
|
104
|
+
"message": "Raw, unmasked Primary Account Number (PAN) detected with valid Luhn checksum.",
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
# 2. Check for separated card numbers (dashes or spaces)
|
|
108
|
+
for match in CARD_SEPARATED_PATTERN.finditer(text):
|
|
109
|
+
candidate = match.group(0)
|
|
110
|
+
digits = re.sub(r"\D", "", candidate)
|
|
111
|
+
if luhn_checksum_valid(digits):
|
|
112
|
+
# Avoid duplicate if already matched by contiguous
|
|
113
|
+
if not any(v.get("found") == candidate or v.get("found") == digits for v in violations):
|
|
114
|
+
violations.append({
|
|
115
|
+
"standard": "PCI-DSS v4.0 Req 3.4",
|
|
116
|
+
"severity": "CRITICAL",
|
|
117
|
+
"type": "UNMASKED_PAN_LEAK",
|
|
118
|
+
"found": candidate,
|
|
119
|
+
"masked_suggestion": mask_pan(digits),
|
|
120
|
+
"message": "Delimited unmasked PAN detected with valid Luhn checksum.",
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
# 3. Check for CVV / Sensitive Authentication Data storage
|
|
124
|
+
for match in CVV_PATTERN.finditer(text):
|
|
125
|
+
violations.append({
|
|
126
|
+
"standard": "PCI-DSS v4.0 Req 3.2",
|
|
127
|
+
"severity": "CRITICAL",
|
|
128
|
+
"type": "SENSITIVE_AUTH_DATA_STORAGE",
|
|
129
|
+
"found": match.group(0),
|
|
130
|
+
"message": "Sensitive Authentication Data (CVV/CVC) detected. Storing CVV post-authorization is strictly prohibited.",
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
return violations
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
# ==============================================================================
|
|
137
|
+
# GDPR & PDPA COMPLIANCE (RIGHT TO BE FORGOTTEN & CONSENT)
|
|
138
|
+
# ==============================================================================
|
|
139
|
+
|
|
140
|
+
def audit_right_to_be_forgotten(
|
|
141
|
+
target_user_id: str,
|
|
142
|
+
db_tables_snapshot: Dict[str, List[Dict[str, Any]]],
|
|
143
|
+
pii_keywords: List[str] = None,
|
|
144
|
+
) -> Dict[str, Any]:
|
|
145
|
+
"""
|
|
146
|
+
Verifies Article 17 GDPR (Right to Erasure).
|
|
147
|
+
Ensures user records and associated PII are completely purged or anonymized.
|
|
148
|
+
"""
|
|
149
|
+
pii_keywords = pii_keywords or ["email", "phone", "full_name", "address", "ssn", "cccd", "ip_address"]
|
|
150
|
+
lingering_records = []
|
|
151
|
+
|
|
152
|
+
for table_name, rows in db_tables_snapshot.items():
|
|
153
|
+
for idx, row in enumerate(rows):
|
|
154
|
+
# Check direct user_id match
|
|
155
|
+
is_matched_user = False
|
|
156
|
+
for col_val in row.values():
|
|
157
|
+
if str(col_val).strip() == str(target_user_id).strip():
|
|
158
|
+
is_matched_user = True
|
|
159
|
+
break
|
|
160
|
+
|
|
161
|
+
if is_matched_user:
|
|
162
|
+
# Check if fields still contain non-empty PII
|
|
163
|
+
for k, v in row.items():
|
|
164
|
+
k_lower = k.lower()
|
|
165
|
+
if any(kw in k_lower for kw in pii_keywords) and v:
|
|
166
|
+
lingering_records.append({
|
|
167
|
+
"table": table_name,
|
|
168
|
+
"row_index": idx,
|
|
169
|
+
"field": k,
|
|
170
|
+
"residual_value": str(v),
|
|
171
|
+
"issue": "PII field retained after account erasure request.",
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
compliant = len(lingering_records) == 0
|
|
175
|
+
return {
|
|
176
|
+
"standard": "GDPR Article 17 / PDPA",
|
|
177
|
+
"user_id": target_user_id,
|
|
178
|
+
"is_compliant": compliant,
|
|
179
|
+
"lingering_pii_count": len(lingering_records),
|
|
180
|
+
"violations": lingering_records,
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def verify_consent_audit_log(consent_record: Dict[str, Any]) -> Dict[str, Any]:
|
|
185
|
+
"""
|
|
186
|
+
Verifies Article 7 GDPR (Conditions for Consent).
|
|
187
|
+
Requires explicit opt-in, timestamp, purpose specification, and IP masking.
|
|
188
|
+
"""
|
|
189
|
+
missing_fields = []
|
|
190
|
+
required_keys = ["user_id", "timestamp", "consent_version", "purposes", "opt_in_state"]
|
|
191
|
+
for r in required_keys:
|
|
192
|
+
if r not in consent_record:
|
|
193
|
+
missing_fields.append(r)
|
|
194
|
+
|
|
195
|
+
is_opt_in = consent_record.get("opt_in_state") is True
|
|
196
|
+
ip_raw = str(consent_record.get("ip_address", ""))
|
|
197
|
+
ip_masked = bool(re.search(r"(\.0$|\.xxx$|::ffff:0$|\*\*\*)", ip_raw)) if ip_raw else True
|
|
198
|
+
|
|
199
|
+
compliant = (len(missing_fields) == 0) and is_opt_in and ip_masked
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
"standard": "GDPR Article 7",
|
|
203
|
+
"is_compliant": compliant,
|
|
204
|
+
"missing_fields": missing_fields,
|
|
205
|
+
"explicit_opt_in": is_opt_in,
|
|
206
|
+
"ip_anonymized": ip_masked,
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
# ==============================================================================
|
|
211
|
+
# ISO 15489 (ELECTRONIC RECORDS MANAGEMENT)
|
|
212
|
+
# ==============================================================================
|
|
213
|
+
|
|
214
|
+
def verify_record_retention_policy(
|
|
215
|
+
created_at_iso: str,
|
|
216
|
+
retention_period_years: int,
|
|
217
|
+
action_attempted: str,
|
|
218
|
+
action_timestamp_iso: Optional[str] = None,
|
|
219
|
+
) -> Dict[str, Any]:
|
|
220
|
+
"""
|
|
221
|
+
Verifies ISO 15489-1 Section 8 (Retention and Disposition).
|
|
222
|
+
Premature permanent deletion of regulated records is a compliance failure.
|
|
223
|
+
"""
|
|
224
|
+
try:
|
|
225
|
+
dt_created = datetime.fromisoformat(created_at_iso.replace("Z", "+00:00"))
|
|
226
|
+
dt_action = (
|
|
227
|
+
datetime.fromisoformat(action_timestamp_iso.replace("Z", "+00:00"))
|
|
228
|
+
if action_timestamp_iso
|
|
229
|
+
else datetime.now(timezone.utc)
|
|
230
|
+
)
|
|
231
|
+
except Exception as e:
|
|
232
|
+
return {"is_compliant": False, "error": f"Invalid ISO date: {e}"}
|
|
233
|
+
|
|
234
|
+
age_days = (dt_action - dt_created).days
|
|
235
|
+
required_days = retention_period_years * 365
|
|
236
|
+
|
|
237
|
+
if action_attempted.upper() in ("PURGE", "DELETE", "DROP", "DESTROY") and age_days < required_days:
|
|
238
|
+
return {
|
|
239
|
+
"standard": "ISO 15489 Section 8",
|
|
240
|
+
"is_compliant": False,
|
|
241
|
+
"action": action_attempted,
|
|
242
|
+
"retention_required_days": required_days,
|
|
243
|
+
"record_age_days": age_days,
|
|
244
|
+
"message": f"Illegal disposition: Record age ({age_days} days) is less than statutory retention period ({required_days} days).",
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return {
|
|
248
|
+
"standard": "ISO 15489 Section 8",
|
|
249
|
+
"is_compliant": True,
|
|
250
|
+
"action": action_attempted,
|
|
251
|
+
"message": "Action conforms to record retention schedule.",
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
# ==============================================================================
|
|
256
|
+
# CLI HANDLER & BATCH SCANNER
|
|
257
|
+
# ==============================================================================
|
|
258
|
+
|
|
259
|
+
def main():
|
|
260
|
+
parser = argparse.ArgumentParser(
|
|
261
|
+
description="Synapse Hub Regulatory & Compliance Audit Sentinel (GDPR, PCI-DSS, ISO 15489)",
|
|
262
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
263
|
+
)
|
|
264
|
+
parser.add_argument("--scan-text", help="Direct text string to scan for PCI-DSS unmasked PANs/CVV")
|
|
265
|
+
parser.add_argument("--scan-file", help="Path to text or JSON file to scan for compliance violations")
|
|
266
|
+
parser.add_argument("--audit-gdpr", help="Path to JSON file containing user deletion snapshot")
|
|
267
|
+
parser.add_argument("--user-id", default="USER_123", help="Target user ID for GDPR Right to be Forgotten audit")
|
|
268
|
+
parser.add_argument("--json", action="store_true", help="Output results in JSON format")
|
|
269
|
+
parser.add_argument("--gate", action="store_true", help="Exit code 1 if any CRITICAL regulatory violation is found")
|
|
270
|
+
|
|
271
|
+
args = parser.parse_args()
|
|
272
|
+
|
|
273
|
+
results = {"audit_timestamp": datetime.now(timezone.utc).isoformat(), "violations": []}
|
|
274
|
+
has_critical = False
|
|
275
|
+
|
|
276
|
+
if args.scan_text:
|
|
277
|
+
viols = scan_text_for_pci_violations(args.scan_text)
|
|
278
|
+
results["violations"].extend(viols)
|
|
279
|
+
if any(v.get("severity") == "CRITICAL" for v in viols):
|
|
280
|
+
has_critical = True
|
|
281
|
+
|
|
282
|
+
elif args.scan_file:
|
|
283
|
+
if not os.path.exists(args.scan_file):
|
|
284
|
+
print(f"❌ Error: File not found: {args.scan_file}", file=sys.stderr)
|
|
285
|
+
return 2
|
|
286
|
+
with open(args.scan_file, "r", encoding="utf-8", errors="ignore") as f:
|
|
287
|
+
content = f.read()
|
|
288
|
+
viols = scan_text_for_pci_violations(content)
|
|
289
|
+
results["violations"].extend(viols)
|
|
290
|
+
if any(v.get("severity") == "CRITICAL" for v in viols):
|
|
291
|
+
has_critical = True
|
|
292
|
+
|
|
293
|
+
elif args.audit_gdpr:
|
|
294
|
+
if not os.path.exists(args.audit_gdpr):
|
|
295
|
+
print(f"❌ Error: File not found: {args.audit_gdpr}", file=sys.stderr)
|
|
296
|
+
return 2
|
|
297
|
+
with open(args.audit_gdpr, "r", encoding="utf-8") as f:
|
|
298
|
+
data = json.load(f)
|
|
299
|
+
gdpr_res = audit_right_to_be_forgotten(args.user_id, data)
|
|
300
|
+
results["gdpr_audit"] = gdpr_res
|
|
301
|
+
if not gdpr_res["is_compliant"]:
|
|
302
|
+
has_critical = True
|
|
303
|
+
else:
|
|
304
|
+
parser.print_help()
|
|
305
|
+
return 2
|
|
306
|
+
|
|
307
|
+
results["total_violations"] = len(results["violations"])
|
|
308
|
+
|
|
309
|
+
if args.json:
|
|
310
|
+
print(json.dumps(results, indent=2, ensure_ascii=False))
|
|
311
|
+
else:
|
|
312
|
+
print("=" * 72)
|
|
313
|
+
print(" SYNAPSE HUB — REGULATORY & COMPLIANCE AUDIT SCORECARD")
|
|
314
|
+
print("=" * 72)
|
|
315
|
+
if "gdpr_audit" in results:
|
|
316
|
+
g = results["gdpr_audit"]
|
|
317
|
+
st = "\033[92m[COMPLIANT]\033[0m" if g["is_compliant"] else "\033[91m[NON-COMPLIANT]\033[0m"
|
|
318
|
+
print(f" GDPR Art. 17 Status: {st}")
|
|
319
|
+
print(f" Residual PII Records: {g['lingering_pii_count']}")
|
|
320
|
+
else:
|
|
321
|
+
print(f" PCI-DSS v4.0 Scan Findings: {len(results['violations'])}")
|
|
322
|
+
for v in results["violations"]:
|
|
323
|
+
print(f" \033[91m[{v['severity']}]\033[0m {v['standard']} | {v['type']} -> {v['message']}")
|
|
324
|
+
if "masked_suggestion" in v:
|
|
325
|
+
print(f" Masked suggestion: {v['masked_suggestion']}")
|
|
326
|
+
print("=" * 72)
|
|
327
|
+
|
|
328
|
+
if args.gate and has_critical:
|
|
329
|
+
print("🚨 Quality Gate Failed: Regulatory compliance violations detected!", file=sys.stderr)
|
|
330
|
+
return 1
|
|
331
|
+
|
|
332
|
+
return 0
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
if __name__ == "__main__":
|
|
336
|
+
sys.exit(main())
|
package/tools/rules_router.py
CHANGED
|
@@ -211,7 +211,7 @@ TASK_TYPE_CONFIGS: Dict[str, Dict[str, Any]] = {
|
|
|
211
211
|
"rules": ["performance_testing_rules.md"],
|
|
212
212
|
"primary_skills": ["backend-load-and-stress-patterns", "web-vitals-and-performance-profiler"],
|
|
213
213
|
"secondary_skills": ["lean-impact-scoreboard"],
|
|
214
|
-
"default_token_cap":
|
|
214
|
+
"default_token_cap": 7000,
|
|
215
215
|
},
|
|
216
216
|
"security": {
|
|
217
217
|
"rules": ["security_testing_rules.md"],
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 Thế Vị (@TeeVee98). All rights reserved.
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
# Project: Synapse-Hub (https://github.com/TeeVee98/Synapse-Hub)
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
tools/tmmi_auditor.py — Enterprise TMMi (Test Maturity Model integration) Assessment Sentinel
|
|
8
|
+
--------------------------------------------------------------------------------------------
|
|
9
|
+
Evaluates test process maturity and engineering rigor across TMMi Levels 1 through 5:
|
|
10
|
+
- Level 1: Initial (Ad-hoc, unmanaged)
|
|
11
|
+
- Level 2: Managed (Test Policy, Planning, Design, Environment & Data)
|
|
12
|
+
- Level 3: Defined (Standard Organization, Non-Functional Testing, Peer Review, POM)
|
|
13
|
+
- Level 4: Measured (Mutation Testing >= 80%, Flaky Analysis, Metric Baselines)
|
|
14
|
+
- Level 5: Optimization (Defect Prevention, Auto-Healing, Continuous Tuning)
|
|
15
|
+
|
|
16
|
+
Usage:
|
|
17
|
+
python tools/tmmi_auditor.py
|
|
18
|
+
python tools/tmmi_auditor.py --json
|
|
19
|
+
python tools/tmmi_auditor.py --gate-level 3
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
import os
|
|
23
|
+
import sys
|
|
24
|
+
import json
|
|
25
|
+
import argparse
|
|
26
|
+
from typing import Dict, Any
|
|
27
|
+
|
|
28
|
+
# Enforce UTF-8 stdout encoding for Windows console compatibility
|
|
29
|
+
if hasattr(sys.stdout, "reconfigure"):
|
|
30
|
+
try:
|
|
31
|
+
sys.stdout.reconfigure(encoding="utf-8")
|
|
32
|
+
sys.stderr.reconfigure(encoding="utf-8")
|
|
33
|
+
except Exception:
|
|
34
|
+
pass
|
|
35
|
+
|
|
36
|
+
REPO_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
TMMI_LEVEL_CRITERIA = {
|
|
40
|
+
2: {
|
|
41
|
+
"title": "Level 2: Managed",
|
|
42
|
+
"description": "Fundamental test management: Test Policy, Test Planning, Test Monitoring, Test Design Techniques.",
|
|
43
|
+
"checks": [
|
|
44
|
+
{"id": "PA_2_1", "name": "Test Policy & Strategy Defined", "path": "AGENTS.md"},
|
|
45
|
+
{"id": "PA_2_2", "name": "Standard Test Design Techniques (BVA/EP)", "path": ".agents/skills/02-test-design/rbt-manual-testing/SKILL.md"},
|
|
46
|
+
{"id": "PA_2_3", "name": "Dynamic & Idempotent Test Data Management", "path": ".agents/skills/07-data-and-state/synthetic-test-data-generator/SKILL.md"},
|
|
47
|
+
{"id": "PA_2_4", "name": "Traceability Matrix & Deliverable Export (ISO 29119-3)", "path": "tools/template_excel_exporter.py"},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
3: {
|
|
51
|
+
"title": "Level 3: Defined",
|
|
52
|
+
"description": "Standardized lifecycle: Clean POM, Non-Functional Testing (Perf, Security, A11y), Peer Reviews.",
|
|
53
|
+
"checks": [
|
|
54
|
+
{"id": "PA_3_1", "name": "Clean POM Flat Architecture Invariant", "path": ".agents/skills/01-web-automation/clean-pom-crafter/SKILL.md"},
|
|
55
|
+
{"id": "PA_3_2", "name": "Non-Functional: Dynamic Application Security (DAST/OWASP)", "path": "tools/security_scanner.py"},
|
|
56
|
+
{"id": "PA_3_3", "name": "Non-Functional: Automated Accessibility Auditing (WCAG 2.2 / VPAT)", "path": "tools/wcag_audit.py"},
|
|
57
|
+
{"id": "PA_3_4", "name": "Non-Functional: Performance SLA & Load Testing (JMeter/k6)", "path": "tools/jtl_analyzer.py"},
|
|
58
|
+
{"id": "PA_3_5", "name": "Static Peer Review & Code Quality Ladder", "path": ".agents/skills/08-code-quality/senior-code-review/SKILL.md"},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
4: {
|
|
62
|
+
"title": "Level 4: Measured",
|
|
63
|
+
"description": "Quantitative quality evaluation: Mutation Testing, Flakiness Analysis, Tail Latency Metrics.",
|
|
64
|
+
"checks": [
|
|
65
|
+
{"id": "PA_4_1", "name": "Syntactic Mutation Testing Engine (Kill Rate >= 80%)", "path": "tools/micro_mutator.py"},
|
|
66
|
+
{"id": "PA_4_2", "name": "Flaky Test Detection & Quarantine Sentinel", "path": "tools/flaky_detector.py"},
|
|
67
|
+
{"id": "PA_4_3", "name": "Specification & Contract Drift Detection", "path": "tools/spec_drift_sentinel.py"},
|
|
68
|
+
{"id": "PA_4_4", "name": "Historical Quality & Flakiness Trend Analytics", "path": "tools/trend_analytics.py"},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
5: {
|
|
72
|
+
"title": "Level 5: Optimization",
|
|
73
|
+
"description": "Defect prevention, self-healing automation, and continuous process optimization.",
|
|
74
|
+
"checks": [
|
|
75
|
+
{"id": "PA_5_1", "name": "Self-Healing Locator & Reflexion Engine", "path": "tools/auto_heal.py"},
|
|
76
|
+
{"id": "PA_5_2", "name": "Static Defect & Fake-Pass Elimination (Infer-Style)", "path": "tools/infer_linter.py"},
|
|
77
|
+
{"id": "PA_5_3", "name": "Prompt Optimization & Assertion Tuning (MIPROv2)", "path": "tools/mipro_assertion_tuner.py"},
|
|
78
|
+
{"id": "PA_5_4", "name": "Adversarial Test Generation & Fuzzing", "path": "tools/api_fuzzer.py"},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def audit_tmmi_maturity(root_dir: str = REPO_ROOT) -> Dict[str, Any]:
|
|
85
|
+
"""Audits repository against TMMi Level 1 through 5 process goals."""
|
|
86
|
+
level_results = {}
|
|
87
|
+
achieved_level = 1
|
|
88
|
+
|
|
89
|
+
for lvl in (2, 3, 4, 5):
|
|
90
|
+
cfg = TMMI_LEVEL_CRITERIA[lvl]
|
|
91
|
+
passed_checks = 0
|
|
92
|
+
total_checks = len(cfg["checks"])
|
|
93
|
+
check_details = []
|
|
94
|
+
|
|
95
|
+
for chk in cfg["checks"]:
|
|
96
|
+
p = os.path.join(root_dir, chk["path"])
|
|
97
|
+
exists = os.path.exists(p)
|
|
98
|
+
if exists:
|
|
99
|
+
passed_checks += 1
|
|
100
|
+
check_details.append({
|
|
101
|
+
"id": chk["id"],
|
|
102
|
+
"name": chk["name"],
|
|
103
|
+
"target_evidence": chk["path"],
|
|
104
|
+
"status": "PASS" if exists else "MISSING",
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
compliance_pct = round((passed_checks / total_checks) * 100, 1)
|
|
108
|
+
is_level_achieved = (compliance_pct == 100.0)
|
|
109
|
+
|
|
110
|
+
level_results[f"level_{lvl}"] = {
|
|
111
|
+
"title": cfg["title"],
|
|
112
|
+
"compliance_pct": compliance_pct,
|
|
113
|
+
"is_achieved": is_level_achieved,
|
|
114
|
+
"passed_checks": passed_checks,
|
|
115
|
+
"total_checks": total_checks,
|
|
116
|
+
"checks": check_details,
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if is_level_achieved and achieved_level == (lvl - 1):
|
|
120
|
+
achieved_level = lvl
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
"standard": "TMMi (Test Maturity Model integration) Foundation",
|
|
124
|
+
"certified_maturity_level": achieved_level,
|
|
125
|
+
"level_title": f"TMMi Level {achieved_level}",
|
|
126
|
+
"maturity_summary": level_results,
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def main():
|
|
131
|
+
parser = argparse.ArgumentParser(
|
|
132
|
+
description="Synapse Hub TMMi (Test Maturity Model integration) Assessment Sentinel",
|
|
133
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
134
|
+
)
|
|
135
|
+
parser.add_argument("--root", default=REPO_ROOT, help="Target repository root directory to assess")
|
|
136
|
+
parser.add_argument("--json", action="store_true", help="Output results in JSON format")
|
|
137
|
+
parser.add_argument("--gate-level", type=int, choices=[1, 2, 3, 4, 5], help="Quality Gate: Fail if achieved level < threshold")
|
|
138
|
+
|
|
139
|
+
args = parser.parse_args()
|
|
140
|
+
|
|
141
|
+
res = audit_tmmi_maturity(args.root)
|
|
142
|
+
|
|
143
|
+
if args.json:
|
|
144
|
+
print(json.dumps(res, indent=2, ensure_ascii=False))
|
|
145
|
+
else:
|
|
146
|
+
lvl = res["certified_maturity_level"]
|
|
147
|
+
color = "\033[92m" if lvl >= 3 else "\033[93m"
|
|
148
|
+
reset = "\033[0m"
|
|
149
|
+
|
|
150
|
+
print("=" * 72)
|
|
151
|
+
print(" SYNAPSE HUB — TMMi MATURITY ASSESSMENT SCORECARD")
|
|
152
|
+
print("=" * 72)
|
|
153
|
+
print(f" Certified Maturity Level: {color}TMMi Level {lvl}{reset} (Scale 1 to 5)")
|
|
154
|
+
print("-" * 72)
|
|
155
|
+
|
|
156
|
+
for l_key, l_data in res["maturity_summary"].items():
|
|
157
|
+
st = "\033[92m[ACHIEVED]\033[0m" if l_data["is_achieved"] else "\033[93m[IN PROGRESS]\033[0m"
|
|
158
|
+
print(f" {st} {l_data['title']:<20} : {l_data['compliance_pct']}% ({l_data['passed_checks']}/{l_data['total_checks']} goals met)")
|
|
159
|
+
for chk in l_data["checks"]:
|
|
160
|
+
c_st = "✅" if chk["status"] == "PASS" else "❌"
|
|
161
|
+
print(f" {c_st} {chk['id']} - {chk['name']}")
|
|
162
|
+
print("=" * 72)
|
|
163
|
+
|
|
164
|
+
if args.gate_level and res["certified_maturity_level"] < args.gate_level:
|
|
165
|
+
print(f"🚨 Quality Gate Failed: Assessed TMMi Level {res['certified_maturity_level']} < required Level {args.gate_level}!", file=sys.stderr)
|
|
166
|
+
return 1
|
|
167
|
+
|
|
168
|
+
return 0
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
if __name__ == "__main__":
|
|
172
|
+
sys.exit(main())
|
package/tools/ui_server.py
CHANGED
|
@@ -238,7 +238,7 @@ class SynapseUiHandler(BaseHTTPRequestHandler):
|
|
|
238
238
|
if path == "/api/status":
|
|
239
239
|
active_target = JOB_MANAGER.target_dir or REPO_ROOT
|
|
240
240
|
self.send_json(200, {
|
|
241
|
-
"version": "4.
|
|
241
|
+
"version": "4.4.0",
|
|
242
242
|
"status": "ONLINE",
|
|
243
243
|
"os": sys.platform,
|
|
244
244
|
"workspace": active_target,
|
package/tools/update_sentinel.py
CHANGED
|
@@ -68,7 +68,7 @@ def get_local_version():
|
|
|
68
68
|
try:
|
|
69
69
|
with open(pkg_file, "r", encoding="utf-8") as f:
|
|
70
70
|
data = json.load(f)
|
|
71
|
-
return data.get("version", "4.
|
|
71
|
+
return data.get("version", "4.4.0")
|
|
72
72
|
except (OSError, json.JSONDecodeError):
|
|
73
73
|
data = {}
|
|
74
74
|
|
|
@@ -77,11 +77,11 @@ def get_local_version():
|
|
|
77
77
|
try:
|
|
78
78
|
with open(manifest_file, "r", encoding="utf-8") as f:
|
|
79
79
|
data = json.load(f)
|
|
80
|
-
return data.get("version", "4.
|
|
80
|
+
return data.get("version", "4.4.0")
|
|
81
81
|
except (OSError, json.JSONDecodeError):
|
|
82
82
|
data = {}
|
|
83
83
|
|
|
84
|
-
return "4.
|
|
84
|
+
return "4.4.0"
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
def fetch_remote_version():
|