audit-tools 0.30.25 → 0.30.26

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.
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Deterministic phase-cut derivation (remediator auto-phasing, T3).
3
+ *
4
+ * When `/remediate-code` is pointed at an arbitrary N-goal input (e.g. the whole
5
+ * backlog), the independent conceptual-design critique used to reject the run as
6
+ * "over-scoped" and the HOST had to manually re-scope to a phase at intake. That
7
+ * is the tool's job, not the host's: given the module-dependency DAG (each module
8
+ * declares the neighbours it `needs`), the tool derives a foundations→consumers
9
+ * phase cut MECHANICALLY — ordered tiers where every module sits one tier below
10
+ * the modules that depend on it. The critique is then handed the derived cut, so
11
+ * it assesses design quality WITHIN a mechanically dependency-ordered phasing
12
+ * rather than rejecting breadth (over-scoping is already handled by construction).
13
+ *
14
+ * Pure + deterministic (no I/O, no Date/Math.random, stable ordering): the same
15
+ * modules always yield the same cut. Cycle-safe — a dependency cycle cannot be
16
+ * topologically tiered, so its members are placed together at the tier just past
17
+ * their highest acyclic dependency (named-sorted, fail toward a LATER tier so a
18
+ * cyclic module never front-runs a real foundation it transitively needs).
19
+ */
20
+ /** One module + the names of the other modules it depends on (its foundations). */
21
+ export interface PhaseCutModule {
22
+ name: string;
23
+ /** Names of modules this module needs in place first (directional: this → dep). */
24
+ depends_on: string[];
25
+ }
26
+ /** One derived phase: an ordered tier of modules that may be authored together. */
27
+ export interface PhaseCutPhase {
28
+ /** 0-based tier ordinal; 0 = foundations. */
29
+ ordinal: number;
30
+ /** Stable human label for the tier. */
31
+ name: string;
32
+ /** Module names in this tier, sorted for determinism. */
33
+ modules: string[];
34
+ }
35
+ /** The derived phase cut: ordered tiers covering every module exactly once. */
36
+ export interface PhaseCut {
37
+ phases: PhaseCutPhase[];
38
+ /** True when a dependency cycle was detected (its members were tiered together). */
39
+ has_cycle: boolean;
40
+ }
41
+ /**
42
+ * Derive the ordered phase cut from a module-dependency DAG. Each module's tier is
43
+ * the length of its longest dependency chain (foundations = 0). Edges to unknown
44
+ * module names are ignored (a `needs` on a module not in scope is not a phase
45
+ * constraint here). Returns one phase per occupied tier, covering every module.
46
+ */
47
+ export declare function derivePhaseCut(modules: PhaseCutModule[]): PhaseCut;
48
+ /**
49
+ * Build {@link PhaseCutModule}s from drafted/finalized module contracts whose
50
+ * modules carry directional `neighbor_needs` (`{ neighbor, needs }` — this module
51
+ * needs `neighbor`). A module that needs another is one tier ABOVE it, so the
52
+ * derived `depends_on` for module M is the set of neighbours M needs. Tolerant of
53
+ * malformed payloads: anything unparseable contributes no module/edge.
54
+ */
55
+ export declare function phaseCutModulesFromContracts(contractsPayload: unknown): PhaseCutModule[];
56
+ /** Render the derived phase cut as a markdown section for the critique prompt. */
57
+ export declare function renderPhaseCutSection(cut: PhaseCut): string;
58
+ //# sourceMappingURL=phaseCut.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phaseCut.d.ts","sourceRoot":"","sources":["../../../src/remediate/contractPipeline/phaseCut.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,mFAAmF;AACnF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,mFAAmF;IACnF,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,mFAAmF;AACnF,MAAM,WAAW,aAAa;IAC5B,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,+EAA+E;AAC/E,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,oFAAoF;IACpF,SAAS,EAAE,OAAO,CAAC;CACpB;AASD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,QAAQ,CA8DlE;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,gBAAgB,EAAE,OAAO,GAAG,cAAc,EAAE,CAmBxF;AAED,kFAAkF;AAClF,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM,CAmB3D"}
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Deterministic phase-cut derivation (remediator auto-phasing, T3).
3
+ *
4
+ * When `/remediate-code` is pointed at an arbitrary N-goal input (e.g. the whole
5
+ * backlog), the independent conceptual-design critique used to reject the run as
6
+ * "over-scoped" and the HOST had to manually re-scope to a phase at intake. That
7
+ * is the tool's job, not the host's: given the module-dependency DAG (each module
8
+ * declares the neighbours it `needs`), the tool derives a foundations→consumers
9
+ * phase cut MECHANICALLY — ordered tiers where every module sits one tier below
10
+ * the modules that depend on it. The critique is then handed the derived cut, so
11
+ * it assesses design quality WITHIN a mechanically dependency-ordered phasing
12
+ * rather than rejecting breadth (over-scoping is already handled by construction).
13
+ *
14
+ * Pure + deterministic (no I/O, no Date/Math.random, stable ordering): the same
15
+ * modules always yield the same cut. Cycle-safe — a dependency cycle cannot be
16
+ * topologically tiered, so its members are placed together at the tier just past
17
+ * their highest acyclic dependency (named-sorted, fail toward a LATER tier so a
18
+ * cyclic module never front-runs a real foundation it transitively needs).
19
+ */
20
+ /** Stable label for a tier ordinal. */
21
+ function phaseName(ordinal, lastOrdinal) {
22
+ if (ordinal === 0)
23
+ return "foundations";
24
+ if (ordinal === lastOrdinal)
25
+ return "integration";
26
+ return `consumers-${ordinal}`;
27
+ }
28
+ /**
29
+ * Derive the ordered phase cut from a module-dependency DAG. Each module's tier is
30
+ * the length of its longest dependency chain (foundations = 0). Edges to unknown
31
+ * module names are ignored (a `needs` on a module not in scope is not a phase
32
+ * constraint here). Returns one phase per occupied tier, covering every module.
33
+ */
34
+ export function derivePhaseCut(modules) {
35
+ const names = modules.map((m) => m.name);
36
+ const known = new Set(names);
37
+ // Normalize edges: keep only deps that name a real in-scope module, drop self-edges.
38
+ const deps = new Map();
39
+ for (const m of modules) {
40
+ deps.set(m.name, [...new Set(m.depends_on)].filter((d) => d !== m.name && known.has(d)));
41
+ }
42
+ // Longest-dependency-chain tier via memoized DFS with cycle detection. A node on
43
+ // an active path (cycle) resolves to the max tier of its already-settled deps + 1
44
+ // (fail toward a later tier), and the cycle flag is raised.
45
+ const tier = new Map();
46
+ const visiting = new Set();
47
+ let hasCycle = false;
48
+ const computeTier = (name) => {
49
+ const cached = tier.get(name);
50
+ if (cached !== undefined)
51
+ return cached;
52
+ if (visiting.has(name)) {
53
+ // Back-edge: a cycle. Don't recurse through it; treat as no added depth here.
54
+ hasCycle = true;
55
+ return 0;
56
+ }
57
+ visiting.add(name);
58
+ let maxDep = -1;
59
+ // Sort deps for deterministic traversal (tier values are order-independent, but
60
+ // keep traversal stable for predictability under future changes).
61
+ for (const d of [...(deps.get(name) ?? [])].sort()) {
62
+ maxDep = Math.max(maxDep, computeTier(d));
63
+ }
64
+ visiting.delete(name);
65
+ const t = maxDep + 1;
66
+ tier.set(name, t);
67
+ return t;
68
+ };
69
+ for (const name of [...names].sort())
70
+ computeTier(name);
71
+ const lastOrdinal = Math.max(0, ...[...tier.values()]);
72
+ const byTier = new Map();
73
+ for (const [name, t] of tier) {
74
+ const bucket = byTier.get(t) ?? [];
75
+ bucket.push(name);
76
+ byTier.set(t, bucket);
77
+ }
78
+ const phases = [];
79
+ for (let ordinal = 0; ordinal <= lastOrdinal; ordinal++) {
80
+ const members = byTier.get(ordinal);
81
+ if (!members || members.length === 0)
82
+ continue;
83
+ phases.push({
84
+ ordinal,
85
+ name: phaseName(ordinal, lastOrdinal),
86
+ modules: [...members].sort(),
87
+ });
88
+ }
89
+ return { phases, has_cycle: hasCycle };
90
+ }
91
+ /**
92
+ * Build {@link PhaseCutModule}s from drafted/finalized module contracts whose
93
+ * modules carry directional `neighbor_needs` (`{ neighbor, needs }` — this module
94
+ * needs `neighbor`). A module that needs another is one tier ABOVE it, so the
95
+ * derived `depends_on` for module M is the set of neighbours M needs. Tolerant of
96
+ * malformed payloads: anything unparseable contributes no module/edge.
97
+ */
98
+ export function phaseCutModulesFromContracts(contractsPayload) {
99
+ const root = contractsPayload;
100
+ const list = Array.isArray(root?.module_contracts) ? root.module_contracts : [];
101
+ const out = [];
102
+ for (const mod of list) {
103
+ if (typeof mod !== "object" || mod === null)
104
+ continue;
105
+ const m = mod;
106
+ if (typeof m.name !== "string" || m.name.length === 0)
107
+ continue;
108
+ const needs = Array.isArray(m.neighbor_needs) ? m.neighbor_needs : [];
109
+ const depends_on = [];
110
+ for (const need of needs) {
111
+ if (typeof need === "object" && need !== null) {
112
+ const neighbor = need.neighbor;
113
+ if (typeof neighbor === "string" && neighbor.length > 0)
114
+ depends_on.push(neighbor);
115
+ }
116
+ }
117
+ out.push({ name: m.name, depends_on });
118
+ }
119
+ return out;
120
+ }
121
+ /** Render the derived phase cut as a markdown section for the critique prompt. */
122
+ export function renderPhaseCutSection(cut) {
123
+ const lines = cut.phases.map((p) => `- **Phase ${p.ordinal} — ${p.name}** (${p.modules.length} module(s)): ${p.modules.join(", ")}`);
124
+ return `## Mechanically-Derived Phase Cut
125
+
126
+ This change is **not** executed as one monolithic landing. The tool derived the
127
+ following ordered, dependency-gated phase cut from the module-dependency DAG —
128
+ each phase's modules depend only on earlier phases, and the scheduler enforces the
129
+ ordering with mechanical dependencies (a later-phase module cannot dispatch until
130
+ its foundations are verified-complete, with a whole-repo green gate between phases):
131
+
132
+ ${lines.join("\n")}
133
+
134
+ Assess the **design quality** within this phasing. Do NOT reject the work as
135
+ "over-scoped" or "too large for one change" — breadth is already handled by
136
+ construction: the phases land incrementally, green at every commit. Flag a real
137
+ design problem (a wrong boundary, a missing invariant, an unsound seam), not the
138
+ number of modules.${cut.has_cycle ? "\n\n> NOTE: a dependency cycle was detected among the modules; its members were tiered together. A genuine circular dependency between modules is a design smell worth your scrutiny." : ""}`;
139
+ }
140
+ //# sourceMappingURL=phaseCut.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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,CAAC,CAAC,CAAC,EAAE,CAAC;QACtE,MAAM,UAAU,GAAa,EAAE,CAAC;QAChC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBAC9C,MAAM,QAAQ,GAAI,IAA+B,CAAC,QAAQ,CAAC;gBAC3D,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;oBAAE,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACrF,CAAC;QACH,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,qBAAqB,CAAC,GAAa;IACjD,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAC1B,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,OAAO,MAAM,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,gBAAgB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACvG,CAAC;IACF,OAAO;;;;;;;;EAQP,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;oBAME,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,uLAAuL,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AACnO,CAAC"}
@@ -46,6 +46,22 @@ export type AdversarialDepth = "light" | "full";
46
46
  * more scrutiny: an absent/unknown tier resolves to `full`.
