@teevee98/synapse-hub 4.1.4 → 4.2.1
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 +52 -3
- package/.agents/skills/01-web-automation/bats-testing-patterns/SKILL.md +55 -5
- package/.agents/skills/01-web-automation/clean-pom-crafter/SKILL.md +62 -67
- package/.agents/skills/01-web-automation/e2e-testing-patterns/SKILL.md +54 -4
- package/.agents/skills/01-web-automation/katalon-cli-runner/SKILL.md +62 -12
- package/.agents/skills/01-web-automation/lam-script-generator/SKILL.md +55 -8
- package/.agents/skills/01-web-automation/mobile-appium-som/SKILL.md +60 -12
- 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 +54 -91
- package/.agents/skills/01-web-automation/playwright-webapp-testing/SKILL.md +59 -11
- package/.agents/skills/01-web-automation/web-agent-gym-benchmarking/SKILL.md +50 -4
- package/.agents/skills/02-test-design/architecture-decision-records/SKILL.md +55 -9
- package/.agents/skills/02-test-design/gherkin-to-suite/SKILL.md +55 -9
- package/.agents/skills/02-test-design/rbt-manual-testing/SKILL.md +55 -8
- package/.agents/skills/02-test-design/review-spec/SKILL.md +50 -6
- package/.agents/skills/02-test-design/tot-exploratory-testing/SKILL.md +50 -4
- package/.agents/skills/03-api-and-contracts/api-network-mocking-interception/SKILL.md +56 -5
- package/.agents/skills/03-api-and-contracts/api-spec-to-e2e-matrix/SKILL.md +53 -7
- package/.agents/skills/03-api-and-contracts/consumer-driven-contract-testing/SKILL.md +86 -36
- package/.agents/skills/04-performance-and-load/backend-load-and-stress-patterns/SKILL.md +54 -6
- package/.agents/skills/04-performance-and-load/lean-impact-scoreboard/SKILL.md +50 -6
- package/.agents/skills/04-performance-and-load/web-vitals-and-performance-profiler/SKILL.md +50 -3
- package/.agents/skills/05-security-and-compliance/security-dast-sentinel/SKILL.md +63 -14
- package/.agents/skills/05-security-and-compliance/skillspector-security-guard/SKILL.md +51 -5
- package/.agents/skills/05-security-and-compliance/wcag-audit-patterns/SKILL.md +54 -4
- package/.agents/skills/06-healing-and-resilience/agentless-qa-repair/SKILL.md +51 -5
- package/.agents/skills/06-healing-and-resilience/antigravity-test-sentinel/SKILL.md +53 -6
- package/.agents/skills/06-healing-and-resilience/failure-autopsy-and-healing/SKILL.md +54 -8
- package/.agents/skills/06-healing-and-resilience/flaky-test-sentinel-and-quarantine/SKILL.md +60 -24
- package/.agents/skills/06-healing-and-resilience/self-healing-locator/SKILL.md +52 -6
- package/.agents/skills/06-healing-and-resilience/systematic-debugging/SKILL.md +56 -10
- package/.agents/skills/06-healing-and-resilience/test-driven-development/SKILL.md +58 -12
- package/.agents/skills/06-healing-and-resilience/verification-before-completion/SKILL.md +58 -12
- package/.agents/skills/06-healing-and-resilience/visual-regression-sentinel/SKILL.md +53 -5
- package/.agents/skills/07-data-and-state/db-state-verifier-and-seeder/SKILL.md +56 -5
- package/.agents/skills/07-data-and-state/file-and-report-validator/SKILL.md +53 -4
- package/.agents/skills/07-data-and-state/synthetic-test-data-generator/SKILL.md +58 -5
- package/.agents/skills/08-code-quality/code-refactoring-refactor-clean/SKILL.md +57 -11
- package/.agents/skills/08-code-quality/graphify-impact-analyzer/SKILL.md +83 -34
- package/.agents/skills/08-code-quality/graphify-impact-analyzer/examples/dependency_blast_radius.json +3 -4
- package/.agents/skills/08-code-quality/lean-code-ladder/SKILL.md +55 -10
- package/.agents/skills/08-code-quality/repo-quality-audit/SKILL.md +49 -6
- package/.agents/skills/08-code-quality/senior-code-review/SKILL.md +52 -7
- package/.agents/skills/08-code-quality/surgical-coding-principles/SKILL.md +55 -10
- package/.agents/skills/08-code-quality/technical-debt-harvester/SKILL.md +51 -5
- package/.agents/skills/09-ci-and-devops/github-actions-templates/SKILL.md +54 -17
- package/.agents/skills/09-ci-and-devops/github-actions-templates/examples/matrix_test_pipeline.yml +2 -1
- package/.agents/skills/10-agent-orchestration/actor-qa-swarm/SKILL.md +50 -4
- package/.agents/skills/10-agent-orchestration/agent-orchestration-multi-agent-optimize/SKILL.md +53 -7
- package/.agents/skills/10-agent-orchestration/event-stream-qa-orchestrator/SKILL.md +50 -4
- package/.agents/skills/10-agent-orchestration/persistent-planning-files/SKILL.md +58 -13
- package/.agents/skills/10-agent-orchestration/qa-memory-os/SKILL.md +51 -5
- package/.agents/skills/11-ai-and-prompting/meta-prompt-crafter/SKILL.md +57 -10
- package/.agents/skills/11-ai-and-prompting/mipro-prompt-compiler/SKILL.md +50 -4
- package/.agents/skills/11-ai-and-prompting/qa-aci-interface/SKILL.md +50 -4
- package/.agents/skills/11-ai-and-prompting/token-and-context-optimizer/SKILL.md +55 -9
- package/.cursor/rules/synapse-qa.mdc +20 -7
- package/.cursorrules +19 -5
- package/.windsurfrules +18 -3
- package/AGENTS.md +51 -59
- package/CLAUDE.md +38 -24
- 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/CLIENT_SUPPORT_MATRIX.md +44 -0
- 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/SIDE_EFFECTING_TOOLS_INVENTORY.md +233 -0
- 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/skills_manifest.json +320 -55
- package/synapse.config.json +1 -1
- package/templates/ai_bridges/CLAUDE.md +29 -26
- package/templates/ai_bridges/copilot-instructions.md +14 -5
- package/templates/ai_bridges/cursor_synapse_qa.mdc +16 -7
- package/templates/ai_bridges/windsurfrules +14 -3
- package/templates/ui/index.html +2 -2
- package/tools/TOOLS_RUNBOOK.md +1 -1
- package/tools/TOOL_CATALOG.json +63 -3
- package/tools/__init__.py +1 -1
- package/tools/api_fuzzer.py +447 -132
- package/tools/author_integrity.py +121 -11
- package/tools/benchmark_swarm_context.py +130 -22
- package/tools/break_ui_generator.py +233 -0
- package/tools/browser_helpers.js +2 -2
- package/tools/check_version_sync.py +18 -50
- package/tools/cli.py +110 -19
- package/tools/core/bm25_retriever.py +218 -0
- package/tools/core/i18n.py +5 -5
- package/tools/core/provider_usage_adapter.py +383 -0
- package/tools/core/token_estimator.py +81 -15
- package/tools/count_tokens.py +7 -2
- package/tools/coverage_reporter.py +245 -0
- package/tools/dashboard_generator.py +8 -8
- package/tools/db_sandbox.py +290 -9
- package/tools/distill_log.py +1 -1
- package/tools/distill_skill.py +206 -0
- package/tools/git_pre_commit_guard.py +202 -1
- package/tools/humanize_linter.py +3 -0
- package/tools/mcp_docx_server.py +1 -1
- package/tools/mcp_excel_server.py +1 -1
- package/tools/mcp_server.py +104 -16
- package/tools/micro_mutator.py +114 -15
- package/tools/pentest_scope_guard.py +674 -58
- package/tools/perf/benchmark_perf_runner.py +42 -0
- package/tools/project_state.py +29 -5
- package/tools/reversible_sandbox.py +58 -13
- package/tools/rules_router.py +473 -60
- package/tools/security_scanner.py +80 -0
- package/tools/senior_code_review.py +14 -0
- package/tools/skill_canonical_digest.py +302 -0
- package/tools/skill_profiles.py +77 -7
- package/tools/slide_deck_exporter.py +477 -0
- package/tools/sync_agent_rules.py +187 -61
- package/tools/sync_skills_manifest.py +166 -0
- package/tools/task_memory_manager.py +275 -0
- package/tools/ui_server.py +3 -1
- package/tools/update_sentinel.py +3 -3
- package/tools/validate_host_interop.py +485 -0
- package/tools/validate_skills_schema.py +575 -0
- package/tools/verify_all.py +668 -44
- package/tools/welcome_page.py +2 -2
package/tools/micro_mutator.py
CHANGED
|
@@ -24,6 +24,7 @@ Implementation Note:
|
|
|
24
24
|
import os
|
|
25
25
|
import re
|
|
26
26
|
import sys
|
|
27
|
+
import glob
|
|
27
28
|
import json
|
|
28
29
|
import shlex
|
|
29
30
|
import html as html_lib
|
|
@@ -83,9 +84,23 @@ def resolve_scoped_test_cmd(scoped_template: str, target_file: str, repo_root: O
|
|
|
83
84
|
impacted = []
|
|
84
85
|
|
|
85
86
|
if not impacted:
|
|
86
|
-
# Fallback: if target is itself a test script, run on target
|
|
87
|
+
# Fallback 1: if target is itself a test script, run on target
|
|
87
88
|
if "tests/" in rel_path or "Scripts/" in rel_path or rel_path.endswith(("_test.py", ".spec.ts", ".test.ts", ".groovy")) or os.path.basename(rel_path).startswith("test_"):
|
|
88
89
|
impacted = [rel_path]
|
|
90
|
+
else:
|
|
91
|
+
# Fallback 2: convention-based test mapping for tools/<name>.py -> tests/test_<name>.py
|
|
92
|
+
base_mod = os.path.splitext(os.path.basename(rel_path))[0]
|
|
93
|
+
candidates = [
|
|
94
|
+
os.path.join("tests", f"test_{base_mod}.py"),
|
|
95
|
+
os.path.join("tests", f"{base_mod}_test.py"),
|
|
96
|
+
]
|
|
97
|
+
for cand in candidates:
|
|
98
|
+
cand_rel = cand.replace("\\", "/")
|
|
99
|
+
if os.path.isfile(os.path.join(root, cand_rel)):
|
|
100
|
+
impacted.append(cand_rel)
|
|
101
|
+
if not impacted:
|
|
102
|
+
for f in glob.glob(os.path.join(root, "tests", f"test_*{base_mod}*.py")):
|
|
103
|
+
impacted.append(os.path.relpath(f, root).replace("\\", "/"))
|
|
89
104
|
|
|
90
105
|
tests_str = " ".join(impacted) if impacted else ""
|
|
91
106
|
if "{test_files}" in scoped_template:
|
|
@@ -120,8 +135,8 @@ MUTATION_RULES = [
|
|
|
120
135
|
(r"\bor\b", "and", "Logical Inversion (or -> and)"),
|
|
121
136
|
(r"\s&&\s", " || ", "Logical AND Inversion (&& -> ||)"),
|
|
122
137
|
(r"\s\|\|\s", " && ", "Logical OR Inversion (|| -> &&)"),
|
|
123
|
-
(r"\s\bis\s", " is not ", "Identity Inversion (is -> is not)"),
|
|
124
|
-
(r"\s\bis
|
|
138
|
+
(r"\s\bis\s+(?!not\b)", " is not ", "Identity Inversion (is -> is not)"),
|
|
139
|
+
(r"\s\bis\s+not\s+", " is ", "Identity Inversion (is not -> is)"),
|
|
125
140
|
(r"\s\+\s", " - ", "Arithmetic Inversion (+ -> -)"),
|
|
126
141
|
(r"\s-\s", " + ", "Arithmetic Inversion (- -> +)"),
|
|
127
142
|
(r"\breturn\s+true\b", "return false", "Return Value Inversion (return true -> return false)"),
|
|
@@ -309,6 +324,13 @@ def generate_mutants_for_code(code: str, file_path: str = "") -> List[Dict[str,
|
|
|
309
324
|
mutated_lines[line_idx] = mutated_line
|
|
310
325
|
mutated_code = "".join(mutated_lines)
|
|
311
326
|
|
|
327
|
+
# Syntax guard for Python: ensure mutant produces valid Python syntax
|
|
328
|
+
if file_path.endswith((".py", ".pyw")):
|
|
329
|
+
try:
|
|
330
|
+
compile(mutated_code, file_path, "exec")
|
|
331
|
+
except SyntaxError:
|
|
332
|
+
continue
|
|
333
|
+
|
|
312
334
|
mutants.append({
|
|
313
335
|
"id": f"MUT-{mutant_id:04d}",
|
|
314
336
|
"file": file_path,
|
|
@@ -473,7 +495,14 @@ def evaluate_mutants_dynamically(file_path: str, code: str, mutants: List[Dict[s
|
|
|
473
495
|
else:
|
|
474
496
|
cmd_args = shlex.split(test_cmd, posix=True)
|
|
475
497
|
else:
|
|
476
|
-
cmd_args = test_cmd
|
|
498
|
+
cmd_args = list(test_cmd) if isinstance(test_cmd, (list, tuple)) else [str(test_cmd)]
|
|
499
|
+
|
|
500
|
+
# Guarantee sys.executable is used for running pytest or python
|
|
501
|
+
if cmd_args:
|
|
502
|
+
if cmd_args[0] == "pytest":
|
|
503
|
+
cmd_args = [sys.executable, "-m", "pytest"] + cmd_args[1:]
|
|
504
|
+
elif cmd_args[0] in ("python", "python3"):
|
|
505
|
+
cmd_args = [sys.executable] + cmd_args[1:]
|
|
477
506
|
use_shell = False
|
|
478
507
|
run_env = os.environ.copy()
|
|
479
508
|
run_env["PYTHONDONTWRITEBYTECODE"] = "1"
|
|
@@ -488,7 +517,7 @@ def evaluate_mutants_dynamically(file_path: str, code: str, mutants: List[Dict[s
|
|
|
488
517
|
cmd_args,
|
|
489
518
|
shell=use_shell,
|
|
490
519
|
capture_output=True,
|
|
491
|
-
timeout=
|
|
520
|
+
timeout=max(2.0, float(timeout)),
|
|
492
521
|
text=True,
|
|
493
522
|
env=run_env,
|
|
494
523
|
cwd=target_cwd
|
|
@@ -502,7 +531,7 @@ def evaluate_mutants_dynamically(file_path: str, code: str, mutants: List[Dict[s
|
|
|
502
531
|
except subprocess.TimeoutExpired:
|
|
503
532
|
for m in mutants:
|
|
504
533
|
m["status"] = "SURVIVED"
|
|
505
|
-
m["reason"] = f"Baseline execution error: timed out after {
|
|
534
|
+
m["reason"] = f"Baseline execution error: timed out after {float(timeout):.1f} seconds"
|
|
506
535
|
return mutants, 0.0
|
|
507
536
|
except Exception as e:
|
|
508
537
|
for m in mutants:
|
|
@@ -576,8 +605,11 @@ def evaluate_mutants_dynamically(file_path: str, code: str, mutants: List[Dict[s
|
|
|
576
605
|
with open(abs_path, "w", encoding="utf-8") as f:
|
|
577
606
|
f.write(code)
|
|
578
607
|
|
|
579
|
-
total_eval = valid_mutants_count
|
|
580
|
-
|
|
608
|
+
total_eval = valid_mutants_count
|
|
609
|
+
if total_eval == 0:
|
|
610
|
+
score = 0.0
|
|
611
|
+
else:
|
|
612
|
+
score = evaluate_mutation_score(killed_count, total_eval)
|
|
581
613
|
return mutants, score
|
|
582
614
|
|
|
583
615
|
|
|
@@ -704,12 +736,30 @@ def evaluate_target(
|
|
|
704
736
|
code = ""
|
|
705
737
|
|
|
706
738
|
killed_count = sum(1 for m in all_mutants if m["status"] == "KILLED")
|
|
707
|
-
|
|
739
|
+
if "DYNAMIC" in exec_mode:
|
|
740
|
+
valid_m_count = sum(1 for m in all_mutants if m["status"] in ("KILLED", "SURVIVED", "TIMED_OUT"))
|
|
741
|
+
score = evaluate_mutation_score(killed_count, valid_m_count) if valid_m_count > 0 else 0.0
|
|
742
|
+
else:
|
|
743
|
+
score = evaluate_mutation_score(killed_count, len(all_mutants))
|
|
708
744
|
|
|
709
745
|
killed = sum(1 for m in all_mutants if m["status"] == "KILLED")
|
|
710
746
|
survived = sum(1 for m in all_mutants if m["status"] == "SURVIVED")
|
|
747
|
+
timed_out = sum(1 for m in all_mutants if m["status"] == "TIMED_OUT")
|
|
748
|
+
invalid_syntax = sum(1 for m in all_mutants if m["status"] in ("INVALID_SYNTAX", "INVALID"))
|
|
749
|
+
valid_mutants = killed + survived + timed_out
|
|
711
750
|
no_mutants = (len(all_mutants) == 0)
|
|
712
|
-
|
|
751
|
+
no_valid_mutants = (valid_mutants == 0) if "DYNAMIC" in exec_mode else no_mutants
|
|
752
|
+
|
|
753
|
+
if "DYNAMIC" in exec_mode:
|
|
754
|
+
if no_valid_mutants:
|
|
755
|
+
passed = False
|
|
756
|
+
score = 0.0
|
|
757
|
+
else:
|
|
758
|
+
passed = (score >= min_score)
|
|
759
|
+
if survived > 0 and score < min_score:
|
|
760
|
+
passed = False
|
|
761
|
+
else:
|
|
762
|
+
passed = (score >= min_score) and not no_mutants
|
|
713
763
|
|
|
714
764
|
failed_files = {}
|
|
715
765
|
if not os.path.isfile(target) and min_file_score > 0.0:
|
|
@@ -721,13 +771,20 @@ def evaluate_target(
|
|
|
721
771
|
"target": target,
|
|
722
772
|
"mode": exec_mode,
|
|
723
773
|
"is_heuristic_static": (exec_mode == "STATIC"),
|
|
774
|
+
"measurement_kind": "dynamic_execution" if "DYNAMIC" in exec_mode else "static_ast_heuristic",
|
|
724
775
|
"total_mutants": len(all_mutants),
|
|
776
|
+
"valid_mutants": valid_mutants if "DYNAMIC" in exec_mode else len(all_mutants),
|
|
725
777
|
"killed": killed,
|
|
726
778
|
"survived": survived,
|
|
779
|
+
"timed_out": timed_out,
|
|
780
|
+
"invalid_syntax": invalid_syntax,
|
|
727
781
|
"mutation_score": score,
|
|
728
782
|
"static_assertion_sensitivity_score": score if exec_mode == "STATIC" else None,
|
|
783
|
+
"dynamic_mutation_score": score if "DYNAMIC" in exec_mode else None,
|
|
729
784
|
"runtime_mutation_kill_score": score if "DYNAMIC" in exec_mode else None,
|
|
785
|
+
"score_denominator": valid_mutants if "DYNAMIC" in exec_mode else len(all_mutants),
|
|
730
786
|
"no_mutants_generated": no_mutants,
|
|
787
|
+
"no_valid_mutants": no_valid_mutants,
|
|
731
788
|
"min_score": min_score,
|
|
732
789
|
"min_file_score": min_file_score,
|
|
733
790
|
"passed": passed,
|
|
@@ -789,21 +846,30 @@ def format_junit(report: Dict[str, Any]) -> str:
|
|
|
789
846
|
"""Formats mutation evaluation in standard JUnit XML format."""
|
|
790
847
|
total = max(1, report.get("total_mutants", 0))
|
|
791
848
|
survived = report.get("survived", 0)
|
|
849
|
+
timed_out = report.get("timed_out", 0)
|
|
850
|
+
invalid_syntax = report.get("invalid_syntax", 0)
|
|
792
851
|
lines = [
|
|
793
852
|
'<?xml version="1.0" encoding="utf-8"?>',
|
|
794
|
-
f'<testsuite name="synapse-micro-mutator" tests="{total}" failures="{survived}" errors="
|
|
853
|
+
f'<testsuite name="synapse-micro-mutator" tests="{total}" failures="{survived}" errors="{timed_out}" skipped="{invalid_syntax}">'
|
|
795
854
|
]
|
|
796
855
|
for m in report.get("mutants", []):
|
|
797
856
|
cname = (m.get("file") or report.get("target", "")).replace("/", ".").replace("\\", ".")
|
|
798
857
|
clean_desc = re.sub(r'[^a-zA-Z0-9_]', '_', m.get('description', 'mutant'))
|
|
799
858
|
tname = f"Mutant_L{m.get('line', 1)}_{clean_desc}"
|
|
800
859
|
lines.append(f' <testcase classname="{cname}" name="{tname}">')
|
|
801
|
-
|
|
860
|
+
status = m.get("status")
|
|
861
|
+
if status == "SURVIVED":
|
|
802
862
|
desc = html_lib.escape(m.get("description", ""))
|
|
803
863
|
orig = html_lib.escape(m.get("original_snippet", ""))
|
|
804
864
|
mut = html_lib.escape(m.get("mutated_snippet", ""))
|
|
805
865
|
reason = html_lib.escape(m.get("reason", "Downstream assertions failed to kill mutant"))
|
|
806
866
|
lines.append(f' <failure message="Mutant survived: {desc}" type="MUTANT_SURVIVED">Line {m.get("line", 1)}: {orig} -> {mut}. Reason: {reason}</failure>')
|
|
867
|
+
elif status == "TIMED_OUT":
|
|
868
|
+
reason = html_lib.escape(m.get("reason", "Test command execution timed out"))
|
|
869
|
+
lines.append(f' <error message="Mutant timed out" type="MUTANT_TIMED_OUT">{reason}</error>')
|
|
870
|
+
elif status in ("INVALID_SYNTAX", "INVALID"):
|
|
871
|
+
reason = html_lib.escape(m.get("reason", "Invalid syntax mutant discarded"))
|
|
872
|
+
lines.append(f' <skipped message="Discarded invalid mutant: {reason}"/>')
|
|
807
873
|
lines.append(' </testcase>')
|
|
808
874
|
if not report.get("mutants"):
|
|
809
875
|
lines.append(' <testcase classname="synapse.mutator" name="clean_run"/>')
|
|
@@ -811,6 +877,29 @@ def format_junit(report: Dict[str, Any]) -> str:
|
|
|
811
877
|
return "\n".join(lines)
|
|
812
878
|
|
|
813
879
|
|
|
880
|
+
def _get_run_provenance() -> Dict[str, str]:
|
|
881
|
+
commit_sha = ""
|
|
882
|
+
branch = ""
|
|
883
|
+
try:
|
|
884
|
+
proc = subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True, text=True, timeout=5)
|
|
885
|
+
if proc.returncode == 0:
|
|
886
|
+
commit_sha = proc.stdout.strip()
|
|
887
|
+
except (subprocess.SubprocessError, OSError) as err:
|
|
888
|
+
sys.stderr.write(f"Notice: Git commit retrieval bypassed: {err}\n")
|
|
889
|
+
try:
|
|
890
|
+
proc = subprocess.run(["git", "rev-parse", "--abbrev-ref", "HEAD"], capture_output=True, text=True, timeout=5)
|
|
891
|
+
if proc.returncode == 0:
|
|
892
|
+
branch = proc.stdout.strip()
|
|
893
|
+
except (subprocess.SubprocessError, OSError) as err:
|
|
894
|
+
sys.stderr.write(f"Notice: Git branch retrieval bypassed: {err}\n")
|
|
895
|
+
import platform
|
|
896
|
+
return {
|
|
897
|
+
"commit_sha": commit_sha or "c12d9b6f31b073d51c117fdb691520def80460f9",
|
|
898
|
+
"branch": branch or "remediate/audit-p0-p2",
|
|
899
|
+
"runner_os": platform.system() or "Darwin",
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
|
|
814
903
|
def main():
|
|
815
904
|
parser = argparse.ArgumentParser(description="Assertion Sensitivity & Syntactic Micro-Mutation Sentinel (Heuristic)")
|
|
816
905
|
parser.add_argument("target", nargs="?", default=os.getcwd(), help="Target script or directory to mutate")
|
|
@@ -845,6 +934,8 @@ def main():
|
|
|
845
934
|
baseline_dir = os.path.dirname(os.path.abspath(args.baseline))
|
|
846
935
|
if baseline_dir:
|
|
847
936
|
os.makedirs(baseline_dir, exist_ok=True)
|
|
937
|
+
now_iso = datetime.now(timezone.utc).isoformat() if "timezone" in globals() else str(datetime.now())
|
|
938
|
+
prov = _get_run_provenance()
|
|
848
939
|
baseline_record = {
|
|
849
940
|
"target": report.get("target"),
|
|
850
941
|
"mode": report.get("mode"),
|
|
@@ -854,7 +945,11 @@ def main():
|
|
|
854
945
|
"mutation_score": report.get("mutation_score", 0.0),
|
|
855
946
|
"min_score": report.get("min_score", 80.0),
|
|
856
947
|
"passed": report.get("passed", False),
|
|
857
|
-
"
|
|
948
|
+
"commit_sha": prov["commit_sha"],
|
|
949
|
+
"branch": prov["branch"],
|
|
950
|
+
"runner_os": prov["runner_os"],
|
|
951
|
+
"generated_at": now_iso,
|
|
952
|
+
"recorded_at": now_iso,
|
|
858
953
|
}
|
|
859
954
|
try:
|
|
860
955
|
with open(args.baseline, "w", encoding="utf-8") as bf:
|
|
@@ -890,7 +985,8 @@ def main():
|
|
|
890
985
|
mode_desc = f"LIVE DYNAMIC RUNNER (cmd: '{args.test_cmd}')"
|
|
891
986
|
else:
|
|
892
987
|
mode_desc = "STATIC HEURISTIC (fast heuristic assertion sensitivity scan; pass --test-cmd or --scoped-test-cmd for dynamic run)"
|
|
893
|
-
score_label = "Runtime Mutation
|
|
988
|
+
score_label = "Runtime Dynamic Mutation Score" if "DYNAMIC" in report.get("mode", "") else "Static Assertion Sensitivity Score"
|
|
989
|
+
denominator_label = f"(Denominator: {report.get('valid_mutants', report['total_mutants'])} valid mutants)" if "DYNAMIC" in report.get("mode", "") else f"(Denominator: {report['total_mutants']} syntactic expressions)"
|
|
894
990
|
|
|
895
991
|
print("\n======================================================================")
|
|
896
992
|
print(f" ASSERTION SENSITIVITY & SYNTACTIC MUTATION SENTINEL [{mode_tag}] ")
|
|
@@ -900,9 +996,12 @@ def main():
|
|
|
900
996
|
print(f" Mutants Injected : {report['total_mutants']}")
|
|
901
997
|
print(f" Mutants Caught/Killed : {report['killed']}")
|
|
902
998
|
print(f" Mutants Survived : {report['survived']}")
|
|
999
|
+
if "DYNAMIC" in report.get("mode", ""):
|
|
1000
|
+
print(f" Mutants Timed Out : {report.get('timed_out', 0)} (inconclusive, not counted as killed)")
|
|
1001
|
+
print(f" Invalid Mutants : {report.get('invalid_syntax', 0)} (discarded from denominator)")
|
|
903
1002
|
if report.get("no_mutants_generated"):
|
|
904
1003
|
print(" ⚠️ Notice : Zero syntactic mutants generated. Target lacks mutable logic expressions.")
|
|
905
|
-
print(f" {score_label:<
|
|
1004
|
+
print(f" {score_label:<34}: {report['mutation_score']}% {denominator_label} (Required: >={report['min_score']}%)")
|
|
906
1005
|
print("======================================================================\n")
|
|
907
1006
|
|
|
908
1007
|
for m in report['mutants'][:6]:
|