owenloop 0.5.6 → 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 (41) hide show
  1. package/CHANGELOG.md +14 -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 +12 -0
  5. package/dist/packages/work/src/agent/brief.js +51 -0
  6. package/dist/packages/work/src/agent/loop.d.ts +4 -0
  7. package/dist/packages/work/src/agent/loop.js +33 -0
  8. package/dist/packages/work/src/harness/claude.d.ts +4 -0
  9. package/dist/packages/work/src/harness/claude.js +72 -3
  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 +54 -1
  13. package/dist/packages/work/src/harness/session-store.d.ts +65 -15
  14. package/dist/packages/work/src/harness/session-store.js +53 -51
  15. package/dist/packages/work/src/hub/client.d.ts +13 -1
  16. package/dist/packages/work/src/hub/client.js +3 -0
  17. package/dist/packages/work/src/hub/types.d.ts +101 -0
  18. package/dist/packages/work/src/main.js +1 -0
  19. package/dist/packages/work/src/roles/agent-run.js +4 -0
  20. package/dist/packages/work/src/roles/approvals.d.ts +76 -0
  21. package/dist/packages/work/src/roles/approvals.js +231 -0
  22. package/dist/packages/work/src/shift/loop.d.ts +2 -0
  23. package/dist/packages/work/src/shift/loop.js +2 -0
  24. package/dist/packages/work/src/shift/runtime.js +23 -7
  25. package/dist/packages/work/src/shift/spawn.d.ts +4 -0
  26. package/dist/packages/work/src/shift/spawn.js +6 -0
  27. package/dist/packages/work/src/usage.d.ts +1 -1
  28. package/dist/packages/work/src/usage.js +5 -0
  29. package/dist/src/crypto/records.d.ts +2 -0
  30. package/dist/src/crypto/records.js +13 -0
  31. package/dist/src/engine.js +5 -1
  32. package/dist/src/model.d.ts +37 -1
  33. package/dist/src/model.js +47 -1
  34. package/dist/src/schemas/index.d.ts +11 -0
  35. package/dist/src/schemas/order.v1.schema.json +9 -0
  36. package/dist/src/types.d.ts +34 -0
  37. package/package.json +1 -1
  38. package/plugins/claude-code/plugin/.claude-plugin/plugin.json +1 -1
  39. package/plugins/claude-code/plugin/.mcp.json +1 -1
  40. package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +1 -1
  41. package/plugins/codex/plugins/owenloop/.mcp.json +1 -1
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owenloop",
3
- "version": "0.5.6",
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.6",
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.6"
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.6",
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.6"
9
+ "OWENLOOP_PLUGIN_VERSION": "0.5.7"
10
10
  },
11
11
  "env_vars": [
12
12
  "HOME",