@event4u/agent-config 16.0.0 → 16.1.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 (246) hide show
  1. package/.augment-plugin/marketplace.json +3 -3
  2. package/.augment-plugin/plugin.json +1 -1
  3. package/.claude-plugin/marketplace.json +1 -1
  4. package/CHANGELOG.md +297 -137
  5. package/CONTRIBUTING.md +9 -0
  6. package/README.md +2 -2
  7. package/dist/agent-src/commands/analyze/inbox.md +26 -0
  8. package/dist/agent-src/commands/analyze/roadmap-repos.md +27 -0
  9. package/dist/agent-src/commands/challenge-me/closure.md +178 -0
  10. package/dist/agent-src/commands/challenge-me.md +9 -2
  11. package/dist/agent-src/commands/council/default.md +25 -5
  12. package/dist/agent-src/commands/feature/plan.md +28 -1
  13. package/dist/agent-src/commands/feature/roadmap.md +28 -1
  14. package/dist/agent-src/commands/implement-ticket.md +27 -0
  15. package/dist/agent-src/commands/jira-ticket.md +27 -0
  16. package/dist/agent-src/commands/pr/create.md +29 -0
  17. package/dist/agent-src/commands/pr/merge.md +60 -9
  18. package/dist/agent-src/commands/roadmap/ai-council.md +7 -1
  19. package/dist/agent-src/commands/roadmap/create.md +74 -27
  20. package/dist/agent-src/commands/roadmap/materialize.md +27 -0
  21. package/dist/agent-src/commands/roadmap/process-full.md +123 -18
  22. package/dist/agent-src/commands/team.md +22 -0
  23. package/dist/agent-src/contexts/authority/scope-growth-ownership.md +80 -0
  24. package/dist/agent-src/contexts/communication/rules-auto/user-interaction-mechanics.md +47 -0
  25. package/dist/agent-src/contexts/execution/auto-orchestration-activation.md +44 -3
  26. package/dist/agent-src/contexts/execution/autonomy-mechanics.md +15 -15
  27. package/dist/agent-src/contexts/execution/decision-closure-execution.md +93 -0
  28. package/dist/agent-src/contexts/execution/fix-loop-ladder.md +108 -0
  29. package/dist/agent-src/contexts/execution/plan-confidence-gate.md +4 -2
  30. package/dist/agent-src/contexts/execution/roadmap-process-loop.md +75 -6
  31. package/dist/agent-src/guidelines/agent-infra/active-remediation-mechanics.md +57 -0
  32. package/dist/agent-src/guidelines/agent-infra/evaluator-independence-mechanics.md +102 -0
  33. package/dist/agent-src/guidelines/design-fidelity-routing.md +29 -0
  34. package/dist/agent-src/rules/autonomous-execution.md +15 -8
  35. package/dist/agent-src/rules/delegation-policy.md +23 -45
  36. package/dist/agent-src/rules/design-fidelity.md +32 -37
  37. package/dist/agent-src/rules/evaluator-independence.md +43 -49
  38. package/dist/agent-src/rules/test-first.md +41 -0
  39. package/dist/agent-src/skills/accessibility-auditor/data/manifest.json +3 -3
  40. package/dist/agent-src/skills/ai-council/SKILL.md +11 -3
  41. package/dist/agent-src/skills/api-design/data/manifest.json +3 -3
  42. package/dist/agent-src/skills/database/data/manifest.json +4 -4
  43. package/dist/agent-src/skills/database/data/query-tuning.csv +3 -3
  44. package/dist/agent-src/skills/design-review/SKILL.md +50 -0
  45. package/dist/agent-src/skills/existing-ui-audit/SKILL.md +14 -4
  46. package/dist/agent-src/skills/experiment-loop/SKILL.md +31 -1
  47. package/dist/agent-src/skills/roadmap-writing/SKILL.md +1 -1
  48. package/dist/agent-src/skills/storybook-workshop/SKILL.md +42 -3
  49. package/dist/agent-src/skills/threat-modeling/SKILL.md +9 -4
  50. package/dist/agent-src/skills/threat-modeling/data/manifest.json +4 -4
  51. package/dist/agent-src/skills/verify-repair-loop/SKILL.md +37 -3
  52. package/dist/agent-src/templates/agent-settings.md +1 -1
  53. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  54. package/dist/agent-src/templates/roadmaps.md +188 -0
  55. package/dist/agent-src/templates/scripts/work_engine/directives/backend/_self_fix.ts +62 -2
  56. package/dist/agent-src/templates/scripts/work_engine/directives/backend/test.ts +1 -0
  57. package/dist/agent-src/templates/scripts/work_engine/directives/backend/verify.ts +1 -0
  58. package/dist/cli-delegate/check_update_banner.js +40 -2
  59. package/dist/cli-delegate/chunk-4E2W63DA.js +335 -0
  60. package/dist/cli-delegate/chunk-5R7HOLAF.js +99 -0
  61. package/dist/cli-delegate/{chunk-IVBPRCQO.js → chunk-6KFEC3G7.js} +1 -1
  62. package/dist/cli-delegate/{chunk-2TAQ2K4V.js → chunk-6KM6ORRY.js} +55 -386
  63. package/dist/cli-delegate/{chunk-2XY7ILBT.js → chunk-FC75PGJE.js} +42 -2
  64. package/dist/cli-delegate/{chunk-GYC3VRYN.js → chunk-FXYUYU4N.js} +57 -13
  65. package/dist/cli-delegate/{chunk-55ACLDUE.js → chunk-GJCBB2UG.js} +168 -10
  66. package/dist/cli-delegate/{chunk-AK6HODNQ.js → chunk-HDVVGPQW.js} +873 -539
  67. package/dist/cli-delegate/{chunk-H32DGUJH.js → chunk-P6ZHP5W2.js} +1 -1
  68. package/dist/cli-delegate/{chunk-57PN4GYJ.js → chunk-RGNIWTEA.js} +1 -1
  69. package/dist/cli-delegate/chunk-ROYYTEZU.js +39 -0
  70. package/dist/cli-delegate/{chunk-3FKR64R5.js → chunk-UNCRJBT3.js} +31 -7
  71. package/dist/cli-delegate/{chunk-2DK2VJWG.js → chunk-WGXTVKCQ.js} +20 -6
  72. package/dist/cli-delegate/chunk-YDPILCOL.js +152 -0
  73. package/dist/cli-delegate/cmd_analyze_session.js +1 -1
  74. package/dist/cli-delegate/cmd_brand_status.js +1 -1
  75. package/dist/cli-delegate/cmd_conformance.js +90 -56
  76. package/dist/cli-delegate/cmd_doctor.js +7 -5
  77. package/dist/cli-delegate/cmd_explain.js +2 -2
  78. package/dist/cli-delegate/cmd_export.js +9 -7
  79. package/dist/cli-delegate/cmd_fleet.js +4 -2
  80. package/dist/cli-delegate/cmd_handoff.js +4 -4
  81. package/dist/cli-delegate/cmd_mcp_available.js +1 -1
  82. package/dist/cli-delegate/cmd_migrate.js +2 -2
  83. package/dist/cli-delegate/cmd_packs_active.js +2 -2
  84. package/dist/cli-delegate/cmd_preflight.js +4 -2
  85. package/dist/cli-delegate/cmd_prune.js +10 -8
  86. package/dist/cli-delegate/cmd_route_audit.js +2 -2
  87. package/dist/cli-delegate/cmd_route_explain.js +1 -1
  88. package/dist/cli-delegate/cmd_session_recycle.js +2 -2
  89. package/dist/cli-delegate/cmd_settings_get.js +28 -2
  90. package/dist/cli-delegate/cmd_settings_migrate.js +9 -7
  91. package/dist/cli-delegate/cmd_settings_set.js +1 -1
  92. package/dist/cli-delegate/cmd_sync.js +10 -8
  93. package/dist/cli-delegate/cmd_uninstall.js +16 -13
  94. package/dist/cli-delegate/cmd_update.js +1 -1
  95. package/dist/cli-delegate/cmd_upgrade.js +1 -1
  96. package/dist/cli-delegate/cmd_validate.js +12 -10
  97. package/dist/cli-delegate/cmd_versions.js +1 -1
  98. package/dist/discovery/deprecation-report.md +1 -1
  99. package/dist/discovery/discovery-manifest.json +85 -38
  100. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  101. package/dist/discovery/discovery-manifest.summary.md +4 -4
  102. package/dist/discovery/dormancy-report.md +1 -1
  103. package/dist/discovery/orphan-report.md +1 -1
  104. package/dist/discovery/packs.json +10 -8
  105. package/dist/discovery/trust-report.md +3 -3
  106. package/dist/discovery/workspaces.json +8 -6
  107. package/dist/hooks/dispatch.js +1832 -1007
  108. package/dist/install/claudeRuleRewrite.js +14 -3
  109. package/dist/install/conflict.js +60 -10
  110. package/dist/install/conflictTracker.js +218 -0
  111. package/dist/install/fsPrimitives.js +54 -0
  112. package/dist/install/install.mjs +2007 -1481
  113. package/dist/install/manifestFiles.js +259 -0
  114. package/dist/install/preflight.js +14 -2
  115. package/dist/install/preserve.js +157 -0
  116. package/dist/install/recordedOwnership.js +132 -0
  117. package/dist/install/txlog.js +11 -2
  118. package/dist/mcp/registry-manifest.json +3 -3
  119. package/dist/mcp/server.json +2 -2
  120. package/dist/mcp/server.mjs +398 -39
  121. package/dist/router.json +1 -1
  122. package/dist/scripts/_lib/agent_settings.js +3 -2
  123. package/dist/scripts/_lib/fs_atomic.js +167 -0
  124. package/dist/scripts/_lib/installed_tools.js +460 -0
  125. package/dist/scripts/_lib/lean_projection_mode.js +3 -2
  126. package/dist/scripts/_lib/settings_renamed_keys.js +78 -0
  127. package/dist/server/routes/install.js +8 -0
  128. package/dist/server/routes/wizard.js +9 -3
  129. package/dist/server/schemas/settings.js +17 -5
  130. package/dist/shared/missionExecution.js +97 -0
  131. package/dist/ui/assets/{index-D0jaCRPM.js → index-DH1xc62v.js} +17 -17
  132. package/dist/ui/index.html +1 -1
  133. package/docs/MIGRATION.md +103 -0
  134. package/docs/contracts/settings-classes.md +26 -7
  135. package/docs/guidelines/agent-infra/active-remediation-mechanics.md +57 -0
  136. package/docs/guidelines/agent-infra/evaluator-independence-mechanics.md +102 -0
  137. package/docs/guidelines/design-fidelity-routing.md +29 -0
  138. package/package.json +1 -1
  139. package/src/agent-src/templates/scripts/work_engine/directives/backend/_self_fix.ts +62 -2
  140. package/src/agent-src/templates/scripts/work_engine/directives/backend/test.ts +1 -0
  141. package/src/agent-src/templates/scripts/work_engine/directives/backend/verify.ts +1 -0
  142. package/src/config/agent-settings.template.yml +139 -27
  143. package/src/config/auto-rule-budget.json +16 -0
  144. package/src/config/ci-local-parity.yml +18 -5
  145. package/src/config/continuity-surface.json +21 -0
  146. package/src/config/gate-coverage.yml +146 -13
  147. package/src/config/gate-violation-baselines.json +6 -6
  148. package/src/config/hook-token-budget.json +2 -0
  149. package/src/config/loop-surfaces.yaml +215 -0
  150. package/src/config/platform-anchor.json +3 -2
  151. package/src/config/release-gate-locality.yml +11 -0
  152. package/src/config/routing-coverage-seed.json +18 -4
  153. package/src/config/rule-enforcement-baseline.json +0 -1
  154. package/src/install/claudeRuleRewrite.ts +16 -2
  155. package/src/install/conflict.ts +65 -9
  156. package/src/install/conflictTracker.ts +299 -0
  157. package/src/install/fsPrimitives.ts +54 -0
  158. package/src/install/manifestFiles.ts +312 -0
  159. package/src/install/preflight.ts +16 -2
  160. package/src/install/preserve.ts +205 -0
  161. package/src/install/recordedOwnership.ts +149 -0
  162. package/src/install/txlog.ts +11 -2
  163. package/src/install/types.ts +19 -4
  164. package/src/scripts/_cli/cmd_conformance.ts +88 -15
  165. package/src/scripts/_cli/cmd_doctor.ts +4 -3
  166. package/src/scripts/_cli/cmd_route_explain.ts +9 -2
  167. package/src/scripts/_cli/cmd_settings_get.ts +44 -0
  168. package/src/scripts/_cli/doctor_execution.ts +90 -0
  169. package/src/scripts/_lib/activation_payload.ts +247 -0
  170. package/src/scripts/_lib/agent_settings.ts +4 -2
  171. package/src/scripts/_lib/authority_path.ts +102 -0
  172. package/src/scripts/_lib/cascade_base.ts +94 -0
  173. package/src/scripts/_lib/changelog_eras.ts +7 -2
  174. package/src/scripts/_lib/continuation_ladder.ts +149 -2
  175. package/src/scripts/_lib/council_transport.ts +129 -0
  176. package/src/scripts/_lib/delivery_ready.ts +112 -0
  177. package/src/scripts/_lib/forge_protection.ts +267 -0
  178. package/src/scripts/_lib/hook_platform_keys.ts +27 -0
  179. package/src/scripts/_lib/json_python_parity.ts +127 -0
  180. package/src/scripts/_lib/lean_projection_mode.ts +14 -3
  181. package/src/scripts/_lib/loop_surfaces.ts +382 -0
  182. package/src/scripts/_lib/mission_record.ts +190 -0
  183. package/src/scripts/_lib/obligation_frequency.ts +217 -0
  184. package/src/scripts/_lib/obligations.ts +402 -0
  185. package/src/scripts/_lib/orchestration_record.ts +11 -20
  186. package/src/scripts/_lib/release_highlights.ts +199 -10
  187. package/src/scripts/_lib/release_holds.ts +493 -0
  188. package/src/scripts/_lib/release_migration_gate.ts +184 -0
  189. package/src/scripts/_lib/rides_along.ts +102 -0
  190. package/src/scripts/_lib/settings_renamed_keys.ts +82 -0
  191. package/src/scripts/_lib/test_delta.ts +166 -0
  192. package/src/scripts/_lib/test_provenance.ts +171 -0
  193. package/src/scripts/_lib/typed_op_grant.ts +246 -0
  194. package/src/scripts/_lib/typed_op_watch.ts +185 -0
  195. package/src/scripts/ai_council/config.ts +8 -11
  196. package/src/scripts/ai_council/fallback_config.ts +5 -3
  197. package/src/scripts/ai_council/ownership_classes.ts +118 -0
  198. package/src/scripts/ask_block_census.ts +285 -15
  199. package/src/scripts/check_enforcement_matrix.ts +624 -0
  200. package/src/scripts/check_gate_reachability.ts +173 -10
  201. package/src/scripts/check_generator_sync.ts +954 -0
  202. package/src/scripts/check_preamble_payload_budget.ts +75 -2
  203. package/src/scripts/check_release_highlights.ts +33 -1
  204. package/src/scripts/check_release_holds.ts +567 -0
  205. package/src/scripts/check_rule_projection_integrity.ts +22 -12
  206. package/src/scripts/check_test_delta.ts +294 -0
  207. package/src/scripts/check_test_weakening.ts +299 -0
  208. package/src/scripts/closure_scan.ts +333 -0
  209. package/src/scripts/compile_hook_manifest.ts +43 -3
  210. package/src/scripts/council_record_shape.ts +209 -0
  211. package/src/scripts/hook_manifest.json +1 -1
  212. package/src/scripts/hook_manifest.yaml +88 -9
  213. package/src/scripts/hooks/concern_registry.ts +4 -0
  214. package/src/scripts/hooks/design_pass_hook.ts +128 -3
  215. package/src/scripts/hooks/evidence_independence.ts +96 -0
  216. package/src/scripts/hooks/memory_recall_hook.ts +540 -0
  217. package/src/scripts/hooks/obligation_settle_hook.ts +182 -0
  218. package/src/scripts/hooks/rule_inject_hook.ts +49 -1
  219. package/src/scripts/hooks/run_continuation_hook.ts +17 -20
  220. package/src/scripts/hooks_doctor.ts +85 -0
  221. package/src/scripts/hooks_status.ts +19 -0
  222. package/src/scripts/install.ts +106 -206
  223. package/src/scripts/janitor.ts +7 -0
  224. package/src/scripts/lint_decision_classes.ts +464 -0
  225. package/src/scripts/lint_hook_manifest.ts +11 -0
  226. package/src/scripts/lint_major_migration_sections.ts +450 -0
  227. package/src/scripts/lint_plan_risk_register.ts +47 -3
  228. package/src/scripts/lint_roadmap_blockers.ts +61 -0
  229. package/src/scripts/lint_roadmap_producers.ts +202 -0
  230. package/src/scripts/measure_rule_budget.ts +101 -5
  231. package/src/scripts/new_roadmap.ts +37 -0
  232. package/src/scripts/orchestration_record.ts +0 -5
  233. package/src/scripts/release.ts +14 -98
  234. package/src/scripts/release_drill.ts +267 -1
  235. package/src/scripts/release_publication.ts +51 -0
  236. package/src/scripts/report_enforcement_drift.ts +566 -0
  237. package/src/scripts/report_host_injection_effect.ts +3 -11
  238. package/src/scripts/report_standing_payload_by_host.ts +26 -152
  239. package/src/scripts/schemas/agent-settings.schema.json +23 -0
  240. package/src/scripts/schemas/command.schema.json +4 -0
  241. package/src/scripts/scope_growth.ts +219 -0
  242. package/src/scripts/trigger_eval_grandfather.json +0 -1
  243. package/src/scripts/ui_conformance_probe.ts +622 -0
  244. package/src/server/schemas/settings.ts +31 -7
  245. package/src/shared/missionExecution.ts +126 -0
  246. package/dist/cli-delegate/chunk-523HCFYO.js +0 -90
