@teevee98/synapse-hub 0.0.0-stage → 3.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/agents/api-engineer.md +67 -0
- package/.agents/agents/failure-analyst.md +75 -0
- package/.agents/agents/live-explorer.md +70 -0
- package/.agents/agents/orchestrator.md +104 -0
- package/.agents/agents/perf-engineer.md +74 -0
- package/.agents/agents/pom-crafter.md +112 -0
- package/.agents/agents/quality-gatekeeper.md +87 -0
- package/.agents/agents/test-designer.md +73 -0
- package/.agents/agents/test-runner.md +67 -0
- package/.agents/rules/author-integrity-guard.md +33 -0
- package/.agents/rules/communication-style.md +18 -0
- package/.agents/rules/context-engineering.md +37 -0
- package/.agents/rules/git-push-protocol.md +33 -0
- package/.agents/rules/graphify.md +14 -0
- package/.agents/rules/lessons-learned.md +25 -0
- package/.agents/rules/mandatory-playwright-live.md +25 -0
- package/.agents/rules/mobile_appium_rules.md +43 -0
- package/.agents/rules/performance_testing_rules.md +35 -0
- package/.agents/rules/skill-precedence.md +29 -0
- package/.agents/rules/systematic-debugging.md +36 -0
- package/.agents/skills/actor-qa-swarm/SKILL.md +77 -0
- package/.agents/skills/actor-qa-swarm/examples/broker_sharding_sample.json +12 -0
- package/.agents/skills/agent-orchestration-multi-agent-optimize/SKILL.md +88 -0
- package/.agents/skills/agent-orchestration-multi-agent-optimize/examples/swarm_workload_config.json +15 -0
- package/.agents/skills/agentless-qa-repair/SKILL.md +69 -0
- package/.agents/skills/agentless-qa-repair/examples/healing_report_sample.json +17 -0
- package/.agents/skills/agentless-qa-repair/examples/three_phase_repair_workflow.md +40 -0
- package/.agents/skills/antigravity-test-sentinel/SKILL.md +63 -0
- package/.agents/skills/antigravity-test-sentinel/examples/dod_gate_policy.json +11 -0
- package/.agents/skills/antigravity-test-sentinel/examples/sprint_dod_enforcement.md +47 -0
- package/.agents/skills/api-network-mocking-interception/SKILL.md +142 -0
- package/.agents/skills/api-network-mocking-interception/examples/network_route_stub.json +9 -0
- package/.agents/skills/api-spec-to-e2e-matrix/SKILL.md +80 -0
- package/.agents/skills/api-spec-to-e2e-matrix/examples/sample_openapi.json +19 -0
- package/.agents/skills/architecture-decision-records/SKILL.md +64 -0
- package/.agents/skills/architecture-decision-records/examples/0001-record-architecture-decisions.md +12 -0
- package/.agents/skills/auth-session-and-cookie-manager/SKILL.md +75 -0
- package/.agents/skills/auth-session-and-cookie-manager/examples/multi_role_auth_matrix.md +70 -0
- package/.agents/skills/auth-session-and-cookie-manager/examples/storage_state_sample.json +11 -0
- package/.agents/skills/backend-load-and-stress-patterns/SKILL.md +85 -0
- package/.agents/skills/backend-load-and-stress-patterns/examples/k6_load_test_sample.js +13 -0
- package/.agents/skills/backend-load-and-stress-patterns/references/k6_load_template.js +82 -0
- package/.agents/skills/bats-testing-patterns/SKILL.md +100 -0
- package/.agents/skills/bats-testing-patterns/examples/cli_runner_test.bats +6 -0
- package/.agents/skills/bats-testing-patterns/resources/implementation-playbook.md +614 -0
- package/.agents/skills/clean-pom-crafter/SKILL.md +110 -0
- package/.agents/skills/clean-pom-crafter/examples/standard_test_case.groovy +28 -0
- package/.agents/skills/clean-pom-crafter/references/pom_patterns.groovy +138 -0
- package/.agents/skills/code-refactoring-refactor-clean/SKILL.md +64 -0
- package/.agents/skills/code-refactoring-refactor-clean/examples/refactored_page_sample.groovy +9 -0
- package/.agents/skills/code-refactoring-refactor-clean/examples/refactored_playwright_pom.ts +52 -0
- package/.agents/skills/code-refactoring-refactor-clean/resources/implementation-playbook.md +881 -0
- package/.agents/skills/consumer-driven-contract-testing/SKILL.md +147 -0
- package/.agents/skills/consumer-driven-contract-testing/examples/order_service_pact.json +45 -0
- package/.agents/skills/db-state-verifier-and-seeder/SKILL.md +123 -0
- package/.agents/skills/db-state-verifier-and-seeder/examples/db_fixture_seed.json +12 -0
- package/.agents/skills/e2e-testing-patterns/SKILL.md +103 -0
- package/.agents/skills/e2e-testing-patterns/examples/playwright_sharded_config.ts +12 -0
- package/.agents/skills/e2e-testing-patterns/resources/implementation-playbook.md +522 -0
- package/.agents/skills/event-stream-qa-orchestrator/SKILL.md +79 -0
- package/.agents/skills/event-stream-qa-orchestrator/examples/timeline_sample.jsonl +2 -0
- package/.agents/skills/failure-autopsy-and-healing/SKILL.md +66 -0
- package/.agents/skills/failure-autopsy-and-healing/examples/closed_loop_healing_walkthrough.md +48 -0
- package/.agents/skills/failure-autopsy-and-healing/examples/sample_junit_failure.xml +8 -0
- package/.agents/skills/failure-autopsy-and-healing/references/healing_matrix.md +64 -0
- package/.agents/skills/failure-autopsy-and-healing/references/qa_investigation_protocol.md +56 -0
- package/.agents/skills/failure-autopsy-and-healing/scripts/triage_failures.sh +83 -0
- package/.agents/skills/file-and-report-validator/SKILL.md +90 -0
- package/.agents/skills/file-and-report-validator/examples/sample_export_schema.json +14 -0
- package/.agents/skills/flaky-test-sentinel-and-quarantine/SKILL.md +114 -0
- package/.agents/skills/flaky-test-sentinel-and-quarantine/examples/quarantine_registry.json +11 -0
- package/.agents/skills/gherkin-to-suite/SKILL.md +103 -0
- package/.agents/skills/gherkin-to-suite/examples/checkout.feature +39 -0
- package/.agents/skills/gherkin-to-suite/examples/suite_report_sample.json +334 -0
- package/.agents/skills/github-actions-templates/SKILL.md +77 -0
- package/.agents/skills/github-actions-templates/examples/matrix_test_pipeline.yml +8 -0
- package/.agents/skills/graphify-impact-analyzer/SKILL.md +76 -0
- package/.agents/skills/graphify-impact-analyzer/examples/dependency_blast_radius.json +8 -0
- package/.agents/skills/katalon-cli-runner/SKILL.md +76 -0
- package/.agents/skills/katalon-cli-runner/examples/headless_kre_exec.sh +3 -0
- package/.agents/skills/katalon-cli-runner/references/groovy-patterns.md +209 -0
- package/.agents/skills/katalon-cli-runner/references/katalon-api.md +155 -0
- package/.agents/skills/katalon-cli-runner/references/runner_commands.md +67 -0
- package/.agents/skills/lam-script-generator/SKILL.md +123 -0
- package/.agents/skills/lam-script-generator/examples/user_story_sample.md +8 -0
- package/.agents/skills/lean-code-ladder/SKILL.md +94 -0
- package/.agents/skills/lean-code-ladder/examples/ladder_walkthrough.md +37 -0
- package/.agents/skills/lean-impact-scoreboard/SKILL.md +48 -0
- package/.agents/skills/lean-impact-scoreboard/examples/sample_benchmark_gain.md +20 -0
- package/.agents/skills/lean-impact-scoreboard/examples/sample_scoreboard.md +15 -0
- package/.agents/skills/meta-prompt-crafter/SKILL.md +107 -0
- package/.agents/skills/meta-prompt-crafter/examples/qa_prompt_template.md +35 -0
- package/.agents/skills/mipro-prompt-compiler/SKILL.md +59 -0
- package/.agents/skills/mipro-prompt-compiler/examples/compiled_module_sample.json +22 -0
- package/.agents/skills/mipro-prompt-compiler/examples/dspy_assertion_optimizer_case.md +46 -0
- package/.agents/skills/mobile-appium-som/SKILL.md +88 -0
- package/.agents/skills/mobile-appium-som/examples/BaseScreen.java +88 -0
- package/.agents/skills/mobile-appium-som/examples/LoginScreen.java +46 -0
- package/.agents/skills/mobile-appium-som/examples/TC_MobileLogin.java +43 -0
- package/.agents/skills/persistent-planning-files/SKILL.md +108 -0
- package/.agents/skills/persistent-planning-files/examples/task_plan_example.md +56 -0
- package/.agents/skills/playwright-live-interaction/SKILL.md +131 -0
- package/.agents/skills/playwright-live-interaction/examples/live_probe_script.js +5 -0
- package/.agents/skills/playwright-live-interaction/references/advanced_superpowers.md +160 -0
- package/.agents/skills/playwright-live-interaction/references/compact_accessibility_snapshots.md +75 -0
- package/.agents/skills/playwright-live-interaction/references/recipes.md +388 -0
- package/.agents/skills/playwright-live-interaction/references/swarm_orchestration.md +134 -0
- package/.agents/skills/playwright-webapp-testing/SKILL.md +93 -0
- package/.agents/skills/playwright-webapp-testing/examples/server_lifecycle_playwright.py +63 -0
- package/.agents/skills/qa-aci-interface/SKILL.md +67 -0
- package/.agents/skills/qa-aci-interface/examples/surgical_code_window_walkthrough.md +40 -0
- package/.agents/skills/qa-aci-interface/examples/surgical_edit_sample.json +12 -0
- package/.agents/skills/qa-memory-os/SKILL.md +80 -0
- package/.agents/skills/qa-memory-os/examples/archival_memory_sample.json +21 -0
- package/.agents/skills/rbt-manual-testing/SKILL.md +137 -0
- package/.agents/skills/rbt-manual-testing/examples/checkout_rbt_manual_suite.md +25 -0
- package/.agents/skills/rbt-manual-testing/references/field_validation_checklist.md +29 -0
- package/.agents/skills/repo-quality-audit/SKILL.md +68 -0
- package/.agents/skills/repo-quality-audit/examples/sample_audit_walkthrough.md +15 -0
- package/.agents/skills/repo-quality-audit/examples/sample_repo_audit.md +33 -0
- package/.agents/skills/review-spec/SKILL.md +60 -0
- package/.agents/skills/review-spec/examples/pocock_grilling_decision_rubric.md +40 -0
- package/.agents/skills/review-spec/examples/sample_spec_review.md +33 -0
- package/.agents/skills/security-dast-sentinel/SKILL.md +119 -0
- package/.agents/skills/security-dast-sentinel/examples/dast_scan_config.json +10 -0
- package/.agents/skills/security-dast-sentinel/references/AI-AND-LLM.md +113 -0
- package/.agents/skills/security-dast-sentinel/references/ATTACK-CLASSES.md +89 -0
- package/.agents/skills/security-dast-sentinel/references/dast_recipes.ts +33 -0
- package/.agents/skills/self-healing-locator/SKILL.md +86 -0
- package/.agents/skills/self-healing-locator/examples/aom_diff_sample.json +16 -0
- package/.agents/skills/senior-code-review/SKILL.md +108 -0
- package/.agents/skills/senior-code-review/examples/sample_review_walkthrough.md +29 -0
- package/.agents/skills/skillspector-security-guard/SKILL.md +57 -0
- package/.agents/skills/skillspector-security-guard/examples/audit_threat_vectors_report.json +35 -0
- package/.agents/skills/skillspector-security-guard/examples/safe_mcp_config.json +12 -0
- package/.agents/skills/surgical-coding-principles/SKILL.md +89 -0
- package/.agents/skills/surgical-coding-principles/examples/surgical_vs_scope_creep.md +46 -0
- package/.agents/skills/synthetic-test-data-generator/SKILL.md +135 -0
- package/.agents/skills/synthetic-test-data-generator/examples/idempotent_data_recipe.json +9 -0
- package/.agents/skills/systematic-debugging/SKILL.md +100 -0
- package/.agents/skills/systematic-debugging/examples/four_phase_case.md +44 -0
- package/.agents/skills/technical-debt-harvester/SKILL.md +70 -0
- package/.agents/skills/technical-debt-harvester/examples/sample_debt_ledger.md +25 -0
- package/.agents/skills/technical-debt-harvester/examples/sample_ledger_output.md +20 -0
- package/.agents/skills/test-driven-development/SKILL.md +114 -0
- package/.agents/skills/test-driven-development/examples/red_green_refactor_qa.md +78 -0
- package/.agents/skills/token-and-context-optimizer/SKILL.md +70 -0
- package/.agents/skills/token-and-context-optimizer/examples/distilled_log_sample.txt +3 -0
- package/.agents/skills/token-and-context-optimizer/references/context_engineering_guide.md +49 -0
- package/.agents/skills/tot-exploratory-testing/SKILL.md +59 -0
- package/.agents/skills/tot-exploratory-testing/examples/payment_gateway_tot_tree.json +62 -0
- package/.agents/skills/tot-exploratory-testing/examples/tot_graph_sample.json +35 -0
- package/.agents/skills/verification-before-completion/SKILL.md +100 -0
- package/.agents/skills/verification-before-completion/examples/evidence_log_example.md +46 -0
- package/.agents/skills/visual-regression-sentinel/SKILL.md +82 -0
- package/.agents/skills/visual-regression-sentinel/examples/visual_mask_rules.json +9 -0
- package/.agents/skills/wcag-audit-patterns/SKILL.md +77 -0
- package/.agents/skills/wcag-audit-patterns/examples/wcag_compliance_checklist.json +10 -0
- package/.agents/skills/wcag-audit-patterns/resources/implementation-playbook.md +541 -0
- package/.agents/skills/web-agent-gym-benchmarking/SKILL.md +62 -0
- package/.agents/skills/web-agent-gym-benchmarking/examples/benchmark_report_sample.json +22 -0
- package/.agents/skills/web-agent-gym-benchmarking/examples/enterprise_tasks_suite.json +38 -0
- package/.agents/skills/web-vitals-and-performance-profiler/SKILL.md +65 -0
- package/.agents/skills/web-vitals-and-performance-profiler/examples/cwv_budget_policy.json +6 -0
- package/.agents/skills/web-vitals-and-performance-profiler/examples/playwright_cwv_profiler_fixture.ts +118 -0
- package/.agents/templates/completion_report.md +57 -0
- package/.agents/workflows/analyze_requirement_document.md +18 -0
- package/.agents/workflows/export_testcases_excel.md +32 -0
- package/.agents/workflows/generate_combinatorial_test_data.md +28 -0
- package/.agents/workflows/generate_cross_module_test_plan.md +37 -0
- package/.agents/workflows/generate_manual_testcases_rbt.md +56 -0
- package/.agents/workflows/generate_requirements_from_website.md +25 -0
- package/.agents/workflows/generate_testcases_from_requirements.md +21 -0
- package/.agents/workflows/graphify.md +10 -0
- package/.agents/workflows/test-impact.md +15 -0
- package/.agents/workflows/verify.md +34 -0
- package/.cursor/rules/agents.mdc +16 -0
- package/.cursor/rules/language.mdc +7 -0
- package/.cursor/rules/synapse-qa.mdc +24 -0
- package/.cursorrules +27 -0
- package/.dockerignore +53 -0
- package/.pre-commit-hooks.yaml +14 -0
- package/.windsurfrules +26 -0
- package/AGENTS.md +86 -0
- package/CLAUDE.md +54 -0
- package/Dockerfile +81 -0
- package/LICENSE +52 -0
- package/NOTICE +264 -0
- package/README.en.md +171 -0
- package/README.md +170 -2
- package/action.yml +51 -0
- package/agentskills.json +16 -0
- package/bin/agent-qa.js +138 -0
- package/docker-compose.yml +74 -0
- package/docs/ARCHITECTURE.en.md +198 -0
- package/docs/ARCHITECTURE.md +199 -0
- package/docs/CI_CD_INTEGRATION.en.md +170 -0
- package/docs/CI_CD_INTEGRATION.md +170 -0
- package/docs/CLI_REFERENCE.en.md +174 -0
- package/docs/CLI_REFERENCE.md +176 -0
- package/docs/CONTRIBUTING.en.md +49 -0
- package/docs/CONTRIBUTING.md +49 -0
- package/docs/PERFORMANCE_AUDIT_REPORT.md +783 -0
- package/docs/PLUGIN_DEVELOPMENT_GUIDE.md +127 -0
- package/docs/QUALITY_GATES.en.md +118 -0
- package/docs/QUALITY_GATES.md +118 -0
- package/docs/TOKEN_QUOTA_PLAYBOOK.md +41 -0
- package/docs/TOOL_CATALOG.md +129 -0
- package/docs/adopted-ecosystem-tools.md +96 -0
- package/docs/research/EXTERNAL_AGENT_SKILLS_SURVEY.md +1062 -0
- package/docs/research/agent_skill_training_analysis.md +1358 -0
- package/docs/schemas/synapse.config.schema.json +86 -0
- package/package.json +94 -4
- package/plugin.json +31 -0
- package/scripts/generate_skill_examples.py +244 -0
- package/scripts/install.ps1 +112 -0
- package/scripts/install_global_plugin.ps1 +94 -0
- package/scripts/install_global_plugin.sh +49 -0
- package/scripts/lint_skills.ps1 +57 -0
- package/scripts/package_dist.py +337 -0
- package/scripts/setup.sh +59 -0
- package/scripts/update_hub.ps1 +19 -0
- package/scripts/update_hub.sh +15 -0
- package/skills_manifest.json +854 -0
- package/synapse.config.json +31 -0
- package/templates/PROJECT_AI_GUIDE_TEMPLATE.md +111 -0
- package/templates/PROJECT_STATE_TEMPLATE.md +20 -0
- package/templates/ai_bridges/CLAUDE.md +54 -0
- package/templates/ai_bridges/copilot-instructions.md +20 -0
- package/templates/ai_bridges/cursor_synapse_qa.mdc +24 -0
- package/templates/ai_bridges/windsurfrules +26 -0
- package/templates/ci/github-actions-synapse.yml +95 -0
- package/templates/ci/gitlab-ci-synapse.yml +16 -0
- package/templates/ui/index.html +1069 -0
- package/templates/welcome.html.tmpl +2074 -0
- package/tools/.infer_baseline.json +30 -0
- package/tools/TOOLS_RUNBOOK.md +1553 -0
- package/tools/TOOL_CATALOG.json +1769 -0
- package/tools/__init__.py +43 -0
- package/tools/_openapi_parser.py +158 -0
- package/tools/agent_canary.py +525 -0
- package/tools/agentless_patcher.py +417 -0
- package/tools/analyze_project.py +262 -0
- package/tools/api_drift_sentinel.py +208 -0
- package/tools/api_fuzzer.py +762 -0
- package/tools/author_integrity.py +190 -0
- package/tools/auto_heal.py +271 -0
- package/tools/auto_heal_reflexion.py +532 -0
- package/tools/autogen_qa_broker.py +844 -0
- package/tools/benchmark_swarm_context.py +394 -0
- package/tools/browser_helpers.js +746 -0
- package/tools/browsergym_eval.py +236 -0
- package/tools/bug_reporter.py +252 -0
- package/tools/bump_version.py +423 -0
- package/tools/cache_resolver.py +1214 -0
- package/tools/check_env.py +426 -0
- package/tools/check_version_sync.py +256 -0
- package/tools/ci_healing_hook.py +126 -0
- package/tools/cli.py +1598 -0
- package/tools/config_decoupler.py +253 -0
- package/tools/contract_validator.py +141 -0
- package/tools/core/__init__.py +70 -0
- package/tools/core/adapters.py +431 -0
- package/tools/core/circuit_breaker.py +263 -0
- package/tools/core/cli_runtime.py +66 -0
- package/tools/core/file_lock.py +159 -0
- package/tools/core/i18n.py +394 -0
- package/tools/core/memory_bus.py +905 -0
- package/tools/core/process_supervisor.py +332 -0
- package/tools/core/telemetry.py +329 -0
- package/tools/count_tokens.py +1267 -0
- package/tools/create_mock_docx.py +104 -0
- package/tools/dashboard_generator.py +2403 -0
- package/tools/db_sandbox.py +675 -0
- package/tools/debt_harvester.py +237 -0
- package/tools/distill_log.py +161 -0
- package/tools/dspy_qa_signatures.py +356 -0
- package/tools/e2e_flow_prober.py +132 -0
- package/tools/export_postman_collection.py +945 -0
- package/tools/flaky_detector.py +389 -0
- package/tools/fsm_enforcer.py +450 -0
- package/tools/fsm_middleware.py +401 -0
- package/tools/fuzz_payloads.py +197 -0
- package/tools/generate_allure_report.py +88 -0
- package/tools/generate_api_matrix.py +193 -0
- package/tools/generate_jmx_plan.py +1322 -0
- package/tools/generate_sbom.py +252 -0
- package/tools/generate_tc_from_story.py +203 -0
- package/tools/generate_test_reports.py +133 -0
- package/tools/generate_tool_catalog.py +482 -0
- package/tools/gherkin_suite.py +758 -0
- package/tools/git_pre_commit_guard.py +298 -0
- package/tools/goldfish_review.py +366 -0
- package/tools/heal/__init__.py +28 -0
- package/tools/heal_pr_automator.py +220 -0
- package/tools/heuristic_locator_matcher.py +351 -0
- package/tools/hub_publisher.py +623 -0
- package/tools/humanize_linter.py +438 -0
- package/tools/infer_linter.py +977 -0
- package/tools/init_config.py +306 -0
- package/tools/interview_story.py +116 -0
- package/tools/jira_sync.py +566 -0
- package/tools/jtl_analyzer.py +474 -0
- package/tools/lint/__init__.py +30 -0
- package/tools/lint_ai_docs.py +374 -0
- package/tools/lookup_tc.py +165 -0
- package/tools/lookup_xpath.py +167 -0
- package/tools/matrix_sharder.py +148 -0
- package/tools/mcp/__init__.py +18 -0
- package/tools/mcp_docx_server.ps1 +13 -0
- package/tools/mcp_docx_server.py +851 -0
- package/tools/mcp_excel_server.ps1 +13 -0
- package/tools/mcp_excel_server.py +441 -0
- package/tools/mcp_server.py +725 -0
- package/tools/md_to_xlsx.py +327 -0
- package/tools/micro_mutator.py +887 -0
- package/tools/mipro_assertion_tuner.py +210 -0
- package/tools/network_mock_shield.py +311 -0
- package/tools/newman_analyzer.py +384 -0
- package/tools/omni_emitter.py +579 -0
- package/tools/omni_parser.py +450 -0
- package/tools/omni_transpiler.py +168 -0
- package/tools/openxml_guard.py +438 -0
- package/tools/output_formatter.py +182 -0
- package/tools/package_release.py +325 -0
- package/tools/perf/__init__.py +24 -0
- package/tools/pinpoint_failure.py +190 -0
- package/tools/project_state.py +171 -0
- package/tools/qa_event_stream.py +358 -0
- package/tools/repo_map.py +346 -0
- package/tools/report/__init__.py +32 -0
- package/tools/reversible_sandbox.py +344 -0
- package/tools/safety_firewall.py +437 -0
- package/tools/security_coverage_ledger.py +538 -0
- package/tools/security_scanner.py +229 -0
- package/tools/senior_code_review.py +393 -0
- package/tools/setup_project.py +770 -0
- package/tools/skill_collision_guard.py +304 -0
- package/tools/skill_profiles.py +217 -0
- package/tools/skill_vault.py +481 -0
- package/tools/skillspector.py +1278 -0
- package/tools/smart_visual_masker.py +132 -0
- package/tools/spec_drift_sentinel.py +438 -0
- package/tools/swe_qa_aci.py +369 -0
- package/tools/synapse_observer.py +485 -0
- package/tools/synapse_qa_bench.py +190 -0
- package/tools/sync_agent_rules.py +274 -0
- package/tools/telemetry_correlator.py +397 -0
- package/tools/template_excel_exporter.py +514 -0
- package/tools/templates/jmeter-distributed/README.md +54 -0
- package/tools/templates/jmeter-distributed/docker-compose.yml +83 -0
- package/tools/test_impact.py +419 -0
- package/tools/test_memory_os.py +462 -0
- package/tools/textgrad_mutation_optimizer.py +237 -0
- package/tools/tms_sync_bridge.py +834 -0
- package/tools/tot_exploratory_tester.py +239 -0
- package/tools/trace_data_flow.py +240 -0
- package/tools/traffic_session_converter.py +256 -0
- package/tools/trend_analytics.py +314 -0
- package/tools/ui_server.py +401 -0
- package/tools/universal_ir.py +488 -0
- package/tools/update_sentinel.py +383 -0
- package/tools/validate_groovy_scripts.py +173 -0
- package/tools/verify_all.py +1271 -0
- package/tools/visual_diff_canvas.py +143 -0
- package/tools/visual_som_helper.py +550 -0
- package/tools/watch_mode.py +308 -0
- package/tools/wcag_audit.py +239 -0
- package/tools/welcome_page.py +290 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Enterprise Project State Machine & Token-Capped Memory Anchor
|
|
4
|
+
--------------------------------------------------------------
|
|
5
|
+
Maintains persistent execution state across long-running AI sessions and Antigravity context compaction.
|
|
6
|
+
Enforces a strict Rolling Window (< 50 lines, ~200 tokens) to guarantee zero token bloat.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import sys
|
|
11
|
+
from datetime import datetime
|
|
12
|
+
|
|
13
|
+
# Enforce UTF-8 stdout encoding for Windows console compatibility
|
|
14
|
+
if hasattr(sys.stdout, 'reconfigure'):
|
|
15
|
+
try:
|
|
16
|
+
sys.stdout.reconfigure(encoding='utf-8')
|
|
17
|
+
sys.stderr.reconfigure(encoding='utf-8')
|
|
18
|
+
except Exception:
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
22
|
+
HUB_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, ".."))
|
|
23
|
+
TEMPLATES_DIR = os.path.join(HUB_ROOT, "templates")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def resolve_state_file(target_dir):
|
|
27
|
+
return os.path.join(target_dir, "PROJECT_STATE.md")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def init_state(target_dir, goal="Initial Autonomous Setup"):
|
|
31
|
+
"""Initializes PROJECT_STATE.md if missing, strictly capped to < 50 lines."""
|
|
32
|
+
state_file = resolve_state_file(target_dir)
|
|
33
|
+
if os.path.exists(state_file):
|
|
34
|
+
return state_file
|
|
35
|
+
|
|
36
|
+
project_name = os.path.basename(os.path.abspath(target_dir))
|
|
37
|
+
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
38
|
+
|
|
39
|
+
content = f"""# Project Execution State (`PROJECT_STATE.md`)
|
|
40
|
+
|
|
41
|
+
- **Project:** `{project_name}`
|
|
42
|
+
- **Last Sync:** `{timestamp}`
|
|
43
|
+
- **Overall Status:** `READY`
|
|
44
|
+
|
|
45
|
+
## 1. Active Goal
|
|
46
|
+
- {goal}
|
|
47
|
+
|
|
48
|
+
## 2. Task Checklist (Rolling Window - Max 8 active items)
|
|
49
|
+
- [x] Initialized project state anchor
|
|
50
|
+
- [ ] Ready for feature or test automation
|
|
51
|
+
|
|
52
|
+
## 3. Active Watchpoints & Healing (Max 3 items)
|
|
53
|
+
- Target Suite / Script: `[None]`
|
|
54
|
+
- Failing Locator / Line: `[None]`
|
|
55
|
+
|
|
56
|
+
## 4. Quality Verification
|
|
57
|
+
- 10 Quality Gates: `READY`
|
|
58
|
+
- Clean POM Integrity: `VERIFIED`
|
|
59
|
+
"""
|
|
60
|
+
with open(state_file, "w", encoding="utf-8") as f:
|
|
61
|
+
f.write(content)
|
|
62
|
+
return state_file
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def update_state(target_dir, goal=None, completed_task=None, pending_task=None, watchpoint=None, gate_status=None):
|
|
66
|
+
"""Updates state in-place while pruning old entries to guarantee < 50 lines (~200 tokens)."""
|
|
67
|
+
state_file = resolve_state_file(target_dir)
|
|
68
|
+
if not os.path.exists(state_file):
|
|
69
|
+
init_state(target_dir, goal or "Active Task")
|
|
70
|
+
|
|
71
|
+
with open(state_file, "r", encoding="utf-8") as f:
|
|
72
|
+
lines = [line.rstrip() for line in f.readlines()]
|
|
73
|
+
|
|
74
|
+
project_name = os.path.basename(os.path.abspath(target_dir))
|
|
75
|
+
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
76
|
+
|
|
77
|
+
# Parse existing tasks
|
|
78
|
+
existing_tasks = []
|
|
79
|
+
current_goal = goal or "Continue autonomous QA workflow"
|
|
80
|
+
current_watchpoints = []
|
|
81
|
+
current_gate = gate_status or "READY"
|
|
82
|
+
|
|
83
|
+
in_tasks = False
|
|
84
|
+
in_watch = False
|
|
85
|
+
|
|
86
|
+
for line in lines:
|
|
87
|
+
if line.startswith("## 1. Active Goal"):
|
|
88
|
+
in_tasks = False
|
|
89
|
+
in_watch = False
|
|
90
|
+
elif line.startswith("## 2. Task Checklist"):
|
|
91
|
+
in_tasks = True
|
|
92
|
+
in_watch = False
|
|
93
|
+
continue
|
|
94
|
+
elif line.startswith("## 3. Active Watchpoints"):
|
|
95
|
+
in_tasks = False
|
|
96
|
+
in_watch = True
|
|
97
|
+
continue
|
|
98
|
+
elif line.startswith("## 4. Quality Verification"):
|
|
99
|
+
in_tasks = False
|
|
100
|
+
in_watch = False
|
|
101
|
+
continue
|
|
102
|
+
|
|
103
|
+
if in_tasks and line.strip().startswith("- ["):
|
|
104
|
+
existing_tasks.append(line.strip())
|
|
105
|
+
elif in_watch and line.strip().startswith("- "):
|
|
106
|
+
current_watchpoints.append(line.strip())
|
|
107
|
+
elif line.startswith("- **Last Sync:**") and not goal:
|
|
108
|
+
pass
|
|
109
|
+
|
|
110
|
+
if completed_task:
|
|
111
|
+
existing_tasks.append(f"- [x] {completed_task}")
|
|
112
|
+
if pending_task:
|
|
113
|
+
existing_tasks.append(f"- [ ] {pending_task}")
|
|
114
|
+
if watchpoint:
|
|
115
|
+
current_watchpoints = [f"- Focus: {watchpoint}"]
|
|
116
|
+
|
|
117
|
+
# Rolling window cap: Keep maximum 8 task items (purge oldest completed tasks)
|
|
118
|
+
if len(existing_tasks) > 8:
|
|
119
|
+
# Keep pending tasks and the most recent completed ones
|
|
120
|
+
pending = [t for t in existing_tasks if t.startswith("- [ ]")]
|
|
121
|
+
completed = [t for t in existing_tasks if t.startswith("- [x]")]
|
|
122
|
+
# Keep up to 4 completed and remaining pending
|
|
123
|
+
completed = completed[-4:]
|
|
124
|
+
existing_tasks = completed + pending
|
|
125
|
+
existing_tasks = existing_tasks[-8:]
|
|
126
|
+
|
|
127
|
+
# Reconstruct compact markdown (< 40 lines)
|
|
128
|
+
tasks_block = "\n".join(existing_tasks) if existing_tasks else "- [ ] Standby for instructions"
|
|
129
|
+
watch_block = "\n".join(current_watchpoints[:3]) if current_watchpoints else "- Target Suite / Script: `[None]`\n- Failing Locator / Line: `[None]`"
|
|
130
|
+
|
|
131
|
+
content = f"""# Project Execution State (`PROJECT_STATE.md`)
|
|
132
|
+
|
|
133
|
+
- **Project:** `{project_name}`
|
|
134
|
+
- **Last Sync:** `{timestamp}`
|
|
135
|
+
- **Overall Status:** `IN_PROGRESS`
|
|
136
|
+
|
|
137
|
+
## 1. Active Goal
|
|
138
|
+
- {current_goal}
|
|
139
|
+
|
|
140
|
+
## 2. Task Checklist (Rolling Window - Max 8 active items)
|
|
141
|
+
{tasks_block}
|
|
142
|
+
|
|
143
|
+
## 3. Active Watchpoints & Healing (Max 3 items)
|
|
144
|
+
{watch_block}
|
|
145
|
+
|
|
146
|
+
## 4. Quality Verification
|
|
147
|
+
- 10 Quality Gates: `{current_gate}`
|
|
148
|
+
- Clean POM Integrity: `VERIFIED`
|
|
149
|
+
"""
|
|
150
|
+
with open(state_file, "w", encoding="utf-8") as f:
|
|
151
|
+
f.write(content)
|
|
152
|
+
return state_file
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def read_state(target_dir):
|
|
156
|
+
"""Reads state file if exists, returning condensed text."""
|
|
157
|
+
state_file = resolve_state_file(target_dir)
|
|
158
|
+
if not os.path.exists(state_file):
|
|
159
|
+
return None
|
|
160
|
+
with open(state_file, "r", encoding="utf-8") as f:
|
|
161
|
+
return f.read()
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
if __name__ == "__main__":
|
|
165
|
+
if len(sys.argv) > 1 and sys.argv[1] in ("-h", "--help"):
|
|
166
|
+
print("Usage: python3 tools/project_state.py [target_dir]")
|
|
167
|
+
print("Initializes or verifies the rolling-window PROJECT_STATE.md anchor in target directory.")
|
|
168
|
+
sys.exit(0)
|
|
169
|
+
target = sys.argv[1] if len(sys.argv) > 1 else os.getcwd()
|
|
170
|
+
sf = init_state(target)
|
|
171
|
+
print(f"Project state anchor initialized at: {sf}")
|
|
@@ -0,0 +1,358 @@
|
|
|
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
|
+
Immutable QA Event Stream Engine (OpenHands EventStream Pattern)
|
|
8
|
+
----------------------------------------------------------------
|
|
9
|
+
Provides a deterministic, append-only event stream for test automation sessions:
|
|
10
|
+
1. Immutable Event Logging: Sequential JSON Lines recording of all actor actions and observations.
|
|
11
|
+
2. Cryptographic Hash Chain: SHA-256 hash chaining ensures audit integrity and tamper resistance.
|
|
12
|
+
3. Reversible Checkpoints: Enables safe rollback to prior verified states on failures.
|
|
13
|
+
4. Stream Verification: Verifies stream schema, timestamp monotonicity, and hash chain integrity.
|
|
14
|
+
|
|
15
|
+
Usage:
|
|
16
|
+
python tools/qa_event_stream.py init-stream --session-id "E2E_001" --out-file .agent_memory/timeline.jsonl
|
|
17
|
+
python tools/qa_event_stream.py record-event --stream .agent_memory/timeline.jsonl --event-type ACTION_CLICK --actor live-explorer --payload '{"target": "#btn"}'
|
|
18
|
+
python tools/qa_event_stream.py verify-stream --stream .agent_memory/timeline.jsonl
|
|
19
|
+
python tools/qa_event_stream.py rollback --stream .agent_memory/timeline.jsonl --to-checkpoint CHECKPOINT_PRE_CHECKOUT
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
import os
|
|
23
|
+
import sys
|
|
24
|
+
import json
|
|
25
|
+
import hashlib
|
|
26
|
+
import argparse
|
|
27
|
+
from datetime import datetime, timezone
|
|
28
|
+
from typing import Dict, Any, Optional
|
|
29
|
+
|
|
30
|
+
# Enforce UTF-8 stdout encoding
|
|
31
|
+
if hasattr(sys.stdout, 'reconfigure'):
|
|
32
|
+
try:
|
|
33
|
+
sys.stdout.reconfigure(encoding='utf-8')
|
|
34
|
+
sys.stderr.reconfigure(encoding='utf-8')
|
|
35
|
+
except Exception:
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
GENESIS_HASH = "0" * 64
|
|
39
|
+
VALID_EVENT_TYPES = {
|
|
40
|
+
"STREAM_INIT",
|
|
41
|
+
"ACTION_NAVIGATE",
|
|
42
|
+
"ACTION_CLICK",
|
|
43
|
+
"ACTION_TYPE",
|
|
44
|
+
"OBSERVATION_DOM",
|
|
45
|
+
"ASSERTION_EVALUATED",
|
|
46
|
+
"CHECKPOINT",
|
|
47
|
+
"ERROR_OCCURRED",
|
|
48
|
+
"ROLLBACK_EXECUTED",
|
|
49
|
+
"TEST_COMPLETED"
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class QaEventStream:
|
|
54
|
+
"""Immutable Event Stream with SHA-256 Hash Chaining."""
|
|
55
|
+
|
|
56
|
+
def __init__(self, repo_root: Optional[str] = None, memory_bus: Optional[Any] = None, use_memory_bus: bool = False):
|
|
57
|
+
self.repo_root = repo_root or os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
58
|
+
self._bus_adapter = None
|
|
59
|
+
if use_memory_bus or memory_bus is not None:
|
|
60
|
+
try:
|
|
61
|
+
from core.adapters import EventStreamMemoryBusAdapter
|
|
62
|
+
except ImportError:
|
|
63
|
+
from tools.core.adapters import EventStreamMemoryBusAdapter
|
|
64
|
+
self._bus_adapter = EventStreamMemoryBusAdapter(bus=memory_bus)
|
|
65
|
+
|
|
66
|
+
def _compute_hash(self, prev_hash: str, session_id: str, event_type: str,
|
|
67
|
+
actor: str, payload_str: str, timestamp: str) -> str:
|
|
68
|
+
raw = f"{prev_hash}|{session_id}|{event_type}|{actor}|{payload_str}|{timestamp}"
|
|
69
|
+
return hashlib.sha256(raw.encode("utf-8")).hexdigest()
|
|
70
|
+
|
|
71
|
+
def init_stream(self, session_id: str, out_file: str) -> Dict[str, Any]:
|
|
72
|
+
"""Initializes an append-only timeline stream file."""
|
|
73
|
+
if self._bus_adapter:
|
|
74
|
+
return self._bus_adapter.init_stream(session_id, out_file=out_file)
|
|
75
|
+
|
|
76
|
+
resolved = os.path.join(self.repo_root, out_file) if not os.path.isabs(out_file) else out_file
|
|
77
|
+
|
|
78
|
+
os.makedirs(os.path.dirname(os.path.abspath(resolved)), exist_ok=True)
|
|
79
|
+
|
|
80
|
+
now = datetime.now(timezone.utc).isoformat()
|
|
81
|
+
init_payload = {"session_id": session_id, "initialized_at": now}
|
|
82
|
+
init_payload_str = json.dumps(init_payload, sort_keys=True)
|
|
83
|
+
event_hash = self._compute_hash(GENESIS_HASH, session_id, "STREAM_INIT", "system", init_payload_str, now)
|
|
84
|
+
|
|
85
|
+
entry = {
|
|
86
|
+
"index": 0,
|
|
87
|
+
"session_id": session_id,
|
|
88
|
+
"event_type": "STREAM_INIT",
|
|
89
|
+
"actor": "system",
|
|
90
|
+
"payload": init_payload,
|
|
91
|
+
"timestamp": now,
|
|
92
|
+
"prev_hash": GENESIS_HASH,
|
|
93
|
+
"event_hash": event_hash
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
with open(resolved, "w", encoding="utf-8", newline="\n") as f:
|
|
97
|
+
f.write(json.dumps(entry) + "\n")
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
"status": "PASS",
|
|
101
|
+
"session_id": session_id,
|
|
102
|
+
"out_file": resolved,
|
|
103
|
+
"genesis_hash": event_hash
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
def record_event(self, stream_file: str, event_type: str, actor: str,
|
|
107
|
+
payload: Any, checkpoint_id: Optional[str] = None) -> Dict[str, Any]:
|
|
108
|
+
"""Appends an event to the stream with continuous cryptographic hash chain."""
|
|
109
|
+
if self._bus_adapter:
|
|
110
|
+
return self._bus_adapter.record_event(stream_file, event_type, actor, payload, checkpoint_id=checkpoint_id)
|
|
111
|
+
|
|
112
|
+
resolved = os.path.join(self.repo_root, stream_file) if not os.path.isabs(stream_file) else stream_file
|
|
113
|
+
|
|
114
|
+
if not os.path.exists(resolved):
|
|
115
|
+
return {"status": "FAIL", "error": f"Stream file not found: {stream_file}"}
|
|
116
|
+
|
|
117
|
+
# Read last line to get index and prev_hash
|
|
118
|
+
last_entry = None
|
|
119
|
+
total_count = 0
|
|
120
|
+
with open(resolved, "r", encoding="utf-8", errors="replace") as f:
|
|
121
|
+
for line in f:
|
|
122
|
+
stripped = line.strip()
|
|
123
|
+
if stripped:
|
|
124
|
+
try:
|
|
125
|
+
last_entry = json.loads(stripped)
|
|
126
|
+
total_count += 1
|
|
127
|
+
except Exception as err:
|
|
128
|
+
sys.stderr.write(f"Notice: Skip malformed stream line: {err}\n")
|
|
129
|
+
|
|
130
|
+
if not last_entry:
|
|
131
|
+
return {"status": "FAIL", "error": "Stream file is empty or corrupted"}
|
|
132
|
+
|
|
133
|
+
prev_hash = last_entry.get("event_hash", GENESIS_HASH)
|
|
134
|
+
session_id = last_entry.get("session_id", "default_session")
|
|
135
|
+
now = datetime.now(timezone.utc).isoformat()
|
|
136
|
+
|
|
137
|
+
if checkpoint_id:
|
|
138
|
+
if isinstance(payload, dict):
|
|
139
|
+
payload["checkpoint_id"] = checkpoint_id
|
|
140
|
+
else:
|
|
141
|
+
payload = {"data": payload, "checkpoint_id": checkpoint_id}
|
|
142
|
+
|
|
143
|
+
payload_str = json.dumps(payload, sort_keys=True) if not isinstance(payload, str) else payload
|
|
144
|
+
event_hash = self._compute_hash(prev_hash, session_id, event_type, actor, payload_str, now)
|
|
145
|
+
|
|
146
|
+
new_entry = {
|
|
147
|
+
"index": total_count,
|
|
148
|
+
"session_id": session_id,
|
|
149
|
+
"event_type": event_type,
|
|
150
|
+
"actor": actor,
|
|
151
|
+
"payload": payload if not isinstance(payload, str) else json.loads(payload_str),
|
|
152
|
+
"timestamp": now,
|
|
153
|
+
"prev_hash": prev_hash,
|
|
154
|
+
"event_hash": event_hash
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
with open(resolved, "a", encoding="utf-8", newline="\n") as f:
|
|
158
|
+
f.write(json.dumps(new_entry) + "\n")
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
"status": "PASS",
|
|
162
|
+
"index": total_count,
|
|
163
|
+
"event_type": event_type,
|
|
164
|
+
"event_hash": event_hash,
|
|
165
|
+
"prev_hash": prev_hash
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
def verify_stream(self, stream_file: str) -> Dict[str, Any]:
|
|
169
|
+
"""Verifies hash chain integrity and JSON schema compliance (Gate 12)."""
|
|
170
|
+
if self._bus_adapter:
|
|
171
|
+
return self._bus_adapter.verify_stream(stream_file)
|
|
172
|
+
|
|
173
|
+
resolved = os.path.join(self.repo_root, stream_file) if not os.path.isabs(stream_file) else stream_file
|
|
174
|
+
if not os.path.exists(resolved):
|
|
175
|
+
return {"status": "FAIL", "verified": False, "error": f"Stream file not found: {stream_file}"}
|
|
176
|
+
|
|
177
|
+
events = []
|
|
178
|
+
with open(resolved, "r", encoding="utf-8", errors="replace") as f:
|
|
179
|
+
for line in f:
|
|
180
|
+
stripped = line.strip()
|
|
181
|
+
if stripped:
|
|
182
|
+
try:
|
|
183
|
+
events.append(json.loads(stripped))
|
|
184
|
+
except Exception as err:
|
|
185
|
+
return {"status": "FAIL", "verified": False, "error": f"JSON decode error: {err}"}
|
|
186
|
+
|
|
187
|
+
if not events:
|
|
188
|
+
return {"status": "FAIL", "verified": False, "error": "Stream is empty"}
|
|
189
|
+
|
|
190
|
+
expected_prev = GENESIS_HASH
|
|
191
|
+
for idx, ev in enumerate(events):
|
|
192
|
+
if ev.get("index") != idx:
|
|
193
|
+
return {
|
|
194
|
+
"status": "FAIL",
|
|
195
|
+
"verified": False,
|
|
196
|
+
"error": f"Index mismatch at position {idx}: expected {idx}, got {ev.get('index')}"
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if ev.get("prev_hash") != expected_prev:
|
|
200
|
+
return {
|
|
201
|
+
"status": "FAIL",
|
|
202
|
+
"verified": False,
|
|
203
|
+
"error": f"Broken hash chain at index {idx}: expected prev_hash {expected_prev}, got {ev.get('prev_hash')}"
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
payload_str = json.dumps(ev.get("payload"), sort_keys=True)
|
|
207
|
+
recalc = self._compute_hash(
|
|
208
|
+
expected_prev,
|
|
209
|
+
ev.get("session_id", ""),
|
|
210
|
+
ev.get("event_type", ""),
|
|
211
|
+
ev.get("actor", ""),
|
|
212
|
+
payload_str,
|
|
213
|
+
ev.get("timestamp", "")
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
if recalc != ev.get("event_hash"):
|
|
217
|
+
return {
|
|
218
|
+
"status": "FAIL",
|
|
219
|
+
"verified": False,
|
|
220
|
+
"error": f"Hash tamper detected at index {idx}: declared {ev.get('event_hash')}, computed {recalc}"
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
expected_prev = ev["event_hash"]
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
"status": "PASS",
|
|
227
|
+
"verified": True,
|
|
228
|
+
"events_verified": len(events),
|
|
229
|
+
"final_event_hash": expected_prev,
|
|
230
|
+
"integrity": "CRYPTOGRAPHICALLY_VERIFIED"
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
def rollback(self, stream_file: str, to_checkpoint: str) -> Dict[str, Any]:
|
|
234
|
+
"""Rolls back execution state to a designated checkpoint in the stream."""
|
|
235
|
+
if self._bus_adapter:
|
|
236
|
+
return self._bus_adapter.rollback(stream_file, to_checkpoint)
|
|
237
|
+
|
|
238
|
+
resolved = os.path.join(self.repo_root, stream_file) if not os.path.isabs(stream_file) else stream_file
|
|
239
|
+
|
|
240
|
+
if not os.path.exists(resolved):
|
|
241
|
+
return {"status": "FAIL", "error": f"Stream file not found: {stream_file}"}
|
|
242
|
+
|
|
243
|
+
target_checkpoint = None
|
|
244
|
+
checkpoint_index = -1
|
|
245
|
+
events = []
|
|
246
|
+
|
|
247
|
+
with open(resolved, "r", encoding="utf-8", errors="replace") as f:
|
|
248
|
+
for line in f:
|
|
249
|
+
stripped = line.strip()
|
|
250
|
+
if stripped:
|
|
251
|
+
try:
|
|
252
|
+
ev = json.loads(stripped)
|
|
253
|
+
events.append(ev)
|
|
254
|
+
p = ev.get("payload", {})
|
|
255
|
+
if isinstance(p, dict) and p.get("checkpoint_id") == to_checkpoint:
|
|
256
|
+
target_checkpoint = ev
|
|
257
|
+
checkpoint_index = ev.get("index", -1)
|
|
258
|
+
except Exception as err:
|
|
259
|
+
sys.stderr.write(f"Notice: Skip malformed stream line during rollback: {err}\n")
|
|
260
|
+
|
|
261
|
+
if not target_checkpoint:
|
|
262
|
+
return {
|
|
263
|
+
"status": "FAIL",
|
|
264
|
+
"error": f"Checkpoint '{to_checkpoint}' not found in event stream."
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
rolled_back_count = len(events) - (checkpoint_index + 1)
|
|
268
|
+
|
|
269
|
+
# Record ROLLBACK_EXECUTED event in the immutable stream
|
|
270
|
+
rollback_payload = {
|
|
271
|
+
"target_checkpoint": to_checkpoint,
|
|
272
|
+
"target_index": checkpoint_index,
|
|
273
|
+
"events_rewound": rolled_back_count,
|
|
274
|
+
"restored_state": target_checkpoint.get("payload")
|
|
275
|
+
}
|
|
276
|
+
rec_res = self.record_event(
|
|
277
|
+
stream_file=stream_file,
|
|
278
|
+
event_type="ROLLBACK_EXECUTED",
|
|
279
|
+
actor="system",
|
|
280
|
+
payload=rollback_payload
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
return {
|
|
284
|
+
"status": "PASS",
|
|
285
|
+
"to_checkpoint": to_checkpoint,
|
|
286
|
+
"target_index": checkpoint_index,
|
|
287
|
+
"events_rewound": rolled_back_count,
|
|
288
|
+
"new_event_hash": rec_res.get("event_hash"),
|
|
289
|
+
"restored_state": target_checkpoint.get("payload")
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def main():
|
|
294
|
+
parser = argparse.ArgumentParser(description="QA Event Stream Engine (OpenHands Pattern)")
|
|
295
|
+
subparsers = parser.add_subparsers(dest="subcommand", help="Subcommand to execute")
|
|
296
|
+
|
|
297
|
+
# init-stream
|
|
298
|
+
init_p = subparsers.add_parser("init-stream", help="Initialize a new event stream")
|
|
299
|
+
init_p.add_argument("--session-id", required=True, help="Unique test session ID")
|
|
300
|
+
init_p.add_argument("--out-file", required=True, help="Path to write JSONL stream")
|
|
301
|
+
|
|
302
|
+
# record-event
|
|
303
|
+
rec_p = subparsers.add_parser("record-event", help="Append an event to the stream")
|
|
304
|
+
rec_p.add_argument("--stream", required=True, help="Path to stream file")
|
|
305
|
+
rec_p.add_argument("--event-type", required=True, help="Event type (ACTION_CLICK, CHECKPOINT, etc.)")
|
|
306
|
+
rec_p.add_argument("--actor", required=True, help="Actor name (live-explorer, test-runner, etc.)")
|
|
307
|
+
rec_p.add_argument("--payload", required=True, help="JSON payload string")
|
|
308
|
+
rec_p.add_argument("--checkpoint-id", help="Optional checkpoint ID")
|
|
309
|
+
|
|
310
|
+
# verify-stream
|
|
311
|
+
ver_p = subparsers.add_parser("verify-stream", help="Verify cryptographic hash chain integrity")
|
|
312
|
+
ver_p.add_argument("--stream", required=True, help="Path to stream file")
|
|
313
|
+
|
|
314
|
+
# rollback
|
|
315
|
+
rb_p = subparsers.add_parser("rollback", help="Roll back state to a checkpoint")
|
|
316
|
+
rb_p.add_argument("--stream", required=True, help="Path to stream file")
|
|
317
|
+
rb_p.add_argument("--to-checkpoint", required=True, help="Target checkpoint ID")
|
|
318
|
+
|
|
319
|
+
args = parser.parse_args()
|
|
320
|
+
engine = QaEventStream()
|
|
321
|
+
|
|
322
|
+
if args.subcommand == "init-stream":
|
|
323
|
+
res = engine.init_stream(session_id=args.session_id, out_file=args.out_file)
|
|
324
|
+
print(json.dumps(res, indent=2))
|
|
325
|
+
sys.exit(0 if res["status"] == "PASS" else 1)
|
|
326
|
+
|
|
327
|
+
elif args.subcommand == "record-event":
|
|
328
|
+
try:
|
|
329
|
+
parsed_payload = json.loads(args.payload)
|
|
330
|
+
except Exception:
|
|
331
|
+
parsed_payload = args.payload
|
|
332
|
+
res = engine.record_event(
|
|
333
|
+
stream_file=args.stream,
|
|
334
|
+
event_type=args.event_type,
|
|
335
|
+
actor=args.actor,
|
|
336
|
+
payload=parsed_payload,
|
|
337
|
+
checkpoint_id=args.checkpoint_id
|
|
338
|
+
)
|
|
339
|
+
print(json.dumps(res, indent=2))
|
|
340
|
+
sys.exit(0 if res["status"] == "PASS" else 1)
|
|
341
|
+
|
|
342
|
+
elif args.subcommand == "verify-stream":
|
|
343
|
+
res = engine.verify_stream(stream_file=args.stream)
|
|
344
|
+
print(json.dumps(res, indent=2))
|
|
345
|
+
sys.exit(0 if res["status"] == "PASS" else 1)
|
|
346
|
+
|
|
347
|
+
elif args.subcommand == "rollback":
|
|
348
|
+
res = engine.rollback(stream_file=args.stream, to_checkpoint=args.to_checkpoint)
|
|
349
|
+
print(json.dumps(res, indent=2))
|
|
350
|
+
sys.exit(0 if res["status"] == "PASS" else 1)
|
|
351
|
+
|
|
352
|
+
else:
|
|
353
|
+
parser.print_help()
|
|
354
|
+
sys.exit(1)
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
if __name__ == "__main__":
|
|
358
|
+
main()
|