@lmzhen/dsh-evolution-core 0.37.1 → 0.39.0

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 (54) hide show
  1. package/README.md +4 -2
  2. package/lib/composition/index.js +2 -2
  3. package/lib/{composition-DckDtQTR.js → composition-dy0gJWDd.js} +1 -1
  4. package/lib/{ensure-CLF9YeBD.js → ensure-B4fjEI0w.js} +3 -10
  5. package/lib/index.js +67 -1302
  6. package/lib/platform/index.js +4 -0
  7. package/lib/platform-Be-_wSVz.js +113 -0
  8. package/lib/presets-C8vuCuNA.js +27 -0
  9. package/lib/restrictor.js +7 -7
  10. package/lib/runtime/plugin.js +197 -0
  11. package/lib/session-projection-CXUNPkq9.js +1250 -0
  12. package/lib/subagent/index.js +1 -1
  13. package/lib/tools-DzcNFex2.js +20 -0
  14. package/lib/types/composition/ensure.js +3 -13
  15. package/lib/types/events.d.ts +1 -1
  16. package/lib/types/index.d.ts +1 -0
  17. package/lib/types/index.js +1 -0
  18. package/lib/types/opt-in.d.ts +1 -1
  19. package/lib/types/opt-in.js +1 -1
  20. package/lib/types/params.js +2 -2
  21. package/lib/types/platform/index.d.ts +21 -0
  22. package/lib/types/platform/index.js +12 -0
  23. package/lib/types/platform/llm.d.ts +46 -0
  24. package/lib/types/platform/llm.js +75 -0
  25. package/lib/types/platform/presets.d.ts +31 -0
  26. package/lib/types/platform/presets.js +31 -0
  27. package/lib/types/platform/projections.d.ts +30 -0
  28. package/lib/types/platform/projections.js +31 -0
  29. package/lib/types/platform/tools.d.ts +23 -0
  30. package/lib/types/platform/tools.js +21 -0
  31. package/lib/types/platform-line.generated.d.ts +6 -6
  32. package/lib/types/platform-line.generated.js +6 -6
  33. package/lib/types/platform-services.d.ts +1 -1
  34. package/lib/types/platform-services.js +4 -1
  35. package/lib/types/restrictor.js +7 -9
  36. package/lib/types/review-context.d.ts +20 -0
  37. package/lib/types/review-context.js +28 -0
  38. package/lib/types/runtime/llm.d.ts +34 -0
  39. package/lib/types/runtime/llm.js +71 -0
  40. package/lib/types/runtime/platform.d.ts +35 -0
  41. package/lib/types/runtime/platform.js +38 -0
  42. package/lib/types/runtime/plugin.d.ts +10 -0
  43. package/lib/types/runtime/plugin.js +11 -0
  44. package/lib/types/runtime/projections.d.ts +29 -0
  45. package/lib/types/runtime/projections.js +62 -0
  46. package/lib/types/scope.d.ts +1 -1
  47. package/lib/types/session-projection.d.ts +26 -53
  48. package/lib/types/session-projection.js +22 -58
  49. package/lib/types/skill-reads.js +3 -3
  50. package/lib/types/skill-store.js +3 -0
  51. package/lib/types/subagent/types.d.ts +1 -1
  52. package/lib/types/tool-dispatch.d.ts +2 -2
  53. package/lib/types/tool-dispatch.js +3 -3
  54. package/package.json +30 -16
package/lib/index.js CHANGED
@@ -1,6 +1,7 @@
1
- import { _ as scopedPackageName, c as MAINTAINER_PRESET_ID, d as RESTRICTED_TOOLS_ROW_ID, f as RESTRICTOR_MODULE, g as scopeOfNearestManifest, p as REVIEWER_PRESET_ID, s as EVOLUTION_PRESET_IDS, u as RESTRICTED_PRESET_DISPLAY } from "./ensure-CLF9YeBD.js";
1
+ import { A as countDispatches, B as supportFileReadFromPath, C as PTC_DISPATCH_EVENT, D as assertDispatchPayload, E as ToolDispatchPayloadError, F as isProgramToolName, G as KEEP_LINE_RE, H as CITATION_SUPPORT_DIRS, I as isSkillReadToolName, J as scanBodyHooks, K as isFileShapedPath, L as isSkillToolName, M as dispatchPathOf, N as dispatchStepOf, O as collectReadSkillNames, P as foldToolDispatches, R as readDispatchSignal, S as NATIVE_RESULT_EVENT, T as ToolDispatchNormalizer, U as DEFAULT_CITATION_REF_BUDGET, V as supportFileReadOf, W as HOOK_LINE_RE, _ as observeEvent, a as evolutionSignalsProjection, b as MODEL_SESSION_EVENT_TYPES, c as sessionLastEventTime, d as evidenceKindIndex, f as isBookkeepingFrame, g as initialTurnFold, h as foldTurnEvents, i as evolutionReadsProjection, j as dispatchKeyOf, k as collectReadSupportFiles, l as sessionReadNames, m as foldTurnEvent, n as evolutionEvidenceProjection, o as isProjectableSession, p as advanceReview, q as resolveCitations, r as evolutionProjectionHistoryProjection, s as sessionEvidenceIndex, t as evolutionActivityProjection, u as sessionTurnSignals, v as DEFAULT_SUPPORT_READ_TOOL_NAMES, w as PTC_DISPATCH_START_EVENT, x as NATIVE_CALL_EVENT, y as DISPATCH_EVENT_TYPES, z as skillReadNameOf } from "./session-projection-CXUNPkq9.js";
2
+ import { _ as scopedPackageName, c as MAINTAINER_PRESET_ID, d as RESTRICTED_TOOLS_ROW_ID, f as RESTRICTOR_MODULE, g as scopeOfNearestManifest, p as REVIEWER_PRESET_ID, s as EVOLUTION_PRESET_IDS, u as RESTRICTED_PRESET_DISPLAY } from "./ensure-B4fjEI0w.js";
2
3
  import { a as methodNotAllowed, c as asRecord, i as json, l as isRecord, n as MAX_REQUEST_BODY_BYTES, o as readJsonObject, r as hostSurface, s as registerHostRoutes, t as HOST_ROUTES } from "./http-routes-_anZVlPf.js";
3
- import { w as allowRowCollisions } from "./composition-DckDtQTR.js";
4
+ import { w as allowRowCollisions } from "./composition-dy0gJWDd.js";
4
5
  import { n as errorText, t as EVOLUTION_ERRORS } from "./errors-DUcEoTLR.js";
5
6
  import { createSubagentChannel, probeChannelState, subagentChannelState } from "./subagent/index.js";
6
7
  import { createHash, randomBytes, randomUUID } from "node:crypto";
@@ -10,205 +11,8 @@ import { cp, lstat, mkdir, open, readFile, readdir, realpath, rename, rm, stat }
10
11
  import { fileURLToPath } from "node:url";
11
12
  import { parse } from "yaml";
12
13
  import { homedir } from "node:os";
14
+ import { AsyncLocalStorage } from "node:async_hooks";
13
15
  import { scopeOf } from "@deepseek-ai/dsh-scope";
