@teevee98/synapse-hub 3.9.1 → 4.0.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 +1 -1
- package/.agents/rules/mandatory-playwright-live.md +21 -5
- package/.agents/rules/mobile_appium_rules.md +14 -39
- package/.agents/rules/security_testing_rules.md +24 -0
- package/.agents/rules/stack-auto-router.md +24 -0
- package/.agents/rules/systematic-debugging.md +9 -8
- package/.agents/skills/{playwright-webapp-testing → 01-web-automation/playwright-webapp-testing}/SKILL.md +18 -1
- package/.agents/skills/05-security-and-compliance/wcag-audit-patterns/SKILL.md +116 -0
- package/.agents/skills/{db-state-verifier-and-seeder → 07-data-and-state/db-state-verifier-and-seeder}/SKILL.md +9 -4
- package/.agents/workflows/generate_manual_testcases_rbt.md +1 -1
- package/AGENTS.md +2 -1
- package/Dockerfile +14 -6
- package/README.en.md +2 -2
- package/README.md +2 -2
- package/agentskills.json +16 -2
- package/docs/ARCHITECTURE.en.md +1 -1
- package/docs/ARCHITECTURE.md +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/scripts/install_global_plugin.ps1 +19 -2
- package/scripts/install_global_plugin.sh +21 -2
- package/skills_manifest.json +514 -511
- package/synapse.config.json +1 -1
- package/tools/TOOL_CATALOG.json +1 -1
- package/tools/__init__.py +1 -1
- package/tools/ast_cache.py +173 -0
- package/tools/browser_helpers.js +2 -2
- package/tools/build_consolidated_report.py +1 -1
- package/tools/cache_resolver.py +11 -6
- package/tools/cli.py +16 -3
- package/tools/core/file_lock.py +106 -8
- package/tools/core/process_supervisor.py +65 -11
- package/tools/core/telemetry.py +32 -3
- package/tools/dashboard_generator.py +6 -6
- package/tools/db_sandbox.py +53 -10
- package/tools/git_pre_commit_guard.py +6 -4
- package/tools/infer_linter.py +2 -2
- package/tools/lint_ai_docs.py +19 -5
- 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/package_release.py +29 -5
- package/tools/pinpoint_failure.py +14 -2
- package/tools/reversible_sandbox.py +85 -7
- package/tools/rules_router.py +373 -0
- package/tools/ui_server.py +1 -1
- package/tools/update_sentinel.py +3 -3
- package/tools/verify_all.py +43 -1
- package/tools/wcag_audit.py +1 -1
- package/tools/welcome_page.py +1 -1
- package/.agents/skills/wcag-audit-patterns/SKILL.md +0 -77
- /package/.agents/skills/{auth-session-and-cookie-manager → 01-web-automation/auth-session-and-cookie-manager}/SKILL.md +0 -0
- /package/.agents/skills/{auth-session-and-cookie-manager → 01-web-automation/auth-session-and-cookie-manager}/examples/multi_role_auth_matrix.md +0 -0
- /package/.agents/skills/{auth-session-and-cookie-manager → 01-web-automation/auth-session-and-cookie-manager}/examples/storage_state_sample.json +0 -0
- /package/.agents/skills/{bats-testing-patterns → 01-web-automation/bats-testing-patterns}/SKILL.md +0 -0
- /package/.agents/skills/{bats-testing-patterns → 01-web-automation/bats-testing-patterns}/examples/cli_runner_test.bats +0 -0
- /package/.agents/skills/{bats-testing-patterns → 01-web-automation/bats-testing-patterns}/resources/implementation-playbook.md +0 -0
- /package/.agents/skills/{clean-pom-crafter → 01-web-automation/clean-pom-crafter}/SKILL.md +0 -0
- /package/.agents/skills/{clean-pom-crafter → 01-web-automation/clean-pom-crafter}/examples/standard_test_case.groovy +0 -0
- /package/.agents/skills/{clean-pom-crafter → 01-web-automation/clean-pom-crafter}/references/pom_patterns.groovy +0 -0
- /package/.agents/skills/{e2e-testing-patterns → 01-web-automation/e2e-testing-patterns}/SKILL.md +0 -0
- /package/.agents/skills/{e2e-testing-patterns → 01-web-automation/e2e-testing-patterns}/examples/playwright_sharded_config.ts +0 -0
- /package/.agents/skills/{e2e-testing-patterns → 01-web-automation/e2e-testing-patterns}/resources/implementation-playbook.md +0 -0
- /package/.agents/skills/{katalon-cli-runner → 01-web-automation/katalon-cli-runner}/SKILL.md +0 -0
- /package/.agents/skills/{katalon-cli-runner → 01-web-automation/katalon-cli-runner}/examples/headless_kre_exec.sh +0 -0
- /package/.agents/skills/{katalon-cli-runner → 01-web-automation/katalon-cli-runner}/references/groovy-patterns.md +0 -0
- /package/.agents/skills/{katalon-cli-runner → 01-web-automation/katalon-cli-runner}/references/katalon-api.md +0 -0
- /package/.agents/skills/{katalon-cli-runner → 01-web-automation/katalon-cli-runner}/references/runner_commands.md +0 -0
- /package/.agents/skills/{lam-script-generator → 01-web-automation/lam-script-generator}/SKILL.md +0 -0
- /package/.agents/skills/{lam-script-generator → 01-web-automation/lam-script-generator}/examples/user_story_sample.md +0 -0
- /package/.agents/skills/{mobile-appium-som → 01-web-automation/mobile-appium-som}/SKILL.md +0 -0
- /package/.agents/skills/{mobile-appium-som → 01-web-automation/mobile-appium-som}/examples/BaseScreen.java +0 -0
- /package/.agents/skills/{mobile-appium-som → 01-web-automation/mobile-appium-som}/examples/LoginScreen.java +0 -0
- /package/.agents/skills/{mobile-appium-som → 01-web-automation/mobile-appium-som}/examples/TC_MobileLogin.java +0 -0
- /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/SKILL.md +0 -0
- /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/examples/live_probe_script.js +0 -0
- /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/references/advanced_superpowers.md +0 -0
- /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/references/compact_accessibility_snapshots.md +0 -0
- /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/references/recipes.md +0 -0
- /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/references/swarm_orchestration.md +0 -0
- /package/.agents/skills/{playwright-webapp-testing → 01-web-automation/playwright-webapp-testing}/examples/server_lifecycle_playwright.py +0 -0
- /package/.agents/skills/{web-agent-gym-benchmarking → 01-web-automation/web-agent-gym-benchmarking}/SKILL.md +0 -0
- /package/.agents/skills/{web-agent-gym-benchmarking → 01-web-automation/web-agent-gym-benchmarking}/examples/benchmark_report_sample.json +0 -0
- /package/.agents/skills/{web-agent-gym-benchmarking → 01-web-automation/web-agent-gym-benchmarking}/examples/enterprise_tasks_suite.json +0 -0
- /package/.agents/skills/{architecture-decision-records → 02-test-design/architecture-decision-records}/SKILL.md +0 -0
- /package/.agents/skills/{architecture-decision-records → 02-test-design/architecture-decision-records}/examples/0001-record-architecture-decisions.md +0 -0
- /package/.agents/skills/{gherkin-to-suite → 02-test-design/gherkin-to-suite}/SKILL.md +0 -0
- /package/.agents/skills/{gherkin-to-suite → 02-test-design/gherkin-to-suite}/examples/checkout.feature +0 -0
- /package/.agents/skills/{gherkin-to-suite → 02-test-design/gherkin-to-suite}/examples/suite_report_sample.json +0 -0
- /package/.agents/skills/{rbt-manual-testing → 02-test-design/rbt-manual-testing}/SKILL.md +0 -0
- /package/.agents/skills/{rbt-manual-testing → 02-test-design/rbt-manual-testing}/examples/checkout_rbt_manual_suite.md +0 -0
- /package/.agents/skills/{rbt-manual-testing → 02-test-design/rbt-manual-testing}/references/field_validation_checklist.md +0 -0
- /package/.agents/skills/{review-spec → 02-test-design/review-spec}/SKILL.md +0 -0
- /package/.agents/skills/{review-spec → 02-test-design/review-spec}/examples/pocock_grilling_decision_rubric.md +0 -0
- /package/.agents/skills/{review-spec → 02-test-design/review-spec}/examples/sample_spec_review.md +0 -0
- /package/.agents/skills/{tot-exploratory-testing → 02-test-design/tot-exploratory-testing}/SKILL.md +0 -0
- /package/.agents/skills/{tot-exploratory-testing → 02-test-design/tot-exploratory-testing}/examples/payment_gateway_tot_tree.json +0 -0
- /package/.agents/skills/{tot-exploratory-testing → 02-test-design/tot-exploratory-testing}/examples/tot_graph_sample.json +0 -0
- /package/.agents/skills/{api-network-mocking-interception → 03-api-and-contracts/api-network-mocking-interception}/SKILL.md +0 -0
- /package/.agents/skills/{api-network-mocking-interception → 03-api-and-contracts/api-network-mocking-interception}/examples/network_route_stub.json +0 -0
- /package/.agents/skills/{api-spec-to-e2e-matrix → 03-api-and-contracts/api-spec-to-e2e-matrix}/SKILL.md +0 -0
- /package/.agents/skills/{api-spec-to-e2e-matrix → 03-api-and-contracts/api-spec-to-e2e-matrix}/examples/sample_openapi.json +0 -0
- /package/.agents/skills/{consumer-driven-contract-testing → 03-api-and-contracts/consumer-driven-contract-testing}/SKILL.md +0 -0
- /package/.agents/skills/{consumer-driven-contract-testing → 03-api-and-contracts/consumer-driven-contract-testing}/examples/order_service_pact.json +0 -0
- /package/.agents/skills/{backend-load-and-stress-patterns → 04-performance-and-load/backend-load-and-stress-patterns}/SKILL.md +0 -0
- /package/.agents/skills/{backend-load-and-stress-patterns → 04-performance-and-load/backend-load-and-stress-patterns}/examples/k6_load_test_sample.js +0 -0
- /package/.agents/skills/{backend-load-and-stress-patterns → 04-performance-and-load/backend-load-and-stress-patterns}/references/k6_load_template.js +0 -0
- /package/.agents/skills/{lean-impact-scoreboard → 04-performance-and-load/lean-impact-scoreboard}/SKILL.md +0 -0
- /package/.agents/skills/{lean-impact-scoreboard → 04-performance-and-load/lean-impact-scoreboard}/examples/sample_benchmark_gain.md +0 -0
- /package/.agents/skills/{lean-impact-scoreboard → 04-performance-and-load/lean-impact-scoreboard}/examples/sample_scoreboard.md +0 -0
- /package/.agents/skills/{web-vitals-and-performance-profiler → 04-performance-and-load/web-vitals-and-performance-profiler}/SKILL.md +0 -0
- /package/.agents/skills/{web-vitals-and-performance-profiler → 04-performance-and-load/web-vitals-and-performance-profiler}/examples/cwv_budget_policy.json +0 -0
- /package/.agents/skills/{web-vitals-and-performance-profiler → 04-performance-and-load/web-vitals-and-performance-profiler}/examples/playwright_cwv_profiler_fixture.ts +0 -0
- /package/.agents/skills/{security-dast-sentinel → 05-security-and-compliance/security-dast-sentinel}/SKILL.md +0 -0
- /package/.agents/skills/{security-dast-sentinel → 05-security-and-compliance/security-dast-sentinel}/examples/dast_scan_config.json +0 -0
- /package/.agents/skills/{security-dast-sentinel → 05-security-and-compliance/security-dast-sentinel}/references/AI-AND-LLM.md +0 -0
- /package/.agents/skills/{security-dast-sentinel → 05-security-and-compliance/security-dast-sentinel}/references/ATTACK-CLASSES.md +0 -0
- /package/.agents/skills/{security-dast-sentinel → 05-security-and-compliance/security-dast-sentinel}/references/dast_recipes.ts +0 -0
- /package/.agents/skills/{skillspector-security-guard → 05-security-and-compliance/skillspector-security-guard}/SKILL.md +0 -0
- /package/.agents/skills/{skillspector-security-guard → 05-security-and-compliance/skillspector-security-guard}/examples/audit_threat_vectors_report.json +0 -0
- /package/.agents/skills/{skillspector-security-guard → 05-security-and-compliance/skillspector-security-guard}/examples/safe_mcp_config.json +0 -0
- /package/.agents/skills/{wcag-audit-patterns → 05-security-and-compliance/wcag-audit-patterns}/examples/wcag_compliance_checklist.json +0 -0
- /package/.agents/skills/{wcag-audit-patterns → 05-security-and-compliance/wcag-audit-patterns}/resources/implementation-playbook.md +0 -0
- /package/.agents/skills/{agentless-qa-repair → 06-healing-and-resilience/agentless-qa-repair}/SKILL.md +0 -0
- /package/.agents/skills/{agentless-qa-repair → 06-healing-and-resilience/agentless-qa-repair}/examples/healing_report_sample.json +0 -0
- /package/.agents/skills/{agentless-qa-repair → 06-healing-and-resilience/agentless-qa-repair}/examples/three_phase_repair_workflow.md +0 -0
- /package/.agents/skills/{antigravity-test-sentinel → 06-healing-and-resilience/antigravity-test-sentinel}/SKILL.md +0 -0
- /package/.agents/skills/{antigravity-test-sentinel → 06-healing-and-resilience/antigravity-test-sentinel}/examples/dod_gate_policy.json +0 -0
- /package/.agents/skills/{antigravity-test-sentinel → 06-healing-and-resilience/antigravity-test-sentinel}/examples/sprint_dod_enforcement.md +0 -0
- /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/SKILL.md +0 -0
- /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/examples/closed_loop_healing_walkthrough.md +0 -0
- /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/examples/sample_junit_failure.xml +0 -0
- /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/references/healing_matrix.md +0 -0
- /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/references/qa_investigation_protocol.md +0 -0
- /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/scripts/triage_failures.sh +0 -0
- /package/.agents/skills/{flaky-test-sentinel-and-quarantine → 06-healing-and-resilience/flaky-test-sentinel-and-quarantine}/SKILL.md +0 -0
- /package/.agents/skills/{flaky-test-sentinel-and-quarantine → 06-healing-and-resilience/flaky-test-sentinel-and-quarantine}/examples/quarantine_registry.json +0 -0
- /package/.agents/skills/{self-healing-locator → 06-healing-and-resilience/self-healing-locator}/SKILL.md +0 -0
- /package/.agents/skills/{self-healing-locator → 06-healing-and-resilience/self-healing-locator}/examples/aom_diff_sample.json +0 -0
- /package/.agents/skills/{systematic-debugging → 06-healing-and-resilience/systematic-debugging}/SKILL.md +0 -0
- /package/.agents/skills/{systematic-debugging → 06-healing-and-resilience/systematic-debugging}/examples/four_phase_case.md +0 -0
- /package/.agents/skills/{test-driven-development → 06-healing-and-resilience/test-driven-development}/SKILL.md +0 -0
- /package/.agents/skills/{test-driven-development → 06-healing-and-resilience/test-driven-development}/examples/red_green_refactor_qa.md +0 -0
- /package/.agents/skills/{verification-before-completion → 06-healing-and-resilience/verification-before-completion}/SKILL.md +0 -0
- /package/.agents/skills/{verification-before-completion → 06-healing-and-resilience/verification-before-completion}/examples/evidence_log_example.md +0 -0
- /package/.agents/skills/{visual-regression-sentinel → 06-healing-and-resilience/visual-regression-sentinel}/SKILL.md +0 -0
- /package/.agents/skills/{visual-regression-sentinel → 06-healing-and-resilience/visual-regression-sentinel}/examples/visual_mask_rules.json +0 -0
- /package/.agents/skills/{db-state-verifier-and-seeder → 07-data-and-state/db-state-verifier-and-seeder}/examples/db_fixture_seed.json +0 -0
- /package/.agents/skills/{file-and-report-validator → 07-data-and-state/file-and-report-validator}/SKILL.md +0 -0
- /package/.agents/skills/{file-and-report-validator → 07-data-and-state/file-and-report-validator}/examples/sample_export_schema.json +0 -0
- /package/.agents/skills/{synthetic-test-data-generator → 07-data-and-state/synthetic-test-data-generator}/SKILL.md +0 -0
- /package/.agents/skills/{synthetic-test-data-generator → 07-data-and-state/synthetic-test-data-generator}/examples/idempotent_data_recipe.json +0 -0
- /package/.agents/skills/{code-refactoring-refactor-clean → 08-code-quality/code-refactoring-refactor-clean}/SKILL.md +0 -0
- /package/.agents/skills/{code-refactoring-refactor-clean → 08-code-quality/code-refactoring-refactor-clean}/examples/refactored_page_sample.groovy +0 -0
- /package/.agents/skills/{code-refactoring-refactor-clean → 08-code-quality/code-refactoring-refactor-clean}/examples/refactored_playwright_pom.ts +0 -0
- /package/.agents/skills/{code-refactoring-refactor-clean → 08-code-quality/code-refactoring-refactor-clean}/resources/implementation-playbook.md +0 -0
- /package/.agents/skills/{graphify-impact-analyzer → 08-code-quality/graphify-impact-analyzer}/SKILL.md +0 -0
- /package/.agents/skills/{graphify-impact-analyzer → 08-code-quality/graphify-impact-analyzer}/examples/dependency_blast_radius.json +0 -0
- /package/.agents/skills/{lean-code-ladder → 08-code-quality/lean-code-ladder}/SKILL.md +0 -0
- /package/.agents/skills/{lean-code-ladder → 08-code-quality/lean-code-ladder}/examples/ladder_walkthrough.md +0 -0
- /package/.agents/skills/{repo-quality-audit → 08-code-quality/repo-quality-audit}/SKILL.md +0 -0
- /package/.agents/skills/{repo-quality-audit → 08-code-quality/repo-quality-audit}/examples/sample_audit_walkthrough.md +0 -0
- /package/.agents/skills/{repo-quality-audit → 08-code-quality/repo-quality-audit}/examples/sample_repo_audit.md +0 -0
- /package/.agents/skills/{senior-code-review → 08-code-quality/senior-code-review}/SKILL.md +0 -0
- /package/.agents/skills/{senior-code-review → 08-code-quality/senior-code-review}/examples/sample_review_walkthrough.md +0 -0
- /package/.agents/skills/{surgical-coding-principles → 08-code-quality/surgical-coding-principles}/SKILL.md +0 -0
- /package/.agents/skills/{surgical-coding-principles → 08-code-quality/surgical-coding-principles}/examples/surgical_vs_scope_creep.md +0 -0
- /package/.agents/skills/{technical-debt-harvester → 08-code-quality/technical-debt-harvester}/SKILL.md +0 -0
- /package/.agents/skills/{technical-debt-harvester → 08-code-quality/technical-debt-harvester}/examples/sample_debt_ledger.md +0 -0
- /package/.agents/skills/{technical-debt-harvester → 08-code-quality/technical-debt-harvester}/examples/sample_ledger_output.md +0 -0
- /package/.agents/skills/{github-actions-templates → 09-ci-and-devops/github-actions-templates}/SKILL.md +0 -0
- /package/.agents/skills/{github-actions-templates → 09-ci-and-devops/github-actions-templates}/examples/matrix_test_pipeline.yml +0 -0
- /package/.agents/skills/{actor-qa-swarm → 10-agent-orchestration/actor-qa-swarm}/SKILL.md +0 -0
- /package/.agents/skills/{actor-qa-swarm → 10-agent-orchestration/actor-qa-swarm}/examples/broker_sharding_sample.json +0 -0
- /package/.agents/skills/{agent-orchestration-multi-agent-optimize → 10-agent-orchestration/agent-orchestration-multi-agent-optimize}/SKILL.md +0 -0
- /package/.agents/skills/{agent-orchestration-multi-agent-optimize → 10-agent-orchestration/agent-orchestration-multi-agent-optimize}/examples/swarm_workload_config.json +0 -0
- /package/.agents/skills/{event-stream-qa-orchestrator → 10-agent-orchestration/event-stream-qa-orchestrator}/SKILL.md +0 -0
- /package/.agents/skills/{event-stream-qa-orchestrator → 10-agent-orchestration/event-stream-qa-orchestrator}/examples/timeline_sample.jsonl +0 -0
- /package/.agents/skills/{persistent-planning-files → 10-agent-orchestration/persistent-planning-files}/SKILL.md +0 -0
- /package/.agents/skills/{persistent-planning-files → 10-agent-orchestration/persistent-planning-files}/examples/task_plan_example.md +0 -0
- /package/.agents/skills/{qa-memory-os → 10-agent-orchestration/qa-memory-os}/SKILL.md +0 -0
- /package/.agents/skills/{qa-memory-os → 10-agent-orchestration/qa-memory-os}/examples/archival_memory_sample.json +0 -0
- /package/.agents/skills/{meta-prompt-crafter → 11-ai-and-prompting/meta-prompt-crafter}/SKILL.md +0 -0
- /package/.agents/skills/{meta-prompt-crafter → 11-ai-and-prompting/meta-prompt-crafter}/examples/qa_prompt_template.md +0 -0
- /package/.agents/skills/{mipro-prompt-compiler → 11-ai-and-prompting/mipro-prompt-compiler}/SKILL.md +0 -0
- /package/.agents/skills/{mipro-prompt-compiler → 11-ai-and-prompting/mipro-prompt-compiler}/examples/compiled_module_sample.json +0 -0
- /package/.agents/skills/{mipro-prompt-compiler → 11-ai-and-prompting/mipro-prompt-compiler}/examples/dspy_assertion_optimizer_case.md +0 -0
- /package/.agents/skills/{qa-aci-interface → 11-ai-and-prompting/qa-aci-interface}/SKILL.md +0 -0
- /package/.agents/skills/{qa-aci-interface → 11-ai-and-prompting/qa-aci-interface}/examples/surgical_code_window_walkthrough.md +0 -0
- /package/.agents/skills/{qa-aci-interface → 11-ai-and-prompting/qa-aci-interface}/examples/surgical_edit_sample.json +0 -0
- /package/.agents/skills/{token-and-context-optimizer → 11-ai-and-prompting/token-and-context-optimizer}/SKILL.md +0 -0
- /package/.agents/skills/{token-and-context-optimizer → 11-ai-and-prompting/token-and-context-optimizer}/examples/distilled_log_sample.txt +0 -0
- /package/.agents/skills/{token-and-context-optimizer → 11-ai-and-prompting/token-and-context-optimizer}/references/context_engineering_guide.md +0 -0
package/synapse.config.json
CHANGED
package/tools/TOOL_CATALOG.json
CHANGED
package/tools/__init__.py
CHANGED
|
@@ -0,0 +1,173 @@
|
|
|
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/ast_cache.py — AST Dataflow Pre-Validation Cache (Boost B3)
|
|
8
|
+
----------------------------------------------------------------
|
|
9
|
+
Provides high-speed persistent caching for AST syntax integrity, undefined variable
|
|
10
|
+
checks (F821), and syntactic mutation scans.
|
|
11
|
+
Uses mtime_ns + file size fast invalidation with SHA-256 fallback to eliminate
|
|
12
|
+
redundant AST parsing across recurring verification runs.
|
|
13
|
+
Uses cross-platform file locking to guarantee concurrency safety under multi-agent swarms.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import argparse
|
|
19
|
+
import hashlib
|
|
20
|
+
import json
|
|
21
|
+
import os
|
|
22
|
+
import sys
|
|
23
|
+
from typing import Any, Callable, Dict, List, Optional, Tuple
|
|
24
|
+
|
|
25
|
+
# Ensure repository root is on sys.path for direct script execution
|
|
26
|
+
_REPO_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
27
|
+
if _REPO_ROOT not in sys.path:
|
|
28
|
+
sys.path.insert(0, _REPO_ROOT)
|
|
29
|
+
|
|
30
|
+
# Import cross-platform advisory file lock
|
|
31
|
+
try:
|
|
32
|
+
from tools.core.file_lock import locked_json_read, locked_json_write
|
|
33
|
+
except ImportError:
|
|
34
|
+
try:
|
|
35
|
+
from core.file_lock import locked_json_read, locked_json_write
|
|
36
|
+
except ImportError:
|
|
37
|
+
# Fallback in case tools is executed without root in sys.path
|
|
38
|
+
sys.path.insert(0, os.path.dirname(__file__))
|
|
39
|
+
from core.file_lock import locked_json_read, locked_json_write
|
|
40
|
+
|
|
41
|
+
DEFAULT_CACHE_REL = os.path.join(".synapse", "ast_cache.json")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class ASTValidationCache:
|
|
45
|
+
"""
|
|
46
|
+
Persistent key-value cache for Python AST verification results.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
def __init__(self, repo_root: Optional[str] = None, cache_path: Optional[str] = None):
|
|
50
|
+
if repo_root is None:
|
|
51
|
+
repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
52
|
+
self.repo_root = os.path.abspath(repo_root)
|
|
53
|
+
|
|
54
|
+
if cache_path is None:
|
|
55
|
+
self.cache_path = os.path.join(self.repo_root, DEFAULT_CACHE_REL)
|
|
56
|
+
else:
|
|
57
|
+
self.cache_path = os.path.abspath(cache_path)
|
|
58
|
+
|
|
59
|
+
self._entries: Dict[str, Dict[str, Any]] = {}
|
|
60
|
+
self._dirty = False
|
|
61
|
+
self.load()
|
|
62
|
+
|
|
63
|
+
def load(self) -> None:
|
|
64
|
+
"""Loads cached AST records from disk under advisory shared lock."""
|
|
65
|
+
if os.path.isfile(self.cache_path):
|
|
66
|
+
try:
|
|
67
|
+
data = locked_json_read(self.cache_path, timeout=5.0)
|
|
68
|
+
if isinstance(data, dict):
|
|
69
|
+
self._entries = data.get("entries", {})
|
|
70
|
+
except Exception:
|
|
71
|
+
self._entries = {}
|
|
72
|
+
else:
|
|
73
|
+
self._entries = {}
|
|
74
|
+
self._dirty = False
|
|
75
|
+
|
|
76
|
+
def save(self) -> None:
|
|
77
|
+
"""Flushes modified cache records to disk under exclusive atomic lock with disk-merge."""
|
|
78
|
+
if not self._dirty:
|
|
79
|
+
return
|
|
80
|
+
os.makedirs(os.path.dirname(self.cache_path), exist_ok=True)
|
|
81
|
+
# Read and merge existing entries to prevent concurrent worker/swarm overwrites
|
|
82
|
+
current_entries: Dict[str, Any] = {}
|
|
83
|
+
if os.path.isfile(self.cache_path):
|
|
84
|
+
try:
|
|
85
|
+
disk_data = locked_json_read(self.cache_path, timeout=5.0)
|
|
86
|
+
if isinstance(disk_data, dict):
|
|
87
|
+
current_entries = disk_data.get("entries", {})
|
|
88
|
+
except Exception:
|
|
89
|
+
current_entries = {}
|
|
90
|
+
current_entries.update(self._entries)
|
|
91
|
+
payload = {
|
|
92
|
+
"version": "1.0",
|
|
93
|
+
"repo_root": self.repo_root,
|
|
94
|
+
"entries": current_entries,
|
|
95
|
+
}
|
|
96
|
+
try:
|
|
97
|
+
locked_json_write(self.cache_path, payload, indent=2, timeout=5.0, atomic=True)
|
|
98
|
+
self._entries = current_entries
|
|
99
|
+
self._dirty = False
|
|
100
|
+
except Exception as err:
|
|
101
|
+
_ = err
|
|
102
|
+
|
|
103
|
+
def get_signature(self, file_path: str) -> Optional[Tuple[int, int]]:
|
|
104
|
+
"""Returns (mtime_ns, size) for fast freshness check."""
|
|
105
|
+
try:
|
|
106
|
+
st = os.stat(file_path)
|
|
107
|
+
return (st.st_mtime_ns, st.st_size)
|
|
108
|
+
except OSError:
|
|
109
|
+
return None
|
|
110
|
+
|
|
111
|
+
def get_cached_result(self, rel_path: str, mtime_ns: int, size: int) -> Optional[Dict[str, Any]]:
|
|
112
|
+
"""Retrieves cached result if signature matches."""
|
|
113
|
+
entry = self._entries.get(rel_path)
|
|
114
|
+
if entry is None:
|
|
115
|
+
return None
|
|
116
|
+
if entry.get("mtime_ns") == mtime_ns and entry.get("size") == size:
|
|
117
|
+
return entry.get("data")
|
|
118
|
+
return None
|
|
119
|
+
|
|
120
|
+
def put_result(self, rel_path: str, mtime_ns: int, size: int, data: Dict[str, Any]) -> None:
|
|
121
|
+
"""Records a new validation outcome in memory."""
|
|
122
|
+
self._entries[rel_path] = {
|
|
123
|
+
"mtime_ns": mtime_ns,
|
|
124
|
+
"size": size,
|
|
125
|
+
"data": data,
|
|
126
|
+
}
|
|
127
|
+
self._dirty = True
|
|
128
|
+
|
|
129
|
+
def clear(self) -> None:
|
|
130
|
+
"""Clears memory and persisted cache."""
|
|
131
|
+
self._entries.clear()
|
|
132
|
+
self._dirty = False
|
|
133
|
+
os.makedirs(os.path.dirname(self.cache_path), exist_ok=True)
|
|
134
|
+
payload = {
|
|
135
|
+
"version": "1.0",
|
|
136
|
+
"repo_root": self.repo_root,
|
|
137
|
+
"entries": {},
|
|
138
|
+
}
|
|
139
|
+
try:
|
|
140
|
+
locked_json_write(self.cache_path, payload, indent=2, timeout=5.0, atomic=True)
|
|
141
|
+
except Exception as err:
|
|
142
|
+
_ = err
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
# Module-level singleton helper
|
|
146
|
+
_GLOBAL_CACHE: Optional[ASTValidationCache] = None
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def get_ast_cache(repo_root: Optional[str] = None) -> ASTValidationCache:
|
|
150
|
+
"""Returns or initializes the process-wide AST cache."""
|
|
151
|
+
global _GLOBAL_CACHE
|
|
152
|
+
if _GLOBAL_CACHE is None:
|
|
153
|
+
_GLOBAL_CACHE = ASTValidationCache(repo_root=repo_root)
|
|
154
|
+
return _GLOBAL_CACHE
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def main():
|
|
158
|
+
parser = argparse.ArgumentParser(description="AST Dataflow Pre-Validation Cache (Boost B3)")
|
|
159
|
+
parser.add_argument("--clear", action="store_true", help="Clear persisted AST cache")
|
|
160
|
+
parser.add_argument("--stats", action="store_true", help="Print cache statistics")
|
|
161
|
+
args = parser.parse_args()
|
|
162
|
+
|
|
163
|
+
cache = get_ast_cache()
|
|
164
|
+
if args.clear:
|
|
165
|
+
cache.clear()
|
|
166
|
+
print("[AST CACHE] Cache cleared successfully.")
|
|
167
|
+
else:
|
|
168
|
+
entries = cache._entries
|
|
169
|
+
print(f"[AST CACHE] Path: {cache.cache_path} | Entries: {len(entries)}")
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
if __name__ == "__main__":
|
|
173
|
+
main()
|
package/tools/browser_helpers.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
(function () {
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
|
-
if (window.__qa && window.__qa.__version === '
|
|
16
|
+
if (window.__qa && window.__qa.__version === '4.0.0') {
|
|
17
17
|
return window.__qa;
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
const qa = {
|
|
50
|
-
__version: '
|
|
50
|
+
__version: '4.0.0',
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* 1. Smart Action Batching
|
|
@@ -165,7 +165,7 @@ def build_consolidated_html():
|
|
|
165
165
|
5: "<code>tools/runaway_stopper.py</code> (RunawaySentinel) · Bất biến Pure Headless Playwright CDP 1920x1080 (AGENTS.md)",
|
|
166
166
|
6: "<code>tools/skill_collision_guard.py</code> (Gate 9 Addy Osmani Pattern) · Phân cấp 4 Persona FSM trong <code>.agents/skills/</code>",
|
|
167
167
|
7: "<code>tools/mechanical_ui_gate.py</code> (Kiểm toán WCAG AA >= 4.5:1, thang chữ typographic) · <code>tests/test_ecosystem_integrations.py</code>",
|
|
168
|
-
8: "<code>.agents/skills/wcag-audit-patterns</code> · <code>.agents/skills/backend-load-and-stress-patterns</code>",
|
|
168
|
+
8: "<code>.agents/skills/05-security-and-compliance/wcag-audit-patterns</code> · <code>.agents/skills/04-performance-and-load/backend-load-and-stress-patterns</code>",
|
|
169
169
|
9: "<code>.github/copilot-instructions.md</code> (Quy tắc Clean POM và Smart Wait theo phạm vi file hẹp)",
|
|
170
170
|
10: "<code>skills-lock.json</code> & <code>.skill-lock.json</code> v3 (Đăng ký 53 skills cho Vercel/Cursor/Antigravity)",
|
|
171
171
|
11: "Bảng màu Dark Studio chuẩn WCAG AA và Typography Scale tích hợp trong báo cáo hợp nhất",
|
package/tools/cache_resolver.py
CHANGED
|
@@ -96,24 +96,29 @@ def djb2_hash(s: str) -> str:
|
|
|
96
96
|
|
|
97
97
|
def compute_error_fingerprint(error_type: str, error_msg: str, stack_anchor: str = "") -> str:
|
|
98
98
|
"""
|
|
99
|
-
Computes a deterministic, normalized fingerprint hash for an error.
|
|
100
|
-
Strips volatile elements (timestamps, hex addresses, line numbers) so semantically
|
|
101
|
-
identical errors across test runs produce the identical fingerprint.
|
|
99
|
+
Computes a deterministic, normalized fingerprint hash for an error (Boost B5).
|
|
100
|
+
Strips volatile elements (timestamps, hex addresses, line numbers, durations) so semantically
|
|
101
|
+
identical errors across test runs produce the identical deterministic DJB2 fingerprint.
|
|
102
102
|
"""
|
|
103
103
|
norm_type = (error_type or "").strip().lower()
|
|
104
104
|
msg = error_msg or ""
|
|
105
105
|
# Strip hex memory addresses
|
|
106
106
|
msg = re.sub(r'0x[0-9a-fA-F]+', '0xADDR', msg)
|
|
107
|
-
# Strip ISO/standard timestamps
|
|
107
|
+
# Strip ISO/standard timestamps (with or without date)
|
|
108
108
|
msg = re.sub(r'\b\d{4}-\d{2}-\d{2}[T\s]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?\b', 'TIMESTAMP', msg)
|
|
109
|
-
|
|
109
|
+
msg = re.sub(r'\b\d{2}:\d{2}:\d{2}(?:\.\d+)?\b', 'TIMESTAMP', msg)
|
|
110
|
+
# Strip execution durations like 3000ms or 2.5s
|
|
111
|
+
msg = re.sub(r'\b\d+(?:\.\d+)?(?:ms|s)\b', 'DUR', msg)
|
|
112
|
+
# Strip variable line numbers in filenames like "file.py:123" or "line 42"
|
|
110
113
|
msg = re.sub(r':\d+\b', ':LINE', msg)
|
|
114
|
+
msg = re.sub(r'\bline \d+\b', 'line LINE', msg, flags=re.IGNORECASE)
|
|
111
115
|
# Collapse whitespace
|
|
112
116
|
msg = re.sub(r'\s+', ' ', msg).strip()[:200]
|
|
113
117
|
|
|
114
|
-
anchor = (stack_anchor or "").strip().lower()
|
|
118
|
+
anchor = (stack_anchor or "").strip().lower().replace('\\', '/')
|
|
115
119
|
if anchor:
|
|
116
120
|
anchor = re.sub(r':\d+\b', ':LINE', anchor)
|
|
121
|
+
anchor = re.sub(r'\bline \d+\b', 'line LINE', anchor, flags=re.IGNORECASE)
|
|
117
122
|
raw = f"{norm_type}:{msg}@{anchor}"
|
|
118
123
|
else:
|
|
119
124
|
raw = f"{norm_type}:{msg}"
|
package/tools/cli.py
CHANGED
|
@@ -99,7 +99,7 @@ def cmd_set_lang(args):
|
|
|
99
99
|
def cmd_version(args):
|
|
100
100
|
"""Displays the current hub version, skill catalog count, and license information."""
|
|
101
101
|
manifest_path = os.path.join(REPO_ROOT, "skills_manifest.json")
|
|
102
|
-
version = "
|
|
102
|
+
version = "4.0.0"
|
|
103
103
|
if os.path.exists(manifest_path):
|
|
104
104
|
try:
|
|
105
105
|
import json
|
|
@@ -552,6 +552,12 @@ def cmd_wcag_audit(args):
|
|
|
552
552
|
sys.exit(wcag_main())
|
|
553
553
|
|
|
554
554
|
|
|
555
|
+
def cmd_rules_router(args):
|
|
556
|
+
from rules_router import main as router_main
|
|
557
|
+
sys.argv = _forward_subcommand_args(args)
|
|
558
|
+
sys.exit(router_main())
|
|
559
|
+
|
|
560
|
+
|
|
555
561
|
def cmd_lookup_tc(args):
|
|
556
562
|
from lookup_tc import main as tc_main
|
|
557
563
|
sys.argv = _forward_subcommand_args(args)
|
|
@@ -680,14 +686,14 @@ def cmd_trend(args):
|
|
|
680
686
|
|
|
681
687
|
def _hub_version():
|
|
682
688
|
manifest_path = os.path.join(REPO_ROOT, "skills_manifest.json")
|
|
683
|
-
version = "
|
|
689
|
+
version = "4.0.0"
|
|
684
690
|
if os.path.exists(manifest_path):
|
|
685
691
|
try:
|
|
686
692
|
import json
|
|
687
693
|
with open(manifest_path, "r", encoding="utf-8") as f:
|
|
688
694
|
version = json.load(f).get("version", version)
|
|
689
695
|
except (OSError, json.JSONDecodeError):
|
|
690
|
-
version = "
|
|
696
|
+
version = "4.0.0"
|
|
691
697
|
return version
|
|
692
698
|
|
|
693
699
|
|
|
@@ -1189,6 +1195,13 @@ def _register_audit_and_inspection_commands(subparsers, lang: Optional[str] = No
|
|
|
1189
1195
|
p_wcag.add_argument("target", nargs="?", default=".", help=_lh("Target HTML file or directory to audit", "Tệp HTML hoặc thư mục cần kiểm toán WCAG", lang))
|
|
1190
1196
|
p_wcag.set_defaults(func=cmd_wcag_audit)
|
|
1191
1197
|
|
|
1198
|
+
# rules-router (Boost B2)
|
|
1199
|
+
p_router = subparsers.add_parser("rules-router", aliases=["route-rules"], help=_lh("Progressive Rules Router & Token Optimizer", "Định tuyến quy tắc thông minh & tối ưu token", lang))
|
|
1200
|
+
p_router.add_argument("workspace", nargs="?", default=".", help=_lh("Target workspace directory to inspect", "Thư mục dự án cần phân tích stack", lang))
|
|
1201
|
+
p_router.add_argument("--json", action="store_true", help=_lh("Output machine-readable JSON format", "Xuất định dạng JSON cho máy đọc", lang))
|
|
1202
|
+
p_router.add_argument("--summary", action="store_true", help=_lh("Output concise 1-line summary", "Xuất tóm tắt 1 dòng ngắn gọn", lang))
|
|
1203
|
+
p_router.set_defaults(func=cmd_rules_router)
|
|
1204
|
+
|
|
1192
1205
|
# impact
|
|
1193
1206
|
p_impact = subparsers.add_parser("impact", help=t("cmd_impact", lang=lang))
|
|
1194
1207
|
p_impact.set_defaults(func=cmd_impact)
|
package/tools/core/file_lock.py
CHANGED
|
@@ -30,6 +30,105 @@ if sys.platform != "win32":
|
|
|
30
30
|
else:
|
|
31
31
|
import msvcrt # type: ignore
|
|
32
32
|
|
|
33
|
+
# Win32 Native Locking Constants (Boost B1)
|
|
34
|
+
LOCKFILE_FAIL_IMMEDIATELY = 0x00000001
|
|
35
|
+
LOCKFILE_EXCLUSIVE_LOCK = 0x00000002
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
import ctypes
|
|
39
|
+
from ctypes import wintypes
|
|
40
|
+
_HAS_CTYPES = True
|
|
41
|
+
except ImportError:
|
|
42
|
+
ctypes = None # type: ignore
|
|
43
|
+
wintypes = None # type: ignore
|
|
44
|
+
_HAS_CTYPES = False
|
|
45
|
+
|
|
46
|
+
if _HAS_CTYPES:
|
|
47
|
+
class _OVERLAPPED(ctypes.Structure):
|
|
48
|
+
_fields_ = [
|
|
49
|
+
("Internal", getattr(wintypes, "ULONG_PTR", ctypes.c_size_t)),
|
|
50
|
+
("InternalHigh", getattr(wintypes, "ULONG_PTR", ctypes.c_size_t)),
|
|
51
|
+
("Offset", getattr(wintypes, "DWORD", ctypes.c_ulong)),
|
|
52
|
+
("OffsetHigh", getattr(wintypes, "DWORD", ctypes.c_ulong)),
|
|
53
|
+
("hEvent", getattr(wintypes, "HANDLE", ctypes.c_void_p)),
|
|
54
|
+
]
|
|
55
|
+
else:
|
|
56
|
+
_OVERLAPPED = None # type: ignore
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _win32_lock(fd: int, shared: bool = False) -> bool:
|
|
60
|
+
"""
|
|
61
|
+
Acquires an advisory file lock on Windows using native Win32 LockFileEx via ctypes.
|
|
62
|
+
Provides genuine shared (LOCKFILE_FAIL_IMMEDIATELY) and exclusive
|
|
63
|
+
(LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY) locks with an OVERLAPPED structure.
|
|
64
|
+
Gracefully falls back to msvcrt.locking if ctypes or LockFileEx is unavailable.
|
|
65
|
+
"""
|
|
66
|
+
msvcrt_mod = sys.modules.get("msvcrt")
|
|
67
|
+
use_ctypes = _HAS_CTYPES and hasattr(ctypes, "windll") and hasattr(ctypes.windll, "kernel32")
|
|
68
|
+
if use_ctypes:
|
|
69
|
+
try:
|
|
70
|
+
handle = msvcrt_mod.get_osfhandle(fd) if msvcrt_mod and hasattr(msvcrt_mod, "get_osfhandle") else fd
|
|
71
|
+
flags = LOCKFILE_FAIL_IMMEDIATELY
|
|
72
|
+
if not shared:
|
|
73
|
+
flags |= LOCKFILE_EXCLUSIVE_LOCK
|
|
74
|
+
overlapped = _OVERLAPPED()
|
|
75
|
+
res = ctypes.windll.kernel32.LockFileEx(
|
|
76
|
+
ctypes.c_void_p(handle),
|
|
77
|
+
ctypes.c_ulong(flags),
|
|
78
|
+
ctypes.c_ulong(0),
|
|
79
|
+
ctypes.c_ulong(1),
|
|
80
|
+
ctypes.c_ulong(0),
|
|
81
|
+
ctypes.byref(overlapped),
|
|
82
|
+
)
|
|
83
|
+
if not res:
|
|
84
|
+
get_last_error = getattr(ctypes, "GetLastError", lambda: 0)
|
|
85
|
+
err = get_last_error()
|
|
86
|
+
raise OSError(err, f"LockFileEx failed with error code {err}")
|
|
87
|
+
return True
|
|
88
|
+
except (AttributeError, TypeError, ValueError) as exc:
|
|
89
|
+
# Fall through to msvcrt fallback if ctypes kernel32 LockFileEx is missing or incompatible
|
|
90
|
+
_ = exc
|
|
91
|
+
|
|
92
|
+
# Graceful fallback to msvcrt.locking (exclusive lock only)
|
|
93
|
+
if msvcrt_mod is not None:
|
|
94
|
+
os.lseek(fd, 0, os.SEEK_SET)
|
|
95
|
+
msvcrt_mod.locking(fd, msvcrt_mod.LK_NBLCK, 1)
|
|
96
|
+
return True
|
|
97
|
+
raise OSError("Neither Win32 ctypes nor msvcrt is available for file locking.")
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _win32_unlock(fd: int) -> bool:
|
|
101
|
+
"""
|
|
102
|
+
Releases an advisory file lock on Windows using native Win32 UnlockFileEx via ctypes.
|
|
103
|
+
Falls back to msvcrt.locking with LK_UNLCK if ctypes is unavailable.
|
|
104
|
+
"""
|
|
105
|
+
msvcrt_mod = sys.modules.get("msvcrt")
|
|
106
|
+
use_ctypes = _HAS_CTYPES and hasattr(ctypes, "windll") and hasattr(ctypes.windll, "kernel32")
|
|
107
|
+
if use_ctypes:
|
|
108
|
+
try:
|
|
109
|
+
handle = msvcrt_mod.get_osfhandle(fd) if msvcrt_mod and hasattr(msvcrt_mod, "get_osfhandle") else fd
|
|
110
|
+
overlapped = _OVERLAPPED()
|
|
111
|
+
res = ctypes.windll.kernel32.UnlockFileEx(
|
|
112
|
+
ctypes.c_void_p(handle),
|
|
113
|
+
ctypes.c_ulong(0),
|
|
114
|
+
ctypes.c_ulong(1),
|
|
115
|
+
ctypes.c_ulong(0),
|
|
116
|
+
ctypes.byref(overlapped),
|
|
117
|
+
)
|
|
118
|
+
return bool(res)
|
|
119
|
+
except (AttributeError, TypeError, ValueError) as exc:
|
|
120
|
+
_ = exc
|
|
121
|
+
|
|
122
|
+
# Graceful fallback to msvcrt.locking
|
|
123
|
+
if msvcrt_mod is not None:
|
|
124
|
+
try:
|
|
125
|
+
os.lseek(fd, 0, os.SEEK_SET)
|
|
126
|
+
msvcrt_mod.locking(fd, msvcrt_mod.LK_UNLCK, 1)
|
|
127
|
+
return True
|
|
128
|
+
except OSError:
|
|
129
|
+
return False
|
|
130
|
+
return False
|
|
131
|
+
|
|
33
132
|
|
|
34
133
|
class FileLockTimeoutError(TimeoutError):
|
|
35
134
|
"""Raised when acquiring a file lock exceeds the allocated timeout."""
|
|
@@ -69,10 +168,13 @@ class FileLock:
|
|
|
69
168
|
fcntl.flock(self._fd, mode | fcntl.LOCK_NB)
|
|
70
169
|
else:
|
|
71
170
|
# Ensure at least 1 byte exists to lock on Windows
|
|
72
|
-
|
|
73
|
-
os.
|
|
171
|
+
try:
|
|
172
|
+
if os.fstat(self._fd).st_size == 0:
|
|
173
|
+
os.write(self._fd, b"\x00")
|
|
174
|
+
except (OSError, PermissionError) as err:
|
|
175
|
+
_ = err
|
|
74
176
|
os.lseek(self._fd, 0, os.SEEK_SET)
|
|
75
|
-
|
|
177
|
+
_win32_lock(self._fd, shared=self.shared)
|
|
76
178
|
return self
|
|
77
179
|
except (BlockingIOError, OSError, PermissionError):
|
|
78
180
|
if self._fd is not None:
|
|
@@ -94,11 +196,7 @@ class FileLock:
|
|
|
94
196
|
if sys.platform != "win32":
|
|
95
197
|
fcntl.flock(self._fd, fcntl.LOCK_UN)
|
|
96
198
|
else:
|
|
97
|
-
|
|
98
|
-
os.lseek(self._fd, 0, os.SEEK_SET)
|
|
99
|
-
msvcrt.locking(self._fd, msvcrt.LK_UNLCK, 1)
|
|
100
|
-
except OSError as err:
|
|
101
|
-
_ = err
|
|
199
|
+
_win32_unlock(self._fd)
|
|
102
200
|
os.close(self._fd)
|
|
103
201
|
except OSError as err:
|
|
104
202
|
_ = err
|
|
@@ -184,11 +184,22 @@ def kill_process_tree(pid: int, timeout: float = 2.0) -> bool:
|
|
|
184
184
|
return True
|
|
185
185
|
|
|
186
186
|
|
|
187
|
-
def reap_orphan_processes(
|
|
187
|
+
def reap_orphan_processes(
|
|
188
|
+
target_names: Optional[Tuple[str, ...]] = None,
|
|
189
|
+
allow_system_wide: bool = False,
|
|
190
|
+
tracked_pids: Optional[List[int]] = None
|
|
191
|
+
) -> int:
|
|
188
192
|
"""
|
|
189
193
|
Safeguard reaper for orphaned runner and browser processes.
|
|
190
194
|
Defaults to known test drivers: chromedriver, chromium, node, java.
|
|
191
|
-
|
|
195
|
+
|
|
196
|
+
Safety Invariants:
|
|
197
|
+
1. Only reaps genuine orphaned processes whose parent process has died (on Windows:
|
|
198
|
+
not psutil.pid_exists(ppid); on POSIX: ppid == 1 or not psutil.pid_exists(ppid)),
|
|
199
|
+
or processes explicitly matching tracked_pids.
|
|
200
|
+
2. Blind OS-wide 'taskkill /IM' and 'pkill -f' are eliminated by default to prevent
|
|
201
|
+
killing the developer's active desktop browsers. System-wide fallback requires
|
|
202
|
+
explicit allow_system_wide=True opt-in.
|
|
192
203
|
"""
|
|
193
204
|
targets = target_names or ("chromedriver", "geckodriver", "chromium", "playwright")
|
|
194
205
|
reaped = 0
|
|
@@ -196,20 +207,38 @@ def reap_orphan_processes(target_names: Optional[Tuple[str, ...]] = None) -> int
|
|
|
196
207
|
try:
|
|
197
208
|
import psutil # type: ignore
|
|
198
209
|
current_pid = os.getpid()
|
|
199
|
-
for proc in psutil.process_iter(attrs=["pid", "name"]):
|
|
210
|
+
for proc in psutil.process_iter(attrs=["pid", "name", "ppid"]):
|
|
200
211
|
try:
|
|
201
212
|
pname = (proc.info.get("name") or "").lower()
|
|
202
213
|
pid = proc.info.get("pid")
|
|
203
|
-
|
|
214
|
+
ppid = proc.info.get("ppid")
|
|
215
|
+
if not pid or pid == current_pid:
|
|
216
|
+
continue
|
|
217
|
+
|
|
218
|
+
if not any(t in pname for t in targets):
|
|
219
|
+
continue
|
|
220
|
+
|
|
221
|
+
is_tracked = bool(tracked_pids and pid in tracked_pids)
|
|
222
|
+
is_orphan = False
|
|
223
|
+
if ppid is not None:
|
|
224
|
+
if sys.platform == "win32":
|
|
225
|
+
is_orphan = not psutil.pid_exists(ppid)
|
|
226
|
+
else:
|
|
227
|
+
is_orphan = (ppid == 1) or (not psutil.pid_exists(ppid))
|
|
228
|
+
|
|
229
|
+
if is_tracked or is_orphan or allow_system_wide:
|
|
204
230
|
proc.kill()
|
|
205
231
|
reaped += 1
|
|
206
232
|
except (psutil.NoSuchProcess, psutil.AccessDenied):
|
|
207
233
|
continue
|
|
208
234
|
return reaped
|
|
209
|
-
except ImportError
|
|
210
|
-
|
|
235
|
+
except ImportError:
|
|
236
|
+
_psutil_available = False
|
|
237
|
+
|
|
238
|
+
# Native CLI fallbacks ONLY if explicitly requested via allow_system_wide
|
|
239
|
+
if not allow_system_wide:
|
|
240
|
+
return 0
|
|
211
241
|
|
|
212
|
-
# Native CLI fallbacks when psutil is not available
|
|
213
242
|
if sys.platform == "win32":
|
|
214
243
|
for target in targets:
|
|
215
244
|
im_name = target if target.endswith(".exe") else f"{target}.exe"
|
|
@@ -222,8 +251,8 @@ def reap_orphan_processes(target_names: Optional[Tuple[str, ...]] = None) -> int
|
|
|
222
251
|
)
|
|
223
252
|
if res.returncode == 0:
|
|
224
253
|
reaped += 1
|
|
225
|
-
except Exception
|
|
226
|
-
|
|
254
|
+
except Exception:
|
|
255
|
+
continue
|
|
227
256
|
else:
|
|
228
257
|
for target in targets:
|
|
229
258
|
try:
|
|
@@ -235,8 +264,8 @@ def reap_orphan_processes(target_names: Optional[Tuple[str, ...]] = None) -> int
|
|
|
235
264
|
)
|
|
236
265
|
if res.returncode == 0:
|
|
237
266
|
reaped += 1
|
|
238
|
-
except Exception
|
|
239
|
-
|
|
267
|
+
except Exception:
|
|
268
|
+
continue
|
|
240
269
|
return reaped
|
|
241
270
|
|
|
242
271
|
|
|
@@ -340,3 +369,28 @@ class ProcessSupervisor:
|
|
|
340
369
|
|
|
341
370
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
342
371
|
self.cleanup_all()
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
def run_supervised(
|
|
375
|
+
cmd: List[str],
|
|
376
|
+
timeout: float = 60.0,
|
|
377
|
+
cwd: Optional[str] = None,
|
|
378
|
+
env: Optional[Dict[str, str]] = None,
|
|
379
|
+
capture_output: bool = True,
|
|
380
|
+
text: bool = True,
|
|
381
|
+
input_data: Optional[str] = None,
|
|
382
|
+
) -> SupervisedResult:
|
|
383
|
+
"""
|
|
384
|
+
Convenience function to execute a command under a governed ProcessSupervisor session.
|
|
385
|
+
Guarantees strict execution timeout, process group isolation, and zombie process cleanup (Boost B4).
|
|
386
|
+
"""
|
|
387
|
+
with ProcessSupervisor(default_timeout=timeout) as supervisor:
|
|
388
|
+
return supervisor.run(
|
|
389
|
+
cmd=cmd,
|
|
390
|
+
timeout=timeout,
|
|
391
|
+
cwd=cwd,
|
|
392
|
+
env=env,
|
|
393
|
+
capture_output=capture_output,
|
|
394
|
+
text=text,
|
|
395
|
+
input_data=input_data,
|
|
396
|
+
)
|
package/tools/core/telemetry.py
CHANGED
|
@@ -202,6 +202,19 @@ def create_trace_context(
|
|
|
202
202
|
)
|
|
203
203
|
|
|
204
204
|
|
|
205
|
+
RESERVED_KEYS = {
|
|
206
|
+
"timestamp",
|
|
207
|
+
"level",
|
|
208
|
+
"trace_id",
|
|
209
|
+
"span_id",
|
|
210
|
+
"parent_span_id",
|
|
211
|
+
"module",
|
|
212
|
+
"event",
|
|
213
|
+
"duration_ms",
|
|
214
|
+
"exception",
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
|
|
205
218
|
class StructuredJsonFormatter(logging.Formatter):
|
|
206
219
|
"""
|
|
207
220
|
Formats log records into structured JSON conforming to enterprise schema:
|
|
@@ -221,9 +234,17 @@ class StructuredJsonFormatter(logging.Formatter):
|
|
|
221
234
|
"duration_ms": getattr(record, "duration_ms", None),
|
|
222
235
|
}
|
|
223
236
|
|
|
224
|
-
# Include custom extra fields
|
|
237
|
+
# Include custom extra fields safely without overwriting reserved system schema
|
|
225
238
|
if hasattr(record, "extra_payload") and isinstance(record.extra_payload, dict):
|
|
226
|
-
|
|
239
|
+
attrs = {}
|
|
240
|
+
for k, v in record.extra_payload.items():
|
|
241
|
+
if k in RESERVED_KEYS:
|
|
242
|
+
attrs[k] = v
|
|
243
|
+
else:
|
|
244
|
+
record_dict[k] = v
|
|
245
|
+
attrs[k] = v
|
|
246
|
+
if attrs:
|
|
247
|
+
record_dict["attributes"] = attrs
|
|
227
248
|
|
|
228
249
|
# Include exception if present
|
|
229
250
|
if record.exc_info:
|
|
@@ -267,7 +288,15 @@ def log_event(
|
|
|
267
288
|
"duration_ms": duration_ms,
|
|
268
289
|
}
|
|
269
290
|
if extra_payload:
|
|
270
|
-
|
|
291
|
+
attrs = {}
|
|
292
|
+
for k, v in extra_payload.items():
|
|
293
|
+
if k in RESERVED_KEYS:
|
|
294
|
+
attrs[k] = v
|
|
295
|
+
else:
|
|
296
|
+
payload[k] = v
|
|
297
|
+
attrs[k] = v
|
|
298
|
+
if attrs:
|
|
299
|
+
payload["attributes"] = attrs
|
|
271
300
|
|
|
272
301
|
lvl_num = getattr(logging, level.upper(), logging.INFO)
|
|
273
302
|
logger = get_logger(logger_name)
|