create-principles-disciple 1.150.3 → 1.150.4

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 (248) hide show
  1. package/_release/product-identity.json +1 -1
  2. package/codex-adapter/dist/ingestion/admission.js +2 -0
  3. package/codex-adapter/dist/pd-hook.d.ts +7 -5
  4. package/codex-adapter/dist/pd-hook.js +18 -7
  5. package/codex-adapter/dist/tool-semantics.js +5 -1
  6. package/codex-adapter/dist/worker/workspace-worker.js +4 -2
  7. package/codex-adapter/package.json +1 -1
  8. package/console/dist/lib/utils.js +16 -1
  9. package/console/dist/web/assets/app.css +147 -46
  10. package/console/dist/web/assets/app.js +35 -32
  11. package/console/package.json +2 -0
  12. package/core/dist/runtime/activation-compatibility-read-model.d.ts.map +1 -1
  13. package/core/dist/runtime/activation-compatibility-read-model.js +2 -1
  14. package/core/dist/runtime/activation-compatibility-read-model.js.map +1 -1
  15. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
  16. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js +106 -19
  17. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js.map +1 -1
  18. package/core/dist/runtime/candidate-audit.d.ts.map +1 -1
  19. package/core/dist/runtime/candidate-audit.js +2 -1
  20. package/core/dist/runtime/candidate-audit.js.map +1 -1
  21. package/core/dist/runtime/config/pd-config-effective.d.ts.map +1 -1
  22. package/core/dist/runtime/config/pd-config-effective.js +2 -0
  23. package/core/dist/runtime/config/pd-config-effective.js.map +1 -1
  24. package/core/dist/runtime/config/pd-config-types.d.ts +52 -0
  25. package/core/dist/runtime/config/pd-config-types.d.ts.map +1 -1
  26. package/core/dist/runtime/config/pd-config-types.js.map +1 -1
  27. package/core/dist/runtime/config/pd-config-validate.d.ts.map +1 -1
  28. package/core/dist/runtime/config/pd-config-validate.js +134 -0
  29. package/core/dist/runtime/config/pd-config-validate.js.map +1 -1
  30. package/core/dist/runtime/feature-flags/feature-flag-contract.d.ts.map +1 -1
  31. package/core/dist/runtime/feature-flags/feature-flag-contract.js +8 -0
  32. package/core/dist/runtime/feature-flags/feature-flag-contract.js.map +1 -1
  33. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.d.ts.map +1 -1
  34. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js +24 -0
  35. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
  36. package/core/dist/runtime/index.d.ts +2 -0
  37. package/core/dist/runtime/index.d.ts.map +1 -1
  38. package/core/dist/runtime/index.js +2 -0
  39. package/core/dist/runtime/index.js.map +1 -1
  40. package/core/dist/runtime/internalization/rule-host-input-builder.d.ts +16 -0
  41. package/core/dist/runtime/internalization/rule-host-input-builder.d.ts.map +1 -1
  42. package/core/dist/runtime/internalization/rule-host-input-builder.js +18 -0
  43. package/core/dist/runtime/internalization/rule-host-input-builder.js.map +1 -1
  44. package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts +8 -0
  45. package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts.map +1 -1
  46. package/core/dist/runtime/internalization/split-diagnostician-runner.js +24 -2
  47. package/core/dist/runtime/internalization/split-diagnostician-runner.js.map +1 -1
  48. package/core/dist/runtime/internalization/tool-semantic-registry.d.ts +26 -0
  49. package/core/dist/runtime/internalization/tool-semantic-registry.d.ts.map +1 -1
  50. package/core/dist/runtime/internalization/tool-semantic-registry.js +55 -5
  51. package/core/dist/runtime/internalization/tool-semantic-registry.js.map +1 -1
  52. package/core/dist/runtime/internalization-chain-integrity-read-model.d.ts.map +1 -1
  53. package/core/dist/runtime/internalization-chain-integrity-read-model.js +2 -2
  54. package/core/dist/runtime/internalization-chain-integrity-read-model.js.map +1 -1
  55. package/core/dist/runtime/internalization-integrity-remediation.d.ts.map +1 -1
  56. package/core/dist/runtime/internalization-integrity-remediation.js +2 -2
  57. package/core/dist/runtime/internalization-integrity-remediation.js.map +1 -1
  58. package/core/dist/runtime/operator-health-read-model.d.ts.map +1 -1
  59. package/core/dist/runtime/operator-health-read-model.js +2 -2
  60. package/core/dist/runtime/operator-health-read-model.js.map +1 -1
  61. package/core/dist/runtime/pain-recall-read-model.d.ts.map +1 -1
  62. package/core/dist/runtime/pain-recall-read-model.js +4 -3
  63. package/core/dist/runtime/pain-recall-read-model.js.map +1 -1
  64. package/core/dist/runtime/pruning-read-model.d.ts.map +1 -1
  65. package/core/dist/runtime/pruning-read-model.js +3 -2
  66. package/core/dist/runtime/pruning-read-model.js.map +1 -1
  67. package/core/dist/runtime/risk/risk-calculator-policy.d.ts +12 -2
  68. package/core/dist/runtime/risk/risk-calculator-policy.d.ts.map +1 -1
  69. package/core/dist/runtime/risk/risk-calculator-policy.js +33 -22
  70. package/core/dist/runtime/risk/risk-calculator-policy.js.map +1 -1
  71. package/core/dist/runtime/schema-conformance-read-model.js +2 -2
  72. package/core/dist/runtime/schema-conformance-read-model.js.map +1 -1
  73. package/core/dist/runtime/store/sqlite-connection.d.ts +0 -5
  74. package/core/dist/runtime/store/sqlite-connection.d.ts.map +1 -1
  75. package/core/dist/runtime/store/sqlite-connection.js +4 -12
  76. package/core/dist/runtime/store/sqlite-connection.js.map +1 -1
  77. package/core/dist/runtime/store/storage-paths.d.ts +17 -0
  78. package/core/dist/runtime/store/storage-paths.d.ts.map +1 -0
  79. package/core/dist/runtime/store/storage-paths.js +52 -0
  80. package/core/dist/runtime/store/storage-paths.js.map +1 -0
  81. package/core/dist/runtime/trajectory-retention.d.ts +257 -0
  82. package/core/dist/runtime/trajectory-retention.d.ts.map +1 -0
  83. package/core/dist/runtime/trajectory-retention.js +598 -0
  84. package/core/dist/runtime/trajectory-retention.js.map +1 -0
  85. package/core/dist/trajectory-store.d.ts +9 -9
  86. package/core/dist/trajectory-store.d.ts.map +1 -1
  87. package/core/dist/trajectory-store.js +9 -12
  88. package/core/dist/trajectory-store.js.map +1 -1
  89. package/core/package.json +1 -1
  90. package/dist/installers/codex-host-installer.d.ts.map +1 -1
  91. package/dist/installers/codex-host-installer.js +92 -5
  92. package/dist/installers/codex-host-installer.js.map +1 -1
  93. package/dist/installers/mcp-binding-shape-mirror.d.ts +27 -0
  94. package/dist/installers/mcp-binding-shape-mirror.d.ts.map +1 -0
  95. package/dist/installers/mcp-binding-shape-mirror.js +105 -0
  96. package/dist/installers/mcp-binding-shape-mirror.js.map +1 -0
  97. package/dist/skill-catalog.d.ts +35 -0
  98. package/dist/skill-catalog.d.ts.map +1 -0
  99. package/dist/skill-catalog.js +85 -0
  100. package/dist/skill-catalog.js.map +1 -0
  101. package/dist/skill-delivery-parity.d.ts +22 -0
  102. package/dist/skill-delivery-parity.d.ts.map +1 -0
  103. package/dist/skill-delivery-parity.js +31 -0
  104. package/dist/skill-delivery-parity.js.map +1 -0
  105. package/host-runtime/dist/active-principle-prompt.d.ts +8 -0
  106. package/host-runtime/dist/active-principle-prompt.js +15 -5
  107. package/host-runtime/dist/adaptive-decision-protocol.d.ts +142 -0
  108. package/host-runtime/dist/adaptive-decision-protocol.js +190 -0
  109. package/host-runtime/dist/adaptive-priority-provider.d.ts +37 -13
  110. package/host-runtime/dist/adaptive-priority-provider.js +65 -62
  111. package/host-runtime/dist/adaptive-selection.d.ts +67 -64
  112. package/host-runtime/dist/adaptive-selection.js +215 -327
  113. package/host-runtime/dist/adaptive-skip-decision.d.ts +26 -14
  114. package/host-runtime/dist/adaptive-skip-decision.js +33 -29
  115. package/host-runtime/dist/codex-rule-context-provider.js +4 -1
  116. package/host-runtime/dist/governance-observation-store.d.ts +40 -1
  117. package/host-runtime/dist/governance-observation-store.js +188 -9
  118. package/host-runtime/dist/governance-signal-admission.d.ts +19 -3
  119. package/host-runtime/dist/governance-signal-admission.js +12 -4
  120. package/host-runtime/dist/host-tool-declaration.d.ts +18 -2
  121. package/host-runtime/dist/host-tool-declaration.js +67 -11
  122. package/host-runtime/dist/host-tool-semantic-resolver.d.ts +7 -0
  123. package/host-runtime/dist/host-tool-semantic-resolver.js +22 -2
  124. package/host-runtime/dist/index.d.ts +3 -0
  125. package/host-runtime/dist/index.js +14 -0
  126. package/host-runtime/dist/production-rulehost-gate.js +15 -3
  127. package/host-runtime/dist/trajectory-retention.d.ts +147 -0
  128. package/host-runtime/dist/trajectory-retention.js +907 -0
  129. package/host-runtime/package.json +1 -1
  130. package/install-layout/dist/index.d.ts +9 -2
  131. package/install-layout/dist/index.js +26 -9
  132. package/install-layout/dist/mcp-binding-contract.d.ts +91 -0
  133. package/install-layout/dist/mcp-binding-contract.js +230 -0
  134. package/install-layout/package.json +1 -1
  135. package/package.json +4 -4
  136. package/pd-cli/dist/commands/build-trajectory-evidence.d.ts.map +1 -1
  137. package/pd-cli/dist/commands/build-trajectory-evidence.js +17 -11
  138. package/pd-cli/dist/commands/build-trajectory-evidence.js.map +1 -1
  139. package/pd-cli/dist/commands/codex-reconcile.d.ts +7 -0
  140. package/pd-cli/dist/commands/codex-reconcile.d.ts.map +1 -1
  141. package/pd-cli/dist/commands/codex-reconcile.js +11 -2
  142. package/pd-cli/dist/commands/codex-reconcile.js.map +1 -1
  143. package/pd-cli/dist/commands/codex-worker.d.ts.map +1 -1
  144. package/pd-cli/dist/commands/codex-worker.js +35 -0
  145. package/pd-cli/dist/commands/codex-worker.js.map +1 -1
  146. package/pd-cli/dist/commands/command-helpers.d.ts +1 -1
  147. package/pd-cli/dist/commands/command-helpers.js +1 -1
  148. package/pd-cli/dist/commands/errors-list.d.ts +1 -1
  149. package/pd-cli/dist/commands/errors-list.js +1 -1
  150. package/pd-cli/dist/commands/health-mcp.d.ts +23 -1
  151. package/pd-cli/dist/commands/health-mcp.d.ts.map +1 -1
  152. package/pd-cli/dist/commands/health-mcp.js +81 -22
  153. package/pd-cli/dist/commands/health-mcp.js.map +1 -1
  154. package/pd-cli/dist/commands/health.d.ts +1 -1
  155. package/pd-cli/dist/commands/health.d.ts.map +1 -1
  156. package/pd-cli/dist/commands/health.js +12 -5
  157. package/pd-cli/dist/commands/health.js.map +1 -1
  158. package/pd-cli/dist/commands/principles-stats.d.ts +1 -1
  159. package/pd-cli/dist/commands/principles-stats.js +1 -1
  160. package/pd-cli/dist/commands/trajectory-retention.d.ts +23 -0
  161. package/pd-cli/dist/commands/trajectory-retention.d.ts.map +1 -0
  162. package/pd-cli/dist/commands/trajectory-retention.js +159 -0
  163. package/pd-cli/dist/commands/trajectory-retention.js.map +1 -0
  164. package/pd-cli/dist/commands/workbuddy-setup.d.ts +69 -0
  165. package/pd-cli/dist/commands/workbuddy-setup.d.ts.map +1 -0
  166. package/pd-cli/dist/commands/workbuddy-setup.js +379 -0
  167. package/pd-cli/dist/commands/workbuddy-setup.js.map +1 -0
  168. package/pd-cli/dist/commands/workbuddy-worker.d.ts.map +1 -1
  169. package/pd-cli/dist/commands/workbuddy-worker.js +42 -6
  170. package/pd-cli/dist/commands/workbuddy-worker.js.map +1 -1
  171. package/pd-cli/dist/index.d.ts +1 -7
  172. package/pd-cli/dist/index.d.ts.map +1 -1
  173. package/pd-cli/dist/index.js +15 -1201
  174. package/pd-cli/dist/index.js.map +1 -1
  175. package/pd-cli/dist/program.d.ts +17 -0
  176. package/pd-cli/dist/program.d.ts.map +1 -0
  177. package/pd-cli/dist/program.js +1263 -0
  178. package/pd-cli/dist/program.js.map +1 -0
  179. package/pd-cli/dist/services/delivery-surfaces.d.ts.map +1 -1
  180. package/pd-cli/dist/services/delivery-surfaces.js +7 -5
  181. package/pd-cli/dist/services/delivery-surfaces.js.map +1 -1
  182. package/pd-cli/dist/services/version-report.d.ts.map +1 -1
  183. package/pd-cli/dist/services/version-report.js +30 -4
  184. package/pd-cli/dist/services/version-report.js.map +1 -1
  185. package/pd-cli/package.json +1 -1
  186. package/pd-mcp-server/dist/version.d.ts +1 -1
  187. package/pd-mcp-server/dist/version.js +1 -1
  188. package/pd-mcp-server/package.json +3 -1
  189. package/plugin/dist/bundle.js +544 -494
  190. package/plugin/dist/constants/tools.d.ts +8 -1
  191. package/plugin/dist/core/trajectory-retention-trigger.d.ts +13 -0
  192. package/plugin/dist/core/trajectory.d.ts +14 -0
  193. package/plugin/dist/hooks/gate-block-helper.d.ts +17 -0
  194. package/plugin/dist/hooks/gate.d.ts +6 -1
  195. package/plugin/dist/host-runtime/openclaw-host-runtime.d.ts +1 -0
  196. package/plugin/dist/index.d.ts +5 -0
  197. package/plugin/dist/openclaw.plugin.json +1 -1
  198. package/plugin/dist/rulehost-evidence.js +29 -23
  199. package/plugin/dist/templates/langs/en/skills/pd-cli-operator/SKILL.md +16 -5
  200. package/plugin/dist/templates/langs/en/skills/pd-control/SKILL.md +7 -6
  201. package/plugin/dist/templates/langs/en/skills/pd-pain-signal/SKILL.md +141 -28
  202. package/plugin/dist/templates/langs/en/skills/pd-review/SKILL.md +15 -1
  203. package/plugin/dist/templates/langs/zh/skills/pd-cli-operator/SKILL.md +16 -5
  204. package/plugin/dist/templates/langs/zh/skills/pd-control/SKILL.md +7 -6
  205. package/plugin/dist/templates/langs/zh/skills/pd-pain-signal/SKILL.md +142 -29
  206. package/plugin/dist/templates/langs/zh/skills/pd-review/SKILL.md +15 -1
  207. package/plugin/openclaw.plugin.json +1 -1
  208. package/plugin/package.json +1 -1
  209. package/plugin/templates/langs/en/skills/pd-cli-operator/SKILL.md +16 -5
  210. package/plugin/templates/langs/en/skills/pd-control/SKILL.md +7 -6
  211. package/plugin/templates/langs/en/skills/pd-pain-signal/SKILL.md +141 -28
  212. package/plugin/templates/langs/en/skills/pd-review/SKILL.md +15 -1
  213. package/plugin/templates/langs/zh/skills/pd-cli-operator/SKILL.md +16 -5
  214. package/plugin/templates/langs/zh/skills/pd-control/SKILL.md +7 -6
  215. package/plugin/templates/langs/zh/skills/pd-pain-signal/SKILL.md +142 -29
  216. package/plugin/templates/langs/zh/skills/pd-review/SKILL.md +15 -1
  217. package/release-manager/dist/installers/codex-host-installer.js +92 -5
  218. package/release-manager/dist/installers/mcp-binding-shape-mirror.js +105 -0
  219. package/release-manager/package.json +1 -1
  220. package/workbuddy-adapter/dist/codec/input-decoder.d.ts +10 -0
  221. package/workbuddy-adapter/dist/codec/input-decoder.js +62 -5
  222. package/workbuddy-adapter/dist/host-adapter.js +1 -0
  223. package/workbuddy-adapter/dist/index.d.ts +1 -0
  224. package/workbuddy-adapter/dist/index.js +1 -0
  225. package/workbuddy-adapter/dist/ingestion/catch-up.d.ts +25 -0
  226. package/workbuddy-adapter/dist/ingestion/catch-up.js +161 -0
  227. package/workbuddy-adapter/dist/ingestion/encode-cwd.d.ts +6 -0
  228. package/workbuddy-adapter/dist/ingestion/encode-cwd.js +39 -0
  229. package/workbuddy-adapter/dist/ingestion/index.d.ts +13 -0
  230. package/workbuddy-adapter/dist/ingestion/index.js +13 -0
  231. package/workbuddy-adapter/dist/ingestion/ingestion.d.ts +46 -0
  232. package/workbuddy-adapter/dist/ingestion/ingestion.js +135 -0
  233. package/workbuddy-adapter/dist/ingestion/transcript-decoder.d.ts +70 -0
  234. package/workbuddy-adapter/dist/ingestion/transcript-decoder.js +554 -0
  235. package/workbuddy-adapter/dist/ingestion/transcript-path.d.ts +39 -0
  236. package/workbuddy-adapter/dist/ingestion/transcript-path.js +117 -0
  237. package/workbuddy-adapter/dist/ingestion/transcript-source.d.ts +15 -0
  238. package/workbuddy-adapter/dist/ingestion/transcript-source.js +152 -0
  239. package/workbuddy-adapter/dist/pd-hook.d.ts +8 -0
  240. package/workbuddy-adapter/dist/pd-hook.js +59 -2
  241. package/workbuddy-adapter/dist/worker/workspace-worker.d.ts +9 -0
  242. package/workbuddy-adapter/dist/worker/workspace-worker.js +46 -17
  243. package/workbuddy-adapter/package.json +1 -1
  244. package/workbuddy-adapter/plugin/hooks/hooks.json +11 -0
  245. package/workbuddy-adapter/plugin/skills/pd-cli-operator/SKILL.md +57 -19
  246. package/workbuddy-adapter/plugin/skills/pd-control/SKILL.md +21 -9
  247. package/workbuddy-adapter/plugin/skills/pd-pain-signal/SKILL.md +72 -61
  248. package/workbuddy-adapter/plugin/skills/pd-review/SKILL.md +27 -12
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-catalog.js","sourceRoot":"","sources":["../src/skill-catalog.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 跨宿主技能交付一致性判定(纯逻辑,不做文件 I/O)。
3
+ *
4
+ * 判定口径全部来自全局清单(`skill-catalog.json`),调用方只负责把每个宿主
5
+ * 实际交付的技能目录读成 `DeliveredHost`。这样测试、迁移脚本与未来的渲染器
6
+ * 校验共用同一条规则,而不是各写一份"四个目录"的比较。
7
+ *
8
+ * 该规则**只**回答"发了几份、声明是否一致",不回答"内容是否同源"——
9
+ * 后者属于渲染 `--check` 的职责(设计 §7.3)。
10
+ */
11
+ import type { SkillCatalog } from './skill-catalog.js';
12
+ export interface DeliveredHost {
13
+ /** 交付面标识,例如 `openclaw-zh` / `codex` / `workbuddy`。 */
14
+ readonly id: string;
15
+ /** 该宿主实际交付的技能目录名。 */
16
+ readonly skills: readonly string[];
17
+ /** 其中 `SKILL.md` 缺失或为空的技能名。 */
18
+ readonly emptySkills: readonly string[];
19
+ }
20
+ /** 返回全部偏差;空数组表示一致。 */
21
+ export declare function checkSkillParity(catalog: SkillCatalog, hosts: readonly DeliveredHost[]): readonly string[];
22
+ //# sourceMappingURL=skill-delivery-parity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-delivery-parity.d.ts","sourceRoot":"","sources":["../src/skill-delivery-parity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,WAAW,aAAa;IAC5B,sDAAsD;IACtD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,qBAAqB;IACrB,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,+BAA+B;IAC/B,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC;AAED,sBAAsB;AACtB,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,SAAS,aAAa,EAAE,GAC9B,SAAS,MAAM,EAAE,CAgCnB"}
@@ -0,0 +1,31 @@
1
+ /** 返回全部偏差;空数组表示一致。 */
2
+ export function checkSkillParity(catalog, hosts) {
3
+ const problems = [];
4
+ const declared = new Set(catalog.skills.map((skill) => skill.name));
5
+ for (const { name, status, retirable } of catalog.skills) {
6
+ const hits = hosts.filter((host) => host.skills.includes(name)).map((host) => host.id);
7
+ const expected = status === 'active' ? hosts.length : 0;
8
+ if (hits.length !== expected) {
9
+ problems.push(`${name} (${status}): expected ${expected} host(s), found ${hits.length} [${hits.join(', ') || 'none'}]`);
10
+ }
11
+ if (!retirable && status !== 'active') {
12
+ problems.push(`${name}: retirable=false but status=${status}`);
13
+ }
14
+ if (status !== 'active')
15
+ continue;
16
+ for (const host of hosts) {
17
+ if (host.emptySkills.includes(name)) {
18
+ problems.push(`${name} (${host.id}): SKILL.md is missing or empty`);
19
+ }
20
+ }
21
+ }
22
+ for (const host of hosts) {
23
+ for (const name of host.skills) {
24
+ if (!declared.has(name)) {
25
+ problems.push(`${name} (${host.id}): delivered but not declared in skill-catalog.json`);
26
+ }
27
+ }
28
+ }
29
+ return problems;
30
+ }
31
+ //# sourceMappingURL=skill-delivery-parity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-delivery-parity.js","sourceRoot":"","sources":["../src/skill-delivery-parity.ts"],"names":[],"mappings":"AAqBA,sBAAsB;AACtB,MAAM,UAAU,gBAAgB,CAC9B,OAAqB,EACrB,KAA+B;IAE/B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAEpE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACzD,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvF,MAAM,QAAQ,GAAG,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACxD,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC7B,QAAQ,CAAC,IAAI,CACX,GAAG,IAAI,KAAK,MAAM,eAAe,QAAQ,mBAAmB,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,GAAG,CACzG,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,SAAS,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;YACtC,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,gCAAgC,MAAM,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,MAAM,KAAK,QAAQ;YAAE,SAAS;QAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBACpC,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC,EAAE,iCAAiC,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC/B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxB,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC,EAAE,qDAAqD,CAAC,CAAC;YAC1F,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -68,6 +68,7 @@ export interface ActivePrinciplePromptResult {
68
68
  injectedExpectationsOverflow?: number;
