@event4u/agent-config 14.5.0 → 14.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +384 -3
  3. package/README.md +1 -1
  4. package/dist/agent-src/commands/analyze/decision.md +7 -0
  5. package/dist/agent-src/commands/analyze/inbox.md +264 -10
  6. package/dist/agent-src/commands/analyze.md +1 -1
  7. package/dist/agent-src/commands/optimize/project.md +10 -0
  8. package/dist/agent-src/commands/roadmap/process-full.md +132 -4
  9. package/dist/agent-src/contexts/execution/roadmap-execution-contract.md +31 -0
  10. package/dist/agent-src/contexts/execution/roadmap-process-loop.md +161 -1
  11. package/dist/agent-src/rules/context-hygiene.md +2 -0
  12. package/dist/agent-src/rules/decision-revisit-gate.md +111 -7
  13. package/dist/agent-src/rules/fix-what-you-see.md +108 -0
  14. package/dist/agent-src/rules/no-roadmap-references.md +0 -5
  15. package/dist/agent-src/rules/recurring-criticism.md +110 -0
  16. package/dist/agent-src/rules/roadmap-progress-sync.md +1 -1
  17. package/dist/agent-src/rules/rule-type-governance.md +0 -2
  18. package/dist/agent-src/rules/self-repair-loop.md +17 -0
  19. package/dist/agent-src/rules/skill-quality.md +0 -2
  20. package/dist/agent-src/rules/source-confidentiality.md +37 -7
  21. package/dist/agent-src/scripts/archival_sweep.ts +117 -0
  22. package/dist/agent-src/scripts/archive_completed_roadmaps.ts +19 -3
  23. package/dist/agent-src/scripts/gate_budget.ts +282 -0
  24. package/dist/agent-src/scripts/gate_execute.ts +72 -31
  25. package/dist/agent-src/scripts/roadmap_gates.ts +74 -3
  26. package/dist/agent-src/scripts/update_roadmap_progress.ts +251 -7
  27. package/dist/agent-src/skills/adr-create/SKILL.md +25 -3
  28. package/dist/agent-src/skills/ai-council/SKILL.md +48 -807
  29. package/dist/agent-src/skills/ai-council/references/advanced-modes.md +320 -0
  30. package/dist/agent-src/skills/ai-council/references/cost-and-redaction.md +99 -0
  31. package/dist/agent-src/skills/ai-council/references/execution-modes.md +162 -0
  32. package/dist/agent-src/skills/ai-council/references/output-and-synthesis.md +125 -0
  33. package/dist/agent-src/skills/ai-council/references/procedure.md +143 -0
  34. package/dist/agent-src/skills/decision-review/SKILL.md +18 -0
  35. package/dist/agent-src/skills/quality-tools/SKILL.md +34 -326
  36. package/dist/agent-src/skills/quality-tools/references/js-ts-tools.md +113 -0
  37. package/dist/agent-src/skills/quality-tools/references/php-tools.md +222 -0
  38. package/dist/agent-src/skills/roadmap-management/SKILL.md +15 -409
  39. package/dist/agent-src/skills/roadmap-management/references/archival.md +226 -0
  40. package/dist/agent-src/skills/roadmap-management/references/authoring.md +107 -0
  41. package/dist/agent-src/skills/roadmap-management/references/dashboard.md +47 -0
  42. package/dist/agent-src/skills/roadmap-management/references/lifecycle.md +58 -0
  43. package/dist/agent-src/skills/skill-writing/SKILL.md +34 -570
  44. package/dist/agent-src/skills/skill-writing/references/procedure.md +275 -0
  45. package/dist/agent-src/skills/skill-writing/references/read-only-scripts.md +18 -0
  46. package/dist/agent-src/skills/skill-writing/references/section-patterns.md +298 -0
  47. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  48. package/dist/agent-src/templates/roadmaps.md +45 -2
  49. package/dist/agent-src/templates/scripts/telemetry/flush_sender.mjs +163 -0
  50. package/dist/agent-src/templates/scripts/telemetry/remote.ts +160 -7
  51. package/dist/agent-src/templates/scripts/telemetry/transport.ts +169 -0
  52. package/dist/cli/registry.js +1 -1
  53. package/dist/cli/registry.js.map +1 -1
  54. package/dist/cli-delegate/chunk-2GNWGMAL.js +172 -0
  55. package/dist/cli-delegate/{chunk-RLN73PR5.js → chunk-4VR4ORQ6.js} +10 -7
  56. package/dist/cli-delegate/chunk-6EOCNQAM.js +402 -0
  57. package/dist/cli-delegate/{chunk-XURJ4AQC.js → chunk-74E3TKWV.js} +381 -280
  58. package/dist/cli-delegate/{chunk-3UCJWMMP.js → chunk-7F3VYSM2.js} +4 -4
  59. package/dist/cli-delegate/{chunk-BKO2AZ7Z.js → chunk-B2ERU2VA.js} +1 -1
  60. package/dist/cli-delegate/{chunk-NXFWFAYV.js → chunk-G23AT6GD.js} +1 -0
  61. package/dist/cli-delegate/{chunk-63WSP6YZ.js → chunk-GJ5BVHXM.js} +72 -165
  62. package/dist/cli-delegate/{chunk-ZPSXJTLI.js → chunk-JZ4NR2TW.js} +353 -1
  63. package/dist/cli-delegate/chunk-MWRD5YOH.js +100 -0
  64. package/dist/cli-delegate/{chunk-GRRPEPRN.js → chunk-T7L2QK3K.js} +24 -5
  65. package/dist/cli-delegate/{chunk-EVTY7ISR.js → chunk-YM4GZDJG.js} +9 -1
  66. package/dist/cli-delegate/cmd_conformance.js +459 -709
  67. package/dist/cli-delegate/cmd_doctor.js +6 -6
  68. package/dist/cli-delegate/cmd_explain.js +1 -1
  69. package/dist/cli-delegate/cmd_export.js +7 -6
  70. package/dist/cli-delegate/cmd_handoff.js +6 -6
  71. package/dist/cli-delegate/cmd_packs_active.js +1 -1
  72. package/dist/cli-delegate/cmd_preflight.js +2 -2
  73. package/dist/cli-delegate/cmd_prune.js +7 -6
  74. package/dist/cli-delegate/cmd_session_recycle.js +840 -30
  75. package/dist/cli-delegate/cmd_settings_migrate.js +7 -6
  76. package/dist/cli-delegate/cmd_settings_set.js +1 -1
  77. package/dist/cli-delegate/cmd_sync.js +7 -6
  78. package/dist/cli-delegate/cmd_uninstall.js +9 -7
  79. package/dist/cli-delegate/cmd_update.js +1 -1
  80. package/dist/cli-delegate/cmd_upgrade.js +1 -1
  81. package/dist/cli-delegate/cmd_validate.js +7 -6
  82. package/dist/discovery/deprecation-report.md +1 -1
  83. package/dist/discovery/discovery-manifest.json +72 -29
  84. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  85. package/dist/discovery/discovery-manifest.summary.md +4 -4
  86. package/dist/discovery/dormancy-report.md +1 -1
  87. package/dist/discovery/orphan-report.md +1 -1
  88. package/dist/discovery/packs.json +10 -8
  89. package/dist/discovery/trust-report.md +3 -3
  90. package/dist/discovery/workspaces.json +8 -6
  91. package/dist/hooks/dispatch.js +3127 -2022
  92. package/dist/install/claudePathsPlan.js +187 -0
  93. package/dist/install/claudePathsPlan.js.map +1 -0
  94. package/dist/install/hostLayerFingerprint.js +136 -0
  95. package/dist/install/hostLayerFingerprint.js.map +1 -0
  96. package/dist/install/install.mjs +553 -425
  97. package/dist/install/partitionEligibility.js +276 -0
  98. package/dist/install/partitionEligibility.js.map +1 -0
  99. package/dist/mcp/registry-manifest.json +3 -3
  100. package/dist/mcp/server.json +2 -2
  101. package/dist/mcp/server.mjs +1744 -1191
  102. package/dist/router.json +1 -1
  103. package/dist/scripts/_lib/agent_src.js +41 -0
  104. package/dist/scripts/_lib/agent_src.js.map +1 -1
  105. package/dist/scripts/_lib/install_layout.js +83 -0
  106. package/dist/scripts/_lib/install_layout.js.map +1 -0
  107. package/dist/scripts/_lib/installed_lock.js +444 -0
  108. package/dist/scripts/_lib/installed_lock.js.map +1 -0
  109. package/dist/scripts/condense.js +13 -164
  110. package/dist/scripts/condense.js.map +1 -1
  111. package/dist/server/schemas/settings.js +4 -0
  112. package/dist/server/schemas/settings.js.map +1 -1
  113. package/docs/contracts/settings-classes.md +12 -6
  114. package/docs/guidelines/agent-infra/agent-interaction-and-decision-quality.md +8 -3
  115. package/docs/guidelines/agent-infra/context-hygiene-mechanics.md +26 -0
  116. package/docs/guidelines/agent-infra/engineering-memory-data-format.md +49 -0
  117. package/docs/guidelines/agent-infra/memory-access.md +17 -0
  118. package/docs/guidelines/agent-infra/recurring-criticism-mechanics.md +96 -0
  119. package/package.json +1 -1
  120. package/src/agent-src/scripts/archival_sweep.ts +117 -0
  121. package/src/agent-src/scripts/archive_completed_roadmaps.ts +19 -3
  122. package/src/agent-src/scripts/gate_budget.ts +282 -0
  123. package/src/agent-src/scripts/gate_execute.ts +72 -31
  124. package/src/agent-src/scripts/roadmap_gates.ts +74 -3
  125. package/src/agent-src/scripts/update_roadmap_progress.ts +251 -7
  126. package/src/agent-src/templates/scripts/telemetry/flush_sender.mjs +163 -0
  127. package/src/agent-src/templates/scripts/telemetry/remote.ts +160 -7
  128. package/src/agent-src/templates/scripts/telemetry/transport.ts +169 -0
  129. package/src/config/agent-settings.template.yml +27 -2
  130. package/src/config/ci-local-parity.yml +18 -0
  131. package/src/config/estate-count-budget.json +367 -3
  132. package/src/config/gate-violation-baselines.json +41 -41
  133. package/src/config/pack-size-budget.json +3 -2
  134. package/src/config/rule-activation-census.json +14 -6
  135. package/src/config/rule-stub-ceilings.json +19 -6
  136. package/src/install/claudePathsPlan.ts +196 -0
  137. package/src/install/hostLayerFingerprint.ts +145 -0
  138. package/src/install/partitionEligibility.ts +325 -0
  139. package/src/scripts/_cli/cmd_session_recycle.ts +9 -1
  140. package/src/scripts/_dispatch.bash +6 -1
  141. package/src/scripts/_lib/ac_heading.ts +30 -0
  142. package/src/scripts/_lib/agent_src.ts +42 -0
  143. package/src/scripts/_lib/bench_ab_pinned_repo.ts +162 -0
  144. package/src/scripts/_lib/bench_ab_workspace.ts +10 -1
  145. package/src/scripts/_lib/envelope_grounding.ts +38 -8
  146. package/src/scripts/_lib/installed_lock.ts +50 -5
  147. package/src/scripts/_lib/layer_overlap_notice.ts +85 -0
  148. package/src/scripts/_lib/md_section.ts +129 -0
  149. package/src/scripts/_lib/scope_guard.sh +86 -4
  150. package/src/scripts/_lib/self_repair.ts +19 -0
  151. package/src/scripts/_lib/self_repair_class_b.ts +171 -0
  152. package/src/scripts/_lib/subagent_capsule.ts +81 -1
  153. package/src/scripts/adr/regenerate_index.ts +13 -2
  154. package/src/scripts/adr_cite_check.ts +424 -0
  155. package/src/scripts/ai_council/cli_help.ts +55 -0
  156. package/src/scripts/before_complete_hook.ts +153 -28
  157. package/src/scripts/bench_ab_v2_complexity.ts +27 -7
  158. package/src/scripts/check_adr_frontmatter.ts +187 -1
  159. package/src/scripts/check_references.ts +60 -0
  160. package/src/scripts/check_release_published.ts +32 -11
  161. package/src/scripts/check_single_delivery.ts +517 -0
  162. package/src/scripts/ci_settle.ts +170 -0
  163. package/src/scripts/condense.ts +20 -170
  164. package/src/scripts/council_cli.ts +3 -3
  165. package/src/scripts/dispatch_r2_reviewer.ts +6 -14
  166. package/src/scripts/hook_manifest.json +1 -1
  167. package/src/scripts/hook_manifest.yaml +77 -14
  168. package/src/scripts/hooks/block_no_verify.ts +61 -10
  169. package/src/scripts/hooks/block_unauthorized_git.ts +1 -1
  170. package/src/scripts/hooks/concern_registry.ts +4 -0
  171. package/src/scripts/hooks/rtk_wrap_hook.ts +8 -3
  172. package/src/scripts/hooks/run_continuation_hook.ts +887 -68
  173. package/src/scripts/hooks/ship_diff_volume_hook.ts +81 -15
  174. package/src/scripts/hooks/source_first_gate_hook.ts +464 -0
  175. package/src/scripts/hooks/state_io.ts +782 -20
  176. package/src/scripts/hooks/subagent_ledger_hook.ts +44 -15
  177. package/src/scripts/hooks/telemetry_flush_hook.ts +139 -0
  178. package/src/scripts/hooks/telemetry_self_repair.ts +128 -0
  179. package/src/scripts/hooks/telemetry_usage_hook.ts +22 -4
  180. package/src/scripts/hooks/turn_end_gate_hook.ts +81 -15
  181. package/src/scripts/install.sh +12 -2
  182. package/src/scripts/install.ts +16 -11
  183. package/src/scripts/language_mirror_hook.ts +561 -25
  184. package/src/scripts/lint_framework_leakage_allowlist.json +2 -2
  185. package/src/scripts/lint_plan_risk_register.ts +4 -3
  186. package/src/scripts/lint_skill_router_head.ts +4 -4
  187. package/src/scripts/mcp_server/tools.ts +2 -2
  188. package/src/scripts/memory_consolidation.ts +189 -0
  189. package/src/scripts/memory_eviction.ts +384 -0
  190. package/src/scripts/new_roadmap.ts +136 -0
  191. package/src/scripts/pack_mcp_content.ts +20 -5
  192. package/src/scripts/release.ts +37 -38
  193. package/src/scripts/report_layer_overlap.ts +78 -0
  194. package/src/scripts/report_memory_pointers.ts +622 -0
  195. package/src/scripts/self_repair_hook.ts +37 -5
  196. package/src/scripts/session_register_hook.ts +115 -15
  197. package/src/scripts/skill_usage_collect.ts +11 -1
  198. package/src/scripts/skill_usage_report.ts +278 -8
  199. package/src/scripts/sync_pr_branch.ts +7 -0
  200. package/src/server/schemas/settings.ts +8 -0
  201. package/dist/cli-delegate/chunk-EJITJBJX.js +0 -172
  202. package/dist/cli-delegate/chunk-PZWRPRWP.js +0 -38
  203. /package/dist/cli-delegate/{chunk-RYNADUFG.js → chunk-LWTYTX6F.js} +0 -0
