kenaz 0.3.18 → 0.3.20

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 (329) hide show
  1. package/core/.claude/commands/agent-worker.md +1 -1
  2. package/core/.claude/commands/architect.md +1 -2
  3. package/core/.claude/commands/spec.md +1 -1
  4. package/core/.claude/commands//347/224/242/345/223/201.md +1 -1
  5. package/core/.claude/hooks/__tests__/task-1977-dedupe-guard.test.js +8 -8
  6. package/core/.claude/skills/architect_agent/SKILL.md +11 -92
  7. package/core/.claude/skills/assessment_agent/SKILL.md +0 -1
  8. package/core/.claude/skills/backend_engineer/SKILL.md +3 -6
  9. package/core/.claude/skills/code_reviewer/SKILL.md +1 -1
  10. package/core/.claude/skills/code_reviewer/patterns.yaml +1 -1
  11. package/core/.claude/skills/designer/SKILL.md +3 -6
  12. package/core/.claude/skills/dev_agent/SKILL.md +30 -491
  13. package/core/.claude/skills/developer/SKILL.md +3 -6
  14. package/core/.claude/skills/feature_agent/SKILL.md +3 -17
  15. package/core/.claude/skills/product_manager/SKILL.md +29 -1064
  16. package/core/.claude/skills/qa_engineer/SKILL.md +12 -17
  17. package/core/.claude/skills/spec_optimizer/SKILL.md +25 -275
  18. package/core/.claude/skills/sre_agent/SKILL.md +3 -6
  19. package/core/.collaboration/README.md +2 -3
  20. package/core/.collaboration/core/task-api.js +5 -138
  21. package/core/.collaboration/docs/CLI.md +0 -2
  22. package/core/.failure/INDEX.yaml +6 -40
  23. package/core/.failure/agent-execution/FAIL-013-search-cwd-drift-and-case-mismatch.yaml +1 -1
  24. package/core/.failure/tools/README.md +9 -227
  25. package/core/.formation/bifrost/launch.js +1 -6
  26. package/core/.formation/bifrost/launch.test.js +1 -1
  27. package/core/.formation/bifrost/shared/ansuz-boot-policy.js +3 -3
  28. package/core/.formation/bifrost/shared/ansuz-boot-policy.test.js +1 -2
  29. package/core/.formation/tools/__tests__/arms.test.js +41 -0
  30. package/core/.formation/tools/__tests__/diagnose-bug.test.js +10 -0
  31. package/core/.formation/tools/__tests__/m1-hmap-convid.test.js +1 -124
  32. package/core/.formation/tools/arms.js +48 -0
  33. package/core/.formation/tools/dispatch.js +24 -15
  34. package/core/.formation/tools/kenaz-stats.js +32 -8
  35. package/core/.formation/tools/kenaz-stats.test.js +15 -2
  36. package/core/.formation/tools/loader.js +17 -140
  37. package/core/.formation/tools/post-complete.js +0 -31
  38. package/core/.formation/tools/prompt.js +16 -1
  39. package/core/.formation/tools/prompt.test.js +20 -0
  40. package/core/.rule/INDEX.yaml +0 -18
  41. package/core/.rule/general/agent-workflow.yaml +14 -164
  42. package/core/.rule/general/project-self-containment.yaml +8 -19
  43. package/core/.rule/general/rust-verify-target.yaml +6 -5
  44. package/core/.rule/general/synapse-code-intelligence.yaml +3 -3
  45. package/core/.specialist/Amelia/capability.yaml +12 -12
  46. package/core/.specialist/Amelia/workflow.yaml +2 -2
  47. package/core/.specialist/Ansuz/SYSTEM_DOC.md +20 -578
  48. package/core/.specialist/Ansuz/cognitive_principles.yaml +2 -3
  49. package/core/.specialist/Ansuz/concepts/boot_rules_summary.yaml +0 -1
  50. package/core/.specialist/Ansuz/concepts/deep_knowledge_pointers.yaml +1 -2
  51. package/core/.specialist/Ansuz/core.yaml +6 -108
  52. package/core/.specialist/Ansuz/guards/lesson_guards.yaml +0 -3
  53. package/core/.specialist/Ansuz/identity_contract.yaml +0 -1
  54. package/core/.specialist/Ansuz/knowledge.yaml +0 -4
  55. package/core/.specialist/Ansuz/rule.yaml +0 -1
  56. package/core/.specialist/Ansuz/tools/handoff-session-identity.test.js +6 -150
  57. package/core/.specialist/tests/runtime-discovery/README.md +1 -1
  58. package/core/.specialist/tools/__tests__/task-2374-usage-counter.test.js +1 -12
  59. package/core/.specialist/tools/ansuz-boot-fast.js +7 -4
  60. package/core/.specialist/tools/ansuz-boot-fast.test.js +10 -3
  61. package/core/.specialist/tools/prompt-files.test.js +1 -0
  62. package/core/.specialist/tools/task-bridge.js +1 -66
  63. package/core/.system/README.md +11 -552
  64. package/core/.system/collaboration/README.md +10 -174
  65. package/core/CLAUDE.md +1 -6
  66. package/core/KENAZ_CORE_VERSION +1 -1
  67. package/core/dev/scripts/js-yaml-resolution.test.js +1 -1
  68. package/core/dev/scripts/peer-identity-e2e.js +402 -0
  69. package/core/dev/scripts/peer-identity-e2e.md +47 -0
  70. package/core/dev/scripts/relay-admin.js +94 -0
  71. package/core/dev/scripts/relay-admin.test.js +131 -0
  72. package/core/dev/scripts/run-rust-tests.js +9 -45
  73. package/core/dev/scripts/rust-verify-worktree.js +4 -4
  74. package/core/dev/scripts/verify-target-dir.js +6 -6
  75. package/core/plugins/kenaz/INVENTORY.md +8 -8
  76. package/core/plugins/kenaz/README.md +10 -0
  77. package/core/plugins/kenaz/commands/architect.md +1 -2
  78. package/core/plugins/kenaz/commands/spec.md +1 -1
  79. package/core/plugins/kenaz/commands//347/224/242/345/223/201.md +1 -1
  80. package/core/plugins/kenaz/guidance.md +1 -1
  81. package/core/plugins/kenaz/hooks/kenaz-hook.js +2 -1
  82. package/core/plugins/kenaz/hooks/sdk-gate.js +9 -0
  83. package/core/plugins/kenaz/scripts/kenaz.test.js +15 -3
  84. package/core/plugins/kenaz/scripts/sync.js +1 -1
  85. package/core/plugins/kenaz/scripts/ygg.js +8 -0
  86. package/core/plugins/kenaz/scripts/ygg.test.js +72 -0
  87. package/core/plugins/kenaz/skills/architect_agent/SKILL.md +11 -92
  88. package/core/plugins/kenaz/skills/assessment_agent/SKILL.md +0 -1
  89. package/core/plugins/kenaz/skills/backend_engineer/SKILL.md +3 -6
  90. package/core/plugins/kenaz/skills/code_reviewer/SKILL.md +1 -1
  91. package/core/plugins/kenaz/skills/code_reviewer/patterns.yaml +1 -1
  92. package/core/plugins/kenaz/skills/designer/SKILL.md +3 -6
  93. package/core/plugins/kenaz/skills/dev_agent/SKILL.md +30 -491
  94. package/core/plugins/kenaz/skills/developer/SKILL.md +3 -6
  95. package/core/plugins/kenaz/skills/feature_agent/SKILL.md +3 -17
  96. package/core/plugins/kenaz/skills/product_manager/SKILL.md +29 -1064
  97. package/core/plugins/kenaz/skills/qa_engineer/SKILL.md +12 -17
  98. package/core/plugins/kenaz/skills/spec_optimizer/SKILL.md +25 -275
  99. package/core/plugins/kenaz/skills/sre_agent/SKILL.md +3 -6
  100. package/core/plugins/kenaz-peer/hooks/register.test.ts +32 -0
  101. package/core/plugins/kenaz-peer/hooks/register.ts +9 -0
  102. package/package.json +6 -6
  103. package/core/.claude/commands/archive.md +0 -24
  104. package/core/.claude/commands/init.md +0 -112
  105. package/core/.claude/commands/legacy_dev.md +0 -18
  106. package/core/.claude/commands/product-review.md +0 -131
  107. package/core/.claude/commands/strategy.md +0 -141
  108. package/core/.claude/commands/sunny.md +0 -1
  109. package/core/.claude/commands//347/224/242/345/223/201/346/252/242/350/246/226.md +0 -129
  110. package/core/.claude/commands//351/200/262/345/272/246.md +0 -15
  111. package/core/.claude/hooks/__tests__/substrate.test.js +0 -122
  112. package/core/.claude/hooks/_substrate-paths.js +0 -95
  113. package/core/.claude/hooks/context-check.js +0 -51
  114. package/core/.claude/hooks/fatigue-check.js +0 -52
  115. package/core/.claude/hooks/handoff-snapshot-on-commit.js +0 -154
  116. package/core/.claude/hooks/handoff-snapshot-on-question.js +0 -158
  117. package/core/.claude/hooks/handoff-staleness.js +0 -197
  118. package/core/.claude/hooks/jev-thalamus-context.js +0 -17
  119. package/core/.claude/hooks/jev-thalamus-context.test.js +0 -41
  120. package/core/.claude/hooks/lease-release.js +0 -119
  121. package/core/.claude/hooks/lease-touch.js +0 -96
  122. package/core/.claude/hooks/reflex-feedback.js +0 -5
  123. package/core/.claude/hooks/session-init.ps1 +0 -49
  124. package/core/.claude/hooks/sound-event.js +0 -70
  125. package/core/.claude/hooks/sound-event.sh +0 -37
  126. package/core/.claude/hooks/stream-delta.js +0 -169
  127. package/core/.claude/no-hooks.settings.json +0 -3
  128. package/core/.claude/skills/legacy_dev/SKILL.md +0 -202
  129. package/core/.claude/skills/sunny/SKILL.md +0 -74
  130. package/core/.collaboration/cli/commands/assign.js +0 -39
  131. package/core/.collaboration/cli/commands/claim.js +0 -33
  132. package/core/.collaboration/cli/commands/complete.js +0 -44
  133. package/core/.collaboration/cli/commands/create.js +0 -110
  134. package/core/.collaboration/cli/commands/get.js +0 -83
  135. package/core/.collaboration/cli/commands/index.js +0 -52
  136. package/core/.collaboration/cli/commands/list.js +0 -51
  137. package/core/.collaboration/cli/commands/lock.js +0 -45
  138. package/core/.collaboration/cli/commands/rebuild.js +0 -39
  139. package/core/.collaboration/cli/commands/search.js +0 -61
  140. package/core/.collaboration/cli/commands/stats.js +0 -61
  141. package/core/.collaboration/cli/commands/transfer.js +0 -41
  142. package/core/.collaboration/cli/commands/unlock.js +0 -48
  143. package/core/.collaboration/cli/formatters/help-formatter.js +0 -70
  144. package/core/.collaboration/cli/formatters/index.js +0 -7
  145. package/core/.collaboration/cli/task-cli.js +0 -46
  146. package/core/.collaboration/cli/utils/arg-parser.js +0 -74
  147. package/core/.collaboration/cli/utils/git-user.js +0 -25
  148. package/core/.collaboration/cli/utils/index.js +0 -9
  149. package/core/.collaboration/cli/utils/output.js +0 -10
  150. package/core/.collaboration/config/default.yaml +0 -189
  151. package/core/.collaboration/core/conflict-resolver.js +0 -461
  152. package/core/.collaboration/core/conflict-resolver.test.js +0 -389
  153. package/core/.collaboration/core/migrate-legacy.js +0 -260
  154. package/core/.collaboration/docs/API.md +0 -787
  155. package/core/.collaboration/docs/ARCHITECTURE.md +0 -596
  156. package/core/.collaboration/docs/FAQ.md +0 -695
  157. package/core/.collaboration/docs/MIGRATION.md +0 -804
  158. package/core/.collaboration/docs/examples/README.md +0 -320
  159. package/core/.collaboration/docs/examples/advanced-queries.js +0 -261
  160. package/core/.collaboration/docs/examples/basic-usage.js +0 -184
  161. package/core/.collaboration/docs/examples/team-workflow.js +0 -352
  162. package/core/.failure/agent-execution/FAIL-001-agent-no-output.yaml +0 -391
  163. package/core/.failure/agent-execution/FAIL-007-pm-lead-wrong-team-invocation.yaml +0 -0
  164. package/core/.failure/agent-execution/FAIL-010-phase0-poem-format-skipped.yaml +0 -28
  165. package/core/.failure/agent-execution/FAIL-010-skipping-cognitive-checkpoint-after-verification.yaml +0 -59
  166. package/core/.failure/agent-execution/FAIL-012-grep-shortcut-during-investigation.yaml +0 -85
  167. package/core/.failure/architecture/FAIL-006-python-version-compatibility.yaml +0 -445
  168. package/core/.failure/pipeline/FAIL-003-queue-pollution.yaml +0 -335
  169. package/core/.failure/pipeline/README.md +0 -95
  170. package/core/.failure/retired/FAIL-009-skipping-synapse-pulse-before-code-change.yaml +0 -49
  171. package/core/.failure/tools/USAGE_GUIDE.md +0 -323
  172. package/core/.failure/tools/check_failures.ps1 +0 -387
  173. package/core/.failure/tools/log_failure.ps1 +0 -474
  174. package/core/.formation/.episode-input.json +0 -10
  175. package/core/.formation/.merge-lock +0 -1
  176. package/core/.formation/lead.yaml +0 -118
  177. package/core/.formation/legacy.bak/designer.yaml +0 -57
  178. package/core/.formation/legacy.bak/pm.yaml +0 -57
  179. package/core/.formation/legacy.bak/qa.yaml +0 -57
  180. package/core/.formation/legacy.bak/review.yaml +0 -62
  181. package/core/.formation/legacy.bak/scheduler.yaml +0 -129
  182. package/core/.formation/legacy.bak/sre.yaml +0 -57
  183. package/core/.formation/role-map.yaml +0 -274
  184. package/core/.formation/roles/_shared/modules/code_review.yaml +0 -98
  185. package/core/.formation/roles/_shared/modules/security.yaml +0 -103
  186. package/core/.formation/roles/_shared/modules/testing.yaml +0 -14
  187. package/core/.formation/roles/backend/role.yaml +0 -93
  188. package/core/.formation/roles/code_reviewer/role.yaml +0 -102
  189. package/core/.formation/roles/database_optimizer/role.yaml +0 -107
  190. package/core/.formation/roles/designer/role.yaml +0 -66
  191. package/core/.formation/roles/developer/role.yaml +0 -75
  192. package/core/.formation/roles/frontend/role.yaml +0 -134
  193. package/core/.formation/roles/incident_response/role.yaml +0 -89
  194. package/core/.formation/roles/qa/role.yaml +0 -89
  195. package/core/.formation/roles/security/role.yaml +0 -87
  196. package/core/.formation/roles/sre/role.yaml +0 -66
  197. package/core/.formation/skills/coordinator.yaml +0 -52
  198. package/core/.formation/solo/diagnosis.yaml +0 -78
  199. package/core/.formation/solo/strategy.yaml +0 -121
  200. package/core/.formation/tests/hello.txt +0 -2
  201. package/core/.formation/tools/coordinator.js +0 -350
  202. package/core/.formation/tools/jev-correction.js +0 -214
  203. package/core/.formation/tools/jev-correction.test.js +0 -178
  204. package/core/.formation/tools/log-reader.js +0 -232
  205. package/core/.formation/tools/revert-daemon-state.js +0 -162
  206. package/core/.formation/tools/test-drift.js +0 -148
  207. package/core/.formation/unit/heimdall.yaml +0 -96
  208. package/core/.formation/unit/plan.yaml +0 -67
  209. package/core/.formation/unit/think.yaml +0 -58
  210. package/core/.kenaz/MUNINN_SNAPSHOT9_EPISODE.json +0 -32
  211. package/core/.kenaz/MUNINN_SNAPSHOT9_RUNE.json +0 -23
  212. package/core/.kenaz/MUNINN_SNAPSHOT9_SUMMARY.md +0 -89
  213. package/core/.kenaz/ash_TASK_1428-20260507.json +0 -14
  214. package/core/.kenaz/muninn_episode_write.ps1 +0 -17
  215. package/core/.kenaz/muninn_snapshot11_rune_candidates.md +0 -63
  216. package/core/.kenaz/muninn_snapshot1_rune_candidates.md +0 -49
  217. package/core/.kenaz/runes_TASK_1428.json +0 -57
  218. package/core/.kenaz/tmp_heimdall_proposal_8d3e392.json +0 -13
  219. package/core/.kenaz/tmp_props.json +0 -1
  220. package/core/.kenaz/tmp_sounddrop_t1_prompt.txt +0 -371
  221. package/core/.rule/MECHANIZED.md +0 -61
  222. package/core/.rule/general/cortex-memory-recall.yaml +0 -446
  223. package/core/.rule/general/pipeline.yaml +0 -246
  224. package/core/.rule/general/sunny-access-control.yaml +0 -60
  225. package/core/.rule/general/system-invariants.yaml +0 -231
  226. package/core/.rule/pipeline/PPL-002-completed-task-archival.yaml +0 -528
  227. package/core/.rule/pipeline/auto-update.yaml +0 -282
  228. package/core/.rule/pipeline/task-execution.yaml +0 -365
  229. package/core/.specialist/Ansuz/concepts/phase_protocol.yaml +0 -65
  230. package/core/.specialist/Ansuz/experiments/boot_ablation_replay.js +0 -197
  231. package/core/.specialist/Ansuz/tools/bootstrap-anchors.js +0 -289
  232. package/core/.specialist/Ansuz/workflow.yaml +0 -1225
  233. package/core/.specialist/experiments/rg_benchmark.js +0 -523
  234. package/core/.specialist/experiments/rg_benchmark_results.json +0 -27
  235. package/core/.specialist/tools/jev-optional-context.js +0 -107
  236. package/core/.specialist/tools/jev-optional-context.test.js +0 -152
  237. package/core/.specialist/tools/memory-action-log.js +0 -839
  238. package/core/.specialist/tools/phase-gate.js +0 -3534
  239. package/core/.specialist/tools/phase-gate.test.js +0 -85
  240. package/core/.specialist/tools/precompute-runner.js +0 -444
  241. package/core/.specialist/tools/rule-engine.js +0 -621
  242. package/core/.specialist/tools/task-bridge-jev.test.js +0 -170
  243. package/core/.synapse/memory-shared.json.sync +0 -1
  244. package/core/.system/agent-skills/README.md +0 -724
  245. package/core/.system/cli-tools/README.md +0 -724
  246. package/core/.system/cortex/MODULES.md +0 -1046
  247. package/core/.system/dashboard/FRONTEND.md +0 -812
  248. package/core/.system/dashboard/README.md +0 -737
  249. package/core/.system/failure/README.md +0 -723
  250. package/core/.system/formation/LEGACY_SKILLS.md +0 -974
  251. package/core/.system/formation/POST_COMPLETE.md +0 -602
  252. package/core/.system/formation/README.md +0 -1094
  253. package/core/.system/formation/TOOLS_REFERENCE.md +0 -1145
  254. package/core/.system/kenaz/README.md +0 -787
  255. package/core/.system/memory/README.md +0 -719
  256. package/core/.system/pipeline/README.md +0 -712
  257. package/core/.system/rule/README.md +0 -794
  258. package/core/.system/sunny/README.md +0 -476
  259. package/core/.system/sunny/RULES.json +0 -89
  260. package/core/.system/sunny/knowledge/INDEX.md +0 -37
  261. package/core/.system/sunny/knowledge/agent-teams-api.md +0 -0
  262. package/core/.system/sunny/knowledge/ansuz-specialist.md +0 -500
  263. package/core/.system/sunny/knowledge/claude-cli-spawn.md +0 -177
  264. package/core/.system/sunny/knowledge/collaboration-api.md +0 -925
  265. package/core/.system/sunny/teammates/README.md +0 -107
  266. package/core/.system/sunny/teammates/how_to_use.yaml +0 -101
  267. package/core/.system/sunny/teammates/tools/headless/launcher.js +0 -318
  268. package/core/.system/sunny/teammates/tools/powershell/launcher.js +0 -241
  269. package/core/.system/sunny/teammates/tools/powershell/start.bat +0 -50
  270. package/core/.system/sunny/teammates/tools/utils/env.js +0 -96
  271. package/core/.system/sunny/teammates/tools/utils/format-output.js +0 -329
  272. package/core/.system/sunny/tools.json +0 -101
  273. package/core/dev/scripts/cleanup-queue.js +0 -184
  274. package/core/dev/scripts/cleanup_queue.js +0 -86
  275. package/core/dev/scripts/legacy/README.md +0 -39
  276. package/core/dev/scripts/legacy/dev_agent_scheduler.ps1.bak +0 -536
  277. package/core/dev/scripts/legacy/multi_agent_scheduler.ps1.bak +0 -1978
  278. package/core/dev/scripts/matrix/CLI_README.md +0 -214
  279. package/core/dev/scripts/matrix/README.md +0 -310
  280. package/core/dev/scripts/matrix/package-lock.json +0 -4266
  281. package/core/dev/scripts/matrix/package.json +0 -55
  282. package/core/dev/scripts/matrix/src/abbreviations.ts +0 -295
  283. package/core/dev/scripts/matrix/src/cli/commands/convert.ts +0 -211
  284. package/core/dev/scripts/matrix/src/cli/commands/create.ts +0 -95
  285. package/core/dev/scripts/matrix/src/cli/commands/delete.ts +0 -102
  286. package/core/dev/scripts/matrix/src/cli/commands/list-tags.ts.wip +0 -140
  287. package/core/dev/scripts/matrix/src/cli/commands/manage-tags.ts.wip +0 -173
  288. package/core/dev/scripts/matrix/src/cli/commands/query.ts +0 -261
  289. package/core/dev/scripts/matrix/src/cli/commands/read.ts +0 -77
  290. package/core/dev/scripts/matrix/src/cli/commands/stats.ts.wip +0 -168
  291. package/core/dev/scripts/matrix/src/cli/commands/tokens.ts.wip +0 -126
  292. package/core/dev/scripts/matrix/src/cli/commands/update.ts +0 -147
  293. package/core/dev/scripts/matrix/src/cli/commands/validate.ts +0 -275
  294. package/core/dev/scripts/matrix/src/cli/index.ts +0 -350
  295. package/core/dev/scripts/matrix/src/cli/utils/file-handler.ts +0 -72
  296. package/core/dev/scripts/matrix/src/cli/utils/logger.ts +0 -65
  297. package/core/dev/scripts/matrix/src/index.ts +0 -62
  298. package/core/dev/scripts/matrix/src/indexer/tag-indexer.ts +0 -165
  299. package/core/dev/scripts/matrix/src/parser.ts +0 -281
  300. package/core/dev/scripts/matrix/src/serializer.ts +0 -151
  301. package/core/dev/scripts/matrix/src/validator.ts +0 -301
  302. package/core/dev/scripts/matrix/tests/abbreviations.test.ts +0 -122
  303. package/core/dev/scripts/matrix/tests/cli.test.ts +0 -177
  304. package/core/dev/scripts/matrix/tests/convert.test.ts +0 -143
  305. package/core/dev/scripts/matrix/tests/parser.test.ts +0 -203
  306. package/core/dev/scripts/matrix/tests/query.test.ts +0 -85
  307. package/core/dev/scripts/matrix/tests/serializer.test.ts +0 -197
  308. package/core/dev/scripts/matrix/tests/validate.test.ts +0 -141
  309. package/core/dev/scripts/matrix/tests/validator.test.ts +0 -167
  310. package/core/dev/scripts/matrix/tsconfig.json +0 -20
  311. package/core/dev/scripts/matrix/types/index.d.ts +0 -111
  312. package/core/dev/scripts/matrix/types/index.d.ts.map +0 -1
  313. package/core/dev/scripts/matrix/types/index.js +0 -8
  314. package/core/dev/scripts/matrix/types/index.js.map +0 -1
  315. package/core/dev/scripts/matrix/types/index.ts +0 -124
  316. package/core/dev/scripts/memory-usage-report.js +0 -152
  317. package/core/dev/scripts/probe/ansuz-scaffold-ablation.js +0 -579
  318. package/core/dev/scripts/probe/ansuz-scaffold-ablation.test.js +0 -244
  319. package/core/dev/scripts/probe/hook-latency-probe.js +0 -315
  320. package/core/dev/scripts/probe/hook-latency-probe.test.js +0 -105
  321. package/core/dev/scripts/probe/prediction-signal-auc.js +0 -483
  322. package/core/dev/scripts/probe/prediction-signal-auc.test.js +0 -200
  323. package/core/dev/scripts/test-pty-ws-tunnel.js +0 -229
  324. package/core/dev/scripts/validate_pipeline.js +0 -197
  325. package/core/dev/spikes/task2145-evidence-20261004/backend-log-excerpt.txt +0 -56
  326. package/core/dev/spikes/task2145-evidence-20261004/graph.shadow +0 -0
  327. package/core/dev/spikes/task2145-evidence-20261004/graph.wal +0 -0
  328. package/core/dev/spikes/task2145-evidence-20261004/graph_corrupt_suspect.marker +0 -1
  329. package/core/plugins/kenaz/commands/strategy.md +0 -141