47
47
  */
48
48
  export declare function adversarialDepthForTier(tier: RiskTier | undefined): AdversarialDepth;
49
+ /**
50
+ * Round-trip granularity dial (T1 slice 4b). The granularity at which the
51
+ * authoring phases are gated:
52
+ * - `collapsed` — coherent authoring acts fold into ONE round-trip producing
53
+ * several artifacts (the ceremony saving — fewer gated steps);
54
+ * - `fine` — every phase its own gated round-trip (failure-isolation +
55
+ * per-phase validation, earned only when there is real complexity to isolate).
56
+ * Only `low` collapses; `medium`/`high` stay fine-grained. Fail-safe toward more
57
+ * isolation: an absent/unknown tier resolves to `fine`. This composes with
58
+ * escalate-on-evidence: a run begins collapsed (optimistic-start) and the moment
59
+ * decomposition raises the tier (slice 4a), the *remaining* phases re-derive
60
+ * fine-grained — the dial is read per next-step, never frozen at run start.
61
+ */
62
+ export type RoundTripGranularity = "collapsed" | "fine";
63
+ /** Map a risk tier to its round-trip granularity. Only `low` collapses. */
64
+ export declare function roundTripGranularityForTier(tier: RiskTier | undefined): RoundTripGranularity;
49
65
  /** A single deterministic path-risk family: a repo path family that warrants scrutiny. */