@@ -0,0 +1,125 @@
1
+ # ai-council — output path and synthesis
2
+
3
+ > Mode body of the [`ai-council`](../SKILL.md) skill (router-head retrofit,
4
+ > 2026-08-20). Content moved VERBATIM from SKILL.md — load this file when the
5
+ > mode table in SKILL.md routes here.
6
+
7
+ ## Output path convention
8
+
9
+ Council artefacts (questions, responses, sessions) are **dev-time
10
+ scratch** — gitignored in both the package repo and consumer repos
11
+ and auto-pruned after `ai_council.session_retention_days` (default
12
+ 7). They inform a decision; they are not the durable contract. The
13
+ durable contract lives in the roadmap / ADR / skill body that cites
14
+ the council's convergence inline.
15
+
16
+ **Linking to a specific council file is forbidden by
17
+ [`no-roadmap-references`](../../../rules/no-roadmap-references.md)
18
+ (council clause)** — gitignored, not in the cloned repo, gone after
19
+ the retention window. Inline the convergence with date + members
20
+ instead.
21
+
22
+ Three directories, three modes:
23
+
24
+ | Mode | Path | Format |
25
+ |---|---|---|
26
+ | **Topic-anchored question** (paired with a roadmap or ADR) | `agents/runtime/council/questions/<topic-slug>.md` | Markdown |
27
+ | **Topic-anchored response** (paired with the question above) | `agents/runtime/council/responses/<topic-slug>.json` | JSON from `council:run --output` |
28
+ | **Ad-hoc session** (no durable artefact yet) | `agents/runtime/council/sessions/<UTC-timestamp>.json` | JSON from `council:run --output` |
29
+
30
+ `<topic-slug>` is kebab-case and **must match** the corresponding
31
+ roadmap / ADR slug if one exists (e.g. `path-fixes` mirrors the
32
+ matching `road-to-<topic-slug>` roadmap under `agents/roadmaps/`).
33
+
34
+ ### Forbidden
35
+
36
+ - Files at `agents/` root (e.g. `agents/runtime/council/question-foo.md`).
37
+ - Dot-prefix scratch (e.g. `agents/.council-question-foo.md`).
38
+ - Any other directory below `agents/` (e.g. `agents/scratch/`,
39
+ `agents/evidence/notes/`). Operator scratch belongs under
40
+ `agents/runtime/tmp/` (gitignored).
41
+ - Cross-references from any artefact to specific council files —
42
+ see [`no-roadmap-references`](../../../rules/no-roadmap-references.md)
43
+ (council clause). Inline the convergence summary instead, with
44
+ date and member list for traceability (`Council (claude-sonnet-4-5
45
+ + gpt-4o, YYYY-MM-DD) reviewed N candidate strategies; converged
46
+ on …`).
47
+
48
+ ### Exempt
49
+
50
+ - `agents/evidence/audits/` — historical audit bundles. The canonical
51
+ council dirs are gitignored; audit bundles are tracked,
52
+ cohesive narratives that may include council artefacts as
53
+ part of their evidence trail (e.g. `audits/2026-05-14-north-star/`
54
+ bundling its triggering question, raw responses, and synthesis
55
+ alongside the audit's findings). The layout linter
56
+ (`scripts/check_council_layout.ts`) skips this directory.
57
+
58
+ `scripts/check_council_layout.ts` is the mechanical check for the
59
+ output path convention — wire it into the package's CI pipeline so
60
+ violations break the build.
61
+
62
+ ## Synthesis templates (lens-aware)
63
+
64
+ The **Convergence / Divergence** slot in `council:render` output is
65
+ populated with a lens-specific synthesis prompt. The host agent reads
66
+ this prompt and writes the summary in the shape it dictates. The five
67
+ templates live in `scripts/ai_council/prompts.ts::_SYNTHESIS_TABLE`
68
+ and are exposed via `synthesis_template(mode)`.
69
+
70
+ **R4 Q4 split** — decision lenses get a structured Karpathy-style
71
+ template; creative lenses keep an open-ended prose body. **Every lens
72
+ now closes with two required verdict-discipline sections** — **Kill
73
+ criteria** (observable falsifiers with a threshold or event, checkable
74
+ without re-convening the council) and **Concrete next step** (exactly
75
+ one artefact-producing action) — added so no synthesis ships an
76
+ unfalsifiable verdict (road-to-opt-council-deliberation Phase 0):
77
+
78
+ | Lens | Class | Synthesis sections |
79
+ |---|---|---|
80
+ | `default` | decision | Agreement · Clashes · Blind spots · Recommendation · **Kill criteria · Concrete next step** |
81
+ | `pr` | decision | Consensus · Conflicts · Must-fix before merge · Recommendation · **Kill criteria · Concrete next step** |
82
+ | `analysis` | decision | Top-10 by consensus · Supporting · Outliers · **Kill criteria · Concrete next step** |
83
+ | `design` | creative | open prose body + **Kill criteria · Concrete next step** |
84
+ | `optimize` | creative | open prose body + **Kill criteria · Concrete next step** |
85
+
86
+ Input modes (`prompt` / `roadmap` / `diff` / `files`) inherit the
87
+ `default` decision template — they are bundling shapes, not lenses.
88
+
89
+ **Source citations:**
90
+ * Template shape — Round 2 council verdict
91
+ (`agents/runtime/council/sessions/2026-05-14-ai-council-redesign/round-1.md`,
92
+ Opus's lens-adaptive synthesis proposal).
93
+ * Decision/creative split — Round 4 Q4 verdict
94
+ (`agents/runtime/council/sessions/2026-05-14-ai-council-redesign/round-3-responses.json`).
95
+ R4 reframed `optimize` as creative because perf trade-offs resist
96
+ pre-templated shape — Performance-wins / Trade-offs /
97
+ Implementation-order is too rigid for the variety of optimize-lens
98
+ artefacts. R4 reframed `design` for the same reason — design
99
+ critiques are inherently narrative.
100
+
101
+ ### `--prose-synthesis` escape hatch (R4 Q4)
102
+
103
+ Both `council:run` and `council:render` accept symmetric escape-hatch
104
+ flags on top of the lens table:
105
+
106
+ * `--prose-synthesis` — force creative-lens passthrough (bare slot)
107
+ regardless of lens. Use when the user on `default`/`pr`/`analysis`
108
+ prefers a narrative recommendation over the structured template.
109
+ * `--no-prose-synthesis` — force the `default` structured template
110
+ even on a creative lens. Use when a `design` or `optimize` artefact
111
+ has a one-shot need for Karpathy-style structure.
112
+
113
+ The flag is mutually exclusive — picking one disables the other on
114
+ the same invocation. When `council:run` records either flag in the
115
+ output JSON, `council:render` honours it unless the renderer is
116
+ called with an explicit flag of its own.
117
+
118
+ ### Renderer lens resolution
119
+
120
+ `council:render <responses.json>` resolves the active lens in this
121
+ order: explicit `--prompt-mode` flag > `prompt_mode` field in the
122
+ payload > `mode` field in the payload > `None` (default decision
123
+ template). The `--prose-synthesis` / `--no-prose-synthesis` flag
124
+ overrides the table regardless of how the lens resolved.
125
+
@@ -0,0 +1,143 @@
1
+ # ai-council — procedure and critical evaluation
2
+
3
+ > Mode body of the [`ai-council`](../SKILL.md) skill (router-head retrofit,
4
+ > 2026-08-20). Content moved VERBATIM from SKILL.md — load this file when the
5
+ > mode table in SKILL.md routes here.
6
+
7
+ ### Neutrality — context-handoff
8
+
9
+ External reviewers do better critique when they know **what the
10
+ project is**, not just what the artefact looks like. The council
11
+ ships a neutral **handoff preamble** (modelled on `/agent-handoff`)
12
+ in front of every member's system prompt, assembled by
13
+ `prompts.handoff_preamble(project, original_ask)`:
14
+
15
+ | Carried | Forbidden |
16
+ |---|---|
17
+ | Project name (from `composer.json` / `package.json` / repo dir) | Host-agent identity (Augment, Claude Code, Cursor, Cline, Windsurf, Copilot agent) — stripped line-by-line before send |
18
+ | Stack one-liner inferred from manifest files | Host-agent reasoning, prior turns, internal analysis |
19
+ | One paragraph of repo purpose from `README.md` (max 400 chars) | Host-agent framing language ("I think this looks weak", "the user probably wants…") |
20
+ | The user's **original ask** verbatim (the free-form sentence that triggered `/council`) | Anything the host agent generated about the artefact |
21
+
22
+ `detect_project_context()` in `scripts/ai_council/project_context.ts`
23
+ reads only the manifest files + root README; missing fields collapse
24
+ to `None` and the preamble silently omits the line. With both
25
+ `project=None` and `original_ask=""`, the preamble degrades to the
26
+ bare `NEUTRALITY_PREAMBLE` (v1 shape — back-compat for callers that
27
+ have not migrated yet).
28
+
29
+ ## Procedure
30
+
31
+ 1. **Resolve target.** Identify the artefact mode (`prompt`, `roadmap`,
32
+ `diff`, `files`) and locate the source. Refuse to proceed if the
33
+ target is ambiguous.
34
+ 2. **Bundle + redact.** Call `scripts/ai_council/bundler.ts` to produce
35
+ a redacted artefact bundle. If `BundleTooLarge` fires, surface the
36
+ size and ask the user to narrow scope — do NOT truncate silently.
37
+ 3. **Clear the spend bound.** The council is standing-authorized — there is
38
+ no per-invocation approval. What still binds is a *bound*, resolved in
39
+ this order:
40
+ - **No billable member** (every member is `mode: cli` under
41
+ subscription auth — `billable=False`) → nothing is spent. Render the
42
+ estimate table as information and fan out. No gate.
43
+ - **Billable members with a configured ceiling** (`cost_budget.max_total_usd`
44
+ non-zero, or `daily_limit_usd` non-zero) → the ceiling **is** the
45
+ authorization the user already gave. Render the estimate and fan out.
46
+ `on_overrun` still fires per member on breach (below) — that is where
47
+ the user regains the decision.
48
+ - **Billable members with no ceiling at all** (`max_total_usd: 0` AND
49
+ `daily_limit_usd: 0`) → unbounded paid spend, so surface the estimate
50
+ and require an explicit `1`. Nothing bounds the call, so the user must.
51
+
52
+ Autonomy settings do not *create* a bound and do not lift the last case.
53
+ Consumers who want the old per-run gate back set a small
54
+ `cost_budget.max_total_usd`: every call then breaches and `on_overrun`
55
+ asks, per member.
56
+ 4. **Fan out.** Dispatch the bundle to each enabled council member via
57
+ `scripts/ai_council/orchestrator.ts`. Each member receives the
58
+ neutrality preamble from `prompts.ts` plus the artefact — nothing
59
+ from the host agent's prior reasoning.
60
+ 5. **Render results.** Stack each member's response under its own
61
+ provider-attributed heading. Never merge or paraphrase responses
62
+ into the host agent's voice.
63
+ 6. **Summarise.** Write a `Convergence / Divergence` block listing
64
+ agreements, disagreements, and unique insights — provider-attributed.
65
+ 7. **Critically evaluate** every finding before it leaves the host
66
+ (see *Critical evaluation* below). The host is the convener **and**
67
+ the skeptic — never a reviewer of the artefact itself, but always a
68
+ reviewer of the **council's output**.
69
+ 8. **Translate validated findings to options.** Convert each finding
70
+ the host accepts (or accepts with modification) into a concrete
71
+ numbered option for the user. Tag every option with the host's
72
+ verdict so the user sees the agent's reasoned position, not the
73
+ council's raw output. The user decides; the council advises; the
74
+ host filters.
75
+
76
+ ## Critical evaluation — convener-skeptic stance
77
+
78
+ ```
79
+ COUNCIL CONVERGENCE IS NOT CORRECTNESS.
80
+ DO NOT BLINDLY ACCEPT FINDINGS. DO NOT BLINDLY REJECT THEM.
81
+ EVERY FINDING GETS A REASONED VERDICT BEFORE IT REACHES THE USER.
82
+ ```
83
+
84
+ ### Mechanism claims need a probe, not a second opinion
85
+
86
+ ```
87
+ A MECHANISM CLAIM IN A COUNCIL ARTEFACT IS MARKED `unverified:` UNTIL A PROBE COVERS IT.
88
+ A VERDICT RESTING ON AN UNVERIFIED MECHANISM CLAIM DOES NOT BIND.
89
+ SEVERAL MODELS AGREEING MULTIPLIES PLAUSIBILITY. IT DOES NOT PRODUCE EVIDENCE.
90
+ ```
91
+
92
+ A **mechanism claim** asserts how the machine behaves: "this toggle removes the
93
+ cost", "that gate scans X", "the host reads the router". The council deliberates
94
+ over **arguments**, never against the running system — it cannot execute a command,
95
+ so it has no way to falsify one. Marking such a claim `unverified:` in the artefact
96
+ keeps the reader from mistaking a well-argued mechanism for a measured one, and the
97
+ non-binding clause means the fix for a wrong claim is a probe, not a re-vote.
98
+
99
+ **Case zero (2026-07-29).** An accepted ADR claimed a compile-time toggle gave
100
+ "zero-cost dormancy" because the rule was dropped from `dist/router.json`. Two
101
+ council members praised the reasoning; neither could check it. A one-line `grep`
102
+ later showed the toggle was read by the router compiler and by **nothing in the
103
+ projector**, so the rule's body kept shipping as a file — and the host reads the
104
+ file. The claim was half wrong, the verdict that rested on it was void, and what
105
+ caught it was a probe, not a third opinion.
106
+
107
+ The council is **uninformed about the codebase, ADRs, locked
108
+ contracts, prior decisions, and project history** — it sees only the
109
+ artefact + neutrality preamble. That is the source of its diversity
110
+ **and** its blind spots. Convergence between members can mean shared
111
+ generic best-practice priors, not project-specific correctness.
112
+
113
+ The host applies a critical lens to **every finding** (convergence
114
+ **and** divergence) before surfacing it as a numbered option:
115
+
116
+ | Check | Question | Tool |
117
+ |---|---|---|
118
+ | **Codebase fit** | Does the finding match the actual code, files, signatures, conventions? | `view` / `codebase-retrieval` / `grep` |
119
+ | **Locked-decision conflict** | Does it contradict an ADR, kernel rule, contract under `docs/contracts/`, or `docs/decisions/`? | `view` |
120
+ | **Already addressed** | Is it a generic best-practice already covered by an existing rule, skill, or test? | `view` / `grep` |
121
+ | **Cost / benefit** | Is the change worth the diff size, churn, and review cost vs. the marginal benefit? | reasoning |
122
+ | **Hallucination** | Does the finding cite a file, function, or behavior that does not exist? | `view` |
123
+
124
+ Each finding receives one of three verdicts:
125
+
126
+ - **`accept`** — codebase fits, no locked-decision conflict, benefit clears cost. Surface as a normal numbered option.
127
+ - **`accept-with-modification`** — core insight valid, but the proposed shape needs adjusting (wrong file, contradicts ADR detail, scope creep). Surface with the **modified** patch and a one-line note.
128
+ - **`reject`** — finding is wrong (hallucinated reference, contradicts a locked decision, already addressed, generic noise). Surface as a **Rejected by host** entry with a one-line reason. Still visible — the user can override.
129
+
130
+ The verdict is the host's **own** reasoning, not the council's.
131
+ Pretending convergence equals correctness, or paraphrasing council
132
+ output as host analysis, both breach the [`direct-answers`](../../../rules/direct-answers.md)
133
+ no-invented-facts rule. When the host cannot reach a confident
134
+ verdict on a finding (mixed evidence, ambiguous scope), it surfaces
135
+ the finding as `needs-input` with the open question — the user
136
+ decides, the host does not guess.
137
+
138
+ ### What this is NOT
139
+
140
+ - **Not a re-review by the host.** The host did not write the artefact independently and cannot critique it independently — that boundary still holds.
141
+ - **Not a vote against the council.** Rejecting a finding requires evidence (file, line, contract reference), not preference.
142
+ - **Not silent filtering.** Every finding reaches the user with its verdict and reason. The user can pick a `reject` option and override the host.
143
+
@@ -280,6 +280,24 @@ in the rule; the lock catalog, fire steps, and failure modes live here.
280
280
  contract — every re-evaluated lock gets a fresh, correctly-scoped
281
281
  disposition, not a re-statement of the old one.
282
282
 
283
+ When the lock is an **ADR**, the disposition carries the five-field reopen
284
+ record from [`adr-layout § Reopen record`](../../../docs/contracts/adr-layout.md):
285
+ the original rationale **addressed** (not cited), what changed with tree
286
+ evidence, dependants and external commitments touched, the rollback path,
287
+ and a blast radius — `narrow | wide | irreversible` — with the evidence for
288
+ that call. Two clauses bind the same record: **precedent creates no
289
+ authority** (that a similar ADR was reopened is never grounds for this one),
290
+ and **one seat must argue the strongest case for keeping the decision**.
291
+ Both answer precedent laundering through correlated self-review, which is
292
+ the failure two independent council seats named for this mechanism on
293
+ 2026-08-19: the proposer frames the evidence, correlated seats ratify, and
294
+ the amendment becomes authoritative input for the next review.
295
+
296
+ Proportionally: a narrow, reversible, bounded transition takes the light
297
+ path (record + council); `wide` or `irreversible` adds owner notification.
298
+ Identical ceremony for a typo-level amendment would cost more than asking
299
+ the owner and the mechanism would die of its own weight.
300
+
283
301
  ### When NOT to fire
284
302
 
285
303
  - The blocked change has no real benefit — the gate is not a lever to
@@ -23,6 +23,20 @@ Use this skill whenever running or configuring code quality tools:
23
23
  - **PHP**: PHPStan (static analysis), Rector (automated refactoring), ECS (coding standards)
24
24
  - **JS/TS**: Biome (linting + formatting), TypeScript compiler (type checking), Jest/Vitest (tests)
25
25
 
26
+ ## Modes
27
+
28
+ This skill is a router head. The cross-mode material — execution policy,
29
+ language detection, environment, output, gotchas — lives below. The per-tool
30
+ procedure bodies live in `references/`; load exactly the mode the detected
31
+ stack calls for.
32
+
33
+ | Detected stack | Mode body | Covers |
34
+ |---|---|---|
35
+ | PHP (`.php` changed) | [`references/php-tools.md`](references/php-tools.md) | Tool detection, PHPStan / ECS / Rector commands and flags, combined pipeline, config files, baseline policy, PHPStan error handling, testing framework, git-aware execution |
36
+ | JS/TS (`.js` / `.ts` / `.tsx` changed) | [`references/js-ts-tools.md`](references/js-ts-tools.md) | Detection, Biome, TypeScript type checking, Jest / Vitest, the JS/TS workflow sequence |
37
+
38
+ Both stacks changed → load both mode bodies and run both pipelines.
39
+
26
40
  ## Execution policy — on demand only, never proactive
27
41
 
28
42
  ```
@@ -59,6 +73,26 @@ git diff --name-only origin/main..HEAD | grep -E '\.(js|ts|tsx)$' # → JS/TS t
59
73
 
60
74
  If both PHP and JS/TS files changed → run **both** pipelines.
61
75
 
76
+ ## Procedure
77
+
78
+ 1. Confirm a run is justified — see Execution policy above. No trigger, no run.
79
+ 2. Detect the stack from the changed files — see Language detection above.
80
+ 2b. **Inspect the project's own quality config before running anything.** Read
81
+ the config files the detected stack actually ships (`phpstan.neon`,
82
+ `ecs.php`, `rector.php`, `biome.json`, `tsconfig.json`, the `scripts` block
83
+ of `package.json`) and the task/make wrapper if one exists. Never assume a
84
+ default ruleset, a default baseline, or a default command — the mode body
85
+ names where to look per stack. Running a tool against assumed config
86
+ produces findings the project never asked for.
87
+ 3. Load the matching mode body from the table in Modes and follow its
88
+ procedure. PHP → [`references/php-tools.md`](references/php-tools.md)
89
+ § Procedure: Run quality checks. JS/TS →
90
+ [`references/js-ts-tools.md`](references/js-ts-tools.md)
91
+ § JS/TS Quality Workflow.
92
+ 4. Both stacks changed → run both mode procedures; neither result excuses the
93
+ other.
94
+ 5. Report per Output format below.
95
+
62
96
  ## Related rules and guidelines
63
97
 
64
98
  - `verify-before-complete` rule — no pass claims without fresh output; suppressed runs are surfaced as "delegated to remote CI", never claimed
@@ -71,332 +105,6 @@ If both PHP and JS/TS files changed → run **both** pipelines.
71
105
 
72
106
  ---
73
107
 
74
- # PHP Quality Tools
75
-
76
- ## Tool Detection
77
-
78
- Check `composer.json` to determine which tools are available and how to run them.
79
- Use the **first matching** command style:
80
-
81
- | `composer.json` contains | Command style | Example |
82
- |---|---|---|
83
- | A project-specific quality wrapper (exposes `quality:*` commands) | `php artisan quality:*` or `composer quality:*` | `php artisan quality:phpstan` |
84
- | `phpstan/phpstan` or `larastan/larastan` | `vendor/bin/phpstan` | `vendor/bin/phpstan analyse` |
85
- | `rector/rector` | `vendor/bin/rector` | `vendor/bin/rector process` |
86
- | `symplify/easy-coding-standard` | `vendor/bin/ecs` | `vendor/bin/ecs check --fix` |
87
-
88
- **Priority:** If a project ships a `quality:*` wrapper (Artisan or Composer script), always prefer it —
89
- wrappers typically add git-aware execution, caching, automatic baseline regeneration, and memory
90
- management on top of the native tools.
91
-
92
- If none of the above is installed → skip quality checks, inform the user.
93
-
94
- All commands run **inside the Docker container** if Docker is used (`docker compose exec` or `make console`).
95
-
96
- ## Commands
97
-
98
- ### PHPStan — Static Analysis
99
-
100
- ```bash
101
- # Native:
102
- vendor/bin/phpstan analyse # Analyse all configured paths
103
- vendor/bin/phpstan analyse --memory-limit=512M # With memory limit
104
- vendor/bin/phpstan analyse --error-format=github # CI-friendly format
105
-
106
- # With a project-specific quality wrapper:
107
- php artisan quality:phpstan # Laravel
108
- composer quality:phpstan # Composer
109
- ```
110
-
111
- **Native flags:**
112
-
113
- | Flag | Description |
114
- |---|---|
115
- | `--memory-limit=SIZE` | Set memory limit (e.g. `512M`, `1G`) |
116
- | `--debug` | Activate debug mode |
117
- | `--error-format=FORMAT` | Output format: `table` (default), `github`, `gitlab` |
118
- | `--pro` | Toggle PHPStan Pro |
119
-
120
- **Wrapper-only flags** (typical of a `quality:*` wrapper — verify in the project):
121
-
122
- | Flag | Description |
123
- |---|---|
124
- | `--baseline` | Generate/update phpstan baseline file |
125
- | `--ignore-git` | Skip Git check, analyse all files |
126
- | `--xdebug` | Activate Xdebug mode |
127
-
128
- ### ECS — Easy Coding Standard
129
-
130
- ```bash
131
- # Native:
132
- vendor/bin/ecs check # Dry-run
133
- vendor/bin/ecs check --fix # Auto-fix
134
-
135
- # With a project-specific quality wrapper:
136
- php artisan quality:ecs --fix # Laravel
137
- composer quality:ecs -- --fix # Composer
138
- ```
139
-
140
- **Native flags:**
141
-
142
- | Flag | Description |
143
- |---|---|
144
- | `--fix` | Fix errors automatically |
145
- | `--clear-cache` | Clear the ECS cache |
146
-
147
- **Wrapper-only flags** (typical of a `quality:*` wrapper — verify in the project):
148
-
149
- | Flag | Description |
150
- |---|---|
151
- | `--ignore-git` | Skip Git check, check all files |
152
- | `--paths-to-scan[=PATHS]` | Custom paths, e.g. `--paths-to-scan='["./core"]'` |
153
- | `--source-branch[=BRANCH]` | Source branch (default: HEAD) |
154
- | `--target-branch[=BRANCH]` | Target branch to compare against |
155
-
156
- ### Rector — Automated Refactoring
157
-
158
- ```bash
159
- # Native:
160
- vendor/bin/rector process # Auto-fix
161
- vendor/bin/rector process --dry-run # Preview changes
162
-
163
- # With a project-specific quality wrapper:
164
- php artisan quality:rector --fix # Laravel
165
- composer quality:rector -- --fix # Composer
166
- ```
167
-
168
- **Native flags:**
169
-
170
- | Flag | Description |
171
- |---|---|
172
- | `--dry-run` | Preview changes without applying |
173
- | `--clear-cache` | Clear the Rector cache |
174
-
175
- **Wrapper-only flags** (typical of a `quality:*` wrapper — verify in the project):
176
-
177
- | Flag | Description |
178
- |---|---|
179
- | `--ignore-git` | Skip Git check, check all files |
180
- | `--paths-to-scan[=PATHS]` | Custom paths |
181
- | `--source-branch[=BRANCH]` | Source branch (default: HEAD) |
182
- | `--target-branch[=BRANCH]` | Target branch to compare against |
183
-
184
- ### Combined Commands
185
-
186
- There is no native single command for running all three tools. Run them in sequence:
187
-
188
- ```bash
189
- # Full pipeline (native):
190
- vendor/bin/rector process && vendor/bin/ecs check --fix && vendor/bin/phpstan analyse
191
-
192
- # With a project-specific quality wrapper (if it ships these combined commands):
193
- php artisan quality:refactor --fix # Rector + ECS
194
- php artisan quality:finalize # Rector + ECS + PHPStan (full pipeline)
195
- ```
196
-
197
- ## Procedure: Run quality checks
198
-
199
- 1. Run PHPStan — fix all errors
200
- 2. Run Rector + ECS with auto-fix — fix style + refactoring
201
- 3. Run PHPStan again — verify step 2 didn't introduce new issues
202
-
203
- If step 3 finds errors → fix and repeat from step 2.
204
-
205
- Detect commands from project (see Tool Detection above).
206
-
207
- ## Configuration
208
-
209
- Config files are typically in the **project root**. Do NOT modify without explicit user permission.
210
-
211
- Detect config location:
212
- - Check project root first: `phpstan.neon`, `ecs.php`, `rector.php`
213
- - Some projects use `phpstan.neon.dist` instead of `phpstan.neon`
214
-
215
- ### Standard config files
216
-
217
- | File | Tool | Purpose |
218
- |---|---|---|
219
- | `phpstan.neon` | PHPStan | Level, paths, extensions, `ignoreErrors`, disallowed calls |
220
- | `phpstan-baseline.neon` | PHPStan | Baseline for existing errors (auto-managed, do NOT edit) |
221
- | `ecs.php` | ECS | Code style: rule sets, configured rules, skip list |
222
- | `rector.php` | Rector | Refactoring: rule sets, PHP version sets, skip list |
223
-
224
- ### Understanding the project's config
225
-
226
- Read the actual config files to understand what rules are active:
227
-
228
- - **phpstan.neon**: Check `level`, `paths`, `ignoreErrors`, `includes` (baselines, extensions)
229
- - **ecs.php**: Check which rule sets are active (PSR-12, PHP-CS-Fixer sets), skip list
230
- - **rector.php**: Check PHP version sets, active rule sets, skip list
231
-
232
- Common patterns across projects:
233
- - PHPStan at high levels (8-9) with `disallowedFunctionCalls` banning `var_dump()`, `dd()`
234
- - ECS with PSR-12 base, trailing commas, Yoda style
235
- - Rector with PHP version migration sets and naming conventions
236
-
237
- ## Baseline policy
238
-
239
- - **NEVER** edit `phpstan-baseline.neon` by hand.
240
- - **NEVER** add errors, update counts, or regenerate manually.
241
- - If the project ships a quality wrapper (exposing `quality:*` commands), it may regenerate the baseline automatically.
242
-
243
- ## PHPStan error handling
244
-
245
- Priority order for dealing with PHPStan errors:
246
-
247
- 1. **Fix the code** — always the first choice. Fix the actual type issue.
248
- 2. **Add type hints / PHPDoc** — if the code is correct but PHPStan can't infer the type.
249
- 3. **Inline ignore (last resort)** — only for confirmed false positives:
250
- ```php
251
- // @phpstan-ignore-next-line — false positive: reason here
252
- ```
253
-
254
- ### When `phpstan.neon` changes ARE allowed
255
-
256
- Adding `ignoreErrors` entries to `phpstan.neon` is allowed when:
257
-
258
- - The error is a **structural limitation** of the toolchain (e.g., Pest tests bind `$this` at runtime, PHPStan can't resolve `artisan()`,
259
- `get()`, etc. on `PHPUnit\Framework\TestCase`)
260
- - The pattern applies **broadly** to a category of files (e.g., all test files), not just one specific line
261
- - The fix would require abandoning the project's conventions (e.g., rewriting Pest tests as PHPUnit classes)
262
-
263
- **If unsure whether a `phpstan.neon` change is appropriate → ask the user before making the change.**
264
-
265
- ### NEVER do these
266
-
267
- - Add entries to baseline files (`phpstan-baseline.neon`)
268
- - Add `ignoreErrors` for individual files or specific code issues that should be fixed
269
- - Use `@phpstan-ignore-next-line` without a reason comment
270
-
271
- See also: `php-coding` rule → PHPStan section.
272
-
273
- ## Testing framework
274
-
275
- - **Always write tests in Pest**, not PHPUnit class syntax — unless the user explicitly asks for PHPUnit.
276
- - Pest tests in `tests/Unit/` automatically use `UnitTestCase` as the base class (configured in `tests/Pest.php`).
277
- - PHPStan cannot fully resolve Pest's runtime bindings — this is handled via `ignoreErrors` patterns in `phpstan.neon`.
278
-
279
- ## Git-aware execution
280
-
281
- By default, all tools only check files changed since the last commit.
282
-
283
- | Flag | Effect |
284
- |------------------------------|-----------------------------------------------|
285
- | (default) | Only changed files (fast, for iterative work) |
286
- | `--ignore-git` | All files (cache still applies) |
287
- | `--clear-cache` | Changed files, but ignore cache |
288
- | `--ignore-git --clear-cache` | Complete fresh run of all files |
289
-
290
- ---
291
-
292
- # JS/TS Quality Tools
293
-
294
- ## Detection
295
-
296
- Check `package.json` for available tools:
297
-
298
- | Indicator | Tool |
299
- |---------------------------------------|---------------------------------------------------------------|
300
- | `@biomejs/biome` in devDependencies | **Biome** — linting + formatting |
301
- | `typescript` in devDependencies | **TypeScript** — type checking |
302
- | `jest` or `vitest` in devDependencies | **Test runner** |
303
- | `eslint` in devDependencies | **ESLint** — legacy linting (check if Biome replaces it) |
304
- | `prettier` in devDependencies | **Prettier** — legacy formatting (check if Biome replaces it) |
305
-
306
- ## Biome — Linting + Formatting
307
-
308
- Biome replaces ESLint + Prettier in one tool.
309
-
310
- ### Config
311
-
312
- - Config file: `biome.json` or `biome.jsonc`
313
- - Includes formatter settings (indent style, line width, trailing commas)
314
- - Includes linter rules (recommended + custom overrides)
315
- - Includes import sorting (via `assist.actions.source.organizeImports`)
316
-
317
- ### Commands
318
-
319
- ```bash
320
- # Check (dry-run) — shows errors without fixing
321
- npx biome check .
322
-
323
- # Fix — auto-fix all fixable issues (formatting + linting + imports)
324
- npx biome check --write .
325
-
326
- # Format only
327
- npx biome format --write .
328
-
329
- # Lint only
330
- npx biome lint .
331
- ```
332
-
333
- ### Via npm scripts (preferred)
334
-
335
- Check `package.json` scripts — projects typically define:
336
-
337
- ```bash
338
- npm run biome # Check (dry-run)
339
- npm run biome:fix # Auto-fix
340
- ```
341
-
342
- Always prefer npm scripts over raw `npx` commands when they exist.
343
-
344
- ## TypeScript — Type Checking
345
-
346
- ### Commands
347
-
348
- ```bash
349
- # Type check without emitting files
350
- npx tsc --noEmit
351
-
352
- # Via npm script (preferred)
353
- npm run tscheck
354
- ```
355
-
356
- ### Config
357
-
358
- - Config file: `tsconfig.json` (may have `tsconfig.app.json`, `tsconfig.node.json` for different targets)
359
- - `strict: true` should be enabled in all projects
360
- - Check `compilerOptions.paths` for import aliases
361
-
362
- ## Jest / Vitest — Testing
363
-
364
- ### Commands
365
-
366
- ```bash
367
- # Run all tests
368
- npm test
369
-
370
- # Run specific test file
371
- npx jest path/to/test.spec.ts
372
-
373
- # Run with coverage
374
- npx jest --coverage
375
-
376
- # Watch mode
377
- npx jest --watch
378
- ```
379
-
380
- ## JS/TS Quality Workflow
381
-
382
- After JS/TS code changes, run this sequence:
383
-
384
- ```
385
- 1. npx biome check --write . → Auto-fix formatting + linting
386
- 2. npx tsc --noEmit → Verify type safety
387
- 3. npm test → Run test suite
388
- ```
389
-
390
- Or via npm scripts:
391
-
392
- ```
393
- 1. npm run biome:fix → Auto-fix
394
- 2. npm run tscheck → Type check
395
- 3. npm test → Tests
396
- ```
397
-
398
- If step 2 finds type errors → fix them in code, then re-run step 1 (Biome may reformat).
399
-
400
108
  ## Execution environment
401
109
 
402
110
  ### PHP tools