@event4u/agent-config 1.16.0 → 1.17.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/.agent-src/commands/{agents-audit.md → agents/audit.md} +4 -3
  2. package/.agent-src/commands/{agents-cleanup.md → agents/cleanup.md} +12 -6
  3. package/.agent-src/commands/{agents-prepare.md → agents/prepare.md} +4 -3
  4. package/.agent-src/commands/agents.md +46 -0
  5. package/.agent-src/commands/{chat-history-checkpoint.md → chat-history/checkpoint.md} +4 -4
  6. package/.agent-src/commands/{chat-history-clear.md → chat-history/clear.md} +4 -4
  7. package/.agent-src/commands/{chat-history-resume.md → chat-history/resume.md} +4 -4
  8. package/.agent-src/commands/chat-history/show.md +107 -0
  9. package/.agent-src/commands/chat-history.md +33 -89
  10. package/.agent-src/commands/{commit-in-chunks.md → commit/in-chunks.md} +15 -13
  11. package/.agent-src/commands/commit.md +22 -2
  12. package/.agent-src/commands/{context-create.md → context/create.md} +4 -3
  13. package/.agent-src/commands/{context-refactor.md → context/refactor.md} +4 -3
  14. package/.agent-src/commands/context.md +44 -0
  15. package/.agent-src/commands/{copilot-agents-init.md → copilot-agents/init.md} +4 -3
  16. package/.agent-src/commands/{copilot-agents-optimize.md → copilot-agents/optimize.md} +4 -3
  17. package/.agent-src/commands/copilot-agents.md +44 -0
  18. package/.agent-src/commands/council/default.md +221 -0
  19. package/.agent-src/commands/{council-design.md → council/design.md} +6 -5
  20. package/.agent-src/commands/{council-optimize.md → council/optimize.md} +7 -6
  21. package/.agent-src/commands/{council-pr.md → council/pr.md} +6 -5
  22. package/.agent-src/commands/council.md +47 -212
  23. package/.agent-src/commands/{create-pr-description.md → create-pr/description-only.md} +4 -2
  24. package/.agent-src/commands/create-pr.md +26 -5
  25. package/.agent-src/commands/{feature-dev.md → feature/dev.md} +5 -10
  26. package/.agent-src/commands/{feature-explore.md → feature/explore.md} +4 -8
  27. package/.agent-src/commands/{feature-plan.md → feature/plan.md} +4 -8
  28. package/.agent-src/commands/{feature-refactor.md → feature/refactor.md} +4 -8
  29. package/.agent-src/commands/{feature-roadmap.md → feature/roadmap.md} +6 -10
  30. package/.agent-src/commands/feature.md +6 -12
  31. package/.agent-src/commands/{fix-ci.md → fix/ci.md} +4 -8
  32. package/.agent-src/commands/{fix-portability.md → fix/portability.md} +4 -8
  33. package/.agent-src/commands/{fix-pr-bot-comments.md → fix/pr-bots.md} +4 -8
  34. package/.agent-src/commands/{fix-pr-developer-comments.md → fix/pr-developers.md} +4 -8
  35. package/.agent-src/commands/{fix-pr-comments.md → fix/pr.md} +7 -11
  36. package/.agent-src/commands/{fix-references.md → fix/refs.md} +4 -8
  37. package/.agent-src/commands/{fix-seeder.md → fix/seeder.md} +4 -8
  38. package/.agent-src/commands/fix.md +7 -13
  39. package/.agent-src/commands/{do-and-judge.md → judge/on-diff.md} +4 -3
  40. package/.agent-src/commands/judge/solo.md +90 -0
  41. package/.agent-src/commands/{do-in-steps.md → judge/steps.md} +4 -3
  42. package/.agent-src/commands/judge.md +35 -70
  43. package/.agent-src/commands/{memory-add.md → memory/add.md} +4 -3
  44. package/.agent-src/commands/{memory-full.md → memory/load.md} +4 -3
  45. package/.agent-src/commands/{memory-promote.md → memory/promote.md} +4 -3
  46. package/.agent-src/commands/{propose-memory.md → memory/propose.md} +4 -3
  47. package/.agent-src/commands/memory.md +48 -0
  48. package/.agent-src/commands/{module-create.md → module/create.md} +4 -3
  49. package/.agent-src/commands/{module-explore.md → module/explore.md} +4 -3
  50. package/.agent-src/commands/module.md +44 -0
  51. package/.agent-src/commands/{optimize-agents.md → optimize/agents.md} +4 -8
  52. package/.agent-src/commands/{optimize-augmentignore.md → optimize/augmentignore.md} +4 -9
  53. package/.agent-src/commands/{optimize-rtk-filters.md → optimize/rtk.md} +4 -8
  54. package/.agent-src/commands/{optimize-skills.md → optimize/skills.md} +4 -8
  55. package/.agent-src/commands/optimize.md +4 -10
  56. package/.agent-src/commands/{override-create.md → override/create.md} +4 -3
  57. package/.agent-src/commands/{override-manage.md → override/manage.md} +4 -3
  58. package/.agent-src/commands/override.md +44 -0
  59. package/.agent-src/commands/{roadmap-create.md → roadmap/create.md} +4 -3
  60. package/.agent-src/commands/{roadmap-execute.md → roadmap/execute.md} +4 -3
  61. package/.agent-src/commands/roadmap.md +44 -0
  62. package/.agent-src/commands/{tests-create.md → tests/create.md} +4 -3
  63. package/.agent-src/commands/{tests-execute.md → tests/execute.md} +4 -3
  64. package/.agent-src/commands/tests.md +44 -0
  65. package/.agent-src/contexts/communication/rules-auto/artifact-engagement-recording-mechanics.md +72 -0
  66. package/.agent-src/contexts/communication/rules-auto/augment-portability-mechanics.md +79 -0
  67. package/.agent-src/contexts/communication/rules-auto/augment-source-of-truth-mechanics.md +98 -0
  68. package/.agent-src/contexts/communication/rules-auto/cli-output-handling-mechanics.md +87 -0
  69. package/.agent-src/contexts/communication/rules-auto/command-suggestion-policy-mechanics.md +62 -0
  70. package/.agent-src/contexts/communication/rules-auto/docs-sync-mechanics.md +78 -0
  71. package/.agent-src/contexts/communication/rules-auto/package-ci-checks-mechanics.md +85 -0
  72. package/.agent-src/contexts/communication/rules-auto/review-routing-awareness-mechanics.md +65 -0
  73. package/.agent-src/contexts/communication/rules-auto/roadmap-progress-sync-mechanics.md +78 -0
  74. package/.agent-src/contexts/communication/rules-auto/skill-quality-mechanics.md +62 -0
  75. package/.agent-src/contexts/communication/rules-auto/slash-command-routing-policy-mechanics.md +55 -0
  76. package/.agent-src/contexts/communication/rules-auto/ui-audit-gate-mechanics.md +53 -0
  77. package/.agent-src/contexts/communication/rules-auto/user-interaction-mechanics.md +77 -0
  78. package/.agent-src/contexts/judges/no-consolidate-rationale.md +102 -0
  79. package/.agent-src/contexts/judges/persona-voice-rubric.md +140 -0
  80. package/.agent-src/rules/artifact-engagement-recording.md +13 -69
  81. package/.agent-src/rules/ask-when-uncertain.md +27 -42
  82. package/.agent-src/rules/augment-portability.md +15 -61
  83. package/.agent-src/rules/augment-source-of-truth.md +27 -93
  84. package/.agent-src/rules/cli-output-handling.md +10 -76
  85. package/.agent-src/rules/command-suggestion-policy.md +18 -59
  86. package/.agent-src/rules/commit-conventions.md +17 -14
  87. package/.agent-src/rules/direct-answers.md +34 -49
  88. package/.agent-src/rules/docker-commands.md +5 -5
  89. package/.agent-src/rules/docs-sync.md +15 -69
  90. package/.agent-src/rules/language-and-tone.md +48 -72
  91. package/.agent-src/rules/missing-tool-handling.md +28 -22
  92. package/.agent-src/rules/no-cheap-questions.md +45 -52
  93. package/.agent-src/rules/no-roadmap-references.md +73 -0
  94. package/.agent-src/rules/package-ci-checks.md +21 -61
  95. package/.agent-src/rules/preservation-guard.md +64 -29
  96. package/.agent-src/rules/review-routing-awareness.md +24 -43
  97. package/.agent-src/rules/roadmap-progress-sync.md +10 -71
  98. package/.agent-src/rules/security-sensitive-stop.md +8 -8
  99. package/.agent-src/rules/skill-quality.md +16 -48
  100. package/.agent-src/rules/slash-command-routing-policy.md +7 -4
  101. package/.agent-src/rules/think-before-action.md +52 -42
  102. package/.agent-src/rules/tool-safety.md +19 -16
  103. package/.agent-src/rules/ui-audit-gate.md +24 -38
  104. package/.agent-src/rules/user-interaction.md +13 -68
  105. package/.agent-src/skills/ai-council/SKILL.md +2 -0
  106. package/.agent-src/skills/api-testing/SKILL.md +1 -1
  107. package/.agent-src/skills/check-refs/SKILL.md +59 -40
  108. package/.agent-src/skills/conventional-commits-writing/SKILL.md +86 -28
  109. package/.agent-src/skills/copilot-agents-optimization/SKILL.md +5 -5
  110. package/.agent-src/skills/developer-like-execution/SKILL.md +4 -4
  111. package/.agent-src/skills/finishing-a-development-branch/SKILL.md +101 -65
  112. package/.agent-src/skills/flux/SKILL.md +30 -10
  113. package/.agent-src/skills/github-ci/SKILL.md +2 -2
  114. package/.agent-src/skills/judge-code-quality/SKILL.md +7 -8
  115. package/.agent-src/skills/judge-security-auditor/SKILL.md +4 -5
  116. package/.agent-src/skills/judge-test-coverage/SKILL.md +3 -4
  117. package/.agent-src/skills/lint-skills/SKILL.md +57 -39
  118. package/.agent-src/skills/md-language-check/SKILL.md +61 -39
  119. package/.agent-src/skills/override-management/SKILL.md +5 -5
  120. package/.agent-src/skills/quality-tools/SKILL.md +2 -2
  121. package/.agent-src/skills/react-shadcn-ui/SKILL.md +116 -43
  122. package/.agent-src/skills/readme-reviewer/SKILL.md +30 -29
  123. package/.agent-src/skills/readme-writing/SKILL.md +78 -53
  124. package/.agent-src/skills/readme-writing-package/SKILL.md +50 -47
  125. package/.agent-src/skills/receiving-code-review/SKILL.md +52 -47
  126. package/.agent-src/skills/refine-prompt/SKILL.md +0 -1
  127. package/.agent-src/skills/requesting-code-review/SKILL.md +35 -30
  128. package/.agent-src/skills/security/SKILL.md +7 -2
  129. package/.agent-src/skills/security-audit/SKILL.md +7 -3
  130. package/.agent-src/skills/systematic-debugging/SKILL.md +68 -60
  131. package/.agent-src/skills/test-driven-development/SKILL.md +59 -57
  132. package/.agent-src/skills/test-performance/SKILL.md +0 -1
  133. package/.agent-src/skills/traefik/SKILL.md +4 -4
  134. package/.agent-src/skills/verify-completion-evidence/SKILL.md +28 -26
  135. package/.claude-plugin/marketplace.json +22 -11
  136. package/AGENTS.md +2 -2
  137. package/CHANGELOG.md +90 -1
  138. package/README.md +18 -17
  139. package/docs/architecture.md +4 -6
  140. package/docs/catalog.md +67 -39
  141. package/docs/contracts/STABILITY.md +13 -7
  142. package/docs/contracts/adr-chat-history-split.md +1 -3
  143. package/docs/contracts/adr-command-suggestion.md +0 -2
  144. package/docs/contracts/adr-implement-ticket-runtime.md +1 -2
  145. package/docs/contracts/adr-product-ui-track.md +3 -6
  146. package/docs/contracts/adr-prompt-driven-execution.md +3 -4
  147. package/docs/contracts/agent-memory-contract.md +6 -11
  148. package/docs/contracts/artifact-engagement-flow.md +6 -9
  149. package/docs/contracts/command-clusters.md +56 -46
  150. package/docs/contracts/command-suggestion-flow.md +1 -3
  151. package/docs/contracts/context-paths.md +99 -0
  152. package/docs/contracts/file-ownership-matrix.json +6722 -0
  153. package/docs/contracts/file-ownership-matrix.md +134 -0
  154. package/docs/contracts/implement-ticket-flow.md +6 -9
  155. package/docs/contracts/linear-ai-rules-inclusion.md +0 -1
  156. package/docs/contracts/linear-ai-three-layers.md +0 -2
  157. package/docs/contracts/load-context-budget-model.md +178 -0
  158. package/docs/contracts/load-context-schema.md +1 -3
  159. package/docs/contracts/rule-interactions.md +0 -1
  160. package/docs/contracts/rule-priority-hierarchy.md +1 -1
  161. package/docs/contracts/ui-track-flow.md +7 -17
  162. package/docs/customization.md +2 -0
  163. package/docs/getting-started.md +5 -4
  164. package/docs/guidelines/agent-infra/asking-and-brevity-examples.md +100 -0
  165. package/package.json +1 -1
  166. package/scripts/_one_off_phase4_dispatch_latency.py +108 -0
  167. package/scripts/_one_off_phase6_trigger_jaccard.py +92 -0
  168. package/scripts/_phase2_shim_helper.py +109 -0
  169. package/scripts/agent-config +10 -0
  170. package/scripts/ai_council/_one_off_2a4_acceptance.py +208 -0
  171. package/scripts/ai_council/_one_off_context_layer_v1_estimate.py +67 -0
  172. package/scripts/ai_council/_one_off_context_layer_v1_review.py +292 -0
  173. package/scripts/ai_council/_one_off_followups_review.py +259 -0
  174. package/scripts/ai_council/_one_off_nondestructive_inline_audit.py +209 -0
  175. package/scripts/ai_council/_one_off_phase_2a_budget_rebalance.py +257 -0
  176. package/scripts/ai_council/_one_off_phase_2a_post_revert.py +197 -0
  177. package/scripts/ai_council/_one_off_rule_hardening_v1.py +251 -0
  178. package/scripts/ai_council/_one_off_structural_open_questions.py +232 -0
  179. package/scripts/ai_council/_one_off_structural_optimization.py +144 -0
  180. package/scripts/ai_council/_one_off_structural_v3_gaps.py +252 -0
  181. package/scripts/ai_council/_one_off_structural_v3_review.py +240 -0
  182. package/scripts/check_always_budget.py +363 -45
  183. package/scripts/check_cluster_patterns.py +159 -0
  184. package/scripts/check_command_count_messaging.py +14 -7
  185. package/scripts/check_context_paths.py +201 -0
  186. package/scripts/check_no_roadmap_refs.py +155 -0
  187. package/scripts/check_phase_coupling.py +148 -0
  188. package/scripts/check_portability.py +2 -0
  189. package/scripts/check_references.py +29 -2
  190. package/scripts/check_safety_floor_untouched.py +125 -0
  191. package/scripts/command_suggester/loader.py +4 -1
  192. package/scripts/compress.py +59 -13
  193. package/scripts/generate_index.py +6 -2
  194. package/scripts/generate_ownership_matrix.py +323 -0
  195. package/scripts/hooks/augment-roadmap-progress.sh +57 -0
  196. package/scripts/install.py +49 -28
  197. package/scripts/lint_no_new_atomic_commands.py +12 -11
  198. package/scripts/requirements-evals.txt +1 -0
  199. package/scripts/roadmap_progress_hook.py +159 -0
  200. package/scripts/schemas/command.schema.json +4 -3
  201. package/scripts/skill_linter.py +1 -0
  202. package/scripts/sync_agent_settings.py +25 -2
  203. package/scripts/update_counts.py +7 -0
