owenloop 0.5.3 → 0.5.5
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 +25 -0
- package/README.md +6 -2
- package/dist/packages/work/src/agent/brief.d.ts +6 -0
- package/dist/packages/work/src/agent/brief.js +102 -2
- package/dist/packages/work/src/agent/loop.d.ts +10 -1
- package/dist/packages/work/src/agent/loop.js +28 -0
- package/dist/packages/work/src/agent/workdir.d.ts +22 -0
- package/dist/packages/work/src/agent/workdir.js +80 -0
- package/dist/packages/work/src/exec/loop.d.ts +13 -1
- package/dist/packages/work/src/exec/loop.js +184 -9
- package/dist/packages/work/src/harness/child-env.js +8 -0
- package/dist/packages/work/src/harness/claude.js +25 -6
- package/dist/packages/work/src/harness/codex.js +7 -0
- package/dist/packages/work/src/harness/contract.d.ts +22 -3
- package/dist/packages/work/src/harness/contract.js +22 -3
- package/dist/packages/work/src/hold/mcp.d.ts +11 -2
- package/dist/packages/work/src/hold/mcp.js +69 -2
- package/dist/packages/work/src/hub/client.d.ts +8 -1
- package/dist/packages/work/src/hub/client.js +1 -0
- package/dist/packages/work/src/hub/types.d.ts +29 -0
- package/dist/packages/work/src/roles/agent-run.js +9 -1
- package/dist/packages/work/src/roles/exec.js +9 -0
- package/dist/packages/work/src/roles/shift.js +9 -1
- package/dist/packages/work/src/settings/settings.d.ts +32 -5
- package/dist/packages/work/src/settings/settings.js +37 -12
- package/dist/packages/work/src/shift/runtime.d.ts +7 -0
- package/dist/packages/work/src/shift/runtime.js +29 -4
- package/dist/packages/work/src/shift/spawn.d.ts +12 -2
- package/dist/packages/work/src/shift/spawn.js +16 -3
- package/dist/src/cli.js +257 -7
- package/dist/src/config-dir.d.ts +62 -0
- package/dist/src/config-dir.js +87 -0
- package/dist/src/crypto/trust-roots.d.ts +8 -4
- package/dist/src/crypto/trust-roots.js +18 -12
- package/dist/src/defs.js +57 -16
- package/dist/src/engine.d.ts +46 -1
- package/dist/src/engine.js +97 -3
- package/dist/src/hub.d.ts +5 -1
- package/dist/src/hub.js +7 -8
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/model.d.ts +29 -5
- package/dist/src/model.js +63 -14
- package/dist/src/paths.d.ts +47 -4
- package/dist/src/paths.js +36 -5
- package/dist/src/types.d.ts +8 -2
- package/dist/src/work-settings.d.ts +8 -5
- package/dist/src/work-settings.js +15 -12
- package/docs/authoring.md +40 -13
- package/docs/bundles.md +9 -0
- package/docs/cli.md +155 -24
- package/docs/crypto.md +8 -8
- package/docs/design.md +20 -2
- package/docs/embedding.md +5 -4
- package/docs/wire-contracts.md +3 -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,31 @@ 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.5](https://github.com/typicalday/owenloop/compare/v0.5.4...v0.5.5) (2026-08-15)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* give every step agent a channel to ask a human ([#168](https://github.com/typicalday/owenloop/issues/168)) ([fa9e5f0](https://github.com/typicalday/owenloop/commit/fa9e5f08d3a9f55c6e95cc504966a6389ec699c4))
|
|
13
|
+
* let a shift operator declare where work may happen ([#166](https://github.com/typicalday/owenloop/issues/166)) ([71e9412](https://github.com/typicalday/owenloop/commit/71e9412c534ba826490dc62464989b47a6f551fe))
|
|
14
|
+
|
|
15
|
+
## [0.5.4](https://github.com/typicalday/owenloop/compare/v0.5.3...v0.5.4) (2026-08-15)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* add `owenloop cancel` to stop a running hub instance ([#158](https://github.com/typicalday/owenloop/issues/158)) ([76ccc75](https://github.com/typicalday/owenloop/commit/76ccc75cf4b1c9312484e691663f9e5c9e1ebe9a))
|
|
21
|
+
* add `owenloop instance show` to read a hub run's live state ([#161](https://github.com/typicalday/owenloop/issues/161)) ([9ab7cec](https://github.com/typicalday/owenloop/commit/9ab7cec6f72dc79c11c2c7079174f9581ff97304))
|
|
22
|
+
* let workdirFrom name a declared input, not only a consume ([#165](https://github.com/typicalday/owenloop/issues/165)) ([fff886b](https://github.com/typicalday/owenloop/commit/fff886b86c097a1b85de745faa322cf92d0e5615))
|
|
23
|
+
* state the submit contract in every rendered brief ([#160](https://github.com/typicalday/owenloop/issues/160)) ([f62430d](https://github.com/typicalday/owenloop/commit/f62430d1febc77597cafb25e8b2928f1ab7e7fb3))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* deliver a payload reject before the owed submits, not after ([#164](https://github.com/typicalday/owenloop/issues/164)) ([b38b709](https://github.com/typicalday/owenloop/commit/b38b709aededd0ebef2684f8c64abb8fe68226de))
|
|
29
|
+
* relay a failed command step's own output to the exec log ([#162](https://github.com/typicalday/owenloop/issues/162)) ([d40595d](https://github.com/typicalday/owenloop/commit/d40595dbfe40bfbf6f5d729296189e5b88424eec))
|
|
30
|
+
* scope owenloop's config dir without hijacking XDG_CONFIG_HOME ([#163](https://github.com/typicalday/owenloop/issues/163)) ([72838b4](https://github.com/typicalday/owenloop/commit/72838b45e3fb6f52038001148bca62f879a90efc))
|
|
31
|
+
|
|
7
32
|
## [0.5.3](https://github.com/typicalday/owenloop/compare/v0.5.2...v0.5.3) (2026-08-14)
|
|
8
33
|
|
|
9
34
|
|
package/README.md
CHANGED
|
@@ -487,8 +487,12 @@ hub's own def hashes. `owenloop agent new
|
|
|
487
487
|
Setting up a machine from scratch? `owenloop setup` may sign you in as a human
|
|
488
488
|
and, when needed, mint or rekey and store a Scoped Identity. Setup writes only
|
|
489
489
|
`hubOrigin` into the execution settings file, preserving the other keys. The
|
|
490
|
-
file is `$
|
|
491
|
-
|
|
490
|
+
file is `$OWENLOOP_CONFIG_DIR/settings.json` when `OWENLOOP_CONFIG_DIR` is set
|
|
491
|
+
to a non-blank absolute path; otherwise `$XDG_CONFIG_HOME/owenloop/settings.json`
|
|
492
|
+
when `XDG_CONFIG_HOME` is non-blank; otherwise
|
|
493
|
+
`$HOME/.config/owenloop/settings.json`. Prefer `OWENLOOP_CONFIG_DIR` when
|
|
494
|
+
running several shifts on one machine — `XDG_CONFIG_HOME` also relocates `gh`,
|
|
495
|
+
`git`, and `gcloud` for every command step the shift dispatches. For
|
|
492
496
|
a non-default account,
|
|
493
497
|
setup only prints the `OWENLOOP_ACCOUNT=<name>` instruction. Setup probes and,
|
|
494
498
|
when needed, converges the bundled `owenloop` plugins for Claude Code and Codex.
|
|
@@ -69,6 +69,12 @@ export interface BriefSpec {
|
|
|
69
69
|
* repeated rejections, not a first attempt.
|
|
70
70
|
*/
|
|
71
71
|
escalated?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* The owed output paths for this order, in packet order — `packet.owes`
|
|
74
|
+
* mapped to its `path`. Feeds the submit contract; absent or empty renders
|
|
75
|
+
* the contract without naming any path.
|
|
76
|
+
*/
|
|
77
|
+
owes?: readonly string[];
|
|
72
78
|
}
|
|
73
79
|
/**
|
|
74
80
|
* Substitute the four dispatch tokens into a step template.
|
|
@@ -28,8 +28,108 @@ export function renderBrief(templateContent, spec) {
|
|
|
28
28
|
.join(spec.account)
|
|
29
29
|
.split(SHIFT_TOKEN)
|
|
30
30
|
.join(spec.shiftId ?? '');
|
|
31
|
-
const
|
|
32
|
-
|
|
31
|
+
const blocks = [
|
|
32
|
+
renderRoutingLine(spec),
|
|
33
|
+
renderSubmitContract(spec),
|
|
34
|
+
renderEscalationContract(spec),
|
|
35
|
+
substituted,
|
|
36
|
+
];
|
|
37
|
+
return blocks.filter((b) => b !== '').join('\n\n');
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* How an order is COMPLETED, stated to every agent on every run.
|
|
41
|
+
*
|
|
42
|
+
* WHY THIS EXISTS. Nothing else ever told an agent that finishing means calling
|
|
43
|
+
* a tool. The engine mounts the work-holder MCP server and then relies entirely
|
|
44
|
+
* on the def author's prose; owenloop's own house verb for it is "green <path>
|
|
45
|
+
* with <value>", which names no tool and is not a phrase any model has seen
|
|
46
|
+
* before. A strong enough model infers the tool call from the mounted surface
|
|
47
|
+
* and submits; a weaker one reads the same sentence as "print this JSON",
|
|
48
|
+
* writes the value into a code fence, and ends its turn. The hub then records
|
|
49
|
+
* nothing, the confirm grace lapses, and the order is re-offered — so the step
|
|
50
|
+
* loops forever while every attempt does the work correctly. That is a defect
|
|
51
|
+
* in what the engine states, not in the def or the model: the engine is the
|
|
52
|
+
* only party that knows the submit contract, so the engine has to state it.
|
|
53
|
+
*
|
|
54
|
+
* WHY IT NAMES THE OWED PATHS. `submit` is per-path and takes the path as an
|
|
55
|
+
* argument, so "call submit" alone is not actionable — an agent that owes two
|
|
56
|
+
* outputs and submits one is as stuck as one that submits none. The list comes
|
|
57
|
+
* from `packet.owes`, which is the hub's own answer to "what does this order
|
|
58
|
+
* still owe", so it stays correct on a re-offer where some paths are already
|
|
59
|
+
* paid.
|
|
60
|
+
*
|
|
61
|
+
* WHY THE COUNTER-EXAMPLE IS SPELLED OUT. The observed failure is not a refusal
|
|
62
|
+
* to submit — it is a belief that printing IS submitting. Naming the tool
|
|
63
|
+
* without ruling out the near-miss leaves that belief intact.
|
|
64
|
+
*
|
|
65
|
+
* Vendor-neutral by construction: it names owenloop's own tool and mount, and
|
|
66
|
+
* no harness. `test/vendor-gate.test.ts` fails any shipped file outside
|
|
67
|
+
* `src/harness/` that names a vendor.
|
|
68
|
+
*/
|
|
69
|
+
function renderSubmitContract(spec) {
|
|
70
|
+
const owed = (spec.owes ?? []).filter((p) => p !== '');
|
|
71
|
+
// Nothing owed, nothing to say — the same stance the routing line takes on an
|
|
72
|
+
// absent modifier. A contract with no path to name would have to write
|
|
73
|
+
// `<path>` into its own example, which teaches the shape of the call while
|
|
74
|
+
// leaving the one argument that matters unanswered.
|
|
75
|
+
if (owed.length === 0)
|
|
76
|
+
return '';
|
|
77
|
+
return [
|
|
78
|
+
`How this order completes: submit your result with the \`submit\` tool on the mounted \`owenloop\` MCP server. You owe ${owed.map((p) => `\`${p}\``).join(', ')} — call it once for each.`,
|
|
79
|
+
`Example: \`submit({"path": "${owed[0]}", "value": <the value this brief asks for>})\`.`,
|
|
80
|
+
'Printing that value as text, or inside a code fence, does NOT submit it — the turn ends, the hub records nothing, and this order is re-offered from scratch. Wherever this brief says "green <path> with <value>", it means exactly this tool call.',
|
|
81
|
+
].join('\n');
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* What an agent does when it CANNOT complete the order, stated to every agent on
|
|
85
|
+
* every run, right after the submit contract.
|
|
86
|
+
*
|
|
87
|
+
* WHY THIS EXISTS. The submit contract closes one hole (an agent that finished
|
|
88
|
+
* but did not know how to say so). This closes the opposite one: an agent that
|
|
89
|
+
* did NOT finish and has no legal way to say so. Until `ask` shipped there were
|
|
90
|
+
* exactly two exits from a step, and a blocked agent had to pick the less
|
|
91
|
+
* damaging:
|
|
92
|
+
* - Submit anyway. The artifact goes green on a value the agent does not
|
|
93
|
+
* believe, and every downstream step builds on it. Observed on a real run:
|
|
94
|
+
* a planner that could read nothing produced a confident, fictional plan and
|
|
95
|
+
* a builder started executing it.
|
|
96
|
+
* - End the turn without submitting. The lease lapses, the task re-arms, and a
|
|
97
|
+
* fresh worker starts from the identical missing information. It repeats
|
|
98
|
+
* until the stall cap, spending a full model run per attempt to relearn the
|
|
99
|
+
* same blocker, and no human is ever told.
|
|
100
|
+
* Neither reaches a person. Both were watched happening. The tool is the fix and
|
|
101
|
+
* this paragraph is what makes the tool reachable — a mounted tool nobody is
|
|
102
|
+
* told about is dead code.
|
|
103
|
+
*
|
|
104
|
+
* WHY IT NAMES THE COST. Models are heavily biased toward producing an answer,
|
|
105
|
+
* and an escalation path that reads as failure will not be taken. So the text
|
|
106
|
+
* states the two facts that make asking the correct move rather than the
|
|
107
|
+
* cowardly one: it costs no attempts, and guessing is worse than asking.
|
|
108
|
+
*
|
|
109
|
+
* WHY IT STATES THE BAR. "Ask whenever unsure" would turn every ambiguity into a
|
|
110
|
+
* human interrupt and the channel would be ignored within a day. The bar is
|
|
111
|
+
* concrete: ask when the missing thing cannot be recovered by working — reading
|
|
112
|
+
* the repo, running a read-only command, re-reading the inputs — because those
|
|
113
|
+
* are exactly the cases where another attempt cannot help.
|
|
114
|
+
*
|
|
115
|
+
* Rendered only when the order owes something, for the same reason the submit
|
|
116
|
+
* contract is: `ask` takes an owed path as its argument, and a contract that has
|
|
117
|
+
* to write `<path>` into its own example teaches the call shape while leaving
|
|
118
|
+
* the one argument that matters unanswered.
|
|
119
|
+
*
|
|
120
|
+
* Vendor-neutral by construction — names owenloop's own tool and mount only.
|
|
121
|
+
*/
|
|
122
|
+
function renderEscalationContract(spec) {
|
|
123
|
+
const owed = (spec.owes ?? []).filter((p) => p !== '');
|
|
124
|
+
if (owed.length === 0)
|
|
125
|
+
return '';
|
|
126
|
+
return [
|
|
127
|
+
`If you CANNOT produce what this order asks for, do not guess and do not end your turn silently — call the \`ask\` tool on the same \`owenloop\` MCP server and stop.`,
|
|
128
|
+
`Example: \`ask({"path": "${owed[0]}", "question": "<the specific decision or fact you need from a person>", "context": "<what you already tried>"})\`.`,
|
|
129
|
+
'Ask when the thing you are missing cannot be recovered by working: a required input is absent, wrong, or contradicts another input; the order asks for a judgment only the operator can make; or you cannot reach something the order depends on. Do NOT ask for anything you could resolve by reading the repository, re-reading your inputs, or running a read-only command — do that first.',
|
|
130
|
+
'Asking costs you nothing: it is not a failed attempt, it consumes none of this step\'s retry budget, and it is the correct outcome when the honest answer is "I do not know". Submitting a value you do not believe is worse than asking — it goes green and every later step builds on it. Ending your turn without submitting is worse than asking — this step simply re-runs with the same information missing, and no person is ever told.',
|
|
131
|
+
'After you ask, your run is over. A human answers on the same artifact and a fresh attempt starts with their answer attached.',
|
|
132
|
+
].join('\n');
|
|
33
133
|
}
|
|
34
134
|
/**
|
|
35
135
|
* The run's depth, stated to the agent in one line, PREPENDED rather than
|
|
@@ -6,7 +6,7 @@ import type { HarnessAdapter } from '../harness/contract.ts';
|
|
|
6
6
|
import { type SessionRecord } from '../harness/session-store.ts';
|
|
7
7
|
import { type CapabilityModelMap, type CapabilityResolution } from './capability-model.ts';
|
|
8
8
|
/** Discriminated result of one worker life; the role maps these to exit codes. */
|
|
9
|
-
export type AgentRunOutcome = 'submitted' | 'completed' | 'misroute' | 'no-template' | 'no-harness' | 'incompatible-harness-policy' | 'unresolvable-capability' | 'unverified-consumed' | 'session-store-failed' | 'no-submit' | 'killed' | 'lease-lost' | 'ownership-error' | 'hub-unreachable' | 'stopped';
|
|
9
|
+
export type AgentRunOutcome = 'submitted' | 'completed' | 'misroute' | 'workdir-denied' | 'no-template' | 'no-harness' | 'incompatible-harness-policy' | 'unresolvable-capability' | 'unverified-consumed' | 'session-store-failed' | 'no-submit' | 'killed' | 'lease-lost' | 'ownership-error' | 'hub-unreachable' | 'stopped';
|
|
10
10
|
/**
|
|
11
11
|
* Locate the normalized step spec for an order. Injected because the lookup is
|
|
12
12
|
* I/O (the verified workflow store) and because resolving the local definition
|
|
@@ -52,6 +52,15 @@ export interface AgentRunLoopOptions {
|
|
|
52
52
|
shiftId?: string;
|
|
53
53
|
/** cwd for the step agent when the order packet carries no `workdir`. */
|
|
54
54
|
cwd: string;
|
|
55
|
+
/**
|
|
56
|
+
* The directories this MACHINE's operator declared as places work may happen,
|
|
57
|
+
* already resolved to absolute paths by `resolveAllowedWorkdirRoots`.
|
|
58
|
+
*
|
|
59
|
+
* NOT `workRoot`. `workRoot` is the single directory owenloop CREATES worktrees
|
|
60
|
+
* under; this is the set of directories an ORDER is permitted to name as its
|
|
61
|
+
* cwd. UNSET or EMPTY means NO RESTRICTION.
|
|
62
|
+
*/
|
|
63
|
+
allowedWorkdirRoots?: string[];
|
|
55
64
|
loadStep: StepLoader;
|
|
56
65
|
resolveAdapter: AdapterResolver;
|
|
57
66
|
/**
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
* back would waste a whole re-offer cycle to learn something already known.
|
|
58
58
|
*/
|
|
59
59
|
import { existsSync } from 'node:fs';
|
|
60
|
+
import { isWorkdirAllowed } from "./workdir.js";
|
|
60
61
|
import { createLeaseLoop } from "../lease/loop.js";
|
|
61
62
|
import { isResumeUnavailable } from "../harness/contract.js";
|
|
62
63
|
import { preflightStepPermissions } from "../harness/permissions.js";
|
|
@@ -363,6 +364,30 @@ export function createAgentRunLoop(opts) {
|
|
|
363
364
|
}
|
|
364
365
|
stepName = packet.step;
|
|
365
366
|
recordCwd = packet.workdir ?? opts.cwd;
|
|
367
|
+
// MACHINE POLICY. The operator who started this shift named the directories
|
|
368
|
+
// work may happen in (`owenloop shift start --work-root`, or
|
|
369
|
+
// `allowedWorkdirRoots` in settings). This worker is one of only two
|
|
370
|
+
// processes that ever sees `OrderPacket.workdir` — the shift's `whats_next`
|
|
371
|
+
// sweep receives a `WorkOrder`, which carries no such field — so the check
|
|
372
|
+
// belongs here and cannot be hoisted into dispatch.
|
|
373
|
+
//
|
|
374
|
+
// RELEASED, not failed, and BEFORE the step spec is loaded or any provider
|
|
375
|
+
// session is opened. Declining work this machine was not configured to host
|
|
376
|
+
// is not a failure of the work: the targeted release returns the order to
|
|
377
|
+
// the hub's pickup window, where a differently-configured machine can take
|
|
378
|
+
// it. `misroute` takes the same shape for the same reason.
|
|
379
|
+
//
|
|
380
|
+
// ONLY an order-NAMED workdir is checked. When the packet names none this
|
|
381
|
+
// worker uses `<workRoot>/<workflow>/<run>/` — a directory owenloop ITSELF
|
|
382
|
+
// created under the operator's own cache root — and denying that would deny
|
|
383
|
+
// every agent order on a machine that declared any root at all.
|
|
384
|
+
if (packet.workdir !== undefined &&
|
|
385
|
+
!isWorkdirAllowed(packet.workdir, opts.allowedWorkdirRoots ?? [])) {
|
|
386
|
+
const roots = (opts.allowedWorkdirRoots ?? []).join(', ');
|
|
387
|
+
opts.err(`owenloop work agent-run: step '${packet.step}' (${order}) names workdir '${packet.workdir}', ` +
|
|
388
|
+
`which is outside every work root this machine declared (${roots}) — releasing for the pickup window`);
|
|
389
|
+
return releaseWith('workdir-denied', 'workdir-denied');
|
|
390
|
+
}
|
|
366
391
|
// The step spec. No bundle / no spec ⇒ we cannot brief anybody; release so
|
|
367
392
|
// the order lapses back through the hub's pickup window.
|
|
368
393
|
let material;
|
|
@@ -402,6 +427,9 @@ export function createAgentRunLoop(opts) {
|
|
|
402
427
|
// statement about the RUN, and a shift has no say in it.
|
|
403
428
|
...(packet.modifier !== undefined ? { modifier: packet.modifier } : {}),
|
|
404
429
|
...(packet.escalated === true ? { escalated: true } : {}),
|
|
430
|
+
// The hub's own answer to "what does this order still owe", so the submit
|
|
431
|
+
// contract names the right paths on a re-offer where some are already paid.
|
|
432
|
+
owes: packet.owes.map((owed) => owed.path),
|
|
405
433
|
};
|
|
406
434
|
// Permissions arrive PRE-NORMALIZED in the spec. `prepare` ran
|
|
407
435
|
// `normalizeStepPermissions` over the step's `x.harness` options at cache
|
|
@@ -22,6 +22,28 @@ export declare function resolveWorkRepo(env: Record<string, string | undefined>,
|
|
|
22
22
|
* run's directory and must never be removed.
|
|
23
23
|
*/
|
|
24
24
|
export declare function isUnderWorkRoot(dir: string, workRoot: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Resolve the declared roots: `OWENLOOP_ALLOWED_WORKDIR_ROOTS` >
|
|
27
|
+
* `settings.allowedWorkdirRoots` > none. Mirrors `resolveWorkRoot`'s precedence
|
|
28
|
+
* shape, so there is one rule to remember across this file.
|
|
29
|
+
*
|
|
30
|
+
* The env var is PATH-style `:`-separated because it names a list of
|
|
31
|
+
* directories and that is the convention every operator already knows for one.
|
|
32
|
+
* It REPLACES the settings list rather than adding to it — a narrowing override
|
|
33
|
+
* that could only ever widen would not be a usable safety control.
|
|
34
|
+
*
|
|
35
|
+
* Every entry is resolved to an absolute path against `cwd`, so a relative
|
|
36
|
+
* declaration means what the operator saw when they typed it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveAllowedWorkdirRoots(env: Record<string, string | undefined>, settingsRoots: string[] | undefined, cwd: string): string[];
|
|
39
|
+
/**
|
|
40
|
+
* Is `workdir` inside (or equal to) one of `roots`?
|
|
41
|
+
*
|
|
42
|
+
* An EMPTY `roots` returns true for every path — that is the unrestricted
|
|
43
|
+
* default, not an accident, and it is why callers can pass the resolved list
|
|
44
|
+
* unconditionally instead of branching on whether the operator declared one.
|
|
45
|
+
*/
|
|
46
|
+
export declare function isWorkdirAllowed(workdir: string, roots: string[]): boolean;
|
|
25
47
|
export interface EnsureWorkDirOptions {
|
|
26
48
|
workRoot: string;
|
|
27
49
|
workflow: string;
|
|
@@ -81,6 +81,86 @@ export function isUnderWorkRoot(dir, workRoot) {
|
|
|
81
81
|
const rel = relative(resolve(workRoot), resolve(dir));
|
|
82
82
|
return rel !== '' && !rel.startsWith('..') && !isAbsolute(rel);
|
|
83
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* ── OPERATOR-DECLARED WORKDIR ROOTS ─────────────────────────────────────────
|
|
86
|
+
*
|
|
87
|
+
* A SEPARATE MECHANISM FROM `workRoot` ABOVE, and the two are easy to confuse,
|
|
88
|
+
* so state the difference once:
|
|
89
|
+
*
|
|
90
|
+
* | | `workRoot` (singular) | `allowedWorkdirRoots` (plural) |
|
|
91
|
+
* |---|---|---|
|
|
92
|
+
* | what it is | a directory owenloop WRITES INTO | a list of directories orders may NAME |
|
|
93
|
+
* | who supplies the path | this machine's operator | the run, via `OrderPacket.workdir` |
|
|
94
|
+
* | what it does | holds `<workflow>/<run>/` per-run dirs | permits or refuses a cwd |
|
|
95
|
+
* | unset means | default to `<cacheDir>/work` | NO RESTRICTION |
|
|
96
|
+
*
|
|
97
|
+
* WHY THIS EXISTS. `OrderPacket.workdir` is an opaque location hint the HUB
|
|
98
|
+
* supplies and the worker obeys (`src/exec/loop.ts`, `src/agent/loop.ts`). Since
|
|
99
|
+
* a def may set it from a declared INPUT — `workdirFrom: target.path`, the
|
|
100
|
+
* grammar owenloop 0.5.4 added — the string can originate with whoever started
|
|
101
|
+
* the run, and a shift is not project-bound. So without a local check, a run on
|
|
102
|
+
* the hub picks any absolute path on the operator's machine as a working
|
|
103
|
+
* directory.
|
|
104
|
+
*
|
|
105
|
+
* The boundary belongs to the MACHINE'S OWNER, not to the hub: the person who
|
|
106
|
+
* starts a shift decides which directories that shift may work in. That is why
|
|
107
|
+
* the declaration is a `shift start` flag / settings key / env var and never a
|
|
108
|
+
* def field, a hub policy, or anything a run can influence.
|
|
109
|
+
*
|
|
110
|
+
* DEFAULT-OPEN, DELIBERATELY. An empty list means every path is allowed, which
|
|
111
|
+
* preserves the behaviour of every shift running today. Making it default-closed
|
|
112
|
+
* would break every existing shift on upgrade, and — worse — would do so as a
|
|
113
|
+
* silent refusal of work the hub believes was accepted.
|
|
114
|
+
*
|
|
115
|
+
* INCLUSIVE OF THE ROOT ITSELF, unlike `isUnderWorkRoot`. An operator who
|
|
116
|
+
* declares `/Users/alex/code/dev` means "this project", and `target.path` for
|
|
117
|
+
* that project IS that exact directory. `isUnderWorkRoot` excludes `dir ===
|
|
118
|
+
* root` because there it guards a DELETION and the root must survive; here it
|
|
119
|
+
* guards a cwd, and there is nothing to protect the root from.
|
|
120
|
+
*/
|
|
121
|
+
/** Split a PATH-style (`:`-separated) list of directories, dropping empties. */
|
|
122
|
+
function splitRootList(raw) {
|
|
123
|
+
return raw
|
|
124
|
+
.split(':')
|
|
125
|
+
.map((entry) => entry.trim())
|
|
126
|
+
.filter((entry) => entry !== '');
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Resolve the declared roots: `OWENLOOP_ALLOWED_WORKDIR_ROOTS` >
|
|
130
|
+
* `settings.allowedWorkdirRoots` > none. Mirrors `resolveWorkRoot`'s precedence
|
|
131
|
+
* shape, so there is one rule to remember across this file.
|
|
132
|
+
*
|
|
133
|
+
* The env var is PATH-style `:`-separated because it names a list of
|
|
134
|
+
* directories and that is the convention every operator already knows for one.
|
|
135
|
+
* It REPLACES the settings list rather than adding to it — a narrowing override
|
|
136
|
+
* that could only ever widen would not be a usable safety control.
|
|
137
|
+
*
|
|
138
|
+
* Every entry is resolved to an absolute path against `cwd`, so a relative
|
|
139
|
+
* declaration means what the operator saw when they typed it.
|
|
140
|
+
*/
|
|
141
|
+
export function resolveAllowedWorkdirRoots(env, settingsRoots, cwd) {
|
|
142
|
+
const override = env['OWENLOOP_ALLOWED_WORKDIR_ROOTS'];
|
|
143
|
+
const raw = override !== undefined && override.trim() !== ''
|
|
144
|
+
? splitRootList(override)
|
|
145
|
+
: (settingsRoots ?? []).map((entry) => entry.trim()).filter((entry) => entry !== '');
|
|
146
|
+
return raw.map((entry) => resolve(cwd, entry));
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Is `workdir` inside (or equal to) one of `roots`?
|
|
150
|
+
*
|
|
151
|
+
* An EMPTY `roots` returns true for every path — that is the unrestricted
|
|
152
|
+
* default, not an accident, and it is why callers can pass the resolved list
|
|
153
|
+
* unconditionally instead of branching on whether the operator declared one.
|
|
154
|
+
*/
|
|
155
|
+
export function isWorkdirAllowed(workdir, roots) {
|
|
156
|
+
if (roots.length === 0)
|
|
157
|
+
return true;
|
|
158
|
+
const target = resolve(workdir);
|
|
159
|
+
return roots.some((root) => {
|
|
160
|
+
const rel = relative(resolve(root), target);
|
|
161
|
+
return rel === '' || (!rel.startsWith('..') && !isAbsolute(rel));
|
|
162
|
+
});
|
|
163
|
+
}
|
|
84
164
|
function defaultRunGit(args, cwd) {
|
|
85
165
|
const r = spawnSync('git', args, { cwd, encoding: 'utf8' });
|
|
86
166
|
return { status: r.status, output: `${r.stdout ?? ''}${r.stderr ?? ''}`.trim() };
|
|
@@ -22,7 +22,7 @@ import type { SshProcessAdapter } from '../../../../src/crypto/ssh.ts';
|
|
|
22
22
|
*/
|
|
23
23
|
export declare const CONSUMES_INLINE_MAX_BYTES = 65536;
|
|
24
24
|
/** Discriminated result of an exec run; the role maps these to exit codes. */
|
|
25
|
-
export type ExecOutcome = 'submitted' | 'completed' | 'misroute' | 'unresolved-instructions' | 'killed' | 'lease-lost' | 'ownership-error' | 'hub-unreachable' | 'submit-rejected' | 'submit-failed' | 'rejected' | 'judge-rejected' | 'judge-no-verdict' | 'reject-failed' | 'stopped';
|
|
25
|
+
export type ExecOutcome = 'submitted' | 'completed' | 'misroute' | 'workdir-denied' | 'unresolved-instructions' | 'killed' | 'lease-lost' | 'ownership-error' | 'hub-unreachable' | 'submit-rejected' | 'submit-failed' | 'rejected' | 'judge-rejected' | 'judge-no-verdict' | 'reject-failed' | 'stopped';
|
|
26
26
|
export interface ExecLoopOptions {
|
|
27
27
|
hub: HubClient;
|
|
28
28
|
runner: CommandRunner;
|
|
@@ -40,6 +40,18 @@ export interface ExecLoopOptions {
|
|
|
40
40
|
instructions: InstructionResolver;
|
|
41
41
|
/** cwd for the command when the order packet carries no `workdir`. */
|
|
42
42
|
cwd: string;
|
|
43
|
+
/**
|
|
44
|
+
* The directories this MACHINE's operator declared as places work may happen,
|
|
45
|
+
* already resolved to absolute paths by `resolveAllowedWorkdirRoots`.
|
|
46
|
+
*
|
|
47
|
+
* NOT `workRoot`. `workRoot` is the single directory owenloop CREATES worktrees
|
|
48
|
+
* under; this is the set of directories an ORDER is permitted to name as its
|
|
49
|
+
* cwd. They answer different questions and neither derives from the other.
|
|
50
|
+
*
|
|
51
|
+
* UNSET or EMPTY means NO RESTRICTION — the pre-existing behaviour, and the
|
|
52
|
+
* only default that does not break every shift already running.
|
|
53
|
+
*/
|
|
54
|
+
allowedWorkdirRoots?: string[];
|
|
43
55
|
sleep: (ms: number) => Promise<void>;
|
|
44
56
|
now: () => number;
|
|
45
57
|
random?: () => number;
|
|
@@ -20,9 +20,12 @@
|
|
|
20
20
|
* 3. RUN + RACE — the runner shells the command out while the lease loop runs.
|
|
21
21
|
* Whichever settles first wins (plan decision 9):
|
|
22
22
|
* - an ordinary command settles (any exit code, or a machinery error) ⇒
|
|
23
|
-
* build a receipt
|
|
24
|
-
*
|
|
25
|
-
* the receipt
|
|
23
|
+
* build a receipt. A payload reject is delivered FIRST (the hub refuses
|
|
24
|
+
* a reject once the claim has closed, and the last owed submit is what
|
|
25
|
+
* closes it); then `submit` the receipt to every owed path, unless that
|
|
26
|
+
* reject closed the run, in which case the owed paths stay debts. Exit 0
|
|
27
|
+
* means the receipt/reject delivery won; the receipt's exit code still
|
|
28
|
+
* carries the command result.
|
|
26
29
|
* - a judge command exits 0 ⇒ submit its receipt; a non-zero exit ⇒ send
|
|
27
30
|
* `reject` for `order.judge` without a receipt; signal or machinery
|
|
28
31
|
* failure ⇒ no verdict, leave the claim for the reap path.
|
|
@@ -42,6 +45,7 @@ import { createHash } from 'node:crypto';
|
|
|
42
45
|
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
43
46
|
import { tmpdir } from 'node:os';
|
|
44
47
|
import { join, resolve } from 'node:path';
|
|
48
|
+
import { isWorkdirAllowed } from "../agent/workdir.js";
|
|
45
49
|
import { createLeaseLoop } from "../lease/loop.js";
|
|
46
50
|
import { parsePayloadLine } from "./payload.js";
|
|
47
51
|
import { buildReceipt } from "./receipt.js";
|
|
@@ -243,6 +247,102 @@ export function createExecLoop(opts) {
|
|
|
243
247
|
return 'reject-failed';
|
|
244
248
|
}
|
|
245
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* Deliver a PAYLOAD reject before the owed submits, and say whether this
|
|
252
|
+
* worker is finished.
|
|
253
|
+
*
|
|
254
|
+
* The distinction from `issueReject` is the third outcome. A judge reject is
|
|
255
|
+
* always the end of the run; a payload reject may leave the claim open, and
|
|
256
|
+
* when it does the owed receipts still have to land. So this returns either a
|
|
257
|
+
* terminal `ExecOutcome` or the sentinel `'continue'`.
|
|
258
|
+
*
|
|
259
|
+
* refused / threw → terminal. `issueReject` has already logged it and
|
|
260
|
+
* settled the lease. Nothing is submitted: a reject that
|
|
261
|
+
* did not land must not be followed by a receipt that
|
|
262
|
+
* greens the path the reject was protesting.
|
|
263
|
+
* landed, closed → terminal `'rejected'`. The rejected path was consumed
|
|
264
|
+
* by this firing, the hub closed the run `no_work`, and
|
|
265
|
+
* the owed paths stay debts for the next firing.
|
|
266
|
+
* landed, still open → `'continue'`. The rejected path was not consumed
|
|
267
|
+
* here, so the claim and the consume fingerprint are
|
|
268
|
+
* both intact and every owed submit proceeds normally.
|
|
269
|
+
*
|
|
270
|
+
* `closed` is read from the hub's own response rather than re-derived from the
|
|
271
|
+
* order, because the consumed-input test lives in the hub
|
|
272
|
+
* (`reject-artifact.ts` checks `runRow.fingerprint`, which is what the engine
|
|
273
|
+
* recorded at claim time — not what the def declares the step consumes).
|
|
274
|
+
*/
|
|
275
|
+
async function relayPayloadReject(path, text, owed) {
|
|
276
|
+
let res;
|
|
277
|
+
try {
|
|
278
|
+
res = await hub.reject({ workflow, run: runId, path, text });
|
|
279
|
+
}
|
|
280
|
+
catch (e) {
|
|
281
|
+
opts.err(`owenloop work exec: reject of ${path} failed: ${errMsg(e)}`);
|
|
282
|
+
// Nothing has been submitted yet, so unlike the post-submit case there
|
|
283
|
+
// are no committed receipts to reason about. Release and let the step be
|
|
284
|
+
// re-offered.
|
|
285
|
+
lease.stop('reject-failed');
|
|
286
|
+
await leasePromise;
|
|
287
|
+
return 'reject-failed';
|
|
288
|
+
}
|
|
289
|
+
if (res.ok !== true) {
|
|
290
|
+
opts.err(`owenloop work exec: reject of ${path} was refused: ${res.text}`);
|
|
291
|
+
lease.stop('reject-failed', res.closed === true ? { release: false } : undefined);
|
|
292
|
+
await leasePromise;
|
|
293
|
+
return 'reject-failed';
|
|
294
|
+
}
|
|
295
|
+
if (res.closed === true) {
|
|
296
|
+
opts.out(`owenloop work exec: rejected ${path} — run closed, ${owed} owed path(s) left as debts`);
|
|
297
|
+
lease.stop('rejected', { release: false });
|
|
298
|
+
await leasePromise;
|
|
299
|
+
return 'rejected';
|
|
300
|
+
}
|
|
301
|
+
opts.out(`owenloop work exec: rejected ${path} (not consumed by this firing) — submitting owed receipts`);
|
|
302
|
+
return 'continue';
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Relay the child's own output to this process's stderr when the command did
|
|
306
|
+
* not succeed.
|
|
307
|
+
*
|
|
308
|
+
* ## Why this exists
|
|
309
|
+
*
|
|
310
|
+
* Until this was added, a command step that failed produced a worker log that
|
|
311
|
+
* named the failure and said NOTHING about its cause. The runner captures the
|
|
312
|
+
* last 4 KiB of combined stdout+stderr as `outputTail` and puts it in the
|
|
313
|
+
* receipt — but a receipt only reaches a human if the submit is ACCEPTED, and
|
|
314
|
+
* the most common command-step failure is precisely the one where it is not:
|
|
315
|
+
* the script dies before printing a payload line, so the receipt has no
|
|
316
|
+
* `payload` key and `merge`'s schema rejects it. The one artifact carrying the
|
|
317
|
+
* diagnosis was discarded by the same event that made it necessary.
|
|
318
|
+
*
|
|
319
|
+
* Measured on `wf_40bd0c3f6783f9d31291d74d`: the `merger` step failed four
|
|
320
|
+
* times across two shifts and one foreground `owenloop work exec`, and every
|
|
321
|
+
* one of those logs contained the same three lines — holding, running,
|
|
322
|
+
* schema-rejected — with no trace of what the child said. Reproducing the
|
|
323
|
+
* script by hand outside the engine was the only way to see its stderr.
|
|
324
|
+
*
|
|
325
|
+
* `outputTail` is already capped at 4 KiB by the runner, so this cannot flood
|
|
326
|
+
* a log. Each line is prefixed so the child's words are never mistaken for
|
|
327
|
+
* exec's own.
|
|
328
|
+
*/
|
|
329
|
+
function relayChildOutput(result, step) {
|
|
330
|
+
if (result.exitCode === 0 && result.error === undefined)
|
|
331
|
+
return;
|
|
332
|
+
const how = result.error !== undefined
|
|
333
|
+
? `could not be run (${result.error})`
|
|
334
|
+
: result.signal !== undefined
|
|
335
|
+
? `was killed by ${result.signal}`
|
|
336
|
+
: `exited ${result.exitCode}`;
|
|
337
|
+
opts.err(`owenloop work exec: the command for step '${step}' ${how}; its last output follows`);
|
|
338
|
+
const tail = result.outputTail.replace(/\n+$/, '');
|
|
339
|
+
if (tail === '') {
|
|
340
|
+
opts.err(' (the command produced no output)');
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
for (const line of tail.split('\n'))
|
|
344
|
+
opts.err(` | ${line}`);
|
|
345
|
+
}
|
|
246
346
|
/** Build the receipt and submit it to every owed path. */
|
|
247
347
|
async function submitReceipt(result, order, resolvedCommand) {
|
|
248
348
|
if (signalled) {
|
|
@@ -255,6 +355,9 @@ export function createExecLoop(opts) {
|
|
|
255
355
|
await leasePromise;
|
|
256
356
|
return 'killed';
|
|
257
357
|
}
|
|
358
|
+
// Before any of the branches below decide what to do about the failure.
|
|
359
|
+
// Every one of them is reachable with a useless log otherwise.
|
|
360
|
+
relayChildOutput(result, order.step);
|
|
258
361
|
const parsedPayload = parsePayloadLine(result.payloadLine, result.payloadOverCap);
|
|
259
362
|
if (order.judge !== undefined) {
|
|
260
363
|
if (result.exitCode === null) {
|
|
@@ -286,6 +389,54 @@ export function createExecLoop(opts) {
|
|
|
286
389
|
run: runId,
|
|
287
390
|
step: order.step,
|
|
288
391
|
}, parsedPayload);
|
|
392
|
+
// ---- the payload reject goes FIRST, and it is not an ordering nicety ----
|
|
393
|
+
//
|
|
394
|
+
// It used to run after every owed submit, on the reasoning that "all owed
|
|
395
|
+
// submissions must land before invalidating a consumed input; rejection
|
|
396
|
+
// moves the consume fingerprint and would born-reject later submits from
|
|
397
|
+
// this run". The second half of that sentence is true. The first half made
|
|
398
|
+
// the reject UNDELIVERABLE, because the submits it waited on are what kill
|
|
399
|
+
// the claim it needs.
|
|
400
|
+
//
|
|
401
|
+
// The hub refuses a reject from a run whose claim has closed
|
|
402
|
+
// (`hub-core/src/verbs/reject-artifact.ts`: `held` requires
|
|
403
|
+
// `runRow.outcome === undefined`, and the refusal is explicit —
|
|
404
|
+
// "is not currently held by an open claim — nothing was rejected"). A step's
|
|
405
|
+
// last owed submit closes the run. So for the single-owed-path case — which
|
|
406
|
+
// is every gate in the delivery workflow — submit-then-reject could only
|
|
407
|
+
// ever produce the pair observed on `run_ecfedb23a84194e446159e67`:
|
|
408
|
+
//
|
|
409
|
+
// submitted receipt to mergeable (green)
|
|
410
|
+
// reject of pr was refused: ... is not currently held by an open claim
|
|
411
|
+
//
|
|
412
|
+
// The gate greened its own output and its reject evaporated, so `merger`
|
|
413
|
+
// proceeded on a PR the gate had explicitly refused to confirm. The def-side
|
|
414
|
+
// cascade that was supposed to un-green `mergeable` never fired, because it
|
|
415
|
+
// hangs off a `pr` rejection that never happened.
|
|
416
|
+
//
|
|
417
|
+
// Rejecting first is correct in both directions, and which one applies is
|
|
418
|
+
// the hub's answer, not a guess:
|
|
419
|
+
//
|
|
420
|
+
// `closed: true` — the rejected path WAS one of this firing's consumed
|
|
421
|
+
// inputs, so the hub closed the run `no_work` (not `failed`: no attempt
|
|
422
|
+
// is burned). The owed paths stay debts and the step re-fires against the
|
|
423
|
+
// rebuilt input. Skipping the submits here is not a loss — an artifact
|
|
424
|
+
// derived from an input this same command just declared bad is exactly
|
|
425
|
+
// what the engine's dead-input cascade would have thrown away anyway.
|
|
426
|
+
// This is also the branch that makes the old born-reject warning moot:
|
|
427
|
+
// there are no later submits to born-reject.
|
|
428
|
+
//
|
|
429
|
+
// `closed: false` — the rejected path was NOT consumed by this firing, so
|
|
430
|
+
// the claim is still open and the fingerprint has not moved. Fall through
|
|
431
|
+
// and submit every owed path exactly as before.
|
|
432
|
+
//
|
|
433
|
+
// A REFUSED reject now submits nothing. That is the point: previously the
|
|
434
|
+
// receipt had already landed and greened a path whose gate had failed.
|
|
435
|
+
if (order.judge === undefined && parsedPayload.reject !== undefined) {
|
|
436
|
+
const rejected = await relayPayloadReject(parsedPayload.reject.path, parsedPayload.reject.text, order.owes.length);
|
|
437
|
+
if (rejected !== 'continue')
|
|
438
|
+
return rejected;
|
|
439
|
+
}
|
|
289
440
|
for (const owe of order.owes) {
|
|
290
441
|
let res;
|
|
291
442
|
try {
|
|
@@ -332,12 +483,6 @@ export function createExecLoop(opts) {
|
|
|
332
483
|
}
|
|
333
484
|
opts.out(`owenloop work exec: submitted receipt to ${owe.path} (${outcome})`);
|
|
334
485
|
}
|
|
335
|
-
if (order.judge === undefined && parsedPayload.reject !== undefined) {
|
|
336
|
-
// All owed submissions must land before invalidating a consumed input;
|
|
337
|
-
// rejection moves the consume fingerprint and would born-reject later
|
|
338
|
-
// submits from this run.
|
|
339
|
-
return issueReject(parsedPayload.reject.path, parsedPayload.reject.text, 'rejected');
|
|
340
|
-
}
|
|
341
486
|
// Every owed path landed — the run has closed, so stop WITHOUT releasing.
|
|
342
487
|
lease.stop('submitted', { release: false });
|
|
343
488
|
await leasePromise;
|
|
@@ -363,6 +508,36 @@ export function createExecLoop(opts) {
|
|
|
363
508
|
await leasePromise;
|
|
364
509
|
return 'misroute';
|
|
365
510
|
}
|
|
511
|
+
// MACHINE POLICY, checked before any instruction is resolved and long before
|
|
512
|
+
// anything is spawned. The operator who started this shift named the
|
|
513
|
+
// directories work may happen in (`owenloop shift start --work-root`, or
|
|
514
|
+
// `allowedWorkdirRoots` in settings); an order naming anything else is
|
|
515
|
+
// refused HERE, in the worker, because the worker is the only process that
|
|
516
|
+
// ever sees `OrderPacket.workdir` — the shift's `whats_next` sweep receives
|
|
517
|
+
// a `WorkOrder`, which has no such field.
|
|
518
|
+
//
|
|
519
|
+
// RELEASED, not failed. This is not a defect in the order and not a failure
|
|
520
|
+
// of the work: it is one machine declining work it was not configured to
|
|
521
|
+
// host. A targeted release returns the order to the hub's pickup window so a
|
|
522
|
+
// differently-configured machine can take it, exactly like `misroute`.
|
|
523
|
+
// Submitting a failure receipt instead would kill a run that is perfectly
|
|
524
|
+
// valid somewhere else.
|
|
525
|
+
//
|
|
526
|
+
// ONLY an order-NAMED workdir is checked. An order that declares none
|
|
527
|
+
// inherits this worker's own launch directory, which the operator chose
|
|
528
|
+
// themselves when they started the shift — bounding an operator's own
|
|
529
|
+
// choice by the operator's own roots protects nobody and would deny every
|
|
530
|
+
// step that legitimately declares no workdir.
|
|
531
|
+
if (order.workdir !== undefined &&
|
|
532
|
+
!isWorkdirAllowed(order.workdir, opts.allowedWorkdirRoots ?? [])) {
|
|
533
|
+
const roots = (opts.allowedWorkdirRoots ?? []).join(', ');
|
|
534
|
+
opts.err(`owenloop work exec: step '${order.step}' (${workflow}/${runId}) names workdir ` +
|
|
535
|
+
`'${order.workdir}', which is outside every work root this machine declared (${roots}) — ` +
|
|
536
|
+
'releasing for the pickup window');
|
|
537
|
+
lease.stop('workdir-denied'); // targeted release — local policy, not a failure
|
|
538
|
+
await leasePromise;
|
|
539
|
+
return 'workdir-denied';
|
|
540
|
+
}
|
|
366
541
|
let resolvedCommand;
|
|
367
542
|
let resolvedBundleDir;
|
|
368
543
|
try {
|