patchwork-os 1.2.0-beta.2.canary.739 → 1.2.0-beta.2.canary.740
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.
|
@@ -53,6 +53,16 @@ export type HaltCategory = "agent_silent_fail" | "agent_narration_only" | "agent
|
|
|
53
53
|
| "approval_rejected"
|
|
54
54
|
/** Whole-recipe failure (e.g. circular dependencies) — has no step row. */
|
|
55
55
|
| "run_level"
|
|
56
|
+
/**
|
|
57
|
+
* The run finished its steps but violated its RUN-LEVEL completion contract
|
|
58
|
+
* (`recipe.expect` → `assertionFailures`). Distinct from `expect_failed`,
|
|
59
|
+
* which is a per-STEP assertion and arrives as an error step row.
|
|
60
|
+
*
|
|
61
|
+
* Its own category because such a run finishes `done`, not `error`: the
|
|
62
|
+
* operator-facing halt count could not see it at all, so "nothing halted"
|
|
63
|
+
* and "the job did not do what it promised" were the same reading.
|
|
64
|
+
*/
|
|
65
|
+
| "contract_failed"
|
|
56
66
|
/**
|
|
57
67
|
* The step uses a construct this runner does not implement (a compound
|
|
58
68
|
* step — `parallel`, `each`, `recipe`, `chain`, `branch` — on a non-chained
|
|
@@ -87,12 +97,20 @@ export interface HaltSummary {
|
|
|
87
97
|
runSeq: number;
|
|
88
98
|
}>;
|
|
89
99
|
}
|
|
90
|
-
interface HaltSummaryInputRun {
|
|
100
|
+
export interface HaltSummaryInputRun {
|
|
91
101
|
seq: number;
|
|
92
102
|
/** Top-level run status — `run_level` halts are runs with status === "error" but no error stepResults (e.g. circular-dep failure before any step ran). */
|
|
93
103
|
status?: "running" | "done" | "error" | "cancelled" | "interrupted";
|
|
94
104
|
/** Top-level errorMessage — surfaced as a `run_level` halt when no per-step halts cover it. */
|
|
95
105
|
errorMessage?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Run-level `recipe.expect` violations. Present on the run-log row already
|
|
108
|
+
* — the runner persists them — so every caller passing a whole row gets
|
|
109
|
+
* this for free and no call site changes.
|
|
110
|
+
*/
|
|
111
|
+
assertionFailures?: Array<{
|
|
112
|
+
message?: string;
|
|
113
|
+
} | unknown>;
|
|
96
114
|
stepResults?: Array<{
|
|
97
115
|
status: "ok" | "skipped" | "error";
|
|
98
116
|
haltReason?: string;
|
|
@@ -108,6 +126,19 @@ interface HaltSummaryInputRun {
|
|
|
108
126
|
* - one entry per error-status stepResult that has a `haltReason`
|
|
109
127
|
* - plus one `run_level` entry if `status === "error"` and there were no
|
|
110
128
|
* per-step halts that already explained it (avoids double-counting).
|
|
129
|
+
* - plus ONE `contract_failed` entry if the run violated its run-level
|
|
130
|
+
* `recipe.expect`, regardless of the two above.
|
|
131
|
+
*
|
|
132
|
+
* The contract entry is deliberately NOT guarded on the step count, unlike
|
|
133
|
+
* `run_level`. That guard exists because a run's `errorMessage` usually
|
|
134
|
+
* restates a step failure already counted — the same fact twice. A violated
|
|
135
|
+
* postcondition is a DIFFERENT fact: every step can succeed and the run still
|
|
136
|
+
* fail to deliver what it promised, and a step can fail for a reason
|
|
137
|
+
* unrelated to the assertion that also failed.
|
|
138
|
+
*
|
|
139
|
+
* ONE entry per run, not one per failure. A run with three assertion failures
|
|
140
|
+
* broke one contract in three ways; counting three would inflate the halt
|
|
141
|
+
* count against "incomplete jobs", which is the reading this count is for.
|
|
111
142
|
*/
|
|
112
143
|
export declare function summariseHalts(runs: HaltSummaryInputRun[]): HaltSummary;
|
|
113
144
|
/**
|
|
@@ -135,4 +166,3 @@ export declare function deriveHaltReasonFromError(opts: {
|
|
|
135
166
|
status: "ok" | "skipped" | "error";
|
|
136
167
|
error?: string;
|
|
137
168
|
}): string | undefined;
|
|
138
|
-
export {};
|
|
@@ -33,6 +33,7 @@ export const HALT_CATEGORY_LABELS = {
|
|
|
33
33
|
missing_connector: "missing connector",
|
|
34
34
|
approval_rejected: "approval rejected",
|
|
35
35
|
run_level: "run-level halt",
|
|
36
|
+
contract_failed: "completion contract failed",
|
|
36
37
|
unsupported_step: "unsupported step form",
|
|
37
38
|
unknown: "uncategorised",
|
|
38
39
|
};
|
|
@@ -58,6 +59,7 @@ export const HALT_CATEGORY_HINTS = {
|
|
|
58
59
|
missing_connector: "install/connect from /connections",
|
|
59
60
|
approval_rejected: "approve the step from the dashboard, or set requireApproval: false",
|
|
60
61
|
run_level: "check recipe for circular deps / parse errors",
|
|
62
|
+
contract_failed: "the run finished but broke its `expect` postcondition — compare the assertion with the run output",
|
|
61
63
|
unsupported_step: "use `fan_out`, or set trigger.type: chained",
|
|
62
64
|
unknown: "open run trace for raw error",
|
|
63
65
|
};
|
|
@@ -122,6 +124,19 @@ export function categoriseHaltReason(reason) {
|
|
|
122
124
|
* - one entry per error-status stepResult that has a `haltReason`
|
|
123
125
|
* - plus one `run_level` entry if `status === "error"` and there were no
|
|
124
126
|
* per-step halts that already explained it (avoids double-counting).
|
|
127
|
+
* - plus ONE `contract_failed` entry if the run violated its run-level
|
|
128
|
+
* `recipe.expect`, regardless of the two above.
|
|
129
|
+
*
|
|
130
|
+
* The contract entry is deliberately NOT guarded on the step count, unlike
|
|
131
|
+
* `run_level`. That guard exists because a run's `errorMessage` usually
|
|
132
|
+
* restates a step failure already counted — the same fact twice. A violated
|
|
133
|
+
* postcondition is a DIFFERENT fact: every step can succeed and the run still
|
|
134
|
+
* fail to deliver what it promised, and a step can fail for a reason
|
|
135
|
+
* unrelated to the assertion that also failed.
|
|
136
|
+
*
|
|
137
|
+
* ONE entry per run, not one per failure. A run with three assertion failures
|
|
138
|
+
* broke one contract in three ways; counting three would inflate the halt
|
|
139
|
+
* count against "incomplete jobs", which is the reading this count is for.
|
|
125
140
|
*/
|
|
126
141
|
export function summariseHalts(runs) {
|
|
127
142
|
const byCategory = {};
|
|
@@ -144,6 +159,21 @@ export function summariseHalts(runs) {
|
|
|
144
159
|
});
|
|
145
160
|
}
|
|
146
161
|
}
|
|
162
|
+
const assertionCount = run.assertionFailures?.length ?? 0;
|
|
163
|
+
if (assertionCount > 0) {
|
|
164
|
+
total++;
|
|
165
|
+
byCategory.contract_failed = (byCategory.contract_failed ?? 0) + 1;
|
|
166
|
+
if (recent.length < 5) {
|
|
167
|
+
recent.push({
|
|
168
|
+
// Names the count rather than quoting an assertion: the assertion
|
|
169
|
+
// text can carry run output, and `recent` is rendered in the CLI,
|
|
170
|
+
// the dashboard and a Prometheus-adjacent surface.
|
|
171
|
+
reason: `run-level expect failed (${assertionCount} assertion${assertionCount === 1 ? "" : "s"})`,
|
|
172
|
+
category: "contract_failed",
|
|
173
|
+
runSeq: run.seq,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
147
177
|
if (stepHaltsForRun === 0 && run.status === "error" && run.errorMessage) {
|
|
148
178
|
total++;
|
|
149
179
|
byCategory.run_level = (byCategory.run_level ?? 0) + 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"haltCategory.js","sourceRoot":"","sources":["../../src/recipes/haltCategory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"haltCategory.js","sourceRoot":"","sources":["../../src/recipes/haltCategory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAsEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAiC;IAChE,iBAAiB,EAAE,mBAAmB;IACtC,oBAAoB,EAAE,sBAAsB;IAC5C,WAAW,EAAE,aAAa;IAC1B,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,YAAY;IACxB,WAAW,EAAE,qBAAqB;IAClC,eAAe,EAAE,iBAAiB;IAClC,aAAa,EAAE,eAAe;IAC9B,YAAY,EAAE,cAAc;IAC5B,yBAAyB,EAAE,2BAA2B;IACtD,YAAY,EAAE,cAAc;IAC5B,YAAY,EAAE,cAAc;IAC5B,aAAa,EAAE,eAAe;IAC9B,iBAAiB,EAAE,mBAAmB;IACtC,iBAAiB,EAAE,mBAAmB;IACtC,SAAS,EAAE,gBAAgB;IAC3B,eAAe,EAAE,4BAA4B;IAC7C,gBAAg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;IACD,IAAI,kCAAkC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACxD,OAAO,SAAS,IAAI,CAAC,MAAM,uDAAuD,CAAC;IACrF,CAAC;IACD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,OAAO,eAAe,IAAI,CAAC,MAAM,8BAA8B,IAAI,CAAC,KAAK,EAAE,CAAC;IAC9E,CAAC;IACD,OAAO,SAAS,IAAI,CAAC,QAAQ,IAAI,GAAG,cAAc,IAAI,CAAC,MAAM,wBAAwB,IAAI,CAAC,KAAK,EAAE,CAAC;AACpG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "patchwork-os",
|
|
3
|
-
"version": "1.2.0-beta.2.canary.
|
|
3
|
+
"version": "1.2.0-beta.2.canary.740",
|
|
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",
|
|
@@ -7,6 +7,20 @@ description: Daily morning brief combining unread emails, calendar, recent git a
|
|
|
7
7
|
allowWrites:
|
|
8
8
|
- file.write
|
|
9
9
|
|
|
10
|
+
# Run-level completion contract. The steps can all report `ok` and the run can
|
|
11
|
+
# still finish `done` having produced no brief — an agent that narrates instead
|
|
12
|
+
# of answering, or a driver that returns empty, leaves `brief` unset and the
|
|
13
|
+
# file step then writes a heading with nothing under it. That is the failure
|
|
14
|
+
# this recipe actually has, and it is silent.
|
|
15
|
+
#
|
|
16
|
+
# `expect` is checked AFTER the last step and does not change the run's status:
|
|
17
|
+
# a violated contract is recorded as `assertionFailures` on the run and counted
|
|
18
|
+
# by `patchwork halts` under `completion contract failed`. So the run still
|
|
19
|
+
# writes whatever it produced — this reports, it does not roll back.
|
|
20
|
+
expect:
|
|
21
|
+
outputs:
|
|
22
|
+
- brief
|
|
23
|
+
|
|
10
24
|
trigger:
|
|
11
25
|
type: cron
|
|
12
26
|
at: "0 8 * * 1-5"
|