kenaz 0.3.22 → 0.3.24

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 (474) hide show
  1. package/core/.claude/hooks/_user-scope.js +1 -1
  2. package/core/.claude/hooks/core-resolve.js +1 -1
  3. package/core/.claude/hooks/worktree-create.js +11 -29
  4. package/core/.claude/hooks/worktree-remove.js +12 -38
  5. package/core/.collaboration/core/reconcile.js +16 -1
  6. package/core/.collaboration/core/task-2467-lifecycle.test.js +63 -0
  7. package/core/.collaboration/core/task-api.js +37 -7
  8. package/core/.formation/bifrost/launch.js +1 -1
  9. package/core/.formation/tools/dispatch-detail/worktree-subagent-mode.md +6 -1
  10. package/core/.formation/tools/kenaz-stats.js +1 -1
  11. package/core/.formation/tools/post-complete/git-merge.js +1 -1
  12. package/core/.formation/tools/prompt.js +1 -1
  13. package/core/.formation/tools/utils.js +5 -5
  14. package/core/.formation/tools/worktree-reclaim.js +73 -2
  15. package/core/.formation/tools/worktree-reclaim.test.js +113 -0
  16. package/core/.kenaz/specialist/ansuz_rules.yaml +7 -51
  17. package/core/.kenaz/specialist/ansuz_session_handoff.schema.json +2 -6
  18. package/core/.rule/general/project-self-containment.yaml +2 -2
  19. package/core/.specialist/Amelia/README.md +1 -1
  20. package/core/.specialist/Amelia/rule.yaml +1 -1
  21. package/core/.specialist/Ansuz/RULES.md +6 -2
  22. package/core/.specialist/Ansuz/concepts/commitment_layer.yaml +1 -1
  23. package/core/.specialist/Ansuz/concepts/evolvable_guardrails.yaml +1 -1
  24. package/core/.specialist/Ansuz/knowledge.yaml +1 -3
  25. package/core/.specialist/tools/__tests__/task-2409-lessons.test.js +10 -0
  26. package/core/.specialist/tools/__tests__/task-2427-harvest.test.js +25 -0
  27. package/core/.specialist/tools/ansuz-boot-fast.js +1 -1
  28. package/core/.specialist/tools/failure-detector.js +4 -4
  29. package/core/.specialist/tools/handoff-doc.js +1 -1
  30. package/core/.specialist/tools/lessons.js +2 -2
  31. package/core/CLAUDE.md +5 -5
  32. package/core/KENAZ_CORE_VERSION +1 -1
  33. package/core/dashboard/scripts/install-kenaz-cli.js +56 -30
  34. package/core/dev/scripts/check-file-size.js +1 -1
  35. package/core/dev/scripts/ci-feedback.js +1 -1
  36. package/core/dev/scripts/gc-agent-worktrees.js +13 -12
  37. package/core/dev/scripts/kenaz-session.js +3 -3
  38. package/core/dev/scripts/peer-identity-e2e.js +6 -4
  39. package/core/dev/scripts/run-rust-tests.js +2 -2
  40. package/core/dev/scripts/skill-routing-replay.js +3 -3
  41. package/core/dev/scripts/task1961/selftest.js +2 -2
  42. package/core/dev/scripts/windows-hide-guard.test.js +112 -0
  43. package/core/plugins/kenaz/guidance.md +1 -0
  44. package/core/plugins/kenaz/hooks/core-resolve.js +1 -1
  45. package/core/plugins/kenaz/hooks/hooks.json +9 -0
  46. package/core/plugins/kenaz/hooks/kenaz-hook.js +58 -4
  47. package/core/plugins/kenaz/hooks/worktree-guard.js +121 -0
  48. package/core/plugins/kenaz/hooks/worktree-guard.test.js +75 -0
  49. package/core/plugins/kenaz/scripts/kenaz.test.js +72 -5
  50. package/core/plugins/kenaz-peer/hooks/register.test.ts +14 -2
  51. package/core/plugins/kenaz-peer/hooks/register.ts +6 -1
  52. package/lib/cli.js +9 -5
  53. package/package.json +6 -6
  54. package/vendor/install-kenaz-cli.js +56 -30
  55. package/core/.kenaz/designs/METAPLASTICITY_CONFIDENCE_DESIGN.md +0 -537
  56. package/core/.kenaz/designs/REFLEX_INITIATOR_DESIGN.md +0 -501
  57. package/core/.kenaz/designs/TASK_1385_handoff_mcp_design.md +0 -426
  58. package/core/.kenaz/designs/TASK_932_hippocampus_consolidation.md +0 -103
  59. package/core/.kenaz/designs/TASK_934_efe_signal_engine.md +0 -97
  60. package/core/.kenaz/designs/TASK_935_self_evolution_framework.md +0 -154
  61. package/core/.kenaz/designs/VISION_cognitive_architecture_roadmap.md +0 -159
  62. package/core/.kenaz/designs/metaplasticity_simulation_results.json +0 -696
  63. package/core/.kenaz/main-memory/README.md +0 -230
  64. package/core/.kenaz/main-memory/kenaz/cortex/001_cortex_overview.md +0 -168
  65. package/core/.kenaz/main-memory/kenaz/cortex/001_rag_engine_overview.md +0 -30
  66. package/core/.kenaz/main-memory/kenaz/memory-system/001_three_tier_architecture.md +0 -361
  67. package/core/.kenaz/main-memory/kenaz/pipeline/001_task_execution_flow.md +0 -117
  68. package/core/.kenaz/main-memory/kenaz/pipeline/001_task_granularity.md +0 -154
  69. package/core/.kenaz/main-memory/kenaz/pipeline/002_team_priority.md +0 -51
  70. package/core/.kenaz/main-memory/kenaz/pipeline/003_feature_id_system.md +0 -46
  71. package/core/.kenaz/main-memory/kenaz/rules/001_gen_007_self_containment.md +0 -108
  72. package/core/.kenaz/main-memory/kenaz/rules/001_rule_priority_system.md +0 -121
  73. package/core/.kenaz/main-memory/kenaz/rules/002_agt_006_pre_check.md +0 -0
  74. package/core/.kenaz/main-memory/kenaz/rules/003_ppl_002_task_archival.md +0 -48
  75. package/core/.kenaz/main-memory/kenaz/system/001_dual_track_task_system.md +0 -197
  76. package/core/.kenaz/main-memory/knowledge/patterns/001_json_bom_issue.md +0 -78
  77. package/core/.kenaz/main-memory/knowledge/patterns/001_leader_worker_pattern.md +0 -0
  78. package/core/.kenaz/main-memory/knowledge/patterns/002_scope_path_conflict.md +0 -115
  79. package/core/.kenaz/main-memory/knowledge/patterns/002_task_dependency_resolution.md +0 -223
  80. package/core/.kenaz/main-memory/knowledge/patterns/003_question_protocol.md +0 -242
  81. package/core/.kenaz/main-memory/knowledge/patterns/004_user_insight_value.md +0 -111
  82. package/core/.kenaz/main-memory/knowledge/patterns/005_file_lock_pattern.md +0 -274
  83. package/core/.kenaz/main-memory/knowledge/references/001_ppl_rules.md +0 -28
  84. package/core/.kenaz/main-memory/knowledge/solutions/001_json_bom_issue.md +0 -137
  85. package/core/.kenaz/main-memory/knowledge/solutions/001_team_invocation.md +0 -0
  86. package/core/.kenaz/main-memory/knowledge/solutions/002_passive_monitoring.md +0 -0
  87. package/core/.kenaz/main-memory/knowledge/solutions/003_windows_file_race_condition.md +0 -239
  88. package/core/.kenaz/main-memory/registry.json +0 -326
  89. package/core/.kenaz/main-memory/version.yaml +0 -58
  90. package/core/.kenaz/specialist/memory_guard_fired.json +0 -1
  91. package/core/.kenaz/specialist/memory_guard_trigger_cache.json +0 -1
  92. package/core/.kenaz/specialist/memory_source_priority.yaml +0 -260
  93. package/core/.kenaz/specialist/prompt_1775.txt +0 -317
  94. package/core/.kenaz/specialist/prompt_1776.txt +0 -326
  95. package/core/.kenaz/specialist/prompt_1791.txt +0 -320
  96. package/core/.kenaz/specialist/prompt_1792.txt +0 -320
  97. package/core/.kenaz/specialist/prompt_1795.txt +0 -281
  98. package/core/.kenaz/specialist/prompt_1813.txt +0 -332
  99. package/core/.kenaz/specialist/prompt_1814.txt +0 -401
  100. package/core/.kenaz/specialist/prompt_1815.txt +0 -394
  101. package/core/.kenaz/specialist/prompt_1816.txt +0 -437
  102. package/core/.kenaz/specialist/prompt_1818.txt +0 -361
  103. package/core/.kenaz/specialist/prompt_1819.txt +0 -421
  104. package/core/.kenaz/specialist/prompt_1821.txt +0 -345
  105. package/core/.kenaz/specialist/prompt_1822.txt +0 -313
  106. package/core/.kenaz/specialist/prompt_1824.txt +0 -348
  107. package/core/.kenaz/specialist/prompt_1826.txt +0 -388
  108. package/core/.kenaz/specialist/rune_efe_salience_gap.md +0 -21
  109. package/core/.kenaz/specialist/task1825_update.json +0 -43
  110. package/core/.kenaz/specialist/taskgen/consolidation_i.json +0 -38
  111. package/core/.kenaz/specialist/taskgen/csharp_a.json +0 -44
  112. package/core/.kenaz/specialist/taskgen/csharp_b.json +0 -40
  113. package/core/.kenaz/specialist/taskgen/embedding_e.json +0 -34
  114. package/core/.kenaz/specialist/taskgen/hygiene_fg.json +0 -39
  115. package/core/.kenaz/specialist/taskgen/pathology_h.json +0 -36
  116. package/core/.kenaz/specialist/taskgen/unity_noise_d.json +0 -38
  117. package/core/.kenaz/specialist/taskgen/visibility_c.json +0 -38
  118. package/core/.specialist/Ansuz/decisions/ADR-requirement-graph-layer.md +0 -390
  119. package/core/.specialist/Ansuz/self_model_seed.backup.json +0 -100
  120. package/core/.specialist/ansuz_session_handoff.json +0 -96
  121. package/core/dev/ALAYA_FIELD_FEEDBACK_DESIGN.md +0 -126
  122. package/core/dev/ANSUZ_SCAFFOLD_DIET_2026-09-20.md +0 -231
  123. package/core/dev/ANSUZ_STARTUP_INJECTION_REVIEW.md +0 -355
  124. package/core/dev/ANSUZ_WORKFLOW_MODERNIZATION.md +0 -143
  125. package/core/dev/CORTEX_META_GRAPH_ASSESSMENT.md +0 -99
  126. package/core/dev/FREYA_DOWNSTREAM_BUGS_2026-09-19.md +0 -44
  127. package/core/dev/GLOBAL_MEMORY_IDENTITY_CONSOLIDATION.md +0 -263
  128. package/core/dev/GUARD_EFFECTIVENESS_DESIGN.md +0 -180
  129. package/core/dev/HEALTH_GATE_VARIANCE_ASSESSMENT.md +0 -271
  130. package/core/dev/HOOK_DIET_2026-09-21.md +0 -126
  131. package/core/dev/JEV_INTEGRATION_PLAN.md +0 -189
  132. package/core/dev/KENAZ_AGENT_CONNECT_v1_SPEC.md +0 -139
  133. package/core/dev/MOBILE_DESIGN_SPEC.md +0 -569
  134. package/core/dev/MULTI_ANSUZ_SPEC.md +0 -136
  135. package/core/dev/MUNINN_RETIREMENT.md +0 -115
  136. package/core/dev/PHASE3_ATTRIBUTION_POPULATION_DIAGNOSIS.md +0 -211
  137. package/core/dev/PHASE3_P3-2B_TASKLEVEL_PROBE.md +0 -83
  138. package/core/dev/PHASE3_P3-2_POPULATION_DISJOINTNESS.md +0 -83
  139. package/core/dev/PHASE3_P3-2_REMEASURE_REPORT.md +0 -231
  140. package/core/dev/PREDICTION_GROUNDING_DESIGN.md +0 -376
  141. package/core/dev/PRODUCT_SPEC.md +0 -317
  142. package/core/dev/PROJECT_REGISTRY_DUPLICATE_ASSESSMENT.md +0 -86
  143. package/core/dev/STARTUP_TIMELINE_TASK_1995.md +0 -181
  144. package/core/dev/SYNAPSE_WORKER_PER_PROJECT.md +0 -881
  145. package/core/dev/TASK_1680_P3-3_DISPATCH_SPEC.md +0 -96
  146. package/core/dev/TASK_1684_CALIBRATION_IMPACT_ANALYSIS.md +0 -170
  147. package/core/dev/TASK_1684_FORK_A_GOODHART_DESIGN.md +0 -171
  148. package/core/dev/TASK_1684_P3_2_REMEASURE_VALIDATION.md +0 -262
  149. package/core/dev/TASK_1903_SIGNAL_AUC_MEASUREMENT.md +0 -207
  150. package/core/dev/TASK_1904_BRANCH_INTEGRITY_AUDIT.md +0 -146
  151. package/core/dev/ansuz-eval/README.md +0 -38
  152. package/core/dev/ansuz-eval/build-fixtures.js +0 -87
  153. package/core/dev/ansuz-eval/grade.js +0 -96
  154. package/core/dev/ansuz-eval/grader.test.js +0 -117
  155. package/core/dev/ansuz-eval/tasks.md +0 -32
  156. package/core/dev/archive/ansuz/BOOT_FULL.md +0 -141
  157. package/core/dev/archive/ansuz/agents/ansuz-boot.md +0 -176
  158. package/core/dev/archive/ansuz/designs/alaya-passive-surfacing.md +0 -84
  159. package/core/dev/archive/ansuz/designs/cc_memory_indexing.md +0 -307
  160. package/core/dev/archive/ansuz/designs/check_guard.md +0 -322
  161. package/core/dev/archive/ansuz/designs/consequence_loop.md +0 -227
  162. package/core/dev/archive/ansuz/designs/mcp_kuzudb_lock_architecture.md +0 -312
  163. package/core/dev/archive/ansuz/designs/phase0_git_enrichment.md +0 -278
  164. package/core/dev/archive/ansuz/designs/refactor_mcp_tools_synapse.md +0 -490
  165. package/core/dev/archive/ansuz/designs/semantic_markdown_extraction.md +0 -167
  166. package/core/dev/archive/ansuz/designs/task_1372_prompt_injects_into.md +0 -193
  167. package/core/dev/archive/ansuz/designs/thought_stack.md +0 -286
  168. package/core/dev/archive/ansuz/investigations/reachability_unified_api_2026-04-11.md +0 -330
  169. package/core/dev/archive/ansuz/investigations/synapse_orphans_indexing_bug_2026-04-11.md +0 -352
  170. package/core/dev/archive/ansuz/investigations/synapse_orphans_reindex_verification_2026-04-11.md +0 -48
  171. package/core/dev/archive/ansuz/investigations/synapse_orphans_verification_2026-04-11.md +0 -170
  172. package/core/dev/archive/ansuz/legacy/kernel.yaml +0 -399
  173. package/core/dev/archive/ansuz/legacy/phases/phase_0.yaml +0 -418
  174. package/core/dev/archive/ansuz/legacy/phases/phase_1.yaml +0 -376
  175. package/core/dev/archive/ansuz/legacy/phases/phase_10.yaml +0 -35
  176. package/core/dev/archive/ansuz/legacy/phases/phase_11.yaml +0 -582
  177. package/core/dev/archive/ansuz/legacy/phases/phase_2.yaml +0 -94
  178. package/core/dev/archive/ansuz/legacy/phases/phase_3.yaml +0 -274
  179. package/core/dev/archive/ansuz/legacy/phases/phase_4.yaml +0 -67
  180. package/core/dev/archive/ansuz/legacy/phases/phase_5.yaml +0 -32
  181. package/core/dev/archive/ansuz/legacy/phases/phase_6.yaml +0 -91
  182. package/core/dev/archive/ansuz/legacy/phases/phase_7.yaml +0 -58
  183. package/core/dev/archive/ansuz/legacy/phases/phase_8.yaml +0 -146
  184. package/core/dev/archive/ansuz/legacy/phases/phase_9.yaml +0 -424
  185. package/core/dev/archive/ansuz/specs/INDEX_bifrost_hook_parity.yaml +0 -92
  186. package/core/dev/archive/ansuz/specs/active-inference-formation.yaml +0 -453
  187. package/core/dev/archive/ansuz/specs/brief_TASK_1228_userpromptsubmit.yaml +0 -191
  188. package/core/dev/archive/ansuz/specs/brief_TASK_1229_pretooluse_posttooluse.yaml +0 -250
  189. package/core/dev/archive/ansuz/specs/brief_TASK_1230_sessionstart_stop.yaml +0 -301
  190. package/core/dev/archive/ansuz/specs/brief_TASK_1231_verification.yaml +0 -272
  191. package/core/dev/archive/skills/feature_agent/SKILL.md +0 -289
  192. package/core/dev/design/PHASE4_DESIGN.md +0 -559
  193. package/core/dev/design/dashboard_docs_integration_PLAN.md +0 -388
  194. package/core/dev/design/matrix_format_ABBREVIATIONS.md +0 -655
  195. package/core/dev/design/matrix_format_DESIGN_SPEC.md +0 -601
  196. package/core/dev/design/matrix_format_DISCUSSION_SUMMARY.md +0 -484
  197. package/core/dev/design/matrix_format_EXAMPLE_memory.matrix +0 -13
  198. package/core/dev/design/matrix_format_EXAMPLE_project_status.matrix +0 -9
  199. package/core/dev/design/matrix_format_EXAMPLE_tasks.matrix +0 -14
  200. package/core/dev/design/matrix_format_SYNTAX_BNF.md +0 -754
  201. package/core/dev/design/matrix_format_TOKEN_COMPARISON.md +0 -484
  202. package/core/dev/design/matrix_v2_COGNITIVE_DESIGN.md +0 -503
  203. package/core/dev/design/matrix_v2_DISCUSSION_SUMMARY.md +0 -414
  204. package/core/dev/design/matrix_v2_EXAMPLE.matrix +0 -67
  205. package/core/dev/designs/EXPANDABLE_CARD_DESIGN_SPEC.md +0 -509
  206. package/core/dev/jev-eval/ACTIVE_CORRECTION.md +0 -52
  207. package/core/dev/jev-eval/ANNOTATION_GUIDE.md +0 -68
  208. package/core/dev/jev-eval/BASELINE_COMPARISON.md +0 -45
  209. package/core/dev/jev-eval/CONTEXT_REVIEW.md +0 -31
  210. package/core/dev/jev-eval/EVALUATION_STATUS.md +0 -39
  211. package/core/dev/jev-eval/HISTORICAL_CORPUS.md +0 -33
  212. package/core/dev/jev-eval/PACKAGING_VERIFICATION.md +0 -42
  213. package/core/dev/jev-eval/README.md +0 -101
  214. package/core/dev/jev-eval/THALAMUS_RANKING.md +0 -58
  215. package/core/dev/jev-eval/VALIDATION_PROGRESS.md +0 -54
  216. package/core/dev/jev-eval/cli.mjs +0 -50
  217. package/core/dev/jev-eval/context.mjs +0 -183
  218. package/core/dev/jev-eval/corpus.mjs +0 -186
  219. package/core/dev/jev-eval/fixtures/conversation-review.seed.jsonl +0 -6
  220. package/core/dev/jev-eval/fixtures/synthetic.jsonl +0 -11
  221. package/core/dev/jev-eval/metrics.mjs +0 -67
  222. package/core/dev/jev-eval/muninn-baseline.mjs +0 -119
  223. package/core/dev/jev-eval/providers.mjs +0 -95
  224. package/core/dev/jev-eval/reports/annotation-pilot-2026-09-20.json +0 -32
  225. package/core/dev/jev-eval/reports/context-review-2026-09-20.json +0 -48
  226. package/core/dev/jev-eval/reports/conversation-review.pending.json +0 -151
  227. package/core/dev/jev-eval/reports/history-corpus-2026-09-20.json +0 -52
  228. package/core/dev/jev-eval/reports/length-probe-2026-09-20.json +0 -133
  229. package/core/dev/jev-eval/reports/live-smoke-2026-09-20.json +0 -616
  230. package/core/dev/jev-eval/reports/muninn-baseline-2026-09-20.json +0 -52
  231. package/core/dev/jev-eval/reports/resilience-2026-09-20.json +0 -520
  232. package/core/dev/jev-eval/reports/rules-baseline.json +0 -197
  233. package/core/dev/jev-eval/reports/synthetic-review.pending.json +0 -357
  234. package/core/dev/jev-eval/resilience.mjs +0 -71
  235. package/core/dev/jev-eval/review.mjs +0 -78
  236. package/core/dev/jev-eval/schema.mjs +0 -87
  237. package/core/dev/jev-eval/test/context.test.mjs +0 -95
  238. package/core/dev/jev-eval/test/corpus.test.mjs +0 -102
  239. package/core/dev/jev-eval/test/eval.test.mjs +0 -146
  240. package/core/dev/jev-eval/test/muninn-baseline.test.mjs +0 -71
  241. package/core/dev/jev-eval/test/resilience.test.mjs +0 -72
  242. package/core/dev/jev-eval/test/review.test.mjs +0 -61
  243. package/core/dev/pipeline/PHASE3_PLANNING_SUMMARY.md +0 -338
  244. package/core/dev/pipeline/PROGRESS.md +0 -113
  245. package/core/dev/pipeline/PROGRESS_template.md +0 -860
  246. package/core/dev/pipeline/QA_REPORT_F008.md +0 -431
  247. package/core/dev/pipeline/QA_REPORT_LOCAL_CLAUDE_DIAGNOSIS.md +0 -583
  248. package/core/dev/pipeline/README.md +0 -210
  249. package/core/dev/pipeline/WORKFLOW_GUIDE.md +0 -824
  250. package/core/dev/pipeline/archived/TASK_015_tauri_init.yaml +0 -53
  251. package/core/dev/pipeline/archived/TASK_016_tauri_commands.yaml +0 -54
  252. package/core/dev/pipeline/archived/TASK_017_rust_pty.yaml +0 -54
  253. package/core/dev/pipeline/archived/TASK_018_tauri_bundle.yaml +0 -53
  254. package/core/dev/pipeline/archived/TASK_019_release_workflow.yaml +0 -56
  255. package/core/dev/pipeline/archived/TASK_020_update_ui.yaml +0 -54
  256. package/core/dev/pipeline/archived/TASK_021_update_notification_ui.yaml +0 -55
  257. package/core/dev/pipeline/archived/TASK_022_remove_node_pty.yaml +0 -65
  258. package/core/dev/pipeline/archived/TASK_023_api_routes_migration.yaml +0 -86
  259. package/core/dev/pipeline/archived/TASK_024_feature_id_system.yaml +0 -51
  260. package/core/dev/pipeline/archived/TASK_025_executable_acceptance.yaml +0 -66
  261. package/core/dev/pipeline/archived/TASK_026_spec_versioning.yaml +0 -56
  262. package/core/dev/pipeline/archived/TASK_027_drift_detection.yaml +0 -60
  263. package/core/dev/pipeline/archived/TASK_028_tauri_pty_manager.yaml +0 -60
  264. package/core/dev/pipeline/archived/TASK_029_tauri_pty_commands.yaml +0 -62
  265. package/core/dev/pipeline/archived/TASK_030_frontend_session_adapter.yaml +0 -54
  266. package/core/dev/pipeline/archived/TASK_031_terminal_tauri_events.yaml +0 -56
  267. package/core/dev/pipeline/archived/TASK_041_scheduler_data_models.yaml +0 -54
  268. package/core/dev/pipeline/archived/TASK_042_path_lock_manager.yaml +0 -53
  269. package/core/dev/pipeline/archived/TASK_043_process_manager.yaml +0 -57
  270. package/core/dev/pipeline/archived/TASK_044_git_integration.yaml +0 -85
  271. package/core/dev/pipeline/archived/TASK_045_task_queue_manager.yaml +0 -54
  272. package/core/dev/pipeline/archived/TASK_046_scheduler_dispatcher.yaml +0 -60
  273. package/core/dev/pipeline/archived/TASK_047_tauri_scheduler_commands.yaml +0 -55
  274. package/core/dev/pipeline/archived/TASK_048_realtime_status_push.yaml +0 -92
  275. package/core/dev/pipeline/archived/TASK_049_frontend_scheduler_integration.yaml +0 -58
  276. package/core/dev/pipeline/archived/TASK_050_error_recovery.yaml +0 -56
  277. package/core/dev/pipeline/archived/TASK_051_optimization_proposals_backend.yaml +0 -53
  278. package/core/dev/pipeline/archived/TASK_052_optimization_proposals_ui.yaml +0 -58
  279. package/core/dev/pipeline/archived/TASK_053_optimization_proposals_diff_view.yaml +0 -54
  280. package/core/dev/pipeline/archived/TASK_054_multi_project_scheduler_state.yaml +0 -76
  281. package/core/dev/pipeline/archived/TASK_055_scheduler_api_project_scope.yaml +0 -64
  282. package/core/dev/pipeline/archived/TASK_056_frontend_scheduler_project_scope.yaml +0 -62
  283. package/core/dev/pipeline/archived/TASK_057_scheduler_module_structure.yaml +0 -54
  284. package/core/dev/pipeline/archived/TASK_058_scheduler_models_extract.yaml +0 -51
  285. package/core/dev/pipeline/archived/TASK_059_scheduler_core_extract.yaml +0 -51
  286. package/core/dev/pipeline/archived/TASK_060_scheduler_commands_extract.yaml +0 -51
  287. package/core/dev/pipeline/archived/TASK_061_scheduler_specialized_commands.yaml +0 -53
  288. package/core/dev/pipeline/archived/TASK_062_process_manager_module_structure.yaml +0 -56
  289. package/core/dev/pipeline/archived/TASK_063_process_manager_core_extract.yaml +0 -56
  290. package/core/dev/pipeline/archived/TASK_064_recovery_module_structure.yaml +0 -57
  291. package/core/dev/pipeline/archived/TASK_065_recovery_core_extract.yaml +0 -56
  292. package/core/dev/pipeline/archived/TASK_066_self_enhancement_scheduler_models.yaml +0 -60
  293. package/core/dev/pipeline/archived/TASK_067_agents_section_quick_actions.yaml +0 -53
  294. package/core/dev/pipeline/archived/TASK_067_self_enhancement_scheduler_core.yaml +0 -65
  295. package/core/dev/pipeline/archived/TASK_068_agent_workflow_rule_enhancement.yaml +0 -46
  296. package/core/dev/pipeline/archived/TASK_068_self_enhancement_tauri_commands.yaml +0 -61
  297. package/core/dev/pipeline/archived/TASK_069_agent_wizard_responsive.yaml +0 -46
  298. package/core/dev/pipeline/archived/TASK_069_self_enhancement_ui.yaml +0 -62
  299. package/core/dev/pipeline/archived/TASK_070_preview_panel_redesign.yaml +0 -62
  300. package/core/dev/pipeline/archived/TASK_070_self_enhancement_integration.yaml +0 -57
  301. package/core/dev/pipeline/archived/TASK_071_preview_panel_qa.yaml +0 -98
  302. package/core/dev/pipeline/archived/TASK_071_single_agent_config.yaml +0 -57
  303. package/core/dev/pipeline/archived/TASK_072_preview_modal_esc_fix.yaml +0 -71
  304. package/core/dev/pipeline/archived/TASK_072_product_review_module.yaml +0 -57
  305. package/core/dev/pipeline/archived/TASK_073_agents_page_component_refactor.yaml +0 -68
  306. package/core/dev/pipeline/archived/TASK_073_rename_single_agent.yaml +0 -64
  307. package/core/dev/pipeline/archived/TASK_074_preview_mode_ui_diagnosis.yaml +0 -71
  308. package/core/dev/pipeline/archived/TASK_074_single_agent_ui_toggle.yaml +0 -56
  309. package/core/dev/pipeline/archived/TASK_075_agents_page_component_refactor.yaml +0 -69
  310. package/core/dev/pipeline/archived/TASK_075_single_agent_integration_test.yaml +0 -75
  311. package/core/dev/pipeline/archived/TASK_076_preview_mode_ui_diagnosis.yaml +0 -70
  312. package/core/dev/pipeline/archived/TASK_076_single_agent_continuous_mode.yaml +0 -65
  313. package/core/dev/pipeline/archived/TASK_077_failure_directory_structure.yaml +0 -51
  314. package/core/dev/pipeline/archived/TASK_077_single_agent_typescript_types.yaml +0 -59
  315. package/core/dev/pipeline/archived/TASK_078_fail_001_agent_no_output.yaml +0 -53
  316. package/core/dev/pipeline/archived/TASK_078_single_agent_ui_simplify.yaml +0 -74
  317. package/core/dev/pipeline/archived/TASK_079_dashboard_rwd_responsive.yaml +0 -63
  318. package/core/dev/pipeline/archived/TASK_079_fail_002_json_bom.yaml +0 -56
  319. package/core/dev/pipeline/archived/TASK_080_fail_003_queue_pollution.yaml +0 -56
  320. package/core/dev/pipeline/archived/TASK_080_http_server_module.yaml +0 -55
  321. package/core/dev/pipeline/archived/TASK_081_failure_logging_tools.yaml +0 -57
  322. package/core/dev/pipeline/archived/TASK_081_http_api_routes.yaml +0 -62
  323. package/core/dev/pipeline/archived/TASK_082_frontend_api_adapter.yaml +0 -51
  324. package/core/dev/pipeline/archived/TASK_082_integrate_failure_to_workflow.yaml +0 -60
  325. package/core/dev/pipeline/archived/TASK_083_cleanup_nextjs_api.yaml +0 -48
  326. package/core/dev/pipeline/archived/TASK_083_task_queue_cleanup.yaml +0 -67
  327. package/core/dev/pipeline/archived/TASK_084_rust_dead_code_cleanup.yaml +0 -66
  328. package/core/dev/pipeline/archived/TASK_084_scheduler_sync_logic_fix.yaml +0 -68
  329. package/core/dev/pipeline/archived/TASK_085_http_api_web_mode_fixes.yaml +0 -46
  330. package/core/dev/pipeline/archived/TASK_085_memory_consolidation_0204_0205.yaml +0 -98
  331. package/core/dev/pipeline/archived/TASK_086_collapsible_preview_panel.yaml +0 -161
  332. package/core/dev/pipeline/archived/TASK_086_web_mode_feature_parity.yaml +0 -62
  333. package/core/dev/pipeline/archived/TASK_087_manual_memory_archival.yaml +0 -163
  334. package/core/dev/pipeline/archived/TASK_087_mobile_http_control.yaml +0 -68
  335. package/core/dev/pipeline/archived/TASK_088_fail_003_to_ppl_002_rule.yaml +0 -63
  336. package/core/dev/pipeline/archived/TASK_088_mobile_http_qa.yaml +0 -121
  337. package/core/dev/pipeline/archived/TASK_089_agent_collaboration_topic.yaml +0 -60
  338. package/core/dev/pipeline/archived/TASK_089_web_mode_monitor_fix.yaml +0 -58
  339. package/core/dev/pipeline/archived/TASK_090_cli_detection_fix.yaml +0 -61
  340. package/core/dev/pipeline/archived/TASK_090_ui_ux_lessons_topic.yaml +0 -63
  341. package/core/dev/pipeline/archived/TASK_091_expandable_card_design.yaml +0 -56
  342. package/core/dev/pipeline/archived/TASK_091_move_agent_section_components.yaml +0 -65
  343. package/core/dev/pipeline/archived/TASK_092_expandable_card_component.yaml +0 -60
  344. package/core/dev/pipeline/archived/TASK_092_refactor_agent_create_wizard.yaml +0 -84
  345. package/core/dev/pipeline/archived/TASK_093_taskcard_detail_integration.yaml +0 -57
  346. package/core/dev/pipeline/archived/TASK_093_update_barrel_exports_test.yaml +0 -84
  347. package/core/dev/pipeline/archived/TASK_094_ai_agent_generation_enhancement.yaml +0 -115
  348. package/core/dev/pipeline/archived/TASK_094_proposalcard_detail_integration.yaml +0 -55
  349. package/core/dev/pipeline/archived/TASK_095_preview_fixes.yaml +0 -129
  350. package/core/dev/pipeline/archived/TASK_095_single_agent_task_selector.yaml +0 -60
  351. package/core/dev/pipeline/archived/TASK_096_agents_page_ux_improvements.yaml +0 -163
  352. package/core/dev/pipeline/archived/TASK_096_single_agent_status_sync.yaml +0 -60
  353. package/core/dev/pipeline/archived/TASK_097_local_claude_error_logging.yaml +0 -59
  354. package/core/dev/pipeline/archived/TASK_097_single_agent_monitor_events.yaml +0 -59
  355. package/core/dev/pipeline/archived/TASK_098_product_manager_team_phase2.yaml +0 -60
  356. package/core/dev/pipeline/archived/TASK_098_single_agent_refactor_test.yaml +0 -58
  357. package/core/dev/pipeline/archived/TASK_099_backend_team_creation.yaml +0 -258
  358. package/core/dev/pipeline/archived/TASK_100_frontend_team_creation.yaml +0 -61
  359. package/core/dev/pipeline/archived/TASK_101_orchestrator_system.yaml +0 -403
  360. package/core/dev/pipeline/archived/TASK_102_designer_sre_teams.yaml +0 -90
  361. package/core/dev/pipeline/archived/TASK_103_integration_testing.yaml +0 -86
  362. package/core/dev/pipeline/archived/TASK_128_integration_testing.yaml +0 -83
  363. package/core/dev/pipeline/archived/TASK_134_cortex_v2_phase3_file_watcher.yaml +0 -65
  364. package/core/dev/pipeline/archived/TASK_134_team_http_api.yaml +0 -96
  365. package/core/dev/pipeline/archived/TASK_135_cortex_v2_phase3_git_monitor.yaml +0 -63
  366. package/core/dev/pipeline/archived/TASK_136_cortex_v2_phase3_change_analyzer.yaml +0 -69
  367. package/core/dev/pipeline/archived/TASK_137_cortex_v2_phase3_cache_invalidator.yaml +0 -67
  368. package/core/dev/pipeline/archived/TASK_137_team_orchestrator_integration.yaml +0 -93
  369. package/core/dev/pipeline/archived/TASK_138_cortex_v2_phase3_distributed_cache.yaml +0 -68
  370. package/core/dev/pipeline/archived/TASK_138_matrix_folder_structure.yaml +0 -61
  371. package/core/dev/pipeline/archived/TASK_139_cortex_v2_phase3_cache_prewarming.yaml +0 -65
  372. package/core/dev/pipeline/archived/TASK_146_unified_documentation.yaml +0 -141
  373. package/core/dev/pipeline/archived/TASK_147_pipeline_execution_rules.yaml +0 -76
  374. package/core/dev/pipeline/archived/TASK_148_update_claude_md.yaml +0 -77
  375. package/core/dev/pipeline/archived/TASK_149_fix_nextjs_mdx_serialization.yaml +0 -63
  376. package/core/dev/pipeline/archived/TASK_149_update_team_docs.yaml +0 -77
  377. package/core/dev/pipeline/archived/TASK_150_pipeline_workflow_guide.yaml +0 -82
  378. package/core/dev/pipeline/archived/TASK_164_fix_smart_context_switch.yaml +0 -49
  379. package/core/dev/pipeline/archived/TASK_165_ctags_symbol_index.yaml +0 -53
  380. package/core/dev/pipeline/archived/TASK_166_symbol_search_mcp_tool.yaml +0 -48
  381. package/core/dev/pipeline/archived/TASK_167_llm_module_summary.yaml +0 -55
  382. package/core/dev/pipeline/archived/TASK_168_map_reduce_context.yaml +0 -51
  383. package/core/dev/pipeline/archived/TASK_169_v2_integration_testing.yaml +0 -52
  384. package/core/dev/pipeline/backups/archive_2026-02-04T22-07-22/TASK_QUEUE_backup.json +0 -95
  385. package/core/dev/pipeline/docs/multi-agent-coordination.md +0 -446
  386. package/core/dev/pipeline/docs/overview.md +0 -406
  387. package/core/dev/pipeline/docs/task-management.md +0 -412
  388. package/core/dev/pipeline/docs/workflows.md +0 -32
  389. package/core/dev/pipeline/orchestrator/schemas/task_queue_schema.json +0 -58
  390. package/core/dev/pipeline/orchestrator/schemas/task_schema.json +0 -139
  391. package/core/dev/pipeline/plans/PLAN_task_cli_refactor.md +0 -281
  392. package/core/dev/pipeline/test_results/TASK_TEST_PARALLEL_002_result.txt +0 -27
  393. package/core/dev/plans/ANSUZ_SLIM_PLAN.md +0 -68
  394. package/core/dev/plans/CLI_FIRST_INSTALL_FLOW.md +0 -120
  395. package/core/dev/plans/FORMATION_RETIREMENT_PLAN.md +0 -313
  396. package/core/dev/plans/KUZU_REPLACEMENT_PLAN.md +0 -126
  397. package/core/dev/scripts/CRASH_DIAGNOSIS.md +0 -47
  398. package/core/dev/scripts/README.md +0 -142
  399. package/core/dev/scripts/RUN_ONCE.bat +0 -40
  400. package/core/dev/scripts/START_DEV_AGENT.bat +0 -63
  401. package/core/dev/scripts/START_MULTI_AGENT.bat +0 -80
  402. package/core/dev/scripts/dev_agent_scheduler.ps1 +0 -536
  403. package/core/dev/scripts/init_git.ps1 +0 -396
  404. package/core/dev/scripts/init_git.sh +0 -337
  405. package/core/dev/scripts/init_project.ps1 +0 -851
  406. package/core/dev/scripts/init_project.sh +0 -477
  407. package/core/dev/scripts/multi_agent_scheduler.ps1 +0 -2021
  408. package/core/dev/scripts/multi_agent_scheduler.sh +0 -1344
  409. package/core/dev/scripts/run_once.sh +0 -47
  410. package/core/dev/scripts/setup_rag.ps1 +0 -304
  411. package/core/dev/scripts/setup_rag.sh +0 -230
  412. package/core/dev/scripts/start_dev_agent.sh +0 -137
  413. package/core/dev/scripts/start_multi_agent.sh +0 -41
  414. package/core/dev/scripts/sync_task_queue.ps1 +0 -505
  415. package/core/dev/scripts/sync_task_queue.sh +0 -392
  416. package/core/dev/specs/agent-connect/PROTOCOL.md +0 -177
  417. package/core/dev/specs/agent-connect/SDK_GUIDE.md +0 -915
  418. package/core/dev/specs/agent-connect/examples/minimal-site/README.md +0 -137
  419. package/core/dev/specs/agent-connect/examples/minimal-site/package.json +0 -12
  420. package/core/dev/specs/agent-connect/examples/minimal-site/public/index.html +0 -116
  421. package/core/dev/specs/agent-connect/examples/minimal-site/public/install-redirect.js +0 -73
  422. package/core/dev/specs/agent-connect/examples/minimal-site/server.js +0 -516
  423. package/core/dev/specs/agent-connect/examples/minimal-site/test/smoke.test.mjs +0 -263
  424. package/core/dev/specs/agent-connect/history/DEFECT_REPORT_kenaz-agent-hub_2026-09-09_v0.4-empty-prompt-no-first-turn.md +0 -77
  425. package/core/dev/specs/agent-connect/history/DEFECT_REPORT_kenaz-agent-hub_2026-09-09_v0.4-prompt-mojibake.md +0 -90
  426. package/core/dev/specs/agent-connect/history/FEATURE_REQUEST_kenaz-agent-hub_2026-09-07.md +0 -61
  427. package/core/dev/specs/agent-connect/history/FEATURE_REQUEST_kenaz-agent-hub_2026-09-08_relay-v1-conformance.md +0 -76
  428. package/core/dev/specs/agent-connect/history/FEATURE_REQUEST_kenaz-agent-hub_2026-09-09_v0.4-session-channel.md +0 -87
  429. package/core/dev/specs/agent-connect/history/FLOWPIX_REPLY_agent-hub_2026-09-08_relay-v1-answers.md +0 -68
  430. package/core/dev/specs/agent-connect/history/FLOWPIX_bridge_CONTRACT.md +0 -642
  431. package/core/dev/specs/agent-connect/history/FLOWPIX_spikes_relay_spike_relay.mjs +0 -244
  432. package/core/dev/specs/agent-connect/history/KENAZ_RESPONSE_agent-hub_2026-09-07.md +0 -77
  433. package/core/dev/specs/agent-connect/history/KENAZ_RESPONSE_agent-hub_2026-09-08_direction-change-v0.3.md +0 -44
  434. package/core/dev/specs/agent-connect/history/KENAZ_RESPONSE_agent-hub_2026-09-08_relay-v1-answers-ack.md +0 -37
  435. package/core/dev/specs/agent-connect/history/KENAZ_RESPONSE_agent-hub_2026-09-08_relay-v1-conformance.md +0 -56
  436. package/core/dev/specs/agent-connect/history/KENAZ_RESPONSE_agent-hub_2026-09-09_annotations-install-coldstart.md +0 -44
  437. package/core/dev/specs/agent-connect/history/KENAZ_RESPONSE_agent-hub_2026-09-09_empty-prompt-first-turn.md +0 -56
  438. package/core/dev/specs/agent-connect/history/KENAZ_RESPONSE_agent-hub_2026-09-09_prompt-mojibake-fixed.md +0 -48
  439. package/core/dev/specs/agent-connect/history/KENAZ_RESPONSE_agent-hub_2026-09-09_session-channel.md +0 -57
  440. package/core/dev/specs/agent-connect/history/PROTOCOL_v0.3_snapshot.md +0 -379
  441. package/core/dev/specs/agent-connect/history/README.md +0 -47
  442. package/core/dev/specs/peer/CODEX_INTERACTIVE_PUSH.md +0 -65
  443. package/core/dev/specs/peer/CODEX_MANAGED_DAEMON.md +0 -54
  444. package/core/dev/specs/peer/CODEX_PEER_PULL_SPIKE.md +0 -54
  445. package/core/dev/specs/peer/MODS_SPIKE.md +0 -133
  446. package/core/dev/specs/peer/PER_PROJECT_ADDRESSING.md +0 -143
  447. package/core/dev/specs/peer/SWARM_PROTOCOLS.md +0 -256
  448. package/core/dev/specs/peer/codex-hook-shim-peer.test.js +0 -113
  449. package/core/dev/specs/peer/codex-push-launcher.test.js +0 -142
  450. package/core/dev/specs/peer/setup-codex-hooks.test.js +0 -60
  451. package/core/dev/specs/peer-ansuz/DELIVERY_SPIKE.md +0 -397
  452. package/core/dev/specs/peer-ansuz/DESIGN.md +0 -109
  453. package/core/dev/specs/peer-ansuz/spike/claude_poke.js +0 -129
  454. package/core/dev/specs/peer-ansuz/spike/claude_session_start_hook.js +0 -37
  455. package/core/dev/specs/peer-ansuz/spike/claude_settings_hook.json +0 -14
  456. package/core/dev/specs/peer-ansuz/spike/codex_appserver_client.js +0 -105
  457. package/core/dev/specs/peer-ansuz/spike/codex_appserver_query.js +0 -29
  458. package/core/dev/specs/peer-ansuz/spike/extract_timeline.js +0 -26
  459. package/core/dev/specs/synapse/SYMBOL_IDENTITY.md +0 -305
  460. package/core/dev/spikes/A4-cypher-varlen.md +0 -176
  461. package/core/dev/spikes/bloat-rounds.sh +0 -25
  462. package/core/dev/spikes/mods/clean-claude.js +0 -9
  463. package/core/dev/spikes/mods/drive-probe.js +0 -29
  464. package/core/dev/spikes/mods/e2e-peer.js +0 -71
  465. package/core/dev/spikes/mods/evidence/e2e-peer-control.json +0 -17
  466. package/core/dev/spikes/mods/evidence/e2e-peer-mod.json +0 -17
  467. package/core/dev/spikes/mods/evidence/probe-006a6e65-d807-4bc1-b648-fd7d1edfe0b4.jsonl +0 -4
  468. package/core/dev/spikes/mods/evidence/probe-cebdf1f7-f9c4-47a8-83cd-7c0786177404.jsonl +0 -12
  469. package/core/dev/spikes/mods/evidence/probe-eb21147d-10ce-4c32-93ed-37ca37d88d5a.jsonl +0 -11
  470. package/core/dev/spikes/mods/evidence/stream-cebdf1f7.jsonl +0 -18
  471. package/core/dev/spikes/mods/kenaz-mod-probe/.claude-plugin/plugin.json +0 -1
  472. package/core/dev/spikes/mods/kenaz-mod-probe/hooks/hooks.json +0 -1
  473. package/core/dev/spikes/mods/kenaz-mod-probe/hooks/register.ts +0 -65
  474. package/core/dev/spikes/mods/kenaz-mod-probe/tsconfig.json +0 -3
