owenloop 0.5.29 → 0.5.30

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 CHANGED
@@ -4,6 +4,13 @@ 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.30](https://github.com/typicalday/owenloop/compare/v0.5.29...v0.5.30) (2026-09-05)
8
+
9
+
10
+ ### Features
11
+
12
+ * **engine:** send a refused path's previous value back with the re-offer ([#312](https://github.com/typicalday/owenloop/issues/312)) ([d697b6e](https://github.com/typicalday/owenloop/commit/d697b6ebb08538fa3a79f9eee0bd648fa13620a5))
13
+
7
14
  ## [0.5.29](https://github.com/typicalday/owenloop/compare/v0.5.28...v0.5.29) (2026-09-05)
8
15
 
9
16
 
@@ -471,6 +471,63 @@ export function renderRejection(spec) {
471
471
  ].join('\n\n');
472
472
  return { message, count, ...(newest !== undefined ? { deliveredReasonAt: newest } : {}) };
473
473
  }
474
+ /**
475
+ * Render what the refused submission actually SAID, for the paths the cold
476
+ * replay is about to show reasons for.
477
+ *
478
+ * WHY ONLY THE COLD PATH NEEDS THIS. A resumed session still holds its own
479
+ * prior submission, so `renderRejection` alone is enough there. A cold replay
480
+ * has no session: `renderReplayBrief`'s own contract is that without the
481
+ * reasons "the fresh agent repeats the rejected submission verbatim" -- but a
482
+ * fresh agent given only reasons cannot repeat it either. It has to rebuild the
483
+ * whole value from the brief to change the one part that was called out, and
484
+ * the rebuild quietly loses everything the reader did not object to. Sending
485
+ * the value back is what makes "keep everything you already have that was not
486
+ * called out above", which the rejection body already says, a thing the agent
487
+ * is able to do.
488
+ *
489
+ * SCOPE. Only paths that both carry a `previousValue` and have fresh reasons in
490
+ * this delta -- a value shown next to no reason is material with no correction
491
+ * attached, and the agent cannot tell what to do with it.
492
+ *
493
+ * HONESTY. The heading does not call this "the rejected value". After a schema
494
+ * reject nothing was committed, so what the hub sends is the last value that
495
+ * did commit, which may be older than the refusal or absent entirely. The
496
+ * wording says what the engine can actually promise.
497
+ */
498
+ function renderPreviousValues(spec) {
499
+ const since = spec.deliveredReasonAt;
500
+ const wanted = spec.paths === undefined ? undefined : new Set(spec.paths);
501
+ const sections = [];
502
+ for (const owed of spec.packet.owes) {
503
+ if (wanted !== undefined && !wanted.has(owed.path))
504
+ continue;
505
+ if (owed.previousValue === undefined)
506
+ continue;
507
+ const fresh = owed.reasons.filter((r) => since === undefined || r.at > since);
508
+ if (fresh.length === 0)
509
+ continue;
510
+ let body;
511
+ try {
512
+ body = JSON.stringify(owed.previousValue, null, 2) ?? String(owed.previousValue);
513
+ }
514
+ catch {
515
+ // A value that arrived as JSON cannot cycle, but a projecting layer is
516
+ // free to hand us anything. Dropping the section beats failing the replay.
517
+ continue;
518
+ }
519
+ sections.push(`The value \`${owed.path}\` currently holds:\n\n\`\`\`json\n${body}\n\`\`\``);
520
+ }
521
+ if (sections.length === 0)
522
+ return '';
523
+ return [
524
+ 'What is already on the owed paths, so you can revise it rather than rebuild it:',
525
+ ...sections,
526
+ 'This is what the path holds now, which is the value that was refused when the'
527
+ + ' refusal came from a reader. When it came from the schema check the value was'
528
+ + ' never committed, so what you see is the last one that was.',
529
+ ].join('\n\n');
530
+ }
474
531
  /**
475
532
  * Assemble a COLD-REPLAY brief: the ordinary rendered brief plus the same
476
533
  * rejection body as a trailing section.
@@ -497,15 +554,27 @@ export function renderReplayBrief(brief, spec) {
497
554
  const full = renderRejection(spec);
498
555
  if (full.message === '')
499
556
  return brief;
500
- const join = (body, dropped) => {
557
+ const join = (body, dropped, values) => {
501
558
  const note = dropped > 0
502
559
  ? `\n\n(${dropped} older rejection reason${dropped === 1 ? '' : 's'} omitted to fit the context budget.)`
503
560
  : '';
504
- return `${brief}\n\n---\n\n${body}${note}`;
561
+ const prior = values === '' ? '' : `${values}\n\n---\n\n`;
562
+ return `${brief}\n\n---\n\n${prior}${body}${note}`;
505
563
  };
506
- let assembled = join(full.message, 0);
564
+ const values = renderPreviousValues(spec);
565
+ let assembled = join(full.message, 0, values);
507
566
  if (estimateTokens(assembled) <= REPLAY_TOKEN_BUDGET)
508
567
  return assembled;
568
+ // First thing over budget: the previous values, whole. They are MATERIAL,
569
+ // and the reasons are the INSTRUCTION -- an agent holding the corrections
570
+ // can still rebuild the value, while one holding the value and no correction
571
+ // cannot know what to change. Same ordering principle as the brief itself,
572
+ // which is never trimmed: keep whatever the agent cannot work without.
573
+ if (values !== '') {
574
+ assembled = join(full.message, 0, '');
575
+ if (estimateTokens(assembled) <= REPLAY_TOKEN_BUDGET)
576
+ return assembled;
577
+ }
509
578
  // Over budget: re-render with progressively fewer reasons, oldest dropped
510
579
  // first. `ordered` is every candidate entry in ascending `at`, so slicing off
511
580
  // the FRONT drops the oldest and keeps whole entries.
@@ -529,7 +598,7 @@ export function renderReplayBrief(brief, spec) {
529
598
  });
530
599
  if (trimmed.message === '')
531
600
  break;
532
- assembled = join(trimmed.message, drop);
601
+ assembled = join(trimmed.message, drop, '');
533
602
  if (estimateTokens(assembled) <= REPLAY_TOKEN_BUDGET)
534
603
  return assembled;
535
604
  }
@@ -283,6 +283,23 @@ export interface OrderPacket {
283
283
  judgmentRejects: number;
284
284
  schemaRejects: number;
285
285
  reasons: ReasonEntry[];
286
+ /**
287
+ * The value this path already holds, projected by a hub new enough to send
288
+ * it and ONLY on a re-offer whose reason thread is non-empty. Absent on a
289
+ * first offer, absent from an older hub, and absent when the refusal never
290
+ * committed a value.
291
+ *
292
+ * It is the REFUSED value only after a judgment or human reject, which
293
+ * follow a commit. A schema reject refuses the write, so after one this
294
+ * carries the last value that did commit, or nothing. Read `reasons` when
295
+ * the distinction matters; the engine's contract is on `Order.owes[]` in
296
+ * `src/types.ts`.
297
+ *
298
+ * Used on the COLD-REPLAY path only — see `renderReplayBrief`. A resumed
299
+ * session still holds its own prior submission, so sending it back there
300
+ * would spend tokens re-stating what the model already has.
301
+ */
302
+ previousValue?: unknown;
286
303
  /**
287
304
  * The JSON Schema the engine will enforce on this output at commit time,
288
305
  * projected off the owning produce entry by a schema-aware hub. Absent
@@ -301,6 +301,7 @@ export declare const ORDER_OWED_FIELDS: {
301
301
  readonly judgmentRejects: "required";
302
302
  readonly schemaRejects: "required";
303
303
  readonly reasons: "required";
304
+ readonly previousValue: "optional";
304
305
  readonly schema: "optional";
305
306
  readonly schemaAppliesTo: "optional";
306
307
  readonly proof: "optional";
@@ -155,6 +155,17 @@ export const ORDER_OWED_FIELDS = {
155
155
  judgmentRejects: 'required',
156
156
  schemaRejects: 'required',
157
157
  reasons: 'required',
158
+ // The value the owed path already holds, sent back only on a re-offer whose
159
+ // reason thread is non-empty. Optional because most offers are first offers
160
+ // and carry no such thread, so every order emitted before this field existed
161
+ // still validates unchanged.
162
+ //
163
+ // Unlike `schema` below this is DYNAMIC, not derived: it is committed engine
164
+ // state read inside the claim transaction, exactly like `version`,
165
+ // `judgmentRejects` and `reasons`, all of which the signature already covers.
166
+ // Covering it too is what stops a re-offer from being replayed with a
167
+ // different prior value substituted under the same claim.
168
+ previousValue: 'optional',
158
169
  // The declared JSON Schema for this owed path and what it governs, projected
159
170
  // off the owning produce entry. Optional because most produces declare no
160
171
  // schema, so every order emitted before this field existed still validates
@@ -1886,6 +1886,7 @@ export class Engine {
1886
1886
  const owes = f.outputs.map((p) => {
1887
1887
  const a = arts.get(p);
1888
1888
  const declared = owedSchema(step, p);
1889
+ const reasons = a?.reasons ?? [];
1889
1890
  return {
1890
1891
  path: p,
1891
1892
  ...(declared !== undefined
@@ -1909,7 +1910,18 @@ export class Engine {
1909
1910
  version: (a?.version ?? 0) + 1,
1910
1911
  judgmentRejects: a?.judgmentRejects ?? 0,
1911
1912
  schemaRejects: a?.schemaRejects ?? 0,
1912
- reasons: a?.reasons ?? [],
1913
+ reasons,
1914
+ // The value the path already holds, but ONLY on a re-offer that
1915
+ // follows a refusal. With an empty reason thread there is no feedback
1916
+ // for a previous value to be feedback ON, so projecting it would put
1917
+ // an artifact-sized payload on every ordinary first offer and buy
1918
+ // nothing. `undefined` is "no value" here, the same reading `consumes`
1919
+ // above gives it. See the field's contract in `types.ts` -- in
1920
+ // particular that this is the REFUSED value only after a judgment or
1921
+ // human reject, since a schema reject never committed one.
1922
+ ...(reasons.length > 0 && a?.value !== undefined
1923
+ ? { previousValue: a.value }
1924
+ : {}),
1913
1925
  };
1914
1926
  });
1915
1927
  const order = {
@@ -561,6 +561,9 @@ export declare const WIRE_SCHEMAS: {
561
561
  };
562
562
  };
563
563
  };
564
+ previousValue: {
565
+ description: string;
566
+ };
564
567
  schema: {
565
568
  description: string;
566
569
  oneOf: {
@@ -97,6 +97,9 @@
97
97
  }
98
98
  }
99
99
  },
100
+ "previousValue": {
101
+ "description": "The value this owed path already holds, sent only on a re-offer whose reason thread is non-empty. Absent on a first offer, and absent when the refusal never committed a value. It is the REFUSED value only after a judgment or human reject, which follow a commit; a schema reject refuses the write, so after one this carries the last value that did commit. Any JSON, because it is a def author's artifact value and not a shape this wire contract controls."
102
+ },
100
103
  "schema": {
101
104
  "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.",
102
105
  "oneOf": [{ "type": "object" }, { "type": "boolean" }]
@@ -281,6 +281,46 @@ export interface Order {
281
281
  judgmentRejects: number;
282
282
  schemaRejects: number;
283
283
  reasons: ReasonEntry[];
284
+ /**
285
+ * The value this owed path already holds, projected ONLY when the reason
286
+ * thread above is non-empty -- that is, only on a re-offer that follows a
287
+ * refusal.
288
+ *
289
+ * WHY IT IS ON THE ORDER. The same argument as `schema` below, for content
290
+ * instead of shape. `reasons` already tells a re-offered producer THAT its
291
+ * last submission was refused and why. It does not tell it WHAT it
292
+ * submitted. A producer reading "your plan was rejected because phase 3
293
+ * cites no artifact", with no sight of the plan it wrote, has to rebuild
294
+ * the whole value from memory to change one phase, and the rebuild
295
+ * silently drops the parts nobody objected to. That is the same rework
296
+ * `schema` exists to prevent, arriving through a different door: feedback
297
+ * is actionable only against the thing it is feedback ON.
298
+ *
299
+ * WHAT IT ACTUALLY HOLDS, which is NOT always the refused value:
300
+ *
301
+ * - After a judgment or human reject, it IS the refused value. Those
302
+ * rejects FOLLOW a commit -- `green()` had already written the artifact
303
+ * and bumped `version` -- so what stands here is what the judge read.
304
+ * - After a schema reject or an artifact-bind reject, it is NOT. Those
305
+ * refuse the write itself, so nothing was committed, and this carries
306
+ * the last value that DID commit, or is absent when none ever did.
307
+ *
308
+ * It is deliberately not named `rejectedValue`. Half the refusal kinds
309
+ * that put a reason on this thread never commit the value they refused,
310
+ * and a name asserting otherwise would be read as a guarantee the engine
311
+ * cannot make. A layer that needs the distinction reads `reasons`, which
312
+ * records each refusal's kind.
313
+ *
314
+ * Absent on a first firing, which has no artifact at all, and absent on
315
+ * any re-offer whose reason thread is empty. Gating on the thread is what
316
+ * keeps an artifact-sized payload off the ordinary offer and confines it
317
+ * to the rework path, the only path able to use it.
318
+ *
319
+ * It is a COPY taken at claim time, under the same contract as `schema`:
320
+ * `Store.restampOrderTarget`, the one post-claim writer of a persisted
321
+ * order, touches only `owes[].version`.
322
+ */
323
+ previousValue?: unknown;
284
324
  /**
285
325
  * The JSON Schema the engine will enforce on this output at commit time,
286
326
  * copied verbatim off the owning produce entry. Absent when that produce
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owenloop",
3
- "version": "0.5.29",
3
+ "version": "0.5.30",
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.29",
3
+ "version": "0.5.30",
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.29"
10
+ "OWENLOOP_PLUGIN_VERSION": "0.5.30"
11
11
  }
12
12
  }
13
13
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owenloop",
3
- "version": "0.5.29",
3
+ "version": "0.5.30",
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.29"
9
+ "OWENLOOP_PLUGIN_VERSION": "0.5.30"
10
10
  },
11
11
  "env_vars": [
12
12
  "HOME",