owenloop 0.5.27 → 0.5.29
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.
- package/CHANGELOG.md +21 -0
- package/dist/packages/work/src/agent/brief.d.ts +10 -0
- package/dist/packages/work/src/agent/brief.js +38 -0
- package/dist/packages/work/src/agent/loop.js +4 -0
- package/dist/packages/work/src/consumed-verifier.d.ts +22 -2
- package/dist/packages/work/src/consumed-verifier.js +131 -12
- package/dist/packages/work/src/contained-path.d.ts +18 -0
- package/dist/packages/work/src/contained-path.js +42 -0
- package/dist/packages/work/src/exec/instructions.js +43 -3
- package/dist/packages/work/src/harness/claude.js +21 -0
- package/dist/packages/work/src/harness/codex.js +29 -0
- package/dist/packages/work/src/harness/contract.d.ts +26 -0
- package/dist/packages/work/src/hold/mcp.d.ts +3 -40
- package/dist/packages/work/src/hold/mcp.js +121 -2
- package/dist/packages/work/src/hub/client.d.ts +10 -1
- package/dist/packages/work/src/hub/client.js +23 -0
- package/dist/packages/work/src/hub/types.d.ts +45 -0
- package/dist/packages/work/src/roles/shift.js +7 -1
- package/dist/packages/work/src/settings/settings.d.ts +12 -1
- package/dist/packages/work/src/settings/settings.js +7 -0
- package/dist/packages/work/src/shift/disk-floor.d.ts +107 -0
- package/dist/packages/work/src/shift/disk-floor.js +148 -0
- package/dist/packages/work/src/shift/host-preflight.d.ts +85 -0
- package/dist/packages/work/src/shift/host-preflight.js +112 -0
- package/dist/packages/work/src/shift/loop.d.ts +18 -0
- package/dist/packages/work/src/shift/loop.js +179 -7
- package/dist/packages/work/src/shift/protocol.d.ts +62 -1
- package/dist/packages/work/src/shift/runtime.d.ts +2 -0
- package/dist/packages/work/src/shift/runtime.js +17 -0
- package/dist/packages/work/src/submit-file.d.ts +3 -2
- package/dist/packages/work/src/submit-file.js +6 -22
- package/dist/src/crypto/records.d.ts +1 -0
- package/dist/src/crypto/records.js +1 -0
- package/dist/src/crypto/verify-consumed.d.ts +16 -1
- package/dist/src/crypto/verify-consumed.js +21 -6
- package/dist/src/schemas/index.d.ts +23 -0
- package/dist/src/schemas/order.v1.schema.json +14 -0
- package/dist/src/store/index.d.ts +1 -1
- package/dist/src/store/instruction-source.d.ts +15 -0
- package/dist/src/store/instruction-source.js +64 -4
- package/dist/src/store/types.d.ts +6 -2
- package/dist/src/store/types.js +5 -1
- package/dist/src/types.d.ts +11 -0
- package/docs/bundles.md +5 -1
- package/docs/cli.md +8 -5
- package/docs/crypto.md +46 -0
- package/docs/shift-logs.md +64 -7
- package/docs/wire-contracts.md +15 -2
- package/package.json +1 -1
- package/plugins/claude-code/plugin/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/plugin/.mcp.json +1 -1
- package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +1 -1
- package/plugins/codex/plugins/owenloop/.mcp.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,27 @@ All notable changes to this project are documented here. The format is based on
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
|
|
5
5
|
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.5.29](https://github.com/typicalday/owenloop/compare/v0.5.28...v0.5.29) (2026-09-05)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **work:** accept a relayed child proof for a calls-produced consumed artifact ([#310](https://github.com/typicalday/owenloop/issues/310)) ([7a185f6](https://github.com/typicalday/owenloop/commit/7a185f6cc42ba712db675d6c14f1d9ef1fdd9e8a))
|
|
13
|
+
|
|
14
|
+
## [0.5.28](https://github.com/typicalday/owenloop/compare/v0.5.27...v0.5.28) (2026-09-05)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **shift:** refuse new work when the disk is nearly full ([#307](https://github.com/typicalday/owenloop/issues/307)) ([fa5ab16](https://github.com/typicalday/owenloop/commit/fa5ab1662e797af1a0715cdac498ecd4018cc330))
|
|
20
|
+
* **work:** let a step store a file as an artifact ([#308](https://github.com/typicalday/owenloop/issues/308)) ([9972635](https://github.com/typicalday/owenloop/commit/997263516b4b3998b28ab7fd58cda139d6454ead))
|
|
21
|
+
* **work:** tell a step up front when its sandbox grants it nowhere to write ([#309](https://github.com/typicalday/owenloop/issues/309)) ([9c0c109](https://github.com/typicalday/owenloop/commit/9c0c10903a9cb37bdb4f1638fd4e036d07c4c573))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* **work:** stop a shift whose host is broken instead of wedging silently ([#305](https://github.com/typicalday/owenloop/issues/305)) ([594f0d8](https://github.com/typicalday/owenloop/commit/594f0d8a290e768ee16385d6c55b3d046c44b5cd))
|
|
27
|
+
|
|
7
28
|
## [0.5.27](https://github.com/typicalday/owenloop/compare/v0.5.26...v0.5.27) (2026-09-05)
|
|
8
29
|
|
|
9
30
|
|
|
@@ -82,6 +82,16 @@ export interface BriefSpec {
|
|
|
82
82
|
* were written to close.
|
|
83
83
|
*/
|
|
84
84
|
owes?: readonly OwedBrief[];
|
|
85
|
+
/**
|
|
86
|
+
* Whether this step's sandbox grants it no writable location at all, as
|
|
87
|
+
* resolved by the harness adapter from the step's own permissions.
|
|
88
|
+
*
|
|
89
|
+
* ONLY `true` RENDERS. Absent or `false` both mean "not known to be shut out",
|
|
90
|
+
* which is not the same as "may write freely" — this brief deliberately makes
|
|
91
|
+
* no positive claim about where a step may write, because no claim it could
|
|
92
|
+
* make would stay true (see `renderWorkspaceLine`).
|
|
93
|
+
*/
|
|
94
|
+
deniesAllWrites?: boolean;
|
|
85
95
|
}
|
|
86
96
|
/**
|
|
87
97
|
* One owed output as the brief sees it: the path, plus how many times a prior
|
|
@@ -36,6 +36,7 @@ export function renderBrief(templateContent, spec) {
|
|
|
36
36
|
.join(spec.shiftId ?? '');
|
|
37
37
|
const blocks = [
|
|
38
38
|
renderRoutingLine(spec),
|
|
39
|
+
renderWorkspaceLine(spec),
|
|
39
40
|
renderInputContract(spec),
|
|
40
41
|
renderSubmitContract(spec),
|
|
41
42
|
renderShapeContract(spec),
|
|
@@ -323,6 +324,43 @@ function renderRoutingLine(spec) {
|
|
|
323
324
|
: '';
|
|
324
325
|
return `Routing: this run was started at the '${spec.modifier}' depth modifier.${escalated}`;
|
|
325
326
|
}
|
|
327
|
+
/**
|
|
328
|
+
* That this step cannot write anywhere, stated before it tries.
|
|
329
|
+
*
|
|
330
|
+
* WHY THIS EXISTS. Measured on a live fleet: read-only steps discovered their
|
|
331
|
+
* own containment one denial at a time -- 87 `EPERM` refusals inside a single
|
|
332
|
+
* step family, every one of them a temporary directory the subject repository's
|
|
333
|
+
* OWN test helpers create. The cost is not the wasted attempts. It is what the
|
|
334
|
+
* agent then reported: one grounding step wrote that "34 file tests were not
|
|
335
|
+
* executed because mkdtemp is blocked by the read-only sandbox", and other
|
|
336
|
+
* attempts filed the same unrun checks as failures OF THE SUBJECT. A step that
|
|
337
|
+
* does not know it cannot write will eventually blame the thing it is judging.
|
|
338
|
+
*
|
|
339
|
+
* ONLY THE NEGATIVE IS STATED. An earlier draft also named the writable roots
|
|
340
|
+
* when there were some. That half was removed: a vendor composes its writable
|
|
341
|
+
* set from sources this process cannot see, so any list would eventually lie,
|
|
342
|
+
* and a vendor with roots to name already names them itself. The silence worth
|
|
343
|
+
* breaking is the other one -- a vendor that grants nothing says nothing.
|
|
344
|
+
*
|
|
345
|
+
* "Not executed" and "failed" are different findings, and only the agent can
|
|
346
|
+
* tell them apart at the moment of the denial. That distinction is the whole
|
|
347
|
+
* point of the line.
|
|
348
|
+
*
|
|
349
|
+
* Vendor-neutral by construction: no sandbox mode or vendor name appears here,
|
|
350
|
+
* only the fact the adapter resolved.
|
|
351
|
+
*/
|
|
352
|
+
function renderWorkspaceLine(spec) {
|
|
353
|
+
if (spec.deniesAllWrites !== true)
|
|
354
|
+
return '';
|
|
355
|
+
return ("Workspace: this step's sandbox grants it no writable location — not your" +
|
|
356
|
+
' working directory, not the system temp directory, not /tmp. A write is' +
|
|
357
|
+
' refused unless a person separately approves that one action, so treat' +
|
|
358
|
+
' writing as unavailable: creating a temporary directory fails, and any check' +
|
|
359
|
+
' that cannot run without writing will not run here. Report such a check as' +
|
|
360
|
+
' NOT EXECUTED and say why. Do NOT report it as a failure of the thing you' +
|
|
361
|
+
' are examining, and do not count it against the subject — an unrun check is' +
|
|
362
|
+
' missing evidence, not adverse evidence.');
|
|
363
|
+
}
|
|
326
364
|
/**
|
|
327
365
|
* The born-bound work-holder mount handed to `HarnessAdapter.start` as
|
|
328
366
|
* `StartArgs.owenloopMcp`. The adapter never constructs or changes the bound
|
|
@@ -724,6 +724,10 @@ export function createAgentRunLoop(opts) {
|
|
|
724
724
|
...(packet.modifier !== undefined ? { modifier: packet.modifier } : {}),
|
|
725
725
|
...(packet.escalated === true ? { escalated: true } : {}),
|
|
726
726
|
owes: briefOwes(packet),
|
|
727
|
+
// Only the adapter knows whether its own sandbox leaves this step a place
|
|
728
|
+
// to write. `false`/absent render nothing, so a `false` here is silence,
|
|
729
|
+
// not a claim that writing is permitted.
|
|
730
|
+
deniesAllWrites: active.deniesAllWrites?.(step.permissions) === true,
|
|
727
731
|
};
|
|
728
732
|
const permissions = step.permissions;
|
|
729
733
|
// Adapter-owned configuration is resolved once per worker life. Passing
|
|
@@ -37,9 +37,29 @@ export interface CreateConsumedVerifierArgs {
|
|
|
37
37
|
/** Optional warning sink; the returned warnings remain authoritative for callers. */
|
|
38
38
|
warn?: (line: string) => void;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
/** The calls-boundary facts for one consumed path, read by the caller from
|
|
41
|
+
* its VERIFIED local definition bytes: the parent's `calls:` step that
|
|
42
|
+
* produces the path, the exact child definition digest the parent pins, and
|
|
43
|
+
* the child's outcome stem. Never derived from the order. */
|
|
44
|
+
export interface VerifiedCallsProducer {
|
|
45
|
+
/** The parent step whose `calls:` produces the consumed path. */
|
|
46
|
+
step: string;
|
|
47
|
+
/** The `calls:` target as authored on that step. */
|
|
48
|
+
target: string;
|
|
49
|
+
/** Exact definition digest the verified parent pins the child at. */
|
|
50
|
+
childDefDigest: string;
|
|
51
|
+
/** The verified child definition's single outcome stem (`outputs[0]`). */
|
|
52
|
+
childOutcome: string;
|
|
53
|
+
}
|
|
54
|
+
export interface ConsumedVerifierOptions {
|
|
41
55
|
hardRule: boolean;
|
|
42
|
-
|
|
56
|
+
/** Calls-boundary context keyed by consumed path. Present only when the
|
|
57
|
+
* caller holds the verified definition (the command resolver). Without it
|
|
58
|
+
* a relayed record is `unverifiable`, never admitted: the hub's hints alone
|
|
59
|
+
* cannot say which child a parent pins. */
|
|
60
|
+
callsProducers?: Readonly<Record<string, VerifiedCallsProducer>>;
|
|
61
|
+
}
|
|
62
|
+
export type ConsumedVerifier = (order: OrderPacket, opts: ConsumedVerifierOptions) => Promise<ConsumedGateResult | ConsumedGateRefusal>;
|
|
43
63
|
/** Create a verifier bound to one injected local environment and clock. */
|
|
44
64
|
export declare function createConsumedVerifier(args: CreateConsumedVerifierArgs): ConsumedVerifier;
|
|
45
65
|
export declare function resetConsumedVerifierWarningsForTests(): void;
|
|
@@ -17,7 +17,7 @@ function errorText(error) {
|
|
|
17
17
|
return error instanceof Error ? error.message : String(error);
|
|
18
18
|
}
|
|
19
19
|
function linkFor(verdict) {
|
|
20
|
-
const match = verdict.reason.match(/^(no-proof|signature|value-digest|version|chain|scope|prerequisite):/);
|
|
20
|
+
const match = verdict.reason.match(/^(no-proof|signature|value-digest|version|chain|scope|prerequisite|calls):/);
|
|
21
21
|
if (match !== null)
|
|
22
22
|
return match[1];
|
|
23
23
|
return verdict.kind === 'invalid' ? 'signature' : 'prerequisite';
|
|
@@ -81,6 +81,88 @@ function parseProofMap(order) {
|
|
|
81
81
|
}
|
|
82
82
|
return { kind: 'ok', proofs };
|
|
83
83
|
}
|
|
84
|
+
function parseRelayMap(order) {
|
|
85
|
+
const raw = order.consumesProofRelay;
|
|
86
|
+
if (raw === undefined)
|
|
87
|
+
return { kind: 'ok', relays: {} };
|
|
88
|
+
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
|
|
89
|
+
return { kind: 'unverifiable', reason: 'prerequisite: consumesProofRelay is not a JSON object' };
|
|
90
|
+
}
|
|
91
|
+
const relays = {};
|
|
92
|
+
for (const [path, value] of Object.entries(raw)) {
|
|
93
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
94
|
+
return { kind: 'unverifiable', reason: `prerequisite: consumesProofRelay entry for artifact '${path}' is not an object` };
|
|
95
|
+
}
|
|
96
|
+
const entry = value;
|
|
97
|
+
if (typeof entry.childDefDigest !== 'string' || entry.childDefDigest === '') {
|
|
98
|
+
return { kind: 'unverifiable', reason: `prerequisite: consumesProofRelay entry for artifact '${path}' has no non-empty string 'childDefDigest'` };
|
|
99
|
+
}
|
|
100
|
+
if (typeof entry.childVersion !== 'number' || !Number.isInteger(entry.childVersion) || entry.childVersion < 0) {
|
|
101
|
+
return { kind: 'unverifiable', reason: `prerequisite: consumesProofRelay entry for artifact '${path}' has no non-negative integer 'childVersion'` };
|
|
102
|
+
}
|
|
103
|
+
if (typeof entry.childOutcome !== 'string' || entry.childOutcome === '') {
|
|
104
|
+
return { kind: 'unverifiable', reason: `prerequisite: consumesProofRelay entry for artifact '${path}' has no non-empty string 'childOutcome'` };
|
|
105
|
+
}
|
|
106
|
+
relays[path] = { childDefDigest: entry.childDefDigest, childVersion: entry.childVersion, childOutcome: entry.childOutcome };
|
|
107
|
+
}
|
|
108
|
+
return { kind: 'ok', relays };
|
|
109
|
+
}
|
|
110
|
+
function callsBoundary(path, relay, producers) {
|
|
111
|
+
if (producers === undefined) {
|
|
112
|
+
// A consumer with no verified definition (an agent worker) can neither
|
|
113
|
+
// confirm nor deny that the path is calls-produced: without a relay the
|
|
114
|
+
// path is an ordinary one to it, and with one it cannot corroborate.
|
|
115
|
+
if (relay === undefined)
|
|
116
|
+
return { kind: 'ordinary' };
|
|
117
|
+
return {
|
|
118
|
+
kind: 'uncorroborated',
|
|
119
|
+
verdict: {
|
|
120
|
+
kind: 'unverifiable',
|
|
121
|
+
reason: `prerequisite: artifact '${path}' carries a calls-boundary relay, but this consumer holds no verified definition to corroborate the calls child against`,
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const producer = producers[path];
|
|
126
|
+
if (producer === undefined) {
|
|
127
|
+
if (relay === undefined)
|
|
128
|
+
return { kind: 'ordinary' };
|
|
129
|
+
return {
|
|
130
|
+
kind: 'refused',
|
|
131
|
+
verdict: {
|
|
132
|
+
kind: 'invalid',
|
|
133
|
+
reason: `calls: artifact '${path}' carries a calls-boundary relay, but the verified definition does not produce it through a calls: step`,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
if (relay === undefined) {
|
|
138
|
+
return {
|
|
139
|
+
kind: 'refused',
|
|
140
|
+
verdict: {
|
|
141
|
+
kind: 'invalid',
|
|
142
|
+
reason: `calls: artifact '${path}' is produced by calls: step '${producer.step}' (${producer.target}), so only a relayed child proof can prove it, but the order carries no consumesProofRelay entry for it`,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (relay.childDefDigest !== producer.childDefDigest) {
|
|
147
|
+
return {
|
|
148
|
+
kind: 'refused',
|
|
149
|
+
verdict: {
|
|
150
|
+
kind: 'invalid',
|
|
151
|
+
reason: `calls: relay for artifact '${path}' names child definition digest '${relay.childDefDigest}', but the verified definition pins calls: step '${producer.step}' (${producer.target}) at '${producer.childDefDigest}'`,
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (relay.childOutcome !== producer.childOutcome) {
|
|
156
|
+
return {
|
|
157
|
+
kind: 'refused',
|
|
158
|
+
verdict: {
|
|
159
|
+
kind: 'invalid',
|
|
160
|
+
reason: `calls: relay for artifact '${path}' names child outcome '${relay.childOutcome}', but the verified child definition for calls: step '${producer.step}' declares outcome '${producer.childOutcome}'`,
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
return { kind: 'relay', relay, producer };
|
|
165
|
+
}
|
|
84
166
|
/** Create a verifier bound to one injected local environment and clock. */
|
|
85
167
|
export function createConsumedVerifier(args) {
|
|
86
168
|
const policy = mergePolicyFloorWithLocal('off', args.policyFloor, 'off', resolveArtifactPolicy(args.env, args.artifactPolicy)).artifactPolicy;
|
|
@@ -111,6 +193,7 @@ export function createConsumedVerifier(args) {
|
|
|
111
193
|
: undefined;
|
|
112
194
|
const rootPublicKey = root.kind === 'present' ? root.publicKey : '';
|
|
113
195
|
const proofs = parseProofMap(order);
|
|
196
|
+
const relays = parseRelayMap(order);
|
|
114
197
|
const warnings = [];
|
|
115
198
|
const chainCache = new Map();
|
|
116
199
|
const chainValidator = (input, options) => {
|
|
@@ -139,18 +222,54 @@ export function createConsumedVerifier(args) {
|
|
|
139
222
|
else if (proofs.kind === 'unverifiable') {
|
|
140
223
|
verdict = { kind: 'unverifiable', reason: proofs.reason };
|
|
141
224
|
}
|
|
225
|
+
else if (relays.kind === 'unverifiable') {
|
|
226
|
+
verdict = { kind: 'unverifiable', reason: relays.reason };
|
|
227
|
+
}
|
|
142
228
|
else {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
229
|
+
// The calls boundary is settled before any record is consulted: a
|
|
230
|
+
// calls-produced path without a relay, or a relay on a non-calls
|
|
231
|
+
// path, is refused here and never reaches ordinary verification.
|
|
232
|
+
const boundary = callsBoundary(path, relays.relays[path], opts.callsProducers);
|
|
233
|
+
if (boundary.kind === 'refused') {
|
|
234
|
+
verdict = boundary.verdict;
|
|
235
|
+
}
|
|
236
|
+
else if (boundary.kind !== 'ordinary' && proofs.proofs[path] === undefined) {
|
|
237
|
+
// Hints without a record prove nothing: the path stays unproven.
|
|
238
|
+
verdict = { kind: 'absent' };
|
|
239
|
+
}
|
|
240
|
+
else if (boundary.kind === 'uncorroborated') {
|
|
241
|
+
verdict = boundary.verdict;
|
|
242
|
+
}
|
|
243
|
+
else if (boundary.kind === 'relay') {
|
|
244
|
+
verdict = await verifyConsumed({
|
|
245
|
+
path,
|
|
246
|
+
value,
|
|
247
|
+
proof: proofs.proofs[path],
|
|
248
|
+
// The pinned CHILD outcome version. The parent's
|
|
249
|
+
// consumedFingerprint[path] counts the parent artifact and is a
|
|
250
|
+
// different number; a coincidental match must never be relied on.
|
|
251
|
+
expectedVersion: boundary.relay.childVersion,
|
|
252
|
+
relay: { childDefDigest: boundary.producer.childDefDigest, childOutcome: boundary.producer.childOutcome },
|
|
253
|
+
orgRootPublicKey: rootPublicKey,
|
|
254
|
+
grants,
|
|
255
|
+
revocations,
|
|
256
|
+
at,
|
|
257
|
+
demand: args.demand ?? {},
|
|
258
|
+
}, verifierOptions);
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
verdict = await verifyConsumed({
|
|
262
|
+
path,
|
|
263
|
+
value,
|
|
264
|
+
...(proofs.proofs[path] === undefined ? {} : { proof: proofs.proofs[path] }),
|
|
265
|
+
...(order.consumedFingerprint?.[path] === undefined ? {} : { expectedVersion: order.consumedFingerprint[path] }),
|
|
266
|
+
orgRootPublicKey: rootPublicKey,
|
|
267
|
+
grants,
|
|
268
|
+
revocations,
|
|
269
|
+
at,
|
|
270
|
+
demand: args.demand ?? {},
|
|
271
|
+
}, verifierOptions);
|
|
272
|
+
}
|
|
154
273
|
}
|
|
155
274
|
const result = policyOutcome(order, opts.hardRule, policy, path, verdict, warnings);
|
|
156
275
|
if (result !== undefined)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a caller-supplied path to a real file inside one containment root.
|
|
3
|
+
*
|
|
4
|
+
* Two checks, in this order and for two different attacks. The LEXICAL check
|
|
5
|
+
* rejects traversal (`../../etc/passwd`) before the filesystem is touched at
|
|
6
|
+
* all, so a probe cannot learn whether a path outside the root exists. The
|
|
7
|
+
* CANONICAL check then resolves symlinks on both sides and re-tests, because a
|
|
8
|
+
* name that is lexically inside the root can still POINT outside it — the
|
|
9
|
+
* lexical check alone would happily read the target of `evidence.json ->
|
|
10
|
+
* /Users/me/.ssh/id_ed25519`.
|
|
11
|
+
*
|
|
12
|
+
* `errorPrefix` is a machine-readable family name the caller owns, so each
|
|
13
|
+
* consumer keeps its own stable error vocabulary (`submit-value-file-…`,
|
|
14
|
+
* `file-artifact-…`) while the containment logic itself is written once. It is
|
|
15
|
+
* written once deliberately: two copies of a security check drift, and the copy
|
|
16
|
+
* that drifts is the one nobody is looking at.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveContainedPath(workdir: string, relativePath: string, errorPrefix: string): Promise<string>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { realpath } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { isInside } from "./harness/gatekeeper.js";
|
|
4
|
+
function errorMessage(error) {
|
|
5
|
+
return error instanceof Error ? error.message : String(error);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Resolve a caller-supplied path to a real file inside one containment root.
|
|
9
|
+
*
|
|
10
|
+
* Two checks, in this order and for two different attacks. The LEXICAL check
|
|
11
|
+
* rejects traversal (`../../etc/passwd`) before the filesystem is touched at
|
|
12
|
+
* all, so a probe cannot learn whether a path outside the root exists. The
|
|
13
|
+
* CANONICAL check then resolves symlinks on both sides and re-tests, because a
|
|
14
|
+
* name that is lexically inside the root can still POINT outside it — the
|
|
15
|
+
* lexical check alone would happily read the target of `evidence.json ->
|
|
16
|
+
* /Users/me/.ssh/id_ed25519`.
|
|
17
|
+
*
|
|
18
|
+
* `errorPrefix` is a machine-readable family name the caller owns, so each
|
|
19
|
+
* consumer keeps its own stable error vocabulary (`submit-value-file-…`,
|
|
20
|
+
* `file-artifact-…`) while the containment logic itself is written once. It is
|
|
21
|
+
* written once deliberately: two copies of a security check drift, and the copy
|
|
22
|
+
* that drifts is the one nobody is looking at.
|
|
23
|
+
*/
|
|
24
|
+
export async function resolveContainedPath(workdir, relativePath, errorPrefix) {
|
|
25
|
+
const candidate = resolve(workdir, relativePath);
|
|
26
|
+
if (!isInside(workdir, candidate)) {
|
|
27
|
+
throw new Error(`${errorPrefix}-outside-workdir: ${relativePath} is outside the run workdir`);
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const canonicalWorkdir = await realpath(workdir);
|
|
31
|
+
const canonicalCandidate = await realpath(candidate);
|
|
32
|
+
if (!isInside(canonicalWorkdir, canonicalCandidate)) {
|
|
33
|
+
throw new Error(`${errorPrefix}-outside-workdir: ${relativePath} is outside the run workdir`);
|
|
34
|
+
}
|
|
35
|
+
return canonicalCandidate;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error instanceof Error && error.message.startsWith(`${errorPrefix}-outside-workdir:`))
|
|
39
|
+
throw error;
|
|
40
|
+
throw new Error(`${errorPrefix}-read-failed: could not read ${relativePath}: ${errorMessage(error)}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -222,14 +222,54 @@ export function createStoreInstructionResolver(options) {
|
|
|
222
222
|
reasons: [],
|
|
223
223
|
})),
|
|
224
224
|
});
|
|
225
|
-
|
|
225
|
+
/**
|
|
226
|
+
* Calls boundary. For every consumed path the VERIFIED definition produces
|
|
227
|
+
* through a `calls:` step, read the facts a relayed child record is checked
|
|
228
|
+
* against — the pinned child definition digest and the child's outcome stem
|
|
229
|
+
* — from the same verified store closure the definition came from. Nothing
|
|
230
|
+
* here consults hub-supplied step text. A source without a dependency
|
|
231
|
+
* closure yields no context, and the verifier then treats any relay as
|
|
232
|
+
* unverifiable rather than guessing.
|
|
233
|
+
*/
|
|
234
|
+
const verifiedCallsProducers = (order, resolved) => {
|
|
235
|
+
if (source.getVerifiedCallsChild === undefined)
|
|
236
|
+
return { ok: true, producers: undefined };
|
|
237
|
+
const producers = {};
|
|
238
|
+
for (const path of Object.keys(order.consumes)) {
|
|
239
|
+
const callsStep = resolved.definition.steps.find((step) => step.calls !== undefined && step.produces.some((produce) => produce.stem === path));
|
|
240
|
+
if (callsStep?.calls === undefined)
|
|
241
|
+
continue;
|
|
242
|
+
const relayed = order.consumesProofRelay?.[path] !== undefined;
|
|
243
|
+
const child = source.getVerifiedCallsChild(order.defDigest, order.step, callsStep.name);
|
|
244
|
+
if (child === undefined) {
|
|
245
|
+
if (!relayed)
|
|
246
|
+
continue;
|
|
247
|
+
return refusal('integrity', order, `the verified definition produces artifact '${path}' through calls: step '${callsStep.name}' (${callsStep.calls}), but its child definition could not be resolved from the verified store closure`);
|
|
248
|
+
}
|
|
249
|
+
const childOutcome = child.definition.outputs?.[0];
|
|
250
|
+
if (childOutcome === undefined) {
|
|
251
|
+
if (!relayed)
|
|
252
|
+
continue;
|
|
253
|
+
return refusal('integrity', order, `the verified definition produces artifact '${path}' through calls: step '${callsStep.name}' (${callsStep.calls}), but the verified child definition '${child.definition.name}' declares no outcome`);
|
|
254
|
+
}
|
|
255
|
+
producers[path] = { step: callsStep.name, target: callsStep.calls, childDefDigest: child.bundleDigest, childOutcome };
|
|
256
|
+
}
|
|
257
|
+
return { ok: true, producers };
|
|
258
|
+
};
|
|
259
|
+
const gateConsumed = async (order, hardRule, resolved) => {
|
|
226
260
|
if (!hasConsumedData(order))
|
|
227
261
|
return undefined;
|
|
228
262
|
if (options.consumedVerifier === undefined) {
|
|
229
263
|
return refusal('unverified-consumed', order, 'consume-side verifier is not configured; dynamic values cannot be admitted to a command worker');
|
|
230
264
|
}
|
|
265
|
+
const callsContext = verifiedCallsProducers(order, resolved);
|
|
266
|
+
if (!callsContext.ok)
|
|
267
|
+
return callsContext;
|
|
231
268
|
try {
|
|
232
|
-
const checked = await options.consumedVerifier(commandConsumedOrder(order), {
|
|
269
|
+
const checked = await options.consumedVerifier(commandConsumedOrder(order), {
|
|
270
|
+
hardRule,
|
|
271
|
+
...(callsContext.producers === undefined ? {} : { callsProducers: callsContext.producers }),
|
|
272
|
+
});
|
|
233
273
|
if (!checked.ok)
|
|
234
274
|
return refusal('unverified-consumed', order, checked.reason);
|
|
235
275
|
for (const warning of checked.warnings)
|
|
@@ -276,7 +316,7 @@ export function createStoreInstructionResolver(options) {
|
|
|
276
316
|
// absent, unverifiable, or invalid dynamic evidence under
|
|
277
317
|
// artifactPolicy=off; otherwise a future command interpolation could
|
|
278
318
|
// carry an unverified value into `/bin/sh -c`.
|
|
279
|
-
const consumedRefusal = await gateConsumed(order, true);
|
|
319
|
+
const consumedRefusal = await gateConsumed(order, true, resolved);
|
|
280
320
|
if (consumedRefusal !== undefined)
|
|
281
321
|
return consumedRefusal;
|
|
282
322
|
const originRefusal = await checkOrigin(order, resolved);
|
|
@@ -542,6 +542,26 @@ function effectiveClaudeTools(permissions) {
|
|
|
542
542
|
return [...OWENLOOP_ONLY_NETWORK_TOOLS];
|
|
543
543
|
return undefined;
|
|
544
544
|
}
|
|
545
|
+
/**
|
|
546
|
+
* Whether this step is left with no way to write anything.
|
|
547
|
+
*
|
|
548
|
+
* This adapter has no path sandbox: `filesystem: 'read-only'` is enforced by
|
|
549
|
+
* NARROWING THE TOOL SET, so the honest test is whether a write-capable tool
|
|
550
|
+
* survives. `preflight` already refuses `read-only` alongside an authored
|
|
551
|
+
* non-read-only tool, but this recomputes the condition rather than trusting
|
|
552
|
+
* that it ran -- a brief that states containment must not rest on a check
|
|
553
|
+
* happening somewhere else.
|
|
554
|
+
*/
|
|
555
|
+
function deniesAllWrites(permissions) {
|
|
556
|
+
if (permissions.filesystem !== 'read-only')
|
|
557
|
+
return false;
|
|
558
|
+
const effective = effectiveClaudeTools(permissions);
|
|
559
|
+
// The `undefined` arm is a type guard, not a case: `read-only` always resolves
|
|
560
|
+
// to a concrete set. It is spelled out so the write-capability test below is
|
|
561
|
+
// the only thing deciding the answer.
|
|
562
|
+
return (effective !== undefined &&
|
|
563
|
+
effective.every((tool) => READ_ONLY_TOOLS.has(tool) || OWENLOOP_CONTROL_TOOLS.has(tool)));
|
|
564
|
+
}
|
|
545
565
|
function strictWorkdirToolIssue(permissions) {
|
|
546
566
|
const effective = effectiveClaudeTools(permissions);
|
|
547
567
|
if (effective === undefined) {
|
|
@@ -1644,6 +1664,7 @@ export const claudeAdapter = {
|
|
|
1644
1664
|
deliver: deliverClaude,
|
|
1645
1665
|
stop,
|
|
1646
1666
|
lintStep,
|
|
1667
|
+
deniesAllWrites,
|
|
1647
1668
|
resumeCommand,
|
|
1648
1669
|
};
|
|
1649
1670
|
// Self-registration at import time: importing this module is what puts the
|
|
@@ -1078,11 +1078,40 @@ function lintStep(bag, step) {
|
|
|
1078
1078
|
}
|
|
1079
1079
|
return findings;
|
|
1080
1080
|
}
|
|
1081
|
+
/**
|
|
1082
|
+
* What this sandbox lets the step write, as plain paths.
|
|
1083
|
+
*
|
|
1084
|
+
* The three modes map cleanly: `read-only` writes nowhere; `danger-full-access`
|
|
1085
|
+
* writes everywhere, which no finite list describes, so it answers `undefined`
|
|
1086
|
+
* rather than a list that would read as a restriction; `workspace-write` writes
|
|
1087
|
+
* to the working directory plus the two temp roots this vendor grants by
|
|
1088
|
+
* default, minus whichever of those two the step excluded itself.
|
|
1089
|
+
*
|
|
1090
|
+
* A permissions bag this adapter would refuse at preflight answers `undefined`
|
|
1091
|
+
* too: `resolveSandbox` throws on it, and a brief line is not the place to
|
|
1092
|
+
* surface a configuration error that `preflight` already reports properly.
|
|
1093
|
+
*/
|
|
1094
|
+
function deniesAllWrites(permissions) {
|
|
1095
|
+
let sandbox;
|
|
1096
|
+
try {
|
|
1097
|
+
sandbox = resolveSandbox(permissions);
|
|
1098
|
+
}
|
|
1099
|
+
catch {
|
|
1100
|
+
// A bag this adapter refuses is a bag it cannot reason about. Claiming the
|
|
1101
|
+
// step is shut out would be a guess, and the honest answer to a guess here
|
|
1102
|
+
// is silence.
|
|
1103
|
+
return false;
|
|
1104
|
+
}
|
|
1105
|
+
// Only `read-only` grants no writable root. The other two modes grant at
|
|
1106
|
+
// least one, and the vendor names those itself, so this adapter does not.
|
|
1107
|
+
return sandbox === 'read-only';
|
|
1108
|
+
}
|
|
1081
1109
|
export const codexAdapter = {
|
|
1082
1110
|
id: HARNESS_ID,
|
|
1083
1111
|
resumeTier: 'native-token',
|
|
1084
1112
|
preflight: codexPreflight,
|
|
1085
1113
|
lintStep,
|
|
1114
|
+
deniesAllWrites,
|
|
1086
1115
|
/**
|
|
1087
1116
|
* The command a human runs to re-open this thread in an interactive terminal.
|
|
1088
1117
|
*
|
|
@@ -443,6 +443,32 @@ export interface HarnessAdapter {
|
|
|
443
443
|
* NOT throw from here — a lint pass over a malformed bag returns findings.
|
|
444
444
|
*/
|
|
445
445
|
lintStep?(bag: Record<string, unknown>, step: string): LintFinding[];
|
|
446
|
+
/**
|
|
447
|
+
* Whether this step's sandbox grants it NO writable location at all.
|
|
448
|
+
*
|
|
449
|
+
* DELIBERATELY NARROW, AND THE NARROWNESS IS THE POINT. An earlier draft of
|
|
450
|
+
* this member returned the list of writable roots. That could not be made
|
|
451
|
+
* true: a vendor composes its writable set from sources this process cannot
|
|
452
|
+
* see -- on-disk configuration layers, roots granted by a human mid-turn, and
|
|
453
|
+
* read-only carve-outs the vendor keeps INSIDE each writable root (a `.git`
|
|
454
|
+
* pointer to an external gitdir, for one). Every one of those makes a list
|
|
455
|
+
* either overstate or understate what the step may touch, and a brief that
|
|
456
|
+
* misstates containment is worse than one that says nothing. The vendor also
|
|
457
|
+
* already tells the model its writable roots when it has any.
|
|
458
|
+
*
|
|
459
|
+
* The negative has none of those problems. "No writable root was granted" is
|
|
460
|
+
* decidable from the step's own resolved permissions, it is the case the
|
|
461
|
+
* vendor says NOTHING about (it has no roots to name), and it is the case that
|
|
462
|
+
* cost real work: measured on a live fleet, read-only steps discovered their
|
|
463
|
+
* own containment one `EPERM` at a time and then filed the resulting unrun
|
|
464
|
+
* checks as failures of the subject under review rather than as checks that
|
|
465
|
+
* never ran.
|
|
466
|
+
*
|
|
467
|
+
* `false` is not a promise that a write will succeed -- it means only that
|
|
468
|
+
* this adapter cannot say the step is shut out. An adapter that does not model
|
|
469
|
+
* a sandbox omits the member entirely.
|
|
470
|
+
*/
|
|
471
|
+
deniesAllWrites?(permissions: StepPermissions): boolean;
|
|
446
472
|
/**
|
|
447
473
|
* OPTIONAL — the command a HUMAN would run to open this session interactively,
|
|
448
474
|
* for `owenloop work sessions` to print.
|
|
@@ -1,40 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `owenloop work hold --mcp` stdio-MCP mount (plan part 2).
|
|
3
|
-
*
|
|
4
|
-
* A born-bound work-holder: the D2 stamped Step Agent's frontmatter declares
|
|
5
|
-
* `mcpServers.owenloop = owenloop work hold --order <wf>/<run> --origin <url> --mcp`,
|
|
6
|
-
* so when the Step Agent session boots it launches THIS as a stdio MCP server. The
|
|
7
|
-
* server exposes four bare tools the model uses to do its order:
|
|
8
|
-
* - `get_order` → the order packet (prompt, inputs, owed outputs) for the run
|
|
9
|
-
* this holder is bound to. No ids are arguments — they came in on argv, never
|
|
10
|
-
* through the model.
|
|
11
|
-
* - `submit` → post a receipt for an owed output path; when the hub reports
|
|
12
|
-
* the submit CLOSED the run, the lease loop is stopped with `release:false`
|
|
13
|
-
* (the claim is already gone).
|
|
14
|
-
* - `reject` → invalidate a consumed artifact through the claiming step's
|
|
15
|
-
* server-derived authority; the client never supplies `by`. A CLOSED reject
|
|
16
|
-
* also stops the lease loop without releasing the already-closed claim.
|
|
17
|
-
* - `ask` → stop and escalate to a human about an OWED output path. The
|
|
18
|
-
* third exit. `submit` and `reject` both assume the worker can finish; until
|
|
19
|
-
* `ask` existed a worker that genuinely could not had only two moves, and
|
|
20
|
-
* both damaged the run: submit something it did not believe (greens a
|
|
21
|
-
* fabrication that every downstream step then builds on), or end its turn
|
|
22
|
-
* silently (the task re-arms and a fresh worker relearns the same blocker
|
|
23
|
-
* until the stall cap). `ask` holds the artifact with no counter movement
|
|
24
|
-
* and surfaces the question to an operator, who answers with
|
|
25
|
-
* `owenloop retry <workflow> <path> --text "<answer>"`.
|
|
26
|
-
*
|
|
27
|
-
* Underneath the tools, the SAME lease loop the CLI `hold` runs keeps the order's
|
|
28
|
-
* lease warm: `createHoldMcp` builds the loop with `onOrder` wired to capture the
|
|
29
|
-
* first-contact packet (so `get_order` needn't re-fetch) and both output sinks
|
|
30
|
-
* routed to stderr (stdout is the JSON-RPC channel). The role starts the loop and
|
|
31
|
-
* pumps stdin into the server; loop and server share one process, and stdin EOF
|
|
32
|
-
* (the session died) stops the loop for its final-breath release.
|
|
33
|
-
*
|
|
34
|
-
* This module is pure wiring + tool handlers — no stdio, no process, no timers of
|
|
35
|
-
* its own — so a unit test drives the tools with a fake hub and a scriptable
|
|
36
|
-
* clock. The role (`src/roles/hold.ts`) owns the real stdin/stdout pump.
|
|
37
|
-
*/
|
|
38
1
|
import { type ToolRegistration } from '../mcp/server.ts';
|
|
39
2
|
import type { HubClient } from '../hub/client.ts';
|
|
40
3
|
import type { ContactHolder } from '../hub/types.ts';
|
|
@@ -42,7 +5,7 @@ import { type SubmissionKeyManager } from '../submit-proof.ts';
|
|
|
42
5
|
import type { SshProcessAdapter } from '../../../../src/crypto/ssh.ts';
|
|
43
6
|
import type { ConsumedVerifier } from '../consumed-verifier.ts';
|
|
44
7
|
import { type HoldLoop } from './loop.ts';
|
|
45
|
-
export declare const HOLD_MCP_TOOL_NAMES: readonly ["get_order", "submit", "reject", "ask"];
|
|
8
|
+
export declare const HOLD_MCP_TOOL_NAMES: readonly ["get_order", "submit", "reject", "ask", "put_file_artifact"];
|
|
46
9
|
export type HoldMcpToolName = (typeof HOLD_MCP_TOOL_NAMES)[number];
|
|
47
10
|
export interface HoldMcpDeps {
|
|
48
11
|
hub: HubClient;
|
|
@@ -50,7 +13,7 @@ export interface HoldMcpDeps {
|
|
|
50
13
|
run: string;
|
|
51
14
|
/** Sole containment root for submit value files. */
|
|
52
15
|
workdir: string;
|
|
53
|
-
/** Positive registration list. Absent exposes
|
|
16
|
+
/** Positive registration list. Absent exposes every tool in `HOLD_MCP_TOOL_NAMES`. */
|
|
54
17
|
tools?: readonly HoldMcpToolName[];
|
|
55
18
|
/** Hub origin used to resolve the local machine signing key. */
|
|
56
19
|
origin?: string;
|
|
@@ -71,7 +34,7 @@ export interface HoldMcpDeps {
|
|
|
71
34
|
jumpToleranceMs?: number;
|
|
72
35
|
}
|
|
73
36
|
export interface HoldMcpMount {
|
|
74
|
-
/** Exactly the selected registrations; full mode has
|
|
37
|
+
/** Exactly the selected registrations; full mode has every tool. */
|
|
75
38
|
tools: ToolRegistration[];
|
|
76
39
|
/** The lease loop kept warm underneath — the role runs and stops it. */
|
|
77
40
|
loop: HoldLoop;
|