patchwork-os 1.2.0-beta.3.canary.896 → 1.2.0-beta.3.canary.898

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.
@@ -8,9 +8,11 @@
8
8
  *
9
9
  * Design constraints baked into the shape (from the 2026-06-04 investigation,
10
10
  * `docs/counterfactual-sim-engine-investigation.md`):
11
- * - `gatedOnRecipeSteps` is a first-class boolean so a consumer can NEVER
12
- * imply an approval gate that does not exist on the recipe execution path
13
- * today (the live gate in transport.ts only gates MCP bridge calls).
11
+ * - `gatedOnRecipeSteps` is a first-class field so a consumer can never
12
+ * imply an approval gate that the runtime would not apply — nor hide one
13
+ * it would. Since v3 it is COMPUTED from the effective policy (the same
14
+ * `computeEffectivePolicy` both runners consult per step), never a
15
+ * constant; `null` when the policy could not be evaluated.
14
16
  * - cost carries an explicit `basis` and is never a precise dollar figure or
15
17
  * `$0` — at static fidelity USD is genuinely not projectable.
16
18
  * - conditional branches resolve to `"undetermined"`, never a faked
@@ -25,8 +27,15 @@
25
27
  * and the `taken`/`skipped` branch outcomes (alongside the existing
26
28
  * `undetermined`). All additions are additive/back-compatible — a static report
27
29
  * is still a valid v2 report.
30
+ *
31
+ * v3: the approval projection is the RUNTIME's verdict, not a tier guess.
32
+ * `gatedOnRecipeSteps` becomes `boolean | null` and is computed;
33
+ * `ApprovalProjection` gains `verdict` / `consultsApproval` and its
34
+ * `wouldRequireApproval` now means "the runner would hold this step for a
35
+ * human" (`null` when unknown); `approvals` gains `basis`, `profile` and
36
+ * `trigger`. A meaning change, hence the bump.
28
37
  */
29
- export declare const SIMULATION_SCHEMA_VERSION = 2;
38
+ export declare const SIMULATION_SCHEMA_VERSION = 3;
30
39
  export type RiskTier = "low" | "medium" | "high";
31
40
  /**
32
41
  * Side-effect class for a single step, derived from registry metadata
@@ -64,15 +73,45 @@ export interface SimulationStep {
64
73
  */
65
74
  mockedFrom?: "history" | "synthesized";
66
75
  }
67
- /** Per-step approval projection — "what WOULD gate, if recipe steps were gated". */
76
+ /**
77
+ * The effective-policy verdict for one step, as `computeEffectivePolicy`
78
+ * returns it, or `"unknown"` when it was not evaluated (a nested-recipe or
79
+ * compound step, or a report built with no policy input).
80
+ */
81
+ export type StepPolicyVerdict = "ALLOW" | "HUMAN_APPROVAL_REQUIRED" | "REFUSED" | "unknown";
82
+ /** Per-step approval projection — what the runtime WOULD do with this step. */
68
83
  export interface ApprovalProjection {
69
84
  stepId: string;
70
85
  tool?: string;
71
86
  tier: RiskTier;
72
- /** True if this step's tier would trip an approval gate (tier !== "low"). */
73
- wouldRequireApproval: boolean;
87
+ /**
88
+ * True when the runner would hold this step for a human
89
+ * (`verdict === "HUMAN_APPROVAL_REQUIRED"`); false when it would not;
90
+ * `null` when the verdict is unknown.
91
+ */
92
+ wouldRequireApproval: boolean | null;
93
+ /** The effective-policy verdict for this step. */
94
+ verdict: StepPolicyVerdict;
95
+ /** True when the runner consults the approval gate for this step at all. */
96
+ consultsApproval?: boolean;
74
97
  reason: string;
75
98
  }
99
+ /**
100
+ * Per-step effective-policy facts handed to the pure transform. Built by
101
+ * `projectRecipePolicy` from `computeEffectivePolicy` — the transform never
102
+ * derives a verdict itself.
103
+ */
104
+ export interface SimulationPolicy {
105
+ profile: "governed" | "compat";
106
+ /** The trigger the runtime evaluates (a top-level chained run is "manual"). */
107
+ trigger: string;
108
+ /** Keyed by plan step id. A step absent here was not evaluated. */
109
+ steps: Map<string, {
110
+ final: Exclude<StepPolicyVerdict, "unknown">;
111
+ consultsApproval: boolean;
112
+ reason: string;
113
+ }>;
114
+ }
76
115
  /** A conditional branch surfaced by the engine. */
