@lmzhen/dsh-evolution-approval 0.3.67 → 0.3.69

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/lib/index.js CHANGED
@@ -6,8 +6,13 @@ import z from "@deepseek-ai/schemastery";
6
6
  * Stage/pending write approval for self-evolution mutations.
7
7
  *
8
8
  * DSH's native approval seam is one-shot only. This service adds the
9
- * Hermes-style staged queue: background review/curator writes are stored in
10
- * `ctx.evolutionState`, and a human approves or rejects them later. A runner
9
+ * Hermes-style staged queue: a write whose ORIGIN is the background review —
10
+ * or a foreground write while `stageForeground` is on is recorded in
11
+ * `ctx.evolutionState`, and a human approves or rejects it later. The CURATOR
12
+ * does NOT route through this queue: it owns its own gate set and writes
13
+ * directly (batch/consolidate), so "curator writes are staged" is not a
14
+ * property of this service (V27 G6.2; see evolution-curator's gate set for what
15
+ * actually constrains an autonomous curator write). A runner
11
16
  * registry replays the exact mutation without passing through the gate a
12
17
  * second time. Resolved records are kept as audit history up to
13
18
  * PENDING_RESOLVED_CAP (the most recent N; the state provider archives the
@@ -228,7 +233,7 @@ var EvolutionApproval = class extends Service {
228
233
  await this.state().releasePendingClaim(id, claimId);
229
234
  return {
230
235
  ok: false,
231
- message: result.message
236
+ message: /changed since this plan|no entry matching|not found|no longer exists/i.test(result.message) ? `${result.message} — a sibling write from the same plan may have already changed this target, so repeated approves will keep failing. Reject this record unless the target changed again.` : result.message
232
237
  };
233
238
  }
234
239
  } catch (error) {
@@ -239,7 +244,15 @@ var EvolutionApproval = class extends Service {
239
244
  message: "Replay runner failed; the pending write remains pending."
240
245
  };
241
246
  }
242
- if (!(await this.state().tryResolvePending(id, "approved", claimId)).applied) {
247
+ const resolution = await this.state().tryResolvePending(id, "approved", claimId).catch((error) => {
248
+ this.ctx.logger.warn(error);
249
+ return `failed: ${error instanceof Error ? error.message : String(error)}`;
250
+ });
251
+ if (typeof resolution === "string") return {
252
+ ok: false,
253
+ message: `Approved write "${id}" was replayed, but resolving the record failed (${resolution.slice(8)}) — the effect has LANDED while the audit row stays "executing". Verify the write manually; approve will not re-run it.`
254
+ };
255
+ if (!resolution.applied) {
243
256
  if ((await this.state().listPending("rejected")).find((item) => item.id === id)) return {
244
257
  ok: false,
245
258
  message: `Approved write "${id}" was replayed, but the record was resolved to "rejected" concurrently — the effect has landed while the audit reads rejected. Verify the write and do NOT replay it.`
@@ -2,8 +2,13 @@
2
2
  * Stage/pending write approval for self-evolution mutations.
3
3
  *
4
4
  * DSH's native approval seam is one-shot only. This service adds the
5
- * Hermes-style staged queue: background review/curator writes are stored in
6
- * `ctx.evolutionState`, and a human approves or rejects them later. A runner
5
+ * Hermes-style staged queue: a write whose ORIGIN is the background review —
6
+ * or a foreground write while `stageForeground` is on is recorded in
7
+ * `ctx.evolutionState`, and a human approves or rejects it later. The CURATOR
8
+ * does NOT route through this queue: it owns its own gate set and writes
9
+ * directly (batch/consolidate), so "curator writes are staged" is not a
10
+ * property of this service (V27 G6.2; see evolution-curator's gate set for what
11
+ * actually constrains an autonomous curator write). A runner
7
12
  * registry replays the exact mutation without passing through the gate a
8
13
  * second time. Resolved records are kept as audit history up to
9
14
  * PENDING_RESOLVED_CAP (the most recent N; the state provider archives the
@@ -31,6 +36,13 @@ export interface ApprovalRequest {
31
36
  * so the write is allowed instead of staging an unanswerable pending record
32
37
  * (claw alignment: "skip approval for non-interactive contexts"). Absent
33
38
  * (no session / no approval service) keeps the previous behavior.
39
+ *
40
+ * V27 G6.2: this field is a FALLBACK, not the authority. With the platform
41
+ * `approval` service mounted, `request()` derives the policy from it
42
+ * (`overrideOf` → deployment `config.policy` → 'ask') and ignores this value
43
+ * entirely; it is read only in assemblies WITHOUT that service. A caller
44
+ * holding the session object must pass it as `session`: a bare `sessionId`
45
+ * cannot be probed (the platform reads `session.events` off the object).
34
46
  */
35
47
  sessionPolicy?: 'ask' | 'never';
36
48
  /** 0.3.17 (E-25): the requesting session id, kept on the record for
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-approval",
3
3
  "description": "Stage/pending approval service for Hermes-style self-evolution writes (community build)",
4
- "version": "0.3.67",
4
+ "version": "0.3.69",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -35,15 +35,15 @@
35
35
  "peerDependencies": {
36
36
  "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
37
37
  "@deepseek-ai/cordis": "^4.0.1",
38
- "@lmzhen/dsh-evolution-state-storage": "^0.3.67",
39
- "@lmzhen/dsh-evolution-state": "^0.3.67"
38
+ "@lmzhen/dsh-evolution-state-storage": "^0.3.69",
39
+ "@lmzhen/dsh-evolution-state": "^0.3.69"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
43
- "@lmzhen/dsh-evolution-state-storage": "^0.3.67",
44
- "@lmzhen/dsh-evolution-state": "^0.3.67",
45
- "@lmzhen/dsh-evolution-io": "^0.3.67",
46
- "@lmzhen/dsh-evolution-io-node": "^0.3.67",
47
- "@lmzhen/dsh-evolution-state-json": "^0.3.67"
43
+ "@lmzhen/dsh-evolution-state-storage": "^0.3.69",
44
+ "@lmzhen/dsh-evolution-state": "^0.3.69",
45
+ "@lmzhen/dsh-evolution-io": "^0.3.69",
46
+ "@lmzhen/dsh-evolution-io-node": "^0.3.69",
47
+ "@lmzhen/dsh-evolution-state-json": "^0.3.69"
48
48
  }
49
49
  }