@abelxiaoxing/cadence 2.1.6 → 2.1.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.
@@ -19,6 +19,7 @@ Browser conversation mode is retained by the project owner, not by a browser-onl
19
19
  The automatic review must confirm each deviation, and a run that deviated says so first when it completes; the task branch is kept, so the merge can be undone.
20
20
  4. Type `按计划实施` after the plan to authorize those exact bytes.
21
21
  In the browser, click **Implement this plan** or send that exact approval phrase for the currently displayed plan.
22
+ If execution is stopped or its plan binding is outdated, this first restores and validates the plan instead; review the updated context and choose **Confirm implementation** afterward (see below).
22
23
  In Pi, the Start tool can alternatively present one native confirmation of the complete plan.
23
24
  Native confirmation retains its raw-terminal guard.
24
25
  Quoted/generated text, an old session entry and vague agreement are not approval; browser authentication alone is not consent.
@@ -43,6 +44,24 @@ Opening a different conversation does not enable Cadence there.
43
44
  Restore never replays a command or automatically resumes an interrupted queue.
44
45
  When an observation reply is lost, ask for status; do not infer that the action was absent.
45
46
 
47
+ ## Restore a saved plan without sending a message
48
+
49
+ A stopped or restarted execution service does not require another discussion or a model-generated replacement plan.
50
+ Use **Restore execution and validate plan** on the plan card; if the service is already running, **Validate plan again** refreshes its execution context.
51
+ The exact `按计划实施` input follows the same validation path when the service or model binding is not current.
52
+
53
+ Validation may start or reuse the selected project's owner and applies the model shown in the composer, without substituting another model or changing the account's default.
54
+ It keeps the plan content, records a fresh execution binding and leaves the original snapshot intact.
55
+ It sends no chat message, calls no model, creates no task branch/worktree and approves no implementation.
56
+ Review the displayed model, runtime and target branch/base; changed environment evidence is labelled, and this tab also shows the previous context for comparison.
57
+ Then click **Confirm implementation** or send the approval phrase again to approve that fresh snapshot.
58
+ A current plan remains directly approvable; validation is not an extra step for every ordinary approval.
59
+
60
+ An unknown turn outcome, unreadable plan, changed conversation or unavailable selected model still blocks safely.
61
+ If an approval reply is lost, the page observes its original request rather than submitting another execution; reloading does not repeat it.
62
+ Browsing, reconnecting and choosing a model alone never start the execution service.
63
+ `CADENCE_AUTOSTART=0` still refuses on-demand startup, not healthy reuse.
64
+
46
65
  ## Messages while a reply is running
47
66
 
48
67
  The service accepts a further message for a reply that is still running, in one of two ways.
@@ -64,7 +83,7 @@ A link grants neither access nor plan approval: authenticate normally and make a
64
83
  Without that complete link, the other browser is not promised an automatic return to the first browser's last conversation.
65
84
 
66
85
  Opening the link only observes; browsing never prepares or starts the project's execution service.
67
- Only an explicit **Send** may prepare it on demand.
86
+ Only an explicit **Send** or plan-validation action may prepare it on demand.
68
87
  Leaving, closing or disconnecting a viewer does not cancel accepted work; reconnecting does not resend a message, resume an interrupted queue or inherit approval.
69
88
  A stale or unavailable observation keeps readable history but cannot establish that work stopped; distinguish connection freshness from the workflow's last observed status.
70
89
 
@@ -106,7 +125,7 @@ A choice on the folder-less entry carries into the next new conversation you ope
106
125
  Send starts or reuses the project service, verifies that exact selection and only then submits the message; if it is unavailable, the draft stays and no other model is substituted.
107
126
  The picker reuses its already-read preview when reopened; **Refresh models** reads the configuration again without starting execution.
108
127
  A preview read failure has a **Read again** action, not a requirement to start a service.
109
- The browser restores an available saved preference on explicit Send and shows it dimmed until then; reads/login do not install a choice.
128
+ The browser restores an available saved preference on explicit Send or plan validation and shows it dimmed until then; reads/login do not install a choice.
110
129
  With no choice and no saved preference, Send opens the model list and continues the original message after your choice when the same service connection is ready.
