@miller-tech/uap 1.163.13 → 1.165.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 (142) hide show
  1. package/README.md +1 -1
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/bin/cli.js +5 -4
  4. package/dist/bin/cli.js.map +1 -1
  5. package/dist/browser/web-browser.d.ts +7 -0
  6. package/dist/browser/web-browser.d.ts.map +1 -1
  7. package/dist/browser/web-browser.js +15 -0
  8. package/dist/browser/web-browser.js.map +1 -1
  9. package/dist/cli/deliver.d.ts +32 -3
  10. package/dist/cli/deliver.d.ts.map +1 -1
  11. package/dist/cli/deliver.js +198 -31
  12. package/dist/cli/deliver.js.map +1 -1
  13. package/dist/cli/guided-setup.d.ts.map +1 -1
  14. package/dist/cli/guided-setup.js +13 -1
  15. package/dist/cli/guided-setup.js.map +1 -1
  16. package/dist/cli/model.d.ts.map +1 -1
  17. package/dist/cli/model.js +9 -1
  18. package/dist/cli/model.js.map +1 -1
  19. package/dist/cli/proxy-lifecycle.d.ts +66 -13
  20. package/dist/cli/proxy-lifecycle.d.ts.map +1 -1
  21. package/dist/cli/proxy-lifecycle.js +116 -49
  22. package/dist/cli/proxy-lifecycle.js.map +1 -1
  23. package/dist/cli/proxy.d.ts +46 -0
  24. package/dist/cli/proxy.d.ts.map +1 -1
  25. package/dist/cli/proxy.js +353 -23
  26. package/dist/cli/proxy.js.map +1 -1
  27. package/dist/cli/verify.d.ts +6 -0
  28. package/dist/cli/verify.d.ts.map +1 -1
  29. package/dist/cli/verify.js +64 -0
  30. package/dist/cli/verify.js.map +1 -1
  31. package/dist/cli/wizard-config.d.ts +4 -0
  32. package/dist/cli/wizard-config.d.ts.map +1 -1
  33. package/dist/cli/wizard-config.js +14 -3
  34. package/dist/cli/wizard-config.js.map +1 -1
  35. package/dist/config/settings-registry.d.ts.map +1 -1
  36. package/dist/config/settings-registry.js +25 -0
  37. package/dist/config/settings-registry.js.map +1 -1
  38. package/dist/coordination/effort-profile.d.ts +39 -0
  39. package/dist/coordination/effort-profile.d.ts.map +1 -0
  40. package/dist/coordination/effort-profile.js +74 -0
  41. package/dist/coordination/effort-profile.js.map +1 -0
  42. package/dist/dashboard/server.d.ts.map +1 -1
  43. package/dist/dashboard/server.js +68 -10
  44. package/dist/dashboard/server.js.map +1 -1
  45. package/dist/delivery/agentic-executor.d.ts +15 -0
  46. package/dist/delivery/agentic-executor.d.ts.map +1 -1
  47. package/dist/delivery/agentic-executor.js +64 -3
  48. package/dist/delivery/agentic-executor.js.map +1 -1
  49. package/dist/delivery/convergence-loop.d.ts +76 -1
  50. package/dist/delivery/convergence-loop.d.ts.map +1 -1
  51. package/dist/delivery/convergence-loop.js +71 -6
  52. package/dist/delivery/convergence-loop.js.map +1 -1
  53. package/dist/delivery/critic.d.ts +7 -0
  54. package/dist/delivery/critic.d.ts.map +1 -1
  55. package/dist/delivery/critic.js.map +1 -1
  56. package/dist/delivery/decompose.d.ts +9 -0
  57. package/dist/delivery/decompose.d.ts.map +1 -1
  58. package/dist/delivery/decompose.js +11 -0
  59. package/dist/delivery/decompose.js.map +1 -1
  60. package/dist/delivery/execution-gate.d.ts +4 -0
  61. package/dist/delivery/execution-gate.d.ts.map +1 -1
  62. package/dist/delivery/execution-gate.js +194 -2
  63. package/dist/delivery/execution-gate.js.map +1 -1
  64. package/dist/delivery/graph-safety.d.ts +75 -0
  65. package/dist/delivery/graph-safety.d.ts.map +1 -0
  66. package/dist/delivery/graph-safety.js +98 -0
  67. package/dist/delivery/graph-safety.js.map +1 -0
  68. package/dist/delivery/mission-acceptance.d.ts.map +1 -1
  69. package/dist/delivery/mission-acceptance.js +69 -21
  70. package/dist/delivery/mission-acceptance.js.map +1 -1
  71. package/dist/delivery/per-phase-escalation-controller.d.ts +37 -0
  72. package/dist/delivery/per-phase-escalation-controller.d.ts.map +1 -0
  73. package/dist/delivery/per-phase-escalation-controller.js +68 -0
  74. package/dist/delivery/per-phase-escalation-controller.js.map +1 -0
  75. package/dist/delivery/per-phase-escalation.d.ts +53 -0
  76. package/dist/delivery/per-phase-escalation.d.ts.map +1 -0
  77. package/dist/delivery/per-phase-escalation.js +57 -0
  78. package/dist/delivery/per-phase-escalation.js.map +1 -0
  79. package/dist/delivery/reflect.d.ts +56 -0
  80. package/dist/delivery/reflect.d.ts.map +1 -0
  81. package/dist/delivery/reflect.js +79 -0
  82. package/dist/delivery/reflect.js.map +1 -0
  83. package/dist/delivery/user-paths.d.ts +42 -0
  84. package/dist/delivery/user-paths.d.ts.map +1 -1
  85. package/dist/delivery/user-paths.js +254 -6
  86. package/dist/delivery/user-paths.js.map +1 -1
  87. package/dist/delivery/user-validation.d.ts.map +1 -1
  88. package/dist/delivery/user-validation.js +21 -1
  89. package/dist/delivery/user-validation.js.map +1 -1
  90. package/dist/delivery/verification-provenance.d.ts +47 -0
  91. package/dist/delivery/verification-provenance.d.ts.map +1 -0
  92. package/dist/delivery/verification-provenance.js +48 -0
  93. package/dist/delivery/verification-provenance.js.map +1 -0
  94. package/dist/delivery/vision-judge.d.ts.map +1 -1
  95. package/dist/delivery/vision-judge.js +8 -1
  96. package/dist/delivery/vision-judge.js.map +1 -1
  97. package/dist/models/complexity.d.ts +36 -0
  98. package/dist/models/complexity.d.ts.map +1 -0
  99. package/dist/models/complexity.js +75 -0
  100. package/dist/models/complexity.js.map +1 -0
  101. package/dist/models/openai-compat-client.d.ts +26 -0
  102. package/dist/models/openai-compat-client.d.ts.map +1 -1
  103. package/dist/models/openai-compat-client.js +60 -8
  104. package/dist/models/openai-compat-client.js.map +1 -1
  105. package/dist/models/router.d.ts.map +1 -1
  106. package/dist/models/router.js +39 -10
  107. package/dist/models/router.js.map +1 -1
  108. package/dist/models/types.d.ts +60 -10
  109. package/dist/models/types.d.ts.map +1 -1
  110. package/dist/models/types.js +128 -11
  111. package/dist/models/types.js.map +1 -1
  112. package/dist/self-tuning/prompt-variants.d.ts +93 -0
  113. package/dist/self-tuning/prompt-variants.d.ts.map +1 -0
  114. package/dist/self-tuning/prompt-variants.js +143 -0
  115. package/dist/self-tuning/prompt-variants.js.map +1 -0
  116. package/dist/tasks/types.d.ts +2 -2
  117. package/dist/types/config.d.ts +8 -0
  118. package/dist/types/config.d.ts.map +1 -1
  119. package/docs/INDEX.md +1 -1
  120. package/docs/benchmarks/COMPREHENSIVE_BENCHMARKS.md +47 -53
  121. package/docs/benchmarks/VALIDATION_RESULTS.md +0 -2
  122. package/docs/guides/COORDINATION.md +1 -1
  123. package/docs/guides/DEPLOY_BATCHING.md +1 -1
  124. package/docs/guides/DROIDS_AND_SKILLS.md +3 -2
  125. package/docs/guides/LOCAL_MODELS.md +1 -1
  126. package/docs/guides/MCP_ROUTER.md +1 -1
  127. package/docs/guides/MEMORY.md +2 -2
  128. package/docs/guides/MULTI_MODEL.md +1 -1
  129. package/docs/guides/POLICIES.md +1 -1
  130. package/docs/guides/PROXY.md +47 -4
  131. package/docs/guides/SANDBOX.md +1 -1
  132. package/docs/guides/WORKTREE_WORKFLOW.md +1 -1
  133. package/docs/reference/CLI.md +16 -3
  134. package/docs/reference/CONFIGURATION.md +1 -1
  135. package/docs/reference/FEATURES.md +1 -1
  136. package/package.json +1 -1
  137. package/src/policies/enforcers/__pycache__/_common.cpython-312.pyc +0 -0
  138. package/src/policies/enforcers/iac_plan_destruction_check.py +32 -4
  139. package/templates/hooks/__pycache__/deliver_autoroute.cpython-312.pyc +0 -0
  140. package/templates/hooks/session-end.sh +9 -0
  141. package/templates/hooks/session-start.sh +10 -0
  142. package/tools/agents/scripts/__pycache__/toolcall_path_normalizer.cpython-312.pyc +0 -0
