synapse-hub 2.4.3 → 2.6.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.
Files changed (184) hide show
  1. package/.agents/agents/failure-analyst.md +13 -0
  2. package/.agents/agents/orchestrator.md +5 -2
  3. package/.agents/agents/pom-crafter.md +13 -0
  4. package/.agents/agents/quality-gatekeeper.md +21 -2
  5. package/.agents/agents/test-runner.md +11 -0
  6. package/.agents/rules/context-engineering.md +22 -102
  7. package/.agents/rules/mobile_appium_rules.md +19 -115
  8. package/.agents/rules/performance_testing_rules.md +18 -62
  9. package/.agents/rules/skill-precedence.md +24 -24
  10. package/.agents/rules/systematic-debugging.md +10 -27
  11. package/.agents/skills/lean-code-ladder/SKILL.md +12 -1
  12. package/.agents/skills/lean-impact-scoreboard/SKILL.md +48 -0
  13. package/.agents/skills/lean-impact-scoreboard/examples/sample_benchmark_gain.md +20 -0
  14. package/.agents/skills/lean-impact-scoreboard/examples/sample_scoreboard.md +15 -0
  15. package/.agents/skills/repo-quality-audit/SKILL.md +68 -0
  16. package/.agents/skills/repo-quality-audit/examples/sample_audit_walkthrough.md +15 -0
  17. package/.agents/skills/repo-quality-audit/examples/sample_repo_audit.md +33 -0
  18. package/.agents/skills/senior-code-review/SKILL.md +90 -0
  19. package/.agents/skills/senior-code-review/examples/sample_review_walkthrough.md +29 -0
  20. package/.agents/skills/technical-debt-harvester/SKILL.md +70 -0
  21. package/.agents/skills/technical-debt-harvester/examples/sample_debt_ledger.md +25 -0
  22. package/.agents/skills/technical-debt-harvester/examples/sample_ledger_output.md +20 -0
  23. package/.agents/skills/token-and-context-optimizer/references/context_engineering_guide.md +49 -0
  24. package/.cursor/rules/synapse-qa.mdc +4 -3
  25. package/.cursorrules +1 -0
  26. package/.windsurfrules +1 -0
  27. package/AGENTS.md +57 -180
  28. package/CLAUDE.md +5 -0
  29. package/NOTICE +40 -4
  30. package/README.en.md +33 -13
  31. package/README.md +36 -16
  32. package/bin/agent-qa.js +3 -2
  33. package/docs/ARCHITECTURE.md +39 -11
  34. package/docs/CLI_REFERENCE.md +15 -1
  35. package/docs/adopted-ecosystem-tools.md +9 -0
  36. package/docs/research/agent_skill_training_analysis.md +1357 -0
  37. package/package.json +1 -3
  38. package/skills_manifest.json +39 -3
  39. package/synapse.config.json +3 -2
  40. package/templates/ai_bridges/CLAUDE.md +5 -0
  41. package/templates/ai_bridges/copilot-instructions.md +2 -0
  42. package/templates/ai_bridges/cursor_synapse_qa.mdc +4 -3
  43. package/templates/ai_bridges/windsurfrules +1 -0
  44. package/templates/welcome.html.tmpl +34 -25
  45. package/tools/.infer_baseline.json +7 -1079
  46. package/tools/TOOLS_RUNBOOK.md +182 -13
  47. package/tools/__init__.py +1 -1
  48. package/tools/agent_canary.py +4 -4
  49. package/tools/analyze_project.py +2 -2
  50. package/tools/api_fuzzer.py +4 -4
  51. package/tools/auto_heal.py +14 -2
  52. package/tools/auto_heal_reflexion.py +172 -0
  53. package/tools/browser_helpers.js +57 -2
  54. package/tools/bump_version.py +30 -2
  55. package/tools/cache_resolver.py +6 -6
  56. package/tools/check_env.py +13 -7
  57. package/tools/cli.py +265 -197
  58. package/tools/count_tokens.py +7 -7
  59. package/tools/dashboard_generator.py +39 -23
  60. package/tools/db_sandbox.py +5 -5
  61. package/tools/debt_harvester.py +236 -0
  62. package/tools/distill_log.py +2 -2
  63. package/tools/dspy_qa_signatures.py +357 -0
  64. package/tools/flaky_detector.py +5 -5
  65. package/tools/generate_tc_from_story.py +2 -2
  66. package/tools/generate_test_reports.py +4 -4
  67. package/tools/git_pre_commit_guard.py +6 -6
  68. package/tools/infer_linter.py +12 -7
  69. package/tools/interview_story.py +117 -0
  70. package/tools/lint_ai_docs.py +3 -3
  71. package/tools/matrix_sharder.py +4 -4
  72. package/tools/mcp_excel_server.py +1 -1
  73. package/tools/mcp_server.py +3 -3
  74. package/tools/micro_mutator.py +6 -6
  75. package/tools/omni_transpiler.py +2 -2
  76. package/tools/output_formatter.py +37 -2
  77. package/tools/pinpoint_failure.py +4 -1
  78. package/tools/repo_map.py +2 -2
  79. package/tools/reversible_sandbox.py +157 -0
  80. package/tools/safety_firewall.py +30 -2
  81. package/tools/senior_code_review.py +341 -0
  82. package/tools/setup_project.py +9 -9
  83. package/tools/skill_collision_guard.py +231 -0
  84. package/tools/skill_vault.py +343 -0
  85. package/tools/skillspector.py +2 -2
  86. package/tools/synapse_qa_bench.py +190 -0
  87. package/tools/sync_agent_rules.py +14 -3
  88. package/tools/test_impact.py +4 -4
  89. package/tools/textgrad_mutation_optimizer.py +234 -0
  90. package/tools/tms_sync_bridge.py +2 -2
  91. package/tools/update_sentinel.py +17 -17
  92. package/tools/verify_all.py +47 -16
  93. package/tools/visual_som_helper.py +8 -8
  94. package/tools/watch_mode.py +7 -8
  95. package/tools/wcag_audit.py +5 -1
  96. package/tools/welcome_page.py +12 -12
  97. package/benchmarks/qa_eval/README.md +0 -71
  98. package/benchmarks/qa_eval/build_dataset.py +0 -677
  99. package/benchmarks/qa_eval/dataset/api_contract_drift/qa-challenge-06_api_contract_drift.json +0 -22
  100. package/benchmarks/qa_eval/dataset/api_contract_drift/qa-challenge-07_api_contract_drift.json +0 -22
  101. package/benchmarks/qa_eval/dataset/api_contract_drift/qa-challenge-08_api_contract_drift.json +0 -22
  102. package/benchmarks/qa_eval/dataset/api_contract_drift/qa-challenge-09_api_contract_drift.json +0 -22
  103. package/benchmarks/qa_eval/dataset/api_contract_drift/qa-challenge-10_api_contract_drift.json +0 -22
  104. package/benchmarks/qa_eval/dataset/fake_pass_tautology/qa-challenge-21_fake_pass_tautology.json +0 -21
  105. package/benchmarks/qa_eval/dataset/fake_pass_tautology/qa-challenge-22_fake_pass_tautology.json +0 -21
  106. package/benchmarks/qa_eval/dataset/fake_pass_tautology/qa-challenge-23_fake_pass_tautology.json +0 -21
  107. package/benchmarks/qa_eval/dataset/fake_pass_tautology/qa-challenge-24_fake_pass_tautology.json +0 -21
  108. package/benchmarks/qa_eval/dataset/fake_pass_tautology/qa-challenge-25_fake_pass_tautology.json +0 -21
  109. package/benchmarks/qa_eval/dataset/locator_drift/qa-challenge-01_locator_drift.json +0 -23
  110. package/benchmarks/qa_eval/dataset/locator_drift/qa-challenge-02_locator_drift.json +0 -23
  111. package/benchmarks/qa_eval/dataset/locator_drift/qa-challenge-03_locator_drift.json +0 -23
  112. package/benchmarks/qa_eval/dataset/locator_drift/qa-challenge-04_locator_drift.json +0 -23
  113. package/benchmarks/qa_eval/dataset/locator_drift/qa-challenge-05_locator_drift.json +0 -23
  114. package/benchmarks/qa_eval/dataset/stale_and_mutation/qa-challenge-16_stale_and_mutation.json +0 -22
  115. package/benchmarks/qa_eval/dataset/stale_and_mutation/qa-challenge-17_stale_and_mutation.json +0 -22
  116. package/benchmarks/qa_eval/dataset/stale_and_mutation/qa-challenge-18_stale_and_mutation.json +0 -22
  117. package/benchmarks/qa_eval/dataset/stale_and_mutation/qa-challenge-19_stale_and_mutation.json +0 -22
  118. package/benchmarks/qa_eval/dataset/stale_and_mutation/qa-challenge-20_stale_and_mutation.json +0 -23
  119. package/benchmarks/qa_eval/dataset/timing_and_race/qa-challenge-11_timing_and_race.json +0 -22
  120. package/benchmarks/qa_eval/dataset/timing_and_race/qa-challenge-12_timing_and_race.json +0 -22
  121. package/benchmarks/qa_eval/dataset/timing_and_race/qa-challenge-13_timing_and_race.json +0 -22
  122. package/benchmarks/qa_eval/dataset/timing_and_race/qa-challenge-14_timing_and_race.json +0 -22
  123. package/benchmarks/qa_eval/dataset/timing_and_race/qa-challenge-15_timing_and_race.json +0 -22
  124. package/benchmarks/qa_eval/eval_runner.py +0 -418
  125. package/examples/cypress-ecommerce-suite/README.md +0 -45
  126. package/examples/cypress-ecommerce-suite/cypress/e2e/checkout.cy.js +0 -17
  127. package/examples/cypress-ecommerce-suite/cypress/pages/BasePage.js +0 -29
  128. package/examples/cypress-ecommerce-suite/cypress/pages/CartPage.js +0 -51
  129. package/examples/cypress-ecommerce-suite/cypress.config.js +0 -13
  130. package/examples/cypress-ecommerce-suite/package.json +0 -13
  131. package/examples/katalon-suite/Keywords/pages/BasePage.groovy +0 -19
  132. package/examples/katalon-suite/Keywords/pages/DashboardPage.groovy +0 -29
  133. package/examples/katalon-suite/Keywords/pages/LoginPage.groovy +0 -45
  134. package/examples/katalon-suite/Profiles/default.glbl +0 -12
  135. package/examples/katalon-suite/README.md +0 -18
  136. package/examples/katalon-suite/Scripts/Auth/TC_LoginSuccess/Script1234567890.groovy +0 -12
  137. package/examples/katalon-suite/Scripts/Dashboard/TC_ViewSummary/Script1234567891.groovy +0 -15
  138. package/examples/katalon-suite/katalon_suite.prj +0 -21
  139. package/examples/playwright-crm-suite/README.md +0 -40
  140. package/examples/playwright-crm-suite/package.json +0 -14
  141. package/examples/playwright-crm-suite/pages/BasePage.ts +0 -37
  142. package/examples/playwright-crm-suite/pages/CustomerPage.ts +0 -57
  143. package/examples/playwright-crm-suite/pages/LoginPage.ts +0 -32
  144. package/examples/playwright-crm-suite/playwright.config.ts +0 -27
  145. package/examples/playwright-crm-suite/tests/auth.spec.ts +0 -22
  146. package/examples/playwright-crm-suite/tests/customers.spec.ts +0 -33
  147. package/examples/plugins/sample-custom-plugin/README.md +0 -14
  148. package/examples/plugins/sample-custom-plugin/plugin.json +0 -16
  149. package/examples/plugins/sample-custom-plugin/skills/custom-security-headers-audit/SKILL.md +0 -29
  150. package/examples/plugins/sample-custom-plugin/skills/custom-security-headers-audit/examples/audit_fixture.json +0 -8
  151. package/examples/plugins/sample-custom-plugin/tools/custom_security_headers.py +0 -125
  152. package/examples/practices/README.md +0 -22
  153. package/examples/practices/requirements/crm/requirements_contracts.md +0 -292
  154. package/examples/practices/requirements/crm/requirements_customers.md +0 -462
  155. package/examples/practices/requirements/crm/requirements_login.md +0 -202
  156. package/examples/practices/requirements/crm/requirements_projects.md +0 -396
  157. package/examples/practices/requirements/crm/requirements_tasks.md +0 -343
  158. package/examples/practices/requirements/ecommerce/requirements_category_brand.txt +0 -402
  159. package/examples/practices/requirements/jira/KAN-5/KAN-1/2026-04-03_04-28-27.png +0 -0
  160. package/examples/practices/requirements/jira/KAN-5/KAN-1/KAN-1_requirement.md +0 -52
  161. package/examples/practices/requirements/jira/KAN-5/KAN-4/2026-04-03_04-28-19.png +0 -0
  162. package/examples/practices/requirements/jira/KAN-5/KAN-4/2026-04-03_04-28-57.png +0 -0
  163. package/examples/practices/requirements/jira/KAN-5/KAN-4/KAN-4_requirement.md +0 -119
  164. package/examples/practices/requirements/jira/KAN-5/KAN-5_overview.md +0 -9
  165. package/examples/practices/requirements/jira/KAN-5/KAN-6/2026-04-03_05-58-08.png +0 -0
  166. package/examples/practices/requirements/jira/KAN-5/KAN-6/2026-04-03_05-58-23.png +0 -0
  167. package/examples/practices/requirements/jira/KAN-5/KAN-6/KAN-6_requirement.md +0 -32
  168. package/examples/practices/testcases/api/book_management_api_test_cases.md +0 -144
  169. package/examples/practices/testcases/api/user_management_api_test_cases.md +0 -139
  170. package/examples/practices/testcases/crm/test_cases_crm_login.md +0 -148
  171. package/examples/practices/testcases/crm/test_cases_customers.md +0 -156
  172. package/examples/pytest-api-suite/README.md +0 -45
  173. package/examples/pytest-api-suite/conftest.py +0 -31
  174. package/examples/pytest-api-suite/pages/user_api_client.py +0 -36
  175. package/examples/pytest-api-suite/requirements.txt +0 -2
  176. package/examples/pytest-api-suite/tests/test_user_api.py +0 -44
  177. package/examples/selenium-suite/README.md +0 -18
  178. package/examples/selenium-suite/pages/base_page.py +0 -27
  179. package/examples/selenium-suite/pages/login_page.py +0 -29
  180. package/examples/selenium-suite/pages/order_page.py +0 -25
  181. package/examples/selenium-suite/pytest.ini +0 -6
  182. package/examples/selenium-suite/requirements.txt +0 -2
  183. package/examples/selenium-suite/tests/test_login.py +0 -10
  184. package/examples/selenium-suite/tests/test_order.py +0 -10
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  trigger: always_on
3
- description: Skill Resolution Precedence and Anti-Collision Protocol enforcing Workspace-Local skills over external generic plugin skills.
3
+ description: Skill Resolution Precedence, Inter-Skill Coordination, and Anti-Collision Protocol enforcing Workspace-Local skills over external generic plugin skills.
4
4
  ---