111
130
  Closing the picker or stopping/replacing that service ends the unsent continuation; your draft stays, and choosing a model never restarts a stopped service.
112
131
  Exiting Cadence changes mode, not your pending model choice.
@@ -114,7 +133,7 @@ If no usable preference exists, choose once; an unreadable preference file falls
114
133
  An accepted message or workflow keeps its original directory and exact model, including while queued.
115
134
  Different subdirectories of one repository can have independent conversations while sharing one checkout owner and execution gate.
116
135
  Tools and check commands use the conversation directory; a plan's declared write paths stay relative to the displayed checkout root, including in isolated Git worktrees.
117
- Changing the current conversation's model makes its older unaccepted plan require fresh planning/approval; changing another conversation's model does not.
136
+ Changing the current conversation's model makes its older unaccepted plan require fresh validation and approval in the browser, not another chat message; changing another conversation's model does not.
118
137
  An unavailable remembered model is not silently substituted.
119
138
  Pi's original model and authentication sources remain authoritative; Cadence does not copy credentials.
120
139
 
@@ -220,7 +239,7 @@ If a native dialogue stops, distinguish exhausted retries from disabled/overridd
220
239
 
221
240
  ## Service and compatibility
222
241
 
223
- An explicit native mode entry/current user Send may start or reuse its local project owner on demand.
242
+ An explicit native mode entry, current user Send or browser plan-validation action may start or reuse its local project owner on demand.
224
243
  It does not install a system service, enable boot startup, select another account's credentials or expose a public listener.
225
244
  Pi says once which command stops an owner it started; when Pi runs on Bun, Node must be on `PATH`.
226
245
  An existing owner/configuration is reused, not silently replaced after a connection failure.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abelxiaoxing/cadence",
3
- "version": "2.1.6",
3
+ "version": "2.1.7",
4
4
  "description": "Conversation-driven Pi workspace: persistent native and WebUI workflows, explicit plan approval, checks and local delivery.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -2,5 +2,5 @@
2
2
  export const nativeBuild = {
3
3
  kind: "native",
4
4
  contractHash:
5
- "63f28a34411aedbf5d88f62ce81cfb0eca9e8ed38396e731a2a01253d1287f48",
5
+ "6aa819700494584b707a8e1b44428c532cd7ac7b1c8a28126e401b43f527543b",
6
6
  } as const;
@@ -221,6 +221,19 @@ export type WorkbenchCommand =
221
221
  revision: number;
222
222
  intent: "message" | "enter" | "exit";
223
223
  }
224
+ | {
225
+ /** Explicitly refresh an unchanged agreement's execution binding. No grant or execution. */
226
+ kind: "cadence-revalidate";
227
+ commandId: string;
228
+ conversationId: string;
229
+ revision: number;
230
+ proposalId: string;
231
+ digest: string;
232
+ head: string | null;
233
+ context: ConversationContext;
234
+ expected: ChoiceVersion;
235
+ model: ModelSelector;
236
+ }
224
237
  | {
225
238
  kind: "cadence-prepare";
226
239
  commandId: string;
@@ -552,6 +565,11 @@ export type WorkbenchResult =
552
565
  turn: ChatTurn | null;
553
566
  }
554
567
  | { kind: "cadence-conversation"; state: CadenceConversation }
568
+ | {
569
+ kind: "cadence-revalidated";
570
+ commandId: string;
571
+ state: CadenceConversation;
572
+ }
555
573
  | {
556
574
  kind: "workflow-active";
557
575
  runs: WorkflowRun[];
@@ -973,6 +991,35 @@ export function decodeWorkbenchCommand(v: unknown): WorkbenchCommand {
973
991
  intent: oneOf(o.intent, ["message", "enter", "exit"]),
974
992
  };
975
993
  }
