@teevee98/synapse-hub 4.1.3 → 4.2.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/rules/git-push-protocol.md +2 -2
- package/.agents/skills/01-web-automation/auth-session-and-cookie-manager/SKILL.md +6 -1
- package/.agents/skills/01-web-automation/bats-testing-patterns/SKILL.md +6 -1
- package/.agents/skills/01-web-automation/clean-pom-crafter/SKILL.md +8 -3
- package/.agents/skills/01-web-automation/clean-pom-crafter/examples/standard_test_case.groovy +3 -0
- package/.agents/skills/01-web-automation/clean-pom-crafter/references/pom_patterns.groovy +3 -0
- package/.agents/skills/01-web-automation/e2e-testing-patterns/SKILL.md +6 -1
- package/.agents/skills/01-web-automation/e2e-testing-patterns/examples/playwright_sharded_config.ts +3 -0
- package/.agents/skills/01-web-automation/katalon-cli-runner/SKILL.md +6 -1
- package/.agents/skills/01-web-automation/lam-script-generator/SKILL.md +6 -1
- package/.agents/skills/01-web-automation/mobile-appium-som/SKILL.md +6 -1
- package/.agents/skills/01-web-automation/mobile-appium-som/examples/BaseScreen.java +2 -2
- package/.agents/skills/01-web-automation/mobile-appium-som/examples/LoginScreen.java +2 -2
- package/.agents/skills/01-web-automation/mobile-appium-som/examples/TC_MobileLogin.java +2 -2
- package/.agents/skills/01-web-automation/playwright-live-interaction/SKILL.md +7 -2
- package/.agents/skills/01-web-automation/playwright-webapp-testing/SKILL.md +6 -1
- package/.agents/skills/01-web-automation/playwright-webapp-testing/examples/server_lifecycle_playwright.py +3 -0
- package/.agents/skills/01-web-automation/web-agent-gym-benchmarking/SKILL.md +6 -1
- package/.agents/skills/02-test-design/architecture-decision-records/SKILL.md +6 -1
- package/.agents/skills/02-test-design/gherkin-to-suite/SKILL.md +6 -1
- package/.agents/skills/02-test-design/rbt-manual-testing/SKILL.md +6 -1
- package/.agents/skills/02-test-design/review-spec/SKILL.md +4 -1
- package/.agents/skills/02-test-design/tot-exploratory-testing/SKILL.md +6 -1
- package/.agents/skills/03-api-and-contracts/api-network-mocking-interception/SKILL.md +6 -1
- package/.agents/skills/03-api-and-contracts/api-spec-to-e2e-matrix/SKILL.md +6 -1
- package/.agents/skills/03-api-and-contracts/consumer-driven-contract-testing/SKILL.md +7 -2
- package/.agents/skills/04-performance-and-load/backend-load-and-stress-patterns/SKILL.md +7 -2
- package/.agents/skills/04-performance-and-load/lean-impact-scoreboard/SKILL.md +4 -1
- package/.agents/skills/04-performance-and-load/web-vitals-and-performance-profiler/SKILL.md +6 -1
- package/.agents/skills/04-performance-and-load/web-vitals-and-performance-profiler/examples/playwright_cwv_profiler_fixture.ts +3 -0
- package/.agents/skills/05-security-and-compliance/security-dast-sentinel/SKILL.md +6 -1
- package/.agents/skills/05-security-and-compliance/security-dast-sentinel/references/dast_recipes.ts +3 -0
- package/.agents/skills/05-security-and-compliance/skillspector-security-guard/SKILL.md +6 -1
- package/.agents/skills/05-security-and-compliance/wcag-audit-patterns/SKILL.md +6 -1
- package/.agents/skills/06-healing-and-resilience/agentless-qa-repair/SKILL.md +6 -1
- package/.agents/skills/06-healing-and-resilience/antigravity-test-sentinel/SKILL.md +6 -1
- package/.agents/skills/06-healing-and-resilience/failure-autopsy-and-healing/SKILL.md +7 -2
- package/.agents/skills/06-healing-and-resilience/flaky-test-sentinel-and-quarantine/SKILL.md +6 -1
- package/.agents/skills/06-healing-and-resilience/self-healing-locator/SKILL.md +6 -1
- package/.agents/skills/06-healing-and-resilience/systematic-debugging/SKILL.md +6 -1
- package/.agents/skills/06-healing-and-resilience/test-driven-development/SKILL.md +6 -1
- package/.agents/skills/06-healing-and-resilience/verification-before-completion/SKILL.md +6 -1
- package/.agents/skills/06-healing-and-resilience/visual-regression-sentinel/SKILL.md +6 -1
- package/.agents/skills/07-data-and-state/db-state-verifier-and-seeder/SKILL.md +6 -1
- package/.agents/skills/07-data-and-state/file-and-report-validator/SKILL.md +6 -1
- package/.agents/skills/07-data-and-state/synthetic-test-data-generator/SKILL.md +6 -1
- package/.agents/skills/08-code-quality/code-refactoring-refactor-clean/SKILL.md +6 -1
- package/.agents/skills/08-code-quality/code-refactoring-refactor-clean/examples/refactored_page_sample.groovy +3 -0
- package/.agents/skills/08-code-quality/code-refactoring-refactor-clean/examples/refactored_playwright_pom.ts +3 -0
- package/.agents/skills/08-code-quality/graphify-impact-analyzer/SKILL.md +6 -1
- package/.agents/skills/08-code-quality/lean-code-ladder/SKILL.md +6 -1
- package/.agents/skills/08-code-quality/repo-quality-audit/SKILL.md +4 -1
- package/.agents/skills/08-code-quality/senior-code-review/SKILL.md +4 -1
- package/.agents/skills/08-code-quality/surgical-coding-principles/SKILL.md +6 -1
- package/.agents/skills/08-code-quality/technical-debt-harvester/SKILL.md +4 -1
- package/.agents/skills/09-ci-and-devops/github-actions-templates/SKILL.md +6 -1
- package/.agents/skills/10-agent-orchestration/actor-qa-swarm/SKILL.md +6 -1
- package/.agents/skills/10-agent-orchestration/agent-orchestration-multi-agent-optimize/SKILL.md +6 -1
- package/.agents/skills/10-agent-orchestration/event-stream-qa-orchestrator/SKILL.md +6 -1
- package/.agents/skills/10-agent-orchestration/persistent-planning-files/SKILL.md +6 -1
- package/.agents/skills/10-agent-orchestration/qa-memory-os/SKILL.md +6 -1
- package/.agents/skills/11-ai-and-prompting/meta-prompt-crafter/SKILL.md +6 -1
- package/.agents/skills/11-ai-and-prompting/mipro-prompt-compiler/SKILL.md +6 -1
- package/.agents/skills/11-ai-and-prompting/qa-aci-interface/SKILL.md +6 -1
- package/.agents/skills/11-ai-and-prompting/qa-aci-interface/examples/surgical_code_window_walkthrough.md +1 -1
- package/.agents/skills/11-ai-and-prompting/token-and-context-optimizer/SKILL.md +6 -1
- package/AGENTS.md +7 -1
- package/LICENSE +5 -5
- package/NOTICE +1 -1
- package/README.en.md +4 -4
- package/README.md +4 -4
- package/agentskills.json +1 -1
- package/docs/ARCHITECTURE.en.md +2 -2
- package/docs/ARCHITECTURE.md +11 -2
- package/docs/CLI_REFERENCE.en.md +6 -4
- package/docs/CLI_REFERENCE.md +1 -1
- package/docs/CONTRIBUTING.en.md +1 -1
- package/docs/CONTRIBUTING.md +2 -2
- package/docs/PERFORMANCE_AUDIT_REPORT.md +2 -2
- package/docs/TOOL_CATALOG.md +6 -2
- package/docs/research/agent_skill_training_analysis.md +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/scripts/generate_skill_examples.py +3 -0
- package/scripts/package_dist.py +3 -0
- package/skills_manifest.json +320 -55
- package/synapse.config.json +1 -1
- package/templates/ui/index.html +2 -2
- package/tools/.infer_baseline.json +3 -796
- package/tools/TOOL_CATALOG.json +63 -3
- package/tools/__init__.py +4 -1
- package/tools/agent_canary.py +3 -0
- package/tools/analyze_project.py +3 -0
- package/tools/api_drift_sentinel.py +3 -0
- package/tools/api_fuzzer.py +182 -118
- package/tools/ast_cache.py +4 -2
- package/tools/author_integrity.py +174 -12
- package/tools/auto_heal.py +7 -2
- package/tools/autogen_qa_broker.py +14 -15
- package/tools/benchmark_swarm_context.py +119 -18
- package/tools/break_ui_generator.py +233 -0
- package/tools/browser_helpers.js +2 -2
- package/tools/bug_reporter.py +3 -0
- package/tools/build_consolidated_report.py +3 -0
- package/tools/bump_version.py +4 -1
- package/tools/cache_resolver.py +7 -3
- package/tools/check_env.py +3 -0
- package/tools/check_version_sync.py +21 -50
- package/tools/ci_healing_hook.py +3 -0
- package/tools/cli.py +116 -22
- package/tools/config_decoupler.py +3 -0
- package/tools/core/__init__.py +3 -0
- package/tools/core/bm25_retriever.py +218 -0
- package/tools/core/file_lock.py +23 -14
- package/tools/core/i18n.py +13 -11
- package/tools/core/memory_bus.py +6 -3
- package/tools/core/process_supervisor.py +28 -18
- package/tools/core/provider_usage_adapter.py +317 -0
- package/tools/core/token_estimator.py +83 -18
- package/tools/count_tokens.py +16 -7
- package/tools/coverage_reporter.py +245 -0
- package/tools/create_mock_docx.py +3 -0
- package/tools/dashboard_generator.py +17 -15
- package/tools/db_sandbox.py +150 -5
- package/tools/debt_harvester.py +2 -2
- package/tools/diagram_architect.py +3 -0
- package/tools/distill_log.py +22 -2
- package/tools/distill_skill.py +191 -0
- package/tools/e2e_flow_prober.py +3 -0
- package/tools/export_postman_collection.py +3 -0
- package/tools/flaky_detector.py +3 -0
- package/tools/fsm_enforcer.py +2 -2
- package/tools/fuzz_payloads.py +3 -0
- package/tools/generate_allure_report.py +3 -0
- package/tools/generate_api_matrix.py +3 -0
- package/tools/generate_jmx_plan.py +3 -0
- package/tools/generate_tc_from_story.py +3 -0
- package/tools/generate_test_reports.py +3 -0
- package/tools/git_pre_commit_guard.py +25 -3
- package/tools/git_worktree_manager.py +3 -0
- package/tools/heal/__init__.py +3 -0
- package/tools/heal_pr_automator.py +3 -0
- package/tools/heuristic_locator_matcher.py +3 -0
- package/tools/hub_publisher.py +3 -3
- package/tools/humanize_linter.py +3 -0
- package/tools/infer_linter.py +19 -9
- package/tools/init_config.py +6 -9
- package/tools/jtl_analyzer.py +3 -0
- package/tools/lint/__init__.py +3 -0
- package/tools/lint_ai_docs.py +3 -0
- package/tools/lookup_tc.py +3 -0
- package/tools/lookup_xpath.py +3 -0
- package/tools/matrix_sharder.py +3 -0
- package/tools/mcp/__init__.py +3 -0
- package/tools/mcp_docx_server.py +1 -1
- package/tools/mcp_excel_server.py +4 -1
- package/tools/mcp_server.py +78 -15
- package/tools/md_to_xlsx.py +3 -0
- package/tools/mechanical_ui_gate.py +3 -0
- package/tools/micro_mutator.py +93 -19
- package/tools/network_mock_shield.py +3 -0
- package/tools/newman_analyzer.py +3 -0
- package/tools/omni_emitter.py +3 -0
- package/tools/omni_parser.py +3 -0
- package/tools/omni_transpiler.py +3 -0
- package/tools/output_formatter.py +3 -0
- package/tools/package_release.py +6 -6
- package/tools/pairwise_generator.py +3 -0
- package/tools/pentest_scope_guard.py +401 -58
- package/tools/perf/__init__.py +3 -0
- package/tools/perf/benchmark_perf_runner.py +42 -0
- package/tools/pinpoint_failure.py +3 -0
- package/tools/project_state.py +3 -0
- package/tools/repo_map.py +3 -0
- package/tools/report/__init__.py +3 -0
- package/tools/rules_router.py +426 -34
- package/tools/runaway_stopper.py +3 -0
- package/tools/safety_firewall.py +3 -0
- package/tools/security_scanner.py +80 -0
- package/tools/senior_code_review.py +14 -0
- package/tools/setup_project.py +9 -4
- package/tools/skill_canonical_digest.py +244 -0
- package/tools/skill_collision_guard.py +2 -2
- package/tools/skill_profiles.py +77 -7
- package/tools/skillspector.py +2 -1
- package/tools/slide_deck_exporter.py +477 -0
- package/tools/smart_visual_masker.py +3 -0
- package/tools/sync_skills_manifest.py +166 -0
- package/tools/task_memory_manager.py +260 -0
- package/tools/telemetry_correlator.py +3 -0
- package/tools/template_excel_exporter.py +2 -2
- package/tools/test_impact.py +3 -0
- package/tools/trace_data_flow.py +3 -0
- package/tools/traffic_session_converter.py +3 -0
- package/tools/ui_server.py +2 -2
- package/tools/universal_ir.py +3 -0
- package/tools/update_sentinel.py +15 -9
- package/tools/validate_groovy_scripts.py +3 -0
- package/tools/validate_host_interop.py +485 -0
- package/tools/validate_skills_schema.py +282 -0
- package/tools/verify_all.py +600 -63
- package/tools/visual_diff_canvas.py +3 -0
- package/tools/visual_som_helper.py +3 -0
- package/tools/watch_mode.py +4 -4
- package/tools/wcag_audit.py +3 -0
- package/tools/welcome_page.py +2 -2
|
@@ -0,0 +1,245 @@
|
|
|
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/coverage_reporter.py — Standardized Coverage Metrics & Roadmap Evaluator
|
|
8
|
+
-------------------------------------------------------------------------------
|
|
9
|
+
Evaluates and distinguishes:
|
|
10
|
+
1. Statement / Line Coverage (fail_under: 60.00% calibrated floor, roadmap: 70% -> 80%).
|
|
11
|
+
2. Branch Coverage (floor: 50.00% baseline floor, roadmap: 60% -> 70%).
|
|
12
|
+
3. Combined Coverage (statements + branches hit / total).
|
|
13
|
+
|
|
14
|
+
Maintains strict separation between line coverage, branch coverage, static heuristic,
|
|
15
|
+
and dynamic mutation kill scores.
|
|
16
|
+
|
|
17
|
+
Outputs:
|
|
18
|
+
- reports/coverage_summary.json (Standardized multi-metric artifact)
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import argparse
|
|
24
|
+
import json
|
|
25
|
+
import logging
|
|
26
|
+
import os
|
|
27
|
+
import subprocess
|
|
28
|
+
import sys
|
|
29
|
+
from datetime import datetime, timezone
|
|
30
|
+
from typing import Any, Dict
|
|
31
|
+
|
|
32
|
+
_logger = logging.getLogger("coverage_reporter")
|
|
33
|
+
REPO_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
34
|
+
DEFAULT_COVERAGE_JSON = os.path.join(REPO_ROOT, "reports", "coverage.json")
|
|
35
|
+
DEFAULT_COVERAGE_XML = os.path.join(REPO_ROOT, "reports", "coverage.xml")
|
|
36
|
+
DEFAULT_SUMMARY_JSON = os.path.join(REPO_ROOT, "reports", "coverage_summary.json")
|
|
37
|
+
|
|
38
|
+
# Calibrated floors and roadmap milestones
|
|
39
|
+
LINE_COVERAGE_FLOOR_PCT = 60.00
|
|
40
|
+
BRANCH_COVERAGE_FLOOR_PCT = 50.00
|
|
41
|
+
|
|
42
|
+
ROADMAP_THRESHOLDS = {
|
|
43
|
+
"current_calibrated": {"line_pct": 60.00, "branch_pct": 50.00},
|
|
44
|
+
"phase_2_consolidation": {"line_pct": 70.00, "branch_pct": 60.00},
|
|
45
|
+
"target_enterprise": {"line_pct": 80.00, "branch_pct": 70.00},
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def get_git_commit(repo_root: str = REPO_ROOT) -> str:
|
|
50
|
+
try:
|
|
51
|
+
out = subprocess.check_output(
|
|
52
|
+
["git", "rev-parse", "HEAD"],
|
|
53
|
+
cwd=repo_root,
|
|
54
|
+
stderr=subprocess.DEVNULL,
|
|
55
|
+
)
|
|
56
|
+
return out.decode("utf-8").strip()
|
|
57
|
+
except (OSError, subprocess.SubprocessError) as err:
|
|
58
|
+
_logger.debug("Could not determine git commit: %s", err)
|
|
59
|
+
return "unversioned"
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def parse_coverage_metrics(
|
|
63
|
+
json_path: str = DEFAULT_COVERAGE_JSON,
|
|
64
|
+
) -> Dict[str, Any]:
|
|
65
|
+
"""Parses coverage metrics from coverage.py json report."""
|
|
66
|
+
if not os.path.exists(json_path):
|
|
67
|
+
raise FileNotFoundError(f"Coverage JSON report not found: {json_path}")
|
|
68
|
+
|
|
69
|
+
with open(json_path, "r", encoding="utf-8") as f:
|
|
70
|
+
data = json.load(f)
|
|
71
|
+
|
|
72
|
+
totals = data.get("totals", {})
|
|
73
|
+
num_statements = totals.get("num_statements", 0)
|
|
74
|
+
covered_lines = totals.get("covered_lines", 0)
|
|
75
|
+
missing_lines = totals.get("missing_lines", 0)
|
|
76
|
+
|
|
77
|
+
# Line / Statement coverage
|
|
78
|
+
line_cov_pct = float(
|
|
79
|
+
totals.get(
|
|
80
|
+
"percent_statements_covered",
|
|
81
|
+
(covered_lines / num_statements * 100.0) if num_statements > 0 else 0.0,
|
|
82
|
+
)
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
# Branch coverage
|
|
86
|
+
num_branches = totals.get("num_branches", 0)
|
|
87
|
+
covered_branches = totals.get("covered_branches", 0)
|
|
88
|
+
missing_branches = totals.get("missing_branches", 0)
|
|
89
|
+
branch_cov_pct = float(
|
|
90
|
+
totals.get(
|
|
91
|
+
"percent_branches_covered",
|
|
92
|
+
(covered_branches / num_branches * 100.0) if num_branches > 0 else 0.0,
|
|
93
|
+
)
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Combined coverage
|
|
97
|
+
combined_cov_pct = float(totals.get("percent_covered", 0.0))
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
"num_statements": num_statements,
|
|
101
|
+
"covered_lines": covered_lines,
|
|
102
|
+
"missing_lines": missing_lines,
|
|
103
|
+
"line_coverage_pct": round(line_cov_pct, 2),
|
|
104
|
+
"num_branches": num_branches,
|
|
105
|
+
"covered_branches": covered_branches,
|
|
106
|
+
"missing_branches": missing_branches,
|
|
107
|
+
"branch_coverage_pct": round(branch_cov_pct, 2),
|
|
108
|
+
"combined_coverage_pct": round(combined_cov_pct, 2),
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def evaluate_coverage(
|
|
113
|
+
coverage_data: Dict[str, Any],
|
|
114
|
+
line_floor: float = LINE_COVERAGE_FLOOR_PCT,
|
|
115
|
+
branch_floor: float = BRANCH_COVERAGE_FLOOR_PCT,
|
|
116
|
+
enforce_branch: bool = True,
|
|
117
|
+
) -> Dict[str, Any]:
|
|
118
|
+
"""Evaluates metrics against calibrated floor and roadmap milestones."""
|
|
119
|
+
line_pct = coverage_data["line_coverage_pct"]
|
|
120
|
+
branch_pct = coverage_data["branch_coverage_pct"]
|
|
121
|
+
|
|
122
|
+
line_pass = line_pct >= line_floor
|
|
123
|
+
branch_pass = branch_pct >= branch_floor if enforce_branch and coverage_data["num_branches"] > 0 else True
|
|
124
|
+
all_pass = line_pass and branch_pass
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
"line_pass": line_pass,
|
|
128
|
+
"branch_pass": branch_pass,
|
|
129
|
+
"all_pass": all_pass,
|
|
130
|
+
"line_floor": line_floor,
|
|
131
|
+
"branch_floor": branch_floor,
|
|
132
|
+
"enforce_branch": enforce_branch,
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def generate_coverage_summary(
|
|
137
|
+
coverage_json: str = DEFAULT_COVERAGE_JSON,
|
|
138
|
+
coverage_xml: str = DEFAULT_COVERAGE_XML,
|
|
139
|
+
output_summary_json: str = DEFAULT_SUMMARY_JSON,
|
|
140
|
+
line_floor: float = LINE_COVERAGE_FLOOR_PCT,
|
|
141
|
+
branch_floor: float = BRANCH_COVERAGE_FLOOR_PCT,
|
|
142
|
+
enforce_branch: bool = True,
|
|
143
|
+
repo_root: str = REPO_ROOT,
|
|
144
|
+
) -> Dict[str, Any]:
|
|
145
|
+
"""Generates standardized coverage summary artifact and writes to disk."""
|
|
146
|
+
metrics = parse_coverage_metrics(coverage_json)
|
|
147
|
+
eval_res = evaluate_coverage(
|
|
148
|
+
metrics,
|
|
149
|
+
line_floor=line_floor,
|
|
150
|
+
branch_floor=branch_floor,
|
|
151
|
+
enforce_branch=enforce_branch,
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
commit_sha = get_git_commit(repo_root)
|
|
155
|
+
now_iso = datetime.now(timezone.utc).isoformat()
|
|
156
|
+
|
|
157
|
+
summary_doc = {
|
|
158
|
+
"generated_at": now_iso,
|
|
159
|
+
"commit": commit_sha,
|
|
160
|
+
"metrics": {
|
|
161
|
+
"line_coverage_pct": metrics["line_coverage_pct"],
|
|
162
|
+
"branch_coverage_pct": metrics["branch_coverage_pct"],
|
|
163
|
+
"combined_coverage_pct": metrics["combined_coverage_pct"],
|
|
164
|
+
"statements_total": metrics["num_statements"],
|
|
165
|
+
"statements_covered": metrics["covered_lines"],
|
|
166
|
+
"statements_missing": metrics["missing_lines"],
|
|
167
|
+
"branches_total": metrics["num_branches"],
|
|
168
|
+
"branches_covered": metrics["covered_branches"],
|
|
169
|
+
"branches_missing": metrics["missing_branches"],
|
|
170
|
+
},
|
|
171
|
+
"thresholds": {
|
|
172
|
+
"line_floor_pct": line_floor,
|
|
173
|
+
"branch_floor_pct": branch_floor,
|
|
174
|
+
"roadmap": ROADMAP_THRESHOLDS,
|
|
175
|
+
},
|
|
176
|
+
"evaluation": {
|
|
177
|
+
"line_passed": eval_res["line_pass"],
|
|
178
|
+
"branch_passed": eval_res["branch_pass"],
|
|
179
|
+
"all_passed": eval_res["all_pass"],
|
|
180
|
+
},
|
|
181
|
+
"artifacts": {
|
|
182
|
+
"coverage_json": os.path.relpath(coverage_json, repo_root) if os.path.exists(coverage_json) else None,
|
|
183
|
+
"coverage_xml": os.path.relpath(coverage_xml, repo_root) if os.path.exists(coverage_xml) else None,
|
|
184
|
+
"summary_json": os.path.relpath(output_summary_json, repo_root),
|
|
185
|
+
},
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
out_dir = os.path.dirname(output_summary_json)
|
|
189
|
+
if out_dir:
|
|
190
|
+
os.makedirs(out_dir, exist_ok=True)
|
|
191
|
+
with open(output_summary_json, "w", encoding="utf-8") as f:
|
|
192
|
+
json.dump(summary_doc, f, indent=2)
|
|
193
|
+
|
|
194
|
+
return summary_doc
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def main() -> int:
|
|
198
|
+
parser = argparse.ArgumentParser(description="Synapse Hub Standardized Coverage Reporter")
|
|
199
|
+
parser.add_argument("--json-report", default=DEFAULT_COVERAGE_JSON, help="Path to coverage.json")
|
|
200
|
+
parser.add_argument("--xml-report", default=DEFAULT_COVERAGE_XML, help="Path to coverage.xml")
|
|
201
|
+
parser.add_argument("--summary-out", default=DEFAULT_SUMMARY_JSON, help="Path to write coverage_summary.json")
|
|
202
|
+
parser.add_argument("--line-floor", type=float, default=LINE_COVERAGE_FLOOR_PCT, help="Statement/line coverage floor")
|
|
203
|
+
parser.add_argument("--branch-floor", type=float, default=BRANCH_COVERAGE_FLOOR_PCT, help="Branch coverage floor")
|
|
204
|
+
parser.add_argument("--no-branch", action="store_true", help="Do not enforce branch coverage threshold")
|
|
205
|
+
parser.add_argument("--check", action="store_true", help="Fail with non-zero exit code if coverage is below threshold")
|
|
206
|
+
parser.add_argument("--json", action="store_true", help="Print summary JSON to stdout")
|
|
207
|
+
args = parser.parse_args()
|
|
208
|
+
|
|
209
|
+
if not os.path.exists(args.json_report):
|
|
210
|
+
sys.stderr.write(f"Error: Coverage JSON report not found at {args.json_report}.\n")
|
|
211
|
+
return 1
|
|
212
|
+
|
|
213
|
+
summary = generate_coverage_summary(
|
|
214
|
+
coverage_json=args.json_report,
|
|
215
|
+
coverage_xml=args.xml_report,
|
|
216
|
+
output_summary_json=args.summary_out,
|
|
217
|
+
line_floor=args.line_floor,
|
|
218
|
+
branch_floor=args.branch_floor,
|
|
219
|
+
enforce_branch=not args.no_branch,
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
if args.json:
|
|
223
|
+
print(json.dumps(summary, indent=2))
|
|
224
|
+
else:
|
|
225
|
+
m = summary["metrics"]
|
|
226
|
+
e = summary["evaluation"]
|
|
227
|
+
print("======================================================================")
|
|
228
|
+
print(" SYNAPSE HUB STANDARDIZED TEST COVERAGE REPORT ")
|
|
229
|
+
print("======================================================================")
|
|
230
|
+
print(f" Line Coverage (Statements) : {m['line_coverage_pct']}% (Floor: >= {args.line_floor}%) - {'✅ PASS' if e['line_passed'] else '❌ FAIL'}")
|
|
231
|
+
print(f" Branch Coverage : {m['branch_coverage_pct']}% (Floor: >= {args.branch_floor}%) - {'✅ PASS' if e['branch_passed'] else '❌ FAIL'}")
|
|
232
|
+
print(f" Combined (Stmt + Branch) : {m['combined_coverage_pct']}%")
|
|
233
|
+
print(f" Total Statements : {m['statements_total']:,} (Covered: {m['statements_covered']:,})")
|
|
234
|
+
print(f" Total Branches : {m['branches_total']:,} (Covered: {m['branches_covered']:,})")
|
|
235
|
+
print(f" Coverage Summary Artifact : {summary['artifacts']['summary_json']}")
|
|
236
|
+
print(f" Coverage XML Artifact : {summary['artifacts']['coverage_xml']}")
|
|
237
|
+
print("======================================================================")
|
|
238
|
+
|
|
239
|
+
if args.check and not summary["evaluation"]["all_passed"]:
|
|
240
|
+
return 1
|
|
241
|
+
return 0
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
if __name__ == "__main__":
|
|
245
|
+
sys.exit(main())
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
+
# SPDX-FileCopyrightText: © 2026 Thế Vị (@TeeVee98) <https://github.com/TeeVee98/Synapse-Hub>
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
2
5
|
"""Generates a lightweight valid mock DOCX fixture (< 20 KB) for OpenXML Guard / Word reader tests."""
|
|
3
6
|
|
|
4
7
|
import os
|
|
@@ -183,8 +183,9 @@ def load_manifest(hub_root: str) -> Dict[str, Any]:
|
|
|
183
183
|
try:
|
|
184
184
|
with open(path, "r", encoding="utf-8") as f:
|
|
185
185
|
return json.load(f)
|
|
186
|
-
except (OSError, json.JSONDecodeError):
|
|
187
|
-
|
|
186
|
+
except (OSError, json.JSONDecodeError) as err:
|
|
187
|
+
import logging
|
|
188
|
+
logging.getLogger("dashboard_generator").debug("Failed to load skills_manifest: %s", err)
|
|
188
189
|
return {"totalSkills": 50, "skills": [], "categories": {}, "profiles": {}}
|
|
189
190
|
|
|
190
191
|
|
|
@@ -211,7 +212,7 @@ def load_benchmark_report(hub_root: str) -> Dict[str, Any]:
|
|
|
211
212
|
"available": True
|
|
212
213
|
}
|
|
213
214
|
except (OSError, UnicodeDecodeError):
|
|
214
|
-
|
|
215
|
+
continue
|
|
215
216
|
return {
|
|
216
217
|
"resolution_rate": "100.0%",
|
|
217
218
|
"mttr": "0.0s",
|
|
@@ -245,7 +246,7 @@ def load_health_report(target_dir: str) -> Dict[str, Any]:
|
|
|
245
246
|
"available": True
|
|
246
247
|
}
|
|
247
248
|
except (OSError, UnicodeDecodeError):
|
|
248
|
-
|
|
249
|
+
continue
|
|
249
250
|
return {
|
|
250
251
|
"dod_status": "100%_PASS",
|
|
251
252
|
"classes_count": 0,
|
|
@@ -310,8 +311,9 @@ def load_latest_execution_results(target_dir: str) -> Dict[str, Any]:
|
|
|
310
311
|
"timestamp": mtime_str,
|
|
311
312
|
"report_path": rel_path
|
|
312
313
|
}
|
|
313
|
-
except (ET.ParseError, OSError, ValueError, KeyError):
|
|
314
|
-
|
|
314
|
+
except (ET.ParseError, OSError, ValueError, KeyError) as err:
|
|
315
|
+
import logging
|
|
316
|
+
logging.getLogger("dashboard_generator").debug("Failed to parse JUnit XML report: %s", err)
|
|
315
317
|
|
|
316
318
|
# Check summaryTemp.txt if JUnit report not parsed
|
|
317
319
|
summary_files = list(target_path.glob("**/summaryTemp.txt"))
|
|
@@ -344,7 +346,7 @@ def load_latest_execution_results(target_dir: str) -> Dict[str, Any]:
|
|
|
344
346
|
"report_path": str(sf.relative_to(target_path))
|
|
345
347
|
}
|
|
346
348
|
except (OSError, ValueError):
|
|
347
|
-
|
|
349
|
+
continue
|
|
348
350
|
|
|
349
351
|
return {
|
|
350
352
|
"available": False,
|
|
@@ -404,7 +406,7 @@ def scan_target_project_assets(target_dir: str, stack_info: Dict[str, str]) -> D
|
|
|
404
406
|
if classes_list:
|
|
405
407
|
break
|
|
406
408
|
except (json.JSONDecodeError, OSError, KeyError):
|
|
407
|
-
|
|
409
|
+
continue
|
|
408
410
|
|
|
409
411
|
# Priority B: Parse repo_map.txt
|
|
410
412
|
if not classes_list:
|
|
@@ -491,7 +493,7 @@ def scan_target_project_assets(target_dir: str, stack_info: Dict[str, str]) -> D
|
|
|
491
493
|
"methods": m_list or ["(Defined in source)"]
|
|
492
494
|
})
|
|
493
495
|
except (OSError, UnicodeDecodeError):
|
|
494
|
-
|
|
496
|
+
continue
|
|
495
497
|
|
|
496
498
|
# 2. Discover Test Cases
|
|
497
499
|
test_files = []
|
|
@@ -1348,7 +1350,7 @@ def _build_target_translations(
|
|
|
1348
1350
|
"th_step_status": "Trạng Thái",
|
|
1349
1351
|
"th_step_details": "Chi Tiết Kỹ Thuật (OTel & AST)",
|
|
1350
1352
|
|
|
1351
|
-
"footer_text": "Báo cáo được khởi tạo tự động bởi Synapse-Hub v4.
|
|
1353
|
+
"footer_text": "Báo cáo được khởi tạo tự động bởi Synapse-Hub v4.2.0 • Bản quyền © Thế Vị (@TeeVee98) • Chuẩn Clean POM & Kiểm Thử Tự Chủ",
|
|
1352
1354
|
}
|
|
1353
1355
|
|
|
1354
1356
|
translations_en = {
|
|
@@ -1426,7 +1428,7 @@ def _build_target_translations(
|
|
|
1426
1428
|
"th_step_status": "Status",
|
|
1427
1429
|
"th_step_details": "Technical Details (OTel & AST)",
|
|
1428
1430
|
|
|
1429
|
-
"footer_text": "Generated automatically by Synapse-Hub v4.
|
|
1431
|
+
"footer_text": "Generated automatically by Synapse-Hub v4.2.0 • Copyright © Thế Vị (@TeeVee98) • Clean POM & Autonomous Testing",
|
|
1430
1432
|
}
|
|
1431
1433
|
|
|
1432
1434
|
_inject_gate_translations(translations_vi, translations_en, gates)
|
|
@@ -1915,7 +1917,7 @@ def _build_hub_translations(
|
|
|
1915
1917
|
"""Builds bilingual dictionaries for Hub Dashboard."""
|
|
1916
1918
|
translations_vi = {
|
|
1917
1919
|
"header_title": "Bảng Điều Hành Chất Lượng Doanh Nghiệp",
|
|
1918
|
-
"header_subtitle": "Synapse-Hub v4.
|
|
1920
|
+
"header_subtitle": "Synapse-Hub v4.2.0 • Hệ Sinh Thái Kiểm Thử AI Agent Tự Chủ",
|
|
1919
1921
|
"nav_welcome": "Giới Thiệu",
|
|
1920
1922
|
"meta_mode": "🏷️ Chế độ: <strong>HỆ SINH THÁI QA HUB</strong>",
|
|
1921
1923
|
"meta_gen": f"🕒 Khởi tạo: <strong>{now_str}</strong>",
|
|
@@ -1985,12 +1987,12 @@ def _build_hub_translations(
|
|
|
1985
1987
|
"th_sk_ver": "Phiên Bản",
|
|
1986
1988
|
"th_sk_cap": "Khả Năng Nghiệp Vụ Cốt Lõi",
|
|
1987
1989
|
|
|
1988
|
-
"footer_text": "Bảng Điều Hành Chất Lượng Doanh Nghiệp • Synapse-Hub v4.
|
|
1990
|
+
"footer_text": "Bảng Điều Hành Chất Lượng Doanh Nghiệp • Synapse-Hub v4.2.0 • Bản quyền © Thế Vị (@TeeVee98) • Hệ Thống Kiểm Thử AI Agent Tự Chủ",
|
|
1989
1991
|
}
|
|
1990
1992
|
|
|
1991
1993
|
translations_en = {
|
|
1992
1994
|
"header_title": "Enterprise QA Executive Dashboard",
|
|
1993
|
-
"header_subtitle": "Synapse-Hub v4.
|
|
1995
|
+
"header_subtitle": "Synapse-Hub v4.2.0 • Autonomous AI Agent Testing Ecosystem",
|
|
1994
1996
|
"nav_welcome": "Welcome",
|
|
1995
1997
|
"meta_mode": "🏷️ Mode: <strong>QA HUB ECOSYSTEM</strong>",
|
|
1996
1998
|
"meta_gen": f"🕒 Generated: <strong>{now_str}</strong>",
|
|
@@ -2060,7 +2062,7 @@ def _build_hub_translations(
|
|
|
2060
2062
|
"th_sk_ver": "Version",
|
|
2061
2063
|
"th_sk_cap": "Core Capabilities",
|
|
2062
2064
|
|
|
2063
|
-
"footer_text": "Enterprise QA Executive Dashboard • Synapse-Hub v4.
|
|
2065
|
+
"footer_text": "Enterprise QA Executive Dashboard • Synapse-Hub v4.2.0 • Copyright © Thế Vị (@TeeVee98) • Autonomous AI Agent Testing Ecosystem",
|
|
2064
2066
|
}
|
|
2065
2067
|
|
|
2066
2068
|
_inject_gate_translations(translations_vi, translations_en, gates)
|
package/tools/db_sandbox.py
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
+
# SPDX-FileCopyrightText: © 2026 Thế Vị (@TeeVee98) <https://github.com/TeeVee98/Synapse-Hub>
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
2
5
|
"""
|
|
3
6
|
Enterprise Zero-Pollution Database Sandbox & Ephemeral Teardown Engine
|
|
4
7
|
---------------------------------------------------------------------
|
|
@@ -191,9 +194,16 @@ class DBSandbox:
|
|
|
191
194
|
|
|
192
195
|
return metadata
|
|
193
196
|
|
|
194
|
-
def restore_snapshot(
|
|
197
|
+
def restore_snapshot(
|
|
198
|
+
self,
|
|
199
|
+
snapshot_id: str = "pristine_baseline",
|
|
200
|
+
consent: Any = False,
|
|
201
|
+
dry_run: bool = False
|
|
202
|
+
) -> Dict[str, Any]:
|
|
195
203
|
"""
|
|
196
204
|
Restores database to pristine baseline, wiping 100% of test data junk.
|
|
205
|
+
Requires explicit consent when dry_run=False. Consent can be a boolean or a
|
|
206
|
+
scoped dictionary bound to target_sandbox.
|
|
197
207
|
"""
|
|
198
208
|
start_time = time.perf_counter()
|
|
199
209
|
try:
|
|
@@ -201,6 +211,58 @@ class DBSandbox:
|
|
|
201
211
|
except ValueError as e:
|
|
202
212
|
return {"status": "ERROR", "message": str(e)}
|
|
203
213
|
|
|
214
|
+
target_path = self.db_path or os.path.join(self.snapshot_dir, "active_test.db")
|
|
215
|
+
|
|
216
|
+
# 1. Dry run preview (Default-safe, zero side effects)
|
|
217
|
+
if dry_run:
|
|
218
|
+
return {
|
|
219
|
+
"status": "dry_run_preview",
|
|
220
|
+
"action": "restore",
|
|
221
|
+
"snapshot_id": clean_id,
|
|
222
|
+
"target_db": target_path,
|
|
223
|
+
"dry_run": True,
|
|
224
|
+
"message": f"DRY-RUN PREVIEW: Would restore database snapshot '{clean_id}' to '{target_path}'. Pass dry_run=False and consent=True to execute."
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
# 2. Authorization / Consent enforcement at action execution boundary
|
|
228
|
+
has_consent = (
|
|
229
|
+
bool(consent)
|
|
230
|
+
or os.environ.get("SYNAPSE_FORCE_RESTORE", "").strip().lower() in ("1", "true", "yes")
|
|
231
|
+
or os.environ.get("PENTEST_CONSENT_ACKNOWLEDGED", "").strip().lower() in ("1", "true", "yes")
|
|
232
|
+
)
|
|
233
|
+
if not has_consent:
|
|
234
|
+
return {
|
|
235
|
+
"status": "ERROR",
|
|
236
|
+
"message": "Destructive database restore requires explicit consent bound to target sandbox. Pass consent=True (or scoped consent dict) or set SYNAPSE_FORCE_RESTORE=1.",
|
|
237
|
+
"snapshot_id": clean_id,
|
|
238
|
+
"target_db": target_path,
|
|
239
|
+
"zero_pollution_guaranteed": False
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
# Scoped consent check: ensure consent for Sandbox A cannot be reused to restore Sandbox B
|
|
243
|
+
if isinstance(consent, dict):
|
|
244
|
+
c_target = consent.get("target_sandbox") or consent.get("target_db")
|
|
245
|
+
if c_target:
|
|
246
|
+
norm_c = os.path.realpath(os.path.abspath(c_target)).lower()
|
|
247
|
+
norm_target = os.path.realpath(os.path.abspath(target_path)).lower()
|
|
248
|
+
if norm_c != norm_target:
|
|
249
|
+
return {
|
|
250
|
+
"status": "ERROR",
|
|
251
|
+
"message": f"Consent target sandbox mismatch: consent granted for '{c_target}', but target is '{target_path}'.",
|
|
252
|
+
"snapshot_id": clean_id,
|
|
253
|
+
"target_db": target_path,
|
|
254
|
+
"zero_pollution_guaranteed": False
|
|
255
|
+
}
|
|
256
|
+
c_action = consent.get("operation") or consent.get("action")
|
|
257
|
+
if c_action and c_action.lower() != "restore":
|
|
258
|
+
return {
|
|
259
|
+
"status": "ERROR",
|
|
260
|
+
"message": f"Consent operation mismatch: consent granted for '{c_action}', but requested operation is 'restore'.",
|
|
261
|
+
"snapshot_id": clean_id,
|
|
262
|
+
"target_db": target_path,
|
|
263
|
+
"zero_pollution_guaranteed": False
|
|
264
|
+
}
|
|
265
|
+
|
|
204
266
|
if os.path.exists(meta_file):
|
|
205
267
|
try:
|
|
206
268
|
with open(meta_file, "r", encoding="utf-8") as f:
|
|
@@ -385,13 +447,61 @@ class DBSandbox:
|
|
|
385
447
|
def audit_and_purge_pollution(
|
|
386
448
|
self,
|
|
387
449
|
known_test_prefixes: Tuple[str, ...] = ("AUTO_", "TEST_", "TEMP_"),
|
|
388
|
-
dry_run: bool = True
|
|
450
|
+
dry_run: bool = True,
|
|
451
|
+
consent: Any = False
|
|
389
452
|
) -> Dict[str, Any]:
|
|
390
453
|
"""
|
|
391
454
|
Scans all tables for orphan records carrying test prefixes and purges them.
|
|
392
455
|
Properly escapes SQL LIKE wildcards ('_' and '%') with an explicit ESCAPE clause
|
|
393
456
|
to avoid deleting real business data (e.g. 'Automotive', 'Tester', 'Tempest').
|
|
457
|
+
Requires explicit consent bound to target sandbox when dry_run=False.
|
|
394
458
|
"""
|
|
459
|
+
target_path = self.db_path or os.path.join(self.snapshot_dir, "active_test.db")
|
|
460
|
+
if not dry_run:
|
|
461
|
+
has_consent = (
|
|
462
|
+
bool(consent)
|
|
463
|
+
or os.environ.get("SYNAPSE_FORCE_PURGE", "").strip().lower() in ("1", "true", "yes")
|
|
464
|
+
or os.environ.get("SYNAPSE_FORCE_RESTORE", "").strip().lower() in ("1", "true", "yes")
|
|
465
|
+
or os.environ.get("PENTEST_CONSENT_ACKNOWLEDGED", "").strip().lower() in ("1", "true", "yes")
|
|
466
|
+
)
|
|
467
|
+
if not has_consent:
|
|
468
|
+
return {
|
|
469
|
+
"status": "ERROR",
|
|
470
|
+
"message": "Destructive database purge requires explicit consent bound to target sandbox. Pass consent=True, --confirm, or set SYNAPSE_FORCE_PURGE=1.",
|
|
471
|
+
"tables_audited": 0,
|
|
472
|
+
"total_purged_rows": 0,
|
|
473
|
+
"purge_details": [],
|
|
474
|
+
"zero_pollution_achieved": False,
|
|
475
|
+
"dry_run": False
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
# Scoped consent check: ensure consent for Sandbox A cannot be reused to purge Sandbox B
|
|
479
|
+
if isinstance(consent, dict):
|
|
480
|
+
c_target = consent.get("target_sandbox") or consent.get("target_db")
|
|
481
|
+
if c_target:
|
|
482
|
+
norm_c = os.path.realpath(os.path.abspath(c_target)).lower()
|
|
483
|
+
norm_target = os.path.realpath(os.path.abspath(target_path)).lower()
|
|
484
|
+
if norm_c != norm_target:
|
|
485
|
+
return {
|
|
486
|
+
"status": "ERROR",
|
|
487
|
+
"message": f"Consent target sandbox mismatch: consent granted for '{c_target}', but target is '{target_path}'.",
|
|
488
|
+
"tables_audited": 0,
|
|
489
|
+
"total_purged_rows": 0,
|
|
490
|
+
"purge_details": [],
|
|
491
|
+
"zero_pollution_achieved": False,
|
|
492
|
+
"dry_run": False
|
|
493
|
+
}
|
|
494
|
+
c_action = consent.get("operation") or consent.get("action")
|
|
495
|
+
if c_action and c_action.lower() not in ("purge", "audit_and_purge"):
|
|
496
|
+
return {
|
|
497
|
+
"status": "ERROR",
|
|
498
|
+
"message": f"Consent operation mismatch: consent granted for '{c_action}', but requested operation is 'purge'.",
|
|
499
|
+
"tables_audited": 0,
|
|
500
|
+
"total_purged_rows": 0,
|
|
501
|
+
"purge_details": [],
|
|
502
|
+
"zero_pollution_achieved": False,
|
|
503
|
+
"dry_run": False
|
|
504
|
+
}
|
|
395
505
|
if not self.db_path:
|
|
396
506
|
candidate = os.path.join(self.snapshot_dir, "active_test.db")
|
|
397
507
|
if os.path.exists(candidate):
|
|
@@ -550,7 +660,7 @@ def wait_for_ready(target: str, strategy: str = "auto", timeout_sec: float = 30.
|
|
|
550
660
|
"error": None,
|
|
551
661
|
}
|
|
552
662
|
last_error = detail
|
|
553
|
-
time.sleep(backoff)
|
|
663
|
+
time.sleep(backoff) # synapse-ignore: HARD_DELAY_ANTI_PATTERN
|
|
554
664
|
backoff = min(backoff * 2, 2.0)
|
|
555
665
|
|
|
556
666
|
return {
|
|
@@ -598,6 +708,8 @@ def main():
|
|
|
598
708
|
help="Preview test records to purge without deleting (default: True)")
|
|
599
709
|
aud_p.add_argument("--apply", "--force", dest="apply", action="store_true", default=False,
|
|
600
710
|
help="Explicitly apply destructive purge to delete matching test records")
|
|
711
|
+
aud_p.add_argument("--confirm", action="store_true", default=False,
|
|
712
|
+
help="Explicit confirmation for destructive purge operation")
|
|
601
713
|
aud_p.add_argument("--json", action="store_true", help="Output JSON format")
|
|
602
714
|
|
|
603
715
|
# Command: wait-ready (Testcontainers-style readiness gate)
|
|
@@ -665,7 +777,7 @@ def main():
|
|
|
665
777
|
print(f"❌ [DB RESTORE BLOCKED] ID: {args.id}")
|
|
666
778
|
print(f" Error: {err_msg}")
|
|
667
779
|
return 1
|
|
668
|
-
res = sandbox.restore_snapshot(args.id)
|
|
780
|
+
res = sandbox.restore_snapshot(args.id, consent=args.confirm or bool(os.environ.get("SYNAPSE_FORCE_RESTORE")))
|
|
669
781
|
if args.json:
|
|
670
782
|
print(json.dumps(res, indent=2))
|
|
671
783
|
else:
|
|
@@ -697,10 +809,43 @@ def main():
|
|
|
697
809
|
effective_dry_run = True if args.dry_run is None else args.dry_run
|
|
698
810
|
if args.apply:
|
|
699
811
|
effective_dry_run = False
|
|
700
|
-
|
|
812
|
+
|
|
813
|
+
if not effective_dry_run:
|
|
814
|
+
has_confirm = (
|
|
815
|
+
args.confirm
|
|
816
|
+
or os.environ.get("SYNAPSE_FORCE_PURGE", "").strip().lower() in ("1", "true", "yes")
|
|
817
|
+
or os.environ.get("SYNAPSE_FORCE_RESTORE", "").strip().lower() in ("1", "true", "yes")
|
|
818
|
+
or os.environ.get("PENTEST_CONSENT_ACKNOWLEDGED", "").strip().lower() in ("1", "true", "yes")
|
|
819
|
+
)
|
|
820
|
+
if not has_confirm:
|
|
821
|
+
err_msg = (
|
|
822
|
+
"Refusing to execute destructive database purge without explicit confirmation. "
|
|
823
|
+
"Pass --confirm (or set SYNAPSE_FORCE_PURGE=1) if target is an isolated sandbox."
|
|
824
|
+
)
|
|
825
|
+
res = {
|
|
826
|
+
"status": "ERROR",
|
|
827
|
+
"message": err_msg,
|
|
828
|
+
"tables_audited": 0,
|
|
829
|
+
"total_purged_rows": 0,
|
|
830
|
+
"purge_details": [],
|
|
831
|
+
"zero_pollution_achieved": False,
|
|
832
|
+
"dry_run": False
|
|
833
|
+
}
|
|
834
|
+
if args.json:
|
|
835
|
+
print(json.dumps(res, indent=2))
|
|
836
|
+
else:
|
|
837
|
+
print("❌ [DB PURGE BLOCKED]")
|
|
838
|
+
print(f" Error: {err_msg}")
|
|
839
|
+
return 1
|
|
840
|
+
|
|
841
|
+
res = sandbox.audit_and_purge_pollution(dry_run=effective_dry_run, consent=args.confirm)
|
|
701
842
|
if args.json:
|
|
702
843
|
print(json.dumps(res, indent=2))
|
|
703
844
|
else:
|
|
845
|
+
if res.get("status") == "ERROR":
|
|
846
|
+
print("❌ [DB PURGE FAILED]")
|
|
847
|
+
print(f" Error: {res.get('message')}")
|
|
848
|
+
return 1
|
|
704
849
|
action_label = "Previewed" if effective_dry_run else "Purged"
|
|
705
850
|
print(f"🧹 [TAINT POLLUTION AUDIT] {action_label} {res['total_purged_rows']} orphan test records.")
|
|
706
851
|
for detail in res.get("purge_details", []):
|
package/tools/debt_harvester.py
CHANGED
|
@@ -29,8 +29,8 @@ if hasattr(sys.stdout, 'reconfigure'):
|
|
|
29
29
|
try:
|
|
30
30
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
31
31
|
sys.stderr.reconfigure(encoding='utf-8')
|
|
32
|
-
except Exception
|
|
33
|
-
|
|
32
|
+
except Exception:
|
|
33
|
+
pass
|
|
34
34
|
|
|
35
35
|
# Default directories to ignore during scan
|
|
36
36
|
IGNORED_DIRS = {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
+
# SPDX-FileCopyrightText: © 2026 Thế Vị (@TeeVee98) <https://github.com/TeeVee98/Synapse-Hub>
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
2
5
|
# -*- coding: utf-8 -*-
|
|
3
6
|
"""
|
|
4
7
|
tools/diagram_architect.py — Standalone Self-Contained SVG & HTML Diagram Builder
|
package/tools/distill_log.py
CHANGED
|
@@ -149,12 +149,16 @@ def distill(
|
|
|
149
149
|
max_lines: int = 40,
|
|
150
150
|
exit_code: Optional[int] = None,
|
|
151
151
|
raw_log_path: Optional[str] = None,
|
|
152
|
-
token_budget: int = 800,
|
|
152
|
+
token_budget: Optional[int] = 800,
|
|
153
153
|
) -> str:
|
|
154
154
|
"""
|
|
155
155
|
Distills raw execution logs down to high-signal failure blocks while guaranteeing
|
|
156
156
|
zero false passes, zero false-positive assertions on info logs, and enforcing token budgets.
|
|
157
157
|
"""
|
|
158
|
+
if token_budget is not None:
|
|
159
|
+
if isinstance(token_budget, bool) or not isinstance(token_budget, int) or token_budget < 0:
|
|
160
|
+
raise ValueError(f"token_budget must be a non-negative integer (>= 0), got {token_budget}")
|
|
161
|
+
|
|
158
162
|
raw_bytes = len(log_text.encode("utf-8"))
|
|
159
163
|
lines = log_text.splitlines()
|
|
160
164
|
total_raw_lines = len(lines)
|
|
@@ -440,13 +444,29 @@ def shrink_tokens(text: str, max_chars_per_line: int = 140) -> str:
|
|
|
440
444
|
return "\n".join(shrunk_lines)
|
|
441
445
|
|
|
442
446
|
|
|
447
|
+
def _non_negative_int(val: str) -> int:
|
|
448
|
+
try:
|
|
449
|
+
ival = int(val)
|
|
450
|
+
except ValueError:
|
|
451
|
+
raise argparse.ArgumentTypeError(f"Invalid integer value: {val!r}")
|
|
452
|
+
if ival < 0:
|
|
453
|
+
raise argparse.ArgumentTypeError(f"token-budget must be a non-negative integer (>= 0), got {ival}")
|
|
454
|
+
return ival
|
|
455
|
+
|
|
456
|
+
|
|
443
457
|
def main():
|
|
444
458
|
parser = argparse.ArgumentParser(description="Distill terminal execution logs into high-signal failure blocks.")
|
|
445
459
|
parser.add_argument("--file", "-f", help="Path to raw log file (reads from stdin if omitted).")
|
|
446
460
|
parser.add_argument("--exit-code", "-e", type=int, default=None, help="Process exit code from test runner.")
|
|
447
461
|
parser.add_argument("--save-raw", "-s", default=None, help="Path to preserve raw log.")
|
|
448
462
|
parser.add_argument("--max-lines", "-m", type=int, default=40, help="Maximum number of output lines.")
|
|
449
|
-
parser.add_argument(
|
|
463
|
+
parser.add_argument(
|
|
464
|
+
"--token-budget",
|
|
465
|
+
"-b",
|
|
466
|
+
type=_non_negative_int,
|
|
467
|
+
default=800,
|
|
468
|
+
help="Maximum token budget for distilled output (must be >= 0).",
|
|
469
|
+
)
|
|
450
470
|
parser.add_argument("--shrink", action="store_true", help="Apply caveman/shrink token compression.")
|
|
451
471
|
args = parser.parse_args()
|
|
452
472
|
|