@lmzhen/dsh-evolution-core 0.44.0 → 0.45.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 (62) hide show
  1. package/lib/authority-plugin.js +14 -0
  2. package/lib/composition/index.js +2 -2
  3. package/lib/{composition-CVafrlEw.js → composition-Da8NfRI7.js} +2 -2
  4. package/lib/contract.js +1 -0
  5. package/lib/index.js +54 -133
  6. package/lib/{mutations-jUuOPaCn.js → io-AmUf4lVY.js} +54 -84
  7. package/lib/io-node.js +24 -0
  8. package/lib/io-registry.js +96 -0
  9. package/lib/mutation-authority-DeJ_Wz14.js +537 -0
  10. package/lib/mutations-DwvbjRHF.js +75 -0
  11. package/lib/numeric-DLeLvvGb.js +324 -0
  12. package/lib/platform/index.js +1 -1
  13. package/lib/{platform-B06_h8t-.js → platform-CFA12Jam.js} +36 -19
  14. package/lib/policy.js +99 -0
  15. package/lib/runtime/plugin.js +8 -1
  16. package/lib/{skill-health-BLGZTIv8.js → skill-health-D1pZGk5V.js} +6 -835
  17. package/lib/{skill-history-_Cssts5o.js → skill-history-CjypdYqv.js} +2 -1
  18. package/lib/skills.js +6 -3
  19. package/lib/subagent/index.js +1 -1
  20. package/lib/types/authority-plugin.d.ts +12 -0
  21. package/lib/types/authority-plugin.js +10 -0
  22. package/lib/types/authority.d.ts +96 -0
  23. package/lib/types/authority.js +237 -0
  24. package/lib/types/contract.d.ts +116 -0
  25. package/lib/types/contract.js +10 -0
  26. package/lib/types/events.d.ts +2 -2
  27. package/lib/types/home-fence.d.ts +25 -17
  28. package/lib/types/home-fence.js +42 -92
  29. package/lib/types/index.d.ts +2 -2
  30. package/lib/types/index.js +2 -2
  31. package/lib/types/io-node.d.ts +15 -0
  32. package/lib/types/io-node.js +36 -0
  33. package/lib/types/io-registry.d.ts +71 -0
  34. package/lib/types/io-registry.js +126 -0
  35. package/lib/types/io.d.ts +29 -2
  36. package/lib/types/io.js +50 -9
  37. package/lib/types/journal-protocol.d.ts +35 -0
  38. package/lib/types/journal-protocol.js +29 -0
  39. package/lib/types/lease-store.d.ts +1 -1
  40. package/lib/types/mutation-unit.d.ts +1 -1
  41. package/lib/types/params.d.ts +2 -16
  42. package/lib/types/params.js +6 -44
  43. package/lib/types/platform/llm.js +4 -1
  44. package/lib/types/platform/projections.d.ts +10 -4
  45. package/lib/types/platform/projections.js +34 -17
  46. package/lib/types/platform-services.d.ts +2 -2
  47. package/lib/types/policy.d.ts +68 -0
  48. package/lib/types/policy.js +161 -0
  49. package/lib/types/run-registry.d.ts +2 -2
  50. package/lib/types/runtime/projections.js +12 -0
  51. package/lib/types/state-store.d.ts +1 -1
  52. package/lib/types/state-store.js +1 -1
  53. package/lib/types/store-ledger.js +2 -2
  54. package/lib/types/write-inventory.js +3 -1
  55. package/lib/write.js +2 -2
  56. package/package.json +25 -4
  57. package/persisted-write-inventory.json +10 -37
  58. package/lib/types/home-owner.d.ts +0 -4
  59. package/lib/types/home-owner.js +0 -37
  60. package/lib/types/tree-lock.d.ts +0 -54
  61. package/lib/types/tree-lock.js +0 -127
  62. package/lib/{ensure-BjToTMMj.js → ensure-C5Mo1dbB.js} +1 -1
@@ -0,0 +1,14 @@
1
+ import { c as evolutionHome, t as MutationAuthority } from "./mutation-authority-DeJ_Wz14.js";
2
+ //#region lib/types/authority-plugin.js
3
+ const name = "evolution-authority";
4
+ const inject = ["evolutionIo"];
5
+ /** Expose the single home/run-fenced mutation authority to domain packages. */
6
+ function apply(ctx) {
7
+ const authority = new MutationAuthority({
8
+ io: ctx.evolutionIo.provider(),
9
+ home: evolutionHome()
10
+ });
11
+ ctx.provide("evolutionMutationAuthority", authority);
12
+ }
13
+ //#endregion
14
+ export { apply, inject, name };
@@ -1,3 +1,3 @@
1
- import { a as entryListSchema, c as MAINTAINER_PRESET_ID, d as RESTRICTED_TOOLS_ROW_ID, f as RESTRICTOR_MODULE, h as restrictedPresetId, i as composeRestrictedPresetDefinition, l as RESTRICTED_PRESET_DELIVERY, m as normalizeAllow, n as ensureRestrictedPreset, o as parsePresetRows, p as REVIEWER_PRESET_ID, r as restrictedPresetState, s as EVOLUTION_PRESET_IDS, t as disposeRestrictedPreset, u as RESTRICTED_PRESET_DISPLAY } from "../ensure-BjToTMMj.js";
2
- import { C as trimTrailingBlankLines, S as rowSiblingEnd, _ as presetRowId, a as composePresetComposition, b as resolveBasePresetPatch, c as composePresetRow, d as listDirectories, f as loadRowOverrides, g as presetRowBody, h as presetRowBlock, i as basePresetPlugins, l as compositionRowIds, m as presetPatchText, n as AGENT_PRESET_ROOT_HINT, o as composePresetEntry, p as mergePresetRow, r as EMPTY_PATCH_SEED, s as composePresetInsert, t as AGENT_PRESET_PACKAGE, u as denseBlockSequence, v as probeDesktopScope, x as rowBlockSpan, y as removePresetRow } from "../composition-CVafrlEw.js";
1
+ import { a as entryListSchema, c as MAINTAINER_PRESET_ID, d as RESTRICTED_TOOLS_ROW_ID, f as RESTRICTOR_MODULE, h as restrictedPresetId, i as composeRestrictedPresetDefinition, l as RESTRICTED_PRESET_DELIVERY, m as normalizeAllow, n as ensureRestrictedPreset, o as parsePresetRows, p as REVIEWER_PRESET_ID, r as restrictedPresetState, s as EVOLUTION_PRESET_IDS, t as disposeRestrictedPreset, u as RESTRICTED_PRESET_DISPLAY } from "../ensure-C5Mo1dbB.js";
2
+ import { C as trimTrailingBlankLines, S as rowSiblingEnd, _ as presetRowId, a as composePresetComposition, b as resolveBasePresetPatch, c as composePresetRow, d as listDirectories, f as loadRowOverrides, g as presetRowBody, h as presetRowBlock, i as basePresetPlugins, l as compositionRowIds, m as presetPatchText, n as AGENT_PRESET_ROOT_HINT, o as composePresetEntry, p as mergePresetRow, r as EMPTY_PATCH_SEED, s as composePresetInsert, t as AGENT_PRESET_PACKAGE, u as denseBlockSequence, v as probeDesktopScope, x as rowBlockSpan, y as removePresetRow } from "../composition-Da8NfRI7.js";
3
3
  export { AGENT_PRESET_PACKAGE, AGENT_PRESET_ROOT_HINT, EMPTY_PATCH_SEED, EVOLUTION_PRESET_IDS, MAINTAINER_PRESET_ID, RESTRICTED_PRESET_DELIVERY, RESTRICTED_PRESET_DISPLAY, RESTRICTED_TOOLS_ROW_ID, RESTRICTOR_MODULE, REVIEWER_PRESET_ID, basePresetPlugins, composePresetComposition, composePresetEntry, composePresetInsert, composePresetRow, composeRestrictedPresetDefinition, compositionRowIds, denseBlockSequence, disposeRestrictedPreset, ensureRestrictedPreset, entryListSchema, listDirectories, loadRowOverrides, mergePresetRow, normalizeAllow, parsePresetRows, presetPatchText, presetRowBlock, presetRowBody, presetRowId, probeDesktopScope, removePresetRow, resolveBasePresetPatch, restrictedPresetId, restrictedPresetState, rowBlockSpan, rowSiblingEnd, trimTrailingBlankLines };