69
69
  }
70
70
  export interface AdaptivePackingReport {
71
+ source?: 'native_gap';
71
72
  status: 'target_present' | 'prioritized' | 'unavailable';
72
73
  reason?: string;
73
74
  targetActivationId: string;
@@ -223,6 +224,13 @@ export declare function buildActivePrinciplePromptContext(input: {
223
224
  artifactId: string;
224
225
  activationId: string;
225
226
  };
227
+ /** Select only from principles absent from the Native prompt for this invocation. */
228
+ selectNativeGap?: (candidates: readonly ActivatedPrinciple[]) => Promise<{
229
+ artifactId: string;
230
+ activationId: string;
231
+ signal?: AbortSignal;
232
+ deadlineAt?: number;
233
+ } | undefined>;
226
234
  /**
227
235
  * PRI-1140 (Owner supplementary condition): additive-only adaptive packing.
228
236
  * Only meaningful together with `adaptivePriority`. When true, the
@@ -345,11 +345,20 @@ export async function buildActivePrinciplePromptContext(input) {
345
345
  };
346
346
  const nativePacking = pack(nativeScanOrder);
347
347
  const nativeResult = makeResult(nativePacking, principles);
348
- const priority = input.adaptivePriority;
348
+ const gapPriority = input.adaptivePriority === undefined && input.selectNativeGap && warnings.length === 0
349
+ ? await input.selectNativeGap(principles.filter((principle) => !nativeResult.principleIds.includes(principle.principleId)))
350
+ : undefined;
351
+ const priority = input.adaptivePriority ?? gapPriority;
349
352
  if (priority === undefined)
350
353
  return nativeResult;
354
+ const signal = gapPriority?.signal ?? input.signal ?? new AbortController().signal;
355
+ const deadlineAt = gapPriority?.deadlineAt ?? input.deadlineAt;
356
+ const additiveOnly = gapPriority !== undefined || input.additiveOnly === true;
357
+ if (gapPriority && (signal.aborted || (deadlineAt !== undefined && Date.now() >= deadlineAt)))
358
+ return nativeResult;
351
359
  const report = (status, reason, displacedActivationIds = []) => ({
352
360
  status,
361
+ ...(gapPriority ? { source: 'native_gap' } : {}),
353
362
  ...(reason ? { reason } : {}),
354
363
  targetActivationId: typeof priority.activationId === 'string' ? priority.activationId : '',
355
364
  targetArtifactId: typeof priority.artifactId === 'string' ? priority.artifactId : '',
@@ -360,7 +369,7 @@ export async function buildActivePrinciplePromptContext(input) {
360
369
  const [nativeTarget] = nativeTargetMatches;
361
370
  const baselineHasTarget = nativePacking.included.some((principle) => principle.artifactId === priority.artifactId && principle.activationId === priority.activationId);
362
371
  const withoutTarget = (reason) => {
363
- if (nativeTargetMatches.length !== 1 || !nativeTarget)
372
+ if (gapPriority || nativeTargetMatches.length !== 1 || !nativeTarget)
364
373
  return { ...nativeResult, adaptivePacking: report('unavailable', reason) };
365
374
  const targetPrincipleId = nativeTarget.principleId;
366
375
  const safePrinciples = principles.filter((principle) => principle.principleId !== targetPrincipleId);
@@ -402,12 +411,11 @@ export async function buildActivePrinciplePromptContext(input) {
402
411
  || authorizedTarget.artifactContentSha256 !== nativeTarget.artifactContentSha256) {
403
412
  return withoutTarget('target_changed');
404
413
  }
405
- const signal = input.signal ?? new AbortController().signal;
406
414
  const targetRendered = renderPrinciplesToDirectives([nativeTarget], new Set([nativeTarget.principleId]), { escapeFn: escapeXml });
407
415
  const targetBody = targetRendered.slice(targetRendered.indexOf('<directive '), targetRendered.indexOf('</directive>') + '</directive>'.length);
408
416
  const prepared = (status, displaced = []) => ({
409
417
  ...report(status, undefined, displaced), targetSnapshot: authorizedTarget, targetBody,
410
- nativeBaseline: nativeResult, ...(input.deadlineAt !== undefined ? { deadlineAt: input.deadlineAt } : {}),
418
+ nativeBaseline: nativeResult, ...(deadlineAt !== undefined ? { deadlineAt } : {}),
411
419
  });
412
420
  if (baselineHasTarget) {
413
421
  const stillValid = await revalidateAdaptivePrinciple(input.workspaceDir, authorizedTarget, signal);
@@ -434,7 +442,7 @@ export async function buildActivePrinciplePromptContext(input) {
434
442
  // native baseline already assembled. Decided BEFORE the revalidation read so
435
443
  // a refused placement costs no further I/O; the would-be displacement is the
436
444
  // recorded reason (bounded like the other diagnostic id lists).
437
- if (input.additiveOnly === true && displacedActivationIds.length > 0) {
445
+ if (additiveOnly && displacedActivationIds.length > 0) {
438
446
  return {
439
447
  ...nativeResult,
440
448
  adaptivePacking: report('unavailable', 'would_displace_native_assembly', displacedActivationIds.slice(0, MAX_SHARED_DIAGNOSTIC_IDS)),
@@ -443,6 +451,8 @@ export async function buildActivePrinciplePromptContext(input) {
443
451
  const stillValid = await revalidateAdaptivePrinciple(input.workspaceDir, authorizedTarget, signal);
444
452
  if (!stillValid)
445
453
  return { ...nativeResult, adaptivePacking: report('unavailable', 'target_changed') };
454
+ if (gapPriority && (signal.aborted || (deadlineAt !== undefined && Date.now() >= deadlineAt)))
455
+ return nativeResult;
446
456
  const result = makeResult(prioritizedPacking, principles, prepared('prioritized', displacedActivationIds));
447
457
  // Adaptive assembly is deliberately limited to the existing renderer's Native budget cap.
448
458
  return result;
@@ -0,0 +1,142 @@
1
+ /**
2
+ * PRI-1182 — Adaptive Activation: the real Decisions scoring protocol.
3
+ *
4
+ * Extracted from the already-verified lab implementation
5
+ * (`scripts/dev/adaptive-selector-lab/diagnostic.mjs`): one POST with
6
+ * `{model, state, questions, provider}`, one `{model, answers}` response.
7
+ *
8
+ * The difference from the lab experiment is the QUESTION SET: the lab asked
9
+ * four task-level questions, while production asks one independent
10
+ * applicability condition per candidate plus one "insufficient context"
11
+ * condition. Each answer is an independent `noul` score in [0, 1] — not a
12
+ * distribution — so PD adjudicates locally instead of trusting the model to
13
+ * emit a decision.
14
+ *
15
+ * Everything here is pure: no I/O, no clock, no transport. The caller owns
16
+ * scheduling, cancellation and diagnostics.
17
+ */
18
+ export declare const ADAPTIVE_DECISION_INSUFFICIENT_QUESTION = "insufficient_context";
19
+ /**
20
+ * PRESET evaluation criteria for this acceptance batch (v1-20261111).
21
+ *
22
+ * These numbers are a deliberate preset, NOT a value derived from the old
23
+ * GLM task-level samples: the old batch scored four task-level questions and
24
+ * is not the same question set. Those samples are used ONLY to replay the
25
+ * adjudicator against already-recorded numbers:
26
+ * replay-02 .9594 .9565 .0708 insufficient .1962 → uncertain (lead below margin)
27
+ * replay-03 .0496 .9958 .2068 insufficient .1375 → selected
28
+ * replay-04 .0624 .0340 .9888 insufficient .2668 → selected
29
+ *
30
+ * Do NOT tune these per failing turn, and do not tune them while a real
31
+ * batch is running: changing them is a product decision that requires a new
32
+ * version string and a new frozen batch.
33
+ */
34
+ export declare const ADAPTIVE_DECISION_CRITERIA: {
35
+ readonly version: 'v1-20261111';
36
+ /** A candidate must reach this independent score to be eligible. */
37
+ readonly selectThreshold: 0.7;
38
+ /** The winner must lead the runner-up by this much, or the turn is ambiguous. */
39
+ readonly leadMargin: 0.25;
40
+ /** Above this "information is insufficient" score, PD refuses to select. */
41
+ readonly insufficientThreshold: 0.6;
42
+ };
43
+ export interface DecisionQuestion {
44
+ readonly type: 'noul';
45
+ readonly instructions: string;
46
+ }
47
+ export type DecisionQuestions = Record<string, DecisionQuestion>;
48
+ export interface DecisionRequestEnvelope {
49
+ readonly model: string;
50
+ readonly state: string;
51
+ readonly questions: DecisionQuestions;
52
+ readonly provider?: {
53
+ readonly only: readonly string[];
54
+ readonly allow_fallbacks: false;
55
+ };
56
+ }
57
+ export type DecisionProtocolError = 'DECISION_MODEL_MISMATCH' | 'DECISION_PROVIDER_MISMATCH' | 'DECISION_OUTPUT_INVALID' | 'DECISION_QUESTION_MISMATCH' | 'DECISION_SCORE_INVALID' | 'INPUT_REFUSED';
58
+ export interface BuildDecisionRequestInput {
59
+ readonly model: string;
60
+ readonly provider?: string;
61
+ readonly currentInstruction: string;
62
+ readonly priorMessages: readonly {
63
+ readonly text: string;
64
+ readonly source: string;
65
+ readonly index: number;
66
+ }[];
67
+ readonly candidates: readonly {
68
+ readonly ref: string;
69
+ readonly text: string;
70
+ readonly digest: string;
71
+ }[];
72
+ /** Bounded by the caller; a request larger than this is refused locally. */
73
+ readonly maxPayloadChars: number;
74
+ }
75
+ export type BuildDecisionRequestResult = {
76
+ readonly ok: true;
77
+ readonly body: DecisionRequestEnvelope;
78
+ readonly questionIds: readonly string[];
79
+ } | {
80
+ readonly ok: false;
81
+ readonly reason: DecisionProtocolError;
82
+ };
83
+ export declare function candidateQuestionId(ref: string): string;
84
+ /**
85
+ * One question per candidate (its applicability condition) plus one
86
+ * "insufficient context" question. Instructions refer to the snapshot by ref;
87
+ * the candidate text itself travels once, in `state`.
88
+ */
89
+ export declare function buildDecisionQuestions(candidates: readonly {
90
+ readonly ref: string;
91
+ readonly text: string;
92
+ }[]): DecisionQuestions;
93
+ export declare function buildDecisionRequest(input: BuildDecisionRequestInput): BuildDecisionRequestResult;
94
+ /**
95
+ * Model identity is exact against an explicit allowlist when one is frozen
96
+ * (the acceptance batch does this). Otherwise one bounded alias class is
97
+ * accepted: a `:free` tag may be absent, and a dated canonical slug
98
+ * (`<base>-YYYYMMDD`) is accepted — the two aliases the lab verified.
99
+ *
100
+ * An unregistered DATE is never accepted through the allowlist path: the
101
+ * observed id must be one of the frozen strings, so a same-prefix slug with a
102
+ * different date is a mismatch.
103
+ */
104
+ export declare function isDecisionModelIdentity(configured: string, observed: string, allowedResponseModels?: readonly string[]): boolean;
105
+ export type DecisionValidationResult = {
106
+ readonly ok: true;
107
+ readonly scores: Readonly<Record<string, number>>;
108
+ } | {
109
+ readonly ok: false;
110
+ readonly reason: DecisionProtocolError;
111
+ };
112
+ /**
113
+ * Validates model identity, provider identity (when configured), completeness
114
+ * of the exact question set, and every score range. Any missing, extra or
115
+ * malformed answer is a rejected turn — never a partial score table.
116
+ */
117
+ export declare function validateDecisionResponse(value: unknown, expected: {
118
+ readonly model: string;
119
+ readonly questionIds: readonly string[];
120
+ readonly provider?: string;
121
+ /** Frozen exact response-model allowlist. Present = exact membership only. */
122
+ readonly allowedResponseModels?: readonly string[];
123
+ }): DecisionValidationResult;
124
+ export type DecisionOutcome = {
125
+ readonly status: 'selected';
126
+ readonly ref: string;
127
+ readonly reason: 'selected';
128
+ readonly scores: Readonly<Record<string, number>>;
129
+ } | {
130
+ readonly status: 'none_applicable' | 'uncertain';
131
+ readonly ref: null;
132
+ readonly reason: 'below_selection_threshold' | 'lead_below_margin' | 'information_insufficient';
133
+ readonly scores: Readonly<Record<string, number>>;
134
+ };
135
+ /**
136
+ * Local adjudication of the INDEPENDENT condition scores. Order matters:
137
+ * insufficient information first (it invalidates any candidate ranking), then
138
+ * the eligibility threshold, then the lead margin.
139
+ */
140
+ export declare function adjudicateDecision(scores: Readonly<Record<string, number>>, candidates: readonly {
141
+ readonly ref: string;
142
+ }[], criteria?: typeof ADAPTIVE_DECISION_CRITERIA): DecisionOutcome;
@@ -0,0 +1,190 @@
1
+ /**
2
+ * PRI-1182 — Adaptive Activation: the real Decisions scoring protocol.
3
+ *
4
+ * Extracted from the already-verified lab implementation
5
+ * (`scripts/dev/adaptive-selector-lab/diagnostic.mjs`): one POST with
6
+ * `{model, state, questions, provider}`, one `{model, answers}` response.
7
+ *
8
+ * The difference from the lab experiment is the QUESTION SET: the lab asked
9
+ * four task-level questions, while production asks one independent
10
+ * applicability condition per candidate plus one "insufficient context"
11
+ * condition. Each answer is an independent `noul` score in [0, 1] — not a
12
+ * distribution — so PD adjudicates locally instead of trusting the model to
13
+ * emit a decision.
14
+ *
15
+ * Everything here is pure: no I/O, no clock, no transport. The caller owns
16
+ * scheduling, cancellation and diagnostics.
17
+ */
18
+ export const ADAPTIVE_DECISION_INSUFFICIENT_QUESTION = 'insufficient_context';
19
+ /**
20
+ * PRESET evaluation criteria for this acceptance batch (v1-20261111).
21
+ *
22
+ * These numbers are a deliberate preset, NOT a value derived from the old
23
+ * GLM task-level samples: the old batch scored four task-level questions and
24
+ * is not the same question set. Those samples are used ONLY to replay the
25
+ * adjudicator against already-recorded numbers:
26
+ * replay-02 .9594 .9565 .0708 insufficient .1962 → uncertain (lead below margin)
27
+ * replay-03 .0496 .9958 .2068 insufficient .1375 → selected
28
+ * replay-04 .0624 .0340 .9888 insufficient .2668 → selected
29
+ *
30
+ * Do NOT tune these per failing turn, and do not tune them while a real
31
+ * batch is running: changing them is a product decision that requires a new
32
+ * version string and a new frozen batch.
33
+ */
34
+ export const ADAPTIVE_DECISION_CRITERIA = {
35
+ version: 'v1-20261111',
36
+ /** A candidate must reach this independent score to be eligible. */
37
+ selectThreshold: 0.7,
38
+ /** The winner must lead the runner-up by this much, or the turn is ambiguous. */
39
+ leadMargin: 0.25,
40
+ /** Above this "information is insufficient" score, PD refuses to select. */
41
+ insufficientThreshold: 0.6,
42
+ };
43
+ export function candidateQuestionId(ref) {
44
+ return `candidate_${ref}`;
45
+ }
46
+ /**
47
+ * One question per candidate (its applicability condition) plus one
48
+ * "insufficient context" question. Instructions refer to the snapshot by ref;
49
+ * the candidate text itself travels once, in `state`.
50
+ */
51
+ export function buildDecisionQuestions(candidates) {
52
+ const questions = {};
53
+ for (const candidate of candidates) {
54
+ questions[candidateQuestionId(candidate.ref)] = {
55
+ type: 'noul',
56
+ instructions: `候选 ${candidate.ref} 的适用性:仅当当前输入明确要求交付、实现、修复、审查或验证,`
57
+ + `且补入这条尚未装配的候选(见 state.candidates.${candidate.ref})能改善下一步的具体行动时,概率接近 1;仅仅主题相关不够。`
58
+ + '仅礼貌、闲聊、元问题或与当前任务无关时,概率接近 0。',
59
+ };
60
+ }
61
+ questions[ADAPTIVE_DECISION_INSUFFICIENT_QUESTION] = {
62
+ type: 'noul',
63
+ instructions: '信息不足:当前输入是否缺少判断候选是否适用所需的信息(例如只有确认词、指代不明、'
64
+ + '不知道在问哪一个任务)?信息不足时概率接近 1;能够明确判断时为 0。',
65
+ };
66
+ return questions;
67
+ }
68
+ export function buildDecisionRequest(input) {
69
+ if (input.candidates.length === 0) {
70
+ return { ok: false, reason: 'INPUT_REFUSED' };
71
+ }
72
+ const questions = buildDecisionQuestions(input.candidates);
73
+ const state = {
74
+ currentInstruction: input.currentInstruction,
75
+ priorMessages: input.priorMessages,
76
+ candidates: input.candidates.map((candidate) => ({
77
+ ref: candidate.ref,
78
+ text: candidate.text,
79
+ digest: candidate.digest,
80
+ })),
81
+ };
82
+ const body = {
83
+ model: input.model,
84
+ state: JSON.stringify(state),
85
+ questions,
86
+ ...(input.provider
87
+ ? { provider: { only: [input.provider], allow_fallbacks: false } }
88
+ : {}),
89
+ };
90
+ if (JSON.stringify({ state: body.state, questions }).length > input.maxPayloadChars) {
91
+ return { ok: false, reason: 'INPUT_REFUSED' };
92
+ }
93
+ return {
94
+ ok: true,
95
+ body,
96
+ questionIds: [...Object.keys(questions)],
97
+ };
98
+ }
99
+ /** rc-1/rc-2: parsed JSON is unknown until these guards pass. */
100
+ function isRecord(value) {
101
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
102
+ }
103
+ /**
104
+ * Model identity is exact against an explicit allowlist when one is frozen
105
+ * (the acceptance batch does this). Otherwise one bounded alias class is
106
+ * accepted: a `:free` tag may be absent, and a dated canonical slug
107
+ * (`<base>-YYYYMMDD`) is accepted — the two aliases the lab verified.
108
+ *
109
+ * An unregistered DATE is never accepted through the allowlist path: the
110
+ * observed id must be one of the frozen strings, so a same-prefix slug with a
111
+ * different date is a mismatch.
112
+ */
113
+ export function isDecisionModelIdentity(configured, observed, allowedResponseModels) {
114
+ if (allowedResponseModels !== undefined && allowedResponseModels.length > 0) {
115
+ return allowedResponseModels.includes(observed);
116
+ }
117
+ if (configured === observed)
118
+ return true;
119
+ const base = configured.endsWith(':free') ? configured.slice(0, -':free'.length) : configured;
120
+ if (base === observed)
121
+ return true;
122
+ return new RegExp(`^${base.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&')}-\\d{8}$`, 'u').test(observed);
123
+ }
124
+ /**
125
+ * Validates model identity, provider identity (when configured), completeness
126
+ * of the exact question set, and every score range. Any missing, extra or
127
+ * malformed answer is a rejected turn — never a partial score table.
128
+ */
129
+ export function validateDecisionResponse(value, expected) {
130
+ if (!isRecord(value))
131
+ return { ok: false, reason: 'DECISION_OUTPUT_INVALID' };
132
+ const { model } = value;
133
+ if (typeof model !== 'string'
134
+ || !isDecisionModelIdentity(expected.model, model, expected.allowedResponseModels)) {
135
+ return { ok: false, reason: 'DECISION_MODEL_MISMATCH' };
136
+ }
137
+ if (expected.provider !== undefined) {
138
+ const { provider } = value;
139
+ if (provider !== undefined
140
+ && (typeof provider !== 'string' || provider.toLowerCase() !== expected.provider.toLowerCase())) {
141
+ return { ok: false, reason: 'DECISION_PROVIDER_MISMATCH' };
142
+ }
143
+ }
144
+ const { answers } = value;
145
+ if (!isRecord(answers))
146
+ return { ok: false, reason: 'DECISION_OUTPUT_INVALID' };
147
+ const answerKeys = Object.keys(answers);
148
+ if (answerKeys.length !== expected.questionIds.length
149
+ || expected.questionIds.some((id) => !Object.hasOwn(answers, id))) {
150
+ return { ok: false, reason: 'DECISION_QUESTION_MISMATCH' };
151
+ }
152
+ const scores = {};
153
+ for (const id of expected.questionIds) {
154
+ const answer = answers[id];
155
+ if (!isRecord(answer) || answer.type !== 'noul') {
156
+ return { ok: false, reason: 'DECISION_OUTPUT_INVALID' };
157
+ }
158
+ const { noul } = answer;
159
+ if (typeof noul !== 'number' || !Number.isFinite(noul) || noul < 0 || noul > 1) {
160
+ return { ok: false, reason: 'DECISION_SCORE_INVALID' };
161
+ }
162
+ scores[id] = noul;
163
+ }
164
+ return { ok: true, scores };
165
+ }
166
+ /**
167
+ * Local adjudication of the INDEPENDENT condition scores. Order matters:
168
+ * insufficient information first (it invalidates any candidate ranking), then
169
+ * the eligibility threshold, then the lead margin.
170
+ */
171
+ export function adjudicateDecision(scores, candidates, criteria = ADAPTIVE_DECISION_CRITERIA) {
172
+ const insufficient = scores[ADAPTIVE_DECISION_INSUFFICIENT_QUESTION];
173
+ if (insufficient !== undefined && insufficient >= criteria.insufficientThreshold) {
174
+ return { status: 'uncertain', ref: null, reason: 'information_insufficient', scores };
175
+ }
176
+ const ranked = candidates
177
+ .map((candidate) => ({
178
+ ref: candidate.ref,
179
+ score: scores[candidateQuestionId(candidate.ref)] ?? 0,
180
+ }))
181
+ .sort((left, right) => right.score - left.score);
182
+ const [top, runnerUp] = ranked;
183
+ if (!top || top.score < criteria.selectThreshold) {
184
+ return { status: 'none_applicable', ref: null, reason: 'below_selection_threshold', scores };
185
+ }
186
+ if (runnerUp && top.score - runnerUp.score < criteria.leadMargin) {
187
+ return { status: 'uncertain', ref: null, reason: 'lead_below_margin', scores };
188
+ }
189
+ return { status: 'selected', ref: top.ref, reason: 'selected', scores };
190
+ }
@@ -9,10 +9,16 @@
9
9
  * mapping. Any missing identity/config/model keeps the Native path unchanged.
10
10
  */
11
11
  import type { HostEvent } from '@principles/core/host';
12
- import type { PdConfig } from '@principles/core/runtime';
12
+ import type { ActivatedPrinciple, PdConfig } from '@principles/core/runtime';
13
13
  import { type AdaptiveSelectionModel } from './adaptive-selection.js';
14
14
  /** Independent switch. `features.host.codex.enabled` remains the whole-hook gate. */
15
15
  export declare const ADAPTIVE_ACTIVATION_FLAG = "host.codex.adaptive_activation";
16
+ export type AdaptiveActivationFlag = typeof ADAPTIVE_ACTIVATION_FLAG | 'host.workbuddy.adaptive_activation' | 'host.openclaw.adaptive_activation';
17
+ /**
18
+ * PRI-1182 §2: time kept back from the host window for the principle assembly
19
+ * and the hook's own output. Selection never spends the reserve.
20
+ */
21
+ export declare const ADAPTIVE_OUTPUT_RESERVE_MS = 200;
16
22
  export interface AdaptivePrioritySelection {
17
23
  readonly artifactId: string;
18
24
  readonly activationId: string;
@@ -20,7 +26,7 @@ export interface AdaptivePrioritySelection {
20
26
  readonly deadlineAt?: number;
21
27
  readonly signal?: AbortSignal;
22
28
  }
23
- export type AdaptivePriorityProvider = (event: HostEvent) => Promise<AdaptivePrioritySelection | undefined>;
29
+ export type AdaptivePriorityProvider = (event: HostEvent, candidates: readonly ActivatedPrinciple[]) => Promise<AdaptivePrioritySelection | undefined>;
24
30
  export interface AdaptiveActivationReadiness {
25
31
  readonly readiness: 'ready' | 'disabled' | 'needs_setup';
26
32
  readonly reason: string;
@@ -29,30 +35,42 @@ export interface AdaptiveActivationReadiness {
29
35
  export type AdaptiveModelResolution = {
30
36
  readonly ok: true;
31
37
  readonly model: AdaptiveSelectionModel;
32
- readonly profileId: string;
33
38
  } | {
34
39
  readonly ok: false;
40
+ readonly readiness: 'disabled' | 'needs_setup';
35
41
  readonly reason: string;
36
42
  readonly nextAction: string;
37
43
  };
38
- export declare function resolveAdaptiveSelectionModel(config: PdConfig, env: Record<string, string | undefined>): AdaptiveModelResolution;
44
+ export declare function resolveAdaptiveSelectionModel(config: PdConfig, env: Record<string, string | undefined>, flag?: AdaptiveActivationFlag): AdaptiveModelResolution;
39
45
  export interface AdaptiveSelectionDiagnosticLine {
40
46
  readonly status: string;
41
47
  readonly reason: string;
42
48
  readonly stage: string;
43
49
  readonly sends: number;
50
+ readonly requestSentAt: number | null;
44
51
  readonly firstByteAt: number | null;
45
52
  readonly generationEndedAt: number | null;
53
+ readonly validatedAt: number | null;
46
54
  readonly cancelledAt: number | null;
47
55
  readonly httpStatus: number | null;
48
56
  readonly finishReason: string;
57
+ /** Observed response model; null when no body was parsed. */
58
+ readonly modelObserved: string | null;
59
+ /** Observed response provider; null when absent or no body was parsed. */
60
+ readonly providerObserved: string | null;
61
+ /** Bounded local adjudication evidence (ids only, never prompt text). */
62
+ readonly decision: {
63
+ readonly status: string;
64
+ readonly ref: string | null;
65
+ readonly reason: string;
66
+ readonly scores: Readonly<Record<string, number>>;
67
+ } | null;
49
68
  readonly failures: readonly string[];
50
69
  }
51
70
  export interface CreateAdaptivePriorityProviderOptions {
52
71
  readonly workspaceDir: string;
53
72
  readonly model: AdaptiveSelectionModel;
54
- readonly firstByteTimeoutMs?: number;
55
- readonly generationTimeoutMs?: number;
73
+ readonly requestTimeoutMs?: number;
56
74
  /**
57
75
  * Absolute host deadline (Codex: the plugin hook window minus the Native
58
76
  * reserve). Selection, revalidation and packing all share it: a selection
@@ -60,13 +78,19 @@ export interface CreateAdaptivePriorityProviderOptions {
60
78
  */
61
79
  readonly outerDeadlineAt?: number;
62
80
  /**
63
- * PRI-1181: below this remaining budget the turn is skipped before the
64
- * candidate read — no model request is sent at all. Defaults to the measured
65
- * minimum (`ADAPTIVE_SKIP_LIMITS.minRemainingBudgetMs`); 0 disables the gate
66
- * for scenarios that isolate transport cancellation.
81
+ * PRI-1182 §2: reserved for assembly and output after the decision. The
82
+ * effective deadline is the earlier of the host's remaining window (minus
83
+ * this reserve) and the request's own short limit.
84
+ */
85
+ readonly outputReserveMs?: number;
86
+ /**
87
+ * PRI-1181/PRI-1182: below this remaining budget the turn is skipped before
88
+ * the candidate read — no model request is sent at all. Defaults to the
89
+ * request's minimum executable envelope
90
+ * (`ADAPTIVE_SKIP_LIMITS.minExecutableBudgetMs`); 0 disables the gate for
91
+ * scenarios that isolate transport cancellation.
67
92
  */
68
- readonly minRemainingBudgetMs?: number;
69
- readonly maxTokens?: number;
93
+ readonly minExecutableBudgetMs?: number;
70
94
  readonly now?: () => number;
71
95
  /** Test seam: production uses the global transport. */
72
96
  readonly fetchImpl?: typeof fetch;
@@ -81,12 +105,12 @@ export type AdaptivePriorityProviderResolution = (AdaptiveActivationReadiness &
81
105
  readonly ok: true;
82
106
  readonly readiness: 'ready';
83
107
  readonly provider: AdaptivePriorityProvider;
84
- readonly profileId: string;
85
108
  }) | (AdaptiveActivationReadiness & {
86
109
  readonly ok: false;
87
110
  });
88
111
  export interface CreateAdaptiveProviderFromConfigOptions extends Omit<CreateAdaptivePriorityProviderOptions, 'workspaceDir' | 'model'> {
89
112
  readonly env?: Record<string, string | undefined>;
113
+ readonly flag?: AdaptiveActivationFlag;
90
114
  }
91
115
  /**
92
116
  * Config-first factory for hosts (Codex pd-hook) that already loaded the