5
5
 
6
6
  # Skill Resolution Precedence & Anti-Collision Protocol
@@ -9,34 +9,34 @@ description: Skill Resolution Precedence and Anti-Collision Protocol enforcing W
9
9
 
10
10
  ---
11
11
 
12
- ## 1. Non-Negotiable Precedence Order
12
+ ## 1. Non-Negotiable 3-Tier Precedence Order
13
+ `[Tier 1: Project-Local Skills] (.agents/skills/*)` > `[Tier 2: Core Rules] (.agents/rules/*)` > `[Tier 3: External Plugins] (generic plugins)`.
14
+ Whenever a Tier 1 local skill exists, the external plugin skill is **strictly suppressed**.
13
15
 
14
- When executing tasks within automated testing repositories, Agent must strictly apply the following resolution order:
16
+ ---
15
17
 
16
- ```text
17
- [Tier 1: Project-Local Skills] (.agent/skills/*)
18
- v (Higher priority - Specialized & Context-Aware)
19
- [Tier 2: Core Project Rules] (.agents/rules/*)
20
- v
21
- [Tier 3: External Plugin Skills] (antigravity-testing-kit, chrome-devtools-plugin)
22
- ```
18
+ ## 2. External Plugin Suppression Rules (Tier 1 overrides Tier 3)
19
+ - **POM & Test Authoring:** Use `clean-pom-crafter` / `lam-script-generator`. Suppress generic QA/test plugins. Flat Clean POM only; no raw XPaths in test scripts.
20
+ - **Code Review:** Use `senior-code-review` (6 pillars against git diff). Suppress generic PR reviewers.
21
+ - **Locator Healing:** Use `self-healing-locator` / `failure-autopsy-and-healing` (AOM diffing). Suppress generic locator healers.
22
+ - **Flaky Test Triage:** Use `flaky-test-sentinel-and-quarantine` (episodic SQLite memory + JUnit parsing).
23
+ - **Live Probing:** Use `playwright-live-interaction` (CDP idle 0 under 200ms). Suppress generic smart locators.
24
+ - **Accessibility:** Use `wcag-audit-patterns` for WCAG 2.2 A/AA criteria; use Chrome DevTools MCP strictly for low-level node inspection.
23
25
 
