@lmzhen/dsh-evolution-review 0.26.15 → 0.26.26

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 (2) hide show
  1. package/lib/index.js +30 -8
  2. package/package.json +11 -11
package/lib/index.js CHANGED
@@ -1,8 +1,8 @@
1
+ import { COMPLETION_SKILL_REVIEW_PROMPT, DEFAULT_MAX_OPS_PER_PLAN, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_MEMORY_REVIEW_MODEL, DEFAULT_REVIEW_CONTEXT_MESSAGES, DEFAULT_REVIEW_MEMORY_INTERVAL, DEFAULT_REVIEW_MESSAGE_CHARS, DEFAULT_REVIEW_SKILL_INTERVAL, DEFAULT_REVIEW_TIMEOUT_MS, DEFAULT_SKILL_CONTENT_CHARS, DEFAULT_SKILL_LIMITS, DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, DEFAULT_SKILL_REVIEW_MODEL, DEFAULT_SKILL_REVIEW_TRIGGER, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, DEFAULT_USER_CHAR_LIMIT, MAX_TIMER_DELAY_MS, PROMPT_BUNDLE, advanceReview, assertSkillsRootAliasRetired, authorityFrom, clampOnce, clearReviewChannel, contentHash, evolutionIoAdapter, filterUnreadSkillOps, filterUnreadSkillOps as filterUnreadSkillOps$1, foldUntrustedLines, isPresent, isUnknown, liveBool, markReviewChannel, newSkillLibrary, paramRowId, payloadText, pickWithPolicy, policyStageLimits, readDispatchSignal, redactSecrets, resolveOrigins, resolveRootConfig, reviewPrompt, sessionAudited, sessionEvidenceIndex, sessionReadNames, sessionTurnSignals, sweepReviewChannelSessions, unwrapLive, userSetKeys, verifyPromptBundle } from "@lmzhen/dsh-evolution-core";
1
2
  import { createHash, randomUUID } from "node:crypto";
2
3
  import z from "@deepseek-ai/schemastery";
3
4
  import { createUserMessage } from "@deepseek-ai/dsh-llm";
4
5
  import { SessionId } from "@deepseek-ai/dsh-session";
5
- import { COMPLETION_SKILL_REVIEW_PROMPT, DEFAULT_MAX_OPS_PER_PLAN, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_MEMORY_REVIEW_MODEL, DEFAULT_REVIEW_CONTEXT_MESSAGES, DEFAULT_REVIEW_MEMORY_INTERVAL, DEFAULT_REVIEW_MESSAGE_CHARS, DEFAULT_REVIEW_SKILL_INTERVAL, DEFAULT_REVIEW_TIMEOUT_MS, DEFAULT_SKILL_CONTENT_CHARS, DEFAULT_SKILL_LIMITS, DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, DEFAULT_SKILL_REVIEW_MODEL, DEFAULT_SKILL_REVIEW_TRIGGER, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, DEFAULT_USER_CHAR_LIMIT, MAX_TIMER_DELAY_MS, PROMPT_BUNDLE, advanceReview, assertSkillsRootAliasRetired, clampOnce, clearReviewChannel, contentHash, evolutionIoAdapter, filterUnreadSkillOps, filterUnreadSkillOps as filterUnreadSkillOps$1, foldUntrustedLines, liveBool, markReviewChannel, newSkillLibrary, paramRowId, payloadText, pickWithPolicy, policyStageLimits, readDispatchSignal, redactSecrets, resolveOrigins, resolveRootConfig, reviewPrompt, sessionAudited, sessionEvidenceIndex, sessionReadNames, sessionTurnSignals, sweepReviewChannelSessions, unwrapLive, userSetKeys, verifyPromptBundle } from "@lmzhen/dsh-evolution-core";
6
6
  import { validateEvolutionPlan } from "@lmzhen/dsh-evolution-plan-validator";