@@ -65,6 +65,46 @@ import * as fs from "node:fs";
65
65
  import * as os from "node:os";
66
66
  import * as path from "node:path";
67
67
  import { fileURLToPath } from "node:url";
68
+
69
+ // src/scripts/_lib/settings_renamed_keys.ts
70
+ var RENAMED_KEYS = /* @__PURE__ */ new Map([
71
+ ["planning.challenge_on_create", "planning.closure_pass"]
72
+ ]);
73
+ var _warned = /* @__PURE__ */ new Set();
74
+ function _read(tree, dotted) {
75
+ let cur = tree;
76
+ for (const part of dotted.split(".")) {
77
+ if (cur === null || typeof cur !== "object" || Array.isArray(cur)) return void 0;
78
+ cur = cur[part];
79
+ }
80
+ return cur;
81
+ }
82
+ function _write(tree, dotted, value) {
83
+ const parts = dotted.split(".");
84
+ let cur = tree;
85
+ for (const part of parts.slice(0, -1)) {
86
+ const next = cur[part];
87
+ if (next === null || typeof next !== "object" || Array.isArray(next)) cur[part] = {};
88
+ cur = cur[part];
89
+ }
90
+ cur[parts[parts.length - 1]] = value;
91
+ }
92
+ function applyRenamedKeys(layer) {
93
+ for (const [oldKey, newKey] of RENAMED_KEYS) {
94
+ const oldValue = _read(layer, oldKey);
95
+ if (oldValue === void 0) continue;
96
+ if (_read(layer, newKey) === void 0) _write(layer, newKey, oldValue);
97
+ if (_warned.has(oldKey)) continue;
98
+ _warned.add(oldKey);
99
+ process.stderr.write(
100
+ `\u26A0\uFE0F settings: \`${oldKey}\` was renamed to \`${newKey}\`. The old key still works for one minor; rename it in your .agent-settings.yml.
101
+ `
102
+ );
103
+ }
104
+ return layer;
105
+ }
106
+
107
+ // src/scripts/_lib/agent_settings.ts
68
108
  var _require = createRequire(import.meta.url);