@@ -1,6 +1,6 @@
1
- import { _ as scopedPackageName } from "./ensure-BjToTMMj.js";
2
- import { existsSync, readFileSync, readdirSync } from "node:fs";
1
+ import { _ as scopedPackageName } from "./ensure-C5Mo1dbB.js";
3
2
  import { dirname, join } from "node:path";
3
+ import { existsSync, readFileSync, readdirSync } from "node:fs";
4
4
  import { fileURLToPath } from "node:url";
5
5
  //#region lib/types/env.js
6
6
  /**
@@ -0,0 +1 @@
1
+ export {};
package/lib/index.js CHANGED
@@ -1,19 +1,52 @@
1
+ import { C as probeUnknown, S as probeText, T as valueOr, _ as probeAbsent, a as nodeEvolutionIo, b as probePresent, c as transactOutcome, d as declaredReportStamp, f as isAbsent, g as mapProbe, h as isUnknown, i as isProcessAlive, l as transactTaskGuard, m as isPresent, n as evolutionIoAdapter, o as renameWithRetry, p as isMissingPath, r as isCommittedWarning, s as transactIo, t as atomicWriteFiles, u as writeDurableTmp, v as probeList, w as reportTime, x as probeReason, y as probeMtime } from "./io-AmUf4lVY.js";
2
+ import { a as leaseFile, c as evolutionHome, d as AuthorityOrderError, f as AuthorityReentryError, h as leaseAsTreeLock, i as LeaseStore, l as evolutionRoot, m as authorityHolder, n as mutationLockFrom, o as HomeFence, p as HomeAuthority, r as DEFAULT_LEASE_TTL_MS, s as HomeFenceError, t as MutationAuthority, u as AuthorityBusyError } from "./mutation-authority-DeJ_Wz14.js";
1
3
  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 isBookkeepingFrame, a as evolutionSignalsProjection, b as MODEL_SESSION_EVENT_TYPES, c as sessionLastEventTime, d as advanceReview, f as foldTurnEvent, g as evidenceKindIndex, h as observeEvent, i as evolutionReadsProjection, j as dispatchKeyOf, k as collectReadSupportFiles, l as sessionReadNames, m as initialTurnFold, n as evolutionEvidenceProjection, o as isProjectableSession, p as foldTurnEvents, 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-EB7mUOlJ.js";
2
- import { $ as COST_ASCII_TOKEN_LOW, $n as MAX_TIMER_DELAY_MS, $t as supportRefs, A as clampedNumber, An as DEFAULT_PROBE_TIMEOUT_MS, At as updateSuppressedNames, B as appendEvolutionEvent, Bn as DEFAULT_STALE_AFTER_DAYS, C as sweepReviewChannelSessions, Cn as DEFAULT_CONSOLIDATION_FAILURES, Ct as loadUsage, D as scanContentThreats, Dn as DEFAULT_CURATOR_REVIEW_MAX_TOKENS, Dt as saveSuppressedNames, E as evaluateThreat, En as DEFAULT_CURATOR_MODEL, Et as normalizeUsageRecord, F as trimPatternBoundaries, Fn as DEFAULT_REVIEW_TIMEOUT_MS, Ft as selectSections, G as readEvolutionEvents, Gn as DEFAULT_USER_CHAR_LIMIT, H as evolutionEventPayloadIssue, Hn as DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, I as EVENT_ARCHIVE_PREFIX, In as DEFAULT_SKILL_CONTENT_CHARS, It as displayBodyOf, J as RULES, Jn as FORBIDDEN_CONTROL_KEYS, K as readEvolutionTimeline, Kn as ENTRY_DELIMITER, Kt as parseFrontmatter, L as EVENT_LOG_RETAIN_ARCHIVES, Ln as DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, Lt as h2Sections, M as FUZZY_MAX_PATTERN_CHARS, Mn as DEFAULT_REVIEW_MEMORY_INTERVAL, Mt as usageObserved, N as FUZZY_MAX_WORK, Nn as DEFAULT_REVIEW_MESSAGE_CHARS, Nt as planExtract, O as scanMemoryThreats, On as DEFAULT_MEMORY_CHAR_LIMIT, Ot as saveUsage, P as fuzzyPatch, Pn as DEFAULT_REVIEW_SKILL_INTERVAL, Pt as projectExtractBodies, Q as COST_ASCII_TOKEN_HIGH, Qn as MAX_SKILL_NAME_LENGTH, Qt as externalRefs, R as EVENT_LOG_ROTATE_AT, Rn as DEFAULT_SKILL_REVIEW_TRIGGER, Rt as readingStats, S as markReviewChannel, Sn as DEFAULT_ARCHIVE_AFTER_DAYS, St as loadSuppressedNames, T as THREAT_EXEMPTION_HINT, Tn as DEFAULT_CURATOR_INTERVAL_HOURS, Tt as mutateUsage, U as listEventArchives, Un as DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, V as eventsFile, Vn as DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, W as parseEvolutionEvents, Wn as DEFAULT_THREAT_MAX_SCAN_CHARS, Xn as MAX_SKILL_CONTENT_CHARS, Yn as MAX_DESCRIPTION_LENGTH, Z as lintSkill, Zn as MAX_SKILL_FILE_BYTES, _ as withTreeWriteLock, _n as POLICY_STAGE_DEFAULTS, _t as emptyRecord, ar as SKILL_ACTION_REQUIRED_FIELDS, at as tokenLineFor, b as clearReviewChannel, bn as AUTHORING_SPLIT_LINE_CHARS, bt as idleDays, c as DEFAULT_LEASE_TTL_MS, cr as SUPPORT_SPRAWL_FILES, ct as MAX_SUPPORT_READ_PATHS, d as HomeFence, dn as authorityFrom, dt as applyCuratorMetaFields, en as applyReferenceRewrite, er as MEMORY_GUIDANCE_SECTION_ORDER, et as COST_CJK_TOKEN_HIGH, f as HomeFenceError, fn as DEFAULT_ARCHIVE_RETENTION_POLICY, ft as bumpPatch, g as treeLockFile, gn as DEFAULT_SUPPORT_FILE_CHAR_POLICY, gt as daysSinceIso, h as readTreeLock, hn as DEFAULT_SKILL_LIMITS, ht as bumpView, i as assessStructureHealth, ir as SKILLS_GUIDANCE_SECTION_ORDER, it as bodyCost, j as makeSerialQueue, jn as DEFAULT_REVIEW_CONTEXT_MESSAGES, jt as usageFile, k as scanThreats, kn as DEFAULT_MIN_IDLE_HOURS, kt as suppressedFile, l as LeaseStore, ln as DEFAULT_WRITE_CONFIRM_MODE, lr as UPSTREAM_LIMIT_CHARS_PER_TOKEN, lt as SUPPRESSED_FILE_VERSION, m as acquireTreeWriteLock, mn as DEFAULT_REFERENCE_REWRITE_POLICY, mt as bumpUse, nn as planReferenceRewrite, nr as PLATFORM_ESTIMATE_CHARS_PER_TOKEN, nt as TOKEN_ASCII_WEIGHT, o as MutationAuthority, on as isUnreadWrite, or as SKILL_NAME_RE, ot as evolutionHome, p as assertHomeOwner, pn as DEFAULT_CITATION_POLICY, pt as bumpSupportRead, q as retainEventArchives, qn as EVOLUTION_WRITE_TOOLS, rn as planRehoming, rr as PROTECTED_BUILTIN_SKILLS, rt as TOKEN_CJK_WEIGHT, s as mutationLockFrom, sr as SUPPORT_DIRS, st as evolutionRoot, t as DEFAULT_HEALTH_THRESHOLDS, tn as describeReferenceRewrite, tr as PLATFORM_CATALOG_DESCRIPTION_DEFAULT, tt as COST_CJK_TOKEN_LOW, u as leaseFile, un as DEFAULT_WRITE_CONFIRM_TIMEOUT_SECONDS, ut as applyCuratorLifecycleFields, v as currentReviewContext, vn as policyStageLimits, vt as foldCuratorFields, w as PATTERN_OVERLAP, wn as DEFAULT_CURATOR_BOOT_GRACE_SECONDS, wt as markAgentCreated, x as isReviewChannelSession, xn as CONTENT_SPLIT_HINT, xt as latestActivityAt, y as withReviewContext, yn as AUTHORING_DESCRIPTION_BAR, yt as getRecord, z as EVENT_LOG_VERSION, zn as DEFAULT_SKILL_VERSION_KEEP, zt as restructureCandidates } from "./skill-health-BLGZTIv8.js";
3
- 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-BjToTMMj.js";
4
+ import { $ as UPSTREAM_LIMIT_CHARS_PER_TOKEN, A as DEFAULT_STALE_AFTER_DAYS, B as MAX_SKILL_CONTENT_CHARS, C as DEFAULT_REVIEW_MESSAGE_CHARS, D as DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, E as DEFAULT_SKILL_CONTENT_CHARS, F as DEFAULT_USER_CHAR_LIMIT, G as PLATFORM_CATALOG_DESCRIPTION_DEFAULT, H as MAX_SKILL_NAME_LENGTH, I as ENTRY_DELIMITER, J as SKILLS_GUIDANCE_SECTION_ORDER, K as PLATFORM_ESTIMATE_CHARS_PER_TOKEN, L as EVOLUTION_WRITE_TOOLS, M as DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, N as DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, O as DEFAULT_SKILL_REVIEW_TRIGGER, P as DEFAULT_THREAT_MAX_SCAN_CHARS, Q as SUPPORT_SPRAWL_FILES, R as FORBIDDEN_CONTROL_KEYS, S as DEFAULT_REVIEW_MEMORY_INTERVAL, T as DEFAULT_REVIEW_TIMEOUT_MS, U as MAX_TIMER_DELAY_MS, V as MAX_SKILL_FILE_BYTES, W as MEMORY_GUIDANCE_SECTION_ORDER, X as SKILL_NAME_RE, Y as SKILL_ACTION_REQUIRED_FIELDS, Z as SUPPORT_DIRS, _ as DEFAULT_CURATOR_REVIEW_MAX_TOKENS, a as DEFAULT_SKILL_LIMITS, b as DEFAULT_PROBE_TIMEOUT_MS, c as policyStageLimits, d as CONTENT_SPLIT_HINT, f as DEFAULT_ARCHIVE_AFTER_DAYS, g as DEFAULT_CURATOR_MODEL, h as DEFAULT_CURATOR_INTERVAL_HOURS, i as DEFAULT_REFERENCE_REWRITE_POLICY, j as DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, k as DEFAULT_SKILL_VERSION_KEEP, l as AUTHORING_DESCRIPTION_BAR, m as DEFAULT_CURATOR_BOOT_GRACE_SECONDS, n as DEFAULT_ARCHIVE_RETENTION_POLICY, o as DEFAULT_SUPPORT_FILE_CHAR_POLICY, p as DEFAULT_CONSOLIDATION_FAILURES, q as PROTECTED_BUILTIN_SKILLS, r as DEFAULT_CITATION_POLICY, s as POLICY_STAGE_DEFAULTS, t as clampedNumber, u as AUTHORING_SPLIT_LINE_CHARS, v as DEFAULT_MEMORY_CHAR_LIMIT, w as DEFAULT_REVIEW_SKILL_INTERVAL, x as DEFAULT_REVIEW_CONTEXT_MESSAGES, y as DEFAULT_MIN_IDLE_HOURS, z as MAX_DESCRIPTION_LENGTH } from "./numeric-DLeLvvGb.js";
5
+ 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-C5Mo1dbB.js";
6
+ import { $ as bumpUse, A as listEventArchives, B as COST_ASCII_TOKEN_LOW, Bt as describeReferenceRewrite, C as EVENT_ARCHIVE_PREFIX, Ct as readingStats, D as appendEvolutionEvent, E as EVENT_LOG_VERSION, F as RULES, G as bodyCost, Gt as isUnreadWrite, H as COST_CJK_TOKEN_LOW, Ht as planRehoming, J as SUPPRESSED_FILE_VERSION, Jt as DEFAULT_WRITE_CONFIRM_MODE, K as tokenLineFor, Lt as externalRefs, M as readEvolutionEvents, N as readEvolutionTimeline, O as eventsFile, P as retainEventArchives, Q as bumpSupportRead, R as lintSkill, Rt as supportRefs, S as trimPatternBoundaries, St as h2Sections, T as EVENT_LOG_ROTATE_AT, U as TOKEN_ASCII_WEIGHT, V as COST_CJK_TOKEN_HIGH, Vt as planReferenceRewrite, W as TOKEN_CJK_WEIGHT, X as applyCuratorMetaFields, Xt as authorityFrom, Y as applyCuratorLifecycleFields, Yt as DEFAULT_WRITE_CONFIRM_TIMEOUT_SECONDS, Z as bumpPatch, _ as scanThreats, _t as usageObserved, at as idleDays, b as FUZZY_MAX_WORK, bt as selectSections, c as clearReviewChannel, ct as loadUsage, d as sweepReviewChannelSessions, dt as normalizeUsageRecord, et as bumpView, f as PATTERN_OVERLAP, ft as saveSuppressedNames, g as scanMemoryThreats, gt as usageFile, h as scanContentThreats, ht as updateSuppressedNames, i as assessStructureHealth, it as getRecord, j as parseEvolutionEvents, jt as parseFrontmatter, k as evolutionEventPayloadIssue, l as isReviewChannelSession, lt as markAgentCreated, m as evaluateThreat, mt as suppressedFile, nt as emptyRecord, o as currentReviewContext, ot as latestActivityAt, p as THREAT_EXEMPTION_HINT, pt as saveUsage, q as MAX_SUPPORT_READ_PATHS, rt as foldCuratorFields, s as withReviewContext, st as loadSuppressedNames, t as DEFAULT_HEALTH_THRESHOLDS, tt as daysSinceIso, u as markReviewChannel, ut as mutateUsage, v as makeSerialQueue, vt as planExtract, w as EVENT_LOG_RETAIN_ARCHIVES, wt as restructureCandidates, x as fuzzyPatch, xt as displayBodyOf, y as FUZZY_MAX_PATTERN_CHARS, yt as projectExtractBodies, z as COST_ASCII_TOKEN_HIGH, zt as applyReferenceRewrite } from "./skill-health-D1pZGk5V.js";
4
7
  import { i as HOST_LOCALES, n as errorText, r as errorTextIn, t as EVOLUTION_ERRORS } from "./errors-BxzLTVbS.js";
5
8
  import { n as isRecord, t as asRecord } from "./guards-3f02mnf2.js";
6
- import { A as valueOr, C as probeList, D as probeText, E as probeReason, O as probeUnknown, S as probeAbsent, T as probePresent, _ as isAbsent, a as mutationsFile, b as isUnknown, c as evolutionIoAdapter, d as nodeEvolutionIo, f as renameWithRetry, g as declaredReportStamp, h as writeDurableTmp, i as loadMutations, k as reportTime, l as isCommittedWarning, m as transactTaskGuard, n as MUTATIONS_FILE_VERSION, o as recordMutation, p as transactIo, r as contentHash, s as atomicWriteFiles, t as DEFAULT_MUTATION_CAP, u as isProcessAlive, v as isMissingPath, w as probeMtime, x as mapProbe, y as isPresent } from "./mutations-jUuOPaCn.js";
9
+ import { a as mutationsFile, i as loadMutations, n as MUTATIONS_FILE_VERSION, o as recordMutation, r as contentHash, t as DEFAULT_MUTATION_CAP } from "./mutations-DwvbjRHF.js";
7
10
  import { HOST_ROUTES, MAX_REQUEST_BODY_BYTES, hostSurface, json, methodNotAllowed, readJsonObject, registerHostRoutes } from "./http-routes.js";
8
- import { w as allowRowCollisions } from "./composition-CVafrlEw.js";
9
- import { u as scopeOf } from "./platform-B06_h8t-.js";
11
+ import { w as allowRowCollisions } from "./composition-Da8NfRI7.js";
12
+ import { u as scopeOf } from "./platform-CFA12Jam.js";
10
13
  import { createSubagentChannel, probeChannelState, subagentChannelState } from "./subagent/index.js";
11
- import { readFileSync } from "node:fs";
14
+ import { readFile, realpath, stat } from "node:fs/promises";
12
15
  import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
16
+ import { readFileSync } from "node:fs";
17
+ import { createHash, randomUUID } from "node:crypto";
13
18
  import { fileURLToPath } from "node:url";
14
19
  import { parse } from "yaml";
15
- import { createHash, randomUUID } from "node:crypto";
16
- import { readFile, realpath, stat } from "node:fs/promises";
20
+ //#region lib/types/journal-protocol.js
21
+ /**
22
+ * A journal protocol: the phases one multi-write operation records, which transitions it allows, and
23
+ * what a restart may do from each phase (W9-commit-protocol §3.1).
24
+ *
25
+ * The commit and undo journals used to disagree: commit had a transition table and a recovery
26
+ * decision but only reported it, while undo wrote a journal nobody read. Both now describe the same
27
+ * shape, so a resumer can be written once against `JournalProtocol` instead of per operation.
28
+ * @module @lmzhen/dsh-evolution-core/journal-protocol
29
+ */
30
+ /**
31
+ * True when `from` may advance to `to`.
32
+ * @param protocol - the journal's protocol.
33
+ * @param from - the recorded phase.
34
+ * @param to - the phase the caller wants to record next.
35
+ * @returns whether the transition is declared.
36
+ */
37
+ function canAdvance(protocol, from, to) {
38
+ return protocol.next[from].includes(to);
39
+ }
40
+ /**
41
+ * True when the phase is terminal (nothing may follow it).
42
+ * @param protocol - the journal's protocol.
43
+ * @param phase - the phase to test.
44
+ * @returns whether the phase is terminal.
45
+ */
46
+ function isTerminal(protocol, phase) {
47
+ return protocol.next[phase].length === 0;
48
+ }
49
+ //#endregion
17
50
  //#region lib/types/tree-write.js
