owenloop 0.5.5 → 0.5.7

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/packages/work/src/agent/approvals.d.ts +53 -0
  3. package/dist/packages/work/src/agent/approvals.js +132 -0
  4. package/dist/packages/work/src/agent/brief.d.ts +40 -4
  5. package/dist/packages/work/src/agent/brief.js +165 -2
  6. package/dist/packages/work/src/agent/loop.d.ts +4 -0
  7. package/dist/packages/work/src/agent/loop.js +68 -3
  8. package/dist/packages/work/src/harness/claude.d.ts +28 -0
  9. package/dist/packages/work/src/harness/claude.js +193 -22
  10. package/dist/packages/work/src/harness/codex.d.ts +37 -1
  11. package/dist/packages/work/src/harness/codex.js +133 -14
  12. package/dist/packages/work/src/harness/contract.d.ts +79 -21
  13. package/dist/packages/work/src/harness/contract.js +25 -20
  14. package/dist/packages/work/src/harness/gatekeeper.d.ts +124 -0
  15. package/dist/packages/work/src/harness/gatekeeper.js +208 -0
  16. package/dist/packages/work/src/harness/session-store.d.ts +65 -15
  17. package/dist/packages/work/src/harness/session-store.js +53 -51
  18. package/dist/packages/work/src/hub/client.d.ts +13 -1
  19. package/dist/packages/work/src/hub/client.js +3 -0
  20. package/dist/packages/work/src/hub/types.d.ts +101 -0
  21. package/dist/packages/work/src/main.js +1 -0
  22. package/dist/packages/work/src/roles/agent-run.js +4 -0
  23. package/dist/packages/work/src/roles/approvals.d.ts +76 -0
  24. package/dist/packages/work/src/roles/approvals.js +231 -0
  25. package/dist/packages/work/src/shift/loop.d.ts +2 -0
  26. package/dist/packages/work/src/shift/loop.js +2 -0
  27. package/dist/packages/work/src/shift/runtime.js +23 -7
  28. package/dist/packages/work/src/shift/spawn.d.ts +4 -0
  29. package/dist/packages/work/src/shift/spawn.js +6 -0
  30. package/dist/packages/work/src/usage.d.ts +1 -1
  31. package/dist/packages/work/src/usage.js +5 -0
  32. package/dist/src/crypto/records.d.ts +2 -0
  33. package/dist/src/crypto/records.js +13 -0
  34. package/dist/src/engine.js +5 -1
  35. package/dist/src/model.d.ts +37 -1
  36. package/dist/src/model.js +47 -1
  37. package/dist/src/schemas/index.d.ts +11 -0
  38. package/dist/src/schemas/order.v1.schema.json +9 -0
  39. package/dist/src/types.d.ts +34 -0
  40. package/docs/agent-runner.md +17 -5
  41. package/package.json +1 -1
  42. package/plugins/claude-code/plugin/.claude-plugin/plugin.json +1 -1
  43. package/plugins/claude-code/plugin/.mcp.json +1 -1
  44. package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +1 -1
  45. package/plugins/codex/plugins/owenloop/.mcp.json +1 -1
@@ -3,4 +3,4 @@
3
3
  * exit 0) and on a dispatch error (to stderr, exit 2). Keeping it in one place
4
4
  * means the help output and the error output never drift apart.
5
5
  */