@@ -99,45 +99,85 @@ export function buildMissionAcceptanceGate(deps) {
99
99
  const userPathsNote = deps.userPathsNote ?? buildUserPathsNote;
100
100
  // eslint-disable-next-line no-console
101
101
  const note = deps.note ?? ((line) => console.log(line));
102
- return async (root) => {
102
+ return async (root, gateCtx) => {
103
+ // Explicit `=== false` — an undefined ctx means the caller did not tell us,
104
+ // which must not be read as "the ladder was green".
105
+ const ladderRed = gateCtx?.ladderPassed === false;
103
106
  // Primary mode: the only objective rung is the trivial bootstrap, and the
104
107
  // real execution gate joins via redetect only on the NEXT turn (one-turn
105
108
  // lag). So gate the artifact's runtime HERE too — idempotent with the
106
109
  // redetected execution rung on later turns.
110
+ //
111
+ // SECONDARY mode (objective gates exist) under MAX FIDELITY also runs the
112
+ // vision review here. It used to run only in primary mode, so a run whose
113
+ // only red rung was a synthetic anti-vacuous self-gate never reached vision:
114
+ // the ladder stayed red, the aesthetic review was skipped, and the model
115
+ // stalled with no visual feedback while fidelity-max verify still BLOCKED
116
+ // delivery on that same vision score (Generator≠Evaluator). Ordering is
117
+ // preserved: the review runs only once the deliverable is OPERATIONAL
118
+ // (execution passes) and BEHAVING as specified (user paths not failing) —
119
+ // never grade pixels of an app that does not run or misbehaves.
120
+ const fidelity = resolveFidelity(root);
107
121
  let visualNote = '';
108
- if (deps.primary) {
122
+ if (deps.primary || fidelity.max) {
109
123
  const exec = await executionGate(root);
110
124
  if (!exec.passed) {
125
+ // Operational gate: a build that does not run cannot be accepted, in
126
+ // either mode. (In secondary mode this gate only runs on a red ladder
127
+ // under runAcceptanceDespiteLadder; returning here avoids judging /
128
+ // grading a broken build.)
111
129
  return {
112
130
  passed: false,
113
131
  feedback: `EXECUTION FAILED — the code must run before it can be accepted:\n${exec.outputTail}`,
114
132
  };
115
133
  }
116
- // Visual gate: watch the artifact RUN — the observation summary becomes
117
- // judge evidence (a code-evidence judge cannot see a never-started
118
- // animation; this can).
119
- const visual = await visualGate(root);
120
- if (!visual.skipped && !visual.passed) {
121
- return { passed: false, feedback: visual.feedback };
122
- }
123
- visualNote = visualRuntimeNote(visual);
124
- // Fidelity-max: the loop must converge against the SAME aesthetic bar
125
- // verify enforces, or "delivered" and "verified" diverge (run Y).
126
- if (!visual.skipped) {
127
- const visionReview = deps.visionReview ?? visionAcceptanceFeedback;
128
- const shots = visual.pages.flatMap((pg) => pg.screenshots.slice(-1));
129
- const visionFail = await visionReview(root, deps.specs.resolve(root), shots);
130
- if (visionFail) {
131
- return { passed: false, feedback: visionFail };
134
+ else {
135
+ // Behavioral gate: do not grade how it LOOKS while user paths FAIL —
136
+ // fix the broken UX first (the required ordering).
137
+ const uv = userPathsNote(root);
138
+ const behavioralFailing = Boolean(uv?.trusted && /User-path validation FAILED/.test(uv.note));
139
+ if (!behavioralFailing) {
140
+ // Visual gate: watch the artifact RUN — the observation summary becomes
141
+ // judge evidence (a code-evidence judge cannot see a never-started
142
+ // animation; this can).
143
+ const visual = await visualGate(root);
144
+ if (!visual.skipped && !visual.passed && deps.primary) {
145
+ return { passed: false, feedback: visual.feedback };
146
+ }
147
+ visualNote = visualRuntimeNote(visual);
148
+ // Fidelity-max: the loop must converge against the SAME aesthetic bar
149
+ // verify enforces, or "delivered" and "verified" diverge (run Y).
150
+ // Runs in primary mode (always, as before) and in secondary mode under
151
+ // max fidelity (the new path that breaks the self-gate catch-22).
152
+ if (!visual.skipped && (deps.primary || fidelity.max)) {
153
+ const visionReview = deps.visionReview ?? visionAcceptanceFeedback;
154
+ const shots = visual.pages.flatMap((pg) => pg.screenshots.slice(-1));
155
+ const visionFail = await visionReview(root, deps.specs.resolve(root), shots);
156
+ if (visionFail) {
157
+ return { passed: false, feedback: visionFail };
158
+ }
159
+ }
132
160
  }
133
161
  }
134
162
  }
135
163
  const resolvedSpec = deps.specs.resolve(root);
136
164
  const uvNote = userPathsNote(root);
165
+ // The secondary-mode note asserts the objective gates passed. That was safe
166
+ // while acceptance only ever ran on a green ladder; under
167
+ // runAcceptanceDespiteLadder it would instruct the judge to treat FAILING
168
+ // build/test requirements as objectively verified — a direct route to
169
+ // accepting criteria the gates are actively rejecting.
137
170
  const baseNote = deps.primary
138
171
  ? visualNote
139
- : 'Objective project gates (build/test suite) ALL PASSED on this turn — treat test/build-related requirements as objectively verified.';
140
- const runtimeNote = [baseNote, uvNote?.note].filter(Boolean).join(' ');
172
+ : ladderRed
173
+ ? 'Objective project gates are currently FAILING on this turn — do NOT treat build/test-related requirements as verified. Judge only what the evidence supports.'
174
+ : 'Objective project gates (build/test suite) ALL PASSED on this turn — treat test/build-related requirements as objectively verified.';
175
+ // The visual observation is real evidence in BOTH modes; discarding it in
176
+ // secondary mode meant paying for a headless browser pass and then throwing
177
+ // the result away.
178
+ const runtimeNote = [baseNote, deps.primary ? '' : visualNote, uvNote?.note]
179
+ .filter(Boolean)
180
+ .join(' ');
141
181
  const r = await judge({
142
182
  spec: resolvedSpec,
143
183
  projectRoot: root,
@@ -147,7 +187,15 @@ export function buildMissionAcceptanceGate(deps) {
147
187
  const verdict = resolveAcceptanceVerdict(r, deps.primary);
148
188
  // Secondary mode only: bounded consecutive judge rejections of
149
189
  // objectively-green turns hand the verdict back to the gates.
150
- if (!deps.primary) {
190
+ //
191
+ // `ladderRed` is load-bearing. The breaker's contract is "the gates say yes,
192
+ // the judge keeps saying no — trust the gates", and it only resets its counter
193
+ // on a PASSING verdict. Feed it red turns (as runAcceptanceDespiteLadder now
194
+ // can) and the count climbs on turns where the gates are saying no too; once
195
+ // it trips it never resets, so every later turn is force-accepted — including
196
+ // the turn the ladder finally goes green, delivering with the judge still
197
+ // holding that the spec is unmet. Red turns are simply not its business.
198
+ if (!deps.primary && !ladderRed) {
151
199
  const checked = deps.specs.breaker(resolvedSpec, root).check(resolvedSpec, verdict);
152
200
  if (checked.overridden) {
153
201
  note('⚖ acceptance: judge rejected consecutive objectively-green turns — accepting on gates (raise UAP_DELIVER_ACCEPTANCE_FLIP_LIMIT to let the judge argue longer)');
@@ -1 +1 @@
1
- {"version":3,"file":"mission-acceptance.js","sourceRoot":"","sources":["../../src/delivery/mission-acceptance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GAEvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,aAAa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AAG,CAAC,CAAC;QACb,MAAM,CAAC,GAAG,MAAM,KAAK,CAAC;YACpB,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,IAAI;YACjB,QAAQ,EAAE,IAAI,CAAC,aAAa;YAC5B,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACxC,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,wBAAwB,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1D,+DAA+D;QAC/D,8DAA8D;QAC9D,EAAE;QACF,6EAA6E;QAC7E,+EAA+E;QAC/E,6EAA6E;QAC7E,6EAA6E;QAC7E,8EAA8E;QAC9E,0EAA0E;QAC1E,yEAAyE;QACzE,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;YAChC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;YACpF,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,IAAI,CACF,+JAA+J,CAChK,CAAC;YACJ,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Per-phase escalation controller (integration of S5 into the loop).
3
+ *
4
+ * A stagnation-driven `onIteration` hook that walks the EXECUTE phase's
5
+ * escalation chain (S5 `resolveEscalation`) rung by rung, then the capability
6
+ * ceiling — superseding the single global `escalateModel` with the full
7
+ * per-(tier, phase) ladder. The single-executor convergence loop can only host
8
+ * the execute-phase ladder; plan/review/reflect ladders belong at the
9
+ * orchestrator layer (they run distinct executors). This controller composes via
10
+ * `composeIterationHooks`, so no loop-core change is needed — it just emits
11
+ * `switchExecutor` directives, exactly like the existing escalation controller.
12
+ */
13
+ import type { IterationRecord, IterationDirective, LoopExecutor } from './convergence-loop.js';
14
+ import type { RoutingPreset, TaskComplexity } from '../models/types.js';
15
+ import type { EscalationScope } from '../coordination/effort-profile.js';
16
+ export interface PerPhaseEscalationConfig {
17
+ preset: RoutingPreset;
18
+ complexity?: TaskComplexity;
19
+ /** Effort scope gating whether the execute phase may escalate at all. */
20
+ scope: EscalationScope;
21
+ /** Bind a resolved model id to a LoopExecutor (provided by the CLI). */
22
+ bindExecutor: (modelId: string) => LoopExecutor;
23
+ stagnationTurns?: number;
24
+ improvementEpsilon?: number;
25
+ onEscalate?: (info: {
26
+ rung: number;
27
+ model: string;
28
+ policy: 'fixed' | 'capability';
29
+ }) => void;
30
+ }
31
+ export interface PerPhaseEscalationController {
32
+ onIteration: (record: IterationRecord) => IterationDirective;
33
+ /** Current execute-phase rung (0 = primary, ≥1 = escalated). For tests. */
34
+ rung: () => number;
35
+ }
36
+ export declare function createPerPhaseEscalationController(cfg: PerPhaseEscalationConfig): PerPhaseEscalationController;
37
+ //# sourceMappingURL=per-phase-escalation-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"per-phase-escalation-controller.d.ts","sourceRoot":"","sources":["../../src/delivery/per-phase-escalation-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE/F,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAKzE,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,yEAAyE;IACzE,KAAK,EAAE,eAAe,CAAC;IACvB,wEAAwE;IACxE,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,YAAY,CAAC;IAChD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,GAAG,YAAY,CAAA;KAAE,KAAK,IAAI,CAAC;CAC9F;AAED,MAAM,WAAW,4BAA4B;IAC3C,WAAW,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,kBAAkB,CAAC;IAC7D,2EAA2E;IAC3E,IAAI,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,wBAAgB,kCAAkC,CAChD,GAAG,EAAE,wBAAwB,GAC5B,4BAA4B,CAiD9B"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Per-phase escalation controller (integration of S5 into the loop).
3
+ *
4
+ * A stagnation-driven `onIteration` hook that walks the EXECUTE phase's
5
+ * escalation chain (S5 `resolveEscalation`) rung by rung, then the capability
6
+ * ceiling — superseding the single global `escalateModel` with the full
7
+ * per-(tier, phase) ladder. The single-executor convergence loop can only host
8
+ * the execute-phase ladder; plan/review/reflect ladders belong at the
9
+ * orchestrator layer (they run distinct executors). This controller composes via
10
+ * `composeIterationHooks`, so no loop-core change is needed — it just emits
11
+ * `switchExecutor` directives, exactly like the existing escalation controller.
12
+ */
13
+ import { resolveEscalation, phaseMayEscalate } from './per-phase-escalation.js';
14
+ const DEFAULT_STAGNATION_TURNS = 2;
15
+ const DEFAULT_EPSILON = 0.01;
16
+ export function createPerPhaseEscalationController(cfg) {
17
+ const stagnationTurns = cfg.stagnationTurns ?? DEFAULT_STAGNATION_TURNS;
18
+ const epsilon = cfg.improvementEpsilon ?? DEFAULT_EPSILON;
19
+ let bestScore = -1;
20
+ let stagnant = 0;
21
+ let rung = 0; // 0 = the primary model already running; escalate from rung 1
22
+ let ceilingReached = false;
23
+ return {
24
+ rung: () => rung,
25
+ onIteration: (record) => {
26
+ if (record.passed)
27
+ return {};
28
+ if (!phaseMayEscalate('execute', cfg.scope))
29
+ return {};
30
+ // Don't let infra flakiness (an executor error / never-verified turn,
31
+ // both score 0) count toward stagnation and walk the ladder to the
32
+ // ceiling — mirror the loop's own `inconclusive` guard.
33
+ if (record.executorError || record.gateResults.length === 0)
34
+ return {};
35
+ // Once at the capability ceiling there is nothing stronger to switch to;
36
+ // stop re-binding the same model every stagnation window.
37
+ if (ceilingReached)
38
+ return {};
39
+ if (record.score > bestScore + epsilon) {
40
+ bestScore = record.score;
41
+ stagnant = 0;
42
+ return {};
43
+ }
44
+ stagnant += 1;
45
+ if (record.score > bestScore)
46
+ bestScore = record.score;
47
+ if (stagnant < stagnationTurns)
48
+ return {};
49
+ // Stagnated — advance one execute rung along the chain / to the ceiling.
50
+ rung += 1;
51
+ stagnant = 0;
52
+ const step = resolveEscalation({
53
+ preset: cfg.preset,
54
+ complexity: cfg.complexity,
55
+ phase: 'execute',
56
+ rung,
57
+ });
58
+ if (step.exhausted)
59
+ ceilingReached = true;
60
+ cfg.onEscalate?.({ rung, model: step.model, policy: step.policy });
61
+ return {
62
+ switchExecutor: cfg.bindExecutor(step.model),
63
+ note: `per-phase escalate execute → ${step.model} (rung ${rung}, ${step.policy})`,
64
+ };
65
+ },
66
+ };
67
+ }
68
+ //# sourceMappingURL=per-phase-escalation-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"per-phase-escalation-controller.js","sourceRoot":"","sources":["../../src/delivery/per-phase-escalation-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAIhF,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAM,eAAe,GAAG,IAAI,CAAC;AAoB7B,MAAM,UAAU,kCAAkC,CAChD,GAA6B;IAE7B,MAAM,eAAe,GAAG,GAAG,CAAC,eAAe,IAAI,wBAAwB,CAA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AAC,UAAU;gBAC1B,KAAK,EAAE,SAAS;gBAChB,IAAI;aACL,CAAC,CAAC;YACH,IAAI,IAAI,CAAC,SAAS;gBAAE,cAAc,GAAG,IAAI,CAAC;YAC1C,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YACnE,OAAO;gBACL,cAAc,EAAE,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;gBAC5C,IAAI,EAAE,gCAAgC,IAAI,CAAC,KAAK,UAAU,IAAI,KAAK,IAAI,CAAC,MAAM,GAAG;aAClF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Per-phase escalation — hybrid policy (S5).
3
+ *
4
+ * Generalizes the single global escalate-model (repair-escalation.ts's
5
+ * resolveEscalateModelId) into a per-(tier, phase) escalation ladder that
6
+ * composes S3's per-phase model chains:
7
+ * - rungs 0..n-1 walk the FIXED chain for the (tier, phase) — deterministic,
8
+ * testable (e.g. execute: qwen → sonnet → opus);
9
+ * - once the chain is exhausted, the FINAL rung defers to a CAPABILITY-driven
10
+ * pick (the adaptive ceiling) — the "hybrid" the design selected.
11
+ *
12
+ * Pure and injectable: the capability pick is a parameter so the real
13
+ * unified-router selector can be wired in without changing this contract. Each
14
+ * phase escalates on its OWN ladder, so a stalled execute phase advances the
15
+ * execute chain without disturbing the review/plan phases (Generator≠Evaluator
16
+ * is preserved because review/execute chains are independent).
17
+ */
18
+ import { type RoutingPreset, type Phase, type TaskComplexity } from '../models/types.js';
19
+ import type { EscalationScope } from '../coordination/effort-profile.js';
20
+ export type EscalationPolicy = 'fixed' | 'capability';
21
+ export interface EscalationStep {
22
+ /** The model id to run this rung on. */
23
+ model: string;
24
+ /** Whether this rung came from the fixed chain or the capability ceiling. */
25
+ policy: EscalationPolicy;
26
+ /** The (clamped) rung index that produced this step. */
27
+ rung: number;
28
+ /** True once the fixed chain is exhausted (capability fallback engaged). */
29
+ exhausted: boolean;
30
+ }
31
+ /** Default capability ceiling: the preset's fallback role, else the last model
32
+ * in the preset's model list, else the executor role. */
33
+ export declare function defaultCapabilityPick(preset: RoutingPreset): string;
34
+ /**
35
+ * Resolve the model for an escalation rung of a (tier, phase). Hybrid policy:
36
+ * fixed chain first, capability-driven ceiling once exhausted. PURE.
37
+ */
38
+ export declare function resolveEscalation(opts: {
39
+ preset: RoutingPreset;
40
+ complexity?: TaskComplexity;
41
+ phase: Phase;
42
+ /** 0-based escalation rung (0 = primary, 1 = first escalation, …). */
43
+ rung: number;
44
+ /** Injectable capability picker for the final rung; defaults to the ceiling. */
45
+ capabilityPick?: (preset: RoutingPreset) => string;
46
+ }): EscalationStep;
47
+ /**
48
+ * Whether a phase is allowed to escalate under an effort scope. `execute` is
49
+ * always allowed; `plan` only under plan+/all scopes; `review`/`reflect` only
50
+ * under `all`/`all+fallback`; `fallback` only under `all+fallback`.
51
+ */
52
+ export declare function phaseMayEscalate(phase: Phase, scope: EscalationScope): boolean;
53
+ //# sourceMappingURL=per-phase-escalation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"per-phase-escalation.d.ts","sourceRoot":"","sources":["../../src/delivery/per-phase-escalation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAqB,KAAK,aAAa,EAAE,KAAK,KAAK,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC5G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEzE,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,YAAY,CAAC;AAEtD,MAAM,WAAW,cAAc;IAC7B,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,MAAM,EAAE,gBAAgB,CAAC;IACzB,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;yDACyD;AACzD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAEnE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACtC,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,KAAK,EAAE,KAAK,CAAC;IACb,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,MAAM,CAAC;CACpD,GAAG,cAAc,CAQjB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAc9E"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Per-phase escalation — hybrid policy (S5).
3
+ *
4
+ * Generalizes the single global escalate-model (repair-escalation.ts's
5
+ * resolveEscalateModelId) into a per-(tier, phase) escalation ladder that
6
+ * composes S3's per-phase model chains:
7
+ * - rungs 0..n-1 walk the FIXED chain for the (tier, phase) — deterministic,
8
+ * testable (e.g. execute: qwen → sonnet → opus);
9
+ * - once the chain is exhausted, the FINAL rung defers to a CAPABILITY-driven
10
+ * pick (the adaptive ceiling) — the "hybrid" the design selected.
11
+ *
12
+ * Pure and injectable: the capability pick is a parameter so the real
13
+ * unified-router selector can be wired in without changing this contract. Each
14
+ * phase escalates on its OWN ladder, so a stalled execute phase advances the
15
+ * execute chain without disturbing the review/plan phases (Generator≠Evaluator
16
+ * is preserved because review/execute chains are independent).
17
+ */
18
+ import { resolvePhaseChain } from '../models/types.js';
19
+ /** Default capability ceiling: the preset's fallback role, else the last model
20
+ * in the preset's model list, else the executor role. */
21
+ export function defaultCapabilityPick(preset) {
22
+ return preset.roles.fallback ?? preset.models[preset.models.length - 1] ?? preset.roles.executor;
23
+ }
24
+ /**
25
+ * Resolve the model for an escalation rung of a (tier, phase). Hybrid policy:
26
+ * fixed chain first, capability-driven ceiling once exhausted. PURE.
27
+ */
28
+ export function resolveEscalation(opts) {
29
+ const chain = resolvePhaseChain(opts.preset, { complexity: opts.complexity, phase: opts.phase });
30
+ const rung = Math.max(0, Math.floor(opts.rung));
31
+ if (chain.length > 0 && rung < chain.length) {
32
+ return { model: chain[rung], policy: 'fixed', rung, exhausted: false };
33
+ }
34
+ const pick = opts.capabilityPick ?? defaultCapabilityPick;
35
+ return { model: pick(opts.preset), policy: 'capability', rung, exhausted: true };
36
+ }
37
+ /**
38
+ * Whether a phase is allowed to escalate under an effort scope. `execute` is
39
+ * always allowed; `plan` only under plan+/all scopes; `review`/`reflect` only
40
+ * under `all`/`all+fallback`; `fallback` only under `all+fallback`.
41
+ */
42
+ export function phaseMayEscalate(phase, scope) {
43
+ switch (phase) {
44
+ case 'execute':
45
+ return scope !== 'fallback';
46
+ case 'plan':
47
+ return scope === 'plan+execute' || scope === 'all' || scope === 'all+fallback';
48
+ case 'review':
49
+ case 'reflect':
50
+ return scope === 'all' || scope === 'all+fallback';
51
+ case 'fallback':
52
+ return scope === 'all+fallback' || scope === 'fallback';
53
+ default:
54
+ return false;
55
+ }
56
+ }
57
+ //# sourceMappingURL=per-phase-escalation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"per-phase-escalation.js","sourceRoot":"","sources":["../../src/delivery/per-phase-escalation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,iBAAiB,EAAuD,MAAM,oBAAoB,CAAC;AAgB5G;yDACyD;AACzD,MAAM,UAAU,qBAAqB,CAAC,MAAqB;IACzD,OAAO,MAAM,CAAC,KAAK,CAAC,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC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K,CAAC;IACjB,CAAC;AACH,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * GEPA-style reflect phase (S6).
3
+ *
4
+ * Upgrades the loop's reflection from "fix-list for the next turn" (critic.ts)
5
+ * to "reflect on WHY the approach failed → rewrite the approach/instruction →
6
+ * retry", with a Pareto archive of the best reflected candidates so the loop
7
+ * reseeds from proven approaches instead of always mutating the latest one
8
+ * (which collapses to a local optimum — the same anti-Goodhart insight as the
9
+ * per-phase Generator≠Evaluator rule).
10
+ *
11
+ * This module is pure: the archive + the rewrite parser. The live wiring
12
+ * (a reflect turn before model escalation, feeding IterationDirective
13
+ * .mutateInstruction into the PromptBuilder) is the consumption step.
14
+ */
15
+ export interface ApproachRewrite {
16
+ /** Reflection: why the prior approach/reasoning failed. */
17
+ why: string;
18
+ /** The rewritten instruction/approach to try next. */
19
+ newInstruction: string;
20
+ }
21
+ export interface ReflectCandidate {
22
+ /** The (possibly rewritten) approach/instruction. */
23
+ instruction: string;
24
+ /** The acceptance/quality score this approach achieved. */
25
+ score: number;
26
+ /** The turn it was produced on (tie-break: prefer earlier). */
27
+ turn: number;
28
+ }
29
+ /**
30
+ * A bounded best-K archive of reflected candidates by score. Deterministic:
31
+ * dedupes by instruction (keeping the higher score), sorts by score desc then
32
+ * earlier turn, and truncates to K. Pure — no I/O, no clock.
33
+ */
34
+ export declare class ReflectArchive {
35
+ private readonly k;
36
+ private items;
37
+ constructor(k?: number);
38
+ add(c: ReflectCandidate): void;
39
+ best(): ReflectCandidate | undefined;
40
+ all(): ReflectCandidate[];
41
+ size(): number;
42
+ /**
43
+ * The best archived candidate whose instruction differs from `current` — so a
44
+ * reflect turn tries a proven-but-DIFFERENT approach rather than re-deriving
45
+ * the one that just stalled. Returns undefined when the archive holds nothing
46
+ * new to try.
47
+ */
48
+ reseedFrom(current: string): ReflectCandidate | undefined;
49
+ }
50
+ /**
51
+ * Parse a reflect model's output into an ApproachRewrite. Fail-soft: returns
52
+ * null when no usable rewrite is present, so a flaky reflect turn never wedges
53
+ * the loop (the caller falls back to model escalation).
54
+ */
55
+ export declare function parseApproachRewrite(raw: string): ApproachRewrite | null;
56
+ //# sourceMappingURL=reflect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reflect.d.ts","sourceRoot":"","sources":["../../src/delivery/reflect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,GAAG,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,qBAAa,cAAc;IAGb,OAAO,CAAC,QAAQ,CAAC,CAAC;IAF9B,OAAO,CAAC,KAAK,CAA0B;gBAEV,CAAC,GAAE,MAAU;IAI1C,GAAG,CAAC,CAAC,EAAE,gBAAgB,GAAG,IAAI;IAW9B,IAAI,IAAI,gBAAgB,GAAG,SAAS;IAIpC,GAAG,IAAI,gBAAgB,EAAE;IAIzB,IAAI,IAAI,MAAM;IAId;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;CAG1D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAYxE"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * GEPA-style reflect phase (S6).
3
+ *
4
+ * Upgrades the loop's reflection from "fix-list for the next turn" (critic.ts)
5
+ * to "reflect on WHY the approach failed → rewrite the approach/instruction →
6
+ * retry", with a Pareto archive of the best reflected candidates so the loop
7
+ * reseeds from proven approaches instead of always mutating the latest one
8
+ * (which collapses to a local optimum — the same anti-Goodhart insight as the
9
+ * per-phase Generator≠Evaluator rule).
10
+ *
11
+ * This module is pure: the archive + the rewrite parser. The live wiring
12
+ * (a reflect turn before model escalation, feeding IterationDirective
13
+ * .mutateInstruction into the PromptBuilder) is the consumption step.
14
+ */
15
+ /**
16
+ * A bounded best-K archive of reflected candidates by score. Deterministic:
17
+ * dedupes by instruction (keeping the higher score), sorts by score desc then
18
+ * earlier turn, and truncates to K. Pure — no I/O, no clock.
19
+ */
20
+ export class ReflectArchive {
21
+ k;
22
+ items = [];
23
+ constructor(k = 4) {
24
+ this.k = k;
25
+ this.k = Math.max(1, Math.floor(k));
26
+ }
27
+ add(c) {
28
+ const i = this.items.findIndex((x) => x.instruction === c.instruction);
29
+ if (i >= 0) {
30
+ if (c.score > this.items[i].score)
31
+ this.items[i] = c;
32
+ }
33
+ else {
34
+ this.items.push(c);
35
+ }
36
+ this.items.sort((a, b) => b.score - a.score || a.turn - b.turn);
37
+ if (this.items.length > this.k)
38
+ this.items = this.items.slice(0, this.k);
39
+ }
40
+ best() {
41
+ return this.items[0];
42
+ }
43
+ all() {
44
+ return [...this.items];
45
+ }
46
+ size() {
47
+ return this.items.length;
48
+ }
49
+ /**
50
+ * The best archived candidate whose instruction differs from `current` — so a
51
+ * reflect turn tries a proven-but-DIFFERENT approach rather than re-deriving
52
+ * the one that just stalled. Returns undefined when the archive holds nothing
53
+ * new to try.
54
+ */
55
+ reseedFrom(current) {
56
+ return this.items.find((x) => x.instruction !== current);
57
+ }
58
+ }
59
+ /**
60
+ * Parse a reflect model's output into an ApproachRewrite. Fail-soft: returns
61
+ * null when no usable rewrite is present, so a flaky reflect turn never wedges
62
+ * the loop (the caller falls back to model escalation).
63
+ */
64
+ export function parseApproachRewrite(raw) {
65
+ try {
66
+ const m = raw.match(/\{[\s\S]*\}/);
67
+ if (!m)
68
+ return null;
69
+ const o = JSON.parse(m[0]);
70
+ if (typeof o.newInstruction === 'string' && o.newInstruction.trim() !== '') {
71
+ return { why: typeof o.why === 'string' ? o.why : '', newInstruction: o.newInstruction };
72
+ }
73
+ return null;
74
+ }
75
+ catch {
76
+ return null;
77
+ }
78
+ }
79
+ //# sourceMappingURL=reflect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reflect.js","sourceRoot":"","sources":["../../src/delivery/reflect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAkBH;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAGI;IAFrB,KAAK,GAAuB,EAAE,CAAC;IAEvC,YAA6B,IAAY,CAAC;QAAb,MAAC,GAAD,CAAC,CAAY;QACxC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IAED,GAAG,CAAC,CAAmB;QACrB,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC;QACvE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK;gBAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACvD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;QAChE,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;YAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED,GAAG;QACD,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED;;;;;OAKG;IACH,UAAU,CAAC,OAAe;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,OAAO,CAAC,CAAC;IAC3D,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACnC,IAAI,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QACpB,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAgD,CAAC;QAC1E,IAAI,OAAO,CAAC,CAAC,cAAc,KAAK,QAAQ,IAAI,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC3E,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC,cAAc,EAAE,CAAC;QAC3F,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -75,7 +75,36 @@ export declare function loadUserPaths(projectRoot: string): ManifestValidation |
75
75
  export declare function mergeUserPaths(projectRoot: string, derived: UserPathsManifest): UserPathsManifest;
76
76
  /** Extract the first JSON object or array from model output (```json fences or bare). */
77
77
  export declare function parseManifestFromModel(text: string): UserPathsManifest | null;
78
+ /**
79
+ * Render the derived user-path manifest as an ACCEPTANCE CONTRACT for the
80
+ * implementer — the concrete journeys + selectors the real-client validator
81
+ * will drive. Injected into the executor's prompt every turn (convergence-loop
82
+ * PromptContext.acceptanceContract) so the model builds a COMPLETE, drivable
83
+ * artifact from turn 1 instead of discovering the contract only through gate
84
+ * failures a weak model cannot act on. Generic across web/http/cli missions.
85
+ *
86
+ * The canvas→DOM bridge line is the completeness rail this exists for: an
87
+ * automated client can only see/click DOM nodes, so a canvas-only UI (a common
88
+ * small-model output for games/visualizations) must ALSO expose the referenced
89
+ * selectors as real DOM elements. A transparent overlay preserves the visual
90
+ * composite the aesthetic judge grades. Returns '' when there is nothing to
91
+ * assert (no manifest / no steps) so callers can inject unconditionally.
92
+ */
93
+ export declare function renderAcceptanceContract(manifest: UserPathsManifest | null | undefined): string;
78
94
  export type ModelExecutor = (prompt: string) => Promise<string>;
95
+ /**
96
+ * Deterministic backstop for the canvas REACHABILITY rule (expect_visible half —
97
+ * sanitizeCanvasTextAssertions only handles expect_text). A weak miner asserts
98
+ * individual canvas-drawn entities as DOM nodes (observed live on the octopus
99
+ * retest: `.enemy-rect`, `.particle`, `#player-ship`). Those are painted on the
100
+ * <canvas>, never in the DOM, so the step can NEVER pass and DEADLOCKS the gate.
101
+ * For canvas missions, drop steps whose target is a CLASS selector (`.foo`) —
102
+ * per-entity collections are always classes and a canvas app has no DOM class
103
+ * entities. Id/tag chrome (#start, #hud, #game-over, canvas) is kept; a path left
104
+ * with no assertion gets an expect_no_console_errors floor. Non-canvas missions
105
+ * and http/cli paths are untouched.
106
+ */
107
+ export declare function sanitizeCanvasEntityAssertions(manifest: UserPathsManifest, instruction: string): UserPathsManifest;
79
108
  /**
80
109
  * One evaluator-model call that proposes user paths for a mission. Fail-soft:
81
110
  * returns null on any error/parse failure so delivery never wedges on the
@@ -115,4 +144,17 @@ export declare function dropRedundantStaticServer(manifest: UserPathsManifest):
115
144
  * Prompt-following models are untouched (nothing to strip).
116
145
  */
117
146
  export declare function sanitizeCanvasTextAssertions(manifest: UserPathsManifest, instruction: string): UserPathsManifest;
147
+ /**
148
+ * Deterministic backstop for the REACHABILITY rule: a weak miner still emits
149
+ * assertions a mechanical click-validator can NEVER satisfy — a specific score
150
+ * or level number that requires actually playing (observed live on the octopus
151
+ * retest: `expect_text {#hud-level:"5"}`, `{#hud-score:"10"}`, `{#hud-score:"100"}`).
152
+ * Such a step cannot pass by scripted input, so it DEADLOCKS the user-path gate
153
+ * (the loop spins 3 turns unchanged and gives up). Loosen each numeric-outcome
154
+ * `expect_text` on a browser path to an `expect_visible` on the same selector —
155
+ * the element's PRESENCE is scripted-reachable, its exact game-state value is not.
156
+ * Word-bearing text ("OCTOPUS INVADERS", "Score", "GAME OVER") is untouched.
157
+ * Browser paths only; http/cli numeric bodies are legitimate and left alone.
158
+ */
159
+ export declare function sanitizeUnreachableGameStateAssertions(manifest: UserPathsManifest): UserPathsManifest;
118
160
  //# sourceMappingURL=user-paths.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"user-paths.d.ts","sourceRoot":"","sources":["../../src/delivery/user-paths.ts"],"names":[],"mappings":"AAgBA,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC;AAExD,6DAA6D;AAC7D,MAAM,WAAW,YAAY;IAE3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE;QAAE,Q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