18
51
  /**
19
52
  * G1/1.5 (S7-09): the TYPED critical section around a tree write.
@@ -3522,7 +3555,8 @@ const SITES_URL = new URL("../persisted-write-inventory.json", import.meta.url);
3522
3555
  const SERIALIZATIONS = [
3523
3556
  "transact",
3524
3557
  "write-lock",
3525
- "instance-claim"
3558
+ "instance-claim",
3559
+ "platform-file-lock"
3526
3560
  ];
3527
3561
  /** Parse + validate the table. A malformed table throws at import: a table the
3528
3562
  * gate cannot read must never degrade into "no declared write sites". */
@@ -3978,7 +4012,7 @@ const STORE_LEDGER = [
3978
4012
  artifact: "resolved record count",
3979
4013
  declare: [{
3980
4014
  kind: "named",
3981
- module: "evolution-state-storage/src/constants.ts",
4015
+ module: "evolution-state/src/constants.ts",
3982
4016
  name: "PENDING_RESOLVED_CAP",
3983
4017
  value: 200
3984
4018
  }]
@@ -3993,7 +4027,7 @@ const STORE_LEDGER = [
3993
4027
  artifact: "review state row count",
3994
4028
  declare: [{
3995
4029
  kind: "named",
3996
- module: "evolution-state-storage/src/constants.ts",
4030
+ module: "evolution-state/src/constants.ts",
3997
4031
  name: "REVIEW_STATE_SESSION_CAP",
3998
4032
  value: 500
3999
4033
  }]
@@ -4414,17 +4448,6 @@ const PARAM_EXPOSURE = Object.freeze([
4414
4448
  values: "",
4415
4449
  card: "evolution-review"
4416
4450
  },
4417
- {
4418
- id: "reviewProvider",
4419
- group: "review",
4420
- tier: "E2",
4421
- authority: "cordis",
4422
- owner: "evolution-review",
4423
- applies: "none",
4424
- docAnchor: "PARAMETERS.md#review",
4425
- summary: "LLM provider for review subagents (deployment identity).",
4426
- why: "identity"
4427
- },
4428
4451
  {
4429
4452
  id: "reviewTimeoutMs",
4430
4453
  group: "review",
@@ -4436,50 +4459,6 @@ const PARAM_EXPOSURE = Object.freeze([
4436
4459
  summary: "Bound on one review subagent run and its write leg.",
4437
4460
  why: "internal"
4438
4461
  },
4439
- {
4440
- id: "reviewContextMessages",
4441
- group: "review",
4442
- tier: "E2",
4443
- authority: "cordis",
4444
- owner: "evolution-review",
4445
- applies: "none",
4446
- docAnchor: "PARAMETERS.md#review",
4447
- summary: "Messages of context handed to a review subagent.",
4448
- why: "internal"
4449
- },
4450
- {
4451
- id: "reviewMessageChars",
4452
- group: "review",
4453
- tier: "E2",
4454
- authority: "cordis",
4455
- owner: "evolution-review",
4456
- applies: "none",
4457
- docAnchor: "PARAMETERS.md#review",
4458
- summary: "Per-message character budget of the review context.",
4459
- why: "internal"
4460
- },
4461
- {
4462
- id: "reviewMaxDepth",
4463
- group: "review",
4464
- tier: "E2",
4465
- authority: "cordis",
4466
- owner: "evolution-review",
4467
- applies: "none",
4468
- docAnchor: "PARAMETERS.md#review",
4469
- summary: "Absolute delegation-depth cap of the review subagent.",
4470
- why: "internal"
4471
- },
4472
- {
4473
- id: "reviewToolAllow",
4474
- group: "review",
4475
- tier: "E2",
4476
- authority: "cordis",
4477
- owner: "evolution-review",
4478
- applies: "none",
4479
- docAnchor: "PARAMETERS.md#review",
4480
- summary: "Tools the review subagent may use (safety surface).",
4481
- why: "security"
4482
- },
4483
4462
  {
4484
4463
  id: "skillContentChars",
4485
4464
  group: "write-caps",
@@ -5015,7 +4994,7 @@ const PARAM_EXPOSURE = Object.freeze([
5015
4994
  group: "library",
5016
4995
  tier: "E2",
5017
4996
  authority: "cordis",
5018
- owner: "evolution-curator",
4997
+ owner: "evolution-core",
5019
4998
  applies: "none",
5020
4999
  docAnchor: "PARAMETERS.md#library",
5021
5000
  summary: "Skills the lifecycle never archives or rewrites.",
@@ -5252,17 +5231,6 @@ const PARAM_EXPOSURE = Object.freeze([
5252
5231
  summary: "Directory holding the family event log the usage store reads.",
5253
5232
  why: "path"
5254
5233
  },
5255
- {
5256
- id: "evolution-state-json.root",
5257
- group: "deployment",
5258
- tier: "E1",
5259
- authority: "cordis",
5260
- owner: "evolution-state-json",
5261
- applies: "none",
5262
- docAnchor: "PARAMETERS.md#deployment",
5263
- summary: "Directory holding the JSON state store.",
5264
- why: "path"
5265
- },
5266
5234
  {
5267
5235
  id: "memory-files.root",
5268
5236
  group: "deployment",
@@ -5557,7 +5525,8 @@ const PARAM_EXPOSURE = Object.freeze([
5557
5525
  applies: "restart",
5558
5526
  docAnchor: "PARAMETERS.md#deployment",
5559
5527
  summary: "Agent-preset base the layered install composes from (--base).",
5560
- why: "install"
5528
+ why: "install",
5529
+ consumer: "basePresetPlugins"
5561
5530
  },
5562
5531
  {
5563
5532
  id: "install.home",
@@ -5579,29 +5548,8 @@ const PARAM_EXPOSURE = Object.freeze([
5579
5548
  applies: "restart",
5580
5549
  docAnchor: "PARAMETERS.md#deployment",
5581
5550
  summary: "Preset row overrides the installer injects (row-overrides.json).",
5582
- why: "install"
5583
- },
5584
- {
5585
- id: "timeout.gateDefault",
5586
- group: "deployment",
5587
- tier: "E2",
5588
- authority: "install",
5589
- owner: "scripts",
5590
- applies: "none",
5591
- docAnchor: "PARAMETERS.md#deployment",
5592
- summary: "Gate budget: the vitest --testTimeout the gate table and the CI step carry (the number lives in testing-policy.timeouts).",
5593
- why: "internal"
5594
- },
5595
- {
5596
- id: "timeout.specDefault",
5597
- group: "deployment",
5598
- tier: "E2",
5599
- authority: "install",
5600
- owner: "scripts",
5601
- applies: "none",
5602
- docAnchor: "PARAMETERS.md#deployment",
5603
- summary: "Local spec budget: the vitest testTimeout the family config generates per leaf tier (the number lives in testing-policy.timeouts).",
5604
- why: "internal"
5551
+ why: "install",
5552
+ consumer: "loadRowOverrides"
5605
5553
  },
5606
5554
  {
5607
5555
  id: "mergeApproval",
@@ -5663,42 +5611,15 @@ const PARAM_EXPOSURE = Object.freeze([
5663
5611
  why: "internal"
5664
5612
  }
5665
5613
  ]);
5666
- /**
5667
- * Register one family row's user layer on the platform settings service.
5668
- *
5669
- * The 0.2.x platform no longer turns a plugin Config into a settings section implicitly:
5670
- * every row that exposes a card must call `settings.register` with its Loader entry id.
5671
- * The owner argument is the row id, which is also the namespace the generated card binds.
5672
- * @param ctx - host plugin context.
5673
- * @param owner - Loader entry id / settings namespace.
5674
- * @param schema - the row's Config schema (schemastery).
5675
- */
5676
- function registerOwnerSettings(ctx, owner, schema) {
5677
- const register = (scope) => {
5678
- const settings = scope.settings;
5679
- if (typeof settings?.register !== "function") return;
5680
- try {
5681
- settings.register(owner, schema);
5682
- } catch (error) {
5683
- ctx.logger?.warn?.(`evolution settings: register(${owner}) failed: ${error instanceof Error ? error.message : String(error)}`);
5684
- }
5685
- };
5686
- const direct = ctx.get?.("settings");
5687
- if (direct !== void 0) {
5688
- register({ settings: direct });
5689
- return;
5690
- }
5691
- ctx.inject?.(["settings"], register);
5692
- }
5693
5614
  /** The settings namespace each OWNER PACKAGE registers (design §7.2).
5694
5615
  *
5695
- * Keyed by owner rather than by group because a namespace has exactly one
5696
- * registrant (the platform refuses a second registration of the same name),
5697
- * while a group may span packages — group 'memory' is served by memory-files and
5616
+ * Keyed by owner rather than by group: a namespace is the settings card's scope (served by the
5617
+ * platform's configForms), while a group may span packages — group 'memory' is served by memory-files and
5698
5618
  * tool-memory, each owning its own section. A package without an entry has no
5699
5619
  * user layer (its knobs stay deployment-only). */
5700
5620
  const PARAM_NAMESPACES = Object.freeze({
5701
5621
  "evolution-review": "evolution-review",
5622
+ "memory": "memory",
5702
5623
  "memory-files": "evolution-memory",
5703
5624
  "tool-memory": "evolution-tool-memory",
5704
5625
  "evolution-curator": "evolution-curator",
@@ -6282,4 +6203,4 @@ function isIgnorableEvent(event) {
6282
6203
  return classifySessionEvent(event) !== "model";
6283
6204
  }
6284
6205
  //#endregion
6285
- export { AUTHORING_DESCRIPTION_BAR, AUTHORING_SPLIT_LINE_CHARS, CITATION_SUPPORT_DIRS, 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_LEASE_TTL_MS, 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, HOOK_LINE_RE, HOST_LOCALES, HOST_ROUTES, HomeFence, HomeFenceError, INJECT_COMBINED_REVIEW_PROMPT, INJECT_COMPLETION_SKILL_REVIEW_PROMPT, INJECT_MEMORY_REVIEW_PROMPT, INJECT_SKILL_REVIEW_PROMPT, INSTANCE_KEYS, KEEP_LINE_RE, LONG_RUNS, LOW_QUALITY_THRESHOLD, LeaseStore, MAINTAINER_PRESET_ID, MAINTAIN_OUTPUT_INSTRUCTION, MAINTAIN_PROMPT, MAX_DESCRIPTION_LENGTH, MAX_REQUEST_BODY_BYTES, 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, MODEL_SESSION_EVENT_TYPES as MODEL_SESSION_EVENTS, MODEL_SESSION_EVENT_TYPES, MUTATIONS_FILE_VERSION, MemoryStore, MutationAuthority, 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, RESTRICTED_PRESET_DISPLAY, RESTRICTED_TOOLS_ROW_ID, RESTRICTOR_MODULE, REVIEWER_PRESET_ID, RUNS_SCHEMA_VERSION, SKILLS_GUIDANCE, SKILLS_GUIDANCE_SECTION_ORDER, SKILL_ACTION_REQUIRED_FIELDS, SKILL_NAME_RE, SKILL_REVIEW_PROMPT, STORE_LEDGER, SUMMARY_DUPLICATE_HINT_THRESHOLD, SUPPORT_DIRS, SUPPORT_SPRAWL_FILES, SUPPRESSED_FILE_VERSION, THREAT_EXEMPTION_HINT, TOKEN_ASCII_WEIGHT, TOKEN_CJK_WEIGHT, ToolDispatchNormalizer, ToolDispatchPayloadError, UNTRUSTED_LINE_BREAK, UNTRUSTED_LINE_MARK, UPSTREAM_LIMIT_CHARS_PER_TOKEN, absentHostServices, acquireTreeWriteLock, admissionVerdict, advanceReview, affinity, allowRowCollisions, appendEvolutionEvent, applyCuratorLifecycleFields, applyCuratorMetaFields, applyNamespaceMigration, applyReferenceRewrite, asRecord, assertDispatchPayload, assertHomeOwner, atomicWriteFiles, authorityFrom, backupsReachability, bodyCost, buildCuratorRunReport, buildExtractPlanFromLibrary, buildHealthBaseline, buildLearnPrompt, bumpPatch, bumpSupportRead, bumpUse, bumpView, callingScope, canonicalWriteId, claimInstance, clampOnce, clampedNumber, classifyNamespaceMigration, classifySessionEvent, clearReviewChannel, collectReadSkillNames, collectReadSupportFiles, computeDedupGroups, computeDriftSignals, computeLifecycleTransitions, computePrefixClusters, computeQualityScores, computeScopeView, contentHash, countDispatches, createGateSet, createSubagentChannel, currentReviewContext, daysSinceIso, declaredReportStamp, describeReferenceRewrite, dispatchKeyOf, dispatchPathOf, dispatchStepOf, displayBodyOf, duplicateHeadings, emptyRecord, errorText, errorTextIn, evaluateThreat, eventsFile, evidenceKindIndex, evolutionActivityProjection, evolutionEventPayloadIssue, evolutionEvidenceProjection, evolutionHome, evolutionIoAdapter, evolutionProjectionHistoryProjection, evolutionReadsProjection, evolutionRoot, evolutionSignalsProjection, externalRefs, findDriftSignal, findOwnerCandidate, foldCuratorFields, foldToolDispatches, foldTurnEvent, foldTurnEvents, foldUntrustedLines, fuzzyPatch, getRecord, h2Sections, historyReachability, hostSurface, identity, idleDays, initialTurnFold, instanceClaimKey, instanceClaimedWriteSites, instanceHolder, isAbsent, isBookkeepingFrame, isCommittedWarning, isDeprecatedParamId, isFileShapedPath, isIgnorableEvent, isMissingPath, isPresent, isProcessAlive, isProgramToolName, isProjectableSession, isRecord, isReviewChannelSession, isSkillReadToolName, isSkillToolName, isUnknown, json, latestActivityAt, leaseFile, lifecycleCandidate, listEventArchives, liveBool, liveEnum, liveNumber, liveString, loadMutations, loadSuppressedNames, loadUsage, makeSerialQueue, mapProbe, markAgentCreated, markReviewChannel, memoryRoot, methodNotAllowed, missingSupportPointers, mutateUsage, mutationLockFrom, mutationsFile, narrowNameMatches, nearDuplicateSummaries, newRunRegistry, nodeEvolutionIo, normalizeUsageRecord, observeEvent, overlongLines, ownerCandidatesFromSummaries, ownerDecisionText, paramNamespace, paramRowId, paramSettingsId, parseCuratorNominations, parseEvolutionEvents, payloadText, persistedWriteSite, persistedWriteSites, pickWithPolicy, planExtract, planNamespaceMigration, planReferenceRewrite, planRehoming, policyStageLimits, probeAbsent, probeChannelState, probeList, probeMtime, probePresent, probeReason, probeText, probeUnknown, projectExtractBodies, projectionText, proposalFromPlan, proposalReportDir, proposalReportName, protectedSkillNamesOf, readDispatchSignal, readEvolutionEvents, readEvolutionTimeline, readExternalSupport, readJsonObject, readNumberParam, readParam, readProposalReport, readProposalReports, readTreeLock, readingStats, recordMutation, redactSecrets, referencedBlobs, registerHostRoutes, registerOwnerSettings, releaseInstance, renameWithRetry, renderCuratorReportMarkdown, renderLongRunTable, reportTime, reportsReachability, reportsSweepLockTarget, resolveCitations, resolveParamId, restructureCandidates, retainEventArchives, retirementReport, reviewPrompt, runWriteGates, runsFile, saveSuppressedNames, saveUsage, scanBodyHooks, scanContentThreats, scanMemoryThreats, scanThreats, scopeOfNearestManifest, scopedPackageName, scopedProbeReport, selectSections, sessionAudited, sessionEvidenceIndex, sessionLastEventTime, sessionReadNames, sessionSeesFamilyTools, sessionTurnSignals, skillReadNameOf, skillWriteGateContext, subagentChannelState, supportFileReadFromPath, supportFileReadOf, supportRefs, suppressedFile, sweepReports, sweepReviewChannelSessions, tokenLineFor, transactIo, transactTaskGuard, treeLockFile, trimPatternBoundaries, unhookedSupportPointers, unwrapLive, updateSuppressedNames, usageFile, usageObserved, userSetKeys, valueOr, verifyPromptBundle, vocabulary, withReviewContext, withTreeWrite, withTreeWriteLock, writeDurableTmp, writePathSymbols, writeProposalReport };
6206
+ export { AUTHORING_DESCRIPTION_BAR, AUTHORING_SPLIT_LINE_CHARS, AuthorityBusyError, AuthorityOrderError, AuthorityReentryError, CITATION_SUPPORT_DIRS, 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_LEASE_TTL_MS, 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, HOOK_LINE_RE, HOST_LOCALES, HOST_ROUTES, HomeAuthority, HomeFence, HomeFenceError, INJECT_COMBINED_REVIEW_PROMPT, INJECT_COMPLETION_SKILL_REVIEW_PROMPT, INJECT_MEMORY_REVIEW_PROMPT, INJECT_SKILL_REVIEW_PROMPT, INSTANCE_KEYS, KEEP_LINE_RE, LONG_RUNS, LOW_QUALITY_THRESHOLD, LeaseStore, MAINTAINER_PRESET_ID, MAINTAIN_OUTPUT_INSTRUCTION, MAINTAIN_PROMPT, MAX_DESCRIPTION_LENGTH, MAX_REQUEST_BODY_BYTES, 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, MODEL_SESSION_EVENT_TYPES as MODEL_SESSION_EVENTS, MODEL_SESSION_EVENT_TYPES, MUTATIONS_FILE_VERSION, MemoryStore, MutationAuthority, 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, RESTRICTED_PRESET_DISPLAY, RESTRICTED_TOOLS_ROW_ID, RESTRICTOR_MODULE, REVIEWER_PRESET_ID, RUNS_SCHEMA_VERSION, SKILLS_GUIDANCE, SKILLS_GUIDANCE_SECTION_ORDER, SKILL_ACTION_REQUIRED_FIELDS, SKILL_NAME_RE, SKILL_REVIEW_PROMPT, STORE_LEDGER, SUMMARY_DUPLICATE_HINT_THRESHOLD, SUPPORT_DIRS, SUPPORT_SPRAWL_FILES, SUPPRESSED_FILE_VERSION, THREAT_EXEMPTION_HINT, TOKEN_ASCII_WEIGHT, TOKEN_CJK_WEIGHT, ToolDispatchNormalizer, ToolDispatchPayloadError, UNTRUSTED_LINE_BREAK, UNTRUSTED_LINE_MARK, UPSTREAM_LIMIT_CHARS_PER_TOKEN, absentHostServices, admissionVerdict, advanceReview, affinity, allowRowCollisions, appendEvolutionEvent, applyCuratorLifecycleFields, applyCuratorMetaFields, applyNamespaceMigration, applyReferenceRewrite, asRecord, assertDispatchPayload, atomicWriteFiles, authorityFrom, authorityHolder, backupsReachability, bodyCost, buildCuratorRunReport, buildExtractPlanFromLibrary, buildHealthBaseline, buildLearnPrompt, bumpPatch, bumpSupportRead, bumpUse, bumpView, callingScope, canAdvance, canonicalWriteId, claimInstance, clampOnce, clampedNumber, classifyNamespaceMigration, classifySessionEvent, clearReviewChannel, collectReadSkillNames, collectReadSupportFiles, computeDedupGroups, computeDriftSignals, computeLifecycleTransitions, computePrefixClusters, computeQualityScores, computeScopeView, contentHash, countDispatches, createGateSet, createSubagentChannel, currentReviewContext, daysSinceIso, declaredReportStamp, describeReferenceRewrite, dispatchKeyOf, dispatchPathOf, dispatchStepOf, displayBodyOf, duplicateHeadings, emptyRecord, errorText, errorTextIn, evaluateThreat, eventsFile, evidenceKindIndex, evolutionActivityProjection, evolutionEventPayloadIssue, evolutionEvidenceProjection, evolutionHome, evolutionIoAdapter, evolutionProjectionHistoryProjection, evolutionReadsProjection, evolutionRoot, evolutionSignalsProjection, externalRefs, findDriftSignal, findOwnerCandidate, foldCuratorFields, foldToolDispatches, foldTurnEvent, foldTurnEvents, foldUntrustedLines, fuzzyPatch, getRecord, h2Sections, historyReachability, hostSurface, identity, idleDays, initialTurnFold, instanceClaimKey, instanceClaimedWriteSites, instanceHolder, isAbsent, isBookkeepingFrame, isCommittedWarning, isDeprecatedParamId, isFileShapedPath, isIgnorableEvent, isMissingPath, isPresent, isProcessAlive, isProgramToolName, isProjectableSession, isRecord, isReviewChannelSession, isSkillReadToolName, isSkillToolName, isTerminal, isUnknown, json, latestActivityAt, leaseAsTreeLock, leaseFile, lifecycleCandidate, listEventArchives, liveBool, liveEnum, liveNumber, liveString, loadMutations, loadSuppressedNames, loadUsage, makeSerialQueue, mapProbe, markAgentCreated, markReviewChannel, memoryRoot, methodNotAllowed, missingSupportPointers, mutateUsage, mutationLockFrom, mutationsFile, narrowNameMatches, nearDuplicateSummaries, newRunRegistry, nodeEvolutionIo, normalizeUsageRecord, observeEvent, overlongLines, ownerCandidatesFromSummaries, ownerDecisionText, paramNamespace, paramRowId, paramSettingsId, parseCuratorNominations, parseEvolutionEvents, payloadText, persistedWriteSite, persistedWriteSites, pickWithPolicy, planExtract, planNamespaceMigration, planReferenceRewrite, planRehoming, policyStageLimits, probeAbsent, probeChannelState, probeList, probeMtime, probePresent, probeReason, probeText, probeUnknown, projectExtractBodies, projectionText, proposalFromPlan, proposalReportDir, proposalReportName, protectedSkillNamesOf, readDispatchSignal, readEvolutionEvents, readEvolutionTimeline, readExternalSupport, readJsonObject, readNumberParam, readParam, readProposalReport, readProposalReports, readingStats, recordMutation, redactSecrets, referencedBlobs, registerHostRoutes, releaseInstance, renameWithRetry, renderCuratorReportMarkdown, renderLongRunTable, reportTime, reportsReachability, reportsSweepLockTarget, resolveCitations, resolveParamId, restructureCandidates, retainEventArchives, retirementReport, reviewPrompt, runWriteGates, runsFile, saveSuppressedNames, saveUsage, scanBodyHooks, scanContentThreats, scanMemoryThreats, scanThreats, scopeOfNearestManifest, scopedPackageName, scopedProbeReport, selectSections, sessionAudited, sessionEvidenceIndex, sessionLastEventTime, sessionReadNames, sessionSeesFamilyTools, sessionTurnSignals, skillReadNameOf, skillWriteGateContext, subagentChannelState, supportFileReadFromPath, supportFileReadOf, supportRefs, suppressedFile, sweepReports, sweepReviewChannelSessions, tokenLineFor, transactIo, transactOutcome, transactTaskGuard, trimPatternBoundaries, unhookedSupportPointers, unwrapLive, updateSuppressedNames, usageFile, usageObserved, userSetKeys, valueOr, verifyPromptBundle, vocabulary, withReviewContext, withTreeWrite, writeDurableTmp, writePathSymbols, writeProposalReport };
@@ -1,8 +1,7 @@
1
- import { n as isRecord } from "./guards-3f02mnf2.js";
2
- import { copyFileSync, existsSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
3
- import { basename, dirname, join } from "node:path";
4
- import { createHash, randomBytes } from "node:crypto";
5
1
  import { cp, lstat, mkdir, open, readFile, readdir, rename, rm, stat } from "node:fs/promises";
2
+ import { basename, dirname, join } from "node:path";
3
+ import { copyFileSync, existsSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
4
+ import { randomBytes } from "node:crypto";
6
5
  //#region lib/types/probe.js
7
6
  function probePresent(value) {
8
7
  return {
@@ -159,6 +158,46 @@ async function transactIo(io, path, task) {
159
158
  console.warn(`evolution-io: ${path} was written but its directory fsync failed — the bytes are visible, durability is unconfirmed: ${error instanceof Error ? error.message : String(error)}`);
160
159
  }
161
160
  }
161
+ function outcomeFailure(error) {
162
+ const message = error instanceof Error ? error.message : String(error);
163
+ if (isCommittedWarning(error)) return {
164
+ kind: "unknown",
165
+ message
166
+ };
167
+ const code = error?.code;
168
+ return {
169
+ kind: "rejected",
170
+ code: typeof code === "string" ? code : "io",
171
+ message
172
+ };
173
+ }
174
+ /**
175
+ * Read-modify-commit that reports what actually happened instead of collapsing the two failure
176
+ * kinds. `transactIo` deliberately turns a committed-warning into success (the bytes are visible),
177
+ * which is right for callers that only need the write; a two-phase caller needs to know that its
178
+ * follow-up step is unconfirmed, so it uses this instead.
179
+ * @param io - the IO backend.
180
+ * @param path - the durable file.
181
+ * @param task - the read-modify-render step.
182
+ * @returns `landed`, `unknown` (written, durability unconfirmed) or `rejected`.
183
+ */
184
+ async function transactOutcome(io, path, task) {
185
+ if (io.transact) try {
186
+ await io.transact(path, task);
187
+ return { kind: "landed" };
188
+ } catch (error) {
189
+ return outcomeFailure(error);
190
+ }
191
+ try {
192
+ const current = await io.readText(path);
193
+ const next = await task(current);
194
+ if (next === null) await io.remove(path);
195
+ else if (next !== current) await io.writeText(path, next);
196
+ return { kind: "landed" };
197
+ } catch (error) {
198
+ return outcomeFailure(error);
199
+ }
200
+ }
162
201
  /** Build a {@link TransactTaskGuard} for one write path. See its doc. */
163
202
  function transactTaskGuard(what) {
164
203
  let invoked = false;
@@ -354,8 +393,10 @@ function isCommittedWarning(error) {
354
393
  /**
355
394
  * Build the Node IO backend: plain fs promises, durable tmp + rename commits (crash atomicity) and
356
395
  * ONE concurrency guarantee of its own — writes to the same path are serialized in-process (see
357
- * `inProcessWrite`). G2 S4 removed the cross-process write lock and its takeover protocol; the
358
- * plugin path gets cross-process safety from the platform provider (`ctx.fs`).
396
+ * `inProcessWrite`). Cross-process exclusion is not this backend's job: every durable writer takes
397
+ * the home lock through `HomeAuthority` (W9-authority), which delegates to the platform's
398
+ * `withFileLock`. The earlier claim that a `ctx.fs` provider supplied it was never true — no such
399
+ * provider exists in the family source.
359
400
  */
360
401
  function nodeEvolutionIo() {
361
402
  /**
@@ -372,13 +413,12 @@ function nodeEvolutionIo() {
372
413
  /** True when the pid is alive (single source: `isProcessAlive`). */
373
414
  const isAlive = isProcessAlive;
374
415
  /**
375
- * G2 S4: the family write-lock protocol is retired. Concurrency is the PLATFORM’s job now — the
376
- * plugin path requires `ctx.fs`, whose writes are versioned — so this backend keeps exactly one
377
- * guarantee of its own: writes to the SAME path inside THIS process are serialized (a promise
378
- * chain per path: no timers, no lock files, no takeover windows). Cross-process RMW safety comes
379
- * from the provider; a standalone caller sharing a directory across processes must not rely on
380
- * this backend alone. The durable tmp + rename commit stays — crash atomicity and mutual
381
- * exclusion are different concerns.
416
+ * This backend keeps exactly one concurrency guarantee of its own: writes to the SAME path inside
417
+ * THIS process are serialized (a promise chain per path: no timers, no lock files, no takeover
418
+ * windows). Cross-process exclusion belongs to `HomeAuthority` (W9-authority), which every
419
+ * durable writer takes and which delegates to the platform's `withFileLock`; a standalone caller
420
+ * that shares a directory across processes must take that lock too. The durable tmp + rename
421
+ * commit stays here — crash atomicity and mutual exclusion are different concerns.
382
422
  */
383
423
  const queues = /* @__PURE__ */ new Map();
384
424
  const inProcessWrite = async (path, run) => {
@@ -645,74 +685,4 @@ function atomicWriteFiles(targetDir, writes, fs = defaultFs, logger = console.wa
645
685
  }
646
686
  }
647
687
  //#endregion
648
- //#region lib/types/mutations.js
649
- /**
650
- * Curator/author audit trail: `.mutations.json` records every skill mutation
651
- * with before/after content hashes so any automated edit is reviewable and
652
- * replayable. Best-effort persistence, mirroring the usage sidecar posture.
653
- * @module @lmzhen/dsh-evolution-core
654
- */
655
- const DEFAULT_MUTATION_CAP = 500;
656
- /** Version of the `.mutations.json` file shape; writers always emit the current one. */
657
- const MUTATIONS_FILE_VERSION = 1;
658
- function mutationsFile(root) {
659
- return join(root, ".mutations.json");
660
- }
661
- function contentHash(content) {
662
- return createHash("sha256").update(content.replaceAll("\r\n", "\n")).digest("hex");
663
- }
664
- /**
665
- * Parse a raw mutations sidecar; malformed content reads as empty (auditing is
666
- * best-effort). Versioned shape ({ version, records }) with legacy
667
- * plain-array compat, plus a field-level guard for records without the
668
- * required identity/timestamp fields (rc.42 audit P2-3).
669
- */
670
- function parseMutationRecords(raw) {
671
- if (raw === null) return [];
672
- try {
673
- return recordsFromParsed(JSON.parse(raw));
674
- } catch {
675
- return [];
676
- }
677
- }
678
- /** Field-level shape guard shared by the parse and the recordMutation write
679
- * path (P3/v15: the guard's JSON.parse and this parse used to run twice over
680
- * the same bytes inside one transact). */
681
- function recordsFromParsed(parsed) {
682
- return (Array.isArray(parsed) ? parsed : typeof parsed === "object" && parsed !== null && Array.isArray(parsed.records) ? parsed.records : []).filter((entry) => typeof entry === "object" && entry !== null && typeof entry.skillName === "string" && typeof entry.action === "string" && typeof entry.at === "string");
683
- }
684
- async function loadMutations(root, io = nodeEvolutionIo()) {
685
- return parseMutationRecords(await io.readText(mutationsFile(root)));
686
- }
687
- /** Append one record, trim to `cap`, and write atomically (versioned shape). */
688
- async function recordMutation(root, io, record, cap = 500, fence) {
689
- const write = async () => {
690
- await transactIo(io, mutationsFile(root), (current) => {
691
- let parsed = [];
692
- if (current !== null) try {
693
- parsed = JSON.parse(current);
694
- } catch {
695
- console.warn(`mutation audit record dropped: ${mutationsFile(root)} is malformed and was not overwritten`);
696
- return current;
697
- }
698
- if (isRecord(parsed)) {
699
- const version = parsed.version;
700
- if (typeof version === "number" && version > 1) {
701
- console.warn(`mutation audit record dropped: ${mutationsFile(root)} declares version ${version} (newer than 1); not overwritten`);
702
- return current;
703
- }
704
- }
705
- const existing = recordsFromParsed(parsed);
706
- existing.push(record);
707
- const trimmed = existing.length > cap ? existing.slice(existing.length - cap) : existing;
708
- return JSON.stringify({
709
- version: 1,
710
- records: trimmed
711
- }, null, 2);
712
- });
713
- };
714
- if (fence !== void 0) await fence.run(write);
715
- else await write();
716
- }
717
- //#endregion
718
- export { valueOr as A, probeList as C, probeText as D, probeReason as E, probeUnknown as O, probeAbsent as S, probePresent as T, isAbsent as _, mutationsFile as a, isUnknown as b, evolutionIoAdapter as c, nodeEvolutionIo as d, renameWithRetry as f, declaredReportStamp as g, writeDurableTmp as h, loadMutations as i, reportTime as k, isCommittedWarning as l, transactTaskGuard as m, MUTATIONS_FILE_VERSION as n, recordMutation as o, transactIo as p, contentHash as r, atomicWriteFiles as s, DEFAULT_MUTATION_CAP as t, isProcessAlive as u, isMissingPath as v, probeMtime as w, mapProbe as x, isPresent as y };
688
+ export { probeUnknown as C, probeText as S, valueOr as T, probeAbsent as _, nodeEvolutionIo as a, probePresent as b, transactOutcome as c, declaredReportStamp as d, isAbsent as f, mapProbe as g, isUnknown as h, isProcessAlive as i, transactTaskGuard as l, isPresent as m, evolutionIoAdapter as n, renameWithRetry as o, isMissingPath as p, isCommittedWarning as r, transactIo as s, atomicWriteFiles as t, writeDurableTmp as u, probeList as v, reportTime as w, probeReason as x, probeMtime as y };
package/lib/io-node.js ADDED
@@ -0,0 +1,24 @@
1
+ import { a as nodeEvolutionIo } from "./io-AmUf4lVY.js";
2
+ //#region lib/types/io-node.js
3
+ /**
4
+ * Local atomic node:fs IO provider.
5
+ *
6
+ * The implementation is the single `nodeEvolutionIo()` from
7
+ * `dsh-evolution-core` (no duplicate copy: the old fork once diverged in
8
+ * exists(), made directories report absent and let re-archives overwrite
9
+ * older archive folders). Only the provider's `name` is added here.
10
+ *
11
+ * @module @lmzhen/dsh-evolution-core/io-node
12
+ */
13
+ ({ ...nodeEvolutionIo() });
14
+ const name = "evolution-io-node";
15
+ const inject = ["evolutionIo"];
16
+ const provider = {
17
+ name: "node",
18
+ ...nodeEvolutionIo()
19
+ };
20
+ function apply(ctx) {
21
+ ctx.effect(() => ctx.evolutionIo.registerProvider(provider, { default: true }), "evolution-io-node.provider");
22
+ }
23
+ //#endregion
24
+ export { apply, inject, name };