14
- import { z } from "zod";
15
- //#region lib/types/citations.js
16
- /**
17
- * Citation resolution for skill bodies and support files (design §5.2).
18
- *
19
- * WHY this exists beside `supportRefs` (skill-store.ts): that scanner answers
20
- * "does this text contain a path-shaped token", which is the right question
21
- * when a package is being ARCHIVED — every such path may dangle — and the wrong
22
- * one when a section is only being MOVED, where nothing leaves and the only
23
- * thing that changes is the directory a citation is read from. Measured false
24
- * positives of the token scan: a URL tail (`https://host/references/x.md`), a
25
- * category path the original Hermes documents as legitimate
26
- * (`skills/scripts/foo.py`), and a prose command line
27
- * (`npm run scripts/build.mjs`).
28
- *
29
- * CONTRACT: a token whose path STARTS WITH a support directory is a citation of
30
- * this skill and is resolved from the SKILL ROOT, in whichever file it is
31
- * written. A token that merely contains a support directory further along its
32
- * path belongs to something else: it is reported as `foreign` and never
33
- * resolved.
34
- *
35
- * PURE: existence is decided against the caller's file list, so identical
36
- * inputs always answer the same report.
37
- */
38
- /** Support directories that make a path a citation of the owning skill. */
39
- const CITATION_SUPPORT_DIRS = [
40
- "references",
41
- "templates",
42
- "scripts",
43
- "assets"
44
- ];
45
- /** Scan budget: bounded so a pathological body cannot stall a maintenance run. */
46
- const DEFAULT_CITATION_REF_BUDGET = 500;
47
- /** Words that introduce an executable command rather than a citation. */
48
- const PROSE_COMMAND_PREFIXES = [
49
- "npm",
50
- "pnpm",
51
- "yarn",
52
- "npx",
53
- "node",
54
- "python",
55
- "python3",
56
- "bash",
57
- "sh",
58
- "git",
59
- "gh",
60
- "run"
61
- ];
62
- const TOKEN_RE = /(?:references|templates|scripts|assets)\/[A-Za-z0-9._/-]+/g;
63
- const TOKEN_CHAR_RE = /[A-Za-z0-9._/-]/;
64
- const FENCE_RE = /^\s*(`{3,}|~{3,})/;
65
- const TRAILING_PUNCT_RE = /[.,;:]+$/;
66
- /** A citation's final segment must look like \u0060name.ext\u0060: a bare \u0060.\u0060 or a dotless
67
- * segment is a directory mention, not a file. */
68
- const FILE_SEGMENT_RE = /^[^.].*\.[^.]+$/;
69
- const FRAGMENT_RE = /^#([A-Za-z0-9._-]+)/;
70
- /** Whether the token starting at `start` is the argument of a shell command. */
71
- function isProseCommand(line, start) {
72
- const head = line.slice(0, start).trimEnd();
73
- if (head === "") return false;
74
- const word = head.split(/\s+/).pop() ?? "";
75
- return PROSE_COMMAND_PREFIXES.includes(word);
76
- }
77
- /** The token's final path segment (`references/a/b.md` -> `b.md`). */
78
- function lastSegmentOf(target) {
79
- return target.slice(target.lastIndexOf("/") + 1);
80
- }
81
- /** The token's parent directory within the skill (`references/a/b.md` -> `references/a`). */
82
- function parentDirOf(target) {
83
- const cut = target.lastIndexOf("/");
84
- return cut <= 0 ? "" : target.slice(0, cut);
85
- }
86
- /** Classify one token by its first path segment. */
87
- function classifyToken(token) {
88
- const head = token.split("/")[0] ?? "";
89
- return CITATION_SUPPORT_DIRS.includes(head) ? "citation" : "foreign";
90
- }
91
- /**
92
- * Resolve every path-shaped token in `content`.
93
- * @param input - content, the skill-root-relative path of its owner, the skill's
94
- * file list, and an optional scan budget.
95
- * @returns the refs plus the dangling and foreign subsets; `truncated` marks a
96
- * report that stopped at the budget.
97
- */
98
- function resolveCitations(input) {
99
- const budget = input.budget ?? 500;
100
- const files = new Set(input.files.map((path) => path.replace(/\\/g, "/")));
101
- const refs = [];
102
- const seen = /* @__PURE__ */ new Set();
103
- let truncated = false;
104
- let fence = null;
105
- const lines = input.content.split("\n");
106
- for (let index = 0; index < lines.length && !truncated; index += 1) {
107
- const rawLine = lines[index] ?? "";
108
- const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
109
- const fenceMark = FENCE_RE.exec(line);
110
- if (fenceMark) {
111
- const marker = fenceMark[1] ?? "";
112
- fence = fence === null ? marker.slice(0, 1) : null;
113
- continue;
114
- }
115
- for (const match of line.matchAll(TOKEN_RE)) {
116
- const matched = match[0];
117
- const matchedAt = match.index;
118
- let start = matchedAt;
119
- while (start > 0 && TOKEN_CHAR_RE.test(line[start - 1] ?? "")) start -= 1;
120
- const prefix = line.slice(0, start);
121
- const tail = line.slice(matchedAt + matched.length);
122
- const fragment = FRAGMENT_RE.exec(tail)?.[1];
123
- const token = matched.replace(TRAILING_PUNCT_RE, "");
124
- const scanned = line.slice(start, matchedAt + matched.length);
125
- const classified = fence !== null ? "fence" : prefix.endsWith(":") && line.slice(start, start + 2) === "//" ? "url" : isProseCommand(line, start) ? "prose" : classifyToken(scanned);
126
- const namesFile = !scanned.split("/").includes("..") && (FILE_SEGMENT_RE.test(lastSegmentOf(scanned)) || files.has(token));
127
- const kind = classified === "citation" && !namesFile ? "prose" : classified;
128
- const target = kind === "citation" ? token : null;
129
- const key = `${index}|${kind}|${target ?? token}`;
130
- if (seen.has(key)) continue;
131
- seen.add(key);
132
- refs.push({
133
- raw: token,
134
- line: index + 1,
135
- target,
136
- base: "root",
137
- kind,
138
- exists: target !== null && files.has(target),
139
- ...fragment === void 0 ? {} : { fragment }
140
- });
141
- if (refs.length >= budget) {
142
- truncated = true;
143
- break;
144
- }
145
- }
146
- }
147
- const citations = refs.filter((ref) => ref.kind === "citation");
148
- const undecidable = (ref) => {
149
- const target = ref.target;
150
- return target !== null && !ref.exists && files.has(parentDirOf(target));
151
- };
152
- return {
153
- refs,
154
- dangling: citations.filter((ref) => !ref.exists && !undecidable(ref)),
155
- unverified: citations.filter(undecidable),
156
- foreign: refs.filter((ref) => ref.kind !== "citation"),
157
- truncated
158
- };
159
- }
160
- /** The sanctioned body hook (design §5.6): a list item whose payload is
161
- * exactly one support-file path, so the file stays discoverable in the body. */
162
- const HOOK_LINE_RE = /^- [^\n]{1,60} → ((?:references|templates|scripts|assets)\/[a-z0-9][a-z0-9._/-]*)$/;
163
- /** The retirement escape hatch (design §5.6): a standalone body comment that
164
- * names the support file it exempts and the reason it must survive. The path
165
- * is part of the marker because the proposal list is per FILE, and a reason is
166
- * required — an unexplained exemption is what this hook exists to prevent. */
167
- const KEEP_LINE_RE = /^<!--\s*keep:\s*((?:references|templates|scripts|assets)\/[a-z0-9][a-z0-9._/-]*)\s+(\S[^>]*?)\s*-->$/;
168
- /** Whether a skill-relative path names a FILE rather than a directory: the same
169
- * rule the scanner applies to a token's final segment (`name.ext`). The support
170
- * listing is one level deep and includes directory entries (a real library has
171
- * `references/archive`), which no pointer or retirement list may treat as a file.
172
- * @param path - a skill-root-relative support path.
173
- * @returns true when the final segment is file-shaped.
174
- */
175
- function isFileShapedPath(path) {
176
- return FILE_SEGMENT_RE.test(path.slice(path.lastIndexOf("/") + 1));
177
- }
178
- /**
179
- * Scan a body for sanctioned hooks and `keep` markers.
180
- * @param content - the SKILL.md body (frontmatter included).
181
- * @returns hook targets plus the `keep` reasons keyed by target.
182
- */
183
- function scanBodyHooks(content) {
184
- const targets = [];
185
- const seen = /* @__PURE__ */ new Set();
186
- const kept = /* @__PURE__ */ new Map();
187
- let fence = null;
188
- for (const rawLine of content.split("\n")) {
189
- const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
190
- const fenceMark = FENCE_RE.exec(line);
191
- if (fenceMark) {
192
- fence = fence === null ? (fenceMark[1] ?? "").slice(0, 1) : null;
193
- continue;
194
- }
195
- if (fence !== null) continue;
196
- const keep = KEEP_LINE_RE.exec(line);
197
- if (keep?.[1] !== void 0) {
198
- kept.set(keep[1], (keep[2] ?? "").trim());
199
- continue;
200
- }
201
- const target = HOOK_LINE_RE.exec(line)?.[1];
202
- if (target === void 0 || seen.has(target)) continue;
203
- seen.add(target);
204
- targets.push(target);
205
- }
206
- return {
207
- targets,
208
- kept
209
- };
210
- }
211
- //#endregion
212
16
  //#region lib/types/tree-write.js
213
17
  /**
214
18
  * G1/1.5 (S7-09): the TYPED critical section around a tree write.
@@ -7554,6 +7358,34 @@ function sweepReviewChannelSessions(isAlive) {
7554
7358
  return removed;
7555
7359
  }
7556
7360
  //#endregion
7361
+ //#region lib/types/review-context.js
7362
+ /**
7363
+ * Plugin-local review execution context.
7364
+ *
7365
+ * This is deliberately not a platform API: the family review executor wraps one
7366
+ * bounded tool loop, and the write tools read the context to attribute writes as
7367
+ * background_review without relying on a Session header or a global mark.
7368
+ *
7369
+ * @module @lmzhen/dsh-evolution-core/review-context
7370
+ */
7371
+ const storage = new AsyncLocalStorage();
7372
+ /**
7373
+ * Run one review tool loop under the review write context.
7374
+ * @param context - review/run identity.
7375
+ * @param task - loop body; nested tool executions inherit the context.
7376
+ * @returns the task's value.
7377
+ */
7378
+ function withReviewContext(context, task) {
7379
+ return storage.run(Object.freeze({ ...context }), task);
7380
+ }
7381
+ /**
7382
+ * The active review context, when the current async execution belongs to a review loop.
7383
+ * @returns the frozen context, or undefined outside a review loop.
7384
+ */
7385
+ function currentReviewContext() {
7386
+ return storage.getStore();
7387
+ }
7388
+ //#endregion
7557
7389
  //#region lib/types/run-registry.js
7558
7390
  /**
7559
7391
  * 0.19.0 (S2) / 0.19.3 (restructure): the family's run-lifecycle owner.
@@ -9085,7 +8917,7 @@ function renderLongRunTable() {
9085
8917
  * `client` probes run in the browser half, where the host has no view of the seats.
9086
8918
  * @module @lmzhen/dsh-evolution-core
9087
8919
  */
9088
- /** The 30 probes, in service-name order (the guard checks this list against the tree). */
8920
+ /** The probes, in service-name order (the guard checks this list against the tree). */
9089
8921
  const PLATFORM_SERVICE_PROBES = Object.freeze([
9090
8922
  {
9091
8923
  service: "agentDefaultModel",
@@ -9147,6 +8979,11 @@ const PLATFORM_SERVICE_PROBES = Object.freeze([
9147
8979
  feature: "the memory-budget divergence section of this report",
9148
8980
  side: "host"
9149
8981
  },
8982
+ {
8983
+ service: "evolutionPlatform",
8984
+ feature: "the single host edge object behind every family platform port",
8985
+ side: "host"
8986
+ },
9150
8987
  {
9151
8988
  service: "evolutionPolicy",
9152
8989
  feature: "the policy snapshot that shadows row knobs",
@@ -9192,6 +9029,16 @@ const PLATFORM_SERVICE_PROBES = Object.freeze([
9192
9029
  feature: "the domain-owned session units",
9193
9030
  side: "host"
9194
9031
  },
9032
+ {
9033
+ service: "evolutionProjections",
9034
+ feature: "the family-owned projection runtime behind the pure readers",
9035
+ side: "host"
9036
+ },
9037
+ {
9038
+ service: "evolutionLlm",
9039
+ feature: "the family LLM runtime for auxiliary model calls",
9040
+ side: "host"
9041
+ },
9195
9042
  {
9196
9043
  service: "sessionQuery",
9197
9044
  feature: "the session corpus behind /evolution sessions",
@@ -9566,1091 +9413,6 @@ function assessStructureHealth(snapshot, thresholds = DEFAULT_HEALTH_THRESHOLDS)
9566
9413
  };
9567
9414
  }
9568
9415
  //#endregion
9569
- //#region lib/types/tool-dispatch.js
9570
- /**
9571
- * The family's ONE reader of platform tool-dispatch events.
9572
- *
9573
- * The platform records a finished tool call under two different event
9574
- * vocabularies and only one of them is written per dispatch, chosen by the
9575
- * mounted tool runtime's mode:
9576
- *
9577
- * - native mode: \`tool/call\` (with \`callId\`) settled by \`tool/result\`, the
9578
- * write sites being core/agent-loop/src/tool-calls.ts:264 and :282.
9579
- * - PTC mode: \`tool/ptc-dispatch-start\` and \`tool/ptc-dispatch\` (with
9580
- * \`subCallId\`), the write sites being core/tools/src/ptc.ts:534 and :509.
9581
- *
9582
- * A consumer that matches a vocabulary directly therefore goes blind in the
9583
- * other mode while still appearing to work — the defect this module exists to
9584
- * make impossible. Every family consumer reads dispatches through
9585
- * \`ToolDispatchNormalizer\` (or the pure helpers below) and matches on
9586
- * \`ToolDispatchSignal\` fields only; \`verify-arch-guards\` rule N11 rejects a
9587
- * dispatch event-type comparison anywhere else.
9588
- *
9589
- * ## The one-dispatch invariant
9590
- *
9591
- * One dispatch produces exactly one \`ToolDispatchSignal\`, no matter how many
9592
- * events carry it: a start/settle pair for a PTC sub-dispatch, a call/result
9593
- * pair for a native call, or both vocabularies for the same call. Deduplication
9594
- * and outcome folding are keyed by the platform's own per-vocabulary call
9595
- * identity, which is stable across the pair (the platform's event JSDoc:
9596
- * "the pairing ids (matching the \`tool/ptc-dispatch-start\` with the same
9597
- * \`subCallId\`)").
9598
- *
9599
- * ## Layer
9600
- *
9601
- * Cross-cutting normalization: the reader half of the dispatch vocabulary,
9602
- * next to \`signals.ts\` (which folds the signals this module emits). Both are
9603
- * consumers; neither subscribes to the platform bus itself.
9604
- * @module
9605
- */
9606
- /** The platform event type carrying a PTC sub-dispatch start. */
9607
- const PTC_DISPATCH_START_EVENT = "tool/ptc-dispatch-start";
9608
- /** The platform event type carrying a PTC sub-dispatch settle. */
9609
- const PTC_DISPATCH_EVENT = "tool/ptc-dispatch";
9610
- /** The platform event type carrying a native tool call. */
9611
- const NATIVE_CALL_EVENT = "tool/call";
9612
- /** The platform event type carrying a native tool result. */
9613
- const NATIVE_RESULT_EVENT = "tool/result";
9614
- /**
9615
- * The dispatch vocabulary this module owns. A consumer must never compare
9616
- * against these literals itself (rule N11); it compares \`kind\` instead.
9617
- */
9618
- const DISPATCH_EVENT_TYPES = [
9619
- NATIVE_CALL_EVENT,
9620
- NATIVE_RESULT_EVENT,
9621
- PTC_DISPATCH_START_EVENT,
9622
- PTC_DISPATCH_EVENT
9623
- ];
9624
- /**
9625
- * Model-visible session frames: the message types plus the ONE dispatch vocabulary above.
9626
- * Consumers classify through this list instead of naming event literals (rule N11).
9627
- */
9628
- const MODEL_SESSION_EVENT_TYPES = [
9629
- "user/message",
9630
- "assistant/message",
9631
- ...DISPATCH_EVENT_TYPES
9632
- ];
9633
- /**
9634
- * \`TypeError\` thrown when a payload that claims to be a dispatch event
9635
- * violates the platform's event declaration. Named so a deployment can tell this
9636
- * refusal apart from a generic failure in a log line.
9637
- */
9638
- var ToolDispatchPayloadError = class extends TypeError {
9639
- name = "ToolDispatchPayloadError";
9640
- };
9641
- /** The dispatch event types this module recognizes, as a set. */
9642
- const DISPATCH_EVENT_TYPE_SET = new Set(DISPATCH_EVENT_TYPES);
9643
- /** \`name\`-less payloads: an external emitter or a corrupt log can produce these. */
9644
- const MALFORMED = "malformed";
9645
- /** One tool-result block of a native result payload, or \`null\` when the payload carries none. */
9646
- function firstResultBlock(data) {
9647
- const content = data.message?.content;
9648
- if (!Array.isArray(content)) return null;
9649
- for (const entry of content) {
9650
- if (entry === null || typeof entry !== "object") continue;
9651
- const block = entry;
9652
- if (block.type === "tool-result") return block;
9653
- }
9654
- return null;
9655
- }
9656
- /** Deterministic identity for a dispatch payload that carries no call id. */
9657
- function payloadIdentity(data) {
9658
- if (data === void 0) return "";
9659
- try {
9660
- return JSON.stringify(data);
9661
- } catch {
9662
- return "";
9663
- }
9664
- }
9665
- /** Read the payload of a recognized dispatch event, or \`null\` for any other event. */
9666
- function readDispatchRecord(event) {
9667
- if (!DISPATCH_EVENT_TYPE_SET.has(event.type)) return null;
9668
- const data = event.data ?? {};
9669
- if (event.type === "tool/result") {
9670
- const owner = data.message?.source?.callId;
9671
- const block = firstResultBlock(data);
9672
- const callId = typeof owner === "string" && owner !== "" ? owner : typeof block?.toolCallId === "string" && block.toolCallId !== "" ? block.toolCallId : void 0;
9673
- if (callId === void 0) return null;
9674
- return {
9675
- kind: "native",
9676
- callId,
9677
- rootCallId: callId,
9678
- name: "",
9679
- arguments: void 0,
9680
- outcome: { ok: data.isError !== true && data.error === void 0 && block?.isError !== true }
9681
- };
9682
- }
9683
- const isPtc = event.type === "tool/ptc-dispatch-start" || event.type === "tool/ptc-dispatch";
9684
- const identity = isPtc ? data.subCallId : data.callId;
9685
- const callId = typeof identity === "string" && identity !== "" ? identity : `${event.type}:${payloadIdentity(event.data)}`;
9686
- const parent = isPtc && typeof data.parentCallId === "string" && data.parentCallId !== "" ? data.parentCallId : void 0;
9687
- const name = typeof data.name === "string" && data.name !== "" ? data.name : MALFORMED;
9688
- return {
9689
- kind: isPtc ? "program" : "native",
9690
- callId,
9691
- rootCallId: typeof data.rootCallId === "string" && data.rootCallId !== "" ? data.rootCallId : parent ?? callId,
9692
- name,
9693
- arguments: data.arguments,
9694
- ...isPtc && event.type === "tool/ptc-dispatch" ? { outcome: { ok: data.isError !== true } } : {}
9695
- };
9696
- }
9697
- /**
9698
- * The ledger key of one dispatch: a scope-qualified call id.
9699
- *
9700
- * v43 audit (FLOW4-4): a normalizer shared by every session (skill-usage's live listener holds ONE
9701
- * process-wide instance) used the bare call id, so two sessions that produced the same id — PTC
9702
- * sub-call ids are short, and an id-less payload falls back to a type+payload key that is not
9703
- * unique by construction — collided: the second session's read was absorbed as "already seen" and
9704
- * never counted, and a settle in one session flipped the other's `ok`. Callers that span sessions
9705
- * pass the session id as `scope`.
9706
- * @param callId - the dispatch's call id (or its payload-derived fallback).
9707
- * @param scope - the owning session id, or '' for a fold that never leaves one session.
9708
- * @returns the key both the ledger and every projection fold dedupe on.
9709
- */
9710
- function dispatchKeyOf(callId, scope = "") {
9711
- return scope === "" ? callId : `${scope}:${callId}`;
9712
- }
9713
- /**
9714
- * The pure half of the ledger: what one event says about one dispatch.
9715
- *
9716
- * The DECISION (which dispatch, and whether this event is the one that opens it) lives here and
9717
- * only here; carriers differ in what they keep — the class below keeps consumer-visible mutable
9718
- * signals, the family's `evolutionReads`/`evolutionSignals` projection units keep plain-JSON
9719
- * ledgers. `name` is empty on an event that only settles an already-opened dispatch (a native
9720
- * `tool/result`), and `outcome` is present exactly when the event carried one.
9721
- * @param event - one session event; any non-dispatch event answers `null`.
9722
- * @param scope - the owning session id, or '' for a single-session fold.
9723
- * @returns the step, or `null` when the event is not a dispatch.
9724
- */
9725
- function dispatchStepOf(event, scope = "") {
9726
- const record = readDispatchRecord(event);
9727
- if (record === null) return null;
9728
- return {
9729
- key: dispatchKeyOf(record.callId, scope),
9730
- kind: record.kind,
9731
- callId: record.callId,
9732
- rootCallId: record.rootCallId,
9733
- name: record.name,
9734
- arguments: record.arguments,
9735
- ...record.outcome === void 0 ? {} : { outcome: record.outcome }
9736
- };
9737
- }
9738
- /**
9739
- * The family's single dispatch ledger: absorbs platform events in log order,
9740
- * emits one \`ToolDispatchSignal\` per dispatch, and folds later events of the
9741
- * same dispatch into the record it already emitted.
9742
- *
9743
- * Consumers keep the \`ToolDispatchSignal\` object they received and re-read it
9744
- * later; no consumer needs to correlate events itself.
9745
- */
9746
- var ToolDispatchNormalizer = class {
9747
- records = /* @__PURE__ */ new Map();
9748
- /** S2-P2-14: cap for the LEDGER (and the settle markers) — opt-in, meant for
9749
- * the long-lived live listener (skill-usage) whose ledger is pure dedup
9750
- * state and would otherwise grow with the process lifetime. `Infinity` (the
9751
- * default, used by whole-log folding) keeps every dispatch. Eviction is
9752
- * oldest-first: a call/result pair spans one tool call, so an evicted
9753
- * dispatch can never be re-paired within any realistic window. */
9754
- maxTracked;
9755
- /** S2-P2-12: call ids whose outcome has already been reported to the settle
9756
- * channel — a replayed result event must not settle the same dispatch twice. */
9757
- settledIds = /* @__PURE__ */ new Set();
9758
- constructor(options = {}) {
9759
- this.maxTracked = options.maxTracked ?? Number.POSITIVE_INFINITY;
9760
- }
9761
- /**
9762
- * Absorb one session event.
9763
- * @param event - the event to absorb; any non-dispatch event is ignored.
9764
- * @returns the dispatch's signal when this event FIRST reveals the dispatch,
9765
- * otherwise \`null\` (the paired event of an already-emitted dispatch, or a
9766
- * non-dispatch event). A \`null\` return is never a dispatch to count again.
9767
- */
9768
- advance(event, scope = "") {
9769
- const step = dispatchStepOf(event, scope);
9770
- if (step === null) return null;
9771
- const existing = this.records.get(step.key);
9772
- if (existing !== void 0) {
9773
- if (step.outcome !== void 0) existing.ok = step.outcome.ok;
9774
- return null;
9775
- }
9776
- if (step.name === "") return null;
9777
- const signal = {
9778
- kind: step.kind,
9779
- callId: step.callId,
9780
- rootCallId: step.rootCallId,
9781
- name: step.name,
9782
- arguments: step.arguments,
9783
- ok: step.outcome?.ok
9784
- };
9785
- this.records.set(step.key, signal);
9786
- this.evict();
9787
- return signal;
9788
- }
9789
- /**
9790
- * S2-P2-12: the SETTLE channel. \`advance\` answers \`null\` for the paired
9791
- * event that settles an already-emitted dispatch, so a consumer that must act
9792
- * on the OUTCOME (e.g. count successful skill reads only) cannot tell which
9793
- * dispatch a \`null\` belonged to. Call this with the same event AFTER
9794
- * \`advance\`: it answers the settled dispatch exactly once (replayed settle
9795
- * events answer \`null\`).
9796
- * @param event - the event already absorbed by \`advance\`.
9797
- * @returns the dispatch this event settled, or \`null\`.
9798
- */
9799
- settledSignalOf(event, scope = "") {
9800
- const step = dispatchStepOf(event, scope);
9801
- if (step?.outcome === void 0) return null;
9802
- if (this.settledIds.has(step.key)) return null;
9803
- const signal = this.records.get(step.key);
9804
- if (signal === void 0) return null;
9805
- this.settledIds.add(step.key);
9806
- this.evict();
9807
- return signal;
9808
- }
9809
- /** Oldest-first eviction once the ledger (or the settle markers) overflows. */
9810
- evict() {
9811
- while (this.records.size > this.maxTracked) {
9812
- const oldest = this.records.keys().next().value;
9813
- if (oldest === void 0) break;
9814
- this.records.delete(oldest);
9815
- this.settledIds.delete(oldest);
9816
- }
9817
- while (this.settledIds.size > this.maxTracked) {
9818
- const oldest = this.settledIds.values().next().value;
9819
- if (oldest === void 0) break;
9820
- this.settledIds.delete(oldest);
9821
- }
9822
- }
9823
- /** Every emitted dispatch, in first-seen order. */
9824
- get signals() {
9825
- return [...this.records.values()];
9826
- }
9827
- /**
9828
- * Fold every event of a session log, in order.
9829
- * @param events - the log, oldest first.
9830
- * @returns one signal per dispatch, in first-seen order.
9831
- */
9832
- foldAll(events) {
9833
- const emitted = [];
9834
- for (const event of events) {
9835
- const signal = this.advance(event);
9836
- if (signal !== null) emitted.push(signal);
9837
- }
9838
- return emitted;
9839
- }
9840
- };
9841
- /**
9842
- * Read one event into a dispatch record without a ledger (the pure half of the
9843
- * fold). Unlike the ledger it does NOT dedupe: a caller that walks a log and
9844
- * emits its own lines needs the call line on the event that opens the result.
9845
- * @param event - one session event; an absent event (an over-advanced index)
9846
- * answers \`null\` rather than throwing.
9847
- * @returns the dispatch this event opens, or \`null\` for any other event.
9848
- */
9849
- function readDispatchSignal(event) {
9850
- if (event?.type === void 0) return null;
9851
- const record = readDispatchRecord({
9852
- type: event.type,
9853
- ...event.data === void 0 ? {} : { data: event.data }
9854
- });
9855
- if (record === null || record.name === "") return null;
9856
- return {
9857
- kind: record.kind,
9858
- callId: record.callId,
9859
- rootCallId: record.rootCallId,
9860
- name: record.name,
9861
- arguments: record.arguments
9862
- };
9863
- }
9864
- /** Tool names that READ one skill. The single authority for skill-read detection. */
9865
- const SKILL_READ_TOOL_NAMES = new Set(["skill"]);
9866
- /**
9867
- * Is this dispatched tool name a single-skill read?
9868
- * @param name - the dispatched tool name.
9869
- * @returns \`true\` only for the read tool whose arguments name one skill.
9870
- */
9871
- function isSkillReadToolName(name) {
9872
- return SKILL_READ_TOOL_NAMES.has(name);
9873
- }
9874
- /** Tool names whose dispatch opens a code program, i.e. whose sub-dispatches are \`program\`. */
9875
- const PROGRAM_TOOL_NAMES = new Set(["run_code"]);
9876
- /**
9877
- * Does this signal read one skill, and did it not fail?
9878
- * @param signal - a normalized dispatch.
9879
- * @returns the skill name the dispatch read, or \`undefined\` when the dispatch
9880
- * is not a skill read or has failed. A dispatch whose outcome is still pending
9881
- * counts as a read: the platform settles every started sub-dispatch, so pending
9882
- * is a live-window state, not a failure.
9883
- */
9884
- /** Tool names whose dispatch reads one FILE — the deployment's file tool
9885
- * (default `read`). A differently named tool is configured, not guessed. */
9886
- const DEFAULT_SUPPORT_READ_TOOL_NAMES = ["read"];
9887
- /** Dispatch arguments: a JSON string in native mode and an already-parsed
9888
- * object in PTC mode (core/tools/src/types.ts:11-23) — parsed defensively so no
9889
- * consumer has to trust one modality's encoding. */
9890
- function parsedArguments(signal) {
9891
- let parsed = signal.arguments;
9892
- if (typeof parsed === "string") try {
9893
- parsed = JSON.parse(parsed);
9894
- } catch {
9895
- return null;
9896
- }
9897
- if (parsed === null || typeof parsed !== "object") return null;
9898
- return parsed;
9899
- }
9900
- /** The path-shaped argument of one already-parsed call, when it carries one. */
9901
- function readPathFromRecord(record) {
9902
- if (record === null) return null;
9903
- for (const key of [
9904
- "file_path",
9905
- "path",
9906
- "file",
9907
- "target"
9908
- ]) {
9909
- const value = record[key];
9910
- if (typeof value === "string" && value.trim() !== "") return value;
9911
- }
9912
- return null;
9913
- }
9914
- /** The path-shaped argument of a file tool, when it carries one. */
9915
- function readPathArgument(signal) {
9916
- return readPathFromRecord(parsedArguments(signal));
9917
- }
9918
- /** The path one dispatch names, for the read-evidence projection. */
9919
- function dispatchPathOf(step) {
9920
- let parsed = step.arguments;
9921
- if (typeof parsed === "string") try {
9922
- parsed = JSON.parse(parsed);
9923
- } catch {
9924
- return null;
9925
- }
9926
- return parsed !== null && typeof parsed === "object" ? readPathFromRecord(parsed) : null;
9927
- }
9928
- /**
9929
- * Read one dispatch as a SUPPORT-FILE read attributed to a skill: a read of
9930
- * `<root>/<skill>/<support dir>/…` is demand evidence for that one file, the
9931
- * way `skillReadNameOf` is demand evidence for a whole body.
9932
- * @param signal - a settled dispatch.
9933
- * @param options - the deployment's file-tool names and its skills root; an
9934
- * empty root falls back to the `/skills/` marker in the path.
9935
- * @returns the skill name and the skill-root-relative path, or `null` when the
9936
- * dispatch is not a support-file read. Pure: no IO, no service lookup.
9937
- */
9938
- /** Attribute one raw path string to a skill support file (pure; no IO). */
9939
- function supportFileReadFromPath(raw, options) {
9940
- const normalized = raw.replace(/\\/g, "/").trim();
9941
- if (normalized === "" || normalized.split("/").includes("..")) return null;
9942
- const root = options.root.replace(/\\/g, "/").replace(/\/+$/, "");
9943
- let relative = null;
9944
- if (root !== "") {
9945
- const lower = normalized.toLowerCase();
9946
- const lowerRoot = root.toLowerCase();
9947
- if (lower.startsWith(lowerRoot + "/")) relative = normalized.slice(root.length + 1);
9948
- }
9949
- if (relative === null) {
9950
- const at = normalized.toLowerCase().lastIndexOf("/skills/");
9951
- if (at === -1) return null;
9952
- relative = normalized.slice(at + 8);
9953
- }
9954
- const parts = relative.split("/").filter((part) => part !== "");
9955
- const skill = parts[0];
9956
- const dir = parts[1];
9957
- if (skill === void 0 || dir === void 0 || parts.length < 3) return null;
9958
- if (!CITATION_SUPPORT_DIRS.includes(dir)) return null;
9959
- return {
9960
- skill: skill.trim(),
9961
- rel: parts.slice(1).join("/")
9962
- };
9963
- }
9964
- function supportFileReadOf(signal, options) {
9965
- if (!options.toolNames.includes(signal.name)) return null;
9966
- if (signal.ok === false) return null;
9967
- const raw = readPathArgument(signal);
9968
- return raw === null ? null : supportFileReadFromPath(raw, options);
9969
- }
9970
- function skillReadNameOf(signal) {
9971
- if (!SKILL_READ_TOOL_NAMES.has(signal.name)) return void 0;
9972
- if (signal.ok === false) return void 0;
9973
- const candidate = parsedArguments(signal);
9974
- if (candidate === null) return void 0;
9975
- const name = typeof candidate.name === "string" ? candidate.name : typeof candidate.skill === "string" ? candidate.skill : "";
9976
- return name === "" ? void 0 : name;
9977
- }
9978
- /**
9979
- * Fold one session log into its deduplicated dispatches.
9980
- * @param events - the log, oldest first. Pass an array, not a live snapshot
9981
- * iterator, when the log can grow while folding.
9982
- * @returns one signal per dispatch, in first-seen order.
9983
- */
9984
- function foldToolDispatches(events) {
9985
- return new ToolDispatchNormalizer().foldAll(events);
9986
- }
9987
- /**
9988
- * Every skill name this log read through a dispatch, deduplicated by dispatch.
9989
- * @param events - the log, oldest first.
9990
- * @returns the names read by at least one non-failed skill dispatch.
9991
- */
9992
- function collectReadSkillNames(events) {
9993
- const names = /* @__PURE__ */ new Set();
9994
- for (const signal of foldToolDispatches(events)) {
9995
- const name = skillReadNameOf(signal);
9996
- if (name !== void 0) names.add(name);
9997
- }
9998
- return names;
9999
- }
10000
- /** Every skill support file this log read through a non-failed configured file tool. */
10001
- function collectReadSupportFiles(events, options) {
10002
- const reads = /* @__PURE__ */ new Map();
10003
- for (const signal of foldToolDispatches(events)) {
10004
- const hit = supportFileReadOf(signal, options);
10005
- if (hit === null) continue;
10006
- const set = reads.get(hit.skill) ?? /* @__PURE__ */ new Set();
10007
- set.add(hit.rel);
10008
- reads.set(hit.skill, set);
10009
- }
10010
- return reads;
10011
- }
10012
- /** Tool names that touch the skill library at all — the review's skill-signal set. */
10013
- const SKILL_TOOL_NAMES = new Set([...SKILL_READ_TOOL_NAMES, "skill_manage"]);
10014
- /**
10015
- * Does this dispatched tool name touch the skill library (read or mutate)?
10016
- * @param name - the dispatched tool name.
10017
- * @returns \`true\` for any skill-library tool. This is the review cadence's
10018
- * skill signal, which has always covered reads and writes alike.
10019
- */
10020
- function isSkillToolName(name) {
10021
- return SKILL_TOOL_NAMES.has(name);
10022
- }
10023
- /**
10024
- * Does this dispatched tool name open a code program?
10025
- * @param name - the dispatched tool name.
10026
- * @returns \`true\` for the tool whose sub-dispatches are \`program\` kind.
10027
- */
10028
- function isProgramToolName(name) {
10029
- return PROGRAM_TOOL_NAMES.has(name);
10030
- }
10031
- /**
10032
- * Assert that a payload really is the dispatch event it claims to be.
10033
- *
10034
- * The normalizer is deliberately lenient (it also folds persisted logs, where a
10035
- * payload may predate the current declaration). S1-E7 (honesty fix): this
10036
- * function is an OPT-IN gate — NO production consumer calls it; the shipped
10037
- * listeners fold tolerant (`'malformed'` synthesis) precisely because a
10038
- * throwing gate wired into every session event would brick the family on any
10039
- * upstream payload drift. Deployments that want fail-loud behavior call this
10040
- * from their own `session/event` listener. It never silently downgrades: an
10041
- * unrecognized event type or a payload missing a declared field throws a named
10042
- * \`ToolDispatchPayloadError\`.
10043
- * @param event - the session event to check.
10044
- * @returns nothing; throws when the payload violates the platform declaration.
10045
- */
10046
- function assertDispatchPayload(event) {
10047
- const data = event.data ?? {};
10048
- if (event.type === "tool/call") {
10049
- if (typeof data.name !== "string" || data.name === "" || typeof data.callId !== "string" || data.callId === "") throw new ToolDispatchPayloadError("tool/call carries no name/callId: the agent-loop write site is broken");
10050
- return;
10051
- }
10052
- if (event.type === "tool/ptc-dispatch-start" || event.type === "tool/ptc-dispatch") {
10053
- if (typeof data.subCallId !== "string" || data.subCallId === "" || typeof data.name !== "string" || data.name === "") throw new ToolDispatchPayloadError(`${event.type} carries no name/subCallId: the PTC bridge write site is broken`);
10054
- if (event.type === "tool/ptc-dispatch" && typeof data.isError !== "boolean") throw new ToolDispatchPayloadError("tool/ptc-dispatch carries no boolean isError: the settle outcome is unusable");
10055
- return;
10056
- }
10057
- if (event.type === "tool/result") return;
10058
- throw new ToolDispatchPayloadError(`${event.type} is not a platform dispatch event; compare signal.kind instead of event types`);
10059
- }
10060
- /**
10061
- * Total dispatches in a log, deduplicated.
10062
- * @param events - the log, oldest first.
10063
- * @returns the number of distinct dispatches, one per dispatch regardless of
10064
- * how many events carried it.
10065
- */
10066
- function countDispatches(events) {
10067
- return foldToolDispatches(events).length;
10068
- }
10069
- //#endregion
10070
- //#region lib/types/signals.js
10071
- /**
10072
- * Deterministic review signal gate.
10073
- *
10074
- * Scans a DSH session event log for durable learning signals before any LLM
10075
- * is spent. `turn/end` calls `observeEvent`; the returned review kind is
10076
- * accumulated until a configured interval fires.
10077
- */
10078
- const CORRECTION_PATTERNS = [
10079
- /(?:don'?t|do not|stop|never)\s+(?:do|use|format|explain|write|say)/i,
10080
- /(?:too|very|way\s+too)\s+(?:verbose|long|detailed|short|brief)/i,
10081
- /(?:I|we)\s+(?:prefer|like|want|need)\b/i,
10082
- /remember\s+(?:this|that|to)/i
10083
- ];
10084
- const FIX_PATTERNS = [/worked after|fixed by|the fix was|root cause/i, /retry(?:ing)? worked|workaround/i];
10085
- /** Text of one persisted content block, or `''` for any other shape.
10086
- *
10087
- * Content blocks cross the durable session-log boundary, so their runtime
10088
- * shape is `unknown` even where the static event type promises
10089
- * `{ type, text }`: a persisted `content: [null]` (A2-7, v18) used to throw a
10090
- * TypeError here and the review catch swallowed the whole turn's remaining
10091
- * signals. Keeping the guard in one helper also keeps the branches free of
10092
- * conditions the static type already excludes.
10093
- * @param block - one element of a persisted message `content` array.
10094
- * @returns the block's text when it is a text block, otherwise an empty string.
10095
- */
10096
- function textOfBlock(block) {
10097
- if (block === null || typeof block !== "object") return "";
10098
- const candidate = block;
10099
- return candidate.type === "text" && typeof candidate.text === "string" ? candidate.text : "";
10100
- }
10101
- /** The empty turn-window fold state. */
10102
- function initialTurnFold() {
10103
- return {
10104
- substantive: false,
10105
- toolCalls: 0,
10106
- userChars: 0,
10107
- assistantChars: 0,
10108
- memorySignal: false,
10109
- skillSignal: false,
10110
- opened: []
10111
- };
10112
- }
10113
- /**
10114
- * Fold ONE session event into a turn-window state, purely.
10115
- *
10116
- * The one fold behind all three readers: `observeEvent` (the mutating face the live `turn/end`
10117
- * path uses), `foldTurn` (a whole-log window fold, kept for structural test sessions) and the
10118
- * family's `evolutionSignals` projection unit. P1-1/N4 guards stay: events arrive from disk, so
10119
- * a persisted `data: null` / non-object or a malformed `content` skips instead of throwing.
10120
- * @param state - the window so far.
10121
- * @param event - the next committed session event.
10122
- * @returns the next state; the same reference when the event carries nothing this fold reads.
10123
- */
10124
- function foldTurnEvent(state, event) {
10125
- const data = event.data;
10126
- if (data === null || typeof data !== "object" || Array.isArray(data)) return state;
10127
- if (event.type === "user/message") {
10128
- const content = data.content;
10129
- if (!Array.isArray(content)) return state;
10130
- const text = content.map(textOfBlock).join(" ");
10131
- return {
10132
- ...state,
10133
- userChars: state.userChars + text.length,
10134
- memorySignal: state.memorySignal || CORRECTION_PATTERNS.some((pattern) => pattern.test(text)),
10135
- skillSignal: state.skillSignal || FIX_PATTERNS.some((pattern) => pattern.test(text))
10136
- };
10137
- }
10138
- if (event.type === "assistant/message") {
10139
- const message = data.message;
10140
- if (!message || !Array.isArray(message.content)) return state;
10141
- const text = message.content.map(textOfBlock).join(" ");
10142
- return {
10143
- ...state,
10144
- assistantChars: state.assistantChars + text.length
10145
- };
10146
- }
10147
- const dispatch = dispatchStepOf(event);
10148
- if (dispatch === null || dispatch.name === "" || state.opened.includes(dispatch.key)) return state;
10149
- let toolCalls = state.toolCalls;
10150
- if (dispatch.kind !== "program") toolCalls += 1;
10151
- return {
10152
- ...state,
10153
- opened: [...state.opened, dispatch.key],
10154
- toolCalls,
10155
- skillSignal: state.skillSignal || isSkillToolName(dispatch.name)
10156
- };
10157
- }
10158
- /**
10159
- * Per-turn dispatch ledgers, keyed by the signal object they feed.
10160
- *
10161
- * `observeEvent` folds ONE event at a time, so the ledger has to outlive the call. One WeakMap
10162
- * entry per `TurnSignals`, so a finished fold's ledger is collectable with the fold itself and two
10163
- * concurrent turns never share one.
10164
- */
10165
- const dispatchLedgers = /* @__PURE__ */ new WeakMap();
10166
- /** The ledger of the turn this signal is folding; empty before its first dispatch. */
10167
- function ledgerForSignal(signal) {
10168
- return dispatchLedgers.get(signal) ?? [];
10169
- }
10170
- /**
10171
- * Fold one session event into the current turn observation (the mutating face of
10172
- * {@link foldTurnEvent}: every reader shares the one fold, this one copies the result back onto
10173
- * the caller's signal object and keeps its ledger for the next event).
10174
- * @param signal - the turn observation to advance.
10175
- * @param event - the next committed session event.
10176
- */
10177
- function observeEvent(signal, event) {
10178
- const next = foldTurnEvent({
10179
- ...signal,
10180
- opened: [...ledgerForSignal(signal)]
10181
- }, event);
10182
- signal.substantive = next.substantive;
10183
- signal.toolCalls = next.toolCalls;
10184
- signal.userChars = next.userChars;
10185
- signal.assistantChars = next.assistantChars;
10186
- signal.memorySignal = next.memorySignal;
10187
- signal.skillSignal = next.skillSignal;
10188
- dispatchLedgers.set(signal, next.opened);
10189
- }
10190
- /** Compute review cadence after `turn/end`. */
10191
- function advanceReview(state, turn, signal, config) {
10192
- if (turn === state.lastTurn) return null;
10193
- state.lastTurn = turn;
10194
- signal.substantive = signal.toolCalls >= config.substantiveMinToolCalls || signal.userChars >= config.substantiveMinUserChars || signal.assistantChars >= config.substantiveMinAgentChars;
10195
- if (!signal.substantive) return null;
10196
- state.turnsSinceMemory += signal.memorySignal ? 1 : Math.max(1, signal.toolCalls);
10197
- state.turnsSinceSkill += signal.skillSignal ? 1 : Math.max(1, signal.toolCalls);
10198
- const memoryDue = state.turnsSinceMemory >= config.memoryInterval;
10199
- const skillDue = state.turnsSinceSkill >= config.skillInterval;
10200
- const zero = () => {
10201
- state.turnsSinceMemory = 0;
10202
- state.turnsSinceSkill = 0;
10203
- };
10204
- if (memoryDue && skillDue) {
10205
- if (config.resetOnFire !== false) zero();
10206
- return "combined";
10207
- }
10208
- if (memoryDue) {
10209
- if (config.resetOnFire !== false) state.turnsSinceMemory = 0;
10210
- return "memory";
10211
- }
10212
- if (skillDue) {
10213
- if (config.resetOnFire !== false) state.turnsSinceSkill = 0;
10214
- return "skill";
10215
- }
10216
- return null;
10217
- }
10218
- /**
10219
- * Fold a log slice into one turn window, purely.
10220
- *
10221
- * The whole-log reference for {@link foldTurnEvent}: a caller that holds events (a fixture, a
10222
- * structural view, a replay) reads a window without touching a platform Session. Production reads
10223
- * the same window live from the family's `evolutionSignals` projection (`sessionTurnSignals`),
10224
- * which folds `foldTurnEvent` once per committed event.
10225
- * @param events - the log, oldest first. Pass an array, not a live iterator, when it can grow.
10226
- * @param fromSeq - index of the first event of the window (0 for the whole log).
10227
- * @returns the window's signals.
10228
- */
10229
- function foldTurnEvents(events, fromSeq = 0) {
10230
- const list = [...events];
10231
- let state = initialTurnFold();
10232
- for (let index = Math.max(0, fromSeq); index < list.length; index += 1) {
10233
- const event = list[index];
10234
- if (event) state = foldTurnEvent(state, event);
10235
- }
10236
- const { substantive, toolCalls, userChars, assistantChars, memorySignal, skillSignal } = state;
10237
- return {
10238
- substantive,
10239
- toolCalls,
10240
- userChars,
10241
- assistantChars,
10242
- memorySignal,
10243
- skillSignal
10244
- };
10245
- }
10246
- //#endregion
10247
- //#region lib/types/evidence.js
10248
- /**
10249
- * Which session frames are EVIDENCE, and which are bookkeeping.
10250
- *
10251
- * The session's evidence index answers "does this seq carry content"; a bare range check used
10252
- * to accept any integer inside the authoring window. A boundary frame satisfies that while carrying
10253
- * nothing a claim can rest on: the `turn/start` seq is the frame a claim about that turn was
10254
- * most likely read out of, and citing it is indistinguishable from citing a real exchange. This
10255
- * module owns the ONE classification of a session frame by what it CARRIES, so the plan path can
10256
- * report an op whose whole citation list is bookkeeping (design
10257
- * `dsh-evolution-skill-history-design.md` §3D, phase 1: report only — no op is refused here).
10258
- *
10259
- * The classification is a DENY list of the pure bookends, not an allow list of content frames.
10260
- * The platform's own vocabulary (`KNOWN_SESSION_EVENT_TYPES`, 57 members at 0.1.5-rc.2) mixes
10261
- * content frames with state-change frames, and out-of-repo plugins append types the family cannot
10262
- * enumerate; an unknown frame is therefore treated as carrying content, because a report that
10263
- * fires on an unclassifiable frame is a false positive and phase 1 exists to measure how many TRUE
10264
- * ones there are. Tightening — a narrower definition, or an allow list built from the platform's
10265
- * vocabulary — changes this table and nothing else (`evidenceKindIndex` is the only reader).
10266
- * @module @lmzhen/dsh-evolution-core
10267
- */
10268
- /** The frame types that record a boundary and carry no content: the turn and step bookends. */
10269
- const BOOKKEEPING_FRAME_TYPES = new Set([
10270
- "turn/start",
10271
- "turn/end",
10272
- "step/start",
10273
- "step/end"
10274
- ]);
10275
- /**
10276
- * Whether one frame type records a boundary and carries no content.
10277
- *
10278
- * The classification table's SECOND reader: the live projection unit
10279
- * (`session-projection.ts`) folds the same answer per event, so the rule stays one table.
10280
- * @param type - a platform session-event type.
10281
- * @returns true for the turn/step bookends.
10282
- */
10283
- function isBookkeepingFrame(type) {
10284
- return BOOKKEEPING_FRAME_TYPES.has(type);
10285
- }
10286
- /**
10287
- * The seqs of the frames that carry content.
10288
- *
10289
- * @param events - the session's frames, oldest first (any iterable; nothing is retained).
10290
- * @returns the substantive seqs, or `undefined` when NO frame carried a usable seq. The two
10291
- * answers are different facts: an empty SET says "every sequenced frame is a boundary", while
10292
- * `undefined` says "this log cannot tell a boundary from a message" (a stub session in a test,
10293
- * a composition whose events carry no seq). A caller that cannot classify must stay silent
10294
- * rather than report every op — the same three-state posture as `sessionReadSkillNames`.
10295
- */
10296
- function evidenceKindIndex(events) {
10297
- const substantive = /* @__PURE__ */ new Set();
10298
- let sequenced = 0;
10299
- for (const event of events) {
10300
- const seq = event.seq;
10301
- if (typeof seq !== "number" || !Number.isInteger(seq)) continue;
10302
- sequenced += 1;
10303
- if (typeof event.type === "string" && BOOKKEEPING_FRAME_TYPES.has(event.type)) continue;
10304
- substantive.add(seq);
10305
- }
10306
- return sequenced === 0 ? void 0 : substantive;
10307
- }
10308
- //#endregion
10309
- //#region lib/types/session-projection.js
10310
- /**
10311
- * The family's session projections: the per-session facts the family used to re-read the log for.
10312
- *
10313
- * 0.2.x deprecates the synchronous log reads (`Session.snapshotEvents` — "existing logic may
10314
- * remain unmigrated for now, but new calls are prohibited",
10315
- * `core/session/src/index.ts:639-658`) and drives DOMAIN-OWNED units instead: a registered unit
10316
- * folds every committed event once, the registry owns the subscription and the per-session
10317
- * watermark, and a reader asks for the current state
10318
- * (`session/session-projection/src/index.ts` — `register`/`stateOf`). Each unit here carries
10319
- * exactly what one pure family reader derives from a log, so that reader keeps its pure form and
10320
- * gains a projection-backed one beside it.
10321
- *
10322
- * State stays bounded. The evidence unit keeps the SPARSE boundary seqs and answers the dense
10323
- * question by complement: a content-seq set grows with every session event, while a turn/step
10324
- * boundary set grows four entries per turn.
10325
- *
10326
- * The registry is part of the platform's BASE bundle (`packages/bundle/base/cordis.patch.yml:158`),
10327
- * so a real host always has it; a composition without it keeps loading (`ctx.inject` probe) and
10328
- * its readers report "cannot classify" instead of guessing — the same posture the pure readers
10329
- * document for a log with no seq.
10330
- * @module @lmzhen/dsh-evolution-core
10331
- */
10332
- const MAX_TIMESTAMP_MS = 864e13;
10333
- const activityStateSchema = z.object({ lastEventTime: z.number().nonnegative().max(MAX_TIMESTAMP_MS) }).strict();
10334
- const evidenceStateSchema = z.object({
10335
- sequenced: z.number().int().nonnegative(),
10336
- through: z.number().int().min(-1).max(Number.MAX_SAFE_INTEGER),
10337
- bookkeeping: z.array(z.number().int().nonnegative())
10338
- }).strict();
10339
- /** The `evolutionActivity` unit (host-only: no client view is registered for it). */
10340
- const evolutionActivityProjection = {
10341
- key: "evolutionActivity",
10342
- stateVersion: 1,
10343
- stateSchema: activityStateSchema,
10344
- init: () => ({ lastEventTime: 0 }),
10345
- apply: (state, event) => {
10346
- const time = typeof event.time === "number" ? event.time : state.lastEventTime;
10347
- return time === state.lastEventTime ? state : { lastEventTime: time };
10348
- }
10349
- };
10350
- /** The `evolutionEvidence` unit (host-only: no client view is registered for it). */
10351
- const evolutionEvidenceProjection = {
10352
- key: "evolutionEvidence",
10353
- stateVersion: 1,
10354
- stateSchema: evidenceStateSchema,
10355
- init: () => ({
10356
- sequenced: 0,
10357
- through: -1,
10358
- bookkeeping: []
10359
- }),
10360
- apply: (state, event) => {
10361
- const seq = event.seq;
10362
- if (typeof seq !== "number" || !Number.isInteger(seq)) return state;
10363
- const sequenced = state.sequenced + 1;
10364
- const through = seq > state.through ? seq : state.through;
10365
- if (typeof event.type !== "string" || !isBookkeepingFrame(event.type)) return {
10366
- sequenced,
10367
- through,
10368
- bookkeeping: state.bookkeeping
10369
- };
10370
- return {
10371
- sequenced,
10372
- through,
10373
- bookkeeping: [...state.bookkeeping, seq]
10374
- };
10375
- }
10376
- };
10377
- /**
10378
- * Whether one session object can be projected at all.
10379
- *
10380
- * The family's readers also take STRUCTURAL session views — `skill-reads.ts` documents the tool
10381
- * path's bare stub — while the registry folds a session's own log (`snapshotEvents(from, to)`,
10382
- * `eventAt(seq)`, `seq`, `inheritedEventCount`) whenever it has to build or advance a cell. A
10383
- * view without those members has no projection state to read, and asking for one would fold a
10384
- * log the unit cannot index.
10385
- * @param session - the value a caller holds as its session.
10386
- * @returns true when the registry can fold this object.
10387
- */
10388
- function isProjectableSession(session) {
10389
- if (session === null || typeof session !== "object") return false;
10390
- const candidate = session;
10391
- const folds = typeof candidate.eventAt === "function";
10392
- const logs = typeof candidate.snapshotEvents === "function";
10393
- return folds && logs && typeof candidate.seq === "number";
10394
- }
10395
- const projectionHistorySchema = z.object({
10396
- catalogs: z.array(z.object({
10397
- text: z.string(),
10398
- entries: z.array(z.object({
10399
- name: z.string(),
10400
- description: z.string()
10401
- }).strict()).max(512),
10402
- update: z.boolean()
10403
- }).strict()).max(8),
10404
- digests: z.array(z.string()).max(64)
10405
- }).strict();
10406
- const readsStateSchema = z.object({ reads: z.array(z.object({
10407
- key: z.string(),
10408
- skill: z.string().nullable(),
10409
- failed: z.boolean(),
10410
- file: z.string().nullable().optional(),
10411
- tool: z.string().optional()
10412
- }).strict()) }).strict();
10413
- const signalsStateSchema = z.object({
10414
- through: z.number().int().min(-1).max(Number.MAX_SAFE_INTEGER),
10415
- lastEventTime: z.number().nonnegative().max(MAX_TIMESTAMP_MS),
10416
- turnStartSeq: z.number().int().min(-1).max(Number.MAX_SAFE_INTEGER),
10417
- turn: z.object({
10418
- substantive: z.boolean(),
10419
- toolCalls: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
10420
- userChars: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
10421
- assistantChars: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
10422
- memorySignal: z.boolean(),
10423
- skillSignal: z.boolean(),
10424
- opened: z.array(z.string())
10425
- }).strict()
10426
- }).strict();
10427
- /** The `evolutionProjectionHistory` unit (host-only). */
10428
- const evolutionProjectionHistoryProjection = {
10429
- key: "evolutionProjectionHistory",
10430
- stateVersion: 1,
10431
- stateSchema: projectionHistorySchema,
10432
- init: () => ({
10433
- catalogs: [],
10434
- digests: []
10435
- }),
10436
- apply: (state, event) => {
10437
- const frame = event;
10438
- if (frame.type !== "user/message" || typeof frame.data !== "object" || frame.data === null) return state;
10439
- const message = frame.data;
10440
- const source = message.source;
10441
- if (source === void 0 || typeof source !== "object") return state;
10442
- if (source.kind === "evolution-skill-projection" && typeof source.digest === "string") {
10443
- if (state.digests.includes(source.digest)) return state;
10444
- return {
10445
- catalogs: state.catalogs,
10446
- digests: [...state.digests, source.digest].slice(-64)
10447
- };
10448
- }
10449
- if (source.kind !== "skill-catalog" || source.form !== "catalog" || !Array.isArray(source.entries)) return state;
10450
- if (!Array.isArray(message.content)) return state;
10451
- const text = message.content.map((block) => block !== null && typeof block === "object" && block.type === "text" ? String(block.text ?? "") : "").join("");
10452
- if (!text.includes("<available_skills>") || !text.includes("</available_skills>")) return state;
10453
- const entries = source.entries.filter((entry) => entry !== null && typeof entry === "object" && typeof entry.name === "string" && typeof entry.description === "string").map((entry) => ({
10454
- name: entry.name,
10455
- description: entry.description
10456
- }));
10457
- return {
10458
- catalogs: [...state.catalogs, {
10459
- text,
10460
- entries,
10461
- update: source.update === true
10462
- }].slice(-8),
10463
- digests: state.digests
10464
- };
10465
- }
10466
- };
10467
- /** The `evolutionReads` unit (host-only: no client view is registered for it). */
10468
- const evolutionReadsProjection = {
10469
- key: "evolutionReads",
10470
- stateVersion: 1,
10471
- stateSchema: readsStateSchema,
10472
- init: () => ({ reads: [] }),
10473
- apply: (state, event) => {
10474
- const step = dispatchStepOf(event);
10475
- if (step === null) return state;
10476
- const at = state.reads.findIndex((entry) => entry.key === step.key);
10477
- const settled = () => {
10478
- const entry = at < 0 ? void 0 : state.reads[at];
10479
- if (entry === void 0 || step.outcome === void 0) return state;
10480
- const failed = !step.outcome.ok;
10481
- if (entry.failed === failed) return state;
10482
- const reads = [...state.reads];
10483
- reads[at] = {
10484
- key: entry.key,
10485
- skill: entry.skill,
10486
- failed,
10487
- ...entry.file === void 0 ? {} : { file: entry.file },
10488
- ...entry.tool === void 0 ? {} : { tool: entry.tool }
10489
- };
10490
- return { reads };
10491
- };
10492
- if (step.name === "") return settled();
10493
- if (at >= 0) return settled();
10494
- const file = dispatchPathOf(step);
10495
- if (file !== null) return { reads: [...state.reads.slice(-511), {
10496
- key: step.key,
10497
- skill: null,
10498
- failed: step.outcome?.ok === false,
10499
- file,
10500
- tool: step.name
10501
- }] };
10502
- if (!isSkillReadToolName(step.name)) return state;
10503
- const skill = skillReadNameOf({
10504
- kind: step.kind,
10505
- callId: step.callId,
10506
- rootCallId: step.rootCallId,
10507
- name: step.name,
10508
- arguments: step.arguments,
10509
- ok: step.outcome?.ok
10510
- }) ?? null;
10511
- return { reads: [...state.reads, {
10512
- key: step.key,
10513
- skill,
10514
- failed: step.outcome?.ok === false
10515
- }] };
10516
- }
10517
- };
10518
- /** The `evolutionSignals` unit (host-only: no client view is registered for it). */
10519
- const evolutionSignalsProjection = {
10520
- key: "evolutionSignals",
10521
- stateVersion: 1,
10522
- stateSchema: signalsStateSchema,
10523
- init: () => ({
10524
- through: -1,
10525
- lastEventTime: 0,
10526
- turnStartSeq: -1,
10527
- turn: initialTurnFold()
10528
- }),
10529
- apply: (state, event) => {
10530
- const start = event.type === "turn/start";
10531
- const turn = foldTurnEvent(start ? initialTurnFold() : state.turn, event);
10532
- const seq = typeof event.seq === "number" && Number.isInteger(event.seq) ? event.seq : state.through;
10533
- const time = typeof event.time === "number" ? event.time : state.lastEventTime;
10534
- const turnStartSeq = start ? seq : state.turnStartSeq;
10535
- if (turn === state.turn && seq === state.through && time === state.lastEventTime && turnStartSeq === state.turnStartSeq) return state;
10536
- return {
10537
- through: seq,
10538
- lastEventTime: time,
10539
- turnStartSeq,
10540
- turn
10541
- };
10542
- }
10543
- };
10544
- /**
10545
- * Register the family's units on the calling context's fiber.
10546
- *
10547
- * Called by the READERS (not by a plugin's mount) and idempotent by the registry's own reference
10548
- * count: the first read of a foldable session installs the definitions, later reads count as
10549
- * co-owners, and the keys survive until the last registrant unloads
10550
- * (`session-projection/src/index.ts:273-292`). Registering at the read is what keeps a session
10551
- * view the registry cannot fold (`isProjectableSession`) from ever reaching its drive — the
10552
- * registry folds the in-memory log on first touch, so a unit that appears mid-session is still
10553
- * correct (`:602-630`).
10554
- *
10555
- * Idempotent by design, so a plugin mounting later does not need its own call.
10556
- * @param ctx - the mounting plugin's context.
10557
- */
10558
- function installEvolutionProjections(ctx) {
10559
- const register = (registry) => {
10560
- registry.register(evolutionActivityProjection);
10561
- registry.register(evolutionEvidenceProjection);
10562
- registry.register(evolutionReadsProjection);
10563
- registry.register(evolutionProjectionHistoryProjection);
10564
- registry.register(evolutionSignalsProjection);
10565
- };
10566
- const mounted = ctx.get("sessionProjections");
10567
- if (mounted !== void 0) {
10568
- register(mounted);
10569
- return;
10570
- }
10571
- ctx.inject(["sessionProjections"], (injected) => {
10572
- register(injected.sessionProjections);
10573
- });
10574
- }
10575
- /**
10576
- * Time of one session's newest event, or `undefined` when the unit is not installed.
10577
- *
10578
- * The curator's idleness gate reads this instead of folding the session log; `undefined` is a
10579
- * measurement that did not happen, which the gate answers with the deployment's fail-open policy.
10580
- * @param ctx - a context of the runtime (the service is read from the global store).
10581
- * @param session - the session to ask about.
10582
- * @returns the newest event's milliseconds, or undefined with no unit or no event.
10583
- */
10584
- function sessionLastEventTime(ctx, session) {
10585
- if (!isProjectableSession(session)) return void 0;
10586
- installEvolutionProjections(ctx);
10587
- const state = ctx.get("sessionProjections")?.stateOf(session, "evolutionActivity");
10588
- if (state === void 0 || state.lastEventTime === 0) return void 0;
10589
- return state.lastEventTime;
10590
- }
10591
- /**
10592
- * The skill names one session read through a non-failed dispatch, or `undefined` when the session
10593
- * cannot be projected (a structural view, or a host without the registry).
10594
- *
10595
- * `undefined` is NOT an empty set: the tool path's read-before-write gate keeps its previous
10596
- * behavior rather than refusing every write in a composition whose session object is a bare stub
10597
- * (`skill-reads.ts` documents that three-state posture).
10598
- * @param ctx - a context of the runtime.
10599
- * @param session - the session whose reads are wanted.
10600
- * @returns the names read, or undefined when the log cannot be folded.
10601
- */
10602
- function sessionReadNames(ctx, session) {
10603
- if (!isProjectableSession(session)) return void 0;
10604
- installEvolutionProjections(ctx);
10605
- const state = ctx.get("sessionProjections")?.stateOf(session, "evolutionReads");
10606
- if (state === void 0) return void 0;
10607
- const names = /* @__PURE__ */ new Set();
10608
- for (const entry of state.reads) if (!entry.failed && entry.skill !== null) names.add(entry.skill);
10609
- return names;
10610
- }
10611
- /**
10612
- * The open turn's window signals, or `undefined` when the session cannot be projected.
10613
- *
10614
- * The window is the events since the newest `turn/start`, folded by the same `foldTurnEvent`
10615
- * `observeEvent` uses; `undefined` means the caller has no measurement (a structural view), not
10616
- * that the turn was empty.
10617
- * @param ctx - a context of the runtime.
10618
- * @param session - the session whose open turn is being judged.
10619
- * @returns the window signals, or undefined when the log cannot be folded.
10620
- */
10621
- function sessionTurnSignals(ctx, session) {
10622
- if (!isProjectableSession(session)) return void 0;
10623
- installEvolutionProjections(ctx);
10624
- const state = ctx.get("sessionProjections")?.stateOf(session, "evolutionSignals");
10625
- if (state === void 0) return void 0;
10626
- const { substantive, toolCalls, userChars, assistantChars, memorySignal, skillSignal } = state.turn;
10627
- return {
10628
- substantive,
10629
- toolCalls,
10630
- userChars,
10631
- assistantChars,
10632
- memorySignal,
10633
- skillSignal
10634
- };
10635
- }
10636
- /**
10637
- * The evidence index of one session, or `undefined` when the log cannot be classified.
10638
- *
10639
- * `undefined` covers both the missing unit and a log whose frames carry no seq: the plan path's
10640
- * `EVIDENCE_CLASS` row is report-only and must stay silent rather than report every op.
10641
- * @param ctx - a context of the runtime.
10642
- * @param session - the session the review plan is authored against.
10643
- * @returns an index answering "does this seq carry content?".
10644
- */
10645
- function sessionEvidenceIndex(ctx, session) {
10646
- if (!isProjectableSession(session)) return void 0;
10647
- installEvolutionProjections(ctx);
10648
- const state = ctx.get("sessionProjections")?.stateOf(session, "evolutionEvidence");
10649
- if (state === void 0 || state.sequenced === 0) return void 0;
10650
- const { through, bookkeeping } = state;
10651
- return { has: (seq) => Number.isInteger(seq) && seq >= 0 && seq <= through && !bookkeeping.includes(seq) };
10652
- }
10653
- //#endregion
10654
9416
  //#region lib/types/skill-reads.js
10655
9417
  /**
10656
9418
  * The skill names ONE session read, or `undefined` when its log is not readable.
@@ -10690,8 +9452,7 @@ function sessionReadSkillNames(ctx, session) {
10690
9452
  function sessionReadSupportFiles(ctx, session, options) {
10691
9453
  if (session === void 0) return void 0;
10692
9454
  if (isProjectableSession(session)) {
10693
- installEvolutionProjections(ctx);
10694
- const state = ctx.get("sessionProjections")?.stateOf(session, "evolutionReads");
9455
+ const state = ctx.get("evolutionProjections")?.reads(session);
10695
9456
  if (state !== void 0) {
10696
9457
  const toolNames = options.toolNames ?? DEFAULT_SUPPORT_READ_TOOL_NAMES;
10697
9458
  const reads = /* @__PURE__ */ new Map();
@@ -12753,6 +11514,10 @@ function resolveOrigins(headerOrigin, isReview = false) {
12753
11514
  * Single source: both tools call this instead of re-deriving the pair.
12754
11515
  */
12755
11516
  function resolveExecOrigins(exec) {
11517
+ if (currentReviewContext() !== void 0) return {
11518
+ approval: "background_review",
11519
+ library: "background_review"
11520
+ };
12756
11521
  const session = exec?.agent?.session;
12757
11522
  return resolveOrigins(session?.header?.origin, isReviewChannelSession(typeof session?.id === "string" ? session.id : void 0));
12758
11523
  }
@@ -16732,13 +15497,13 @@ const PARAM_EXPOSURE = Object.freeze([
16732
15497
  owner: "evolution-review",
16733
15498
  applies: "live",
16734
15499
  docAnchor: "PARAMETERS.md#review",
16735
- summary: "Run the review in the parent session (inject), on a subagent, or in a background branch.",
15500
+ summary: "Run the review in the plugin-owned auxiliary loop (aux), or as a parent-session turn (inject; debugging only).",
16736
15501
  label: "运行位置",
16737
- hint: "在哪里运行检查:在当前会话里/交给子代理/后台分支。",
15502
+ hint: "默认在插件内辅助审查;inject 仅用于调试,会把审查写入当前会话。",
16738
15503
  control: "select",
16739
15504
  unit: "",
16740
- values: "inject|branch",
16741
- valueLabels: "在当前会话里|后台分支",
15505
+ values: "aux|inject",
15506
+ valueLabels: "插件内辅助|当前会话(调试)",
16742
15507
  card: "evolution-review"
16743
15508
  },
16744
15509
  {
@@ -16765,9 +15530,9 @@ const PARAM_EXPOSURE = Object.freeze([
16765
15530
  owner: "evolution-review",
16766
15531
  applies: "live",
16767
15532
  docAnchor: "PARAMETERS.md#review",
16768
- summary: "Deliver result notices into the parent conversation.",
15533
+ summary: "Deliver result notices into the parent conversation for inject mode; aux results are audit-only.",
16769
15534
  label: "结果通知",
16770
- hint: "关闭后检查结果不再写进对话;检查本身照常运行,结果留在审计记录里。",
15535
+ hint: "inject 调试模式下才把结果写进对话;aux 结果只进审计记录,始终不写对话。",
16771
15536
  control: "switch",
16772
15537
  unit: "",
16773
15538
  values: "",
@@ -18496,7 +17261,7 @@ function scopedProbeReport() {
18496
17261
  * Does this session's scope see the family's model tools?
18497
17262
  *
18498
17263
  * The scope is the live agent's — the platform's own addressing for "what does
18499
- * this session see" (`tools.get(name, scope)`, packages/core/tools/src/index.ts:1194).
17264
+ * this session see" (`tools.get(name, scope)`, packages/core/tools/src/index.ts:239).
18500
17265
  * A session with no live agent (a finished or cold session) has no scope to ask
18501
17266
  * in, so it resolves to false; the consumers this gate serves only run for live
18502
17267
  * agents.
@@ -18619,12 +17384,12 @@ const DIAGNOSTICS_RUNTIME_KEYS = [
18619
17384
  //#region lib/types/platform-line.generated.js
18620
17385
  /** The frozen platform line this release targets (peers/engines/anchors derived from version+floor). */
18621
17386
  const PLATFORM_LINE = {
18622
- version: "0.2.1-rc.3",
18623
- floor: "0.2.1-rc.2",
18624
- previousAnchor: "0.2.0-rc.2",
18625
- peersRange: "^0.2.1-rc.2",
18626
- enginesRange: ">=0.2.1-rc.2 <0.2.2-0",
18627
- upstreamRef: "dsh-v0.2.1-rc.3"
17387
+ version: "0.2.2-rc.1",
17388
+ floor: "0.2.2-rc.0",
17389
+ previousAnchor: "0.2.1-rc.2",
17390
+ peersRange: "^0.2.2-rc.0",
17391
+ enginesRange: ">=0.2.2-rc.0 <0.2.3-0",
17392
+ upstreamRef: "dsh-v0.2.2-rc.1"
18628
17393
  };
18629
17394
  //#endregion
18630
17395
  //#region lib/types/session-fold.js
@@ -18641,4 +17406,4 @@ function isIgnorableEvent(event) {
18641
17406
  return classifySessionEvent(event) !== "model";
18642
17407
  }
18643
17408
  //#endregion
18644
- export { AUTHORING_DESCRIPTION_BAR, AUTHORING_SPLIT_LINE_CHARS, BASELINE_ACTION, CITATION_SUPPORT_DIRS, COMBINED_REVIEW_PLAN_PROMPT, COMBINED_REVIEW_PROMPT, COMPLETION_SKILL_REVIEW_PROMPT, CONTENT_SPLIT_HINT, COST_ASCII_TOKEN_HIGH, COST_ASCII_TOKEN_LOW, COST_CJK_TOKEN_HIGH, COST_CJK_TOKEN_LOW, CURATOR_DRY_RUN_BANNER, CURATOR_PROMPT, DEDUP_MAX_PAIR_COMPARISONS, DEDUP_SIMILARITY_THRESHOLD, DEFAULT_ADMISSION, DEFAULT_ARCHIVE_AFTER_DAYS, DEFAULT_ARCHIVE_RETENTION_POLICY, DEFAULT_CITATION_POLICY, DEFAULT_CITATION_REF_BUDGET, DEFAULT_CONSOLIDATION_FAILURES, DEFAULT_CURATOR_BOOT_GRACE_SECONDS, DEFAULT_CURATOR_INTERVAL_HOURS, DEFAULT_CURATOR_MODEL, DEFAULT_CURATOR_REVIEW_MAX_TOKENS, DEFAULT_HEALTH_THRESHOLDS, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_MIN_IDLE_HOURS, DEFAULT_MUTATION_CAP, DEFAULT_PROBE_TIMEOUT_MS, DEFAULT_REFERENCE_REWRITE_POLICY, DEFAULT_REVIEW_CONTEXT_MESSAGES, DEFAULT_REVIEW_MEMORY_INTERVAL, DEFAULT_REVIEW_MESSAGE_CHARS, DEFAULT_REVIEW_SKILL_INTERVAL, DEFAULT_REVIEW_TIMEOUT_MS, DEFAULT_RUN_RECORDS, DEFAULT_SKILL_CONTENT_CHARS, DEFAULT_SKILL_LIMITS, DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, DEFAULT_SKILL_REVIEW_TRIGGER, DEFAULT_SKILL_VERSION_KEEP, DEFAULT_STALE_AFTER_DAYS, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, DEFAULT_SUPPORT_FILE_CHAR_POLICY, DEFAULT_SUPPORT_READ_TOOL_NAMES, DEFAULT_THREAT_MAX_SCAN_CHARS, DEFAULT_USER_CHAR_LIMIT, DEFAULT_WRITE_CONFIRM_MODE, DEFAULT_WRITE_CONFIRM_TIMEOUT_SECONDS, DIAGNOSTICS_FACT_KEYS, DIAGNOSTICS_RUNTIME_KEYS, DIAGNOSTICS_VIEW_SCHEMA_VERSION, DISPATCH_EVENT_TYPES, DRIFT_MAX_LINE_CHARS, DRIFT_SIGNALS_VERSION, DRIFT_SIGNAL_NOUNS, DSH_AUTHORING_STANDARDS, ENTRY_DELIMITER, EVENT_ARCHIVE_PREFIX, EVENT_LOG_RETAIN_ARCHIVES, EVENT_LOG_ROTATE_AT, EVENT_LOG_VERSION, EVOLUTION_ERRORS, EVOLUTION_PRESET_IDS, EVOLUTION_WRITE_TOOLS, EXTRACT_PROMPT_HASH, EXTRACT_PROMPT_V1, EXTRACT_PROMPT_VERSION, EvolutionGateSet, FAMILY_SESSION_TOOL_NAMES, FORBIDDEN_CONTROL_KEYS, FUZZY_MAX_PATTERN_CHARS, FUZZY_MAX_WORK, HEALTH_STAMP_RE, HISTORY_DIR, HISTORY_INDEX_VERSION, HOOK_LINE_RE, HOST_ROUTES, INSTANCE_KEYS, KEEP_LINE_RE, LONG_RUNS, LOW_QUALITY_THRESHOLD, MAINTAINER_PRESET_ID, MAINTAIN_OUTPUT_INSTRUCTION, MAINTAIN_PROMPT, MAX_DESCRIPTION_LENGTH, MAX_REQUEST_BODY_BYTES, MAX_RESTRUCTURE_MOVES, MAX_SKILL_CONTENT_CHARS, MAX_SKILL_FILE_BYTES, MAX_SKILL_NAME_LENGTH, MAX_SUPPORT_READ_PATHS, MAX_TIMER_DELAY_MS, MEMORY_GUIDANCE_SECTION_ORDER, MEMORY_REVIEW_PROMPT, MIN_STAMP_BODY_CHARS, MODEL_SESSION_EVENT_TYPES as MODEL_SESSION_EVENTS, MODEL_SESSION_EVENT_TYPES, MUTATIONS_FILE_VERSION, MemoryStore, MutationUnit, NAMESPACE_MIGRATIONS, NATIVE_CALL_EVENT, NATIVE_RESULT_EVENT, PARAM_ALIASES, PARAM_EXPOSURE, PARAM_GROUP_LABELS, PARAM_NAMESPACES, PATTERN_OVERLAP, PLATFORM_CATALOG_DESCRIPTION_DEFAULT, PLATFORM_ESTIMATE_CHARS_PER_TOKEN, PLATFORM_LINE, PLATFORM_SERVICE_PROBES, POLICY_STAGE_DEFAULTS, PROMPT_BUNDLE, PROMPT_BUNDLE_ID, PROMPT_BUNDLE_VERSION, PROTECTED_BUILTIN_SKILLS, PTC_DISPATCH_EVENT, PTC_DISPATCH_START_EVENT, QUALITY_WEIGHTS, READ_REQUIRED_ACTIONS, RESTRICTED_PRESET_DISPLAY, RESTRICTED_TOOLS_ROW_ID, RESTRICTOR_MODULE, RESTRUCTURE_TARGET_RE, RETENTION_FEEDBACK_KEEP_RATIO, RETENTION_FEEDBACK_MIN_CHARS, REVIEWER_PRESET_ID, RULES, RUNS_SCHEMA_VERSION, SKILLS_GUIDANCE, SKILLS_GUIDANCE_SECTION_ORDER, SKILL_ACTION_REQUIRED_FIELDS, SKILL_NAME_RE, SKILL_REVIEW_PLAN_PROMPT, SKILL_REVIEW_PROMPT, SNAPSHOT_EXTRA_NAME_RE, STORE_LEDGER, SUMMARY_DUPLICATE_HINT_THRESHOLD, SUPPORT_DIRS, SUPPORT_SPRAWL_FILES, SUPPRESSED_FILE_VERSION, SkillLibrary, SkillModel, TEXT_DIFF_MAX_CHARS, TEXT_DIFF_MAX_LINES, THREAT_EXEMPTION_HINT, TOKEN_ASCII_WEIGHT, TOKEN_CJK_WEIGHT, ToolDispatchNormalizer, ToolDispatchPayloadError, UNIT_JOURNAL_PHASES, UNIT_JOURNAL_SCHEMA_VERSION, UNIT_STORAGE_SCHEMA_VERSION, UNTRUSTED_LINE_BREAK, UNTRUSTED_LINE_MARK, UPSTREAM_LIMIT_CHARS_PER_TOKEN, UnitTransactions, VERSION_SUMMARY_MAX_CHARS, WriteKernel, absentHostServices, acquireTreeWriteLock, admissionVerdict, advanceReview, affinity, ageCopyKey, allowRowCollisions, anchorVerdict, appendEvolutionEvent, applyCuratorLifecycleFields, applyCuratorMetaFields, applyNamespaceMigration, applyReferenceRewrite, asRecord, assertDispatchPayload, assertSkillsRootAliasRetired, assertUnitJournalTransition, assessStructureHealth, atomicWriteFiles, authoringFeedback, authorityFrom, backupsReachability, blobPath, bodyCost, buildCuratorRunReport, buildExtractPlanFromLibrary, buildHealthBaseline, buildLearnPrompt, bumpPatch, bumpSupportRead, bumpUse, bumpView, callingScope, candidateSkills, canonicalWriteId, claimInstance, clampOnce, clampedNumber, classifyNamespaceMigration, classifySessionEvent, clearReviewChannel, collectReadSkillNames, collectReadSupportFiles, computeDedupGroups, computeDriftSignals, computeLifecycleTransitions, computePrefixClusters, computeQualityScores, computeScopeView, contentHash, contentRetentionFeedback, countDispatches, countReferenceFiles, createGateSet, createSubagentChannel, daysSinceIso, declaredReportStamp, describeReferenceRewrite, diffFindings, dispatchKeyOf, dispatchPathOf, dispatchStepOf, displayBodyOf, duplicateHeadings, elapsedSince, emptyRecord, ensureSkillFrontmatter, entryTarget, errorText, evaluateThreat, eventsFile, evidenceKindIndex, evolutionActivityProjection, evolutionEventPayloadIssue, evolutionEvidenceProjection, evolutionHome, evolutionIoAdapter, evolutionProjectionHistoryProjection, evolutionReadsProjection, evolutionRoot, evolutionSignalsProjection, executeUnitUndo, externalRefs, fileMutationLock, filterUnreadSkillOps, findDriftSignal, findOwnerCandidate, foldCuratorFields, foldToolDispatches, foldTurnEvent, foldTurnEvents, foldUntrustedLines, frontmatterBlock, frontmatterCatalogInvalid, fuzzyPatch, getRecord, h2Sections, historyIndexFile, historyReachability, historyRoot, hostSurface, identity, idleDays, initialTurnFold, installEvolutionProjections, instanceClaimKey, instanceClaimedWriteSites, instanceHolder, isAbsent, isBookkeepingFrame, isCommittedWarning, isDeprecatedParamId, isFileShapedPath, isIgnorableEvent, isLandmark, isMissingPath, isPresent, isProcessAlive, isProgramToolName, isProjectableSession, isRecord, isReviewChannelSession, isSkillReadToolName, isSkillToolName, isUnknown, isUnreadWrite, json, landmarkVerdict, latestActivityAt, latestVersionAt, lifecycleCandidate, lintBody, lintSkill, listEventArchives, liveBool, liveEnum, liveNumber, liveString, loadMutations, loadSuppressedNames, loadUsage, loadVersionContent, loadVersions, makeSerialQueue, mapProbe, markAgentCreated, markReviewChannel, markerEntryName, memoryRoot, methodNotAllowed, missingSupportPointers, mutateUsage, mutationsFile, narrowNameMatches, nearDuplicateSummaries, newRunRegistry, newSkillLibrary, nextHistoryIndex, nodeEvolutionIo, normalizeFrontmatter, normalizeUsageRecord, normalizeVersionSummary, observeEvent, orderVersions, overlongLines, ownerCandidatesFromSummaries, ownerDecisionText, paramNamespace, paramRowId, paramSettingsId, parseCuratorNominations, parseEvolutionEvents, parseFrontmatter, parseHistoryIndex, partitionVersions, payloadText, persistedWriteSite, persistedWriteSites, pickWithPolicy, planExtract, planNamespaceMigration, planReferenceRewrite, planRehoming, planUnitUndoAcross, policyStageLimits, probeAbsent, probeChannelState, probeList, probeMtime, probePresent, probeReason, probeText, probeUnknown, projectExtractBodies, projectionText, proposalFromPlan, proposalReportDir, proposalReportName, protectedSkillNamesOf, pruneTreeChangeUnits, readDispatchSignal, readEvolutionEvents, readEvolutionTimeline, readExternalSupport, readHistoryIndex, readJsonObject, readNumberParam, readParam, readProposalReports, readTreeLock, readUnitEvidence, readUnitIndex, readUnitJournal, readUnitReceipt, readUnitSnapshot, readingStats, recordMutation, recordVersions, redactSecrets, referencedBlobs, registerHostRoutes, registerOwnerSettings, relatedSkillNames, releaseInstance, renameWithRetry, renderCuratorReportMarkdown, renderLongRunTable, reportTime, reportsReachability, reportsSweepLockTarget, resolveCitations, resolveExecOrigins, resolveOrigins, resolveParamId, resolveRootConfig, resolveSkillsRoot, resolveUnitMembers, resolveUnitMembersFromIndexes, restructureCandidates, retainEventArchives, retirementReport, reviewPrompt, revisionAnchor, revisionAnchorOf, revisionFingerprint, revisionSupportDigest, runWriteGates, runsFile, saveSuppressedNames, saveUsage, scanBodyHooks, scanContentThreats, scanMemoryThreats, scanThreats, scopeOfNearestManifest, scopedPackageName, scopedProbeReport, selectSections, sessionAudited, sessionEvidenceIndex, sessionLastEventTime, sessionReadNames, sessionReadSkillNames, sessionReadSupportFiles, sessionSeesFamilyTools, sessionTurnSignals, skillLibraryUnitBackend, skillReadNameOf, skillRowCells, skillStateKey, skillWriteGateContext, skillsRoot, staleRouteStubs, subagentChannelState, supportFileReadFromPath, supportFileReadOf, supportRefs, suppressedFile, sweepReports, sweepReviewChannelSessions, textDiffFacts, tokenLineFor, transactIo, transactTaskGuard, treeLockFile, trimPatternBoundaries, unhookedSupportPointers, unitEvidenceDigest, unitEvidencePath, unitIndexPath, unitJournalPath, unitJournalPhaseRank, unitJournalPort, unitMembersAreComplete, unitReceiptPath, unitSnapshotPath, unitSnapshotPort, unitSnapshotsDir, unitStorageKey, unwrapLive, updateSuppressedNames, upsertUnitIndex, usageFile, usageObserved, userSetKeys, validateFrontmatter, validateMutationRequest, validateRestructureTarget, validateSupportPath, valueOr, verifyPromptBundle, versionActionKind, versionRowCells, versionSummaryPrompt, versionTarget, vocabulary, withTreeWrite, withTreeWriteLock, writeDurableTmp, writePathSymbols, writeProposalReport, writeUnitEvidence, writeUnitJournal, writeUnitReceipt, writeUnitSnapshot, yamlPlainScalarNeedsQuotes };
17409
+ export { AUTHORING_DESCRIPTION_BAR, AUTHORING_SPLIT_LINE_CHARS, BASELINE_ACTION, CITATION_SUPPORT_DIRS, COMBINED_REVIEW_PLAN_PROMPT, COMBINED_REVIEW_PROMPT, COMPLETION_SKILL_REVIEW_PROMPT, CONTENT_SPLIT_HINT, COST_ASCII_TOKEN_HIGH, COST_ASCII_TOKEN_LOW, COST_CJK_TOKEN_HIGH, COST_CJK_TOKEN_LOW, CURATOR_DRY_RUN_BANNER, CURATOR_PROMPT, DEDUP_MAX_PAIR_COMPARISONS, DEDUP_SIMILARITY_THRESHOLD, DEFAULT_ADMISSION, DEFAULT_ARCHIVE_AFTER_DAYS, DEFAULT_ARCHIVE_RETENTION_POLICY, DEFAULT_CITATION_POLICY, DEFAULT_CITATION_REF_BUDGET, DEFAULT_CONSOLIDATION_FAILURES, DEFAULT_CURATOR_BOOT_GRACE_SECONDS, DEFAULT_CURATOR_INTERVAL_HOURS, DEFAULT_CURATOR_MODEL, DEFAULT_CURATOR_REVIEW_MAX_TOKENS, DEFAULT_HEALTH_THRESHOLDS, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_MIN_IDLE_HOURS, DEFAULT_MUTATION_CAP, DEFAULT_PROBE_TIMEOUT_MS, DEFAULT_REFERENCE_REWRITE_POLICY, DEFAULT_REVIEW_CONTEXT_MESSAGES, DEFAULT_REVIEW_MEMORY_INTERVAL, DEFAULT_REVIEW_MESSAGE_CHARS, DEFAULT_REVIEW_SKILL_INTERVAL, DEFAULT_REVIEW_TIMEOUT_MS, DEFAULT_RUN_RECORDS, DEFAULT_SKILL_CONTENT_CHARS, DEFAULT_SKILL_LIMITS, DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, DEFAULT_SKILL_REVIEW_TRIGGER, DEFAULT_SKILL_VERSION_KEEP, DEFAULT_STALE_AFTER_DAYS, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, DEFAULT_SUPPORT_FILE_CHAR_POLICY, DEFAULT_SUPPORT_READ_TOOL_NAMES, DEFAULT_THREAT_MAX_SCAN_CHARS, DEFAULT_USER_CHAR_LIMIT, DEFAULT_WRITE_CONFIRM_MODE, DEFAULT_WRITE_CONFIRM_TIMEOUT_SECONDS, DIAGNOSTICS_FACT_KEYS, DIAGNOSTICS_RUNTIME_KEYS, DIAGNOSTICS_VIEW_SCHEMA_VERSION, DISPATCH_EVENT_TYPES, DRIFT_MAX_LINE_CHARS, DRIFT_SIGNALS_VERSION, DRIFT_SIGNAL_NOUNS, DSH_AUTHORING_STANDARDS, ENTRY_DELIMITER, EVENT_ARCHIVE_PREFIX, EVENT_LOG_RETAIN_ARCHIVES, EVENT_LOG_ROTATE_AT, EVENT_LOG_VERSION, EVOLUTION_ERRORS, EVOLUTION_PRESET_IDS, EVOLUTION_WRITE_TOOLS, EXTRACT_PROMPT_HASH, EXTRACT_PROMPT_V1, EXTRACT_PROMPT_VERSION, EvolutionGateSet, FAMILY_SESSION_TOOL_NAMES, FORBIDDEN_CONTROL_KEYS, FUZZY_MAX_PATTERN_CHARS, FUZZY_MAX_WORK, HEALTH_STAMP_RE, HISTORY_DIR, HISTORY_INDEX_VERSION, HOOK_LINE_RE, HOST_ROUTES, INSTANCE_KEYS, KEEP_LINE_RE, LONG_RUNS, LOW_QUALITY_THRESHOLD, MAINTAINER_PRESET_ID, MAINTAIN_OUTPUT_INSTRUCTION, MAINTAIN_PROMPT, MAX_DESCRIPTION_LENGTH, MAX_REQUEST_BODY_BYTES, MAX_RESTRUCTURE_MOVES, MAX_SKILL_CONTENT_CHARS, MAX_SKILL_FILE_BYTES, MAX_SKILL_NAME_LENGTH, MAX_SUPPORT_READ_PATHS, MAX_TIMER_DELAY_MS, MEMORY_GUIDANCE_SECTION_ORDER, MEMORY_REVIEW_PROMPT, MIN_STAMP_BODY_CHARS, MODEL_SESSION_EVENT_TYPES as MODEL_SESSION_EVENTS, MODEL_SESSION_EVENT_TYPES, MUTATIONS_FILE_VERSION, MemoryStore, MutationUnit, NAMESPACE_MIGRATIONS, NATIVE_CALL_EVENT, NATIVE_RESULT_EVENT, PARAM_ALIASES, PARAM_EXPOSURE, PARAM_GROUP_LABELS, PARAM_NAMESPACES, PATTERN_OVERLAP, PLATFORM_CATALOG_DESCRIPTION_DEFAULT, PLATFORM_ESTIMATE_CHARS_PER_TOKEN, PLATFORM_LINE, PLATFORM_SERVICE_PROBES, POLICY_STAGE_DEFAULTS, PROMPT_BUNDLE, PROMPT_BUNDLE_ID, PROMPT_BUNDLE_VERSION, PROTECTED_BUILTIN_SKILLS, PTC_DISPATCH_EVENT, PTC_DISPATCH_START_EVENT, QUALITY_WEIGHTS, READ_REQUIRED_ACTIONS, RESTRICTED_PRESET_DISPLAY, RESTRICTED_TOOLS_ROW_ID, RESTRICTOR_MODULE, RESTRUCTURE_TARGET_RE, RETENTION_FEEDBACK_KEEP_RATIO, RETENTION_FEEDBACK_MIN_CHARS, REVIEWER_PRESET_ID, RULES, RUNS_SCHEMA_VERSION, SKILLS_GUIDANCE, SKILLS_GUIDANCE_SECTION_ORDER, SKILL_ACTION_REQUIRED_FIELDS, SKILL_NAME_RE, SKILL_REVIEW_PLAN_PROMPT, SKILL_REVIEW_PROMPT, SNAPSHOT_EXTRA_NAME_RE, STORE_LEDGER, SUMMARY_DUPLICATE_HINT_THRESHOLD, SUPPORT_DIRS, SUPPORT_SPRAWL_FILES, SUPPRESSED_FILE_VERSION, SkillLibrary, SkillModel, TEXT_DIFF_MAX_CHARS, TEXT_DIFF_MAX_LINES, THREAT_EXEMPTION_HINT, TOKEN_ASCII_WEIGHT, TOKEN_CJK_WEIGHT, ToolDispatchNormalizer, ToolDispatchPayloadError, UNIT_JOURNAL_PHASES, UNIT_JOURNAL_SCHEMA_VERSION, UNIT_STORAGE_SCHEMA_VERSION, UNTRUSTED_LINE_BREAK, UNTRUSTED_LINE_MARK, UPSTREAM_LIMIT_CHARS_PER_TOKEN, UnitTransactions, VERSION_SUMMARY_MAX_CHARS, WriteKernel, absentHostServices, acquireTreeWriteLock, admissionVerdict, advanceReview, affinity, ageCopyKey, allowRowCollisions, anchorVerdict, appendEvolutionEvent, applyCuratorLifecycleFields, applyCuratorMetaFields, applyNamespaceMigration, applyReferenceRewrite, asRecord, assertDispatchPayload, assertSkillsRootAliasRetired, assertUnitJournalTransition, assessStructureHealth, atomicWriteFiles, authoringFeedback, authorityFrom, backupsReachability, blobPath, bodyCost, buildCuratorRunReport, buildExtractPlanFromLibrary, buildHealthBaseline, buildLearnPrompt, bumpPatch, bumpSupportRead, bumpUse, bumpView, callingScope, candidateSkills, canonicalWriteId, claimInstance, clampOnce, clampedNumber, classifyNamespaceMigration, classifySessionEvent, clearReviewChannel, collectReadSkillNames, collectReadSupportFiles, computeDedupGroups, computeDriftSignals, computeLifecycleTransitions, computePrefixClusters, computeQualityScores, computeScopeView, contentHash, contentRetentionFeedback, countDispatches, countReferenceFiles, createGateSet, createSubagentChannel, currentReviewContext, daysSinceIso, declaredReportStamp, describeReferenceRewrite, diffFindings, dispatchKeyOf, dispatchPathOf, dispatchStepOf, displayBodyOf, duplicateHeadings, elapsedSince, emptyRecord, ensureSkillFrontmatter, entryTarget, errorText, evaluateThreat, eventsFile, evidenceKindIndex, evolutionActivityProjection, evolutionEventPayloadIssue, evolutionEvidenceProjection, evolutionHome, evolutionIoAdapter, evolutionProjectionHistoryProjection, evolutionReadsProjection, evolutionRoot, evolutionSignalsProjection, executeUnitUndo, externalRefs, fileMutationLock, filterUnreadSkillOps, findDriftSignal, findOwnerCandidate, foldCuratorFields, foldToolDispatches, foldTurnEvent, foldTurnEvents, foldUntrustedLines, frontmatterBlock, frontmatterCatalogInvalid, fuzzyPatch, getRecord, h2Sections, historyIndexFile, historyReachability, historyRoot, hostSurface, identity, idleDays, initialTurnFold, instanceClaimKey, instanceClaimedWriteSites, instanceHolder, isAbsent, isBookkeepingFrame, isCommittedWarning, isDeprecatedParamId, isFileShapedPath, isIgnorableEvent, isLandmark, isMissingPath, isPresent, isProcessAlive, isProgramToolName, isProjectableSession, isRecord, isReviewChannelSession, isSkillReadToolName, isSkillToolName, isUnknown, isUnreadWrite, json, landmarkVerdict, latestActivityAt, latestVersionAt, lifecycleCandidate, lintBody, lintSkill, listEventArchives, liveBool, liveEnum, liveNumber, liveString, loadMutations, loadSuppressedNames, loadUsage, loadVersionContent, loadVersions, makeSerialQueue, mapProbe, markAgentCreated, markReviewChannel, markerEntryName, memoryRoot, methodNotAllowed, missingSupportPointers, mutateUsage, mutationsFile, narrowNameMatches, nearDuplicateSummaries, newRunRegistry, newSkillLibrary, nextHistoryIndex, nodeEvolutionIo, normalizeFrontmatter, normalizeUsageRecord, normalizeVersionSummary, observeEvent, orderVersions, overlongLines, ownerCandidatesFromSummaries, ownerDecisionText, paramNamespace, paramRowId, paramSettingsId, parseCuratorNominations, parseEvolutionEvents, parseFrontmatter, parseHistoryIndex, partitionVersions, payloadText, persistedWriteSite, persistedWriteSites, pickWithPolicy, planExtract, planNamespaceMigration, planReferenceRewrite, planRehoming, planUnitUndoAcross, policyStageLimits, probeAbsent, probeChannelState, probeList, probeMtime, probePresent, probeReason, probeText, probeUnknown, projectExtractBodies, projectionText, proposalFromPlan, proposalReportDir, proposalReportName, protectedSkillNamesOf, pruneTreeChangeUnits, readDispatchSignal, readEvolutionEvents, readEvolutionTimeline, readExternalSupport, readHistoryIndex, readJsonObject, readNumberParam, readParam, readProposalReports, readTreeLock, readUnitEvidence, readUnitIndex, readUnitJournal, readUnitReceipt, readUnitSnapshot, readingStats, recordMutation, recordVersions, redactSecrets, referencedBlobs, registerHostRoutes, registerOwnerSettings, relatedSkillNames, releaseInstance, renameWithRetry, renderCuratorReportMarkdown, renderLongRunTable, reportTime, reportsReachability, reportsSweepLockTarget, resolveCitations, resolveExecOrigins, resolveOrigins, resolveParamId, resolveRootConfig, resolveSkillsRoot, resolveUnitMembers, resolveUnitMembersFromIndexes, restructureCandidates, retainEventArchives, retirementReport, reviewPrompt, revisionAnchor, revisionAnchorOf, revisionFingerprint, revisionSupportDigest, runWriteGates, runsFile, saveSuppressedNames, saveUsage, scanBodyHooks, scanContentThreats, scanMemoryThreats, scanThreats, scopeOfNearestManifest, scopedPackageName, scopedProbeReport, selectSections, sessionAudited, sessionEvidenceIndex, sessionLastEventTime, sessionReadNames, sessionReadSkillNames, sessionReadSupportFiles, sessionSeesFamilyTools, sessionTurnSignals, skillLibraryUnitBackend, skillReadNameOf, skillRowCells, skillStateKey, skillWriteGateContext, skillsRoot, staleRouteStubs, subagentChannelState, supportFileReadFromPath, supportFileReadOf, supportRefs, suppressedFile, sweepReports, sweepReviewChannelSessions, textDiffFacts, tokenLineFor, transactIo, transactTaskGuard, treeLockFile, trimPatternBoundaries, unhookedSupportPointers, unitEvidenceDigest, unitEvidencePath, unitIndexPath, unitJournalPath, unitJournalPhaseRank, unitJournalPort, unitMembersAreComplete, unitReceiptPath, unitSnapshotPath, unitSnapshotPort, unitSnapshotsDir, unitStorageKey, unwrapLive, updateSuppressedNames, upsertUnitIndex, usageFile, usageObserved, userSetKeys, validateFrontmatter, validateMutationRequest, validateRestructureTarget, validateSupportPath, valueOr, verifyPromptBundle, versionActionKind, versionRowCells, versionSummaryPrompt, versionTarget, vocabulary, withReviewContext, withTreeWrite, withTreeWriteLock, writeDurableTmp, writePathSymbols, writeProposalReport, writeUnitEvidence, writeUnitJournal, writeUnitReceipt, writeUnitSnapshot, yamlPlainScalarNeedsQuotes };