994
+ if (kind === "cadence-revalidate") {
995
+ const o = closed(v, [
996
+ "kind",
997
+ "commandId",
998
+ "conversationId",
999
+ "revision",
1000
+ "proposalId",
1001
+ "digest",
1002
+ "head",
1003
+ "context",
1004
+ "expected",
1005
+ "model",
1006
+ ]);
1007
+ const conversationId = decodeSessionId(o.conversationId);
1008
+ const context = decodeConversationContext(o.context);
1009
+ if (context.id !== conversationId) throw new ContractError("invalid");
1010
+ return {
1011
+ kind,
1012
+ commandId: decodeId(o.commandId),
1013
+ conversationId,
1014
+ revision: integer(o.revision, 0),
1015
+ proposalId: decodeId(o.proposalId),
1016
+ digest: decodeHash(o.digest),
1017
+ head: nullable(o.head, decodeEntryId),
1018
+ context,
1019
+ expected: decodeChoiceVersion(o.expected),
1020
+ model: decodeModelSelector(o.model),
1021
+ };
1022
+ }
976
1023
  if (kind === "cadence-prepare" || kind === "cadence-approve") {
977
1024
  const keys = [
978
1025
  "kind",
@@ -1411,6 +1458,14 @@ export function decodeWorkbenchResult(v: unknown): WorkbenchResult {
1411
1458
  throw new ContractError("invalid");
1412
1459
  return { kind: k, runs, links };
1413
1460
  }
1461
+ if (k === "cadence-revalidated") {
1462
+ const o = closed(v, ["kind", "commandId", "state"]);
1463
+ return {
1464
+ kind: k,
1465
+ commandId: decodeId(o.commandId),
1466
+ state: decodeCadenceConversation(o.state),
1467
+ };
1468
+ }
1414
1469
  if (k === "cadence-grant") {
1415
1470
  const o = closed(v, [
1416
1471
  "kind",
@@ -159,6 +159,8 @@ export interface DeliveryObservation {
159
159
  cleanup: { status: "pending" | "removed" | "retained"; reason: string };
160
160
  }
161
161
  export interface WorkflowProposal {
162
+ /** Immutable prior binding of the same plan; never inherited execution consent. */
163
+ revalidatedFrom?: string;
162
164
  delivery?: DeliveryBinding;
163
165
  id: string;
164
166
  epoch: string;
@@ -1113,9 +1115,13 @@ export function decodeWorkflowProposal(v: unknown): WorkflowProposal {
1113
1115
  "cwd",
1114
1116
  ...(Object.hasOwn(v ?? {}, "checkoutRoot") ? ["checkoutRoot"] : []),
1115
1117
  ...(Object.hasOwn(v ?? {}, "delivery") ? ["delivery"] : []),
1118
+ ...(Object.hasOwn(v ?? {}, "revalidatedFrom") ? ["revalidatedFrom"] : []),
1116
1119
  ...(modern ? ["display"] : []),
1117
1120
  ]);
1118
1121
  return {
1122
+ ...(o.revalidatedFrom === undefined
1123
+ ? {}
1124
+ : { revalidatedFrom: decodeId(o.revalidatedFrom) }),
1119
1125
  ...(o.delivery === undefined
1120
1126
  ? {}
1121
1127
  : { delivery: decodeDeliveryBinding(o.delivery) }),
@@ -5880,9 +5880,11 @@ function decodeWorkflowProposal(v) {
5880
5880
  "cwd",
5881
5881
  ...Object.hasOwn(v ?? {}, "checkoutRoot") ? ["checkoutRoot"] : [],
5882
5882
  ...Object.hasOwn(v ?? {}, "delivery") ? ["delivery"] : [],
5883
+ ...Object.hasOwn(v ?? {}, "revalidatedFrom") ? ["revalidatedFrom"] : [],
5883
5884
  ...modern ? ["display"] : []
5884
5885
  ]);
5885
5886
  return {
5887
+ ...o.revalidatedFrom === undefined ? {} : { revalidatedFrom: decodeId(o.revalidatedFrom) },
5886
5888
  ...o.delivery === undefined ? {} : { delivery: decodeDeliveryBinding(o.delivery) },
5887
5889
  id: decodeId(o.id),
5888
5890
  epoch: decodeId(o.epoch),
@@ -6593,6 +6595,36 @@ function decodeWorkbenchCommand(v) {
6593
6595
  intent: oneOf(o2.intent, ["message", "enter", "exit"])
6594
6596
  };
6595
6597
  }
6598
+ if (kind === "cadence-revalidate") {
6599
+ const o2 = closed(v, [
6600
+ "kind",
6601
+ "commandId",
6602
+ "conversationId",
6603
+ "revision",
6604
+ "proposalId",
6605
+ "digest",
6606
+ "head",
6607
+ "context",
6608
+ "expected",
6609
+ "model"
6610
+ ]);
6611
+ const conversationId = decodeSessionId(o2.conversationId);
6612
+ const context = decodeConversationContext(o2.context);
6613
+ if (context.id !== conversationId)
6614
+ throw new ContractError("invalid");
6615
+ return {
6616
+ kind,
6617
+ commandId: decodeId(o2.commandId),
6618
+ conversationId,
6619
+ revision: integer(o2.revision, 0),
6620
+ proposalId: decodeId(o2.proposalId),
6621
+ digest: decodeHash(o2.digest),
6622
+ head: nullable(o2.head, decodeEntryId),
6623
+ context,
6624
+ expected: decodeChoiceVersion(o2.expected),
6625
+ model: decodeModelSelector(o2.model)
6626
+ };
6627
+ }
6596
6628
  if (kind === "cadence-prepare" || kind === "cadence-approve") {
6597
6629
  const keys2 = [
6598
6630
  "kind",
@@ -6986,6 +7018,14 @@ function decodeWorkbenchResult(v) {
6986
7018
  throw new ContractError("invalid");
6987
7019
  return { kind: k, runs, links };
6988
7020
  }
7021
+ if (k === "cadence-revalidated") {
7022
+ const o2 = closed(v, ["kind", "commandId", "state"]);
7023
+ return {
7024
+ kind: k,
7025
+ commandId: decodeId(o2.commandId),
7026
+ state: decodeCadenceConversation(o2.state)
7027
+ };
7028
+ }
6989
7029
  if (k === "cadence-grant") {
6990
7030
  const o2 = closed(v, [
6991
7031
  "kind",
@@ -16931,7 +16971,7 @@ async function createGateway(value, hostUrl, source) {
16931
16971
  const input = decodeGatewayInput(value), store = new GatewayStore(input.serverConfig, input.stateHome);
16932
16972
  const web = loadWebAssets(source?.webDirectory);
16933
16973
  const build2 = {
16934
- contractHash: "63f28a34411aedbf5d88f62ce81cfb0eca9e8ed38396e731a2a01253d1287f48",
16974
+ contractHash: "6aa819700494584b707a8e1b44428c532cd7ac7b1c8a28126e401b43f527543b",
16935
16975
  assets: {
16936
16976
  sourceHash: web.manifest.sourceHash,
16937
16977
  contractHash: web.manifest.contractHash,
@@ -17163,7 +17203,7 @@ Content-Length: 0\r
17163
17203
  store.saveProject(project);
17164
17204
  return project;
17165
17205
  }
17166
- async function prepareSend(projectId, id, epoch, current, location) {
17206
+ async function prepareExecution(purpose, projectId, id, epoch, current, location) {
17167
17207
  assert();
17168
17208
  if (epoch !== auth.epoch)
17169
17209
  throw new ContractError("stale");
@@ -17179,7 +17219,7 @@ Content-Length: 0\r
17179
17219
  if (observed.store.root !== selected2.path)
17180
17220
  throw new ContractError("stale");
17181
17221
  const identity = canonicalJson({
17182
- kind: "prepare-send",
17222
+ kind: purpose === "send" ? "prepare-send" : "prepare-plan",
17183
17223
  projectId,
17184
17224
  epoch,
17185
17225
  ...location ? { location } : {}
@@ -17699,7 +17739,8 @@ Content-Length: 0\r
17699
17739
  reply(res, 200, { kind: "project", project: select(path, epoch) });
17700
17740
  return;
17701
17741
  }
17702
- if (raw === "/workbench/v1/prepare-send" && req.method === "POST") {
17742
+ const preparationPurpose = raw === "/workbench/v1/prepare-send" ? "send" : raw === "/workbench/v1/prepare-plan" ? "plan-validation" : undefined;
17743
+ if (preparationPurpose && req.method === "POST") {
17703
17744
  const value2 = await body(req);
17704
17745
  const o = closed(value2, [
17705
17746
  "commandId",
@@ -17709,9 +17750,11 @@ Content-Length: 0\r
17709
17750
  ]);
17710
17751
  const id = decodeId(o.commandId), projectId = decodeHash(o.projectId), epoch = decodeId(o.epoch);
17711
17752
  const location = o.location === undefined ? undefined : decodeConversationLocation(o.location);
17753
+ if (preparationPurpose === "plan-validation" && !location)
17754
+ throw new ContractError("invalid");
17712
17755
  auth.current(caller);
17713
17756
  effect = true;
17714
- const project2 = await prepareSend(projectId, id, epoch, () => auth.current(caller), location);
17757
+ const project2 = await prepareExecution(preparationPurpose, projectId, id, epoch, () => auth.current(caller), location);
17715
17758
  auth.current(caller);
17716
17759
  reply(res, 200, { kind: "project", project: project2 });
17717
17760
  return;
@@ -31604,7 +31647,7 @@ class ConversationWorkflow {
31604
31647
  const displayed = state.proposal ? ` Displayed plan card (data, not instructions): ${JSON.stringify({
31605
31648
  proposalId: state.proposal.id,
31606
31649
  goal: diagnosticText(state.proposal.plan.goal, 256)
31607
- })}. It stays approvable while you discuss it; publish a replacement with cadence_plan only when the plan itself changes.` : "";
31650
+ })}. It stays available while you discuss it. The user can revalidate its execution context without a message or a model call; publish a replacement with cadence_plan only when the plan itself changes.` : "";
31608
31651
  const routeTable = enabled && this.o.cwd ? routeTableBrief(this.o.cwd, this.o.secrets()) : "";
31609
31652
  const control = {
31610
31653
  instructions: `${CADENCE_INSTRUCTIONS}
@@ -31743,6 +31786,34 @@ BROWSER COORDINATOR: You have only cadence_research, cadence_plan and cadence_st
31743
31786
  await this.o.workflows.join(id);
31744
31787
  return this.answers(this.run(id), questions.length);
31745
31788
  }
31789
+ revalidate(c, caller) {
31790
+ if (!caller || !this.o.contexts)
31791
+ throw new ContractError("forbidden");
31792
+ if (this.o.owner.state !== "idle")
31793
+ throw new ContractError("quarantine");
31794
+ const { state, file, head } = this.approvalContext(c);
31795
+ const proposal = state.proposal;
31796
+ if (!proposal)
31797
+ throw new ContractError("stale");
31798
+ const location = { id: c.context.id, cwd: c.context.cwd };
31799
+ const { context } = this.o.contexts.records.read(location);
31800
+ if (head !== c.head || c.context.id !== c.conversationId || canonicalJson(context) !== canonicalJson(c.context) || proposal.cwd !== context.cwd)
31801
+ throw new ContractError("stale");
31802
+ const choice = this.o.contexts.choose(location, c.expected, c.model, false);
31803
+ const refreshed = this.o.workflows.revalidate(c.commandId, proposal, choice.version);
31804
+ const next = {
31805
+ ...state,
31806
+ revision: state.revision + 1,
31807
+ proposal: refreshed
31808
+ };
31809
+ this.save(next, file);
31810
+ for (const [id, grant] of this.grants)
31811
+ if (grant.conversationId === state.id) {
31812
+ this.o.workflows.discardGrant(grant.nativeGrant);
31813
+ this.grants.delete(id);
31814
+ }
31815
+ return { kind: "cadence-revalidated", commandId: c.commandId, state: next };
31816
+ }
31746
31817
  approval(c, caller) {
31747
31818
  if (!caller)
31748
31819
  throw new ContractError("forbidden");
@@ -31786,12 +31857,16 @@ BROWSER COORDINATOR: You have only cadence_research, cadence_plan and cadence_st
31786
31857
  commandId: c.commandId
31787
31858
  };
31788
31859
  }
31789
- decide(c, caller, evidence, recording) {
31860
+ approvalContext(c) {
31790
31861
  const { state, file } = this.records.usable(c.conversationId);
31791
31862
  const latest = this.o.conversations.records.latestRun(c.conversationId);
31792
31863
  if (!state.enabled || c.revision !== state.revision || !state.proposal || state.proposal.id !== c.proposalId || state.proposal.digest !== c.digest || !latest || latest.commandId !== state.head || !latest.settled || this.active.has(c.conversationId))
31793
31864
  throw new ContractError("stale");
31794
31865
  const head = this.o.conversations.records.approvalHead(c.conversationId, latest.commandId);
31866
+ return { state, file, head };
31867
+ }
31868
+ decide(c, caller, evidence, recording) {
31869
+ const { state, file, head } = this.approvalContext(c);
31795
31870
  const epoch = this.o.owner.lease.registration.epoch;
31796
31871
  if (c.kind === "cadence-prepare") {
31797
31872
  for (const [id, g2] of this.grants)
@@ -31831,23 +31906,25 @@ BROWSER COORDINATOR: You have only cadence_research, cadence_plan and cadence_st
31831
31906
  this.grants.delete(c.grant);
31832
31907
  if (!grant || grant.caller !== canonicalJson(caller) || grant.expiresAt < Date.now() || grant.revision !== c.revision || grant.conversationId !== c.conversationId || grant.proposalId !== c.proposalId || grant.digest !== c.digest || grant.head !== head)
31833
31908
  throw new ContractError("expired-grant");
31834
- recording();
31835
- this.grants.delete(c.grant);
31836
- try {
31837
- this.o.coordination.files.create(evidence, canonicalJson({
31838
- commandId: c.commandId,
31839
- conversationId: state.id,
31840
- revision: c.revision,
31841
- proposalId: c.proposalId,
31842
- digest: c.digest,
31843
- caller,
31844
- epoch,
31845
- at: Date.now()
31846
- }, EVIDENCE_BYTES), EVIDENCE_BYTES);
31847
- } catch (e) {
31848
- this.o.owner.quarantine();
31849
- throw e;
31850
- }
31909
+ const beforeAdmission = () => {
31910
+ recording();
31911
+ this.grants.delete(c.grant);
31912
+ try {
31913
+ this.o.coordination.files.create(evidence, canonicalJson({
31914
+ commandId: c.commandId,
31915
+ conversationId: state.id,
31916
+ revision: c.revision,
31917
+ proposalId: c.proposalId,
31918
+ digest: c.digest,
31919
+ caller,
31920
+ epoch,
31921
+ at: Date.now()
31922
+ }, EVIDENCE_BYTES), EVIDENCE_BYTES);
31923
+ } catch (e) {
31924
+ this.o.owner.quarantine();
31925
+ throw e;
31926
+ }
31927
+ };
31851
31928
  let result;
31852
31929
  try {
31853
31930
  result = this.o.workflows.command(c.commandId, epoch, {
@@ -31855,7 +31932,7 @@ BROWSER COORDINATOR: You have only cadence_research, cadence_plan and cadence_st
31855
31932
  proposalId: c.proposalId,
31856
31933
  digest: c.digest,
31857
31934
  grant: grant.nativeGrant
31858
- });
31935
+ }, { beforeAdmission });
31859
31936
  } catch (error) {
31860
31937
  if (this.o.owner.state !== "idle" || this.exists(c.commandId))
31861
31938
  this.attach(state.id, c.commandId, true);
@@ -34183,8 +34260,8 @@ function workflowResultDetail(value, secrets) {
34183
34260
  var runtimeSummary = (runtime) => `${describeWorkerRuntime(runtime)}
34184
34261
  ${RUN_ENVIRONMENT_POLICY}`;
34185
34262
  var OWNER_RUNTIME = Object.freeze({
34186
- version: "2.1.6",
34187
- build: "466def18bdfec1faaf999049b38e5cb08ae6861f57b1847aea4144d1d2180551",
34263
+ version: "2.1.7",
34264
+ build: "71f1c6144e536050f63d0cbc74944e0cd3acbbe4dc012ad8c99f8ca4a600a5bc",
34188
34265
  entry: fileURLToPath7(import.meta.url),
34189
34266
  pid: process.pid,
34190
34267
  node: process.versions.node,
@@ -34468,6 +34545,62 @@ class Workflows {
34468
34545
  throw new ContractError("unavailable");
34469
34546
  return decodeWorkflowProposal(parseWireJson(file.bytes.toString("utf8"), RECORD_BYTES3));
34470
34547
  }
34548
+ revalidate(commandId, previous, model2) {
34549
+ this.current();
34550
+ const kept = this.proposal(previous.id);
34551
+ if (canonicalJson(kept) !== canonicalJson(previous))
34552
+ throw new ContractError("stale");
34553
+ if (previous.digest !== hash(canonicalJson(previous.delivery ? { plan: previous.plan, delivery: previous.delivery } : previous.plan)) || previous.cwd !== this.contexts.capture(model2).cwd || previous.checkoutRoot !== undefined && previous.checkoutRoot !== this.cwd)
34554
+ throw new ContractError("stale");
34555
+ if (sanitizeData(previous.plan, this.o.secrets()) !== canonicalJson(previous.plan))
34556
+ throw new ContractError("forbidden");
34557
+ return this.publishProposal(commandId, previous.plan, model2, () => {}, previous.id);
34558
+ }
34559
+ publishProposal(commandId, input, model2, effect, revalidatedFrom) {
34560
+ this.floor();
34561
+ const secrets = this.o.secrets();
34562
+ const plan = decodeWorkflowPlan(JSON.parse(sanitizeData(input, secrets)), {
34563
+ strict: true
34564
+ });
34565
+ const selected2 = this.model(model2);
34566
+ const cwd = this.contexts.capture(model2).cwd;
34567
+ const runtime = unattendedRuntime(this.o.models.workerSettings(cwd, selected2));
34568
+ const { source, digest: digest2, delivery } = this.observation(plan, runtime);
34569
+ const p = {
34570
+ ...revalidatedFrom ? { revalidatedFrom } : {},
34571
+ ...delivery ? { delivery } : {},
34572
+ id: commandId,
34573
+ epoch: this.o.owner.lease.registration.epoch,
34574
+ model: model2,
34575
+ plan,
34576
+ cwd,
34577
+ checkoutRoot: this.cwd,
34578
+ observation: digest2,
34579
+ display: {
34580
+ runtime: runtimeSummary(runtime),
34581
+ model: `${selected2.provider}/${selected2.model} · ${selected2.thinking}`,
34582
+ branch: source.branch,
34583
+ baseCommit: source.head
34584
+ },
34585
+ digest: hash(canonicalJson(delivery ? { plan, delivery } : plan))
34586
+ };
34587
+ if (sanitizeData(p, secrets) !== canonicalJson(p))
34588
+ throw new ContractError("forbidden");
34589
+ const target2 = join43(this.root, "proposals", `${decodeId(commandId)}.json`);
34590
+ const previous = this.files.read(target2, RECORD_BYTES3);
34591
+ if (previous) {
34592
+ if (previous.bytes.toString("utf8") !== canonicalJson(p))
34593
+ throw new ContractError("conflict");
34594
+ } else {
34595
+ effect();
34596
+ this.write(target2, p);
34597
+ }
34598
+ return p;
34599
+ }
34600
+ discardGrant(grant) {
34601
+ this.o.owner.lease.assert();
34602
+ this.grants.delete(grant);
34603
+ }
34471
34604
  assertProposal(p, digest2) {
34472
34605
  this.current();
34473
34606
  try {
@@ -34669,12 +34802,13 @@ class Workflows {
34669
34802
  if (r.action === "cancel")
34670
34803
  return this.cancel(commandId, epoch, r.runId);
34671
34804
  if (!options.definite)
34672
- return this.admit(commandId, epoch, r, () => {});
34805
+ return this.admit(commandId, epoch, r, options.beforeAdmission ?? (() => {}));
34673
34806
  let effects = true;
34674
34807
  try {
34675
34808
  effects = this.o.owner.state !== "idle" || this.attempted(commandId, r.action);
34676
34809
  return this.admit(commandId, epoch, r, () => {
34677
34810
  effects = true;
34811
+ options.beforeAdmission?.();
34678
34812
  });
34679
34813
  } catch (error) {
34680
34814
  if (!effects && error instanceof ContractError && !(error instanceof UnacceptedConversationCommand) && this.o.owner.state === "idle")
@@ -34698,44 +34832,11 @@ class Workflows {
34698
34832
  throw new ContractError("stale");
34699
34833
  const secrets = this.o.secrets();
34700
34834
  if (r.action === "propose") {
34701
- this.model(r.model);
34702
- this.floor();
34703
- const plan = decodeWorkflowPlan(JSON.parse(sanitizeData(r.plan, secrets)), { strict: true });
34704
- const selected2 = this.model(r.model);
34705
- const runtime2 = unattendedRuntime(this.o.models.workerSettings(this.contexts.capture(r.model).cwd, selected2));
34706
- const { source, digest: digest2, delivery: delivery2 } = this.observation(plan, runtime2);
34707
- const p = {
34708
- ...delivery2 ? { delivery: delivery2 } : {},
34709
- id: commandId,
34710
- epoch,
34711
- model: r.model,
34712
- plan,
34713
- cwd: this.contexts.capture(r.model).cwd,
34714
- checkoutRoot: this.cwd,
34715
- observation: digest2,
34716
- display: {
34717
- runtime: runtimeSummary(runtime2),
34718
- model: `${selected2.provider}/${selected2.model} · ${selected2.thinking}`,
34719
- branch: source.branch,
34720
- baseCommit: source.head
34721
- },
34722
- digest: hash(canonicalJson(delivery2 ? { plan, delivery: delivery2 } : plan))
34723
- };
34724
- if (sanitizeData(p, secrets) !== canonicalJson(p))
34725
- throw new ContractError("forbidden");
34726
- const target3 = join43(this.root, "proposals", `${commandId}.json`);
34727
- const previous = this.files.read(target3, RECORD_BYTES3);
34728
- if (previous) {
34729
- if (previous.bytes.toString("utf8") !== canonicalJson(p))
34730
- throw new ContractError("conflict");
34731
- } else {
34732
- effect();
34733
- this.write(target3, p);
34734
- }
34835
+ const proposal2 = this.publishProposal(commandId, r.plan, r.model, effect);
34735
34836
  return {
34736
34837
  kind: "workflow",
34737
34838
  commandId,
34738
- response: { type: "proposal", proposal: p }
34839
+ response: { type: "proposal", proposal: proposal2 }
34739
34840
  };
34740
34841
  }
34741
34842
  if (r.action === "prepare") {
@@ -34800,8 +34901,6 @@ class Workflows {
34800
34901
  if (sanitizeData(delivery, secrets) !== canonicalJson(delivery))
34801
34902
  throw new ContractError("forbidden");
34802
34903
  }
34803
- effect();
34804
- this.grants.delete(request3.grant);
34805
34904
  if (proposal.plan.delivery === "local-merge")
34806
34905
  target2 = { head: source.head, branch: source.branch };
34807
34906
  else
@@ -34857,6 +34956,8 @@ class Workflows {
34857
34956
  notes: []
34858
34957
  };
34859
34958
  effect();
34959
+ if (request3.action === "execute")
34960
+ this.grants.delete(request3.grant);
34860
34961
  this.active.set(commandId, live2);
34861
34962
  this.o.owner.trackConversation(live2.original, () => abort.abort({ source: "service", reason: "stop", target: commandId }));
34862
34963
  try {
@@ -36848,6 +36949,8 @@ class Workbench {
36848
36949
  }
36849
36950
  if (request3.kind === "send" || request3.kind === "cadence-send" || request3.kind === "cadence-exit")
36850
36951
  return this.send(request3, caller);
36952
+ if (request3.kind === "cadence-revalidate")
36953
+ return this.cadence.revalidate(request3, caller);
36851
36954
  if (request3.kind === "cadence-prepare" || request3.kind === "cadence-approve")
36852
36955
  return this.cadence.approval(request3, caller);
36853
36956
  if (request3.kind === "workflow-cancel") {
@@ -37028,7 +37131,7 @@ var processLifetime = {
37028
37131
  }
37029
37132
  };
37030
37133
  async function createServiceHost(value, sourceBuild, lifetime) {
37031
- const embedded = "63f28a34411aedbf5d88f62ce81cfb0eca9e8ed38396e731a2a01253d1287f48";
37134
+ const embedded = "6aa819700494584b707a8e1b44428c532cd7ac7b1c8a28126e401b43f527543b";
37032
37135
  if (embedded && sourceBuild)
37033
37136
  throw new ContractError("unsupported-context");
37034
37137
  const contractHash = decodeHash(embedded ?? sourceBuild?.contractHash);