6
- export declare const USAGE = "owenloop work \u2014 execution-side CLI companion to owenloop\n\nUsage:\n owenloop work hold --order <id> [options] hold an order with a heartbeating lease\n owenloop work exec <order-id> [options] run a command order in a self-leasing loop\n owenloop work agent-run <order-id> [options] host an agent order's step agent in a\n harness, in a self-leasing loop\n owenloop work prepare <workflow> [--origin <url>]\n fetch, cache & normalize step specs\n owenloop work lint <workflow-name | path> lint x.harness option bags in a def\n owenloop work sessions [--all] [--json] list this machine's recorded harness\n sessions and how to re-open them\n owenloop work release --session <id> [options] drain a session's held claims\n owenloop work settings print the resolved settings file\n owenloop work join <code> [--hub <origin>] [--as <account>]\n redeem a join code and store the Scoped\n Identity credential (one-time provisioning)\n\nOptions:\n -h, --help show this help and exit 0\n --version print the owenloop work version and exit 0\n\n root shift options (run as owenloop shift start <crew...> | --all):\n <crew...> serve only these crews (positional, space\n separated); or --all for every crew on the key\n --all serve every crew on the key\n --origin <url> hub origin (else settings.hubOrigin)\n --as <account> Scoped Identity credential account to read + hand\n to dispatched holds/execs (default 'default')\n --name <n> Shift name (default <hostname>/<cwd>)\n --cap <n> max in-flight exec children (default 3)\n --poll-interval <ms> wake poll cadence (default 5000)\n --once bootstrap wake + one sweep, then exit (demo/e2e)\n --max-agents <n> max in-flight agent-run children, separate from\n --cap (default 4; else settings.maxConcurrentAgents)\n --cache-dir/--state-dir <p> override the resolved dirs\n\n hold options:\n --order <workflow>/<run> the order to hold (or --order <run> --workflow)\n --workflow <wf> required when --order is a bare run id\n --origin <url> hub origin (else settings.hubOrigin)\n --as <account> Scoped Identity credential account (default\n 'default'; the shift stamps this into born-bound\n holds)\n --session <id> session-holder tag (else env OWENLOOP_SESSION;\n else an anon:<hostname>:<pid> fallback \u2014 a\n holder is always sent)\n --shift <id> dispatching Shift's self-declared id (else\n env OWENLOOP_SHIFT_ID); advisory only\n --heartbeat-interval <ms> lease renew cadence (default 60000)\n --jump-tolerance <ms> wall-gap slack before a tick is treated as a\n clock jump / laptop sleep (default 30000)\n --ignore-stdin don't final-breath on stdin EOF (detached use)\n --never-release another process holds the claim; stop without\n releasing it (agent-run spawns its --mcp child\n this way \u2014 see hold.ts HOLDER OF RECORD)\n --mcp run as a stdio-MCP work-holder: tools get_order /\n submit, lease kept warm underneath (mutually\n exclusive with --ignore-stdin \u2014 stdin is the\n transport)\n\n exec options (usually spawned by shift, not run by hand):\n <workflow>/<run> the command order to run (positional order-id;\n or a bare <run> plus --workflow <wf>)\n --workflow <wf> required when the order-id is a bare run id\n --origin <url> hub origin (else settings.hubOrigin)\n --shift <id> dispatching Shift's self-declared id (else\n env OWENLOOP_SHIFT_ID); advisory only\n --heartbeat-interval <ms> lease renew cadence (default 60000)\n --jump-tolerance <ms> wall-gap slack before a tick is treated as a\n clock jump / laptop sleep (default 30000)\n\n agent-run options (spawned by the shift, not run by hand):\n <workflow>/<run> the agent order to host (positional order-id;\n or a bare <run> plus --workflow <wf>)\n --workflow <wf> required when the order-id is a bare run id\n --origin <url> hub origin (else settings.hubOrigin)\n --harness <id> which registered harness hosts the step agent\n (else env OWENLOOP_HARNESS, else the step def's\n 'harness' field, else the first registered one)\n --shift <id> dispatching Shift's self-declared id (else\n env OWENLOOP_SHIFT_ID); advisory only\n --heartbeat-interval <ms> lease renew cadence (default 60000)\n --jump-tolerance <ms> wall-gap slack before a tick is treated as a\n clock jump / laptop sleep (default 30000)\n --submit-grace <ms> after the turn ends, how long to keep asking the\n hub whether the agent's submit landed (default\n 15000). Task completion comes from the HUB, never\n from the harness stream.\n --confirm-interval <ms> poll cadence inside that grace (default 1000)\n\n release options:\n --session <id> session whose claims to drain (else env\n OWENLOOP_SESSION). Agent-held claims re-offer;\n exec-held claims are drain-exempt (B3).\n --origin <url> hub origin (else settings.hubOrigin)\n\n settings (no options in v1):\n prints the resolved settings file path, whether it exists, each known\n knob (hubOrigin, cacheDir, stateDir, dispatchCap, commandRouting,\n maxConcurrentAgents, workRoot, workRepo) with its value + provenance,\n and any unrecognized keys.\n settings.dispatchCap/stateDir are the lowest-precedence\n fallbacks for shift's --cap/--state-dir. NO secrets ever\n live in settings \u2014 credentials stay in owenloop's own store.\n\n sessions options:\n --all include 'dead' sessions (hidden by default \u2014\n a dead session can no longer be resumed)\n --json print the raw newest-per-step records, tokens\n included, instead of the table\n --cache-dir <p> override the resolved cache dir\n\n join options:\n --hub <origin> hub to redeem against (else settings.hubOrigin;\n one of the two is REQUIRED \u2014 the code never\n chooses the hub)\n --as <account> credential account to store under (default:\n the Scoped Identity name the hub returns)\n\n shift/hold/exec/prepare/release env:\n credentials come from owenloop's store \u2014 each role reads the\n agent:<account> slot for its origin (never the human slot); a\n missing slot refuses with a runnable 'owenloop login' command.\n OWENLOOP_ACCOUNT Scoped Identity account for exec/prepare/release\n (default 'default'; shift uses --as, and\n stamps it onto dispatched holds/execs)\n OWENLOOP_TOKEN dev-only bearer override \u2014 when set, used\n verbatim and the store + account are\n bypassed (NOT the primary path)\n OWENLOOP_CACHE_DIR cache root\n OWENLOOP_STATE_DIR shift in-flight state dir\n OWENLOOP_SHIFT_LOG_DIR dir for the shift's shift.log and each\n worker's <run>.log; below --log-dir, above\n settings.shiftLogDir, default the state dir\n OWENLOOP_SHIFT_LOG_MAX_AGE_MS\n how long a worker's <run>.log is kept, in ms;\n below --log-max-age, above\n settings.shiftLogMaxAgeMs, default 14 days.\n Worker logs only \u2014 shift.log is never reaped\n OWENLOOP_SESSION hold session-holder tag / release drain target\n OWENLOOP_SHIFT_ID dispatching Shift's self-declared id for\n hold/exec/agent-run's --shift (advisory\n only, never for auth/routing/dispatch)\n OWENLOOP_HARNESS agent-run harness id; below --harness, above\n the step def's 'harness' field\n OWENLOOP_WORK_ROOT root for per-RUN agent work dirs\n (<workRoot>/<workflow>/<run>); above\n settings.workRoot, default <cacheDir>/work.\n A hub-supplied OrderPacket.workdir still\n wins, and is never reaped.\n OWENLOOP_WORK_REPO local git repo to cut per-run work dirs from\n as worktrees instead of plain dirs; above\n settings.workRepo, default off\n\n Credentials / accounts:\n owenloop work's RUNTIME roles (shift/hold/exec/prepare/release) are READ-ONLY\n over owenloop's credential store \u2014 they never write credentials. Each\n role reads the agent:<account> slot for its origin (never the human\n slot); the account defaults to 'default'. 'owenloop work join' is the one\n deliberate provisioning-time writer: it stores the Scoped Identity token a hub\n redeem returns via owenloop's public storeCredential, once, at join time\n \u2014 not a runtime write.\n store / connect an account (run owenloop; owenloop work never writes it):\n owenloop login --hub <origin> --as agent:<account>\n (use --as agent for the default account)\n or provision a fresh box from a hub-issued join code:\n owenloop work join <code> --hub <origin>\n select an account at run time:\n --as <account> on shift / hold\n OWENLOOP_ACCOUNT on exec / prepare / release\n (shift resolves once and threads both channels)\n owenloop work does NOT list stored accounts \u2014 enumerating an origin's accounts\n is an owenloop-side capability; check owenloop for which slots are stored.\n\nExit codes:\n 0 success / help / version / lint clean or warnings-only\n 1 runtime failure (fetch/hub error, cache write) / lint found an error\n 2 usage error (unknown or missing role, missing required arg)\n 3 role not implemented yet (skeleton stub \u2014 lands in a later delivery)\n";
6
+ export declare const USAGE = "owenloop work \u2014 execution-side CLI companion to owenloop\n\nUsage:\n owenloop work hold --order <id> [options] hold an order with a heartbeating lease\n owenloop work exec <order-id> [options] run a command order in a self-leasing loop\n owenloop work agent-run <order-id> [options] host an agent order's step agent in a\n harness, in a self-leasing loop\n owenloop work prepare <workflow> [--origin <url>]\n fetch, cache & normalize step specs\n owenloop work lint <workflow-name | path> lint x.harness option bags in a def\n owenloop work sessions [--all] [--json] list this machine's recorded harness\n sessions and how to re-open them\n owenloop work approvals [--json] every tool call a worker is blocked on\n RIGHT NOW, waiting for a person\n owenloop work approvals approve|deny <wf>/<run> <tool-use-id> [--note <text>]\n answer one; the answer goes back to the\n still-blocked call, not to a later attempt\n owenloop work release --session <id> [options] drain a session's held claims\n owenloop work settings print the resolved settings file\n owenloop work join <code> [--hub <origin>] [--as <account>]\n redeem a join code and store the Scoped\n Identity credential (one-time provisioning)\n\nOptions:\n -h, --help show this help and exit 0\n --version print the owenloop work version and exit 0\n\n root shift options (run as owenloop shift start <crew...> | --all):\n <crew...> serve only these crews (positional, space\n separated); or --all for every crew on the key\n --all serve every crew on the key\n --origin <url> hub origin (else settings.hubOrigin)\n --as <account> Scoped Identity credential account to read + hand\n to dispatched holds/execs (default 'default')\n --name <n> Shift name (default <hostname>/<cwd>)\n --cap <n> max in-flight exec children (default 3)\n --poll-interval <ms> wake poll cadence (default 5000)\n --once bootstrap wake + one sweep, then exit (demo/e2e)\n --max-agents <n> max in-flight agent-run children, separate from\n --cap (default 4; else settings.maxConcurrentAgents)\n --cache-dir/--state-dir <p> override the resolved dirs\n\n hold options:\n --order <workflow>/<run> the order to hold (or --order <run> --workflow)\n --workflow <wf> required when --order is a bare run id\n --origin <url> hub origin (else settings.hubOrigin)\n --as <account> Scoped Identity credential account (default\n 'default'; the shift stamps this into born-bound\n holds)\n --session <id> session-holder tag (else env OWENLOOP_SESSION;\n else an anon:<hostname>:<pid> fallback \u2014 a\n holder is always sent)\n --shift <id> dispatching Shift's self-declared id (else\n env OWENLOOP_SHIFT_ID); advisory only\n --heartbeat-interval <ms> lease renew cadence (default 60000)\n --jump-tolerance <ms> wall-gap slack before a tick is treated as a\n clock jump / laptop sleep (default 30000)\n --ignore-stdin don't final-breath on stdin EOF (detached use)\n --never-release another process holds the claim; stop without\n releasing it (agent-run spawns its --mcp child\n this way \u2014 see hold.ts HOLDER OF RECORD)\n --mcp run as a stdio-MCP work-holder: tools get_order /\n submit, lease kept warm underneath (mutually\n exclusive with --ignore-stdin \u2014 stdin is the\n transport)\n\n exec options (usually spawned by shift, not run by hand):\n <workflow>/<run> the command order to run (positional order-id;\n or a bare <run> plus --workflow <wf>)\n --workflow <wf> required when the order-id is a bare run id\n --origin <url> hub origin (else settings.hubOrigin)\n --shift <id> dispatching Shift's self-declared id (else\n env OWENLOOP_SHIFT_ID); advisory only\n --heartbeat-interval <ms> lease renew cadence (default 60000)\n --jump-tolerance <ms> wall-gap slack before a tick is treated as a\n clock jump / laptop sleep (default 30000)\n\n agent-run options (spawned by the shift, not run by hand):\n <workflow>/<run> the agent order to host (positional order-id;\n or a bare <run> plus --workflow <wf>)\n --workflow <wf> required when the order-id is a bare run id\n --origin <url> hub origin (else settings.hubOrigin)\n --harness <id> which registered harness hosts the step agent\n (else env OWENLOOP_HARNESS, else the step def's\n 'harness' field, else the first registered one)\n --shift <id> dispatching Shift's self-declared id (else\n env OWENLOOP_SHIFT_ID); advisory only\n --heartbeat-interval <ms> lease renew cadence (default 60000)\n --jump-tolerance <ms> wall-gap slack before a tick is treated as a\n clock jump / laptop sleep (default 30000)\n --submit-grace <ms> after the turn ends, how long to keep asking the\n hub whether the agent's submit landed (default\n 15000). Task completion comes from the HUB, never\n from the harness stream.\n --confirm-interval <ms> poll cadence inside that grace (default 1000)\n\n release options:\n --session <id> session whose claims to drain (else env\n OWENLOOP_SESSION). Agent-held claims re-offer;\n exec-held claims are drain-exempt (B3).\n --origin <url> hub origin (else settings.hubOrigin)\n\n settings (no options in v1):\n prints the resolved settings file path, whether it exists, each known\n knob (hubOrigin, cacheDir, stateDir, dispatchCap, commandRouting,\n maxConcurrentAgents, workRoot, workRepo) with its value + provenance,\n and any unrecognized keys.\n settings.dispatchCap/stateDir are the lowest-precedence\n fallbacks for shift's --cap/--state-dir. NO secrets ever\n live in settings \u2014 credentials stay in owenloop's own store.\n\n sessions options:\n --all include 'dead' sessions (hidden by default \u2014\n a dead session can no longer be resumed)\n --json print the raw newest-per-step records, tokens\n included, instead of the table\n --cache-dir <p> override the resolved cache dir\n\n join options:\n --hub <origin> hub to redeem against (else settings.hubOrigin;\n one of the two is REQUIRED \u2014 the code never\n chooses the hub)\n --as <account> credential account to store under (default:\n the Scoped Identity name the hub returns)\n\n shift/hold/exec/prepare/release env:\n credentials come from owenloop's store \u2014 each role reads the\n agent:<account> slot for its origin (never the human slot); a\n missing slot refuses with a runnable 'owenloop login' command.\n OWENLOOP_ACCOUNT Scoped Identity account for exec/prepare/release\n (default 'default'; shift uses --as, and\n stamps it onto dispatched holds/execs)\n OWENLOOP_TOKEN dev-only bearer override \u2014 when set, used\n verbatim and the store + account are\n bypassed (NOT the primary path)\n OWENLOOP_CACHE_DIR cache root\n OWENLOOP_STATE_DIR shift in-flight state dir\n OWENLOOP_SHIFT_LOG_DIR dir for the shift's shift.log and each\n worker's <run>.log; below --log-dir, above\n settings.shiftLogDir, default the state dir\n OWENLOOP_SHIFT_LOG_MAX_AGE_MS\n how long a worker's <run>.log is kept, in ms;\n below --log-max-age, above\n settings.shiftLogMaxAgeMs, default 14 days.\n Worker logs only \u2014 shift.log is never reaped\n OWENLOOP_SESSION hold session-holder tag / release drain target\n OWENLOOP_SHIFT_ID dispatching Shift's self-declared id for\n hold/exec/agent-run's --shift (advisory\n only, never for auth/routing/dispatch)\n OWENLOOP_HARNESS agent-run harness id; below --harness, above\n the step def's 'harness' field\n OWENLOOP_WORK_ROOT root for per-RUN agent work dirs\n (<workRoot>/<workflow>/<run>); above\n settings.workRoot, default <cacheDir>/work.\n A hub-supplied OrderPacket.workdir still\n wins, and is never reaped.\n OWENLOOP_WORK_REPO local git repo to cut per-run work dirs from\n as worktrees instead of plain dirs; above\n settings.workRepo, default off\n\n Credentials / accounts:\n owenloop work's RUNTIME roles (shift/hold/exec/prepare/release) are READ-ONLY\n over owenloop's credential store \u2014 they never write credentials. Each\n role reads the agent:<account> slot for its origin (never the human\n slot); the account defaults to 'default'. 'owenloop work join' is the one\n deliberate provisioning-time writer: it stores the Scoped Identity token a hub\n redeem returns via owenloop's public storeCredential, once, at join time\n \u2014 not a runtime write.\n store / connect an account (run owenloop; owenloop work never writes it):\n owenloop login --hub <origin> --as agent:<account>\n (use --as agent for the default account)\n or provision a fresh box from a hub-issued join code:\n owenloop work join <code> --hub <origin>\n select an account at run time:\n --as <account> on shift / hold\n OWENLOOP_ACCOUNT on exec / prepare / release\n (shift resolves once and threads both channels)\n owenloop work does NOT list stored accounts \u2014 enumerating an origin's accounts\n is an owenloop-side capability; check owenloop for which slots are stored.\n\nExit codes:\n 0 success / help / version / lint clean or warnings-only\n 1 runtime failure (fetch/hub error, cache write) / lint found an error\n 2 usage error (unknown or missing role, missing required arg)\n 3 role not implemented yet (skeleton stub \u2014 lands in a later delivery)\n";
@@ -15,6 +15,11 @@ Usage:
15
15
  owenloop work lint <workflow-name | path> lint x.harness option bags in a def