@@ -0,0 +1,209 @@
1
+ """Council inline-content audit for `non-destructive-by-default` (Phase 1.1.3).
2
+
3
+ Roadmap `road-to-1-16-followups` Phase 1.1.3 requires a council audit
4
+ before merging the `load_context:` rollout for the safety-floor rule.
5
+ Both reviewers must return PASS confirming that:
6
+
7
+ - The Hard-Floor trigger table stays inline.
8
+ - The Iron Law caps block stays inline.
9
+ - The Cloud Behavior section stays inline.
10
+ - No obligation moved to `destructive-mechanics.md` that should
11
+ have stayed in the rule.
12
+
13
+ This audit is post-rollout (the rollout already shipped via Phase 7.4
14
+ of `road-to-structural-optimization`); it certifies the *current* state
15
+ of `main` against the Phase 1.1.3 contract.
16
+
17
+ Invocation:
18
+ .venv/bin/python -m scripts.ai_council._one_off_nondestructive_inline_audit
19
+ """
20
+ from __future__ import annotations
21
+
22
+ import sys
23
+ from pathlib import Path
24
+
25
+ from scripts.ai_council.bundler import bundle_files
26
+ from scripts.ai_council.clients import (
27
+ AnthropicClient,
28
+ OpenAIClient,
29
+ load_anthropic_key,
30
+ load_openai_key,
31
+ )
32
+ from scripts.ai_council.orchestrator import (
33
+ CostBudget,
34
+ CouncilQuestion,
35
+ consult,
36
+ estimate,
37
+ )
38
+ from scripts.ai_council.pricing import estimate_cost, load_prices
39
+ from scripts.ai_council.project_context import detect_project_context
40
+ from scripts.ai_council.session import SessionManifest, save as save_session
41
+
42
+ REPO_ROOT = Path(__file__).resolve().parents[2]
43
+ ARTEFACTS = [
44
+ REPO_ROOT / ".agent-src.uncompressed/rules/non-destructive-by-default.md",
45
+ REPO_ROOT / ".agent-src.uncompressed/contexts/authority/destructive-mechanics.md",
46
+ ]
47
+
48
+ ORIGINAL_ASK = (
49
+ "Phase 1.1.3 of road-to-1-16-followups requires a council audit on "
50
+ "the `non-destructive-by-default` rule after `load_context:` rollout. "
51
+ "Verify that Hard-Floor table, Iron Law caps block, and Cloud Behavior "
52
+ "section are still inline; flag any obligation that moved to context "
53
+ "and should not have."
54
+ )
55
+
56
+ REVIEW_PROMPT = """\
57
+ # Council Inline-Content Audit — non-destructive-by-default
58
+
59
+ ## Context
60
+
61
+ The host agent rolled out `load_context:` to the `non-destructive-by-default` \
62
+ rule (universal safety floor). Failure-mode catalog and Bulk-deletions-WIP \
63
+ allowed/forbidden lists moved to `destructive-mechanics.md`. The roadmap \
64
+ contract requires that the load-bearing inline obligations stay in the rule.
65
+
66
+ You are auditing the **current state** of two files (rule + mechanics) to \
67
+ certify the rollout. This is not a re-design review.
68
+
69
+ ## Required-inline checklist
70
+
71
+ 1. **Hard-Floor trigger table** — six rows: production-branch merge, \
72
+ deploy/release, push to remote, production data/infra, whimsical or \
73
+ unscoped bulk deletion, commit containing bulk deletions or infra changes.
74
+ 2. **Iron Law caps block** — three lines starting with \
75
+ `HARD FLOOR OVERRIDES EVERYTHING.`
76
+ 3. **Cloud Behavior section** — two-sentence statement that the floor applies \
77
+ on Claude.ai Web, Skills API, and any cloud agent, with no cloud override.
78
+ 4. **"Triggers require explicit user confirmation on this turn" clause** — \
79
+ the not-from-previous-turn, not-from-roadmap, not-from-standing-autonomy \
80
+ anchor.
81
+
82
+ ## Output Contract (STRICT)
83
+
84
+ Produce exactly these blocks in order. Total response budget <= 800 words.
85
+
86
+ ```
87
+ ### Inline-content audit
88
+
89
+ **Hard-Floor trigger table inline:** <YES | NO — list missing rows>
90
+ **Iron Law caps block inline:** <YES | NO — quote what is there>
91
+ **Cloud Behavior section inline:** <YES | NO — quote what is there>
92
+ **On-this-turn confirmation clause inline:** <YES | NO — quote anchor>
93
+ ```
94
+
95
+ ```
96
+ ### Misplaced-content audit
97
+
98
+ **Any obligation moved to mechanics that should be inline:** <NONE | list>
99
+ **Any failure mode duplicated in both files (drift risk):** <NONE | list>
100
+ ```
101
+
102
+ ```
103
+ ### Final verdict
104
+
105
+ **Verdict:** <PASS | FAIL>
106
+ **If FAIL, single blocking issue:** <one sentence>
107
+ ```
108
+
109
+ Verdict definitions:
110
+ - **PASS** — every required-inline item is present in the rule; no obligation \
111
+ is misplaced. The rollout meets the Phase 1.1.3 contract.
112
+ - **FAIL** — at least one required-inline item is missing, weakened, or \
113
+ duplicated in a way that creates a normative drift surface.
114
+
115
+ The two artefacts follow this prompt verbatim.
116
+ """
117
+
118
+
119
+ def main() -> int:
120
+ anthropic = AnthropicClient(api_key=load_anthropic_key(), model="claude-sonnet-4-5")
121
+ openai = OpenAIClient(api_key=load_openai_key(), model="gpt-4o")
122
+ members = [anthropic, openai]
123
+
124
+ context = bundle_files(ARTEFACTS)
125
+ project = detect_project_context(REPO_ROOT)
126
+ table = load_prices()
127
+
128
+ user_prompt = REVIEW_PROMPT + "\n\n---\n\n" + context.text
129
+
130
+ question = CouncilQuestion(
131
+ mode="files",
132
+ user_prompt=user_prompt,
133
+ max_tokens=2048,
134
+ )
135
+
136
+ estimates = estimate(
137
+ question, members, table, project=project, original_ask=ORIGINAL_ASK,
138
+ )
139
+ print("=== ESTIMATE (single round, max tokens) ===")
140
+ total_est = 0.0
141
+ for c, e in zip(members, estimates):
142
+ print(f" {c.name}/{c.model}: ~{e.input_tokens} in + {e.output_tokens} out = ${e.total_usd:.4f}")
143
+ total_est += e.total_usd
144
+ print(f" TOTAL per round (max): ${total_est:.4f}")
145
+ print()
146
+
147
+ budget = CostBudget(
148
+ max_input_tokens=200_000,
149
+ max_output_tokens=80_000,
150
+ max_calls=20,
151
+ max_total_usd=2.50,
152
+ )
153
+
154
+ rounds_collected: list[list] = []
155
+
156
+ def _on_round_complete(round_idx: int, round_responses) -> None:
157
+ rounds_collected.append(list(round_responses))
158
+ print(f"=== ROUND {round_idx + 1} COMPLETE ===")
159
+ for r in round_responses:
160
+ if r.error:
161
+ print(f" [error] {r.provider}/{r.model}: {r.error}")
162
+ continue
163
+ actual = estimate_cost(r.provider, r.model, r.input_tokens, r.output_tokens, table)
164
+ print(f" [done] {r.provider}/{r.model}: {r.input_tokens} in / "
165
+ f"{r.output_tokens} out · {r.latency_ms} ms · ${actual.total_usd:.4f}")
166
+ print()
167
+
168
+ print("=== CONSULT (1 round, Phase 1.1.3 inline-content audit) ===")
169
+ consult(
170
+ members, question, budget,
171
+ rounds=1,
172
+ on_round_complete=_on_round_complete,
173
+ table=table, project=project, original_ask=ORIGINAL_ASK,
174
+ )
175
+
176
+ if not rounds_collected:
177
+ print("[error] no rounds completed", file=sys.stderr)
178
+ return 1
179
+
180
+ actual_total = 0.0
181
+ for round_responses in rounds_collected:
182
+ for r in round_responses:
183
+ if r.error:
184
+ continue
185
+ actual = estimate_cost(r.provider, r.model, r.input_tokens, r.output_tokens, table)
186
+ actual_total += actual.total_usd
187
+ print(f"=== TOTAL ACTUAL: ${actual_total:.4f} ===")
188
+
189
+ final_round = rounds_collected[-1]
190
+ if not [r for r in final_round if not r.error]:
191
+ return 1
192
+
193
+ manifest = SessionManifest(
194
+ mode="files",
195
+ artefact=".agent-src.uncompressed/rules/non-destructive-by-default.md",
196
+ original_ask=ORIGINAL_ASK,
197
+ members=[f"{r.provider}/{r.model}" for r in final_round],
198
+ rounds=len(rounds_collected),
199
+ cost_usd_estimated=total_est,
200
+ cost_usd_actual=actual_total,
201
+ extra={"purpose": "Phase 1.1.3 inline-content audit on non-destructive-by-default"},
202
+ )
203
+ session_dir = save_session(manifest=manifest, responses=rounds_collected)
204
+ print(f"[saved] {session_dir.relative_to(REPO_ROOT)}/")
205
+ return 1 if any(r.error for round_r in rounds_collected for r in round_r) else 0
206
+
207
+
208
+ if __name__ == "__main__":
209
+ raise SystemExit(main())
@@ -0,0 +1,257 @@
1
+ """Council adjudication of Phase 2A always-budget overshoot.
2
+
3
+ Phase 2A of road-to-structural-optimization slimmed the top-3
4
+ budget-consuming `type: always` rules (language-and-tone,
5
+ ask-when-uncertain, direct-answers) by extracting MECHANICS into
6
+ contexts under contexts/communication/rules-always/. Under the
7
+ locked Model (b) literal, the extended budget grew from 47,448 to
8
+ 52,534 chars (49,000 cap → 107.2 %), 5.2 pp above the 2 % G3
9
+ tolerance band defined in
10
+ docs/contracts/load-context-budget-model.md.
11
+
12
+ Per that contract: an overshoot above the band rejects the model
13
+ and escalates to council. Phase 2A § Abort/rollback fires its
14
+ budget kill-switch in this exact case.
15
+
16
+ This one-off bundles the linter output, the three slimmed rules,
17
+ the three new mechanics contexts, and the locked budget contract,
18
+ and asks the council to pick the smallest viable resolution.
19
+
20
+ Invocation:
21
+ .venv/bin/python -m scripts.ai_council._one_off_phase_2a_budget_rebalance
22
+ """
23
+ from __future__ import annotations
24
+
25
+ import sys
26
+ from pathlib import Path
27
+
28
+ from scripts.ai_council.bundler import bundle_files
29
+ from scripts.ai_council.clients import (
30
+ AnthropicClient,
31
+ OpenAIClient,
32
+ load_anthropic_key,
33
+ load_openai_key,
34
+ )
35
+ from scripts.ai_council.orchestrator import (
36
+ CostBudget,
37
+ CouncilQuestion,
38
+ consult,
39
+ estimate,
40
+ )
41
+ from scripts.ai_council.pricing import estimate_cost, load_prices
42
+ from scripts.ai_council.project_context import detect_project_context
43
+ from scripts.ai_council.session import SessionManifest, save as save_session
44
+
45
+ REPO_ROOT = Path(__file__).resolve().parents[2]
46
+ ARTEFACTS = [
47
+ REPO_ROOT / "docs/contracts/load-context-budget-model.md",
48
+ REPO_ROOT / ".agent-src.uncompressed/rules/language-and-tone.md",
49
+ REPO_ROOT / ".agent-src.uncompressed/rules/ask-when-uncertain.md",
50
+ REPO_ROOT / ".agent-src.uncompressed/rules/direct-answers.md",
51
+ REPO_ROOT / ".agent-src.uncompressed/contexts/communication/rules-always/language-and-tone-mechanics.md",
52
+ REPO_ROOT / ".agent-src.uncompressed/contexts/communication/rules-always/ask-when-uncertain-mechanics.md",
53
+ REPO_ROOT / ".agent-src.uncompressed/contexts/communication/rules-always/direct-answers-mechanics.md",
54
+ ]
55
+
56
+ ORIGINAL_ASK = (
57
+ "Phase 2A of road-to-structural-optimization slimmed the top-3 "
58
+ "always-rules and breached the 2 % G3 tolerance band on the "
59
+ "always-budget under Model (b) literal. The contract requires "
60
+ "council escalation. Council task: pick the smallest viable "
61
+ "resolution from a fixed option set."
62
+ )
63
+
64
+ REVIEW_PROMPT = """\
65
+ # Council Adjudication — Phase 2A Always-Budget Overshoot
66
+
67
+ ## Measured state (linter output, model (b) literal)
68
+
69
+ ```
70
+ FAIL always-rule extended budget: 52,534 / 49,000 chars (107.2%)
71
+ thresholds: warn 80% · fail 90% · per-rule ≤ 6,000 (ext) ·
72
+ top-3 ≤ 24,500 (ext) · depth ≤ 2 · G3 band ≤ +2%
73
+
74
+ ext= 8529 raw= 4636 scope-control.md (top-3) allowlisted ≤ 8,529
75
+ ext= 7887 raw= 4607 non-destructive-by-default.md (top-3) allowlisted ≤ 7,887
76
+ ext= 6827 raw= 2424 ask-when-uncertain.md (top-3) PER-RULE BREACH
77
+ ext= 6283 raw= 2758 direct-answers.md PER-RULE BREACH
78
+ ext= 5863 raw= 3658 language-and-tone.md
79
+ ext= 5781 raw= 3309 commit-policy.md
80
+ ext= 5481 raw= 2196 verify-before-complete.md
81
+ ext= 4415 raw= 4415 no-cheap-questions.md
82
+ ext= 1468 raw= 1468 agent-authority.md
83
+ ```
84
+
85
+ Pre-Phase-2A baseline (Phase 0.2.3 retroactive test, locked):
86
+ **47,448 / 49,000 = 96.8 %** (within tolerance, model (b) accepted).
87
+
88
+ Phase-2A delta per slimmed rule (raw rule shrank, mechanics
89
+ context loaded as new dependency):
90
+
91
+ | Rule | ext before | ext after | delta |
92
+ |---|---:|---:|---:|
93
+ | language-and-tone | 5,832 | 5,863 | +31 |
94
+ | ask-when-uncertain | 5,196 | 6,827 | +1,631 |
95
+ | direct-answers | 4,722 | 6,283 | +1,561 |
96
+
97
+ Phase 0.4 worked example council-locked the +1,561 delta on
98
+ direct-answers. ask-when-uncertain (+1,631) is structurally
99
+ identical. The total overshoot is **+3,534 chars over cap**.
100
+
101
+ ## Why the literal model can no longer hit budget
102
+
103
+ Under model (b) literal each rule pays full cost for every context
104
+ it loads. Each mechanics extraction adds ~1.5–2 KB of frontmatter +
105
+ headers + context-introduction overhead per rule. Phase 2A is
106
+ structurally unable to satisfy the roadmap success criterion
107
+ ("budget delta ≥ −5 %") under model (b); extraction *always* adds
108
+ overhead unless mechanics are consolidated and shared across rules.
109
+
110
+ ## Fixed option set (pick exactly one)
111
+
112
+ - **R1 — Switch to Model (c) shared-divisor.** Reserved by the
113
+ contract as "first refinement step if the 2 % tolerance band is
114
+ exceeded". Under (c), `Σ RawSize(c) / N_loaders`. Currently each
115
+ mechanics file has N=1, so (c) reduces to (b). Buy-in for (c)
116
+ enables R5 below.
117
+ - **R2 — Raise TOTAL_CAP.** Set cap to 56,000 chars (current
118
+ utilization 93.8 % under new cap). Acknowledges extraction
119
+ overhead is real; freezes Phase 2A wins; abandons the −5 %
120
+ delta success criterion.
121
+ - **R3 — Raise PER_RULE_CAP to 7,000 + add allowlist entries +
122
+ raise TOTAL_CAP to 54,000.** Minimal-change variant: keeps the
123
+ shape, accepts the two new per-rule breaches, raises cap
124
+ modestly.
125
+ - **R4 — Revert Phase 2A.** Abandon mechanics extraction on the
126
+ three rules; restore them to original size; mark Phase 2A as
127
+ "structurally infeasible under locked contract"; close roadmap
128
+ phase.
129
+ - **R5 — Consolidate the three mechanics into one shared context
130
+ + adopt R1.** Single `rules-always-mechanics.md` loaded by all
131
+ three slimmed rules; under (c) each rule pays 1/3 of the
132
+ consolidated context size. Highest engineering cost, only path
133
+ that delivers a net negative delta.
134
+
135
+ ## Output Contract (STRICT)
136
+
137
+ ```
138
+ ### Verdict
139
+ **Choice:** <R1 | R2 | R3 | R4 | R5>
140
+ **One-sentence rationale:** <≤ 30 words>
141
+ ```
142
+
143
+ ```
144
+ ### Required follow-up actions (numbered, ≤ 4)
145
+ 1. <smallest concrete step, files named>
146
+ 2. <...>
147
+ ```
148
+
149
+ ```
150
+ ### Risk note
151
+ **Single biggest risk of the chosen option:** <one sentence>
152
+ **Mitigation:** <one sentence>
153
+ ```
154
+
155
+ ```
156
+ ### Contract amendment needed?
157
+ **Amend load-context-budget-model.md?** <YES — section · NO>
158
+ **Amend road-to-structural-optimization Phase 2A success criterion?**
159
+ <YES — new criterion in 1 line · NO>
160
+ ```
161
+
162
+ Be decisive — total response ≤ 1,000 words. Artefacts follow
163
+ verbatim.
164
+ """
165
+
166
+
167
+ def main() -> int:
168
+ anthropic = AnthropicClient(api_key=load_anthropic_key(), model="claude-sonnet-4-5")
169
+ openai = OpenAIClient(api_key=load_openai_key(), model="gpt-4o")
170
+ members = [anthropic, openai]
171
+
172
+ context = bundle_files(ARTEFACTS)
173
+ project = detect_project_context(REPO_ROOT)
174
+ table = load_prices()
175
+
176
+ user_prompt = REVIEW_PROMPT + "\n\n---\n\n" + context.text
177
+
178
+ question = CouncilQuestion(
179
+ mode="files",
180
+ user_prompt=user_prompt,
181
+ max_tokens=2560,
182
+ )
183
+
184
+ estimates = estimate(
185
+ question, members, table, project=project, original_ask=ORIGINAL_ASK,
186
+ )
187
+ print("=== ESTIMATE (single round) ===")
188
+ total_est = 0.0
189
+ for c, e in zip(members, estimates):
190
+ print(f" {c.name}/{c.model}: ~{e.input_tokens} in + {e.output_tokens} out = ${e.total_usd:.4f}")
191
+ total_est += e.total_usd
192
+ print(f" TOTAL per round (max): ${total_est:.4f}")
193
+ print()
194
+
195
+ budget = CostBudget(
196
+ max_input_tokens=200_000,
197
+ max_output_tokens=80_000,
198
+ max_calls=20,
199
+ max_total_usd=2.50,
200
+ )
201
+
202
+ rounds_collected: list[list] = []
203
+
204
+ def _on_round_complete(round_idx: int, round_responses) -> None:
205
+ rounds_collected.append(list(round_responses))
206
+ print(f"=== ROUND {round_idx + 1} COMPLETE ===")
207
+ for r in round_responses:
208
+ if r.error:
209
+ print(f" [error] {r.provider}/{r.model}: {r.error}")
210
+ continue
211
+ actual = estimate_cost(r.provider, r.model, r.input_tokens, r.output_tokens, table)
212
+ print(f" [done] {r.provider}/{r.model}: {r.input_tokens} in / "
213
+ f"{r.output_tokens} out · {r.latency_ms} ms · ${actual.total_usd:.4f}")
214
+ print()
215
+
216
+ print("=== CONSULT (1 round, Phase 2A budget rebalance) ===")
217
+ consult(
218
+ members, question, budget,
219
+ rounds=1,
220
+ on_round_complete=_on_round_complete,
221
+ table=table, project=project, original_ask=ORIGINAL_ASK,
222
+ )
223
+
224
+ if not rounds_collected:
225
+ print("[error] no rounds completed", file=sys.stderr)
226
+ return 1
227
+
228
+ actual_total = 0.0
229
+ for round_responses in rounds_collected:
230
+ for r in round_responses:
231
+ if r.error:
232
+ continue
233
+ actual = estimate_cost(r.provider, r.model, r.input_tokens, r.output_tokens, table)
234
+ actual_total += actual.total_usd
235
+ print(f"=== TOTAL ACTUAL: ${actual_total:.4f} ===")
236
+
237
+ final_round = rounds_collected[-1]
238
+ if not [r for r in final_round if not r.error]:
239
+ return 1
240
+
241
+ manifest = SessionManifest(
242
+ mode="files",
243
+ artefact="agents/roadmaps/road-to-structural-optimization.md",
244
+ original_ask=ORIGINAL_ASK,
245
+ members=[f"{r.provider}/{r.model}" for r in final_round],
246
+ rounds=len(rounds_collected),
247
+ cost_usd_estimated=total_est,
248
+ cost_usd_actual=actual_total,
249
+ extra={"purpose": "Phase 2A always-budget overshoot adjudication"},
250
+ )
251
+ session_dir = save_session(manifest=manifest, responses=rounds_collected)
252
+ print(f"[saved] {session_dir.relative_to(REPO_ROOT)}/")
253
+ return 1 if any(r.error for round_r in rounds_collected for r in round_r) else 0
254
+
255
+
256
+ if __name__ == "__main__":
257
+ raise SystemExit(main())
@@ -0,0 +1,197 @@
1
+ """Council adjudication of post-revert always-budget contract.
2
+
3
+ Phase 2A executed R4 (revert) per the prior council verdict. The
4
+ three slimmed always-rules and their mechanics contexts have been
5
+ restored; mechanics-context directory removed. Measured state on
6
+ this branch is now 47,448 / 49,000 chars = 96.8 % — strictly better
7
+ than `main` at 100.6 % which currently passes via the G3 tolerance
8
+ band.
9
+
10
+ The strict 90 % FAIL gate in scripts/check_always_budget.py was
11
+ written assuming Phase 2A would succeed in dropping utilization
12
+ below 90 %. Phase 2A is now structurally infeasible under model (b)
13
+ (per the previous council finding) and the cap-tightening was
14
+ deferred to Phase 5. Branch must unblock CI without regressing the
15
+ contract spirit.
16
+
17
+ Council task: pick the smallest viable reconciliation.
18
+ """
19
+ from __future__ import annotations
20
+
21
+ import sys
22
+ from pathlib import Path
23
+
24
+ from scripts.ai_council.bundler import bundle_files
25
+ from scripts.ai_council.clients import (
26
+ AnthropicClient,
27
+ OpenAIClient,
28
+ load_anthropic_key,
29
+ load_openai_key,
30
+ )
31
+ from scripts.ai_council.orchestrator import (
32
+ CostBudget,
33
+ CouncilQuestion,
34
+ consult,
35
+ estimate,
36
+ )
37
+ from scripts.ai_council.pricing import estimate_cost, load_prices
38
+ from scripts.ai_council.project_context import detect_project_context
39
+ from scripts.ai_council.session import SessionManifest, save as save_session
40
+
41
+ REPO_ROOT = Path(__file__).resolve().parents[2]
42
+ ARTEFACTS = [
43
+ REPO_ROOT / "docs/contracts/load-context-budget-model.md",
44
+ REPO_ROOT / "scripts/check_always_budget.py",
45
+ ]
46
+
47
+ ORIGINAL_ASK = (
48
+ "Phase 2A reverted (R4) per prior council verdict. Branch budget is "
49
+ "96.8 % (gap-zone FAIL); main is 100.6 % (PASS via G3 band). Branch "
50
+ "is strictly better than main yet rejected by the strict 90 % gate. "
51
+ "Pick the smallest contract reconciliation to unblock CI."
52
+ )
53
+
54
+ REVIEW_PROMPT = """\
55
+ # Council Adjudication — Post-Revert Always-Budget Reconciliation
56
+
57
+ ## Current state (after R4 revert is committed locally)
58
+
59
+ ```
60
+ FAIL always-rule extended budget: 47,448 / 49,000 chars (96.8%)
61
+ thresholds: warn 80% · fail 90% · per-rule ≤ 6,000 (ext) ·
62
+ top-3 ≤ 24,500 (ext) · depth ≤ 2 · G3 band ≤ +2%
63
+ ```
64
+
65
+ `main` (last green): **49,311 / 49,000 = 100.6 %** — passes because
66
+ the linter only rejects 90–100 % (gap zone) and > 102 %; 100–102 %
67
+ is the documented G3 tolerance band.
68
+
69
+ This branch is objectively closer to the cap than `main` but
70
+ rejected. The 90 % gate was written under the assumption Phase 2A
71
+ would land below 90 %. Phase 2A is structurally infeasible under
72
+ model (b) (prior council finding); roadmap re-routes the trim to
73
+ Phase 5 via either model (c) shared-divisor or shared-mechanics
74
+ consolidation.
75
+
76
+ ## Fixed option set (pick exactly one)
77
+
78
+ - **A1 — Recovery-band carve-out.** Extend the linter so "current
79
+ pct ≤ last-green-`main` pct AND pct ≤ 100 %" becomes a documented
80
+ `WARN (recovery band)`, not FAIL. Persists until Phase 5
81
+ re-tightens. No baseline regression possible; needs `main`-pct
82
+ lookup (committed scalar in repo or CI artifact).
83
+ - **A2 — Lower FAIL_THRESHOLD to 100 %.** Drop the 90 % gate to
84
+ match the contract's spirit ("< cap is acceptable; > cap +2 %
85
+ fails"). Phase 5 re-tightens to 85 %/95 % per its own task list.
86
+ Smallest diff. Risk: removes the early-warning gate.
87
+ - **A3 — Trim ~3.4k chars from current rules.** Find another
88
+ candidate (none of the three Phase-2A targets, since 2A proved
89
+ extraction adds overhead). Risk: the next-largest rules touch
90
+ the safety floor (Q3=A locked).
91
+ - **A4 — Bump TOTAL_CAP to 53,000 + keep 90 % FAIL.** Rewrites the
92
+ contract's total cap upward; freezes current state at ~89.5 %.
93
+ Defers Phase 5 trim to a separate roadmap. Cleanest CI but
94
+ contract drift.
95
+ - **A5 — Mark phase as `irreducible-at-current-method` and freeze
96
+ the linter at current state.** Pin a `CURRENT_BASELINE = 47_448`
97
+ ceiling alongside the 90 % gate; PASS while pct ≤ baseline,
98
+ FAIL on regression. Deflects Phase 5 work upstream into model (c).
99
+
100
+ ## Constraints
101
+
102
+ - Safety-floor rules (`non-destructive-by-default`, `commit-policy`,
103
+ `scope-control`, `verify-before-complete`) are Q3=A locked and
104
+ may not be slimmed.
105
+ - `road-to-structural-optimization` Phase 5 owns the long-term
106
+ trim — do not duplicate work into Phase 2A.
107
+ - The four other phases (1, 2B, 3, 4, 6) on this branch are
108
+ blocked by this CI gate; the choice gates roadmap throughput.
109
+
110
+ ## Output Contract (STRICT)
111
+
112
+ ```
113
+ ### Verdict
114
+ **Choice:** <A1 | A2 | A3 | A4 | A5>
115
+ **One-sentence rationale:** <≤ 30 words>
116
+ ```
117
+
118
+ ```
119
+ ### Required follow-up actions (numbered, ≤ 4)
120
+ 1. <smallest concrete step, files named>
121
+ 2. <...>
122
+ ```
123
+
124
+ ```
125
+ ### Risk note
126
+ **Single biggest risk of the chosen option:** <one sentence>
127
+ **Mitigation:** <one sentence>
128
+ ```
129
+
130
+ ```
131
+ ### Contract amendment needed?
132
+ **Amend load-context-budget-model.md?** <YES — section · NO>
133
+ **Amend road-to-structural-optimization Phase 5 success criterion?**
134
+ <YES — new criterion in 1 line · NO>
135
+ ```
136
+
137
+ Be decisive — total response ≤ 800 words. Artefacts follow verbatim.
138
+ """
139
+
140
+
141
+ def main() -> int:
142
+ anthropic = AnthropicClient(api_key=load_anthropic_key(), model="claude-sonnet-4-5")
143
+ openai = OpenAIClient(api_key=load_openai_key(), model="gpt-4o")
144
+ members = [anthropic, openai]
145
+
146
+ context = bundle_files(ARTEFACTS)
147
+ project = detect_project_context(REPO_ROOT)
148
+ table = load_prices()
149
+
150
+ user_prompt = REVIEW_PROMPT + "\n\n---\n\n" + context.text
151
+
152
+ question = CouncilQuestion(mode="files", user_prompt=user_prompt, max_tokens=2048)
153
+ estimates = estimate(question, members, table, project=project, original_ask=ORIGINAL_ASK)
154
+ print("=== ESTIMATE (single round) ===")
155
+ total_est = 0.0
156
+ for c, e in zip(members, estimates):
157
+ print(f" {c.name}/{c.model}: ~{e.input_tokens} in + {e.output_tokens} out = ${e.total_usd:.4f}")
158
+ total_est += e.total_usd
159
+ print(f" TOTAL per round (max): ${total_est:.4f}")
160
+
161
+ budget = CostBudget(max_input_tokens=200_000, max_output_tokens=80_000, max_calls=20, max_total_usd=2.50)
162
+ rounds_collected: list[list] = []
163
+
164
+ def _on_round_complete(round_idx, round_responses) -> None:
165
+ rounds_collected.append(list(round_responses))
166
+ print(f"=== ROUND {round_idx + 1} COMPLETE ===")
167
+ for r in round_responses:
168
+ if r.error:
169
+ print(f" [error] {r.provider}/{r.model}: {r.error}")
170
+ continue
171
+ a = estimate_cost(r.provider, r.model, r.input_tokens, r.output_tokens, table)
172
+ print(f" [done] {r.provider}/{r.model}: {r.input_tokens} in / {r.output_tokens} out · ${a.total_usd:.4f}")
173
+
174
+ print("=== CONSULT (1 round, post-revert reconciliation) ===")
175
+ consult(members, question, budget, rounds=1, on_round_complete=_on_round_complete,
176
+ table=table, project=project, original_ask=ORIGINAL_ASK)
177
+ if not rounds_collected:
178
+ return 1
179
+ actual = sum(estimate_cost(r.provider, r.model, r.input_tokens, r.output_tokens, table).total_usd
180
+ for rr in rounds_collected for r in rr if not r.error)
181
+ print(f"=== TOTAL ACTUAL: ${actual:.4f} ===")
182
+ final = rounds_collected[-1]
183
+ if not [r for r in final if not r.error]:
184
+ return 1
185
+ manifest = SessionManifest(
186
+ mode="files", artefact="agents/roadmaps/road-to-structural-optimization.md",
187
+ original_ask=ORIGINAL_ASK, members=[f"{r.provider}/{r.model}" for r in final],
188
+ rounds=len(rounds_collected), cost_usd_estimated=total_est, cost_usd_actual=actual,
189
+ extra={"purpose": "Post-revert always-budget contract reconciliation"},
190
+ )
191
+ sd = save_session(manifest=manifest, responses=rounds_collected)
192
+ print(f"[saved] {sd.relative_to(REPO_ROOT)}/")
193
+ return 0
194
+
195
+
196
+ if __name__ == "__main__":
197
+ raise SystemExit(main())