24
26
  ---
25
27
 
26
- ## 2. Specific Skill Mapping & Exclusion Matrix
27
-
28
- | Task Type | REQUIRED Skill (Tier 1) | EXCLUDED / SUPPRESSED Skill (Tier 3) | Reason |
29
- |---|---|---|---|
30
- | **Test Script & POM Generation** | `clean-pom-crafter`<br/>`lam-script-generator` | `QA Automation Engineer` | Enforces Flat Architecture, zero XPaths in scripts, dynamic `uniqueCode`, and 2-phase search. Generic plugin templates violate Clean POM standards. |
31
- | **Locator Healing & DOM Diffing** | `self-healing-locator`<br/>`failure-autopsy-and-healing` | `Locator Healer Agent` | Uses token-efficient AOM diffing (Role > Label > TestId) and reads local JUnit XML/Screenshots. |
32
- | **Flaky Test Triage & Root Cause** | `failure-autopsy-and-healing` | `Flaky Test Analyzer` | Triage occurs via 0-token JUnit XML parsing, `Screenshots/FAILED_*.png` autopsy, and SQLite cosine cache (`memory_cache.db`). |
33
- | **Live Web & Locator Probing** | `playwright-live-interaction` | `Smart Locator Agent` | Direct CDP network idle 0, dynamic overlay bypass, and in-browser helper integration. |
34
- | **Code Refactoring & Tech Debt** | `code-refactoring-refactor-clean` | *(Consolidated)* | Single unified skill covering SOLID refactoring, code smells, and technical debt remediation. |
35
- | **Accessibility (A11y) Testing** | `wcag-audit-patterns`<br/>*(Guideline)* | `a11y-debugging`<br/>*(Tooling Only)* | `wcag-audit-patterns` governs WCAG 2.2 rules; `a11y-debugging` is used solely for low-level Chrome DevTools inspection. |
28
+ ## 3. Internal Inter-Skill Coordination & Boundaries
29
+ - **Code Authoring:** `lean-code-ladder` decides *what* to build (7-rung ladder); `surgical-coding-principles` restricts *where* to touch (surgical git diff).
30
+ - **Technical Debt:** `technical-debt-harvester` tracks `shortcut:` markers; `code-refactoring-refactor-clean` executes refactoring.
31
+ - **Quality Review:** `senior-code-review` audits source diffs; `review-spec` audits requirements/stories (0-context stress test).
32
+ - **System Audit:** `tools/analyze_project.py` gathers facts (AST, env, gates); `repo-quality-audit` prioritizes "Fix #1 first".
33
+ - **API Testing:** `api-spec-to-e2e-matrix` compiles test matrices; `api-network-mocking-interception` stubs routes and chaos faults.
34
+ - **Failure Analysis:** `self-healing-locator` heals individual locators; `failure-autopsy-and-healing` triages suite-wide crashes.
35
+ - **DoD Gatekeeper:** `verification-before-completion` checks fresh command evidence; `antigravity-test-sentinel` enforces all 10 gates.
36
36
 
37
37
  ---
38
38
 
39
- ## 3. Strict Prohibitions
40
-
41
- 1. **Never use generic test generation:** Do not generate boilerplate Selenium/Cucumber tests from external plugins that use `findTestObject` or Object Repository folders.
42
- 2. **Never dump raw HTML for locator healing:** Always extract compact AOM subtrees (< 500 tokens).
39
+ ## 4. Strict Prohibitions
40
+ 1. **Zero Generic Boilerplate:** Never generate legacy Selenium, Cucumber, or `findTestObject` code.
41
+ 2. **Zero Raw HTML Dumps:** Extract compact AOM subtrees (< 500 tokens); never dump raw HTML trees.
42
+ 3. **Zero Unverified Assertions:** Never complete tasks without running fresh verification via `tools/verify_all.py`.
@@ -31,7 +31,7 @@ This rule governs all AI Agents operating on the repository. It mandates strict
31
31
  ```bash
32
32
  python3 tools/verify_all.py
33
33
  ```