16
16
  owenloop work sessions [--all] [--json] list this machine's recorded harness
17
17
  sessions and how to re-open them
18
+ owenloop work approvals [--json] every tool call a worker is blocked on
19
+ RIGHT NOW, waiting for a person
20
+ owenloop work approvals approve|deny <wf>/<run> <tool-use-id> [--note <text>]
21
+ answer one; the answer goes back to the
22
+ still-blocked call, not to a later attempt
18
23
  owenloop work release --session <id> [options] drain a session's held claims
19
24
  owenloop work settings print the resolved settings file
20
25
  owenloop work join <code> [--hub <origin>] [--as <account>]
@@ -298,6 +298,8 @@ export declare const ORDER_OWED_FIELDS: {
298
298
  readonly judgmentRejects: "required";
299
299
  readonly schemaRejects: "required";
300
300
  readonly reasons: "required";
301
+ readonly schema: "optional";
302
+ readonly schemaAppliesTo: "optional";
301
303
  readonly proof: "optional";
302
304
  };
303
305
  export declare const ORDER_REASON_FIELDS: {
@@ -147,6 +147,19 @@ export const ORDER_OWED_FIELDS = {
147
147
  judgmentRejects: 'required',
148
148
  schemaRejects: 'required',
149
149
  reasons: 'required',
150
+ // The declared JSON Schema for this owed path and what it governs, projected
151
+ // off the owning produce entry. Optional because most produces declare no
152
+ // schema, so every order emitted before this field existed still validates
153
+ // unchanged — and an order for an unconstrained output carries neither key
154
+ // rather than a null.
155
+ //
156
+ // These are DERIVED, not dynamic: both come from the definition, whose
157
+ // identity the order already pins in `defDigest`. Listing them here is about
158
+ // the wire shape being complete, not about adding anything the signature did
159
+ // not already cover — a tampered schema is a tampered def, and the digest is
160
+ // what catches that.
161
+ schema: 'optional',
162
+ schemaAppliesTo: 'optional',
150
163
  proof: 'optional',
151
164
  };
152
165
  export const ORDER_REASON_FIELDS = {
@@ -10,7 +10,7 @@
10
10
  * born-rejects the output instead of greening it.
11
11
  */
12
12
  import { elementPath, parseElement, parseWorkdirFrom, sealPath, } from "./paths.js";
13
- import { collectionStem, computeFingerprint, eligibleFirings, fingerprintMatches, groupBlockingWinner, isEscalated, isGreen, judgeNameOf, maintainDecisions, pendingOwed, plainConsumes, rejectionEpisode, requiredInputs, workflowStatus, } from "./model.js";
13
+ import { collectionStem, computeFingerprint, eligibleFirings, fingerprintMatches, groupBlockingWinner, isEscalated, isGreen, judgeNameOf, maintainDecisions, owedSchema, pendingOwed, plainConsumes, rejectionEpisode, requiredInputs, workflowStatus, } from "./model.js";
14
14
  import { summarizeIssues, validateValue } from "./schema.js";
15
15
  import { hashDef } from "./defs.js";
16
16
  import { claimMatches, composeCapabilities } from "./capabilities.js";
@@ -1448,8 +1448,12 @@ export class Engine {
1448
1448
  const defDigest = this.instructionSource.digestOf(def);
1449
1449
  const owes = f.outputs.map((p) => {
1450
1450
  const a = arts.get(p);
1451
+ const declared = owedSchema(step, p);
1451
1452
  return {
1452
1453
  path: p,
1454
+ ...(declared !== undefined
1455
+ ? { schema: declared.schema, schemaAppliesTo: declared.appliesTo }
1456
+ : {}),
1453
1457
  // The TARGET version this claim's next successful producer commit will
1454
1458
  // land, not the currently-committed one: `green()` writes
1455
1459
  // `art.version + 1`, so that is the version a consumer will later see
@@ -10,7 +10,7 @@
10
10
  * The artifact set for one workflow instance is passed as a `Map<path, data>`.
11
11
  */
12
12
  import { SETTLED_STATES } from './types.ts';
13
- import type { Acceptance, ArtifactData, CheckOptions, CheckReport, CheckStep, ConsumePattern, FiringTrigger, Fingerprint, InvariantPredicate, StepDef, ProducePattern, RejectKind, RunData, WorkflowDef, WorkflowGraph, WorkflowTrace } from './types.ts';
13
+ import type { Acceptance, ArtifactData, CheckOptions, CheckReport, CheckStep, ConsumePattern, FiringTrigger, Fingerprint, InvariantPredicate, JsonSchema, StepDef, ProducePattern, RejectKind, RunData, WorkflowDef, WorkflowGraph, WorkflowTrace } from './types.ts';
14
14
  export type ArtifactMap = ReadonlyMap<string, ArtifactData>;
15
15
  /**
16
16
  * Clock and quiescence facts needed for idle-trigger eligibility.
@@ -186,6 +186,42 @@ export declare function isEscalated(a: ArtifactData | undefined, after: number):
186
186
  * a history row, never change routing.
187
187
  */
188
188
  export declare function rejectionEpisode(a: ArtifactData | undefined): number;
189
+ /**
190
+ * The JSON Schema the engine will enforce on an OWED path, plus what that
191
+ * schema governs — for projection onto the order packet (`Order.owes[]`).
192
+ *
193
+ * This is a read of the definition for the producer's benefit; it decides
194
+ * nothing. Enforcement stays where it already is, and this function's whole
195
+ * job is to return the same schema those sites will apply, so an order never
196
+ * advertises a shape the commit path would not check. Each branch names the
197
+ * site it mirrors:
198
+ *
199
+ * 1. MAP CHILD (`stem[3].suffix`) → the map produce's schema, governing the
200
+ * element value. Mirrors `engine.ts` `produceSchema()`'s map branch, which
201
+ * `green()` calls on the element.
202
+ * 2. COLLECTION SEAL (`stem` + the seal suffix) → the collection produce's
203
+ * schema, governing EACH MEMBER. Mirrors `engine.ts`'s `emit` path, which
204
+ * looks the schema up by `p.kind === 'collection' && p.stem === stem` and
205
+ * validates the member being emitted. The owed path is the seal because
206
+ * `plainOutputs()` pushes `sealPath(stem)` for a collection — the seal is
207
+ * what the step discharges, the members are what the schema describes.
208
+ * Reporting `appliesTo: 'member'` is the whole reason this function returns
209
+ * a discriminator instead of a bare schema.
210
+ * 3. SINGLETON → the singleton produce's schema, governing the submitted
211
+ * value. Mirrors `produceSchema()`'s singleton branch.
212
+ *
213
+ * Map is tested before singleton because a map produce's `stem` and a
214
+ * singleton's can be spelled the same; only the owed path's index token tells
215
+ * them apart, and `parseElement` is the thing that reads it.
216
+ *
217
+ * Returns undefined when the produce declares no schema, which is the common
218
+ * case — the engine then accepts any JSON, and the order should say nothing
219
+ * rather than imply a constraint that does not exist.
220
+ */
221
+ export declare function owedSchema(step: StepDef, path: string): {
222
+ schema: JsonSchema;
223
+ appliesTo: 'value' | 'member';
224
+ } | undefined;
189
225
  /** Bare elements (no further suffix) of a collection stem, in index order. */
190
226
  export declare function members(arts: ArtifactMap, stem: string): ArtifactData[];
191
227
  /**
package/dist/src/model.js CHANGED
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * The artifact set for one workflow instance is passed as a `Map<path, data>`.
11
11
  */
12
- import { bindProduce, elementPath, isMemberOf, parseElement, sealPath, } from "./paths.js";
12
+ import { bindProduce, elementPath, isMemberOf, parseElement, sealPath, sealStem, } from "./paths.js";
13
13
  import { DEBT_STATES, OUTSTANDING_STATES, SETTLED_STATES } from "./types.js";
14
14
  // ---- step shape classification ----------------------------------------------
15
15
  export function mapConsume(step) {
@@ -226,6 +226,52 @@ function produceOwning(step, path) {
226
226
  }
227
227
  return undefined;
228
228
  }
229
+ /**
230
+ * The JSON Schema the engine will enforce on an OWED path, plus what that
231
+ * schema governs — for projection onto the order packet (`Order.owes[]`).
232
+ *
233
+ * This is a read of the definition for the producer's benefit; it decides
234
+ * nothing. Enforcement stays where it already is, and this function's whole
235
+ * job is to return the same schema those sites will apply, so an order never
236
+ * advertises a shape the commit path would not check. Each branch names the
237
+ * site it mirrors:
238
+ *
239
+ * 1. MAP CHILD (`stem[3].suffix`) → the map produce's schema, governing the
240
+ * element value. Mirrors `engine.ts` `produceSchema()`'s map branch, which
241
+ * `green()` calls on the element.
242
+ * 2. COLLECTION SEAL (`stem` + the seal suffix) → the collection produce's
243
+ * schema, governing EACH MEMBER. Mirrors `engine.ts`'s `emit` path, which
244
+ * looks the schema up by `p.kind === 'collection' && p.stem === stem` and
245
+ * validates the member being emitted. The owed path is the seal because
246
+ * `plainOutputs()` pushes `sealPath(stem)` for a collection — the seal is
247
+ * what the step discharges, the members are what the schema describes.
248
+ * Reporting `appliesTo: 'member'` is the whole reason this function returns
249
+ * a discriminator instead of a bare schema.
250
+ * 3. SINGLETON → the singleton produce's schema, governing the submitted
251
+ * value. Mirrors `produceSchema()`'s singleton branch.
252
+ *
253
+ * Map is tested before singleton because a map produce's `stem` and a
254
+ * singleton's can be spelled the same; only the owed path's index token tells
255
+ * them apart, and `parseElement` is the thing that reads it.
256
+ *
257
+ * Returns undefined when the produce declares no schema, which is the common
258
+ * case — the engine then accepts any JSON, and the order should say nothing
259
+ * rather than imply a constraint that does not exist.
260
+ */
261
+ export function owedSchema(step, path) {
262
+ const el = parseElement(path);
263
+ if (el && el.suffix !== '') {
264
+ const mp = step.produces.find((p) => p.kind === 'map' && p.stem === el.stem && p.suffix === el.suffix);
265
+ return mp?.schema === undefined ? undefined : { schema: mp.schema, appliesTo: 'value' };
266
+ }
267
+ const sealed = sealStem(path);
268
+ if (sealed !== null) {
269
+ const cp = step.produces.find((p) => p.kind === 'collection' && p.stem === sealed);
270
+ return cp?.schema === undefined ? undefined : { schema: cp.schema, appliesTo: 'member' };
271
+ }
272
+ const sp = step.produces.find((p) => p.kind === 'singleton' && p.stem === path);
273
+ return sp?.schema === undefined ? undefined : { schema: sp.schema, appliesTo: 'value' };
274
+ }
229
275
  /** An artifact is frozen (no firing re-arms it) when either stall trips or it is held. */
230
276
  function frozen(a, step) {
231
277
  if (!a)
@@ -558,6 +558,17 @@ export declare const WIRE_SCHEMAS: {
558
558
  };
559
559
  };
560
560
  };
561
+ schema: {
562
+ description: string;
563
+ oneOf: {
564
+ type: string;
565
+ }[];
566
+ };
567
+ schemaAppliesTo: {
568
+ description: string;
569
+ type: string;
570
+ enum: string[];
571
+ };
561
572
  proof: {
562
573
  type: string;
563
574
  };
@@ -96,6 +96,15 @@
96
96
  }
97
97
  }
98
98
  },
99
+ "schema": {
100
+ "description": "The JSON Schema the engine will enforce on this owed path at commit time, copied verbatim off the owning produce entry. Absent when that produce declares none, which is the common case and means any JSON is accepted. A JSON Schema is either a keyword object or a bare boolean, so both forms are admitted here.",
101
+ "oneOf": [{ "type": "object" }, { "type": "boolean" }]
102
+ },
103
+ "schemaAppliesTo": {
104
+ "description": "What `schema` governs. Present exactly when `schema` is. `value` — the value submitted to this path (a singleton produce, or one element of a map produce). `member` — each member emitted into this collection, NOT the seal value the path names; a collection's owed path is its seal while its declared schema is checked per member on emit.",
105
+ "type": "string",
106
+ "enum": ["value", "member"]
107
+ },
99
108
  "proof": { "type": "string" }
100
109
  }
101
110
  }