@@ -1,490 +0,0 @@
1
- # Refactor: `mcp_tools/synapse.rs` — Three-Stage Decomposition
2
-
3
- **Target file**: `dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/synapse.rs`
4
- **Current size**: 9 703 LOC / 370 KB
5
- **Method**: build-map → plan-split → minimal-patch, verify wire + `cargo check` between every step (see memory `feedback_large_file_three_stage_refactor.md`)
6
-
7
- ---
8
-
9
- ## Stage 1 — Map (this document)
10
-
11
- Produced 2026-04-21 via Explore subagent. Read-only analysis; no code changes.
12
-
13
- ### 1.1 Public API inventory (45 handlers + 3 utility fns)
14
-
15
- **Thought Stack (l.65-188, ~180 LOC):**
16
- - `tool_synapse_thought_push` (l.65) · `tool_synapse_thought_pop` (l.126) · `tool_synapse_thought_stack_list` (l.163)
17
-
18
- **Core Synapse query (l.701-4063):**
19
- - `tool_synapse_status` (l.701) · `tool_synapse_cypher` (l.794) · `tool_synapse_index` (l.899) · `tool_synapse_search` (l.959) · `tool_synapse_context` (l.1607) · `tool_synapse_impact` (l.2020) · `tool_synapse_detect_changes` (l.2223)
20
-
21
- **Cognitive layer (l.2401-4063):**
22
- - `tool_synapse_inscribe` (l.2401) · `tool_synapse_backfill_trigger_embeddings` (l.2714) · `tool_synapse_forge` (l.2742) · `tool_synapse_declare` (l.3055) · `tool_synapse_proposed_connections` (l.3324) · `tool_synapse_verify` (l.3406) · `tool_synapse_recall` (l.3571) · `tool_synapse_sigils` (l.3991) · `tool_synapse_trace_route` (l.4063)
23
-
24
- **Architectural analysis (l.4344-5069):**
25
- - `tool_synapse_map` (l.4344) · `tool_synapse_pulse` (l.4671) · `tool_synapse_imagine` (l.4933) · `tool_synapse_rune_conflicts` (l.4971) · `tool_synapse_pain_paths` (l.5069)
26
-
27
- **Code hygiene (l.5484-7575):**
28
- - `tool_synapse_orphans` (l.5484) · `tool_synapse_health` (l.5859) · `tool_synapse_debug_pool` (l.6322) · `tool_synapse_knowledge_gaps` (l.6345) · `tool_synapse_audit` (l.6402) · `tool_synapse_clustering_log` (l.6472) · `tool_synapse_scan_stale_runes` (l.7217) · `tool_synapse_maintain` (l.7249) · `tool_synapse_associate` (l.7285) · `tool_synapse_apply_usage_boosts` (l.7523) · `tool_synapse_preamble` (l.7575) · `tool_synapse_attention` (l.7629)
29
- - Helpers: `is_cli_entry_symbol` (l.5545) · `orphan_cypher_query` (l.5581)
30
-
31
- **Thalamus SNN (l.7874-8196):**
32
- - `tool_thalamus_status` (l.7874) · `tool_thalamus_history` (l.7953) · `tool_thalamus_stimulate` (l.8011) · `tool_spike_bus_send` (l.8100) · `tool_spike_bus_poll` (l.8142) · `tool_thalamus_context` (l.8196)
33
-
34
- **Advanced synthesis (l.8298-9357):**
35
- - `tool_muninn_sense` (l.8298) · `tool_synapse_efe` (l.8379) · `tool_synapse_efe_feedback` (l.8444) · `tool_synapse_think` (l.8787) · `tool_synapse_link_cognitive` (l.9173) · `tool_reflex_query` (l.9357)
36
-
37
- ### 1.2 First-class data structures
38
-
39
- | struct | line | field count | serde | purpose |
40
- |---|---|---|---|---|
41
- | `ThoughtStackThought` | 201 | 6 | ✓ | Ansuz tactical thought record |
42
- | `ThoughtStackFile` | 215 | 3 | ✓ | Thought stack container + versioning |
43
- | `PainPath` | 5129 | 5 | — | Cross-boundary call-chain representation |
44
- | `PainPathNode` | 5137 | 5 | — | Node within a chain |
45
- | `BoundaryJump` | 5145 | 5 | — | Community-boundary crossing |
46
- | `HealthDashboardSection` | 6744 | 8 | ✓ | Single health-metric section |
47
- | `HealthDashboard` | 6756 | 9 | ✓ | Unified 7-section health report |
48
- | `AttentionAccum` | 7862 | 3 | — | Heat / curiosity / risk accumulator |
49
- | `QueryIntent` (enum) | 8523 | 5 | — | Query-routing intent classification |
50
- | `SubsystemQuery` | 8545 | 3 | — | Planned subsystem query |
51
- | `RoutingMetrics` | 8780 | multi | — | MAGMA routing observability |
52
-
53
- ### 1.3 Logical sub-modules already present
54
-
55
- | tag | line range | responsibility | primary symbols |
56
- |---|---|---|---|
57
- | A. Thought Stack | 190-340 | JSON-backed tactical thought LIFO | `ThoughtStackFile`, `ThoughtStackThought`, 3 handlers, `load_thought_stack`, `persist_thought_stack`, `sweep_expired_thoughts` |
58
- | B. Response compression | 18-64 + 1341-1544 | Adaptive token-budget reduction | `estimate_tokens*`, `parse_detail_level`, `compress_search_response`, `strip_snippets_from_search`, `compress_context_response`, `strip_context_to_summary`, `build_*_overview` |
59
- | C. Rune + graph context | 359-677 + 1915-1990 | memory.db ↔ KuzuDB fusion | `query_runes_with_verified`, `query_sigil_memberships`, `log_symbol_access`, `rune_to_json`, `enrich_search_with_runes`, `query_cognitive_applies_to`, `query_1hop_neighbors` |
60
- | D. Cypher / graph traversal | 794-900 + 4099-4633 | Raw + derived graph queries | `tool_synapse_cypher`, `tool_synapse_impact`, `tool_synapse_context`, `tool_synapse_trace_route`, `tool_synapse_map`, `bfs_calls_chain`, `kuzu_value_to_json`, `query_communities`, `query_call_hotspots` |
61
- | E. Large analytics (Health / Pain) | 5069-6230 + 5855-6320 | Multi-metric synthesis reports | `tool_synapse_health`, `tool_synapse_pain_paths`, `tool_synapse_orphans`, `tool_synapse_knowledge_gaps`, `pain_paths_impl`, `orphans_impl`, `compute_gini`, `count_pain_paths` |
62
- | F. Cognitive integration | 2401-4344 + 7217-7575 | rune ↔ symbol bridges | `tool_synapse_inscribe`, `tool_synapse_recall`, `tool_synapse_forge`, `tool_synapse_declare`, `tool_synapse_verify`, `tool_synapse_scan_stale_runes`, `tool_synapse_maintain`, `tool_synapse_associate` |
63
- | G. Thalamus + Spike Bus | 7868-8290 + 8092-8190 | Real-time neuronal potential | 6 thalamus/spike-bus handlers |
64
- | H. Advanced routing / EFE | 8516-9360 | Unified cognitive router + EFE learning | `tool_synapse_think`, `tool_synapse_efe`, `tool_synapse_efe_feedback`, `tool_muninn_sense`, `classify_query_intent`, `build_query_plans` |
65
-
66
- ### 1.4 Top 3 low-risk split candidates (Stage 2 inputs)
67
-
68
- | # | proposed file | symbols | LOC | why low-risk |
69
- |---|---|---|---|---|
70
- | **1** | `handlers/thought_stack.rs` | `ThoughtStackThought`, `ThoughtStackFile`, 3 handlers (`push`/`pop`/`list`), `load_thought_stack`, `persist_thought_stack`, `sweep_expired_thoughts`, `thought_stack_path`, `generate_thought_id`, `infer_project_name` | ~180 | Fully independent JSON I/O subsystem. Deps: `chrono`, `serde`, `std::path` only. No Synapse graph / memory.db access. Zero cross-references from other handlers (grep-verified). |
71
- | **2** | `handlers/response_compression.rs` | `estimate_tokens`, `estimate_tokens_json`, `parse_detail_level`, `parse_token_threshold`, `compress_search_response`, `strip_snippets_from_search`, `build_search_overview`, `compress_context_response`, `strip_context_to_summary`, `build_context_overview` | ~220 | Pure `serde_json::Value` operations, no DB access. 4 call sites (l.973-974, 1350, 1472) — all re-wire by `use`. Single responsibility. |
72
- | **3** | `handlers/health_dashboard.rs` | `HealthDashboard`, `HealthDashboardSection`, `tool_synapse_maintain` + aggregation layer (`maintain_item_list`, `maintain_failure_section`, `maintain_guard`, `maintain_count_to_severity`, `build_orphans_section`, `build_stale_runes_section`, `build_conflicts_section`, `build_gaps_section`, `build_pain_paths_section`, `build_overdue_episodes_section`, `build_audit_summary_section`, `synapse_maintain`) | ~520 | Coordinator layer — `synapse_maintain` calls 7 existing public handlers (orphans / stale / conflicts / gaps / pain_paths / episodes / audit); those handlers themselves STAY in main file. Aggregation uses `maintain_guard` macro. High internal cohesion, low external coupling. |
73
-
74
- **Combined first-pass reduction**: ~920 LOC → 8 783 LOC after Stage 3 of all three candidates. ~10% trim with zero cross-cutting refactor.
75
-
76
- **Recommended Stage 2 target**: **Thought Stack** (candidate #1). Zero cross-dependencies is the textbook "好驗證" property — wire verification is: (a) `cargo check` passes, (b) `synapse_thought_push` + `pop` + `stack_list` still dispatch via MCP. Failure modes are few and visible.
77
-
78
- ---
79
-
80
- ## Stage 2 — Split plan (candidate #1: Thought Stack)
81
-
82
- Produced 2026-04-21. Stage 2 is still read-only. Target locked: **Thought Stack** only.
83
-
84
- ### 2.1 New file
85
-
86
- **Path**: `dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/thought_stack.rs`
87
- **Layout rationale**: sibling to `synapse.rs` (matches existing per-domain layout: `cortex.rs / hippocampus.rs / kenaz.rs / prefrontal.rs / synapse.rs`). `super::super::*` paths stay identical to synapse.rs — no path rewiring needed.
88
-
89
- ### 2.2 Symbols to move (in source order)
90
-
91
- | lines in synapse.rs | symbol | kind | visibility |
92
- |---|---|---|---|
93
- | 65-124 | `tool_synapse_thought_push` | async fn | `pub(crate)` (unchanged) |
94
- | 126-161 | `tool_synapse_thought_pop` | async fn | `pub(crate)` |
95
- | 163-188 | `tool_synapse_thought_stack_list` | async fn | `pub(crate)` |
96
- | 194-198 | `THOUGHT_STACK_SCHEMA_VERSION` / `MAX_DEPTH` / `TTL_DAYS` / `MAX_TEXT_CHARS` / `FILE` | const | private (module-local) |
97
- | 200-212 | `ThoughtStackThought` | struct | private |
98
- | 214-229 | `ThoughtStackFile` + `Default` impl | struct + impl | private |
99
- | 231-236 | `thought_stack_path` | fn | private |
100
- | 238-263 | `load_thought_stack` | fn | private |
101
- | 265-282 | `persist_thought_stack` | fn | private |
102
- | 284-303 | `sweep_expired_thoughts` | fn | private |
103
- | 305-314 | `infer_project_name` | fn | private |
104
- | 316-322 | `normalize_optional_text` | fn | private |
105
- | 324-336 | `generate_thought_id` | fn | private |
106
-
107
- Also move the `// ===== Thought Stack =====` section header at l.190-192.
108
-
109
- **Total move**: ~207 LOC (slightly larger than Stage 1 estimate of ~180).
110
-
111
- ### 2.3 Imports for the new file
112
-
113
- ```rust
114
- use serde::{Deserialize, Serialize};
115
- use serde_json::Value;
116
-
117
- use super::super::{resolve_project, McpToolResult, ProjectInfo};
118
- use super::get_str;
119
- ```
120
-
121
- No new dependencies. `chrono` and `std::path` are already used fully-qualified inline in the moved code.
122
-
123
- ### 2.4 Other-file touches
124
-
125
- | file | change | scope |
126
- |---|---|---|
127
- | `mcp_tools/mod.rs` | add `pub mod thought_stack;` after `pub mod synapse;` | 1 line |
128
- | `routes/mcp.rs` | rewrite l.377 / l.378 / l.380: `mcp_tools::synapse::tool_synapse_thought_*` → `mcp_tools::thought_stack::tool_synapse_thought_*` | 3 lines |
129
- | `mcp_tools/synapse.rs` | delete l.65-336 (all Thought Stack block) | -272 lines |
130
-
131
- After patch:
132
- - `synapse.rs` 9 703 → ~9 431 LOC
133
- - new `thought_stack.rs` ~207 LOC
134
- - Net: same total (−0 LOC) but scope-separated
135
-
136
- ### 2.5 Dependency risks
137
-
138
- | risk | severity | mitigation |
139
- |---|---|---|
140
- | `ProjectInfo` path (`super::super::`) in new file | LOW | Same super-path works because sibling placement. Verified by tracing. |
141
- | External symbol leak (some other module references moved fn) | LOW | Grep across `dashboard/src-tauri/src/` returned only synapse.rs + definitions.rs (strings) + mcp.rs (dispatch). No other callers. |
142
- | `definitions.rs` tool-name strings | NIL | `definitions.rs` references `"synapse_thought_push"` as a string literal (MCP tool advertisement) — no symbol-level dependency. |
143
- | `chrono::Duration` / `chrono::Utc` fully-qualified | NIL | Already fully-qualified at usage site; no import needed. |
144
- | `serde_json::json!` macro inside handlers | NIL | Macro resolves via `serde_json` crate import at file top. |
145
-
146
- ### 2.6 Move order (single atomic commit)
147
-
148
- Execute as ONE commit so either everything lands or nothing does:
149
-
150
- 1. Create `mcp_tools/thought_stack.rs` with moved symbols + new imports
151
- 2. Add `pub mod thought_stack;` in `mcp_tools/mod.rs`
152
- 3. Delete l.65-336 from `mcp_tools/synapse.rs`
153
- 4. Update 3 dispatch arms in `routes/mcp.rs` (l.377, 378, 380)
154
- 5. `cargo check -p kenaz-dashboard` — must pass with no new errors
155
- 6. Post-merge: restart Dashboard, call `synapse_thought_push` → `synapse_thought_stack_list` → `synapse_thought_pop` via MCP; each must return expected JSON structure
156
-
157
- ### 2.7 Section markers in synapse.rs (added 2026-04-21)
158
-
159
- Before Stage 3, the move region is explicitly fenced in `synapse.rs` with grep-anchorable markers:
160
-
161
- - `// BEGIN: Thought Stack — Ansuz tactical thought LIFO` (l.66, inside a 29-line marker block with full move inventory)
162
- - `// END: Thought Stack` (l.366, exact-match line)
163
-
164
- Stage 3 agent should move **everything between these two markers, inclusive of the markers themselves**, into `mcp_tools/thought_stack.rs`. The markers then become the file-header comment in the new file, preserving the inventory for future readers.
165
-
166
- ### 2.8 Acceptance criteria (for Stage 3 task spec)
167
-
168
- - `test -f dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/thought_stack.rs` returns present
169
- - `grep -Fxc "// END: Thought Stack" dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/synapse.rs` returns 0 (marker fully removed from old home — use `-Fx` for exact-line match to avoid false positives from marker-referencing body text)
170
- - `grep -Fxc "// END: Thought Stack" dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/thought_stack.rs` returns 1 (marker preserved in new home)
171
- - `grep -n "pub mod thought_stack" dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/mod.rs` returns non-empty
172
- - `grep -n "mcp_tools::thought_stack::tool_synapse_thought" dashboard/src-tauri/src/infrastructure/http_server/routes/mcp.rs` returns 3 lines
173
- - `grep -c "fn tool_synapse_thought" dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/synapse.rs` returns 0 (handlers fully removed)
174
- - `grep -c "fn tool_synapse_thought" dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/thought_stack.rs` returns 3
175
- - `cargo check -p kenaz-dashboard 2>&1 | grep -c "^error"` returns 0
176
- - `wc -l dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/synapse.rs` returns ≤ 9 500
177
-
178
- ### 2.8 Constraint clause (must appear in dispatch prompt)
179
-
180
- > 除非與本任務直接相關,否則不要修改其他函式、命名或檔案結構。不改 public API,不改 `pub(crate)` 可見性,不重命名任何符號,不 reformat 未移動的代碼。
181
-
182
- ---
183
-
184
- ## Stage 3 — Minimal patch (Thought Stack)
185
-
186
- Landed 2026-04-21 via TASK_1348. Thought Stack block (3 handlers + 2 structs + 6 helpers + 5 consts, 272 LOC) moved to `mcp_tools/thought_stack.rs` (309 LOC incl. marker header). `mcp.rs` dispatch rewired to `mcp_tools::thought_stack::tool_synapse_thought_*`. `cargo check -p kenaz-dashboard` passes 0 errors. Live MCP smoke test (push / pop / stack_list) deferred to next Dashboard restart — known caveat, not an AC blocker.
187
-
188
- Post-Stage-3 #1 file size: `synapse.rs` 9 703 → 9 431 LOC.
189
-
190
- ---
191
-
192
- ## Stage 2 — Split plan (candidate #2: Response Compression)
193
-
194
- Produced 2026-04-21. Stage 2 is still read-only. Target locked: **Response Compression**.
195
-
196
- ### 3.1 Why now
197
-
198
- Stage 1 map ranked #2 the second-lowest risk. Current file still 9 431 LOC. Extracting response compression:
199
-
200
- - Clean dependency inversion: `tool_synapse_search` / `tool_synapse_context` become consumers of a sibling utility module, mirroring the `thought_stack` pattern.
201
- - Pure `serde_json::Value` operations — no DB, no macro, no async, no lock.
202
- - Fan-in is narrow: 6 call sites, all inside 2 handlers (`tool_synapse_search` l.990, `tool_synapse_context` l.1335).
203
- - Re-proves the sibling-file pattern (`mcp_tools/<name>.rs`) on a pure-utility split before the coordinator-layer #3 move.
204
-
205
- ### 3.2 New file
206
-
207
- **Path**: `dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/response_compression.rs`
208
- **Layout rationale**: sibling to `synapse.rs` and `thought_stack.rs`. Same `super::super::*` import surface — zero path rewiring.
209
-
210
- ### 3.3 Symbols to move (source-order, current line numbers)
211
-
212
- The move is **4 non-contiguous regions** — Stage 3 agent must handle each separately.
213
-
214
- | region | lines in synapse.rs | symbol | kind | visibility after move |
215
- |---|---|---|---|---|
216
- | A | 18-20 | `// ==== Detail Level Compression ====` header | comment | moves |
217
- | A | 22-25 | `estimate_tokens` | fn | private |
218
- | A | 27-33 | `estimate_tokens_json` | fn | private |
219
- | A | 35-41 | `parse_detail_level` | fn | `pub(super)` (needed by synapse.rs) |
220
- | A | 43-48 | `parse_token_threshold` | fn | `pub(super)` |
221
- | B | 66-85 | `build_overview_file_groups` | fn | private |
222
- | C | 1069-1071 | `// ==== Search Response Compression ====` header | comment | moves |
223
- | C | 1073-1127 | `compress_search_response` | fn | `pub(super)` |
224
- | C | 1129-1170 | `strip_snippets_from_search` | fn | private |
225
- | C | 1172-1193 | `build_search_overview` | fn | private |
226
- | D | 1195-1197 | `// ==== Context Response Compression ====` header | comment | moves |
227
- | D | 1199-1244 | `compress_context_response` | fn | `pub(super)` |
228
- | D | 1246-1269 | `strip_context_to_summary` | fn | private |
229
- | D | 1271-1333 | `build_context_overview` | fn | private |
230
-
231
- **Stays in synapse.rs (between regions A and B)**: `has_canonical_symbol_id_prefix` (l.50), `called_by_format_warning` (l.54). Unrelated edge-validation helpers — do NOT touch.
232
-
233
- **Total move**: ~285 LOC (design doc Stage 1 estimated 220; delta = 65 LOC, primarily `build_overview_file_groups` (20 LOC) missed in map + Region A/C/D blank lines + doc-comments).
234
-
235
- ### 3.4 Imports for the new file
236
-
237
- ```rust
238
- use serde_json::Value;
239
-
240
- use crate::features::synapse::search::HybridSearchResult;
241
- ```
242
-
243
- No `serde::{Deserialize, Serialize}` (no structs moved). No `super::super::` imports (none needed — move scope is self-contained utility logic).
244
-
245
- ### 3.5 Other-file touches
246
-
247
- | file | change | scope |
248
- |---|---|---|
249
- | `mcp_tools/mod.rs` | add `pub(crate) mod response_compression;` after `pub mod thought_stack;` | 1 line |
250
- | `mcp_tools/synapse.rs` | add near top: `use super::response_compression::{compress_context_response, compress_search_response, parse_detail_level, parse_token_threshold};` | 1 line (import) |
251
- | `mcp_tools/synapse.rs` | delete l.18-48 (region A), l.66-85 (region B), l.1069-1193 (region C), l.1195-1333 (region D) | ≈ -285 lines |
252
-
253
- No changes to `routes/mcp.rs` — none of the moved fns are dispatch targets (all are internal helpers).
254
-
255
- After patch:
256
- - `synapse.rs` 9 431 → ~9 150 LOC
257
- - new `response_compression.rs` ~290 LOC
258
- - Net: same total (−0 LOC) but scope-separated
259
-
260
- ### 3.6 Call-site re-wire inventory
261
-
262
- Only the 6 call sites need to resolve through the new `use` import. All are inside 2 handlers:
263
-
264
- | call site | handler | symbol |
265
- |---|---|---|
266
- | l.701 | `tool_synapse_search` | `parse_detail_level` |
267
- | l.702 | `tool_synapse_search` | `parse_token_threshold` |
268
- | l.1057 | `tool_synapse_search` | `compress_search_response` |
269
- | l.1346 | `tool_synapse_context` | `parse_detail_level` |
270
- | l.1347 | `tool_synapse_context` | `parse_token_threshold` |
271
- | l.1629 | `tool_synapse_context` | `compress_context_response` |
272
-
273
- After the top-of-file `use` import lands, none of the call-site expressions need to change (bare names still resolve).
274
-
275
- ### 3.7 Dependency risks
276
-
277
- | risk | severity | mitigation |
278
- |---|---|---|
279
- | `HybridSearchResult` path from new file | LOW | Fully-qualified path already used in original (`crate::features::synapse::search::HybridSearchResult`). Can collapse to `use` in new file. |
280
- | Visibility elevation of 4 fns to `pub(super)` | NIL | `pub(super)` grants visibility only within the `mcp_tools` module — still private to the crate. No external API change. |
281
- | `serde_json::json!` macro inside compress/build fns | NIL | `serde_json` is already a direct dep; macro resolves via crate import. |
282
- | Preamble has its own private `estimate_tokens` (`preamble.rs:1454`) | NIL | Different module (`crate::features::synapse::preamble`). No name collision at visibility boundary. |
283
- | Non-contiguous move (4 regions, not 1 block) | LOW-MEDIUM | Stage 3 agent must delete from **bottom up** (region D → C → B → A) to preserve line numbers in earlier deletions. Explicit order in move-order section below. |
284
-
285
- ### 3.8 Move order (single atomic commit)
286
-
287
- Execute as ONE commit so either everything lands or nothing does:
288
-
289
- 1. Create `mcp_tools/response_compression.rs` with all 10 moved fns (regions A+B+C+D concatenated, A→B→C→D order for readability) + imports.
290
- 2. Add `pub(crate) mod response_compression;` in `mcp_tools/mod.rs`.
291
- 3. Add `use super::response_compression::{...};` near top of `mcp_tools/synapse.rs` (after existing `use super::get_str;` line).
292
- 4. Delete region D (l.1195-1333) from `mcp_tools/synapse.rs`.
293
- 5. Delete region C (l.1069-1193) from `mcp_tools/synapse.rs`.
294
- 6. Delete region B (l.66-85) from `mcp_tools/synapse.rs`.
295
- 7. Delete region A (l.18-48) from `mcp_tools/synapse.rs`.
296
- 8. `cargo check -p kenaz-dashboard` — must pass with 0 new errors.
297
- 9. Post-merge: smoke test via MCP is optional — restart Dashboard and call `synapse_search` with `detail_level=summary` then `detail_level=overview`; call `synapse_context` with same. Expect identical JSON structure to pre-refactor. **Deferred — Dashboard restart caveat.**
298
-
299
- ### 3.9 Acceptance criteria (grep-verifiable)
300
-
301
- - `test -f dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/response_compression.rs` returns present
302
- - `grep -cE "^fn (compress_search_response|compress_context_response|parse_detail_level|parse_token_threshold|estimate_tokens|estimate_tokens_json|strip_snippets_from_search|strip_context_to_summary|build_search_overview|build_context_overview|build_overview_file_groups)" dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/synapse.rs` returns 0 (all 10 handlers fully removed — note `pub(super)` fns in new file will have different prefix)
303
- - `grep -cE "fn (compress_search_response|compress_context_response|parse_detail_level|parse_token_threshold|estimate_tokens|estimate_tokens_json|strip_snippets_from_search|strip_context_to_summary|build_search_overview|build_context_overview|build_overview_file_groups)" dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/response_compression.rs` returns 10
304
- - `grep -n "pub(crate) mod response_compression" dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/mod.rs` returns non-empty
305
- - `grep -n "use super::response_compression::" dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/synapse.rs` returns non-empty
306
- - `cargo check -p kenaz-dashboard 2>&1 | grep -c "^error"` returns 0
307
- - `wc -l dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/synapse.rs` returns ≤ 9 200
308
-
309
- ### 3.10 Constraint clause (must appear in dispatch prompt)
310
-
311
- > 除非與本任務直接相關,否則不要修改其他函式、命名或檔案結構。不改 public API。四個呼叫站點(`parse_detail_level`、`parse_token_threshold`、`compress_search_response`、`compress_context_response`)可見性提升到 `pub(super)` 即可;其餘 6 個(`estimate_tokens`、`estimate_tokens_json`、`strip_snippets_from_search`、`build_search_overview`、`strip_context_to_summary`、`build_context_overview`、`build_overview_file_groups`)保持 private。不重命名任何符號,不 reformat 未移動的代碼。不修改 `has_canonical_symbol_id_prefix` / `called_by_format_warning`(位於移除區間 A 與 B 之間,屬於 unrelated edge-validation helpers,必須原地保留)。
312
-
313
- ---
314
-
315
- ## Stage 3 — Minimal patch (Response Compression)
316
-
317
- _TBD — after Stage 2 §3 approval. Will become a task card (TASK_1350) with the acceptance criteria above + constraint clause, dispatched via Formation unit._
318
-
319
- <!-- TASK_1359 pre-flight guard: ran `grep -cE "^## (Stage|Stage 1)" .specialist/Ansuz/designs/refactor_mcp_tools_synapse.md` before editing; result = 5, so this append is based on the expected post-TASK_1350 document shape. -->
320
-
321
- ## Stage 2 — Split plan (candidate #3: Health Dashboard)
322
-
323
- Produced 2026-04-22 via TASK_1359. Stage 2 is still read-only. Target locked: **Health Dashboard** only.
324
-
325
- This section intentionally starts at 4.x so it cannot collide with the earlier candidate #1 2.x plan or candidate #2 3.x plan. The existing sections above are source material and must remain untouched.
326
-
327
- ### 4.1 New file
328
-
329
- **Path**: `dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/health_dashboard.rs`
330
-
331
- **Layout rationale**: sibling to `synapse.rs`, `thought_stack.rs`, and planned `response_compression.rs`. The Health Dashboard is a coordinator layer, not a primitive analytics engine:
332
-
333
- - It owns `HealthDashboard` / `HealthDashboardSection` response composition.
334
- - It calls existing health-related MCP handlers and normalizes their responses into a single report.
335
- - It should not absorb the implementation of orphan detection, stale-rune scanning, rune conflicts, knowledge gaps, pain paths, overdue episodes, or audit rules.
336
- - It should keep the same MCP tool name, `synapse_maintain`, with the dispatcher rewired to `mcp_tools::health_dashboard::tool_synapse_maintain`.
337
-
338
- The new file should expose only the handler needed by dispatch plus any minimal test-visible function if the existing tests require it. Private helper visibility should stay private unless compiler errors prove otherwise.
339
-
340
- ### 4.2 Symbols to move (source-order, current line numbers)
341
-
342
- Current grep verification in this worktree places the block at `synapse.rs` l.6155-l.6677, with tests referencing `synapse_maintain` at l.8837 and l.8958. Stage 1's map came from an older line map, so the l.6744 / l.6756 references below are the original Stage 1 anchors, while the current execution agent must trust grep over stale line numbers.
343
-
344
- | Stage 1 anchor | current grep line | symbol | kind | visibility after move |
345
- |---|---:|---|---|---|
346
- | l.6744 | l.6155 | `HealthDashboardSection` | struct | private unless tests require `pub(super)` |
347
- | l.6756 | l.6167 | `HealthDashboard` | struct | private unless tests require `pub(super)` |
348
- | n/a | l.6179 | `maintain_item_list` | fn | private |
349
- | n/a | l.6187 | `maintain_failure_section` | fn | private |
350
- | n/a | l.6206 | `maintain_guard` | fn | private |
351
- | n/a | l.6229 | `maintain_count_to_severity` | fn | private |
352
- | n/a | l.6239 | `build_orphans_section` | fn | private |
353
- | n/a | l.6277 | `build_stale_runes_section` | fn | private |
354
- | n/a | l.6346 | `build_conflicts_section` | fn | private |
355
- | n/a | l.6394 | `build_gaps_section` | fn | private |
356
- | n/a | l.6440 | `build_pain_paths_section` | fn | private |
357
- | n/a | l.6488 | `build_overdue_episodes_section` | fn | private |
358
- | n/a | l.6540 | `build_audit_summary_section` | fn | private |
359
- | n/a | l.6594 | `synapse_maintain` | fn | private or `pub(super)` only if tests remain outside module |
360
- | n/a | l.6659 | `tool_synapse_maintain` | async fn | `pub(crate)` unchanged |
361
-
362
- **Expected move size**: ~740 LOC, not the Stage 1 estimate of ~520 LOC.
363
-
364
- Delta reconciliation:
365
-
366
- - `maintain_guard` is not just a trivial wrapper; it carries async/blocking failure normalization and repeated fallback-section shaping.
367
- - Stage 1 under-enumerated the seven `build_*_section` functions and their local JSON-shaping logic.
368
- - The move also includes inter-section whitespace, section comments, doc comments, and response-field normalization that were not counted in the initial rough map.
369
- - The current file has tests later in `synapse.rs` that reference `synapse_maintain`; Stage 3 must either move the relevant tests with the module or keep a narrow `pub(super)` seam so tests compile.
370
- - If the actual extracted region exceeds 900 LOC after including tests, Stage 3 should split execution into two atomic commits: first move production code and dispatch wiring, then move or rewire tests. If it remains under 900 LOC, one atomic commit is acceptable.
371
-
372
- ### 4.3 Imports for the new file
373
-
374
- Start with the smallest import surface and let `cargo check` identify any missing items:
375
-
376
- ```rust
377
- use serde::{Deserialize, Serialize};
378
- use serde_json::{json, Value};
379
-
380
- use super::super::{resolve_project, McpToolResult};
381
- use super::get_usize;
382
- ```
383
-
384
- Expected cross-module handler imports:
385
-
386
- ```rust
387
- use super::hippocampus::tool_hippocampus_due_episodes;
388
- use super::synapse::{
389
- tool_synapse_audit,
390
- tool_synapse_knowledge_gaps,
391
- tool_synapse_orphans,
392
- tool_synapse_pain_paths,
393
- tool_synapse_rune_conflicts,
394
- tool_synapse_scan_stale_runes,
395
- };
396
- ```
397
-
398
- Do **not** move the callee implementations listed above into `health_dashboard.rs`. They are existing public handlers with independent callers and dispatcher entries.
399
-
400
- If the extracted code currently relies on fully-qualified `tokio::task::spawn_blocking`, keep that style rather than adding an import. If it uses `chrono::Utc` fully qualified, keep it fully qualified.
401
-
402
- ### 4.4 Other-file touches
403
-
404
- | file | change | scope |
405
- |---|---|---|
406
- | `mcp_tools/mod.rs` | add `pub mod health_dashboard;` near the other `mcp_tools` modules | 1 line |
407
- | `routes/mcp.rs` | rewrite the `synapse_maintain` arm from `mcp_tools::synapse::tool_synapse_maintain(args).await` to `mcp_tools::health_dashboard::tool_synapse_maintain(args).await` | 1 dispatch arm |
408
- | `mcp_tools/synapse.rs` | delete only the Health Dashboard coordinator block after it is copied into the new file | ~740 LOC |
409
- | `mcp_tools/synapse.rs` tests | either move `synapse_maintain` tests into `health_dashboard.rs` or update the test path narrowly | test-only touch, if compiler requires |
410
-
411
- No changes to the seven callee handler bodies. No changes to tool definitions or public MCP names.
412
-
413
- After patch, expected shape:
414
-
415
- - `synapse.rs` shrinks by roughly 700-800 LOC.
416
- - `health_dashboard.rs` contains the dashboard structs, helper functions, coordinator, handler, and any moved tests.
417
- - Net repository LOC should stay roughly neutral; this is a file-boundary refactor, not a behavior change.
418
-
419
- ### 4.5 Dependency risks
420
-
421
- The coordinator calls seven existing public handlers. Verification in this worktree used exact grep fallback because Synapse indexing was empty. The callee functions are plain `pub(crate) async fn` handlers and must stay in their current modules.
422
-
423
- | callee / tool | grep result | current home | move? | risk | mitigation |
424
- |---|---|---|---|---|---|
425
- | `tool_synapse_orphans` | `pub(crate) async fn`, `synapse.rs:4895` | `mcp_tools/synapse.rs` | no | LOW | Import and call it from `health_dashboard.rs`; leave dispatcher entry unchanged. |
426
- | `tool_synapse_scan_stale_runes` | `pub(crate) async fn`, `synapse.rs:6628` | `mcp_tools/synapse.rs` | no | MEDIUM | It sits adjacent to the Health Dashboard block. Stage 3 must avoid over-deleting into this handler. |
427
- | `tool_synapse_rune_conflicts` | `pub(crate) async fn`, `synapse.rs:4382` | `mcp_tools/synapse.rs` | no | LOW | Import only; no helper inlining. |
428
- | `tool_synapse_knowledge_gaps` | `pub(crate) async fn`, `synapse.rs:5756` | `mcp_tools/synapse.rs` | no | LOW | Import only; existing dispatcher remains in `synapse`. |
429
- | `tool_synapse_pain_paths` | `pub(crate) async fn`, `synapse.rs:4480` | `mcp_tools/synapse.rs` | no | LOW | Import only; no call-site behavior change. |
430
- | `tool_hippocampus_due_episodes` (`hippocampus_due_episodes` MCP tool) | `pub(crate) async fn`, `hippocampus.rs:758` | `mcp_tools/hippocampus.rs` | no | LOW-MEDIUM | The Rust symbol includes the `tool_` prefix; import `super::hippocampus::tool_hippocampus_due_episodes`. |
431
- | `tool_synapse_audit` | `pub(crate) async fn`, `synapse.rs:5813` | `mcp_tools/synapse.rs` | no | LOW | Import only; audit implementation stays with Synapse hygiene. |
432
-
433
- Additional risks:
434
-
435
- | risk | severity | mitigation |
436
- |---|---|---|
437
- | Accidental inlining of callees into the new module | HIGH | Forbidden. `health_dashboard.rs` is the aggregation layer only. |
438
- | Deleting `tool_synapse_scan_stale_runes` while removing the adjacent coordinator block | MEDIUM | Fence the exact block before deleting. Start at `struct HealthDashboardSection`; end after `tool_synapse_maintain`. |
439
- | Tests reference private `synapse_maintain` from the old module | MEDIUM | Prefer moving the tests with the implementation. If not practical, use the narrowest visibility needed. |
440
- | Circular module dependency from `health_dashboard` importing `synapse` handlers | LOW | Rust sibling modules can import each other through `super::synapse`; the existing handlers are `pub(crate)`. |
441
- | Handler result shape drift | MEDIUM | Preserve all JSON field names and generated section names exactly. This is a move-only refactor. |
442
-
443
- ### 4.6 Move order (single atomic commit, cargo-check gated)
444
-
445
- Execute as one atomic commit when the extracted production block is under 900 LOC. If tests push the move over 900 LOC, use the two-commit split described in 4.2.
446
-
447
- 1. Pre-flight: confirm the design doc already contains the five prior stage headers with `grep -cE "^## (Stage|Stage 1)" .specialist/Ansuz/designs/refactor_mcp_tools_synapse.md`; expected result is `5`.
448
- 2. In `synapse.rs`, locate the exact current Health Dashboard region with `rg -n "HealthDashboardSection|tool_synapse_maintain|synapse_maintain"`.
449
- 3. Create `mcp_tools/health_dashboard.rs` with the moved structs, helper functions, `synapse_maintain`, and `tool_synapse_maintain`.
450
- 4. Add `pub mod health_dashboard;` in `mcp_tools/mod.rs`.
451
- 5. Rewire only the `synapse_maintain` dispatch arm in `routes/mcp.rs`.
452
- 6. Delete the old Health Dashboard coordinator block from `mcp_tools/synapse.rs`.
453
- 7. Move or narrowly rewire the `synapse_maintain` tests if `cargo check` or test compilation requires it.
454
- 8. Run `cargo check -p kenaz-dashboard`; result must have 0 new errors.
455
- 9. If available after Dashboard restart, smoke test `synapse_maintain` through MCP with a small `top_n` and confirm all seven sections are present.
456
-
457
- Deletion order in Stage 3 should be conservative:
458
-
459
- - Copy first.
460
- - Compile to expose missing imports while both copies still exist only if symbol duplication is avoided by temporary names or a staged patch; otherwise skip this compile.
461
- - Delete old block in one bounded hunk.
462
- - Compile immediately.
463
-
464
- ### 4.7 Acceptance criteria (grep-verifiable)
465
-
466
- Stage 3 task spec should include these checks:
467
-
468
- - `test -f dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/health_dashboard.rs` returns present.
469
- - `grep -n "pub mod health_dashboard" dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/mod.rs` returns non-empty.
470
- - `grep -n "mcp_tools::health_dashboard::tool_synapse_maintain" dashboard/src-tauri/src/infrastructure/http_server/routes/mcp.rs` returns 1 line.
471
- - `grep -cE "struct HealthDashboard|fn maintain_item_list|fn maintain_failure_section|fn maintain_guard|fn maintain_count_to_severity|fn build_orphans_section|fn build_stale_runes_section|fn build_conflicts_section|fn build_gaps_section|fn build_pain_paths_section|fn build_overdue_episodes_section|fn build_audit_summary_section|fn synapse_maintain|fn tool_synapse_maintain" dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/synapse.rs` returns 0.
472
- - `grep -cE "struct HealthDashboard|fn maintain_item_list|fn maintain_failure_section|fn maintain_guard|fn maintain_count_to_severity|fn build_orphans_section|fn build_stale_runes_section|fn build_conflicts_section|fn build_gaps_section|fn build_pain_paths_section|fn build_overdue_episodes_section|fn build_audit_summary_section|fn synapse_maintain|fn tool_synapse_maintain" dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/health_dashboard.rs` returns at least 14.
473
- - `grep -cE "pub\\(crate\\) async fn (tool_synapse_orphans|tool_synapse_scan_stale_runes|tool_synapse_rune_conflicts|tool_synapse_knowledge_gaps|tool_synapse_pain_paths|tool_synapse_audit)" dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/synapse.rs` returns 6.
474
- - `grep -c "pub(crate) async fn tool_hippocampus_due_episodes" dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/hippocampus.rs` returns 1.
475
- - `grep -c "tool_synapse_maintain" dashboard/src-tauri/src/infrastructure/http_server/routes/mcp_tools/synapse.rs` returns 0, except test-module references if tests intentionally remain behind a `super::health_dashboard` path.
476
- - `cargo check -p kenaz-dashboard 2>&1 | grep -c "^error"` returns 0.
477
- - Optional smoke: `synapse_maintain` returns top-level keys `overall_score`, `generated_at`, `orphans`, `stale_runes`, `conflicts`, `gaps`, `pain_paths`, `overdue_episodes`, and `audit_summary`.
478
-
479
- ### 4.8 Constraint clause (must appear in dispatch prompt)
480
-
481
- > 除非與本任務直接相關,否則不要修改其他函式、命名或檔案結構
482
-
483
- Stage 3 prompt must also preserve these operational constraints:
484
-
485
- - This is a move-only refactor. Do not rename `HealthDashboard`, `HealthDashboardSection`, `tool_synapse_maintain`, `maintain_item_list`, `maintain_failure_section`, `maintain_guard`, `maintain_count_to_severity`, any `build_*_section` function, or `synapse_maintain`.
486
- - Do not modify the seven callee handlers. They are verified existing `pub(crate) async fn` handlers and must stay in `synapse.rs` / `hippocampus.rs`.
487
- - Do not rewrite response schema field names or section names.
488
- - Do not expand the task into Health score internals, orphan detection internals, audit rule internals, or Hippocampus overdue episode logic.
489
- - Do not reformat unrelated regions in `synapse.rs`.
490
- - Keep public MCP tool names unchanged.