77
116
  export interface BranchProjection {
78
117
  stepId: string;
@@ -173,16 +212,28 @@ export interface RecipeSimulationReport {
173
212
  /** "chained" recipes have a real DAG; "flat" recipes are a linear list. */
174
213
  topology: "chained" | "flat";
175
214
  /**
176
- * CRITICAL honesty field. False today: the approval queue does NOT gate
177
- * recipe-runner steps. Consumers MUST surface this so the approval
178
- * projection is never read as live gate behaviour.
215
+ * CRITICAL honesty field. True when the runtime consults the approval gate
216
+ * for at least one of this recipe's steps under the current profile,
217
+ * approval-gate setting and trigger; false when it consults it for none;
218
+ * `null` when the effective policy could not be evaluated. Computed from
219
+ * `computeEffectivePolicy`, never a constant.
179
220
  */
180
- gatedOnRecipeSteps: boolean;
221
+ gatedOnRecipeSteps: boolean | null;
181
222
  steps: SimulationStep[];
182
223
  summary: SimulationSummary;
183
224
  risk: RunRiskSummary;
184
225
  approvals: {
185
- gatedOnRecipeSteps: boolean;
226
+ gatedOnRecipeSteps: boolean | null;
227
+ /**
228
+ * `"effective-policy"`: verdicts come from `computeEffectivePolicy`.
229
+ * `"unavailable"`: the policy could not be evaluated; verdicts are
230
+ * `"unknown"` and nothing is claimed either way.
231
+ */
232
+ basis: "effective-policy" | "unavailable";
233
+ /** Governance profile the verdicts were computed under. */
234
+ profile?: "governed" | "compat";
235
+ /** Trigger the verdicts were computed for. */
236
+ trigger?: string;
186
237
  projected: ApprovalProjection[];
187
238
  note: string;
188
239
  };
@@ -8,9 +8,11 @@
8
8
  *
9
9
  * Design constraints baked into the shape (from the 2026-06-04 investigation,
10
10
  * `docs/counterfactual-sim-engine-investigation.md`):
11
- * - `gatedOnRecipeSteps` is a first-class boolean so a consumer can NEVER
12
- * imply an approval gate that does not exist on the recipe execution path
13
- * today (the live gate in transport.ts only gates MCP bridge calls).
11
+ * - `gatedOnRecipeSteps` is a first-class field so a consumer can never
12
+ * imply an approval gate that the runtime would not apply — nor hide one
13
+ * it would. Since v3 it is COMPUTED from the effective policy (the same
14
+ * `computeEffectivePolicy` both runners consult per step), never a
15
+ * constant; `null` when the policy could not be evaluated.
14
16
  * - cost carries an explicit `basis` and is never a precise dollar figure or
15
17
  * `$0` — at static fidelity USD is genuinely not projectable.
16
18
  * - conditional branches resolve to `"undetermined"`, never a faked
@@ -25,6 +27,13 @@
25
27
  * and the `taken`/`skipped` branch outcomes (alongside the existing
26
28
  * `undetermined`). All additions are additive/back-compatible — a static report
27
29
  * is still a valid v2 report.
30
+ *
31
+ * v3: the approval projection is the RUNTIME's verdict, not a tier guess.
32
+ * `gatedOnRecipeSteps` becomes `boolean | null` and is computed;
33
+ * `ApprovalProjection` gains `verdict` / `consultsApproval` and its
34
+ * `wouldRequireApproval` now means "the runner would hold this step for a
35
+ * human" (`null` when unknown); `approvals` gains `basis`, `profile` and
36
+ * `trigger`. A meaning change, hence the bump.
28
37
  */
29
- export const SIMULATION_SCHEMA_VERSION = 2;
38
+ export const SIMULATION_SCHEMA_VERSION = 3;
30
39
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/recipes/simulation/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/recipes/simulation/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchwork-os",
3
- "version": "1.2.0-beta.3.canary.896",
3
+ "version": "1.2.0-beta.3.canary.898",
4
4
  "description": "Your personal AI runtime, local-first. Patchwork OS gives any AI model a consistent set of tools, YAML recipes, a delegation policy with approval queue, and a durable trace memory — all on your machine, all under your policy.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",