@@ -221,6 +221,40 @@ export interface Order {
221
221
  judgmentRejects: number;
222
222
  schemaRejects: number;
223
223
  reasons: ReasonEntry[];
224
+ /**
225
+ * The JSON Schema the engine will enforce on this output at commit time,
226
+ * copied verbatim off the owning produce entry. Absent when that produce
227
+ * declares none — the common case, and the engine then accepts any JSON.
228
+ *
229
+ * WHY IT IS ON THE ORDER. `schemaRejects` and the `'schema'` reason entries
230
+ * already travel here, so a producer is told AFTER the fact that the shape
231
+ * it submitted was wrong, and told the cap it is burning down. It was never
232
+ * told the shape. A re-offered agent reading "your last submission failed
233
+ * its schema" has the same information it had the first time and no more,
234
+ * which is why the same malformed shape gets resubmitted until the counter
235
+ * stalls the step. This closes that: the requirement is stated up front,
236
+ * from the same declaration the refusal will be measured against.
237
+ *
238
+ * It is a COPY, not a reference. The order is immutable once written
239
+ * (`RunData.order`), so this is the schema as it stood at claim time; a def
240
+ * edited mid-run leaves the projected schema and the enforced one able to
241
+ * disagree, exactly as `defDigest` already records for the rest of the
242
+ * order.
243
+ */
244
+ schema?: JsonSchema;
245
+ /**
246
+ * What `schema` governs. Present exactly when `schema` is.
247
+ *
248
+ * - `'value'` — the submitted value itself. Singleton produces, and one
249
+ * element of a map produce.
250
+ * - `'member'` — EACH member emitted into this collection. NOT the seal
251
+ * value at the path this entry names. A collection's owed path is its
252
+ * seal (`model.ts` `plainOutputs` pushes `sealPath(stem)`), while the
253
+ * declared schema is checked per member on `emit`, so projecting it
254
+ * without this discriminator would tell a producer to shape the seal
255
+ * like a member.
256
+ */
257
+ schemaAppliesTo?: 'value' | 'member';
224
258
  /** Opaque proof/signature placeholder for future WP-A4-signed reason
225
259
  * threads. Data-only today: no cryptographic code attaches or verifies
226
260
  * it — the slot exists so signed dynamic data can land without changing
@@ -59,8 +59,8 @@ A cache created by an older CLI may contain `filesystem` or `network` under `per
59
59
  | `network: owenloop-only` | supported through isolated settings, skills, MCP, and built-in tools | refused |
60
60
  | `network: unrestricted` | supported | supported with `filesystem: unrestricted`, or with an omitted filesystem field and legacy sandbox `workspace-write` / `danger-full-access`; legacy sandbox `read-only` is refused because Codex has no independent read-only network control |
61
61
  | `maxTurns` | enforced by the SDK | refused; Codex app-server has no thread or turn limit parameter |
62
- | `permissionMode: ask` | translated to `default` | translated to `approvalPolicy: untrusted` |
63
- | `permissionMode: auto-safe` | translated to `auto`, without the danger companion flag | translated to `approvalPolicy: on-request` |
62
+ | `permissionMode: ask` | translated to `default`, with the adapter's gatekeeper set to `human-gate` | translated to `approvalPolicy: untrusted` |
63
+ | `permissionMode: auto-safe` | translated to `default` (NOT the SDK's `auto`, which never reaches the permission callback), with the adapter's gatekeeper set to `classifier`; no danger companion flag | translated to `approvalPolicy: on-request` |
64
64
  | `permissionMode: full-access` | translated to `bypassPermissions` plus the SDK's `allowDangerouslySkipPermissions` companion flag | translated to `approvalPolicy: never` |
65
65
  | another adapter's `permissionMode` value | refused; the Claude Code adapter accepts only its own SDK union plus the three neutral values | refused; the Codex adapter accepts only `untrusted`, `on-request`, `never`, plus the three neutral values |
66
66
 
@@ -81,12 +81,24 @@ The neutral vocabulary is three positions on one axis, and both shipped harnesse
81
81
  | Neutral value | What is the gate | Claude Code | Codex |
82
82
  |---|---|---|---|
83
83
  | `ask` | a human, before anything beyond trivially safe reads | `default` | `untrusted` |
84
- | `auto-safe` | a model-side classifier; it proceeds on ordinary work and consults a human only when an action is potentially dangerous | `auto` | `on-request` |
84
+ | `auto-safe` | a classifier; it proceeds on ordinary work and escalates only when an action is potentially dangerous | `default` + the adapter's gatekeeper | `on-request` |
85
85
  | `full-access` | nothing; the harness never consults a human and a failed action is reported back to the model | `bypassPermissions` + `allowDangerouslySkipPermissions` | `never` |
86
86
 
87
- `auto-safe` is not a milder `full-access`. It can still stop and ask, which is the whole point of it, so an adapter must never map it onto a never-ask mode. The two exist separately so a definition states the choice rather than having it inferred.
87
+ `auto-safe` is not a milder `full-access`. It can still escalate, which is the whole point of it, so an adapter must never map it onto a never-ask mode. The two exist separately so a definition states the choice rather than having it inferred.
88
88
 
89
- `ask` and `auto-safe` are meaningful only where something can answer a prompt. In a Shift-dispatched run nothing can today, so a prompt is a stall: the Step Agent stops mid-turn, submits nothing, and the hub re-arms the step into a retry storm whose every worker dies in the same place. That is a reason for a definition author to choose `full-access` for headless steps, not a reason for an adapter to silently upgrade one value into another.
89
+ ### Who does the gating, and how a headless step escalates
90
+
91
+ The vendor classifiers do not, in practice, consult anyone. The SDK's `auto` mode was probed with five actions — among them a recursive delete on an absolute path outside the session working directory, an outbound network request, and a read of a file outside that directory. It consulted the host on none of them, auto-denied none of them, and four ran. `auto` also never reaches the SDK's `canUseTool` callback, so no host-side wiring can give it an exception path.
92
+
93
+ The Claude Code adapter therefore does not delegate `auto-safe` to `auto`. Both `ask` and `auto-safe` translate to `default`, the one SDK mode that routes every unapproved tool call to `canUseTool`, and the adapter's own gatekeeper decides:
94
+
95
+ - **Path containment.** A tool call naming a path outside the step's working directory escalates, under either policy. This is decidable and is the check that catches the probes above.
96
+ - **A shell deny-list.** Under `auto-safe`, `Bash` escalates on a short list of destructive or exfiltrating patterns (`sudo`, recursive force-delete, device writes, ownership changes, `curl`/`wget` carrying a request body, changes to what runs on the machine outside the step). It is a deny-list, not a proof: an obfuscated command gets past it. A step whose every command must be reviewed says `ask`, which escalates all of them without consulting the list.
97
+ - **Policy.** `ask` allows only a contained read and escalates everything else. `auto-safe` allows ordinary work and escalates what the two checks above establish. The worker-owned `owenloop` MCP mount is allowed under both, because gating it would remove a stuck step's ability to say so.
98
+
99
+ An escalation in a Shift-dispatched run cannot be a synchronous prompt — no person is watching at the moment of the call, and a call left waiting is a stall that re-arms the step into a retry storm. The adapter denies the call and routes the agent to the `ask` MCP tool, which freezes the owed artifact, closes the run without burning further attempts, and puts the question on a human's attention feed with an answer path back into the next attempt. The denial is also emitted as a progress event, so an operator can see a gate that fired.
100
+
101
+ A step that names no `permissionMode` at all reaches the SDK's `default` and is gated under the `classifier` policy. Before the gatekeeper existed such a step was denied wholesale — `default` denies when no callback is wired — silently and finally, with nobody prompted and nothing recorded.
90
102
 
91
103
  For each neutral value an adapter must either map it onto the vendor mode with the same meaning, or refuse it in preflight. Refusal is a legitimate answer and fails closed: the worker releases its claim and starts no model process. Mapping a value onto a mode that grants more than the value describes is never legitimate.
92
104
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owenloop",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "description": "Deterministic rails for agentic workflows. Declare steps and dependencies; the engine guarantees order, redoes what changes invalidate, and stops what keeps failing — instead of hoping the agent follows through.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "typicalday",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owenloop",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "description": "Claude Code driver for owenloop — cross-harness shift and conduct skills driven by the owenloop CLI, plus one hub control-plane MCP server backing an author skill and a fallback worker, for conducting and authoring workflows against your hosted owenloop server.",
5
5
  "author": {
6
6
  "name": "Typical Day"
@@ -7,7 +7,7 @@
7
7
  "mcp"
8
8
  ],
9
9
  "env": {
10
- "OWENLOOP_PLUGIN_VERSION": "0.5.5"
10
+ "OWENLOOP_PLUGIN_VERSION": "0.5.7"
11
11
  }
12
12
  }
13
13
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owenloop",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "description": "Codex plugin for the owenloop workflow engine.",
5
5
  "skills": "./skills/",
6
6
  "mcpServers": "./.mcp.json"
@@ -6,7 +6,7 @@
6
6
  "mcp"
7
7
  ],
8
8
  "env": {
9
- "OWENLOOP_PLUGIN_VERSION": "0.5.5"
9
+ "OWENLOOP_PLUGIN_VERSION": "0.5.7"
10
10
  },
11
11
  "env_vars": [
12
12
  "HOME",