50
66
  export interface PathRiskPattern {
51
67
  /** Stable label, surfaced in the rationale (e.g. "concurrency"). */
@@ -1 +1 @@
1
- {"version":3,"file":"riskSignal.d.ts","sourceRoot":"","sources":["../../src/remediate/riskSignal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,eAAO,MAAM,iCAAiC,EAC5C,4CAAqD,CAAC;AAExD;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAIjD,8CAA8C;AAC9C,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAEnD;AAED,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAE9D;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,MAAM,CAAC;AAEhD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,gBAAgB,CAEpF;AAED,0FAA0F;AAC1F,MAAM,WAAW,eAAe;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BAAsB,sBAAsB,CAC1C,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC,GAC3E,OAAO,CAAC,gBAAgB,CAAC,CAQ3B"}
@@ -38,6 +38,10 @@ export function maxRiskTier(a, b) {
38
38
  export function adversarialDepthForTier(tier) {
39
39
  return tier === "low" ? "light" : "full";
40
40
  }
41
+ /** Map a risk tier to its round-trip granularity. Only `low` collapses. */
42
+ export function roundTripGranularityForTier(tier) {
43
+ return tier === "low" ? "collapsed" : "fine";
44
+ }
41
45
  /**
42
46
  * Default deterministic path-risk pattern set. These are the subsystems where a
43
47
  * change is correctness-sensitive (the spec's "concurrency / dispatch / merge /
@@ -1 +1 @@
1
- {"version":3,"file":"riskSignal.js","sourceRoot":"","sources":["../../src/remediate/riskSignal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,CAAC,MAAM,iCAAiC,GAC5C,4CAAqD,CAAC;AAUxD,MAAM,SAAS,GAA6B,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAE3E,8CAA8C;AAC9C,MAAM,UAAU,YAAY,CAAC,IAAc;IACzC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,WAAW,CAAC,CAAW,EAAE,CAAW;IAClD,OAAO,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC;AAaD;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAA0B;IAChE,OAAO,IAAI,KAAK,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,CAAC,KAAK,UAAU,oBAAoB,CACxC,YAAoB;IAEpB,OAAO,oBAAoB,CAAmB,WAAW,CAAC,YAAY,CAAC,CAAC,UAAU,CAAC,CAAC;AACtF,CAAC;AAED,kDAAkD;AAClD,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,YAAoB,EACpB,MAAwB;IAExB,MAAM,aAAa,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AACpE,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,YAAoB,EACpB,YAA4E;IAE5E,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAC1D,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,MAAM,GAAG,uBAAuB,CAAC,MAAM,YAAY,EAAE,CAAC,CAAC;IAC7D,MAAM,qBAAqB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAClD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -2,12 +2,18 @@ import { type ValidationIssue, type JudgeReport, type SessionConfig } from "audi
2
2
  import type { ContractPipelineArtifactName } from "../contractPipeline/artifactStore.js";
3
3
  import type { RemediationStep } from "./types.js";
4
4
  /**
5
- * Maximum judge-ordered contract repairs per run. After the cap, the run
6
- * proceeds to implementation planning with the unrepaired counterexamples
7
- * carried as residual risks an unbounded critic↔repair oscillation is the
8
- * failure mode this exists to prevent.
5
+ * Runaway backstop for the judge↔repair loop the LOUD exception path, NOT the
6
+ * normal terminator. The loop normally terminates by *convergence*: it keeps
7
+ * repairing only while each round surfaces a genuinely NEW accepted counterexample
8
+ * (real progress), reaches a fixpoint when the judge approves, and escalates to the
9
+ * user the moment a round re-accepts an already-addressed counterexample without
10
+ * progress (a stall/oscillation). This ceiling exists only so a pathological run
11
+ * that keeps minting brand-new accepted counterexamples forever cannot loop without
12
+ * bound; hitting it is itself an escalation (loud), never a silent proceed. It is
13
+ * deliberately generous — a genuinely deep but converging design (each round a new
14
+ * real defect) must not be cut mid-convergence (the failure mode of the former N=2).
9
15
  */
10
- export declare const MAX_CONTRACT_REPAIR_ITERATIONS = 2;
16
+ export declare const MAX_CONTRACT_REPAIR_ITERATIONS = 8;
11
17
  /** Maximum implementation_dag regenerations after traceability rejections. */
12
18
  export declare const MAX_DAG_REGENERATION_ATTEMPTS = 2;
13
19
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"contractPipeline.d.ts","sourceRoot":"","sources":["../../../src/remediate/steps/contractPipeline.ts"],"names":[],"mappings":"AAwBA,OAAO,EAOL,KAAK,eAAe,EACpB,KAAK,WAAW,EAIhB,KAAK,aAAa,EAEnB,MAAM,oBAAoB,CAAC;AA6D5B,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAIzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAwClD;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,IAAI,CAAC;AAEhD,8EAA8E;AAC9E,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,mCAAmC,IAAI,CAAC;AAuCrD,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,oEAAoE,CAAC;IACrF,qFAAqF;IACrF,QAAQ,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;IACzE,qDAAqD;IACrD,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAMD,wBAAsB,yBAAyB,CAC7C,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,qBAAqB,CAAC,CAWhC;AAED,wBAAsB,0BAA0B,CAC9C,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAGf;AA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qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,mBAAmB,CAEjF;AA0JD;;;GAGG;AACH,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAwuCjC;AAkED;;;GAGG;AACH,wBAAsB,uCAAuC,CAC3D,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAqJf"}
@@ -24,7 +24,8 @@ import { mkdir, rename } from "node:fs/promises";
24
24
  import { join } from "node:path";
25
25
  import { writeJsonFile, readOptionalJsonFile, formatValidationIssues, hashContent, isRecord, withFsRetry, captureStepBoundaryFriction, } from "audit-tools/shared";
26
26
  import { CP_ARTIFACT_NAMES, contractArtifactExists, contractArtifactFilePath, contractPipelineDir, detectStaleArtifacts, isEnvelope, pathASeedFilePath, readContractArtifact, writeContractArtifact, } from "../contractPipeline/artifactStore.js";
27
- import { readIntakeRiskSignal, writeIntakeRiskSignal, escalateRiskSignal, decompositionRiskEvidence, adversarialDepthForTier, } from "../riskSignal.js";
27
+ import { readIntakeRiskSignal, writeIntakeRiskSignal, escalateRiskSignal, decompositionRiskEvidence, adversarialDepthForTier, roundTripGranularityForTier, } from "../riskSignal.js";
28
+ import { derivePhaseCut, phaseCutModulesFromContracts, renderPhaseCutSection, } from "../contractPipeline/phaseCut.js";
28
29
  import { detectCyclicSeamObligations, validateCycleBreak, } from "../contractPipeline/cyclicSeamResolution.js";
29
30
  import { deriveObligationLedger, buildTestValidatorPlanScaffold, buildImplementationDagScaffold, acceptedCounterexampleIds, } from "../contractPipeline/derive.js";
30
31
  import { ensureNodeId, toBlockId } from "../contractPipeline/idRegistry.js";
@@ -60,14 +61,39 @@ const ARTIFACT_TO_PHASE = {
60
61
  // ── Phase → step kind mapping ──────────────────────────────────────────────────
61
62
  const CONTRACT_STEP_KIND = "contract_pipeline";
62
63
  const PRE_IMPLEMENTATION_PHASE_ORDER = CONTRACT_PIPELINE_PHASE_ORDER.filter((phase) => phase !== "closing");
64
+ /**
65
+ * Granularity collapse group (T1 slice 4b). The framing phases — goal, context,
66
+ * decomposition — are ONE coherent act of authoring (scope the change top-down):
67
+ * they carry no adversarial judgment and no deterministic derivation interleaves
68
+ * them, so for low-complexity work they fold into a single round-trip producing
69
+ * all three artifacts instead of three gated steps. The group deliberately STOPS
70
+ * at decomposition (before module_contract_drafting): keeping the decomposition→
71
+ * drafting boundary lets the slice-4a escalate-on-evidence intercept inspect the
72
+ * fresh decomposition and raise the tier — un-collapsing every remaining phase —
73
+ * before any contract is drafted or the per-module wave fans out. Collapse is
74
+ * best-effort: any member artifact the worker omits or writes malformed is
75
+ * re-emitted as its own fine-grained step by `nextMissingContractPhase`, so no
76
+ * work is ever lost. See `roundTripGranularityForTier`.
77
+ */
78
+ const FRAMING_COLLAPSE_GROUP = [
79
+ "goal_normalization",
80
+ "context_collection",
81
+ "decomposition",
82
+ ];
63
83
  // ── Bounded-loop caps ─────────────────────────────────────────────────────────
64
84
  /**
65
- * Maximum judge-ordered contract repairs per run. After the cap, the run
66
- * proceeds to implementation planning with the unrepaired counterexamples
67
- * carried as residual risks an unbounded critic↔repair oscillation is the
68
- * failure mode this exists to prevent.
85
+ * Runaway backstop for the judge↔repair loop the LOUD exception path, NOT the
86
+ * normal terminator. The loop normally terminates by *convergence*: it keeps
87
+ * repairing only while each round surfaces a genuinely NEW accepted counterexample
88
+ * (real progress), reaches a fixpoint when the judge approves, and escalates to the
89
+ * user the moment a round re-accepts an already-addressed counterexample without
90
+ * progress (a stall/oscillation). This ceiling exists only so a pathological run
91
+ * that keeps minting brand-new accepted counterexamples forever cannot loop without
92
+ * bound; hitting it is itself an escalation (loud), never a silent proceed. It is
93
+ * deliberately generous — a genuinely deep but converging design (each round a new
94
+ * real defect) must not be cut mid-convergence (the failure mode of the former N=2).
69
95
  */
70
- export const MAX_CONTRACT_REPAIR_ITERATIONS = 2;
96
+ export const MAX_CONTRACT_REPAIR_ITERATIONS = 8;
71
97
  /** Maximum implementation_dag regenerations after traceability rejections. */
72
98
  export const MAX_DAG_REGENERATION_ATTEMPTS = 2;
73
99
  /**
@@ -318,11 +344,26 @@ function inferRepairDirective(judge) {
318
344
  instruction: "Address every judge-accepted counterexample in the judge report's classifications.",
319
345
  };
320
346
  }
347
+ /** Judge-accepted counterexample ids from a judge report's classifications. */
348
+ function acceptedCeIdsOf(judge) {
349
+ return (judge?.classifications ?? [])
350
+ .filter((c) => c.classification === "accepted")
351
+ .map((c) => c.counterexample_id);
352
+ }
321
353
  /**
322
- * Decide whether implementation planning may proceed: an approved judge
323
- * verdict proceeds; a failing verdict triggers one targeted repair per judge
324
- * report, capped at MAX_CONTRACT_REPAIR_ITERATIONS — after the cap, the run
325
- * proceeds with the unrepaired counterexamples recorded as residual risks.
354
+ * Decide whether implementation planning may proceed. Convergence-terminated,
355
+ * NOT capped at an arbitrary count:
356
+ * - approved verdict proceed (the fixpoint);
357
+ * - a needs_repair verdict that surfaces a NEW accepted counterexample (one not
358
+ * already addressed by a prior repair) ⇒ repair (genuine progress);
359
+ * - a needs_repair verdict whose accepted counterexamples were ALL already
360
+ * addressed ⇒ escalate (stall/oscillation — the repair loop is not converging,
361
+ * surface the outstanding counterexamples to the user instead of silently
362
+ * shipping residual risk or looping);
363
+ * - the runaway backstop (MAX_CONTRACT_REPAIR_ITERATIONS) ⇒ escalate (loud).
364
+ * The former fixed N=2 cap that proceeded-with-residual-risk at an arbitrary count
365
+ * is gone: a deep-but-converging run is no longer cut mid-convergence, and a
366
+ * genuinely non-converging run is surfaced rather than buried.
326
367
  */
327
368
  async function evaluateJudgeGate(artifactsDir) {
328
369
  const judgeEnvelope = await readContractArtifact(artifactsDir, "judge_report");
@@ -334,12 +375,6 @@ async function evaluateJudgeGate(artifactsDir) {
334
375
  const repairState = await readRepairState(artifactsDir);
335
376
  const judgeHash = judgeEnvelope.content_hash;
336
377
  const alreadyHandled = repairState.repairs.some((repair) => repair.judge_hash === judgeHash);
337
- if (!alreadyHandled && repairState.repairs.length >= MAX_CONTRACT_REPAIR_ITERATIONS) {
338
- return {
339
- kind: "proceed_residual",
340
- note: `The judge verdict remains "needs_repair" after ${repairState.repairs.length} repair iteration(s) (the cap). Proceed anyway: treat every judge-accepted counterexample that remains unaddressed as a residual risk, and cover each one with an implementation or verification node.`,
341
- };
342
- }
343
378
  // Map judge.repair_directive.target if present; if absent, infer from classifications.
344
379
  const rawDirective = judge.repair_directive;
345
380
  const directive = rawDirective
@@ -350,7 +385,36 @@ async function evaluateJudgeGate(artifactsDir) {
350
385
  instruction: rawDirective.instruction,
351
386
  }
352
387
  : inferRepairDirective(judge);
353
- return { kind: "repair", directive, judgeHash };
388
+ const acceptedIds = acceptedCeIdsOf(judge);
389
+ const addressed = new Set(repairState.repairs.flatMap((r) => r.accepted_ce_ids ?? []));
390
+ const newAccepted = acceptedIds.filter((id) => !addressed.has(id));
391
+ // Idempotent re-entry: this exact judge report already drove a repair (its hash
392
+ // is recorded). Re-emit the same repair directive; do not re-evaluate convergence
393
+ // (the repair has not yet produced a fresh judge report).
394
+ if (alreadyHandled) {
395
+ return { kind: "repair", directive, judgeHash, acceptedCeIds: newAccepted };
396
+ }
397
+ // Runaway backstop (loud) — the exception path, not the normal terminator.
398
+ if (repairState.repairs.length >= MAX_CONTRACT_REPAIR_ITERATIONS) {
399
+ return {
400
+ kind: "escalate",
401
+ reason: "runaway",
402
+ outstanding: acceptedIds,
403
+ note: `The judge↔repair loop reached its runaway backstop (${repairState.repairs.length} repair rounds) without converging. Each round was still surfacing accepted counterexamples. This is pathological non-convergence — review the outstanding counterexamples and the contract design with the user before proceeding.`,
404
+ };
405
+ }
406
+ // Progress: a new accepted counterexample (or the first round) ⇒ repair.
407
+ if (repairState.repairs.length === 0 || newAccepted.length > 0) {
408
+ return { kind: "repair", directive, judgeHash, acceptedCeIds: newAccepted };
409
+ }
410
+ // Stall: a needs_repair verdict whose every accepted counterexample was already
411
+ // addressed by a prior repair ⇒ the loop is not converging ⇒ escalate.
412
+ return {
413
+ kind: "escalate",
414
+ reason: "stall",
415
+ outstanding: acceptedIds,
416
+ note: `The judge re-accepted counterexample(s) that a prior repair already addressed (${acceptedIds.join(", ") || "none newly accepted"}), with no new accepted counterexample this round. The repair loop is not converging on these items. Resolve them with the user — adjust the contract design or accept the counterexamples as known limitations — before the plan can be promoted.`,
417
+ };
354
418
  }
355
419
  /**
356
420
  * The traceability invariant: no implementation_dag node may exist without
@@ -777,6 +841,45 @@ After writing the output file, run:
777
841
  stopCondition: `Stop after writing the contract-pipeline output for phase "${phase}" and running next-step.`,
778
842
  });
779
843
  };
844
+ // T1 slice 4b: emit ONE round-trip whose prompt concatenates the rendered
845
+ // specs of several consecutive authoring phases. The worker writes every
846
+ // named artifact top-down (each later phase's inputs are the files it wrote in
847
+ // the earlier sections of the same round-trip), then runs next-step once. The
848
+ // group header overrides the per-section "stop after writing" lines so they are
849
+ // not read as three separate stop points.
850
+ const buildCollapsedFramingStep = (phases) => {
851
+ const sections = phases.map((phase) => {
852
+ const rendered = renderContractPipelinePrompt({
853
+ role: phase,
854
+ artifactPaths,
855
+ sourcePaths,
856
+ repoRoot: root,
857
+ pathASeedPath,
858
+ hostCanDispatchSubagents: options.hostCanDispatchSubagents,
859
+ adversarialDepth,
860
+ });
861
+ return { phase, rendered };
862
+ });
863
+ const outputPaths = sections.map((s) => s.rendered.outputPath);
864
+ const header = `# Collapsed Authoring Round-Trip — ${phases.length} Phases
865
+
866
+ This is a low-complexity change, so these ${phases.length} coherent authoring phases are combined into a SINGLE round-trip. Complete EVERY section below — author them top-down, writing each artifact to its named path (each later section's inputs are the files you write in the earlier sections of this same round-trip). Then run next-step ONCE.
867
+
868
+ Treat any per-section "Stop after writing the output file / do not advance" instruction as scoped to that section only — it does NOT mean stop the round-trip. Finish all sections first.
869
+
870
+ If you cannot complete a section (an artifact would be malformed), write the ones you can and run next-step: the pipeline re-emits any missing or invalid artifact as its own fine-grained step, so no work is lost.
871
+
872
+ Artifacts to produce (in order):
873
+ ${outputPaths.map((p, i) => `${i + 1}. \`${p}\` (${phases[i]})`).join("\n")}`;
874
+ const body = sections
875
+ .map((s) => `\n---\n\n${s.rendered.prompt}`)
876
+ .join("\n");
877
+ return buildStep({
878
+ prompt: `${header}\n${body}`,
879
+ outputPath: outputPaths[outputPaths.length - 1],
880
+ stopCondition: `Stop after writing all ${phases.length} collapsed-framing artifacts (${phases.join(", ")}) and running next-step once.`,
881
+ });
882
+ };
780
883
  const buildParallelModuleWaveStep = async (phase) => {
781
884
  // DC-3: fan the phase out to ONE agent per module, concurrency-capped by the
782
885
  // shared wave scheduler (the same quota/host machinery implement dispatch
@@ -1061,8 +1164,10 @@ ${rejectionRewriteInstruction(archived.archivedPath)}`);
1061
1164
  return buildNextContractPipelineStep(options);
1062
1165
  }
1063
1166
  }
1064
- // 3. Judge gate: implementation planning is reachable only through an
1065
- // approved verdict, a bounded targeted repair, or the repair cap.
1167
+ // 3. Judge gate: implementation planning is reachable only through an approved
1168
+ // verdict (the fixpoint) or a convergent targeted repair. A stalled /
1169
+ // non-converging repair loop escalates to the user (blocked) instead of
1170
+ // silently proceeding with residual risk.
1066
1171
  if (nextPhase === "implementation_planning") {
1067
1172
  const gate = await evaluateJudgeGate(artifactsDir);
1068
1173
  if (gate.kind === "repair") {
@@ -1073,6 +1178,7 @@ ${rejectionRewriteInstruction(archived.archivedPath)}`);
1073
1178
  judge_hash: gate.judgeHash,
1074
1179
  target: repairTarget,
1075
1180
  at: new Date().toISOString(),
1181
+ accepted_ce_ids: gate.acceptedCeIds,
1076
1182
  });
1077
1183
  await writeRepairState(artifactsDir, repairState);
1078
1184
  }
@@ -1088,11 +1194,37 @@ ${rejectionRewriteInstruction(archived.archivedPath)}`);
1088
1194
  stopCondition: `Stop after rewriting "${repairTarget}" per the judge repair directive and running next-step.`,
1089
1195
  });
1090
1196
  }
1091
- if (gate.kind === "proceed_residual") {
1092
- return buildPhaseStep("implementation_planning", `## Repair Cap Reached Residual Risks
1197
+ if (gate.kind === "escalate") {
1198
+ // Non-convergence (stall or runaway backstop): surface it to the user
1199
+ // loudly rather than promoting a plan over an un-converged contract. The
1200
+ // outstanding accepted counterexamples are named so the user can resolve
1201
+ // them (revise the contract design or accept them as known limitations).
1202
+ await captureStepBoundaryFriction(artifactsDir, runId, {
1203
+ eventType: "repair_round",
1204
+ discriminator: `judge_nonconvergence:${gate.reason}`,
1205
+ note: `Judge↔repair loop escalated (${gate.reason}): ${gate.note}`,
1206
+ category: "trap",
1207
+ }, "remediate-code");
1208
+ return writeCurrentStep({
1209
+ stepKind: CONTRACT_STEP_KIND,
1210
+ status: "blocked",
1211
+ runId,
1212
+ repoRoot: root,
1213
+ artifactsDir,
1214
+ prompt: `# Judge↔Repair Loop Did Not Converge
1093
1215
 
1094
1216
  ${gate.note}
1095
- `);
1217
+
1218
+ ## Outstanding accepted counterexamples
1219
+
1220
+ ${gate.outstanding.length > 0
1221
+ ? gate.outstanding.map((id) => `- ${id}`).join("\n")
1222
+ : "_(none newly accepted this round)_"}
1223
+
1224
+ Read the judge_report and counterexample artifacts, decide with the user how to resolve each outstanding counterexample (revise the contract design and re-run, or accept it as a known limitation), then re-run next-step.`,
1225
+ allowedCommands: [],
1226
+ stopCondition: "Stop — the contract pipeline is blocked on a non-converging judge↔repair loop pending a user decision.",
1227
+ });
1096
1228
  }
1097
1229
  // gate.kind === "proceed": fall through to the normal phase step below.
1098
1230
  }
@@ -1601,6 +1733,41 @@ ${preCriticCitationGate.errorLines.join("\n")}
1601
1733
  }
1602
1734
  return buildParallelModuleWaveStep(nextPhase);
1603
1735
  }
1736
+ // Auto-phasing (T3): at the conceptual-design critique, hand the critic the
1737
+ // tool-DERIVED phase cut so it assesses design quality WITHIN a mechanically
1738
+ // dependency-ordered foundations→consumers phasing, instead of rejecting an
1739
+ // arbitrary N-goal change as "over-scoped" and forcing the host to re-scope by
1740
+ // hand at intake. The cut is derived deterministically from the drafted module
1741
+ // contracts' directional neighbor_needs edges (present by the critique phase);
1742
+ // only injected when there is a genuine multi-phase cut to communicate.
1743
+ if (nextPhase === "critique") {
1744
+ const contractsPayload = envelopePayload(await readContractArtifact(artifactsDir, "module_contracts"));
1745
+ const cutModules = phaseCutModulesFromContracts(contractsPayload);
1746
+ if (cutModules.length > 1) {
1747
+ const cut = derivePhaseCut(cutModules);
1748
+ if (cut.phases.length > 1) {
1749
+ const reReview = await buildReReviewSection(nextPhase, artifactsDir);
1750
+ const phaseCutSection = renderPhaseCutSection(cut);
1751
+ return buildPhaseStep("critique", reReview ? `${phaseCutSection}\n${reReview}` : phaseCutSection);
1752
+ }
1753
+ }
1754
+ }
1755
+ // Granularity collapse (T1 slice 4b): for low-complexity work, fold the framing
1756
+ // suffix [nextPhase..decomposition] into ONE round-trip producing several
1757
+ // artifacts, instead of one gated step per phase. Reads the POST-escalation
1758
+ // riskSignal (slice 4a may have already raised the tier above), so the dial is
1759
+ // never frozen at run start — `fine` for medium/high keeps full per-phase
1760
+ // isolation. Only collapses a genuine multi-phase suffix; a single trailing
1761
+ // framing phase falls through to the normal per-phase dispatch below.
1762
+ if (nextPhase &&
1763
+ roundTripGranularityForTier(riskSignal?.tier) === "collapsed" &&
1764
+ FRAMING_COLLAPSE_GROUP.includes(nextPhase)) {
1765
+ const startIdx = FRAMING_COLLAPSE_GROUP.indexOf(nextPhase);
1766
+ const suffix = FRAMING_COLLAPSE_GROUP.slice(startIdx);
1767
+ if (suffix.length > 1) {
1768
+ return buildCollapsedFramingStep([...suffix]);
1769
+ }
1770
+ }
1604
1771
  // Skeleton-scaffolded phases (S3): the tool pre-fills structure/ids from the
1605
1772
  // derived obligation ledger so the worker fills only the judgment slots.
1606
1773
  if (nextPhase === "test_validator_plan" || nextPhase === "implementation_planning") {