7
7
  /**
8
8
  * Whether a message is a notice this plugin delivered, judged only by durable source fields.
@@ -731,6 +731,7 @@ function apply(ctx, rawConfig = {}) {
731
731
  const io = ctx.get("evolutionIo");
732
732
  if (!io) return hashes;
733
733
  const library = newSkillLibrary({
734
+ authority: authorityFrom({ origin: "foreground" }),
734
735
  config: rootConfig,
735
736
  io: evolutionIoAdapter(() => io.provider())
736
737
  });
@@ -931,6 +932,7 @@ function apply(ctx, rawConfig = {}) {
931
932
  const io = ctx.get("evolutionIo");
932
933
  if (!io) return null;
933
934
  return newSkillLibrary({
935
+ authority: authorityFrom({ origin: "foreground" }),
934
936
  config: rootConfig,
935
937
  io: evolutionIoAdapter(() => io.provider())
936
938
  });
@@ -941,7 +943,7 @@ function apply(ctx, rawConfig = {}) {
941
943
  let ok = true;
942
944
  try {
943
945
  for (const op of plan.memoryOps ?? []) {
944
- if (signal?.aborted === true) {
946
+ if (ctx.fiber.uid === null || signal?.aborted === true) {
945
947
  const reason = "the review was unloaded mid-plan";
946
948
  ctx.logger.warn(`dsh-evolution-review: executePlan stopped at an op boundary after ${actions.length} op(s): ${reason}`);
947
949
  return {
@@ -972,7 +974,7 @@ function apply(ctx, rawConfig = {}) {
972
974
  }
973
975
  }
974
976
  for (const op of plan.skillOps ?? []) {
975
- if (signal?.aborted === true) {
977
+ if (ctx.fiber.uid === null || signal?.aborted === true) {
976
978
  const reason = "the review was unloaded mid-plan";
977
979
  ctx.logger.warn(`dsh-evolution-review: executePlan stopped at an op boundary after ${actions.length} op(s): ${reason}`);
978
980
  return {
@@ -992,17 +994,35 @@ function apply(ctx, rawConfig = {}) {
992
994
  evidence: op.evidence
993
995
  };
994
996
  let stagedBytes;
995
- if ((args.action === "update" || args.action === "edit") && hashLibrary && typeof args.name === "string" && args.name !== "") stagedBytes = await hashLibrary.read(args.name).catch(() => void 0);
997
+ if ((args.action === "update" || args.action === "edit") && hashLibrary && typeof args.name === "string" && args.name !== "") {
998
+ const probe = await hashLibrary.readSkillProbe(args.name);
999
+ if (isUnknown(probe)) {
1000
+ ok = false;
1001
+ failedOps.push(`skill ${args.action} ${args.name}: target is unreadable (${probe.reason}); refusing to stage an unverifiable anchor`);
1002
+ continue;
1003
+ }
1004
+ stagedBytes = isPresent(probe) ? probe.value : null;
1005
+ }
996
1006
  if ((args.action === "write_file" || args.action === "remove_file") && hashLibrary && typeof args.name === "string" && args.name !== "" && typeof args.file_path === "string" && args.file_path !== "") {
997
- const stageFile = await hashLibrary.readSupportFile(args.name, args.file_path).catch(() => void 0);
998
- if (stageFile !== void 0) args.staged_from_sha256 = stageFile === null ? "absent" : contentHash(stageFile);
1007
+ const supportProbe = await hashLibrary.readSupportFileProbe(args.name, args.file_path);
1008
+ if (isUnknown(supportProbe)) {
1009
+ ok = false;
1010
+ failedOps.push(`file ${args.action} ${args.name}/${args.file_path}: target is unreadable (${supportProbe.reason}); refusing to stage an unverifiable anchor`);
1011
+ continue;
1012
+ }
1013
+ const stageFile = isPresent(supportProbe) ? supportProbe.value : null;
1014
+ args.staged_from_sha256 = stageFile === null ? "absent" : contentHash(stageFile);
999
1015
  }
1000
1016
  const opName = typeof args.name === "string" ? args.name : "";
1001
1017
  const hashChecked = (args.action === "update" || args.action === "edit" || args.action === "patch") && opName !== "" && preRunHashes?.has(opName) === true;
1002
1018
  const anchored = hashChecked && typeof stagedBytes === "string" ? stagedBytes : null;
1003
1019
  let gateVerifiedBytes = null;
1004
1020
  if (hashChecked) {
1005
- const live = anchored !== null ? anchored : hashLibrary ? await hashLibrary.read(opName).catch(() => null) : null;
1021
+ const live = anchored !== null ? anchored : await (async () => {
1022
+ if (hashLibrary === null) return null;
1023
+ const probed = await hashLibrary.readSkillProbe(opName);
1024
+ return isPresent(probed) ? probed.value : null;
1025
+ })();
1006
1026
  const preRun = preRunHashes.get(opName);
1007
1027
  if (live === null || preRun !== void 0 && contentHash(live) !== preRun) {
1008
1028
  ok = false;
@@ -1022,7 +1042,8 @@ function apply(ctx, rawConfig = {}) {
1022
1042
  actions.push(`Skill ${op.name} ${op.action ?? "patch"}`);
1023
1043
  onLanded?.(`Skill ${op.name} ${op.action ?? "patch"}`);
1024
1044
  if (hashChecked) {
1025
- const landed = await hashLibrary?.read(opName).catch(() => null) ?? null;
1045
+ const landedProbe = hashLibrary === null ? void 0 : await hashLibrary.readSkillProbe(opName);
1046
+ const landed = landedProbe !== void 0 && isPresent(landedProbe) ? landedProbe.value : null;
1026
1047
  if (landed !== null) preRunHashes.set(opName, contentHash(landed));
1027
1048
  }
1028
1049
  } else {
@@ -1101,6 +1122,7 @@ function apply(ctx, rawConfig = {}) {
1101
1122
  };
1102
1123
  const policySnapshot = policySnapshotOf(ctx.get("evolutionPolicy"));
1103
1124
  const library = newSkillLibrary({
1125
+ authority: authorityFrom({ origin: resolveOrigins(void 0, true).library }),
1104
1126
  config: rootConfig,
1105
1127
  io: evolutionIoAdapter(() => io.provider()),
1106
1128
  limits: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-review",
3
3
  "description": "Background review orchestration (community build)",
4
- "version": "0.26.15",
4
+ "version": "0.26.26",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -27,9 +27,9 @@
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
29
  "@deepseek-ai/schemastery": "^3.18.4",
30
- "@lmzhen/dsh-evolution-approval": "^0.26.15",
31
- "@lmzhen/dsh-evolution-core": "^0.26.15",
32
- "@lmzhen/dsh-evolution-plan-validator": "^0.26.15"
30
+ "@lmzhen/dsh-evolution-approval": "^0.26.26",
31
+ "@lmzhen/dsh-evolution-core": "^0.26.26",
32
+ "@lmzhen/dsh-evolution-plan-validator": "^0.26.26"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@deepseek-ai/cordis": "^4.0.1",
@@ -37,8 +37,8 @@
37
37
  "@deepseek-ai/dsh-llm": "^0.2.0-rc.1",
38
38
  "@deepseek-ai/dsh-session": "^0.2.0-rc.1",
39
39
  "@deepseek-ai/dsh-tools": "^0.2.0-rc.1",
40
- "@lmzhen/dsh-evolution-state": "^0.26.15",
41
- "@lmzhen/dsh-evolution-policy": "^0.26.15"
40
+ "@lmzhen/dsh-evolution-policy": "^0.26.26",
41
+ "@lmzhen/dsh-evolution-state": "^0.26.26"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@deepseek-ai/dsh-agent": "^0.2.0-rc.1",
@@ -48,10 +48,10 @@
48
48
  "@deepseek-ai/dsh-session-persistence": "^0.2.0-rc.1",
49
49
  "@deepseek-ai/dsh-session-persistence-jsonl": "^0.2.0-rc.1",
50
50
  "@deepseek-ai/dsh-tools": "^0.2.0-rc.1",
51
- "@lmzhen/dsh-evolution-approval": "^0.26.15",
52
- "@lmzhen/dsh-evolution-core": "^0.26.15",
53
- "@lmzhen/dsh-evolution-curator": "^0.26.15",
54
- "@lmzhen/dsh-evolution-plan-validator": "^0.26.15",
55
- "@lmzhen/dsh-evolution-state": "^0.26.15"
51
+ "@lmzhen/dsh-evolution-approval": "^0.26.26",
52
+ "@lmzhen/dsh-evolution-core": "^0.26.26",
53
+ "@lmzhen/dsh-evolution-curator": "^0.26.26",
54
+ "@lmzhen/dsh-evolution-plan-validator": "^0.26.26",
55
+ "@lmzhen/dsh-evolution-state": "^0.26.26"
56
56
  }
57
57
  }