@@ -1,528 +0,0 @@
1
- # PPL-002: 已完成任務必須封存到 .memory/
2
- # 嚴重程度: high
3
- # 來源: FAIL-003 (TASK_QUEUE 污染問題)
4
-
5
- _meta:
6
- id: "PPL-002"
7
- category: "pipeline"
8
- severity: "high"
9
- version: "1.0.0"
10
- created_at: "2026-02-05"
11
- last_updated: "2026-02-05"
12
- applies_to:
13
- - "ai_agent"
14
- - "human_developer"
15
- - "ci_cd"
16
- related_failures:
17
- - "FAIL-003" # TASK_QUEUE 污染問題
18
- priority: 1 # 高優先級,影響系統穩定性
19
-
20
- # ============================================================
21
- # 規則定義
22
- # ============================================================
23
-
24
- title: "已完成任務必須立即封存到 .memory/"
25
-
26
- description: |
27
- 當任務狀態變為 completed 時,必須在同一操作中將任務從 TASK_QUEUE.json
28
- 移除並封存到 .memory/COMPLETED_TASKS.json,確保佇列只包含活躍任務
29
- (pending/in_progress/blocked)。
30
-
31
- rationale: |
32
- **為什麼需要此規則**:
33
- - 保持 TASK_QUEUE.json 精簡,提升載入和解析效率
34
- - 防止 Multi-Agent Scheduler 重複載入已完成任務
35
- - 避免佇列污染(completed 任務混入 active 佇列)
36
- - 確保統計數據準確反映專案進度
37
- - 減少 token 消耗(Agent 不需要過濾大量歷史任務)
38
-
39
- background: |
40
- **失敗歷史**:
41
- 此規則源於 FAIL-003(TASK_QUEUE 污染問題),該問題已重複發生 2 次:
42
-
43
- **問題現象**:
44
- 已完成任務被移到 .memory/ 後,Multi-Agent Scheduler 又把它們加回
45
- TASK_QUEUE.json 並標記為 completed,導致:
46
- - 佇列文件體積持續增長
47
- - 統計數據混亂(total 包含大量歷史任務)
48
- - Agent 任務選取效率降低(需過濾大量已完成任務)
49
- - 潛在的任務重複執行風險
50
-
51
- **根本原因**:
52
- Scheduler 同步邏輯從 dev/pipeline/completed/ 目錄讀取任務,將歷史任務
53
- 重新加入佇列,且沒有過濾 completed 狀態。
54
-
55
- # ============================================================
56
- # 強制執行規則
57
- # ============================================================
58
-
59
- rules:
60
- # ----------------------------------------------------------
61
- # PPL-002.1: 佇列只包含活躍任務
62
- # ----------------------------------------------------------
63
- - id: "PPL-002.1"
64
- name: "佇列只包含活躍任務"
65
- severity: "must"
66
- description: |
67
- TASK_QUEUE.json 的 tasks 陣列只能包含狀態為 pending, in_progress,
68
- 或 blocked 的任務。不允許 completed 或 cancelled 任務存在。
69
-
70
- definition:
71
- active_states: ["pending", "in_progress", "blocked"]
72
- forbidden_states: ["completed", "cancelled"]
73
-
74
- validation:
75
- - type: "json_schema"
76
- rule: "tasks[*].status MUST BE IN ['pending', 'in_progress', 'blocked']"
77
- - type: "count"
78
- rule: "tasks.filter(t => t.status == 'completed').length MUST BE 0"
79
-
80
- violation_detection: |
81
- # 檢測佇列污染
82
- const queue = JSON.parse(fs.readFileSync('dev/pipeline/TASK_QUEUE.json', 'utf8'));
83
- const polluted = queue.tasks.filter(t =>
84
- ['completed', 'cancelled'].includes(t.status)
85
- );
86
-
87
- if (polluted.length > 0) {
88
- console.error(`❌ 違反 PPL-002.1: 發現 ${polluted.length} 個已完成任務污染佇列`);
89
- console.error('任務 ID:', polluted.map(t => t.id).join(', '));
90
- process.exit(1);
91
- }
92
-
93
- # ----------------------------------------------------------
94
- # PPL-002.2: 任務完成後立即封存
95
- # ----------------------------------------------------------
96
- - id: "PPL-002.2"
97
- name: "任務完成後立即封存"
98
- severity: "must"
99
- description: |
100
- 當任務狀態變為 completed 時,必須在同一個操作流程中執行以下步驟,
101
- 不可跳過或延遲任何步驟。
102
-
103
- workflow:
104
- - step: 1
105
- action: "移動任務 YAML 文件"
106
- source: "dev/pipeline/tasks/TASK_XXX.yaml"
107
- destination: "dev/pipeline/completed/TASK_XXX.yaml"
108
- command: "mv dev/pipeline/tasks/TASK_XXX.yaml dev/pipeline/completed/"
109
-
110
- - step: 2
111
- action: "從 TASK_QUEUE.json 移除該任務"
112
- implementation: |
113
- const queue = JSON.parse(fs.readFileSync('dev/pipeline/TASK_QUEUE.json', 'utf8'));
114
- queue.tasks = queue.tasks.filter(t => t.id !== 'TASK_XXX');
115
- fs.writeFileSync('dev/pipeline/TASK_QUEUE.json', JSON.stringify(queue, null, 2));
116
-
117
- - step: 3
118
- action: "封存到 .memory/COMPLETED_TASKS.json"
119
- implementation: |
120
- const completed = JSON.parse(fs.readFileSync('.memory/COMPLETED_TASKS.json', 'utf8'));
121
- completed.push({
122
- id: task.id,
123
- title: task.title,
124
- priority: task.priority,
125
- agent_type: task.agent_type,
126
- source: task.source,
127
- estimated_hours: task.estimated_hours,
128
- complexity: task.complexity,
129
- source_file: task.source_file,
130
- completed_at: new Date().toISOString()
131
- });
132
- fs.writeFileSync('.memory/COMPLETED_TASKS.json', JSON.stringify(completed, null, 2));
133
-
134
- - step: 4
135
- action: "更新統計數據"
136
- implementation: |
137
- queue.statistics = {
138
- total: queue.tasks.length + completed.length,
139
- pending: queue.tasks.filter(t => t.status === 'pending').length,
140
- in_progress: queue.tasks.filter(t => t.status === 'in_progress').length,
141
- blocked: queue.tasks.filter(t => t.status === 'blocked').length,
142
- completed: completed.length,
143
- cancelled: 0
144
- };
145
- queue.last_updated = new Date().toISOString();
146
-
147
- atomic_requirement: |
148
- 所有四個步驟必須作為一個原子操作執行。如果任何步驟失敗,
149
- 必須回滾所有變更,避免數據不一致。
150
-
151
- # ----------------------------------------------------------
152
- # PPL-002.3: Scheduler 禁止從 completed/ 同步
153
- # ----------------------------------------------------------
154
- - id: "PPL-002.3"
155
- name: "Scheduler 禁止從 completed/ 同步"
156
- severity: "must"
157
- description: |
158
- Multi-Agent Scheduler 的任務同步邏輯必須只從 dev/pipeline/tasks/
159
- 目錄讀取,completed/ 目錄僅供歷史記錄和審計使用。
160
-
161
- allowed_source: "dev/pipeline/tasks/"
162
- forbidden_sources:
163
- - "dev/pipeline/completed/"
164
- - ".memory/COMPLETED_TASKS.json"
165
-
166
- implementation_guide: |
167
- // ✅ 正確:只從 tasks/ 讀取
168
- pub fn sync_tasks_from_filesystem(&mut self, project_path: &Path) -> Result<()> {
169
- let tasks_dir = project_path.join("dev/pipeline/tasks");
170
- self.load_tasks_from_directory(&tasks_dir)?;
171
- Ok(())
172
- }
173
-
174
- // ❌ 錯誤:從 completed/ 讀取
175
- pub fn sync_tasks_from_filesystem(&mut self, project_path: &Path) -> Result<()> {
176
- let tasks_dir = project_path.join("dev/pipeline/tasks");
177
- let completed_dir = project_path.join("dev/pipeline/completed"); // ❌ 禁止
178
- self.load_tasks_from_directory(&tasks_dir)?;
179
- self.load_tasks_from_directory(&completed_dir)?; // ❌ 污染源頭
180
- Ok(())
181
- }
182
-
183
- code_review_checklist:
184
- - "Scheduler 代碼不包含 'completed/' 路徑引用"
185
- - "沒有從 .memory/ 讀取任務並加入佇列"
186
- - "同步邏輯只掃描 tasks/ 目錄"
187
-
188
- # ----------------------------------------------------------
189
- # PPL-002.4: 啟動時驗證佇列完整性
190
- # ----------------------------------------------------------
191
- - id: "PPL-002.4"
192
- name: "啟動時驗證佇列完整性"
193
- severity: "must"
194
- description: |
195
- Multi-Agent Scheduler 啟動時必須驗證 TASK_QUEUE.json 中無 completed
196
- 狀態任務。如果發現污染,拒絕啟動並提示執行清理腳本。
197
-
198
- validation_logic: |
199
- pub fn validate_queue_integrity(&self) -> Result<()> {
200
- let completed_count = self.tasks.iter()
201
- .filter(|t| t.status == TaskStatus::Completed)
202
- .count();
203
-
204
- if completed_count > 0 {
205
- return Err(SchedulerError::QueuePollution(
206
- format!(
207
- "❌ 發現 {} 個已完成任務污染佇列!\n\
208
- 請執行清理腳本:node dev/scripts/cleanup-queue.js",
209
- completed_count
210
- )
211
- ));
212
- }
213
-
214
- Ok(())
215
- }
216
-
217
- startup_sequence:
218
- - step: 1
219
- action: "載入 TASK_QUEUE.json"
220
- - step: 2
221
- action: "執行完整性驗證 (validate_queue_integrity)"
222
- - step: 3
223
- action: "如果驗證失敗,拒絕啟動並輸出錯誤訊息"
224
- - step: 4
225
- action: "如果驗證通過,繼續正常啟動流程"
226
-
227
- # ----------------------------------------------------------
228
- # PPL-002.5: 定期清理機制
229
- # ----------------------------------------------------------
230
- - id: "PPL-002.5"
231
- name: "定期清理機制"
232
- severity: "should"
233
- description: |
234
- 建立自動化清理腳本,定期清除 TASK_QUEUE.json 中的 completed 任務。
235
- 雖然正常流程不應產生污染,但作為安全網機制。
236
-
237
- frequency: "每週一次,或當檢測到污染時手動執行"
238
-
239
- cleanup_script_path: "dev/scripts/cleanup-queue.js"
240
-
241
- cleanup_script: |
242
- // dev/scripts/cleanup-queue.js
243
- const fs = require('fs');
244
- const path = require('path');
245
-
246
- const queuePath = 'dev/pipeline/TASK_QUEUE.json';
247
- const memoryPath = '.memory/COMPLETED_TASKS.json';
248
- const backupDir = 'dev/pipeline/backups';
249
-
250
- // 備份
251
- const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
252
- const backupPath = path.join(backupDir, `queue_backup_${timestamp}.json`);
253
- fs.mkdirSync(backupDir, { recursive: true });
254
- fs.copyFileSync(queuePath, backupPath);
255
- console.log(`✅ 已備份到 ${backupPath}`);
256
-
257
- // 讀取並移除 BOM
258
- let content = fs.readFileSync(queuePath, 'utf8');
259
- if (content.charCodeAt(0) === 0xFEFF) {
260
- content = content.slice(1);
261
- }
262
-
263
- const queue = JSON.parse(content);
264
- const completed = JSON.parse(fs.readFileSync(memoryPath, 'utf8'));
265
-
266
- // 過濾已完成任務
267
- const beforeCount = queue.tasks.length;
268
- queue.tasks = queue.tasks.filter(t =>
269
- ['pending', 'in_progress', 'blocked'].includes(t.status)
270
- );
271
- const afterCount = queue.tasks.length;
272
- const removedCount = beforeCount - afterCount;
273
-
274
- // 重新計算統計
275
- queue.statistics = {
276
- total: queue.tasks.length + completed.length,
277
- pending: queue.tasks.filter(t => t.status === 'pending').length,
278
- in_progress: queue.tasks.filter(t => t.status === 'in_progress').length,
279
- blocked: queue.tasks.filter(t => t.status === 'blocked').length,
280
- completed: completed.length,
281
- cancelled: 0
282
- };
283
-
284
- queue.last_updated = new Date().toISOString();
285
-
286
- // 寫回文件
287
- fs.writeFileSync(queuePath, JSON.stringify(queue, null, 2));
288
-
289
- console.log(`✅ 清理完成!移除 ${removedCount} 個已完成任務`);
290
- console.log(` - 當前佇列: ${queue.tasks.length} 個任務`);
291
- console.log(` - pending: ${queue.statistics.pending}`);
292
- console.log(` - in_progress: ${queue.statistics.in_progress}`);
293
- console.log(` - blocked: ${queue.statistics.blocked}`);
294
- console.log(` - 累積完成: ${queue.statistics.completed}`);
295
-
296
- powershell_wrapper: |
297
- # dev/scripts/cleanup-completed-tasks.ps1
298
- param(
299
- [switch]$DryRun,
300
- [switch]$Verbose
301
- )
302
-
303
- $QueuePath = "dev/pipeline/TASK_QUEUE.json"
304
-
305
- # 執行清理腳本
306
- node dev/scripts/cleanup-queue.js
307
-
308
- # 驗證結果
309
- $data = Get-Content $QueuePath | ConvertFrom-Json
310
- $completedCount = ($data.tasks | Where-Object { $_.status -eq 'completed' }).Count
311
-
312
- if ($completedCount -gt 0) {
313
- Write-Warning "⚠️ 仍有 $completedCount 個已完成任務!"
314
- exit 1
315
- } else {
316
- Write-Host "✅ 佇列已清理,無已完成任務" -ForegroundColor Green
317
- }
318
-
319
- # ============================================================
320
- # 預防措施
321
- # ============================================================
322
-
323
- prevention:
324
- checklist:
325
- - item: "任務完成後立即封存"
326
- description: "完成任務後,立即將 YAML 移到 completed/ 並更新 Queue"
327
- responsibility: "Dev Agent, Human Developer"
328
-
329
- - item: "Scheduler 啟動前驗證"
330
- description: "Scheduler 啟動前,驗證 Queue 中無 completed 任務"
331
- responsibility: "Multi-Agent Scheduler"
332
-
333
- - item: "定期執行清理腳本"
334
- description: "每週執行一次 cleanup-queue.js 確保佇列乾淨"
335
- responsibility: "CI/CD Pipeline, Human Developer"
336
-
337
- - item: "監控統計數據異常"
338
- description: "當 total > 100 或 completed > 0 in queue 時觸發警報"
339
- responsibility: "Monitoring System"
340
-
341
- - item: "禁止從 completed/ 同步"
342
- description: "Scheduler 代碼禁止從 completed/ 目錄讀取任務"
343
- responsibility: "Code Review"
344
-
345
- - item: "統一狀態更新邏輯"
346
- description: "所有狀態更新必須通過 task_queue.rs 的 API"
347
- responsibility: "All Developers"
348
-
349
- automated_checks:
350
- - type: "pre_commit_hook"
351
- name: "validate-queue-integrity.sh"
352
- description: "提交前驗證 TASK_QUEUE.json 完整性"
353
- implementation: |
354
- #!/bin/bash
355
- # .git/hooks/pre-commit
356
- queue_file="dev/pipeline/TASK_QUEUE.json"
357
-
358
- if [ -f "$queue_file" ]; then
359
- completed_count=$(jq '[.tasks[] | select(.status == "completed")] | length' "$queue_file")
360
-
361
- if [ "$completed_count" -gt 0 ]; then
362
- echo "❌ 錯誤:TASK_QUEUE.json 包含 $completed_count 個已完成任務"
363
- echo "請執行:node dev/scripts/cleanup-queue.js"
364
- exit 1
365
- fi
366
- fi
367
-
368
- - type: "ci_cd_check"
369
- name: "Queue Integrity Check"
370
- description: "CI/CD Pipeline 驗證佇列完整性"
371
- implementation: |
372
- # .github/workflows/validate-queue.yml
373
- name: Validate Queue Integrity
374
- on: [push, pull_request]
375
- jobs:
376
- validate:
377
- runs-on: ubuntu-latest
378
- steps:
379
- - uses: actions/checkout@v3
380
- - name: Check Queue
381
- run: |
382
- completed=$(jq '[.tasks[] | select(.status == "completed")] | length' dev/pipeline/TASK_QUEUE.json)
383
- if [ "$completed" -gt 0 ]; then
384
- echo "❌ Queue污染: $completed 個已完成任務"
385
- exit 1
386
- fi
387
-
388
- - type: "monitoring"
389
- name: "Queue Health Monitor"
390
- description: "監控 TASK_QUEUE.json 健康狀態"
391
- metrics:
392
- - metric: "queue_size"
393
- threshold: 100
394
- alert: "佇列任務數超過 100,可能有污染"
395
- - metric: "completed_in_queue"
396
- threshold: 0
397
- alert: "發現已完成任務在佇列中"
398
-
399
- # ============================================================
400
- # 違規處理
401
- # ============================================================
402
-
403
- enforcement:
404
- - type: "blocking"
405
- severity: "critical"
406
- action: "拒絕 Scheduler 啟動"
407
- condition: "TASK_QUEUE.json 包含 completed 任務"
408
- message: |
409
- ❌ 無法啟動 Multi-Agent Scheduler
410
-
411
- 原因:發現 {count} 個已完成任務污染佇列
412
- 任務 ID: {task_ids}
413
-
414
- 解決方案:
415
- 1. 執行清理腳本:node dev/scripts/cleanup-queue.js
416
- 2. 或手動移除 completed 任務
417
- 3. 重新啟動 Scheduler
418
-
419
- 規則:PPL-002.1, PPL-002.4
420
-
421
- - type: "warning"
422
- severity: "high"
423
- action: "Code Review 警告"
424
- condition: "Scheduler 代碼包含 'completed/' 路徑引用"
425
- message: |
426
- ⚠️ Code Review 警告
427
-
428
- 發現 Scheduler 代碼引用 completed/ 目錄,這可能導致佇列污染。
429
-
430
- 違反規則:PPL-002.3
431
- 請移除對 completed/ 的引用,只從 tasks/ 讀取任務。
432
-
433
- - type: "auto_fix"
434
- severity: "medium"
435
- action: "自動清理"
436
- condition: "定期清理腳本執行"
437
- message: |
438
- ✅ 自動清理完成
439
-
440
- 已移除 {count} 個已完成任務
441
- 當前佇列: {queue_size} 個任務
442
-
443
- 規則:PPL-002.5
444
-
445
- # ============================================================
446
- # 相關資源
447
- # ============================================================
448
-
449
- related_resources:
450
- failure_records:
451
- - id: "FAIL-003"
452
- title: "TASK_QUEUE 污染問題"
453
- path: ".failure/pipeline/FAIL-003-queue-pollution.yaml"
454
- description: "此規則的源頭失敗記錄"
455
-
456
- # The TASK_QUEUE.json scheduler (cmd_modules/scheduler/task_queue.rs,
457
- # dispatcher.rs) this rule was written against no longer exists. Task state,
458
- # including done -> archived, now lives in the task-api state machine.
459
- code_locations:
460
- - component: "Task state machine (done -> archived)"
461
- path: ".collaboration/core/task-api.js"
462
- description: "ALL_STATUS_DIRS / 允許的狀態轉移,含 done → archived 封存"
463
-
464
- scripts:
465
- - name: "cleanup-queue.js"
466
- path: "dev/scripts/cleanup-queue.js"
467
- description: "清理佇列腳本(Node.js)"
468
-
469
- - name: "cleanup-completed-tasks.ps1"
470
- path: "dev/scripts/cleanup-completed-tasks.ps1"
471
- description: "清理佇列腳本(PowerShell wrapper)"
472
-
473
- documentation:
474
- - title: "Pipeline 系統規範"
475
- path: ".rule/general/pipeline.yaml"
476
- description: "Pipeline 系統的整體規則"
477
-
478
- - title: "統計數據規範"
479
- path: ".memory/MEMORY.md"
480
- section: "Pipeline 管理"
481
- description: "累積制統計數據的詳細說明"
482
-
483
- # ============================================================
484
- # 教訓與啟示
485
- # ============================================================
486
-
487
- lessons_learned:
488
- - lesson: "數據模型要清晰分離"
489
- description: |
490
- 不要在單一文件(TASK_QUEUE.json)中混合當前狀態和歷史記錄。
491
- 應該:
492
- - Queue: 只存當前待處理任務
493
- - Memory: 存歷史已完成任務
494
- - Statistics: 計算時合併兩者
495
-
496
- - lesson: "累積制 ≠ 全部塞進佇列"
497
- description: |
498
- 累積制統計數據是指「統計總數包含歷史」,而非「佇列包含歷史任務」。
499
- 這是兩個層面的概念,不應混淆。
500
-
501
- - lesson: "同步邏輯要明確來源"
502
- description: |
503
- Scheduler 同步任務時,必須明確:
504
- - ✅ 從 tasks/ 讀取 → 待處理任務
505
- - ❌ 從 completed/ 讀取 → 污染佇列
506
-
507
- - lesson: "啟動前驗證資料完整性"
508
- description: |
509
- 系統啟動時應驗證核心數據文件的完整性,發現異常立即拒絕啟動,
510
- 避免帶病運行。
511
-
512
- - lesson: "自動化清理優於手動維護"
513
- description: |
514
- 定期自動化清理比依賴開發者記憶更可靠。
515
-
516
- # ============================================================
517
- # 修訂歷史
518
- # ============================================================
519
-
520
- changelog:
521
- - version: "1.0.0"
522
- date: "2026-02-05"
523
- author: "Developer Agent"
524
- changes:
525
- - "初始建立規則,源於 FAIL-003"
526
- - "定義五大子規則(PPL-002.1 ~ PPL-002.5)"
527
- - "提供清理腳本和驗證邏輯"
528
- - "建立預防措施和自動化檢查"