69
109
  var Logger = class {
70
110
  name = "scripts._lib.agent_settings";
@@ -504,9 +544,9 @@ function load_agent_settings(options = {}) {
504
544
  }
505
545
  const cascade = _resolve_cascade_paths(cwd, project_path);
506
546
  const merged = template_defaults(template_path ?? void 0);
507
- _deep_merge(merged, user_global_filtered);
547
+ _deep_merge(merged, applyRenamedKeys(user_global_filtered));
508
548
  for (const p of cascade) {
509
- const layer = _read_yaml(p) ?? {};
549
+ const layer = applyRenamedKeys(_read_yaml(p) ?? {});
510
550
  if (Object.keys(layer).length > 0) {
511
551
  _deep_merge(merged, layer);
512
552
  }
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-OY53J6II.js";
5
5
  import {
6
6
  load_agent_settings
7
- } from "./chunk-2XY7ILBT.js";
7
+ } from "./chunk-FC75PGJE.js";
8
8
  import {
9
9
  resolve_with_fallback,
10
10
  write_target
@@ -2805,7 +2805,7 @@ function buildSecondModel(entry, cls, locked, d) {
2805
2805
  if (!("second_model" in entry)) return null;
2806
2806
  if (locked.has(cls)) {
2807
2807
  throw d.error(
2808
- `decision_resolution.classes.${cls}.second_model=${d.repr(entry["second_model"])}: a second-model rung is not configurable for high-impact / user-required decisions \u2014 those classes are LOCKED to \`user\` (Iron Law) and never resolve on a model of any kind.`
2808
+ `decision_resolution.classes.${cls}.second_model=${d.repr(entry["second_model"])}: a second-model rung is not configurable for an owner-routed class (high-impact / user-required on the impact axis; product-owned / business-owned / destructive-owned on the ownership axis) \u2014 those classes are LOCKED to \`user\` (Iron Law) and never resolve on a model of any kind.`
2809
2809
  );
2810
2810
  }
2811
2811
  const raw = entry["second_model"];
@@ -2818,6 +2818,54 @@ function buildSecondModel(entry, cls, locked, d) {
2818
2818
  return raw;
2819
2819
  }
2820
2820
 
2821
+ // src/scripts/ai_council/ownership_classes.ts
2822
+ var OWNERSHIP_CLASSES = [
2823
+ "deterministic",
2824
+ "reversible-technical",
2825
+ "contested-technical",
2826
+ "critical-technical",
2827
+ "product-owned",
2828
+ "business-owned",
2829
+ "destructive-owned",
2830
+ "spend-exhaustion"
2831
+ ];
2832
+ var OWNER_LOCKED_CLASSES = /* @__PURE__ */ new Set([
2833
+ "product-owned",
2834
+ "business-owned",
2835
+ "destructive-owned"
2836
+ ]);
2837
+ var NEVER_OWNER_CLASSES = /* @__PURE__ */ new Set(["spend-exhaustion"]);
2838
+ function allOwnerLocked(impactLocked) {
2839
+ return /* @__PURE__ */ new Set([...impactLocked, ...OWNER_LOCKED_CLASSES]);
2840
+ }
2841
+ var DEFAULT_RESOLUTION_MODES = {
2842
+ trivial: "agent",
2843
+ low_impact: "agent",
2844
+ medium_impact: "council",
2845
+ high_impact: "user",
2846
+ user_required: "user",
2847
+ deterministic: "agent",
2848
+ "reversible-technical": "agent",
2849
+ "contested-technical": "council",
2850
+ "critical-technical": "council",
2851
+ "product-owned": "user",
2852
+ "business-owned": "user",
2853
+ "destructive-owned": "user",
2854
+ "spend-exhaustion": "agent"
2855
+ };
2856
+ function defaultModeFor(cls) {
2857
+ return DEFAULT_RESOLUTION_MODES[cls] ?? "agent";
2858
+ }
2859
+ function ownershipModeError(cls, mode, repr) {
2860
+ if (OWNER_LOCKED_CLASSES.has(cls) && mode !== "user") {
2861
+ return `decision_resolution.classes.${cls}.mode=${repr(mode)}: class \`${cls}\` is LOCKED to \`user\` (Iron Law) \u2014 product, business and destructive decisions are owner-owned and never resolve on a model.`;
2862
+ }
2863
+ if (NEVER_OWNER_CLASSES.has(cls) && mode === "user") {
2864
+ return `decision_resolution.classes.${cls}.mode=${repr(mode)}: class \`${cls}\` is never owner-routed (Iron Law) \u2014 spend exhaustion pauses and reports, it does not ask.`;
2865
+ }
2866
+ return null;
2867
+ }
2868
+
2821
2869
  // src/scripts/ai_council/py_format.ts
2822
2870
  function _pyReprStr(s) {
2823
2871
  const hasSingle = s.includes("'");
@@ -3445,13 +3493,7 @@ var _LOCKED_IMPACT_CLASSES = /* @__PURE__ */ new Set([
3445
3493
  "high_impact",
3446
3494
  "user_required"
3447
3495
  ]);
3448
- var _DEFAULT_RESOLUTION_MODES = {
3449
- trivial: "agent",
3450
- low_impact: "agent",
3451
- medium_impact: "council",
3452
- high_impact: "user",
3453
- user_required: "user"
3454
- };
3496
+ var _ALL_OWNER_LOCKED = allOwnerLocked(_LOCKED_IMPACT_CLASSES);
3455
3497
  function _build_decision_resolution(d) {
3456
3498
  if (!_isDict(d)) {
3457
3499
  throw new CouncilConfigError("`decision_resolution` must be a mapping.");
@@ -3469,14 +3511,14 @@ function _build_decision_resolution(d) {
3469
3511
  );
3470
3512
  }
3471
3513
  const classes = /* @__PURE__ */ new Map();
3472
- for (const cls of _IMPACT_CLASSES) {
3514
+ for (const cls of [..._IMPACT_CLASSES, ...OWNERSHIP_CLASSES]) {
3473
3515
  const entry_raw = _orEmpty(classes_raw[cls] ?? null);
3474
3516
  if (!_isDict(entry_raw)) {
3475
3517
  throw new CouncilConfigError(
3476
3518
  `\`decision_resolution.classes.${cls}\` must be a mapping.`
3477
3519
  );
3478
3520
  }
3479
- const mode = _get(entry_raw, "mode", _DEFAULT_RESOLUTION_MODES[cls]);
3521
+ const mode = _get(entry_raw, "mode", defaultModeFor(cls));
3480
3522
  if (!(_isStr(mode) && _VALID_RESOLUTION_MODES.has(mode))) {
3481
3523
  throw new CouncilConfigError(
3482
3524
  `decision_resolution.classes.${cls}.mode=${_pyRepr3(mode)} not in ${_sortedListRepr(_VALID_RESOLUTION_MODES)}.`
@@ -3487,7 +3529,9 @@ function _build_decision_resolution(d) {
3487
3529
  `decision_resolution.classes.${cls}.mode=${_pyRepr3(mode)}: class \`${cls}\` is LOCKED to \`user\` (Iron Law) \u2014 high-impact and user-required decisions never bypass the user.`
3488
3530
  );
3489
3531
  }
3490
- if (_LOCKED_IMPACT_CLASSES.has(cls) && "dispatch" in entry_raw) {
3532
+ const ownErr = ownershipModeError(cls, mode, _pyRepr3);
3533
+ if (ownErr !== null) throw new CouncilConfigError(ownErr);
3534
+ if (_ALL_OWNER_LOCKED.has(cls) && "dispatch" in entry_raw) {
3491
3535
  throw new CouncilConfigError(
3492
3536
  `decision_resolution.classes.${cls}.dispatch=${_pyRepr3(entry_raw.dispatch)}: dispatch is not configurable for high-impact / user-required decisions \u2014 always full council.`
3493
3537
  );
@@ -3501,7 +3545,7 @@ function _build_decision_resolution(d) {
3501
3545
  const second_model = buildSecondModel(
3502
3546
  entry_raw,
3503
3547
  cls,
3504
- _LOCKED_IMPACT_CLASSES,
3548
+ _ALL_OWNER_LOCKED,
3505
3549
  _FALLBACK_DEPS
3506
3550
  );
3507
3551
  classes.set(cls, { mode, confidence_threshold: threshold, second_model });
@@ -15,6 +15,10 @@ import {
15
15
  SECTION_HEADER,
16
16
  _is_source_repo
17
17
  } from "./chunk-M2DPGFZ4.js";
18
+ import {
19
+ executionPostureFromOverrides,
20
+ resolveExecutionPosture
21
+ } from "./chunk-ROYYTEZU.js";
18
22
  import {
19
23
  DEFAULT_PROJECTS_ROOT,
20
24
  DEFAULT_SEAT_CEILING,
@@ -29,21 +33,17 @@ import {
29
33
  projectStoreSlug,
30
34
  scanTranscripts,
31
35
  weightedInputUnits
32
- } from "./chunk-GYC3VRYN.js";
36
+ } from "./chunk-FXYUYU4N.js";
33
37
  import {
34
38
  git_common_dir
35
39
  } from "./chunk-E4XIZDIB.js";
36
40
  import {
37
- DEFAULT_DEPLOY_ROOTS,
38
41
  MANAGED_SIGNATURE,
39
- SCHEMA_VERSIONS_SUPPORTED,
40
42
  TOOL_TO_HOST,
41
43
  build_claude_hook_matrix,
42
44
  global_deploy_inventory_exports,
43
- manifest_path,
44
- read_manifest,
45
45
  residualReport
46
- } from "./chunk-2TAQ2K4V.js";
46
+ } from "./chunk-6KM6ORRY.js";
47
47
  import {
48
48
  read_lockfile
49
49
  } from "./chunk-T7L2QK3K.js";
@@ -52,6 +52,12 @@ import {
52
52
  excludedRuleBasenames,
53
53
  ruleScopeFromSettings
54
54
  } from "./chunk-DMSZHXZS.js";
55
+ import {
56
+ DEFAULT_DEPLOY_ROOTS,
57
+ SCHEMA_VERSIONS_SUPPORTED,
58
+ manifest_path,
59
+ read_manifest
60
+ } from "./chunk-4E2W63DA.js";
55
61
  import {
56
62
  require_dist
57
63
  } from "./chunk-OY53J6II.js";
@@ -66,7 +72,7 @@ import {
66
72
  iter_setting_overrides,
67
73
  project_settings_path,
68
74
  resolve_project_root
69
- } from "./chunk-2XY7ILBT.js";
75
+ } from "./chunk-FC75PGJE.js";
70
76
  import {
71
77
  event4u_root,
72
78
  resolve_with_fallback
@@ -2835,6 +2841,158 @@ function checkHumanizerRuntime(which) {
2835
2841
  };
2836
2842
  }
2837
2843
 
2844
+ // src/scripts/_lib/forge_protection.ts
2845
+ var SOURCE = {
2846
+ rulesets: "GET repos/{owner}/{repo}/rulesets + GET .../rulesets/{id}",
2847
+ repo: "GET repos/{owner}/{repo} (allow_auto_merge)",
2848
+ environments: "GET repos/{owner}/{repo}/environments (deployment_branch_policy)"
2849
+ };
2850
+ function isActiveBranchRuleset(rs) {
2851
+ return rs.enforcement === "active" && rs.target === "branch";
2852
+ }
2853
+ function reachesDefaultBranch(rs, defaultBranch) {
2854
+ const include = rs.conditions?.ref_name?.include ?? [];
2855
+ return include.some(
2856
+ (p) => p === "~DEFAULT_BRANCH" || p === "~ALL" || p === `refs/heads/${defaultBranch}`
2857
+ );
2858
+ }
2859
+ function hasRule(rs, type) {
2860
+ return (rs.rules ?? []).some((r) => r.type === type);
2861
+ }
2862
+ function requiredContexts(rs) {
2863
+ for (const r of rs.rules ?? []) {
2864
+ if (r.type !== "required_status_checks") continue;
2865
+ const p = r.parameters;
2866
+ if (p === null || typeof p !== "object") continue;
2867
+ const list = p["required_status_checks"];
2868
+ if (!Array.isArray(list)) continue;
2869
+ return list.map(
2870
+ (e) => e !== null && typeof e === "object" ? e["context"] : null
2871
+ ).filter((c) => typeof c === "string");
2872
+ }
2873
+ return [];
2874
+ }
2875
+ function forgeProtectionRows(reading) {
2876
+ const rows = [];
2877
+ const rulesets = reading.rulesets;
2878
+ const branch = reading.defaultBranch;
2879
+ const covering = rulesets === null || branch === null ? null : rulesets.filter((rs) => isActiveBranchRuleset(rs) && reachesDefaultBranch(rs, branch));
2880
+ rows.push(
2881
+ covering === null ? {
2882
+ id: "default_branch_protected",
2883
+ state: "unread",
2884
+ source: SOURCE.rulesets,
2885
+ detail: "the rulesets were not queried"
2886
+ } : covering.length > 0 ? {
2887
+ id: "default_branch_protected",
2888
+ state: "satisfied",
2889
+ source: SOURCE.rulesets,
2890
+ detail: `${String(covering.length)} active branch ruleset(s) cover the default branch`
2891
+ } : {
2892
+ id: "default_branch_protected",
2893
+ state: "unsatisfied",
2894
+ source: SOURCE.rulesets,
2895
+ detail: "no active branch ruleset covers the default branch. NOTE: the classic branches/<b>/protection endpoint 404s on a ruleset-protected repository, so a 404 there is not evidence for this row."
2896
+ }
2897
+ );
2898
+ const contexts = covering === null ? null : covering.flatMap(requiredContexts);
2899
+ rows.push(
2900
+ contexts === null ? {
2901
+ id: "required_checks_present",
2902
+ state: "unread",
2903
+ source: SOURCE.rulesets,
2904
+ detail: "the rulesets were not queried"
2905
+ } : contexts.length > 0 ? {
2906
+ id: "required_checks_present",
2907
+ state: "satisfied",
2908
+ source: SOURCE.rulesets,
2909
+ detail: `${String(contexts.length)} required context(s): ${contexts.join(", ")}`
2910
+ } : {
2911
+ id: "required_checks_present",
2912
+ state: "unsatisfied",
2913
+ source: SOURCE.rulesets,
2914
+ detail: "no required status check context is configured"
2915
+ }
2916
+ );
2917
+ const noFastForward = covering === null ? null : covering.some((rs) => hasRule(rs, "non_fast_forward"));
2918
+ rows.push(
2919
+ noFastForward === null ? {
2920
+ id: "force_push_disabled",
2921
+ state: "unread",
2922
+ source: SOURCE.rulesets,
2923
+ detail: "the rulesets were not queried"
2924
+ } : {
2925
+ id: "force_push_disabled",
2926
+ state: noFastForward ? "satisfied" : "unsatisfied",
2927
+ source: SOURCE.rulesets,
2928
+ detail: noFastForward ? "a non_fast_forward rule is active on the default branch" : "no non_fast_forward rule covers the default branch"
2929
+ }
2930
+ );
2931
+ rows.push(
2932
+ reading.allowAutoMerge === null ? {
2933
+ id: "auto_merge_available",
2934
+ state: "unread",
2935
+ source: SOURCE.repo,
2936
+ detail: "the repository record was not queried"
2937
+ } : {
2938
+ id: "auto_merge_available",
2939
+ state: reading.allowAutoMerge ? "satisfied" : "unsatisfied",
2940
+ source: SOURCE.repo,
2941
+ detail: reading.allowAutoMerge ? "allow_auto_merge is enabled" : "allow_auto_merge is disabled \u2014 merge delivery cannot queue behind checks"
2942
+ }
2943
+ );
2944
+ rows.push(
2945
+ reading.deployRestricted === null ? {
2946
+ id: "deploy_via_pipeline_only",
2947
+ state: "unread",
2948
+ source: SOURCE.environments,
2949
+ detail: "the environments were not queried"
2950
+ } : {
2951
+ id: "deploy_via_pipeline_only",
2952
+ state: reading.deployRestricted ? "satisfied" : "unsatisfied",
2953
+ source: SOURCE.environments,
2954
+ detail: reading.deployRestricted ? "every environment restricts its deployment branches" : "at least one environment accepts a deployment from any branch"
2955
+ }
2956
+ );
2957
+ return rows;
2958
+ }
2959
+ function protectionActions(rows) {
2960
+ return rows.filter((r) => r.state !== "satisfied").map((r) => `${r.id}: ${r.state} \u2014 ${r.detail} (source: ${r.source})`);
2961
+ }
2962
+
2963
+ // src/scripts/_cli/doctor_execution.ts
2964
+ function executionJson(overrides) {
2965
+ let posture;
2966
+ try {
2967
+ posture = executionPostureFromOverrides(overrides());
2968
+ } catch {
2969
+ posture = resolveExecutionPosture({});
2970
+ }
2971
+ return {
2972
+ fix_loop_max: posture.fix_loop_max,
2973
+ escalation: [...posture.escalation]
2974
+ };
2975
+ }
2976
+ function forgeProtectionJson(reading) {
2977
+ const rows = forgeProtectionRows(reading);
2978
+ return {
2979
+ rows: rows.map((r) => ({
2980
+ id: r.id,
2981
+ state: r.state,
2982
+ source: r.source,
2983
+ detail: r.detail
2984
+ })),
2985
+ actions: protectionActions(rows),
2986
+ read_from_forge: rows.some((r) => r.state !== "unread")
2987
+ };
2988
+ }
2989
+ var UNREAD_FORGE = {
2990
+ rulesets: null,
2991
+ defaultBranch: null,
2992
+ allowAutoMerge: null,
2993
+ deployRestricted: null
2994
+ };
2995
+
2838
2996
  // src/scripts/_lib/environment_detector.ts
2839
2997
  import { spawnSync } from "node:child_process";
2840
2998
  import * as fs13 from "node:fs";
@@ -5919,9 +6077,9 @@ function _emit_json(project_root, missing, modified, foreign, tag_drift, checks
5919
6077
  foreign,
5920
6078
  tag_drift
5921
6079
  };
5922
- if (origin !== null) {
5923
- payload["project_root_origin"] = origin;
5924
- }
6080
+ if (origin !== null) payload["project_root_origin"] = origin;
6081
+ payload["execution"] = executionJson(() => iter_setting_overrides({ cwd: project_root }));
6082
+ payload["forge_protection"] = forgeProtectionJson(UNREAD_FORGE);
5925
6083
  if (checks !== null) {
5926
6084
  payload["checks"] = checks;
5927
6085
  const drift = missing.length + modified.length + foreign.length + tag_drift.length;