34
- - All 9 Gates must return `PASS`. If any gate fails, the task is NOT complete.
34
+ - All 10 Gates must return `PASS`. If any gate fails, the task is NOT complete.
35
35
  2. **Targeted Re-Test:**
36
36
  - After modifying Page Classes, check impacted Test Cases with:
37
37
  ```bash
@@ -46,32 +46,15 @@ This rule governs all AI Agents operating on the repository. It mandates strict
46
46
 
47
47
  ## 3. Situational Tool Dispatch Matrix & Zero-Command Autonomy
48
48
 
49
- > 🚀 **Zero-Command Autonomous Invariant (Zero Manual Commands):**
50
- > The user **NEVER** needs to remember syntax or manually type tool commands (`agent-qa setup`, `agent-qa analyze`, `verify_all.py`...).
51
- > The AI Agent **MUST AUTONOMOUSLY recognize context and trigger** the corresponding tools below on-demand whenever the situation arises.
52
- >
53
- > 🎯 **On-Demand Activation Principle (Situation-Specific — Never Run Blindly):**
54
- > Tools assigned to AI and Subagents are **situational weapons**, **NEVER executed all at once**. Agents draw the specific tool from the arsenal if and only if a concrete need arises (e.g.: failing test triggers `auto_heal`, new project triggers `setup_project`, API breaking change triggers `api_drift_sentinel`).
55
-
56
- | Context / Trigger | Mandatory Tool | Specific Objective |
57
- | :--- | :--- | :--- |
58
- | **New project / Missing `PROJECT_AI_GUIDE.md` / Fresh clone** | `python3 tools/setup_project.py [target]` | 100% Autonomous: Detects framework (Playwright/Katalon/Pytest), generates `PROJECT_AI_GUIDE.md`, installs `pre-push` hook, extracts `repo_map.txt`, runs initial audit. |
59
- | **User requests: "analyze project" / "re-analyze" / "project audit"** | `python3 tools/analyze_project.py [target]` | Execute comprehensive 5-in-1 health audit, sync repo_map, infer_linter, data_flow, verify_all & generate PROJECT_HEALTH_REPORT.md.<br/>**Post-Action:** Stage, commit & push updated project files (`PROJECT_HEALTH_REPORT.md`, `repo_map.txt`) to git. |
60
- | **Starting task / Querying Page Class methods** | `tools/repo_map.txt`<br/>*(run `python3 tools/repo_map.py` if classes changed)* | Read compressed 500-token map for signatures; avoid reading 4,000-line files. |
61
- | **Dispatching Browser Actions (Live/CDP)** | `python3 tools/safety_firewall.py --dry-run` | Mandatory Pre-execution Hook: Block irreversible/destructive operations before browser dispatch. |
62
- | **Creating or updating Test Scripts** | `python3 tools/infer_linter.py` | Run AST scan for Fake-Pass (0 asserts) and empty catch blocks. |
63
- | **New/Modified Test Case Quality** | `python3 tools/micro_mutator.py --min-score 80` | AST Mutation Testing: Reject test suites with mutation score < 80%. |
64
- | **Before Git Commit or Completing Task** | `python3 tools/verify_all.py` | Validate all 9 Quality Gates DoD. |
65
- | **After modifying Page Classes** | `python3 tools/test_impact.py --git-diff` | Scope impacted test cases; avoid re-running entire test suites. |
66
- | **When Test FAILS in CLI/KRE** | `python3 tools/pinpoint_failure.py` | Parse JUnit XML to identify exact failing line and exception in 0.1s. |
67
- | **When CLI / Gradle logs are verbose** | `python3 tools/distill_log.py <log>` | Filter 95% noise; preserve only actionable stacktraces and pointers. |
68
- | **Handling UI exceptions (Overlay, Stale)** | `python3 tools/cache_resolver.py query "<error>"` | Lookup 0-token solution from local SQLite memory cache before improvising. |
69
- | **Pre-Push / Suite Acceptance** | `python3 tools/trace_data_flow.py` | Run Taint Analysis to verify no orphan database junk remains uncleaned. |
70
- | **Canary Self-Healing Audit** | `python3 tools/agent_canary.py --run` | Inject 8 failure vectors to benchmark MTTR and autonomous recovery rate. |
71
- | **Testing GIS Canvas / Chart without DOM** | `python3 tools/visual_diff_canvas.py` | Compare pixel / SSIM to detect visual rendering regression. |
72
- | **Pulling code / New clone** | `python3 tools/cache_resolver.py init` | Automatically sync Central Agent Memory (`~/.agent_memory/global_cache.db`). |
73
- | **Before authoring test for Page/Flow** | `python3 tools/cache_resolver.py get-lessons --context "<page>"` | Query top 2 episodic lessons learned to avoid repeating past failure patterns. |
74
- | **After healing a bug / failure** | `python3 tools/cache_resolver.py record-lesson` | Record a concise 2-line lesson into SQLite memory for cross-session reflexion. |
49
+ > 🚀 **Zero-Command Autonomous Invariant:** The user **NEVER** needs to manually type tool commands. The AI Agent **MUST AUTONOMOUSLY recognize context and trigger** the corresponding tools on-demand. Never run tools blindly; invoke only when the concrete situation arises.
50
+
51
+ - **Setup & Audit:** New project -> `tools/setup_project.py`; Project audit -> `tools/analyze_project.py`; Code review -> `tools/senior_code_review.py`; Debt scan -> `tools/debt_harvester.py`.
52
+ - **Quality Gates & DoD:** Pre-commit/Handoff -> `tools/verify_all.py` (10 Gates DoD); Script lint -> `tools/infer_linter.py`; Mutation testing -> `tools/micro_mutator.py --min-score 80`.
53
+ - **Failure Autopsy & Healing:** Test failure -> `tools/pinpoint_failure.py` (parse JUnit XML in 0.1s); Iterative repair -> `tools/auto_heal_reflexion.py`; Reversible rollback -> `tools/reversible_sandbox.py`.
54
+ - **Context & Safety:** Verbose logs -> `tools/distill_log.py`; Destructive browser actions -> `tools/safety_firewall.py`; Method signatures -> `tools/repo_map.txt`.
55
+ - **Memory & Reflexion:** UI exceptions -> `tools/cache_resolver.py query "<error>"`; Query/Save proven patterns -> `tools/skill_vault.py`.
56
+
57
+ *(For the complete CLI parameters and full tools catalog, refer to [tools/TOOLS_RUNBOOK.md](file://tools/TOOLS_RUNBOOK.md)).*
75
58
 
76
59
  ---
77
60
 
@@ -9,7 +9,18 @@ Specialized skill for minimizing newly written code in test automation projects:
9
9
 
10
10
  ---
11
11
 
12
- ## 1. The 7-Rung Ladder
12
+ ## 1. The 7-Rung Ladder & Intensity Levels
13
+
14
+ ### Intensity Levels
15
+
16
+ | Level | Behavior |
17
+ |:---:|---|
18
+ | **lite** | Build what was asked. Name the smaller/lazier option in one line and let the user pick. |
19
+ | **full** | The standard 7-rung ladder rules below. (Default) |
20
+ | **ultra** | Deletion before addition: question the request and push back on any part the business need does not strictly justify. |
21
+ | **off** | Deactivate lean constraints; standard code synthesis. |
22
+
23
+ ### The 7-Rung Ladder
13
24
 
14
25
  Before writing any new code, descend the ladder and take the **first rung that fully works**:
15
26
 
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: lean-impact-scoreboard
3
+ description: "Display the measured impact scoreboard (code reduction %, token optimization %, cost reduction %, test rigor) from lean engineering benchmarks."
4
+ category: architecture_and_analysis
5
+ version: "1.0.0"
6
+ ---
7
+
8
+ # Lean Impact Scoreboard — Verified Efficiency & Token Benchmarks
9
+
10
+ Displays empirical metrics and benchmarks demonstrating the impact of Lean Engineering (The 7-Rung Ladder, Clean POM, and Verification-First).
11
+
12
+ ---
13
+
14
+ ## 1. Benchmark Overview
15
+
16
+ Based on extensive agentic benchmarks (39 real-world tasks across backend, frontend, security, and test suites):
17
+
18
+ ```text
19
+ ================================================================================
20
+ Metric Baseline (No Skill) Lean Mode Delta
21
+ ================================================================================
22
+ Lines of Code Generated 100% 47% -53% 📉
23
+ Output Tokens Consumed 100% 55% -45% 📉
24
+ API Cost 100% 74% -26% 📉
25
+ Agent Execution Time 100% 59% -41% ⚡
26
+ Risky Logic Shipped with Tests 68% 98% +30% 🛡️
27
+ Bug Detection Rate (Mutants) 46% 66% +20% 🎯
28
+ ================================================================================
29
+ ```
30
+
31
+ ---
32
+
33
+ ## 2. Key Insights
34
+
35
+ 1. **Less Code, Zero Loss of Safety:**
36
+ The goal is never code golfing. Code is concise because unnecessary abstractions, speculative wrappers, and redundant libraries are eliminated. Validation, trust boundaries, error handling, and accessibility are never compromised.
37
+ 2. **Empirical Verification Over Guesswork:**
38
+ 98% of all risky logic (branches, parsers, auth, financial paths) ships with an automated unit assertion, compared to only 68% in standard unconstrained AI runs.
39
+ 3. **Real Per-Repo Metrics:**
40
+ Never hallucinate synthetic per-repo savings figures. For repository-specific health and debt measurements:
41
+ - Run `agent-qa debt` to review tracked shortcut debt.
42
+ - Run `python3 tools/analyze_project.py` to inspect AST maps and Quality Gate adherence.
43
+
44
+ ---
45
+
46
+ ## 3. Attribution
47
+
48
+ Adapted from **ponytail-gain** (https://github.com/DietrichGebert/ponytail) — MIT License, Copyright (c) 2026 DietrichGebert. Re-calibrated for Enterprise QA and Synapse Hub benchmarks.
@@ -0,0 +1,20 @@
1
+ # Sample Lean Impact Scoreboard
2
+
3
+ Representative scoreboard displayed by `/synapse-gain`:
4
+
5
+ ```text
6
+ ================================================================================
7
+ Metric Baseline (No Skill) Lean Mode Delta
8
+ ================================================================================
9
+ Lines of Code Generated 100% 47% -53% 📉
10
+ Output Tokens Consumed 100% 55% -45% 📉
11
+ API Cost 100% 74% -26% 📉
12
+ Agent Execution Time 100% 59% -41% ⚡
13
+ Risky Logic Shipped with Tests 68% 98% +30% 🛡️
14
+ Bug Detection Rate (Mutants) 46% 66% +20% 🎯
15
+ ================================================================================
16
+ ```
17
+
18
+ ### Explanatory Context
19
+ - **Why less code?** Reuses existing codebase helpers, standard libraries, and native platform widgets instead of reinventing wheels.
20
+ - **Why more tests?** Enforces the completeness invariant: any non-trivial branch, loop, parser, or security logic must ship with a small test proving edge-case correctness.
@@ -0,0 +1,15 @@
1
+ # Sample Lean Impact Scoreboard
2
+
3
+ ## Example Display
4
+ ```text
5
+ ==============================================================================
6
+ SYNAPSE LEAN IMPACT SCOREBOARD
7
+ ==============================================================================
8
+ Target Repository : EnterprisePaymentGateway
9
+ Lines of Code Removed : -4,820 lines (-34.2%)
10
+ Token Consumption Drop : -58.4%
11
+ Estimated Cloud Cost : -\$1,420 / mo
12
+ Quality Gate Status : 100% PASS (9/9 Gates DoD)
13
+ Mutation Score : 91.4% (Threshold: >= 80%)
14
+ ==============================================================================
15
+ ```
@@ -0,0 +1,68 @@
1
+ ---
2
+ name: repo-quality-audit
3
+ description: "Quality audit of a whole codebase: bugs, security risks, concurrency and scale bottlenecks, missing test coverage, and code bloat. Ranks findings with 'Fix this first' priority."
4
+ category: architecture_and_analysis
5
+ version: "1.0.0"
6
+ ---
7
+
8
+ # Repo Quality Audit — Comprehensive Repository Health & Risk Audit
9
+
10
+ Audit an entire repository like the senior engineer who just inherited it and will be paged when it breaks.
11
+ Prioritize: **Correctness -> Safety -> Scale -> Tests -> Speed -> Lean**.
12
+ Always rank issues and provide a clear **"Fix this first"** verdict.
13
+
14
+ ---
15
+
16
+ ## 1. Mapping the Codebase First
17
+
18
+ Before diagnosing defects:
19
+ 1. **Entry Points & Architecture:** Inspect entry points (CLI commands, route handlers, test runners, background workers) and dependency manifests (`package.json`, `pyproject.toml`, `pom.xml`, `build.gradle`).
20
+ 2. **Expected Load:** Determine whether the system is a local utility, a parallel CI suite, or a high-throughput microservice.
21
+ 3. **Data Flow Tracing:** Trace critical business flows end-to-end:
22
+ - External inputs and request payloads
23
+ - Authentication & authorization checks
24
+ - Database mutations and state persistence
25
+ - Teardown and cleanup lifecycles
26
+
27
+ ---
28
+
29
+ ## 2. Six Audit Dimensions
30
+
31
+ | Dimension | Inspection Focus | Red Flags |
32
+ |---|---|---|
33
+ | **1. Bugs & Logic** | Edge cases, return type mismatches, error handling | Swallowed exceptions, null dereferences, broken callers |
34
+ | **2. Security & Data** | Trust boundaries, authentication, secrets | Hardcoded tokens, SQLi/RCE risks, missing input sanitization |
35
+ | **3. Concurrency & Scale** | Resource contention, memory lifecycle | Race conditions, static sleeps, unbounded caches, unclosed connections |
36
+ | **4. Test Deficit** | Untested business-critical logic | Complex branches or parsers with zero test assertions |
37
+ | **5. Performance** | Hot paths, loop overhead | Unindexed queries, redundant network calls, $O(n^2)$ iterations |
38
+ | **6. Bloat & Dead Code** | Code that should not exist | Unused dependencies, duplicate helper functions, single-impl interfaces |
39
+
40
+ ---
41
+
42
+ ## 3. Reporting Structure
43
+
44
+ 1. **Overview & Assumptions:**
45
+ - What this codebase does
46
+ - The operational load assumed
47
+ 2. **Ranked Findings (Max 20, ordered by severity):**
48
+ - **Must fix (Blockers):** Bugs causing data loss, security CVEs, unhandled crashes.
49
+ - **Should fix (Reliability):** Concurrency races, missing regression tests, flaky waits.
50
+ - **Nice to have (Hygiene):** Dead code removal, dependency pruning, code deduplication.
51
+ 3. **Verdict & Lean Metric:**
52
+ - **Verdict:** "Fix #1 first: [Summary of top priority issue]"
53
+ - **Lean Savings Potential:** Potential reduction in lines of code (`-N lines`) and unused dependencies (`-M dependencies`).
54
+ - **Not Checked:** Explicitly state any submodules or third-party assets omitted.
55
+
56
+ ---
57
+
58
+ ## 4. Complementary Hub Tools
59
+
60
+ - `python3 tools/analyze_project.py` — 5-in-1 automated health audit and AST repo map.
61
+ - `python3 tools/verify_all.py` — 9 Quality Gates DoD gatekeeper.
62
+ - `python3 tools/debt_harvester.py` — Scan repository for unaddressed shortcut debt.
63
+
64
+ ---
65
+
66
+ ## 5. Attribution
67
+
68
+ Adapted from **ponytail-audit** (https://github.com/DietrichGebert/ponytail) — MIT License, Copyright (c) 2026 DietrichGebert. Re-architected for Enterprise QA and Synapse Hub Standards.
@@ -0,0 +1,15 @@
1
+ # Sample Repo Quality Audit Walkthrough
2
+
3
+ ## Overview
4
+ This walkthrough demonstrates a repo-wide quality audit identifying high-impact risks with "Fix this first" prioritization.
5
+
6
+ ## Example Command
7
+ ```bash
8
+ agent-qa audit . --output REPO_QUALITY_AUDIT.md
9
+ ```
10
+
11
+ ## Sample Output Findings
12
+ 1. **Critical:** In-memory queue without persistent backoff under concurrent load (`WorkerPool.groovy:142`).
13
+ - *Fix:* Introduce Redis-backed queue or bounded worker pool.
14
+ 2. **Medium:** Unbounded mock API responses causing potential memory bloat (`MockServer.groovy:89`).
15
+ - *Fix:* Enforce pagination or bounded payload limits.
@@ -0,0 +1,33 @@
1
+ # Sample Repository Quality Audit
2
+
3
+ Representative full-repo quality audit report:
4
+
5
+ ```markdown
6
+ # Repository Quality Audit Report
7
+
8
+ - **Target Repository:** `warehouse-inventory-api`
9
+ - **Assumed Load:** 50 concurrent warehouse scanners + batch office imports (up to 5,000 items).
10
+
11
+ ### Findings (Ranked Priority)
12
+
13
+ #### 1. [Must Fix] Office Batch Import Fails on Row 1,200 (`src/importers/csv.py:45`)
14
+ - **What this is:** In-memory batch processor loading entire CSV into a single transaction.
15
+ - **Problem:** When batch exceeds 1,000 items, database pool exhausts connection limits and drops connection silently.
16
+ - **Fix:** Chunk processing into 250-row windowed transactions.
17
+ - **If we skip it:** Nightly stock sync fails for all regional warehouses.
18
+
19
+ #### 2. [Should Fix] Risky Discount Logic Has No Tests (`src/services/pricing.py:112`)
20
+ - **What this is:** Tiered pricing rule engine based on customer loyalty grade.
21
+ - **Problem:** Complex ternary branching calculates negative discounts if grade is undefined. Zero unit tests cover this branch.
22
+ - **Fix:** Add boundary unit tests in `tests/test_pricing.py` asserting non-negative pricing.
23
+ - **If we skip it:** Special promotions risk leaking negative prices to checkouts.
24
+
25
+ #### 3. [Nice to Have] Dead Legacy XML Exporter (`src/exporters/legacy_xml.py`)
26
+ - **What this is:** Deprecated XML export helper replaced by REST API 6 months ago.
27
+ - **Fix:** Delete the 120-line unused module.
28
+ - **If we skip it:** Maintenance burden and confusion for new team members.
29
+
30
+ ### Verdict
31
+ Fix #1 first: Chunk batch imports into 250-row windowed transactions.
32
+ Lean Potential: -120 dead lines, -1 unused XML library.
33
+ ```
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: senior-code-review
3
+ description: "Quality review of a code change: verify logic correctness, security boundaries, real concurrency/load, missing test coverage, execution speed, and eliminate bloat. Reads connected callers and data flows, not just the diff."
4
+ category: architecture_and_analysis
5
+ version: "1.0.0"
6
+ ---
7
+
8
+ # Senior Code Review — Enterprise Quality & Lean Diff Review
9
+
10
+ Review code changes like the senior engineer who will be paged at 2 AM when it breaks.
11
+ Order of importance: **Correctness -> Safety -> Scale -> Tests -> Speed -> Lean**.
12
+ Lean still matters: every extra line must be read, tested, and fixed later.
13
+
14
+ ---
15
+
16
+ ## 1. Understand First
17
+
18
+ - **Target Scoping:** Review what the user requests: uncommitted or staged changes, a branch, a PR link, or specific files. If unspecified: uncommitted changes (or last commit if clean).
19
+ - **Read Beyond the Diff:** Read the diff, then read the code it touches:
20
+ - Callers of every changed function or Page Class method.
21
+ - Functions and services called by the diff.
22
+ - Associated unit/E2E tests and fixtures.
23
+ - **Trace the Real Flow:** Where does user input arrive? What is validated? Where is state persisted? What is emitted?
24
+ - **Expected Scale:** Identify the expected operational load (single script execution vs concurrent CI runners or thousands of users). Judge scale against that.
25
+
26
+ ---
27
+
28
+ ## 2. Six Core Review Pillars
29
+
30
+ ### 1. Bug & Edge Cases
31
+ - Wrong calculation, crash, or unhandled edge cases (empty collections, zero values, timezone drift, string encoding).
32
+ - Callers broken by changed method signatures or altered return types.
33
+ - A bug fixed in one caller while the shared function/keyword remains broken for others.
34
+
35
+ ### 2. Risk & Security
36
+ - Injection vulnerabilities (SQL, Shell, Command, Path traversal).
37
+ - Hardcoded secrets, plain tokens, or private keys.
38
+ - Missing input validation at trust boundaries.
39
+ - Data loss risks: swallowed errors, unhandled promise rejections, missing DB transactions.
40
+
41
+ ### 3. Scale & Concurrency
42
+ - Race conditions (check-then-act without locking).
43
+ - Memory or cache leaks (unbounded collections that only grow).
44
+ - $O(n^2)$ iterations or N+1 queries on variable-sized data.
45
+ - Static delays (`Thread.sleep`, `time.sleep`) that block event loops or fail under variable network latency.
46
+
47
+ ### 4. Missing Tests
48
+ - New non-trivial logic (branch, loop, parser, auth check, payment/money path) lacking a test that fails when broken.
49
+ - Every bug fix must include a regression test proving the fix.
50
+
51
+ ### 5. Speed & Latency
52
+ - Bottlenecks in hot paths and repeated iterations.
53
+ - Unnecessary synchronous I/O or redundant API re-fetching.
54
+
55
+ ### 6. Lean & Anti-Bloat
56
+ - **Delete:** Dead code, commented-out code, unused options, speculative configuration.
57
+ - **Reuse:** Leverage existing Page Classes, BasePage helpers, or utility functions.
58
+ - **Stdlib / Native:** Use platform features instead of adding external dependencies.
59
+ - **YAGNI:** Remove single-use abstractions, single-impl interfaces, and passthrough wrappers.
60
+
61
+ ---
62
+
63
+ ## 3. Concrete Reporting Format
64
+
65
+ Every finding **must** have a concrete, reproducible failure scenario:
66
+
67
+ ```markdown
68
+ #### [Severity: Must fix | Should fix | Nice to have] <Finding Title> (`<file>:<line>`)
69
+ - **What this is:** <One concise sentence describing the touched code>
70
+ - **Problem:** <Specific input or scenario that leads to the defect or failure>
71
+ - **Fix:** <Smallest complete diff or code change to resolve the issue>
72
+ - **If we skip it:** <What goes wrong in production or CI pipeline>
73
+ ```
74
+
75
+ ---
76
+
77
+ ## 4. Automation CLI
78
+
79
+ Run the automated senior review tool on your current working tree:
80
+ ```bash
81
+ python3 tools/senior_code_review.py # Review uncommitted changes
82
+ python3 tools/senior_code_review.py --staged # Review staged git changes
83
+ python3 tools/senior_code_review.py --branch main # Compare against main branch
84
+ ```
85
+
86
+ ---
87
+
88
+ ## 5. Attribution
89
+
90
+ Adapted from **ponytail-review** (https://github.com/DietrichGebert/ponytail) — MIT License, Copyright (c) 2026 DietrichGebert. Re-architected for Enterprise QA, Clean POM, and Synapse Hub Quality Gates.
@@ -0,0 +1,29 @@
1
+ # Sample Senior Code Review Walkthrough
2
+
3
+ Below is a representative senior code review performed on an API and test diff.
4
+
5
+ ```markdown
6
+ # Senior Developer Quality & Lean Code Review
7
+
8
+ - **Files Changed:** `3`
9
+ - **Findings:** `2` (1 Must fix, 1 Should fix, 0 Nice to have)
10
+
11
+ ### 🚨 Must Fix (Blockers)
12
+
13
+ #### 1. Swallowed Database Exception (`src/services/billing.py:84`)
14
+ - **What this is:** Try-catch block around payment transaction commit.
15
+ - **Problem:** When the gateway returns a network error, the exception is caught with `pass`, silently failing the invoice without alerting the user or reverting the database transaction.
16
+ - **Fix:** Rethrow `PaymentGatewayException` and rollback the active DB transaction.
17
+ - **If we skip it:** Invoices will appear as paid in UI while payments actually failed.
18
+
19
+ ### ⚠️ Should Fix (Reliability & Scale)
20
+
21
+ #### 2. Static Sleep in Async Test (`tests/test_billing.py:32`)
22
+ - **What this is:** `time.sleep(3)` placed after dispatching webhook.
23
+ - **Problem:** Static wait causes test flakiness on slower CI runners and wastes 3 seconds on fast local runs.
24
+ - **Fix:** Replace with `await waitForCondition(isWebhookReceived, timeout=5000)`.
25
+ - **If we skip it:** CI pipeline will intermittently fail on high queue load.
26
+
27
+ ### Verdict
28
+ ❌ **Action Required:** Resolve 1 blocker before merging.
29
+ ```
@@ -0,0 +1,70 @@
1
+ ---
2
+ name: technical-debt-harvester
3
+ description: "Harvest shortcut: comments into a tracked debt ledger so deliberate compromises do not rot into forgotten tech debt."
4
+ category: architecture_and_analysis
5
+ version: "1.0.0"
6
+ ---
7
+
8
+ # Technical Debt Harvester — Pragmatic Shortcut & Deferral Tracker
9
+
10
+ Harvest deliberate shortcut comments (`shortcut: <limit>, <when to upgrade>`) across the entire repository into a structured Markdown ledger so pragmatic compromises do not silently rot into permanent defects.
11
+
12
+ ---
13
+
14
+ ## 1. The Shortcut Comment Standard
15
+
16
+ When writing lean code or taking a pragmatic shortcut under time or scope constraints, leave an inline comment specifying the **ceiling (limit)** and the **upgrade trigger**:
17
+
18
+ ```python
19
+ # Format:
20
+ # shortcut: <the limit>, <when to upgrade>
21
+
22
+ # Examples:
23
+ # shortcut: max 100 items in memory, migrate to Redis if active sessions exceed 1,000
24
+ # shortcut: SQLite database, switch to PostgreSQL when concurrent writers > 5
25
+ ```
26
+
27
+ Any shortcut comment that omits an upgrade trigger is classified as `no-trigger` and flagged for review.
28
+
29
+ ---
30
+
31
+ ## 2. Supported Comment Syntaxes
32
+
33
+ The harvester automatically detects markers across all common language comment styles:
34
+ - `# shortcut:` (Python, Bash, Ruby, YAML)
35
+ - `// shortcut:` (TypeScript, JavaScript, Java, Groovy, C++, Go, Rust, C#)
36
+ - `/* shortcut: ... */` (CSS, Multi-line blocks)
37
+ - `-- shortcut:` (SQL, Lua)
38
+ - `<!-- shortcut: ... -->` (HTML, XML, Markdown)
39
+
40
+ *(Also backwards compatible with older `ponytail:` comments).*
41
+
42
+ ---
43
+
44
+ ## 3. Automation CLI
45
+
46
+ ```bash
47
+ # Scan working directory and display ledger
48
+ python3 tools/debt_harvester.py
49
+
50
+ # Save output to Markdown file
51
+ python3 tools/debt_harvester.py --output DEBT_LEDGER.md
52
+
53
+ # Output in JSON format for CI tooling
54
+ python3 tools/debt_harvester.py --json
55
+
56
+ # Scan with custom keyword
57
+ python3 tools/debt_harvester.py --keyword "DEBT:"
58
+ ```
59
+
60
+ Or via the unified CLI:
61
+ ```bash
62
+ agent-qa debt
63
+ agent-qa debt --output DEBT_LEDGER.md
64
+ ```
65
+
66
+ ---
67
+
68
+ ## 4. Attribution
69
+
70
+ Adapted from **ponytail-debt** (https://github.com/DietrichGebert/ponytail) — MIT License, Copyright (c) 2026 DietrichGebert. Re-architected with native Python tooling for Synapse Hub.
@@ -0,0 +1,25 @@
1
+ # Sample Technical Debt Ledger
2
+
3
+ Representative output from `agent-qa debt`:
4
+
5
+ ```markdown
6
+ # Technical Debt & Shortcut Ledger
7
+
8
+ > **Ledger Policy:** Deliberate shortcuts prevent over-engineering. Track limits and upgrade triggers so they never rot silently into permanent defects.
9
+
10
+ - **Repository:** `order-service`
11
+ - **Total Shortcuts:** `3`
12
+ - **Missing Upgrade Triggers:** `1` ⚠️ *(Action Required)*
13
+
14
+ ---
15
+
16
+ | Location | Description | Ceiling (Limit) | Upgrade Trigger | Status |
17
+ | :--- | :--- | :--- | :--- | :--- |
18
+ | `src/cache.py:24` | In-memory Python dictionary cache | 1,000 active sessions | Migrate to Redis when worker count > 2 | ✅ Tracked |
19
+ | `src/auth.py:89` | Synchronous token verification | Max 50 req/sec | Switch to async JWKS cache under high load | ✅ Tracked |
20
+ | `src/pdf.py:14` | Hardcoded paper margin 10px | Not specified | None | ⚠️ `no-trigger` |
21
+
22
+ ### Recommended Action
23
+ 1. Review the `1` shortcut tagged `no-trigger` above and define concrete upgrade conditions.
24
+ 2. Run `agent-qa debt` in CI to monitor debt accumulation.
25
+ ```
@@ -0,0 +1,20 @@
1
+ # Sample Technical Debt Ledger
2
+
3
+ ## Example Output
4
+ ```markdown
5
+ # Technical Debt & Shortcut Ledger
6
+
7
+ > **Ledger Policy:** Deliberate shortcuts prevent over-engineering. Track limits and upgrade triggers so they never rot silently into permanent defects.
8
+
9
+ - **Repository:** `OrderService`
10
+ - **Total Shortcuts:** `2`
11
+ - **Missing Upgrade Triggers:** `0` ✅ *(All tracked)*
12
+
13
+ ---
14
+
15
+ ### Tracked Shortcuts
16
+ 1. `src/services/OrderProcessor.groovy:45`
17
+ - *Shortcut:* In-memory map cache
18
+ - *Ceiling:* 10,000 active orders
19
+ - *Upgrade Trigger:* Migrate to Redis when daily active orders > 10,000
20
+ ```
@@ -0,0 +1,49 @@
1
+ # Context Engineering & Token Optimization Guide (Full Architecture)
2
+
3
+ *(Synthesized from `muratcankoylan/Agent-Skills-for-Context-Engineering`, `alexgreensh/token-optimizer`, and `obra/superpowers`)*
4
+
5
+ ---
6
+
7
+ ## 1. Pillar 1: Observation Masking
8
+ Raw tool outputs (CLI execution logs, Gradle builds, browser console traces) contain 90% repetitive noise and low-signal tokens.
9
+ - **Log Truncation & Summarization:** Never dump thousands of lines into the active conversation. Extract only: failing line number, exception name, test case identifier (`TC-xxx`), and status.
10
+ - **Pointer Masking:** Use structured references pointing to files on disk: `[Full raw log saved to file://<path>; 2,400 verbose lines omitted]`.
11
+
12
+ ---
13
+
14
+ ## 2. Pillar 2: Progressive Disclosure
15
+ Never load large codebases or giant classes (over 500 lines) into context at once. Load information in 3 progressive tiers:
16
+ - **Tier 1:** High-Level Index & Repo Map (< 150 lines) via `tools/repo_map.txt`.
17
+ - **Tier 2:** Graph Semantic Scoping via `graphify explain` or `test_impact.py`.
18
+ - **Tier 3:** Targeted Micro-Read (20-50 lines using `StartLine`/`EndLine`).
19
+
20
+ ---
21
+
22
+ ## 3. Pillar 3: KV-Cache Friendly Ordering
23
+ LLM inference engines cache Key-Value (KV) attention states for identical prompt prefixes.
24
+ - **Static Prefix First:** Keep instructions, rules, and tool schemas immutable at the top.
25
+ - **Append-Only Dynamic State:** Only append new test results and tool observations at the bottom.
26
+ - **Predictable Format:** Use identical pre-flight status badges on every turn to maximize cache hits (> 85%).
27
+
28
+ ---
29
+
30
+ ## 4. Pillar 4: Scoped Context & Compaction Anchoring
31
+ - **Compaction State Anchoring:** Critical state must be persisted to disk in `PROJECT_STATE.md`. When compaction fires, re-anchor immediately from disk with zero memory loss.
32
+ - **Workspace Isolation (`Workspace: 'share'`):** Subagents use isolated worktrees to prevent dirty tree collisions.
33
+ - **Zero Context Contagion:** Subagents return distilled 3-5 line summaries; stdout remains in subagent sandbox.
34
+ - **Data Partitioning:** Subagents append agent IDs to test data (`uniqueCode = "AUTO_" + time + "_SUB" + id`).
35
+
36
+ ---
37
+
38
+ ## 5. Pillar 5: Semantic Context Distillation (Pure Signal, Zero Noise)
39
+ All sensory inputs must pass through deterministic filters:
40
+ - **CLI Logs (`tools/distill_log.py`):** Truncate 95% of verbose lines.
41
+ - **DOM Purifier (`qa.getCompactAOM`):** Strictly forbidden to send raw HTML. Use compact AOM (< 500 tokens).
42
+ - **Universal IR (`tools/universal_ir.py`):** Author clean universal IR before emitting framework-specific code.
43
+
44
+ ---
45
+
46
+ ## 6. Pillar 6: Elephant-Goldfish Memory Model
47
+ - **The Elephant (Stateful Orchestrator):** Narrows problem boundaries, gathers intent, drafts specs in `docs/specs/*.md`, maintains `PROJECT_STATE.md`. Never writes tests during design phase.
48
+ - **The Goldfish (Stateless Subagent Swarm):** Fresh subagent with ZERO conversation history; evaluates solely cold artifacts on disk via `tools/goldfish_review.py`.
49
+ - **Air-Gap Data Contract:** All inter-stage data exchanges pass via disk files (JSON/JUnit XML), never raw prompt inheritance.