@lmzhen/dsh-evolution-core 0.54.0 → 0.55.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{extract-plan-D4zO7dmD.js → extract-plan-BxDhKSki.js} +2 -1
- package/lib/extract.js +7 -7
- package/lib/index.js +830 -546
- package/lib/{limits-TD4Pv92Q.js → limits-CO4JGSJL.js} +20 -6
- package/lib/{skill-history-CZp8vhyL.js → mutation-storage-adapter-7R3ra0wj.js} +4 -647
- package/lib/mutations-mvTnWkua.js +592 -0
- package/lib/policy.js +9 -3
- package/lib/{quality-BLc6UQQb.js → quality-CREp6s1G.js} +1 -1
- package/lib/{skill-health-BIpiPvw6.js → review-context-70XYS11J.js} +124 -183
- package/lib/runtime/plugin.js +1 -1
- package/lib/{session-projection-ByNxQi9O.js → session-projection-CbIKvDfJ.js} +3 -2
- package/lib/skill-history-YX84wO20.js +647 -0
- package/lib/skills.js +16 -11
- package/lib/text-metrics-CyJhxWBs.js +132 -0
- package/lib/types/constants.d.ts +19 -5
- package/lib/types/constants.js +19 -5
- package/lib/types/drift-signals.d.ts +1 -4
- package/lib/types/drift-signals.js +14 -23
- package/lib/types/extract-request.js +3 -2
- package/lib/types/frontmatter.js +12 -8
- package/lib/types/index.d.ts +2 -1
- package/lib/types/index.js +2 -1
- package/lib/types/memory-store.d.ts +32 -6
- package/lib/types/memory-store.js +86 -30
- package/lib/types/mutation-unit.js +2 -1
- package/lib/types/params.js +6 -3
- package/lib/types/policy.d.ts +5 -0
- package/lib/types/policy.js +8 -2
- package/lib/types/prompts.d.ts +1 -1
- package/lib/types/prompts.js +1 -1
- package/lib/types/signals.js +3 -2
- package/lib/types/skill-health.d.ts +8 -5
- package/lib/types/skill-health.js +27 -28
- package/lib/types/skill-history.d.ts +2 -2
- package/lib/types/skill-history.js +9 -8
- package/lib/types/skill-lint.d.ts +1 -1
- package/lib/types/skill-lint.js +4 -4
- package/lib/types/skill-stats.d.ts +3 -1
- package/lib/types/skill-stats.js +7 -3
- package/lib/types/skill-store.js +2 -1
- package/lib/types/text-budgets.d.ts +185 -0
- package/lib/types/text-budgets.js +70 -0
- package/lib/types/text-metrics.d.ts +88 -0
- package/lib/types/text-metrics.js +131 -0
- package/lib/{usage-B1qveKi9.js → usage-DrczLTP4.js} +2 -515
- package/lib/write.js +3 -2
- package/package.json +1 -1
- package/lib/mutations-DQXddSJd.js +0 -75
- package/lib/types/cost.d.ts +0 -63
- package/lib/types/cost.js +0 -67
package/lib/index.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { S as reportTime, _ as probeMtime, a as isProcessAlive, b as probeText, c as transactIo, d as isAbsent, f as isMissingPath, g as probeList, h as probeAbsent, i as isCommittedWarning, l as writeDurableTmp, m as isUnknown, n as atomicWriteFiles, o as nodeEvolutionIo, p as isPresent, r as evolutionIoAdapter, s as renameWithRetry, t as TransactionNotInvokedError, u as declaredReportStamp, v as probePresent, x as probeUnknown, y as probeReason } from "./io-GxghO3Ip.js";
|
|
2
2
|
import { a as leaseFile, c as AuthorityBusyError, d as HomeAuthority, f as authorityHolder, i as LeaseStore, l as AuthorityOrderError, n as mutationLockFrom, o as HomeFence, p as leaseAsTreeLock, r as DEFAULT_LEASE_TTL_MS, s as HomeFenceError, t as MutationAuthority, u as AuthorityReentryError } from "./mutation-authority-DQfpXs1O.js";
|
|
3
3
|
import { a as isFileShapedPath, i as KEEP_LINE_RE, n as DEFAULT_CITATION_REF_BUDGET, o as resolveCitations, r as HOOK_LINE_RE, s as scanBodyHooks, t as CITATION_SUPPORT_DIRS } from "./citations-CZKTUGQF.js";
|
|
4
|
-
import { A as
|
|
4
|
+
import { $ as SUPPORT_SPRAWL_FILES, A as DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, B as MAX_SKILL_CONTENT_CHARS, C as DEFAULT_REVIEW_TIMEOUT_MS, D as DEFAULT_SKILL_VERSION_KEEP, E as DEFAULT_SKILL_REVIEW_TRIGGER, F as DEFAULT_USER_TOKENS, G as MEMORY_GUIDANCE_SECTION_ORDER, H as MAX_SKILL_NAME_LENGTH, I as ENTRY_DELIMITER, J as REVIEW_TEXT_PREVIEW_GRAPHEMES, K as MERGE_BODY_PREVIEW_BYTES, L as EVOLUTION_WRITE_TOOLS, M as DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, N as DEFAULT_THREAT_MAX_SCAN_CHARS, O as DEFAULT_SOFT_BODY_TOKENS, P as DEFAULT_USER_CHAR_LIMIT, Q as SUPPORT_DIRS, R as FORBIDDEN_CONTROL_KEYS, S as DEFAULT_REVIEW_SKILL_INTERVAL, T as DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, U as MAX_TIMER_DELAY_MS, V as MAX_SKILL_FILE_BYTES, W as MEMORY_ENTRY_PREVIEW_GRAPHEMES, X as SKILL_ACTION_REQUIRED_FIELDS, Y as SKILLS_GUIDANCE_SECTION_ORDER, Z as SKILL_NAME_RE, _ as DEFAULT_MEMORY_CHAR_LIMIT, a as DEFAULT_SUPPORT_FILE_CHAR_POLICY, b as DEFAULT_PROBE_TIMEOUT_MS, c as AUTHORING_DESCRIPTION_BAR, d as DEFAULT_ARCHIVE_AFTER_DAYS, et as TEXT_DIFF_MAX_GRAPHEMES, f as DEFAULT_CONSOLIDATION_FAILURES, g as DEFAULT_CURATOR_REVIEW_MAX_TOKENS, h as DEFAULT_CURATOR_MODEL, i as DEFAULT_SKILL_LIMITS, j as DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, k as DEFAULT_STALE_AFTER_DAYS, l as AUTHORING_SPLIT_LINE_CHARS, m as DEFAULT_CURATOR_INTERVAL_HOURS, n as DEFAULT_CITATION_POLICY, nt as VERSION_BODY_PREVIEW_GRAPHEMES, o as POLICY_STAGE_DEFAULTS, p as DEFAULT_CURATOR_BOOT_GRACE_SECONDS, q as PROTECTED_BUILTIN_SKILLS, r as DEFAULT_REFERENCE_REWRITE_POLICY, s as policyStageLimits, t as DEFAULT_ARCHIVE_RETENTION_POLICY, tt as UPSTREAM_LIMIT_CHARS_PER_TOKEN, u as CONTENT_SPLIT_HINT, v as DEFAULT_MEMORY_TOKENS, w as DEFAULT_SKILL_CONTENT_CHARS, x as DEFAULT_REVIEW_MEMORY_INTERVAL, y as DEFAULT_MIN_IDLE_HOURS, z as MAX_DESCRIPTION_LENGTH } from "./limits-CO4JGSJL.js";
|
|
5
5
|
import { _ as scopedPackageName, d as RESTRICTED_TOOLS_ROW_ID, f as RESTRICTOR_MODULE, g as scopeOfNearestManifest, l as MAINTAINER_PRESET_ID, p as REVIEWER_PRESET_ID, s as EVOLUTION_PRESET_IDS, u as RESTRICTED_PRESET_DISPLAY } from "./ensure-BLmEW0Ju.js";
|
|
6
|
-
import {
|
|
6
|
+
import { A as retainEventArchives, C as appendEvolutionEvent, D as parseEvolutionEvents, E as listEventArchives, G as DEFAULT_WRITE_CONFIRM_MODE, H as isUnreadWrite, I as softBodyTokenBudget, K as DEFAULT_WRITE_CONFIRM_TIMEOUT_SECONDS, L as RULES, O as readEvolutionEvents, P as assessStructureHealth, S as EVENT_LOG_VERSION, T as evolutionEventPayloadIssue, _ as fuzzyPatch, a as isReviewChannelSession, b as EVENT_LOG_RETAIN_ARCHIVES, c as PATTERN_OVERLAP, d as scanContentThreats, f as scanMemoryThreats, g as FUZZY_MAX_WORK, h as FUZZY_MAX_PATTERN_CHARS, i as clearReviewChannel, j as DEFAULT_HEALTH_THRESHOLDS, k as readEvolutionTimeline, l as THREAT_EXEMPTION_HINT, m as makeSerialQueue, n as recordReviewRead, o as markReviewChannel, p as scanThreats, q as authorityFrom, r as withReviewContext, s as sweepReviewChannelSessions, t as currentReviewContext, u as evaluateThreat, v as trimPatternBoundaries, w as eventsFile, x as EVENT_LOG_ROTATE_AT, y as EVENT_ARCHIVE_PREFIX, z as lintSkill } from "./review-context-70XYS11J.js";
|
|
7
7
|
import { i as HOST_LOCALES, n as errorText, r as errorTextIn, t as EVOLUTION_ERRORS } from "./errors-BxzLTVbS.js";
|
|
8
|
-
import { A as dispatchKeyOf, C as PTC_DISPATCH_EVENT, D as assertDispatchPayload, E as ToolDispatchPayloadError, F as isSkillToolName, I as readDispatchSignal, L as skillReadNameOf, M as dispatchStepOf, N as foldToolDispatches, O as collectReadSkillNames, P as isSkillReadToolName, R as supportFileReadFromPath, S as NATIVE_RESULT_EVENT, T as ToolDispatchNormalizer, _ 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 dispatchPathOf, k as collectReadSupportFiles, l as sessionReadNames, m as initialTurnFold, n as evolutionEvidenceProjection, o as isProjectableSession, p as foldTurnEvents, 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 supportFileReadOf } from "./session-projection-
|
|
9
|
-
import {
|
|
8
|
+
import { A as dispatchKeyOf, C as PTC_DISPATCH_EVENT, D as assertDispatchPayload, E as ToolDispatchPayloadError, F as isSkillToolName, I as readDispatchSignal, L as skillReadNameOf, M as dispatchStepOf, N as foldToolDispatches, O as collectReadSkillNames, P as isSkillReadToolName, R as supportFileReadFromPath, S as NATIVE_RESULT_EVENT, T as ToolDispatchNormalizer, _ 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 dispatchPathOf, k as collectReadSupportFiles, l as sessionReadNames, m as initialTurnFold, n as evolutionEvidenceProjection, o as isProjectableSession, p as foldTurnEvents, 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 supportFileReadOf } from "./session-projection-CbIKvDfJ.js";
|
|
9
|
+
import { a as measureUnit, i as measureText, n as conservativeTokenEstimator, o as truncateGraphemes, r as graphemeCount, s as utf8ByteLength, t as codePointCount } from "./text-metrics-CyJhxWBs.js";
|
|
10
|
+
import { A as h2Sections, C as saveUsage, D as usageObserved, E as usageFile, F as describeReferenceRewrite, I as planReferenceRewrite, L as planRehoming, M as externalRefs, N as supportRefs, O as selectSections, P as applyReferenceRewrite, S as saveSuppressedNames, T as updateSuppressedNames, _ as loadUsage, a as applyCuratorMetaFields, b as normalizeUsageRecord, c as bumpUse, d as emptyRecord, f as foldCuratorFields, g as loadSuppressedNames, h as latestActivityAt, i as applyCuratorLifecycleFields, j as readingStats, k as displayBodyOf, l as bumpView, m as idleDays, n as SUPPRESSED_FILE_VERSION, o as bumpPatch, p as getRecord, r as VIEW_WINDOW_DAYS, s as bumpSupportRead, t as MAX_SUPPORT_READ_PATHS, u as daysSinceIso, v as markAgentCreated, w as suppressedFile, x as recentViewCount, y as mutateUsage } from "./usage-DrczLTP4.js";
|
|
10
11
|
import { n as isRecord, t as asRecord } from "./guards-3f02mnf2.js";
|
|
11
|
-
import {
|
|
12
|
+
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-mvTnWkua.js";
|
|
13
|
+
import { T as ownerCandidatesFromSummaries, _ as readProposalReport, a as SUMMARY_DUPLICATE_HINT_THRESHOLD, b as proposalFromPlan, c as computePrefixClusters, d as nearDuplicateSummaries, f as projectionText, g as proposalReportName, h as proposalReportDir, i as QUALITY_WEIGHTS, l as computeQualityScores, m as readExternalSupport, n as DEDUP_SIMILARITY_THRESHOLD, o as affinity, p as vocabulary, r as LOW_QUALITY_THRESHOLD, s as computeDedupGroups, t as DEDUP_MAX_PAIR_COMPARISONS, u as identity, v as readProposalReports, w as findOwnerCandidate, y as writeProposalReport } from "./quality-CREp6s1G.js";
|
|
12
14
|
import { n as evolutionRoot, t as evolutionHome } from "./state-store-Jpa-iYIZ.js";
|
|
15
|
+
import "./skill-history-YX84wO20.js";
|
|
13
16
|
import { HOST_ROUTES, MAX_REQUEST_BODY_BYTES, hostSurface, json, methodNotAllowed, readJsonObject, registerHostRoutes } from "./http-routes.js";
|
|
14
17
|
import { w as allowRowCollisions } from "./composition-CtNbVHq3.js";
|
|
15
18
|
import { t as clampedNumber } from "./numeric-Dc53KQoe.js";
|
|
16
|
-
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-DQXddSJd.js";
|
|
17
19
|
import { u as scopeOf, y as settingsPort } from "./platform-DyHnHUmQ.js";
|
|
18
20
|
import { n as toolsPort } from "./tools-BrUswg8v.js";
|
|
19
21
|
import { abortLink, createSubagentChannel as createSubagentKernel, createSubagentRun, probeChannelState, textOfValue, waitForSubagentEnd } from "./subagent/index.js";
|
|
@@ -319,127 +321,569 @@ async function runWriteGates(context) {
|
|
|
319
321
|
return null;
|
|
320
322
|
}
|
|
321
323
|
//#endregion
|
|
322
|
-
//#region lib/types/
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
324
|
+
//#region lib/types/drift-signals.js
|
|
325
|
+
/**
|
|
326
|
+
* Library-level drift signals for the maintenance subagent (design 011).
|
|
327
|
+
*
|
|
328
|
+
* Deterministic fact checks over a skill-library snapshot: domain drift
|
|
329
|
+
* (narrow names, near-duplicate groups, prefix clusters) and layer drift
|
|
330
|
+
* (log-like bodies, duplicate headings, overlong lines, missing support-file
|
|
331
|
+
* pointers, description over the authoring bar). Pure functions only — no IO,
|
|
332
|
+
* no LLM, no services. Thresholds are imported from their owning modules
|
|
333
|
+
* (skill-health / quality / skill-store), never duplicated.
|
|
334
|
+
*
|
|
335
|
+
* Distinct from `signals.ts` — the session-level review signal gate.
|
|
336
|
+
*/
|
|
337
|
+
/** Physical line length at/above which a body line is reported overlong (011 §4). */
|
|
338
|
+
const DRIFT_MAX_LINE_CHARS = 1500;
|
|
339
|
+
/** Signal-set version: bump whenever ids/thresholds change (011 §7 version coupling). */
|
|
340
|
+
const DRIFT_SIGNALS_VERSION = "3";
|
|
341
|
+
/** Render-time nouns for the MAINTAIN_PROMPT placeholders (single vocabulary with the facts block). */
|
|
342
|
+
const DRIFT_SIGNAL_NOUNS = {
|
|
343
|
+
dedup_group: "近重复组",
|
|
344
|
+
prefix_cluster: "前缀聚类",
|
|
345
|
+
stamp_density: "stamp 密度",
|
|
346
|
+
body_size: "正文体量",
|
|
347
|
+
dup_heading: "重复标题",
|
|
348
|
+
overlong_line: "超长行",
|
|
349
|
+
pointer_missing: "缺失指针",
|
|
350
|
+
citation_resolution: "引用解析",
|
|
351
|
+
demand: "需求证据",
|
|
352
|
+
description_chars: "描述长度",
|
|
353
|
+
narrow_name: "窄名",
|
|
354
|
+
usage_observed: "使用观察",
|
|
355
|
+
quality_low: "质量分"
|
|
356
|
+
};
|
|
357
|
+
const NARROW_NAME_PATTERNS = [
|
|
358
|
+
{
|
|
359
|
+
label: "error-string",
|
|
360
|
+
re: /^(?:err|error|exception|traceback|warn|fail)(?:[-_][a-z0-9]+)+$/i
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
label: "pr-number",
|
|
364
|
+
re: /^(?:pr|issue)[-_]?\d{2,}$/i
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
label: "dated",
|
|
368
|
+
re: /\d{4}-\d{2}-\d{2}/
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
label: "session-verb",
|
|
372
|
+
re: /^(?:fix|debug|audit|salvage|diagnose|investigate)[-_][a-z0-9-]+$/i
|
|
341
373
|
}
|
|
342
|
-
|
|
374
|
+
];
|
|
375
|
+
/** Detect support files the body never references (by basename or relative path). */
|
|
376
|
+
function missingSupportPointers(body, supportFiles) {
|
|
377
|
+
return supportFiles.filter((path) => {
|
|
378
|
+
const base = path.split("/").pop() ?? path;
|
|
379
|
+
return base.length > 0 && !body.includes(base) && !body.includes(path);
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
/** Support files the body mentions WITHOUT the sanctioned hook form (design
|
|
383
|
+
* §5.6). Such a mention still counts as a pointer for `pointer_missing`, but
|
|
384
|
+
* only the hook form keeps the file discoverable after a move — detail only.
|
|
385
|
+
* A file carrying a `keep` marker is exempt: its mention IS the marker. */
|
|
386
|
+
function unhookedSupportPointers(body, supportFiles) {
|
|
387
|
+
const { targets, kept } = scanBodyHooks(body);
|
|
388
|
+
const hooked = new Set(targets);
|
|
389
|
+
return supportFiles.filter((path) => {
|
|
390
|
+
if (!isFileShapedPath(path)) return false;
|
|
391
|
+
const base = path.split("/").pop() ?? path;
|
|
392
|
+
if (kept.has(path) || base.length > 0 && kept.has(base)) return false;
|
|
393
|
+
return (base.length > 0 && body.includes(base) || body.includes(path)) && !hooked.has(path) && !hooked.has(base);
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
/** Support files with no readers, no citations and no `keep` marker whose owning
|
|
397
|
+
* skill has been idle for at least the lifecycle stale window. PROPOSAL INPUT
|
|
398
|
+
* only — nothing retires a file on its own — and an unmeasurable input (no age
|
|
399
|
+
* evidence, no citation scan) yields an empty list WITH its reason, never a
|
|
400
|
+
* silent "nothing qualifies".
|
|
401
|
+
* @param snapshot - the skill's drift snapshot.
|
|
402
|
+
* @param supportFiles - its enumerated support files, in listing order.
|
|
403
|
+
* @returns the candidates plus the status that explains an empty list.
|
|
404
|
+
*/
|
|
405
|
+
function retirementReport(snapshot, supportFiles) {
|
|
406
|
+
const idle = snapshot.liveness?.idleDays;
|
|
407
|
+
if (idle === void 0) return {
|
|
408
|
+
candidates: [],
|
|
409
|
+
status: "no-age"
|
|
410
|
+
};
|
|
411
|
+
if (snapshot.citations === void 0) return {
|
|
412
|
+
candidates: [],
|
|
413
|
+
status: "unscanned"
|
|
414
|
+
};
|
|
415
|
+
if (idle < 30) return {
|
|
416
|
+
candidates: [],
|
|
417
|
+
status: "none"
|
|
418
|
+
};
|
|
419
|
+
const cited = /* @__PURE__ */ new Set();
|
|
420
|
+
for (const ref of snapshot.citations.refs) if (ref.kind === "citation" && ref.target !== null) cited.add(ref.target);
|
|
421
|
+
const { kept } = scanBodyHooks(snapshot.body);
|
|
422
|
+
const demand = snapshot.demand ?? {};
|
|
423
|
+
const candidates = supportFiles.filter((path) => isFileShapedPath(path) && (demand[path] ?? 0) === 0 && !cited.has(path) && !kept.has(path)).map((path) => ({
|
|
424
|
+
path,
|
|
425
|
+
idleDays: Math.floor(idle)
|
|
426
|
+
}));
|
|
343
427
|
return {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
corpora: {
|
|
347
|
-
user,
|
|
348
|
-
platform
|
|
349
|
-
},
|
|
350
|
-
values
|
|
428
|
+
candidates,
|
|
429
|
+
status: candidates.length === 0 ? "none" : "listed"
|
|
351
430
|
};
|
|
352
431
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
* protections (pinned / bundled / hub-installed) are file markers resolved by
|
|
364
|
-
* `SkillLibrary.writeProtection` / `deleteProtection` — they depend on the
|
|
365
|
-
* filesystem and the write origin, not on a name list.
|
|
366
|
-
* @module @lmzhen/dsh-evolution-core
|
|
367
|
-
*/
|
|
368
|
-
var EvolutionGateSet = class {
|
|
369
|
-
exclude;
|
|
370
|
-
referenced;
|
|
371
|
-
suppressed;
|
|
372
|
-
constructor(inputs = {}) {
|
|
373
|
-
this.exclude = inputs.exclude ?? /* @__PURE__ */ new Set();
|
|
374
|
-
this.referenced = inputs.referenced ?? /* @__PURE__ */ new Set();
|
|
375
|
-
this.suppressed = inputs.suppressed ?? /* @__PURE__ */ new Set();
|
|
432
|
+
/** Duplicate `## heading` occurrences: singleton results default to head of the file. */
|
|
433
|
+
function duplicateHeadings(body) {
|
|
434
|
+
const counts = /* @__PURE__ */ new Map();
|
|
435
|
+
for (const raw of body.split("\n")) {
|
|
436
|
+
const line = raw.endsWith("\r") ? raw.slice(0, -1) : raw;
|
|
437
|
+
const m = /^##\s+(.+)$/.exec(line);
|
|
438
|
+
if (m?.[1]) {
|
|
439
|
+
const heading = m[1].trim();
|
|
440
|
+
if (heading) counts.set(heading, (counts.get(heading) ?? 0) + 1);
|
|
441
|
+
}
|
|
376
442
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
443
|
+
return [...counts.entries()].filter(([, count]) => count > 1).map(([heading, count]) => ({
|
|
444
|
+
heading,
|
|
445
|
+
count
|
|
446
|
+
}));
|
|
447
|
+
}
|
|
448
|
+
/** Physical lines over `max` graphemes: `{ lineNo, chars }`, 1-based line numbers. */
|
|
449
|
+
function overlongLines(body, max = DRIFT_MAX_LINE_CHARS) {
|
|
450
|
+
const out = [];
|
|
451
|
+
const lines = body.split("\n");
|
|
452
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
453
|
+
const raw = lines[index] ?? "";
|
|
454
|
+
const length = graphemeCount(raw.endsWith("\r") ? raw.slice(0, -1) : raw);
|
|
455
|
+
if (length > max) out.push({
|
|
456
|
+
lineNo: index + 1,
|
|
457
|
+
chars: length
|
|
458
|
+
});
|
|
387
459
|
}
|
|
388
|
-
|
|
389
|
-
|
|
460
|
+
return out;
|
|
461
|
+
}
|
|
462
|
+
/** Narrow-name shapes detected in a skill name (empty = none). */
|
|
463
|
+
function narrowNameMatches(name) {
|
|
464
|
+
return NARROW_NAME_PATTERNS.filter(({ re }) => re.test(name)).map(({ label }) => label);
|
|
465
|
+
}
|
|
466
|
+
function supportGroupCount(supportFiles) {
|
|
467
|
+
const groups = /* @__PURE__ */ new Set();
|
|
468
|
+
for (const path of supportFiles ?? []) {
|
|
469
|
+
const head = path.split("/")[0];
|
|
470
|
+
if (head) groups.add(head);
|
|
390
471
|
}
|
|
391
|
-
|
|
392
|
-
/** Build a GateSet from the curator-style config field names. */
|
|
393
|
-
function createGateSet(config) {
|
|
394
|
-
return new EvolutionGateSet({
|
|
395
|
-
exclude: config.excludeSkillNames,
|
|
396
|
-
referenced: config.referencedSkillNames,
|
|
397
|
-
suppressed: config.suppressedNames
|
|
398
|
-
});
|
|
472
|
+
return groups.size;
|
|
399
473
|
}
|
|
400
|
-
|
|
401
|
-
//#region lib/types/curator.js
|
|
402
|
-
/**
|
|
403
|
-
* Deterministic skill curator: active → stale → archived transitions.
|
|
404
|
-
* Pure function with one deliberate side effect: records in the passed
|
|
405
|
-
* `usage` map are MUTATED (state/archived_at) to carry the transition — the
|
|
406
|
-
* caller owns the map and decides whether to clone first (dry-run) or persist
|
|
407
|
-
* after. File moves are performed by SkillLibrary.
|
|
408
|
-
*/
|
|
409
|
-
function buildCuratorRunReport(input) {
|
|
474
|
+
function sig(id, verdict, value, threshold, detail) {
|
|
410
475
|
return {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
llmNominations: [...input.llmNominations],
|
|
417
|
-
archiveCandidates: [...input.archiveCandidates],
|
|
418
|
-
archived: [...input.archived],
|
|
419
|
-
failed: [...input.failed],
|
|
420
|
-
...input.aborted === void 0 ? {} : { aborted: input.aborted },
|
|
421
|
-
...input.unattributed === void 0 || input.unattributed.length === 0 ? {} : { unattributed: [...input.unattributed] },
|
|
422
|
-
...input.consolidated === void 0 ? {} : { consolidated: [...input.consolidated] },
|
|
423
|
-
...input.snapshotPath === void 0 ? {} : { snapshotPath: input.snapshotPath },
|
|
424
|
-
...input.llmReviewEnabled === void 0 ? {} : { llmReviewEnabled: input.llmReviewEnabled },
|
|
425
|
-
...input.nominationsWarnings === void 0 ? {} : { nominationsWarnings: [...input.nominationsWarnings] },
|
|
426
|
-
...input.scanWarnings === void 0 ? {} : { scanWarnings: [...input.scanWarnings] },
|
|
427
|
-
...input.wouldPrune === void 0 ? {} : { wouldPrune: input.wouldPrune === null ? null : [...input.wouldPrune] }
|
|
476
|
+
id,
|
|
477
|
+
verdict,
|
|
478
|
+
value,
|
|
479
|
+
threshold,
|
|
480
|
+
detail
|
|
428
481
|
};
|
|
429
482
|
}
|
|
430
483
|
/**
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
* stale candidates / LLM nominations).
|
|
484
|
+
* Compute all drift signals for a snapshot. Missing inputs (quality score,
|
|
485
|
+
* usage window) yield `unknown` — never a fabricated verdict.
|
|
434
486
|
*/
|
|
435
|
-
function
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
487
|
+
function computeDriftSignals(snapshots) {
|
|
488
|
+
const library = [];
|
|
489
|
+
const names = snapshots.map((s) => s.name);
|
|
490
|
+
const dedup = computeDedupGroups({ contents: new Map(snapshots.map((s) => [s.name, s.body])) });
|
|
491
|
+
const dedupTruncation = dedup.truncated ? " (dedup scan truncated at the pair-comparison budget)" : "";
|
|
492
|
+
library.push(dedup.groups.length === 0 ? sig("dedup_group", "pass", `none${dedupTruncation}`, "size >= 2") : sig("dedup_group", "over", `${dedup.groups.map((group) => group.join(", ")).join(" | ")}${dedupTruncation}`, "size >= 2", `members=${dedup.groups.map((group) => group.join("|")).join(";")}`));
|
|
493
|
+
const clusters = computePrefixClusters(names);
|
|
494
|
+
library.push(clusters.length === 0 ? sig("prefix_cluster", "pass", "none", "size >= 2") : sig("prefix_cluster", "over", clusters.map((cluster) => cluster.members.join(", ")).join(" | "), "size >= 2", `key=${clusters.map((cluster) => cluster.key).join("|")}`));
|
|
495
|
+
const allProvided = snapshots.length > 0 && snapshots.every((s) => s.usageObserved !== null && s.usageObserved !== void 0);
|
|
496
|
+
library.push(!allProvided ? sig("usage_observed", "unknown", "not-observed", void 0, "usage window status missing") : snapshots.every((s) => s.usageObserved === true) ? sig("usage_observed", "pass", "observed") : sig("usage_observed", "pass", "unobserved"));
|
|
497
|
+
return {
|
|
498
|
+
library,
|
|
499
|
+
skills: snapshots.map((snapshot) => {
|
|
500
|
+
const signals = [];
|
|
501
|
+
const body = snapshot.body;
|
|
502
|
+
const supportFiles = snapshot.supportFiles ?? [];
|
|
503
|
+
const supportEnumerated = snapshot.supportFiles !== void 0;
|
|
504
|
+
const health = assessStructureHealth({
|
|
505
|
+
skillName: snapshot.name,
|
|
506
|
+
bodyChars: body.length,
|
|
507
|
+
bodyText: body,
|
|
508
|
+
supportGroups: supportGroupCount(supportFiles)
|
|
509
|
+
}, DEFAULT_HEALTH_THRESHOLDS);
|
|
510
|
+
const density = health.dims.stampDensityPerKb;
|
|
511
|
+
signals.push(density === null ? sig("stamp_density", "pass", "below-min-body") : sig("stamp_density", density >= DEFAULT_HEALTH_THRESHOLDS.stampDensityPerKb ? "over" : "pass", `${density.toFixed(2)}/KB`, `${DEFAULT_HEALTH_THRESHOLDS.stampDensityPerKb}/KB`));
|
|
512
|
+
const bodyTokens = health.dims.bodyTokens;
|
|
513
|
+
const tokenBudget = softBodyTokenBudget(DEFAULT_HEALTH_THRESHOLDS);
|
|
514
|
+
const overLine = bodyTokens >= tokenBudget;
|
|
515
|
+
signals.push(sig("body_size", overLine ? "over" : "pass", `${bodyTokens} tokens / ${body.length} chars`, `${tokenBudget} tokens`, `body=${(bodyTokens / tokenBudget).toFixed(1)}x${oversizeSupportNote(snapshot.supportChars)}`));
|
|
516
|
+
const dupes = duplicateHeadings(body);
|
|
517
|
+
signals.push(dupes.length === 0 ? sig("dup_heading", "pass", "none") : sig("dup_heading", "over", dupes.map((d) => `${d.heading}(${d.count})`).join(", "), "count >= 2"));
|
|
518
|
+
const long = overlongLines(body);
|
|
519
|
+
signals.push(long.length === 0 ? sig("overlong_line", "pass", "none") : sig("overlong_line", "over", long.map((l) => `${l.lineNo}:${l.chars}`).join(", "), `${DRIFT_MAX_LINE_CHARS}`));
|
|
520
|
+
const missing = supportEnumerated ? missingSupportPointers(body, supportFiles) : void 0;
|
|
521
|
+
const unhooked = supportEnumerated ? unhookedSupportPointers(body, supportFiles) : [];
|
|
522
|
+
const unhookedDetail = unhooked.length === 0 ? void 0 : `unhooked=${unhooked.length}: ${unhooked.slice(0, 5).join(", ")}`;
|
|
523
|
+
signals.push(!supportEnumerated ? sig("pointer_missing", "unknown", "not-enumerated", void 0, "support files not enumerated") : (missing ?? []).length === 0 ? sig("pointer_missing", "pass", "none", void 0, unhookedDetail) : sig("pointer_missing", "over", missing?.join(", ") ?? "", void 0, unhookedDetail));
|
|
524
|
+
signals.push(citationSignal(snapshot.citations));
|
|
525
|
+
signals.push(demandSignal(snapshot, supportFiles, supportEnumerated));
|
|
526
|
+
const narrow = narrowNameMatches(snapshot.name);
|
|
527
|
+
signals.push(narrow.length === 0 ? sig("narrow_name", "pass", "none") : sig("narrow_name", "over", narrow.join(", "), void 0, `name=${snapshot.name}`));
|
|
528
|
+
const description = snapshot.description;
|
|
529
|
+
const descriptionLength = description === void 0 ? 0 : graphemeCount(description);
|
|
530
|
+
signals.push(description === void 0 ? sig("description_chars", "unknown", "missing", `60`) : sig("description_chars", descriptionLength > 60 ? "over" : "pass", `${descriptionLength}`, `60`));
|
|
531
|
+
const quality = snapshot.quality;
|
|
532
|
+
signals.push(quality === null || quality === void 0 ? sig("quality_low", "unknown", "not-assessed") : sig("quality_low", quality < .3 ? "over" : "pass", quality.toFixed(2), `${LOW_QUALITY_THRESHOLD}`));
|
|
533
|
+
return {
|
|
534
|
+
name: snapshot.name,
|
|
535
|
+
signals,
|
|
536
|
+
...snapshot.protected !== void 0 && snapshot.protected !== null ? { protected: snapshot.protected } : {},
|
|
537
|
+
...snapshot.catalogInvalid !== void 0 ? { catalogInvalid: snapshot.catalogInvalid } : {}
|
|
538
|
+
};
|
|
539
|
+
})
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
/** Dangling-citation verdict: a partial scan is `unknown`, never a clean pass. */
|
|
543
|
+
function citationSignal(citations) {
|
|
544
|
+
if (citations === void 0) return sig("citation_resolution", "unknown", "not-scanned", void 0, "support-file list missing");
|
|
545
|
+
if (citations.truncated) return sig("citation_resolution", "unknown", `truncated at ${citations.refs.length} refs`, void 0, "partial scan — not a clean verdict");
|
|
546
|
+
const cited = citations.refs.filter((ref) => ref.kind === "citation");
|
|
547
|
+
if (citations.dangling.length > 0) {
|
|
548
|
+
const missing = citations.dangling.slice(0, 5).map((ref) => ref.target ?? ref.raw).join(", ");
|
|
549
|
+
return sig("citation_resolution", "over", `dangling=${citations.dangling.length}/${cited.length}`, "dangling=0", `missing: ${missing}`);
|
|
550
|
+
}
|
|
551
|
+
return sig("citation_resolution", "pass", `citations=${cited.length} foreign=${citations.foreign.length}${citations.unverified.length === 0 ? "" : ` unverified=${citations.unverified.length}`}`);
|
|
552
|
+
}
|
|
553
|
+
/** V4 (design §16.6): the report half of the support-file cap. Only files the
|
|
554
|
+
* assembler could PROVE large enough to be over the cap are namespaced here; an
|
|
555
|
+
* absent map claims nothing (unknown is not zero).
|
|
556
|
+
* @param supportChars - measured character counts, or undefined when unmeasured.
|
|
557
|
+
* @returns a detail suffix naming the oversize files, or an empty string.
|
|
558
|
+
*/
|
|
559
|
+
function oversizeSupportNote(supportChars) {
|
|
560
|
+
if (supportChars === void 0) return "";
|
|
561
|
+
const oversize = Object.entries(supportChars).filter(([, chars]) => chars > MAX_SKILL_CONTENT_CHARS).sort((a, b) => b[1] - a[1]);
|
|
562
|
+
if (oversize.length === 0) return "";
|
|
563
|
+
const shown = oversize.slice(0, 3).map(([path, chars]) => `${path}(${chars})`);
|
|
564
|
+
return `; oversize support file(s): ${shown.join(", ")}${oversize.length > shown.length ? " …" : ""}`;
|
|
565
|
+
}
|
|
566
|
+
/** Render-time reason for an empty retirement list (design §5.6). */
|
|
567
|
+
const RETIREMENT_STATUS_TEXT = {
|
|
568
|
+
listed: "listed",
|
|
569
|
+
none: "none",
|
|
570
|
+
"no-age": "age unknown",
|
|
571
|
+
unscanned: "citations unscanned"
|
|
572
|
+
};
|
|
573
|
+
/** Cold-support-file verdict (design §5.5): zero reads are evidence only while
|
|
574
|
+
* the observation window is open and the file list is known. */
|
|
575
|
+
function demandSignal(snapshot, supportFiles, supportEnumerated) {
|
|
576
|
+
if (!supportEnumerated || supportFiles.length === 0) return sig("demand", "unknown", "not-enumerated", void 0, "support files not enumerated");
|
|
577
|
+
if (snapshot.usageObserved !== true) return sig("demand", "unknown", "window-closed", void 0, "no observed reads yet: zero is not evidence");
|
|
578
|
+
const demand = snapshot.demand ?? {};
|
|
579
|
+
const cold = supportFiles.filter((path) => (demand[path] ?? 0) === 0);
|
|
580
|
+
const retire = retirementReport(snapshot, supportFiles);
|
|
581
|
+
const retireDetail = retire.candidates.length === 0 ? `retire: ${RETIREMENT_STATUS_TEXT[retire.status]}` : `retire≥30d: ${retire.candidates.slice(0, 5).map((c) => `${c.path}(${c.idleDays}d)`).join(", ")}`;
|
|
582
|
+
if (cold.length === 0) return sig("demand", "pass", `${supportFiles.length} warm`, "cold=0", retireDetail);
|
|
583
|
+
const sample = cold.slice(0, 5).join(", ");
|
|
584
|
+
return sig("demand", "over", `cold=${cold.length}/${supportFiles.length}`, "cold=0", `never read: ${sample} · ${retireDetail}`);
|
|
585
|
+
}
|
|
586
|
+
/** Convenience: fetch one signal from an assessment or library list. */
|
|
587
|
+
function findDriftSignal(signals, id) {
|
|
588
|
+
return signals.find((signal) => signal.id === id);
|
|
589
|
+
}
|
|
590
|
+
//#endregion
|
|
591
|
+
//#region lib/types/text-budgets.js
|
|
592
|
+
/**
|
|
593
|
+
* Named text budgets: every character-based decision declares its axis, unit and
|
|
594
|
+
* severity here, so business code never invents a measurement or a unit inline.
|
|
595
|
+
*
|
|
596
|
+
* A budget is not a language profile. Storage/display/context/quality are
|
|
597
|
+
* different questions about the same string; the metric module answers all of
|
|
598
|
+
* them, and this table decides which answer each gate uses.
|
|
599
|
+
*
|
|
600
|
+
* @module @lmzhen/dsh-evolution-core
|
|
601
|
+
*/
|
|
602
|
+
/** The default soft body token budget. */
|
|
603
|
+
const SOFT_BODY_TOKENS = DEFAULT_SOFT_BODY_TOKENS;
|
|
604
|
+
/** The derived token budgets for the old character memory limits. */
|
|
605
|
+
const MEMORY_TOKENS = DEFAULT_MEMORY_TOKENS;
|
|
606
|
+
const USER_TOKENS = DEFAULT_USER_TOKENS;
|
|
607
|
+
/**
|
|
608
|
+
* The family's named budgets.
|
|
609
|
+
*
|
|
610
|
+
* Context budgets are registered here before their wiring lands so the inventory
|
|
611
|
+
* and doctor have one authority; P2 is what makes them stop being dormant.
|
|
612
|
+
*/
|
|
613
|
+
const TEXT_BUDGETS = {
|
|
614
|
+
skillBodyHard: {
|
|
615
|
+
id: "skill.body.hard",
|
|
616
|
+
axis: "storage",
|
|
617
|
+
unit: "codePoints",
|
|
618
|
+
limit: MAX_SKILL_CONTENT_CHARS,
|
|
619
|
+
severity: "hard"
|
|
620
|
+
},
|
|
621
|
+
skillFileBytes: {
|
|
622
|
+
id: "skill.file.bytes",
|
|
623
|
+
axis: "storage",
|
|
624
|
+
unit: "utf8Bytes",
|
|
625
|
+
limit: MAX_SKILL_FILE_BYTES,
|
|
626
|
+
severity: "hard"
|
|
627
|
+
},
|
|
628
|
+
skillName: {
|
|
629
|
+
id: "skill.name",
|
|
630
|
+
axis: "storage",
|
|
631
|
+
unit: "codePoints",
|
|
632
|
+
limit: 64,
|
|
633
|
+
severity: "hard"
|
|
634
|
+
},
|
|
635
|
+
skillDescription: {
|
|
636
|
+
id: "skill.description.hard",
|
|
637
|
+
axis: "display",
|
|
638
|
+
unit: "graphemes",
|
|
639
|
+
limit: MAX_DESCRIPTION_LENGTH,
|
|
640
|
+
severity: "hard"
|
|
641
|
+
},
|
|
642
|
+
skillDescriptionAuthoring: {
|
|
643
|
+
id: "skill.description.authoring",
|
|
644
|
+
axis: "display",
|
|
645
|
+
unit: "graphemes",
|
|
646
|
+
limit: 60,
|
|
647
|
+
severity: "soft"
|
|
648
|
+
},
|
|
649
|
+
skillSummary: {
|
|
650
|
+
id: "skill.summary",
|
|
651
|
+
axis: "display",
|
|
652
|
+
unit: "graphemes",
|
|
653
|
+
limit: 50,
|
|
654
|
+
severity: "hard"
|
|
655
|
+
},
|
|
656
|
+
feedbackNote: {
|
|
657
|
+
id: "feedback.note",
|
|
658
|
+
axis: "display",
|
|
659
|
+
unit: "graphemes",
|
|
660
|
+
limit: 20,
|
|
661
|
+
severity: "hard"
|
|
662
|
+
},
|
|
663
|
+
lineLength: {
|
|
664
|
+
id: "skill.line",
|
|
665
|
+
axis: "display",
|
|
666
|
+
unit: "graphemes",
|
|
667
|
+
limit: DRIFT_MAX_LINE_CHARS,
|
|
668
|
+
severity: "soft"
|
|
669
|
+
},
|
|
670
|
+
substantiveUser: {
|
|
671
|
+
id: "review.substantive.user",
|
|
672
|
+
axis: "display",
|
|
673
|
+
unit: "graphemes",
|
|
674
|
+
limit: 200,
|
|
675
|
+
severity: "soft"
|
|
676
|
+
},
|
|
677
|
+
substantiveAgent: {
|
|
678
|
+
id: "review.substantive.agent",
|
|
679
|
+
axis: "display",
|
|
680
|
+
unit: "graphemes",
|
|
681
|
+
limit: 500,
|
|
682
|
+
severity: "soft"
|
|
683
|
+
},
|
|
684
|
+
retentionFeedback: {
|
|
685
|
+
id: "history.retention-feedback",
|
|
686
|
+
axis: "display",
|
|
687
|
+
unit: "graphemes",
|
|
688
|
+
limit: 200,
|
|
689
|
+
severity: "report"
|
|
690
|
+
},
|
|
691
|
+
diffWindow: {
|
|
692
|
+
id: "history.diff-window",
|
|
693
|
+
axis: "display",
|
|
694
|
+
unit: "graphemes",
|
|
695
|
+
limit: TEXT_DIFF_MAX_GRAPHEMES,
|
|
696
|
+
severity: "report"
|
|
697
|
+
},
|
|
698
|
+
reviewPreview: {
|
|
699
|
+
id: "history.review-preview",
|
|
700
|
+
axis: "display",
|
|
701
|
+
unit: "graphemes",
|
|
702
|
+
limit: REVIEW_TEXT_PREVIEW_GRAPHEMES,
|
|
703
|
+
severity: "report"
|
|
704
|
+
},
|
|
705
|
+
memoryPreview: {
|
|
706
|
+
id: "memory.entry-preview",
|
|
707
|
+
axis: "display",
|
|
708
|
+
unit: "graphemes",
|
|
709
|
+
limit: 200,
|
|
710
|
+
severity: "report"
|
|
711
|
+
},
|
|
712
|
+
versionBodyPreview: {
|
|
713
|
+
id: "history.body-preview",
|
|
714
|
+
axis: "display",
|
|
715
|
+
unit: "graphemes",
|
|
716
|
+
limit: VERSION_BODY_PREVIEW_GRAPHEMES,
|
|
717
|
+
severity: "report"
|
|
718
|
+
},
|
|
719
|
+
mergeBodyPreview: {
|
|
720
|
+
id: "merge.body-preview",
|
|
721
|
+
axis: "display",
|
|
722
|
+
unit: "utf8Bytes",
|
|
723
|
+
limit: MERGE_BODY_PREVIEW_BYTES,
|
|
724
|
+
severity: "report"
|
|
725
|
+
},
|
|
726
|
+
bodySoft: {
|
|
727
|
+
id: "skill.body.soft",
|
|
728
|
+
axis: "context",
|
|
729
|
+
unit: "tokens",
|
|
730
|
+
limit: SOFT_BODY_TOKENS,
|
|
731
|
+
severity: "soft"
|
|
732
|
+
},
|
|
733
|
+
memory: {
|
|
734
|
+
id: "memory.budget",
|
|
735
|
+
axis: "context",
|
|
736
|
+
unit: "tokens",
|
|
737
|
+
limit: MEMORY_TOKENS,
|
|
738
|
+
severity: "hard"
|
|
739
|
+
},
|
|
740
|
+
user: {
|
|
741
|
+
id: "user.budget",
|
|
742
|
+
axis: "context",
|
|
743
|
+
unit: "tokens",
|
|
744
|
+
limit: USER_TOKENS,
|
|
745
|
+
severity: "hard"
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
/**
|
|
749
|
+
* Compare one string against one named budget.
|
|
750
|
+
* @param text - the string to measure.
|
|
751
|
+
* @param budget - the budget to apply.
|
|
752
|
+
* @param estimator - optional token source for token budgets.
|
|
753
|
+
* @returns the measured value and the remaining allowance (negative when over).
|
|
754
|
+
*/
|
|
755
|
+
function compareTextBudget(text, budget, estimator) {
|
|
756
|
+
const metrics = measureText(text, estimator);
|
|
757
|
+
const measured = budget.unit === "tokens" ? metrics.tokens.value : budget.unit === "utf8Bytes" ? metrics.utf8Bytes : budget.unit === "codePoints" ? metrics.codePoints : metrics.graphemes;
|
|
758
|
+
return {
|
|
759
|
+
budget,
|
|
760
|
+
value: measured,
|
|
761
|
+
over: measured > budget.limit,
|
|
762
|
+
remaining: budget.limit - measured
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
//#endregion
|
|
766
|
+
//#region lib/types/health-baseline.js
|
|
767
|
+
function buildHealthBaseline(skills) {
|
|
768
|
+
const values = {};
|
|
769
|
+
for (const rule of RULES) values[rule.id] = {
|
|
770
|
+
platformHits: 0,
|
|
771
|
+
userHits: 0,
|
|
772
|
+
userHitRate: 0
|
|
773
|
+
};
|
|
774
|
+
let user = 0;
|
|
775
|
+
let platform = 0;
|
|
776
|
+
for (const skill of skills) {
|
|
777
|
+
if (skill.corpus === "user") user += 1;
|
|
778
|
+
else platform += 1;
|
|
779
|
+
for (const finding of lintSkill(skill.facts)) {
|
|
780
|
+
const row = values[finding.rule];
|
|
781
|
+
if (row === void 0) continue;
|
|
782
|
+
if (skill.corpus === "user") row.userHits += 1;
|
|
783
|
+
else row.platformHits += 1;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
for (const row of Object.values(values)) row.userHitRate = user === 0 ? 0 : row.userHits / user;
|
|
787
|
+
return {
|
|
788
|
+
unit: "chars",
|
|
789
|
+
scope: "references markdown file count",
|
|
790
|
+
corpora: {
|
|
791
|
+
user,
|
|
792
|
+
platform
|
|
793
|
+
},
|
|
794
|
+
values
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
//#endregion
|
|
798
|
+
//#region lib/types/gates.js
|
|
799
|
+
/**
|
|
800
|
+
* The control-plane protection sets, held once and queried everywhere
|
|
801
|
+
* (decision B, rc.44 plan M2): the lifecycle engine, the scope view, the LLM
|
|
802
|
+
* nomination gate and the control-plane consolidate all answer "is this name
|
|
803
|
+
* off limits — and why" from the same instance, so the gate sets can never
|
|
804
|
+
* drift apart the way the three pre-rc.46 implementations did.
|
|
805
|
+
*
|
|
806
|
+
* Scope boundary: a GateSet covers NAME-SET protections only. Marker-based
|
|
807
|
+
* protections (pinned / bundled / hub-installed) are file markers resolved by
|
|
808
|
+
* `SkillLibrary.writeProtection` / `deleteProtection` — they depend on the
|
|
809
|
+
* filesystem and the write origin, not on a name list.
|
|
810
|
+
* @module @lmzhen/dsh-evolution-core
|
|
811
|
+
*/
|
|
812
|
+
var EvolutionGateSet = class {
|
|
813
|
+
exclude;
|
|
814
|
+
referenced;
|
|
815
|
+
suppressed;
|
|
816
|
+
constructor(inputs = {}) {
|
|
817
|
+
this.exclude = inputs.exclude ?? /* @__PURE__ */ new Set();
|
|
818
|
+
this.referenced = inputs.referenced ?? /* @__PURE__ */ new Set();
|
|
819
|
+
this.suppressed = inputs.suppressed ?? /* @__PURE__ */ new Set();
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* The first protection blocking this name, or null. Any hit blocks — the
|
|
823
|
+
* order is diagnostic only, so a name in two sets reports the first.
|
|
824
|
+
*/
|
|
825
|
+
blockReason(name) {
|
|
826
|
+
if (this.exclude.has(name)) return "excluded";
|
|
827
|
+
if (this.referenced.has(name)) return "referenced";
|
|
828
|
+
if (this.suppressed.has(name)) return "suppressed";
|
|
829
|
+
if (PROTECTED_BUILTIN_SKILLS.has(name)) return "protected-builtin";
|
|
830
|
+
return null;
|
|
831
|
+
}
|
|
832
|
+
isBlocked(name) {
|
|
833
|
+
return this.blockReason(name) !== null;
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
/** Build a GateSet from the curator-style config field names. */
|
|
837
|
+
function createGateSet(config) {
|
|
838
|
+
return new EvolutionGateSet({
|
|
839
|
+
exclude: config.excludeSkillNames,
|
|
840
|
+
referenced: config.referencedSkillNames,
|
|
841
|
+
suppressed: config.suppressedNames
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
//#endregion
|
|
845
|
+
//#region lib/types/curator.js
|
|
846
|
+
/**
|
|
847
|
+
* Deterministic skill curator: active → stale → archived transitions.
|
|
848
|
+
* Pure function with one deliberate side effect: records in the passed
|
|
849
|
+
* `usage` map are MUTATED (state/archived_at) to carry the transition — the
|
|
850
|
+
* caller owns the map and decides whether to clone first (dry-run) or persist
|
|
851
|
+
* after. File moves are performed by SkillLibrary.
|
|
852
|
+
*/
|
|
853
|
+
function buildCuratorRunReport(input) {
|
|
854
|
+
return {
|
|
855
|
+
schemaVersion: 1,
|
|
856
|
+
runId: input.runId,
|
|
857
|
+
startedAt: input.startedAt,
|
|
858
|
+
finishedAt: input.finishedAt,
|
|
859
|
+
staleCandidates: [...input.staleCandidates],
|
|
860
|
+
llmNominations: [...input.llmNominations],
|
|
861
|
+
archiveCandidates: [...input.archiveCandidates],
|
|
862
|
+
archived: [...input.archived],
|
|
863
|
+
failed: [...input.failed],
|
|
864
|
+
...input.aborted === void 0 ? {} : { aborted: input.aborted },
|
|
865
|
+
...input.unattributed === void 0 || input.unattributed.length === 0 ? {} : { unattributed: [...input.unattributed] },
|
|
866
|
+
...input.consolidated === void 0 ? {} : { consolidated: [...input.consolidated] },
|
|
867
|
+
...input.snapshotPath === void 0 ? {} : { snapshotPath: input.snapshotPath },
|
|
868
|
+
...input.llmReviewEnabled === void 0 ? {} : { llmReviewEnabled: input.llmReviewEnabled },
|
|
869
|
+
...input.nominationsWarnings === void 0 ? {} : { nominationsWarnings: [...input.nominationsWarnings] },
|
|
870
|
+
...input.scanWarnings === void 0 ? {} : { scanWarnings: [...input.scanWarnings] },
|
|
871
|
+
...input.wouldPrune === void 0 ? {} : { wouldPrune: input.wouldPrune === null ? null : [...input.wouldPrune] }
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* Render a curator run report as a compact human-readable markdown digest
|
|
876
|
+
* (G6): run metadata first, then the notable sections (archived / failed /
|
|
877
|
+
* stale candidates / LLM nominations).
|
|
878
|
+
*/
|
|
879
|
+
function renderCuratorReportMarkdown(report) {
|
|
880
|
+
const lines = [
|
|
881
|
+
`# Curator run ${report.runId}`,
|
|
882
|
+
"",
|
|
883
|
+
`- **Started** ${report.startedAt}`,
|
|
884
|
+
`- **Finished** ${report.finishedAt}`,
|
|
885
|
+
`- **Stale candidates**: ${report.staleCandidates.length}`,
|
|
886
|
+
`- **LLM nominations**: ${report.llmNominations.length}`,
|
|
443
887
|
`- **Archived**: ${report.archived.length}`,
|
|
444
888
|
`- **Failed**: ${report.failed.length}`,
|
|
445
889
|
...report.aborted === void 0 ? [] : [`- **Aborted**: ${report.aborted}`],
|
|
@@ -761,6 +1205,14 @@ function previewEntries(entries) {
|
|
|
761
1205
|
const more = entries.length > ERROR_PREVIEW_ENTRIES ? `\n (+${entries.length - ERROR_PREVIEW_ENTRIES} more)` : "";
|
|
762
1206
|
return `\n\nCurrent entries (preview):\n${shown.join("\n")}${more}`;
|
|
763
1207
|
}
|
|
1208
|
+
/** Count one entry list in both units; empty is zero in both. */
|
|
1209
|
+
function usageOf(entries) {
|
|
1210
|
+
const text = entries.join(ENTRY_DELIMITER);
|
|
1211
|
+
return {
|
|
1212
|
+
chars: text.length,
|
|
1213
|
+
tokens: text.length === 0 ? 0 : measureText(text).tokens.value
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
764
1216
|
function memoryRoot(env = process.env) {
|
|
765
1217
|
return join(evolutionRoot(env), "memories");
|
|
766
1218
|
}
|
|
@@ -787,6 +1239,8 @@ function hasEntryDelimiter(content) {
|
|
|
787
1239
|
var MemoryStore = class {
|
|
788
1240
|
memoryLimit;
|
|
789
1241
|
userLimit;
|
|
1242
|
+
memoryTokenLimit;
|
|
1243
|
+
userTokenLimit;
|
|
790
1244
|
addDatePrefix;
|
|
791
1245
|
root;
|
|
792
1246
|
maxFailures;
|
|
@@ -805,8 +1259,10 @@ var MemoryStore = class {
|
|
|
805
1259
|
constructor(options = {}) {
|
|
806
1260
|
this.io = options.io ?? nodeEvolutionIo();
|
|
807
1261
|
this.fence = options.fence;
|
|
808
|
-
this.
|
|
809
|
-
this.
|
|
1262
|
+
this.memoryTokenLimit = options.memoryTokenLimit;
|
|
1263
|
+
this.userTokenLimit = options.userTokenLimit;
|
|
1264
|
+
this.memoryLimit = options.memoryTokenLimit ?? options.memoryCharLimit ?? 2200;
|
|
1265
|
+
this.userLimit = options.userTokenLimit ?? options.userCharLimit ?? 1375;
|
|
810
1266
|
this.addDatePrefix = options.addDatePrefix ?? false;
|
|
811
1267
|
this.root = options.root ?? memoryRoot();
|
|
812
1268
|
this.maxFailures = options.maxConsolidationFailures ?? 3;
|
|
@@ -825,6 +1281,39 @@ var MemoryStore = class {
|
|
|
825
1281
|
limitFor(target) {
|
|
826
1282
|
return target === "memory" ? this.memoryLimit : this.userLimit;
|
|
827
1283
|
}
|
|
1284
|
+
/** Token budget when the target opted into token mode; undefined keeps legacy chars. */
|
|
1285
|
+
tokenLimitFor(target) {
|
|
1286
|
+
return target === "memory" ? this.memoryTokenLimit : this.userTokenLimit;
|
|
1287
|
+
}
|
|
1288
|
+
/** The value the active gate compares: tokens in token mode, UTF-16 chars otherwise. */
|
|
1289
|
+
judgedValue(target, usage) {
|
|
1290
|
+
return this.tokenLimitFor(target) === void 0 ? usage.chars : usage.tokens;
|
|
1291
|
+
}
|
|
1292
|
+
/** Unit noun for model-facing messages; legacy mode keeps its old wording. */
|
|
1293
|
+
unitFor(target) {
|
|
1294
|
+
return this.tokenLimitFor(target) === void 0 ? "chars" : "tokens";
|
|
1295
|
+
}
|
|
1296
|
+
/**
|
|
1297
|
+
* Byte ceiling for the oversized-read guard. It is NOT the token budget:
|
|
1298
|
+
* a token cannot be compared to bytes. Token mode uses a conservative byte
|
|
1299
|
+
* envelope so a canonical English/CJK file is never mistaken for corruption.
|
|
1300
|
+
*/
|
|
1301
|
+
byteGuardFor(target) {
|
|
1302
|
+
const tokenLimit = this.tokenLimitFor(target);
|
|
1303
|
+
if (tokenLimit === void 0) return this.limitFor(target) * READ_GUARD_FACTOR;
|
|
1304
|
+
return Math.max(16 * 1024, tokenLimit * 4 * READ_GUARD_FACTOR);
|
|
1305
|
+
}
|
|
1306
|
+
/** Add the public dual-unit facts to one internal result. */
|
|
1307
|
+
decorateResult(target, result) {
|
|
1308
|
+
const usage = usageOf(result.entries);
|
|
1309
|
+
const tokenLimit = this.tokenLimitFor(target);
|
|
1310
|
+
return {
|
|
1311
|
+
...result,
|
|
1312
|
+
chars: usage.chars,
|
|
1313
|
+
tokens: usage.tokens,
|
|
1314
|
+
...tokenLimit === void 0 ? {} : { tokenLimit }
|
|
1315
|
+
};
|
|
1316
|
+
}
|
|
828
1317
|
/** P2-1 (v18): the generated date prefix participates in duplicate detection
|
|
829
1318
|
* only when THIS store writes it. With addDatePrefix=false a fact's own
|
|
830
1319
|
* leading `## YYYY-MM-DD\n` is content, not a generated prefix. */
|
|
@@ -832,19 +1321,19 @@ var MemoryStore = class {
|
|
|
832
1321
|
return this.addDatePrefix ? stripDatePrefix(entry) : entry;
|
|
833
1322
|
}
|
|
834
1323
|
/**
|
|
835
|
-
* Read-guard probe: `{ size,
|
|
836
|
-
*
|
|
837
|
-
*
|
|
838
|
-
*
|
|
1324
|
+
* Read-guard probe: `{ size, byteLimit }` when the on-disk file exceeds the
|
|
1325
|
+
* target's byte ceiling, `null` when it is absent, unknown, under the bound,
|
|
1326
|
+
* or the target has no limit configured. The ceiling is bytes, never the
|
|
1327
|
+
* token/char budget itself.
|
|
839
1328
|
*/
|
|
840
1329
|
async oversizedFile(target) {
|
|
841
1330
|
const size = await this.io.size?.(fileFor(this.root, target));
|
|
842
1331
|
if (size === null || size === void 0) return null;
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
return size >
|
|
1332
|
+
if (this.limitFor(target) <= 0) return null;
|
|
1333
|
+
const byteLimit = this.byteGuardFor(target);
|
|
1334
|
+
return size > byteLimit ? {
|
|
846
1335
|
size,
|
|
847
|
-
|
|
1336
|
+
byteLimit
|
|
848
1337
|
} : null;
|
|
849
1338
|
}
|
|
850
1339
|
async read(target) {
|
|
@@ -877,14 +1366,15 @@ var MemoryStore = class {
|
|
|
877
1366
|
}
|
|
878
1367
|
/**
|
|
879
1368
|
* StorageHint percentage must clamp at 100 like the render header: a drifted
|
|
880
|
-
* entry can push
|
|
881
|
-
* clamped usage indicator.
|
|
1369
|
+
* entry can push usage past the limit, and "Storage at 125%" contradicts the
|
|
1370
|
+
* clamped usage indicator. The percentage is computed in the ACTIVE unit.
|
|
882
1371
|
*/
|
|
883
|
-
storageHint(target,
|
|
1372
|
+
storageHint(target, usage) {
|
|
884
1373
|
const limit = this.limitFor(target);
|
|
885
1374
|
if (limit <= 0) return "";
|
|
886
|
-
const
|
|
887
|
-
|
|
1375
|
+
const value = this.judgedValue(target, usage);
|
|
1376
|
+
const percent = Math.min(100, Math.floor(value * 100 / limit));
|
|
1377
|
+
return percent >= 80 ? ` ⚠️ Storage at ${percent}% (${value}/${limit} ${this.unitFor(target)}).` : "";
|
|
888
1378
|
}
|
|
889
1379
|
/**
|
|
890
1380
|
* Best-effort raw-copy backup of the on-disk file to `<file>.bak` before a
|
|
@@ -928,7 +1418,7 @@ var MemoryStore = class {
|
|
|
928
1418
|
const suffix = backup ? ` 已把备份保存到 ${basename(backup)}。` : "";
|
|
929
1419
|
return {
|
|
930
1420
|
ok: false,
|
|
931
|
-
message: `记忆文件为 ${oversized.size} 字节(上限 ${oversized.
|
|
1421
|
+
message: `记忆文件为 ${oversized.size} 字节(上限 ${oversized.byteLimit})—— 跳过读取。${suffix} 请手动修复该文件后重试。`,
|
|
932
1422
|
entries: [],
|
|
933
1423
|
chars: 0,
|
|
934
1424
|
limit: this.limitFor(target)
|
|
@@ -990,7 +1480,7 @@ var MemoryStore = class {
|
|
|
990
1480
|
};
|
|
991
1481
|
}
|
|
992
1482
|
async add(target, facts) {
|
|
993
|
-
return await this.serial(() => this.addChained(target, facts));
|
|
1483
|
+
return await this.serial(async () => this.decorateResult(target, await this.addChained(target, facts)));
|
|
994
1484
|
}
|
|
995
1485
|
async addChained(target, facts) {
|
|
996
1486
|
if (!facts.trim()) return {
|
|
@@ -1049,31 +1539,35 @@ var MemoryStore = class {
|
|
|
1049
1539
|
const entries = [...new Set(normalizeEntries(raw))];
|
|
1050
1540
|
if (entries.some((entry) => this.dedupeKey(entry) === content)) {
|
|
1051
1541
|
this.resetFailures();
|
|
1542
|
+
const usage = usageOf(entries);
|
|
1052
1543
|
return {
|
|
1053
1544
|
result: {
|
|
1054
1545
|
ok: true,
|
|
1055
|
-
message: `该条目已存在(未重复添加)。${this.storageHint(target,
|
|
1546
|
+
message: `该条目已存在(未重复添加)。${this.storageHint(target, usage)}`,
|
|
1056
1547
|
entries,
|
|
1057
|
-
chars:
|
|
1548
|
+
chars: usage.chars,
|
|
1549
|
+
tokens: usage.tokens,
|
|
1058
1550
|
limit: this.limitFor(target)
|
|
1059
1551
|
},
|
|
1060
1552
|
write: null
|
|
1061
1553
|
};
|
|
1062
1554
|
}
|
|
1063
1555
|
const next = [...entries, prefixed];
|
|
1064
|
-
const
|
|
1556
|
+
const usage = usageOf(next);
|
|
1557
|
+
const total = this.judgedValue(target, usage);
|
|
1065
1558
|
const addLimit = this.limitFor(target);
|
|
1066
1559
|
if (addLimit > 0 && total > addLimit) return {
|
|
1067
|
-
result: this.failure(target, `添加该条目会超过 ${addLimit}
|
|
1560
|
+
result: this.failure(target, `添加该条目会超过 ${addLimit} ${this.unitFor(target)} 上限。请先合并或删除过期条目,再重试。`, entries),
|
|
1068
1561
|
write: null
|
|
1069
1562
|
};
|
|
1070
1563
|
this.resetFailures();
|
|
1071
1564
|
return {
|
|
1072
1565
|
result: {
|
|
1073
1566
|
ok: true,
|
|
1074
|
-
message: `已添加条目。${this.storageHint(target,
|
|
1567
|
+
message: `已添加条目。${this.storageHint(target, usage)}`,
|
|
1075
1568
|
entries: next,
|
|
1076
|
-
chars:
|
|
1569
|
+
chars: usage.chars,
|
|
1570
|
+
tokens: usage.tokens,
|
|
1077
1571
|
limit: this.limitFor(target)
|
|
1078
1572
|
},
|
|
1079
1573
|
write: render(next)
|
|
@@ -1117,7 +1611,7 @@ var MemoryStore = class {
|
|
|
1117
1611
|
const entries = normalizeEntries(raw);
|
|
1118
1612
|
if (render(entries) !== raw) return "external";
|
|
1119
1613
|
const limit = this.limitFor(target);
|
|
1120
|
-
if (limit > 0 && entries.some((entry) =>
|
|
1614
|
+
if (limit > 0 && entries.some((entry) => this.judgedValue(target, usageOf([entry])) > limit)) return "over-limit";
|
|
1121
1615
|
return null;
|
|
1122
1616
|
}
|
|
1123
1617
|
/** External-drift predicate: canonical-form violations only (see
|
|
@@ -1148,11 +1642,14 @@ var MemoryStore = class {
|
|
|
1148
1642
|
if (shrinkOnly) return null;
|
|
1149
1643
|
const limit = this.limitFor(target);
|
|
1150
1644
|
const entries = normalizeEntries(raw);
|
|
1645
|
+
const over = entries.filter((entry) => this.judgedValue(target, usageOf([entry])) > limit).length;
|
|
1646
|
+
const usage = usageOf(entries);
|
|
1151
1647
|
return {
|
|
1152
1648
|
ok: false,
|
|
1153
|
-
message: `${
|
|
1649
|
+
message: `${over} 条记忆超过了配置的 ${this.tokenLimitFor(target) === void 0 ? target === "memory" ? "memoryCharLimit" : "userCharLimit" : `${target} tokens`}(${limit});它们是在更高上限下写入的。请提高上限或删除条目 —— 删除类操作仍然可用。`,
|
|
1154
1650
|
entries,
|
|
1155
|
-
chars:
|
|
1651
|
+
chars: usage.chars,
|
|
1652
|
+
tokens: usage.tokens,
|
|
1156
1653
|
limit
|
|
1157
1654
|
};
|
|
1158
1655
|
}
|
|
@@ -1166,7 +1663,7 @@ var MemoryStore = class {
|
|
|
1166
1663
|
};
|
|
1167
1664
|
}
|
|
1168
1665
|
async applyBatch(target, operations) {
|
|
1169
|
-
return await this.serial(() => this.applyBatchChained(target, operations));
|
|
1666
|
+
return await this.serial(async () => this.decorateResult(target, await this.applyBatchChained(target, operations)));
|
|
1170
1667
|
}
|
|
1171
1668
|
async applyBatchChained(target, operations) {
|
|
1172
1669
|
if (operations.length === 0) return {
|
|
@@ -1307,19 +1804,21 @@ var MemoryStore = class {
|
|
|
1307
1804
|
working[matchIndex] = entryBody;
|
|
1308
1805
|
}
|
|
1309
1806
|
}
|
|
1310
|
-
const
|
|
1807
|
+
const usage = usageOf(working);
|
|
1808
|
+
const total = this.judgedValue(target, usage);
|
|
1311
1809
|
const batchLimit = this.limitFor(target);
|
|
1312
1810
|
if (batchLimit > 0 && total > batchLimit) return {
|
|
1313
|
-
result: this.failure(target, `批处理结果(${total}
|
|
1811
|
+
result: this.failure(target, `批处理结果(${total} ${this.unitFor(target)})超过 ${batchLimit} 上限。请在同一个批里再删除或缩短一些条目。`, entries),
|
|
1314
1812
|
write: null
|
|
1315
1813
|
};
|
|
1316
1814
|
this.resetFailures();
|
|
1317
1815
|
return {
|
|
1318
1816
|
result: {
|
|
1319
1817
|
ok: true,
|
|
1320
|
-
message: `已应用 ${operations.length} 个操作。${this.storageHint(target,
|
|
1818
|
+
message: `已应用 ${operations.length} 个操作。${this.storageHint(target, usage)}`,
|
|
1321
1819
|
entries: working,
|
|
1322
|
-
chars:
|
|
1820
|
+
chars: usage.chars,
|
|
1821
|
+
tokens: usage.tokens,
|
|
1323
1822
|
limit: this.limitFor(target)
|
|
1324
1823
|
},
|
|
1325
1824
|
write: render(working)
|
|
@@ -1340,16 +1839,18 @@ var MemoryStore = class {
|
|
|
1340
1839
|
]]) {
|
|
1341
1840
|
const oversized = entries.length === 0 ? await this.oversizedFile(target) : null;
|
|
1342
1841
|
if (oversized) {
|
|
1343
|
-
parts.push(`## ${label} — file skipped: ${oversized.size} bytes (limit ${oversized.
|
|
1842
|
+
parts.push(`## ${label} — file skipped: ${oversized.size} bytes (limit ${oversized.byteLimit}); not read`);
|
|
1344
1843
|
continue;
|
|
1345
1844
|
}
|
|
1346
1845
|
const safe = entries.filter((entry) => !scanMemoryThreats(entry, void 0, this.threatScanOptions()));
|
|
1347
1846
|
if (safe.length > 0) {
|
|
1348
1847
|
const body = safe.join(ENTRY_DELIMITER);
|
|
1349
1848
|
const limit = this.limitFor(target);
|
|
1849
|
+
const usage = usageOf(safe);
|
|
1850
|
+
const judged = this.judgedValue(target, usage);
|
|
1350
1851
|
const note = safe.length === entries.length ? "" : ` (${entries.length - safe.length} threat-matched entries filtered)`;
|
|
1351
|
-
const
|
|
1352
|
-
parts.push(`## ${label} (${safe.length} entries)${
|
|
1852
|
+
const usageText = limit > 0 ? ` [${Math.min(100, Math.floor(judged * 100 / limit))}% — ${judged}/${limit} ${this.unitFor(target)}]` : "";
|
|
1853
|
+
parts.push(`## ${label} (${safe.length} entries)${usageText}${note}\n${body}`);
|
|
1353
1854
|
} else if (entries.length > 0) parts.push(`## ${label} — ${entries.length} entries withheld by the security scan; none injected`);
|
|
1354
1855
|
}
|
|
1355
1856
|
return parts.join("\n\n");
|
|
@@ -1561,7 +2062,7 @@ A. 域·碎片化
|
|
|
1561
2062
|
- A3 {signal:prefix_cluster}=over:判簇内是否同伞;非同伞→notes 提域划分观察,不强制建伞。
|
|
1562
2063
|
|
|
1563
2064
|
B. 层·分层错位
|
|
1564
|
-
- B1 {signal:stamp_density}(阈值 {signal:stamp_density.threshold})或 {signal:body_size}(阈值 {signal:body_size.threshold})=over:按**三问判据**判锚/残留——① 该编号/时间戳是否被库内其他文件引用?② 除"何时产生/为何存在"外是否还承载信息?③ 删除是否影响任何跨文档检索?(①是且③是→锚;否则→残留候选,人审)。锚→允许保留 + needs_human + semantic_reasoning 写三问结果;**锚不使用 is_override**(is_override 仅用于 §7 申诉;锚是 B1 的正常裁决路径);残留→restructure 建议(movable headings 逐字引用)。**锚≠可读:单行 >4000 字符即使在锚类也必须拆分。** **软带(authoring band)**:\`body_size\` 的 value 形如 \`<tokens> tokens / <chars> chars\`,threshold
|
|
2065
|
+
- B1 {signal:stamp_density}(阈值 {signal:stamp_density.threshold})或 {signal:body_size}(阈值 {signal:body_size.threshold})=over:按**三问判据**判锚/残留——① 该编号/时间戳是否被库内其他文件引用?② 除"何时产生/为何存在"外是否还承载信息?③ 删除是否影响任何跨文档检索?(①是且③是→锚;否则→残留候选,人审)。锚→允许保留 + needs_human + semantic_reasoning 写三问结果;**锚不使用 is_override**(is_override 仅用于 §7 申诉;锚是 B1 的正常裁决路径);残留→restructure 建议(movable headings 逐字引用)。**锚≠可读:单行 >4000 字符即使在锚类也必须拆分。** **软带(authoring band)**:\`body_size\` 的 value 形如 \`<tokens> tokens / <chars> chars\`,threshold 是**固定 token 预算**(当前默认 7,273;不再按正文成分折算);detail 里的 \`body=Nx\` 是 \`估算 tokens ÷ 7,273\`,不是字符数除以 20,000——倍数越大越优先拆。参考:中文约 7.3k 字符、英文约 21.8k 字符触及默认线。用 restructure 把 log 状整节搬进 references/*.md 并留钩子;**不要靠删证据来降成本**。
|
|
1565
2066
|
- B2 {signal:pointer_missing}=over:读支持文件后判性质——可复用模式→上移正文;会话专属实录→保留+补指针;形态=patch 指引。**未读内容仅凭文件名 → conf≤0.4 且措辞"先人工确认再执行"。** **缺失指针=支持文件存在、正文无引用(单向语义),finding 表述勿反向。** detail 里的 \`unhooked=N\` 是**被正文提及但不成钩子形态**的文件:它们不算缺失(verdict 不变),但搬迁后正文只剩裸文件名,注意力难以命中——指引是把该行改成 \`- <症状或问句> → references/x.md\`。
|
|
1566
2067
|
- B3 {signal:dup_heading}=over:删除多余标题行(保留一份),patch 指引。
|
|
1567
2068
|
- B4 {signal:overlong_line}=over:>1500 拆行;>4000 判定可读性危机(内容合法也拆);patch 指引。**finding 必须给全量口径:共 N 行超限,其中 >4000 的逐行列出。**
|
|
@@ -2728,404 +3229,139 @@ function claimInstance(home, key, owner) {
|
|
|
2728
3229
|
if (current === void 0 || current === owner) {
|
|
2729
3230
|
claims.set(id, owner);
|
|
2730
3231
|
return {
|
|
2731
|
-
granted: true,
|
|
2732
|
-
key: id,
|
|
2733
|
-
holder: owner
|
|
2734
|
-
};
|
|
2735
|
-
}
|
|
2736
|
-
return {
|
|
2737
|
-
granted: false,
|
|
2738
|
-
key: id,
|
|
2739
|
-
holder: current
|
|
2740
|
-
};
|
|
2741
|
-
}
|
|
2742
|
-
/** Release only the claim `owner` took — never another instance's. */
|
|
2743
|
-
function releaseInstance(home, key, owner) {
|
|
2744
|
-
const id = instanceClaimKey(home, key);
|
|
2745
|
-
if (claims.get(id) === owner) claims.delete(id);
|
|
2746
|
-
}
|
|
2747
|
-
/** The current holder of `key` at `home`, IN THIS PROCESS, or undefined
|
|
2748
|
-
* (which also covers "another process holds it" — v43 FLOW2-1). */
|
|
2749
|
-
function instanceHolder(home, key) {
|
|
2750
|
-
return claims.get(instanceClaimKey(home, key));
|
|
2751
|
-
}
|
|
2752
|
-
//#endregion
|
|
2753
|
-
//#region lib/types/write-inventory.js
|
|
2754
|
-
/**
|
|
2755
|
-
* B3 / G4 (0.3.78): the persisted-write inventory — WHICH file the family
|
|
2756
|
-
* writes, WHO writes it, and WHAT keeps two writers apart.
|
|
2757
|
-
*
|
|
2758
|
-
* The table lives in `persisted-write-inventory.json` at the package root so
|
|
2759
|
-
* the TypeScript side, the architecture gate (`verify-arch-guards` rule N20)
|
|
2760
|
-
* and the regression specs read ONE file (the row-overrides.json pattern).
|
|
2761
|
-
*
|
|
2762
|
-
* "What keeps two writers apart" has exactly three answers in this family:
|
|
2763
|
-
* - `transact` — the IO backend's cross-process write lock (transactIo);
|
|
2764
|
-
* - `write-lock` — the per-target `<path>.lock` protocol of the skill tree;
|
|
2765
|
-
* - `instance-claim` — the per-home single-instance claim (instance-scope.ts),
|
|
2766
|
-
* for a writer whose sweeps cannot be expressed as one locked file.
|
|
2767
|
-
* A site that answers with NONE of them is the "two instances, one file" class:
|
|
2768
|
-
* a per-instance serial queue looks like serialization and is not.
|
|
2769
|
-
* @module @lmzhen/dsh-evolution-core/src/write-inventory
|
|
2770
|
-
*/
|
|
2771
|
-
const SITES_URL = new URL("../persisted-write-inventory.json", import.meta.url);
|
|
2772
|
-
const SERIALIZATIONS = [
|
|
2773
|
-
"transact",
|
|
2774
|
-
"write-lock",
|
|
2775
|
-
"instance-claim",
|
|
2776
|
-
"platform-file-lock"
|
|
2777
|
-
];
|
|
2778
|
-
/** Parse + validate the table. A malformed table throws at import: a table the
|
|
2779
|
-
* gate cannot read must never degrade into "no declared write sites". */
|
|
2780
|
-
function parseTable(raw) {
|
|
2781
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) throw new Error("evolution-core: persisted-write-inventory.json must be an object with { symbols, sites }");
|
|
2782
|
-
const table = raw;
|
|
2783
|
-
if (table.symbols === null || typeof table.symbols !== "object" || Array.isArray(table.symbols)) throw new Error("evolution-core: persisted-write-inventory.json needs a symbols legend (the roots every path is written against)");
|
|
2784
|
-
for (const [symbol, entry] of Object.entries(table.symbols)) {
|
|
2785
|
-
const problems = [];
|
|
2786
|
-
if (!symbol.startsWith("<") || !symbol.endsWith(">")) problems.push("symbol name (must be <name>)");
|
|
2787
|
-
if (entry === null || typeof entry !== "object") problems.push("entry");
|
|
2788
|
-
else {
|
|
2789
|
-
const symbolEntry = entry;
|
|
2790
|
-
if (typeof symbolEntry.resolver !== "string" || symbolEntry.resolver === "") problems.push("resolver");
|
|
2791
|
-
if (symbolEntry.segments !== void 0 && (!Array.isArray(symbolEntry.segments) || symbolEntry.segments.some((segment) => typeof segment !== "string"))) problems.push("segments");
|
|
2792
|
-
}
|
|
2793
|
-
if (problems.length > 0) throw new Error(`evolution-core: persisted-write-inventory.json symbol ${symbol} is malformed (missing/invalid: ${problems.join(", ")})`);
|
|
2794
|
-
}
|
|
2795
|
-
if (!Array.isArray(table.sites)) throw new Error("evolution-core: persisted-write-inventory.json needs a sites array");
|
|
2796
|
-
const sites = [];
|
|
2797
|
-
for (const [index, entry] of table.sites.entries()) {
|
|
2798
|
-
const site = entry;
|
|
2799
|
-
const problems = [];
|
|
2800
|
-
if (typeof site.id !== "string" || site.id === "") problems.push("id");
|
|
2801
|
-
if (typeof site.path !== "string" || site.path === "") problems.push("path");
|
|
2802
|
-
if (typeof site.writer !== "string" || site.writer === "") problems.push("writer");
|
|
2803
|
-
if (typeof site.marker !== "string" || site.marker === "") problems.push("marker");
|
|
2804
|
-
if (typeof site.serializedBy !== "string" || !SERIALIZATIONS.includes(site.serializedBy)) problems.push("serializedBy");
|
|
2805
|
-
if (site.serializedBy === "instance-claim" && typeof site.instance !== "string") problems.push("instance");
|
|
2806
|
-
if (!Array.isArray(site.state)) problems.push("state");
|
|
2807
|
-
if (problems.length > 0) throw new Error(`evolution-core: persisted-write-inventory.json entry ${index} is malformed (missing/invalid: ${problems.join(", ")})`);
|
|
2808
|
-
sites.push({
|
|
2809
|
-
id: site.id,
|
|
2810
|
-
path: site.path,
|
|
2811
|
-
writer: site.writer,
|
|
2812
|
-
serializedBy: site.serializedBy,
|
|
2813
|
-
marker: site.marker,
|
|
2814
|
-
...typeof site.instance === "string" ? { instance: site.instance } : {},
|
|
2815
|
-
state: site.state,
|
|
2816
|
-
note: typeof site.note === "string" ? site.note : ""
|
|
2817
|
-
});
|
|
2818
|
-
}
|
|
2819
|
-
if (new Set(sites.map((site) => site.id)).size !== sites.length) throw new Error("evolution-core: persisted-write-inventory.json declares duplicate site ids");
|
|
2820
|
-
return {
|
|
2821
|
-
symbols: table.symbols,
|
|
2822
|
-
sites
|
|
2823
|
-
};
|
|
2824
|
-
}
|
|
2825
|
-
/** Instance keys held by writer services — the single source shared by the
|
|
2826
|
-
* claim site and the inventory row that declares it (rule N20 checks the row's
|
|
2827
|
-
* `instance` names one of these). */
|
|
2828
|
-
const INSTANCE_KEYS = {
|
|
2829
|
-
/** The per-home curator: report writing + the retention sweep. */
|
|
2830
|
-
curator: "evolution-curator" };
|
|
2831
|
-
let cachedSites;
|
|
2832
|
-
/**
|
|
2833
|
-
* The declared persisted write sites, in file order.
|
|
2834
|
-
*
|
|
2835
|
-
* v43 audit (S2-3 / P1-10): this used to be a module-scope readFileSync plus
|
|
2836
|
-
* parse, so an unshipped asset threw AT IMPORT — one absent file took the whole
|
|
2837
|
-
* family's load down (0.3.79 shipped a tarball without this asset and every
|
|
2838
|
-
* package failed to load). The read is lazy now: importing the package never
|
|
2839
|
-
* fails on this asset, while the first caller still gets a loud, descriptive
|
|
2840
|
-
* failure instead of an empty table ("no declared write sites" would silently
|
|
2841
|
-
* disable rule N20).
|
|
2842
|
-
* @internal S2.4 (PLAN 2026-09-16): no production caller — the arch guard
|
|
2843
|
-
* reads the JSON asset directly; the tests are the only in-tree consumers.
|
|
2844
|
-
* @returns the sites, in file order.
|
|
2845
|
-
*/
|
|
2846
|
-
function persistedWriteSites() {
|
|
2847
|
-
if (cachedSites !== void 0) return cachedSites;
|
|
2848
|
-
let raw;
|
|
2849
|
-
try {
|
|
2850
|
-
raw = readFileSync(fileURLToPath(SITES_URL), "utf8");
|
|
2851
|
-
} catch (error) {
|
|
2852
|
-
const cause = error instanceof Error ? error.message : String(error);
|
|
2853
|
-
throw new Error(`evolution-core: persisted-write-inventory.json is unreadable (${cause}) — the package asset is missing or was not shipped; the write-inventory rules cannot be evaluated without it`);
|
|
2854
|
-
}
|
|
2855
|
-
const table = parseTable(JSON.parse(raw));
|
|
2856
|
-
cachedSites = table.sites;
|
|
2857
|
-
return table.sites;
|
|
2858
|
-
}
|
|
2859
|
-
//#endregion
|
|
2860
|
-
//#region lib/types/scope.js
|
|
2861
|
-
function callingScope(ctx, held) {
|
|
2862
|
-
if (held !== void 0) return held;
|
|
2863
|
-
return scopeOf(ctx);
|
|
2864
|
-
}
|
|
2865
|
-
//#endregion
|
|
2866
|
-
//#region lib/types/drift-signals.js
|
|
2867
|
-
/**
|
|
2868
|
-
* Library-level drift signals for the maintenance subagent (design 011).
|
|
2869
|
-
*
|
|
2870
|
-
* Deterministic fact checks over a skill-library snapshot: domain drift
|
|
2871
|
-
* (narrow names, near-duplicate groups, prefix clusters) and layer drift
|
|
2872
|
-
* (log-like bodies, duplicate headings, overlong lines, missing support-file
|
|
2873
|
-
* pointers, description over the authoring bar). Pure functions only — no IO,
|
|
2874
|
-
* no LLM, no services. Thresholds are imported from their owning modules
|
|
2875
|
-
* (skill-health / quality / skill-store), never duplicated.
|
|
2876
|
-
*
|
|
2877
|
-
* Distinct from `signals.ts` — the session-level review signal gate.
|
|
2878
|
-
*/
|
|
2879
|
-
/** Physical line length at/above which a body line is reported overlong (011 §4). */
|
|
2880
|
-
const DRIFT_MAX_LINE_CHARS = 1500;
|
|
2881
|
-
/** Signal-set version: bump whenever ids/thresholds change (011 §7 version coupling). */
|
|
2882
|
-
const DRIFT_SIGNALS_VERSION = "3";
|
|
2883
|
-
/** Render-time nouns for the MAINTAIN_PROMPT placeholders (single vocabulary with the facts block). */
|
|
2884
|
-
const DRIFT_SIGNAL_NOUNS = {
|
|
2885
|
-
dedup_group: "近重复组",
|
|
2886
|
-
prefix_cluster: "前缀聚类",
|
|
2887
|
-
stamp_density: "stamp 密度",
|
|
2888
|
-
body_size: "正文体量",
|
|
2889
|
-
dup_heading: "重复标题",
|
|
2890
|
-
overlong_line: "超长行",
|
|
2891
|
-
pointer_missing: "缺失指针",
|
|
2892
|
-
citation_resolution: "引用解析",
|
|
2893
|
-
demand: "需求证据",
|
|
2894
|
-
description_chars: "描述长度",
|
|
2895
|
-
narrow_name: "窄名",
|
|
2896
|
-
usage_observed: "使用观察",
|
|
2897
|
-
quality_low: "质量分"
|
|
2898
|
-
};
|
|
2899
|
-
const NARROW_NAME_PATTERNS = [
|
|
2900
|
-
{
|
|
2901
|
-
label: "error-string",
|
|
2902
|
-
re: /^(?:err|error|exception|traceback|warn|fail)(?:[-_][a-z0-9]+)+$/i
|
|
2903
|
-
},
|
|
2904
|
-
{
|
|
2905
|
-
label: "pr-number",
|
|
2906
|
-
re: /^(?:pr|issue)[-_]?\d{2,}$/i
|
|
2907
|
-
},
|
|
2908
|
-
{
|
|
2909
|
-
label: "dated",
|
|
2910
|
-
re: /\d{4}-\d{2}-\d{2}/
|
|
2911
|
-
},
|
|
2912
|
-
{
|
|
2913
|
-
label: "session-verb",
|
|
2914
|
-
re: /^(?:fix|debug|audit|salvage|diagnose|investigate)[-_][a-z0-9-]+$/i
|
|
2915
|
-
}
|
|
2916
|
-
];
|
|
2917
|
-
/** Detect support files the body never references (by basename or relative path). */
|
|
2918
|
-
function missingSupportPointers(body, supportFiles) {
|
|
2919
|
-
return supportFiles.filter((path) => {
|
|
2920
|
-
const base = path.split("/").pop() ?? path;
|
|
2921
|
-
return base.length > 0 && !body.includes(base) && !body.includes(path);
|
|
2922
|
-
});
|
|
2923
|
-
}
|
|
2924
|
-
/** Support files the body mentions WITHOUT the sanctioned hook form (design
|
|
2925
|
-
* §5.6). Such a mention still counts as a pointer for `pointer_missing`, but
|
|
2926
|
-
* only the hook form keeps the file discoverable after a move — detail only.
|
|
2927
|
-
* A file carrying a `keep` marker is exempt: its mention IS the marker. */
|
|
2928
|
-
function unhookedSupportPointers(body, supportFiles) {
|
|
2929
|
-
const { targets, kept } = scanBodyHooks(body);
|
|
2930
|
-
const hooked = new Set(targets);
|
|
2931
|
-
return supportFiles.filter((path) => {
|
|
2932
|
-
if (!isFileShapedPath(path)) return false;
|
|
2933
|
-
const base = path.split("/").pop() ?? path;
|
|
2934
|
-
if (kept.has(path) || base.length > 0 && kept.has(base)) return false;
|
|
2935
|
-
return (base.length > 0 && body.includes(base) || body.includes(path)) && !hooked.has(path) && !hooked.has(base);
|
|
2936
|
-
});
|
|
2937
|
-
}
|
|
2938
|
-
/** Support files with no readers, no citations and no `keep` marker whose owning
|
|
2939
|
-
* skill has been idle for at least the lifecycle stale window. PROPOSAL INPUT
|
|
2940
|
-
* only — nothing retires a file on its own — and an unmeasurable input (no age
|
|
2941
|
-
* evidence, no citation scan) yields an empty list WITH its reason, never a
|
|
2942
|
-
* silent "nothing qualifies".
|
|
2943
|
-
* @param snapshot - the skill's drift snapshot.
|
|
2944
|
-
* @param supportFiles - its enumerated support files, in listing order.
|
|
2945
|
-
* @returns the candidates plus the status that explains an empty list.
|
|
2946
|
-
*/
|
|
2947
|
-
function retirementReport(snapshot, supportFiles) {
|
|
2948
|
-
const idle = snapshot.liveness?.idleDays;
|
|
2949
|
-
if (idle === void 0) return {
|
|
2950
|
-
candidates: [],
|
|
2951
|
-
status: "no-age"
|
|
2952
|
-
};
|
|
2953
|
-
if (snapshot.citations === void 0) return {
|
|
2954
|
-
candidates: [],
|
|
2955
|
-
status: "unscanned"
|
|
2956
|
-
};
|
|
2957
|
-
if (idle < 30) return {
|
|
2958
|
-
candidates: [],
|
|
2959
|
-
status: "none"
|
|
2960
|
-
};
|
|
2961
|
-
const cited = /* @__PURE__ */ new Set();
|
|
2962
|
-
for (const ref of snapshot.citations.refs) if (ref.kind === "citation" && ref.target !== null) cited.add(ref.target);
|
|
2963
|
-
const { kept } = scanBodyHooks(snapshot.body);
|
|
2964
|
-
const demand = snapshot.demand ?? {};
|
|
2965
|
-
const candidates = supportFiles.filter((path) => isFileShapedPath(path) && (demand[path] ?? 0) === 0 && !cited.has(path) && !kept.has(path)).map((path) => ({
|
|
2966
|
-
path,
|
|
2967
|
-
idleDays: Math.floor(idle)
|
|
2968
|
-
}));
|
|
2969
|
-
return {
|
|
2970
|
-
candidates,
|
|
2971
|
-
status: candidates.length === 0 ? "none" : "listed"
|
|
2972
|
-
};
|
|
2973
|
-
}
|
|
2974
|
-
/** Duplicate `## heading` occurrences: singleton results default to head of the file. */
|
|
2975
|
-
function duplicateHeadings(body) {
|
|
2976
|
-
const counts = /* @__PURE__ */ new Map();
|
|
2977
|
-
for (const raw of body.split("\n")) {
|
|
2978
|
-
const line = raw.endsWith("\r") ? raw.slice(0, -1) : raw;
|
|
2979
|
-
const m = /^##\s+(.+)$/.exec(line);
|
|
2980
|
-
if (m?.[1]) {
|
|
2981
|
-
const heading = m[1].trim();
|
|
2982
|
-
if (heading) counts.set(heading, (counts.get(heading) ?? 0) + 1);
|
|
2983
|
-
}
|
|
2984
|
-
}
|
|
2985
|
-
return [...counts.entries()].filter(([, count]) => count > 1).map(([heading, count]) => ({
|
|
2986
|
-
heading,
|
|
2987
|
-
count
|
|
2988
|
-
}));
|
|
2989
|
-
}
|
|
2990
|
-
/** Physical lines over `max` characters: `{ lineNo, chars }`, 1-based line numbers. */
|
|
2991
|
-
function overlongLines(body, max = DRIFT_MAX_LINE_CHARS) {
|
|
2992
|
-
const out = [];
|
|
2993
|
-
const lines = body.split("\n");
|
|
2994
|
-
for (let index = 0; index < lines.length; index += 1) {
|
|
2995
|
-
const raw = lines[index] ?? "";
|
|
2996
|
-
const length = raw.endsWith("\r") ? raw.length - 1 : raw.length;
|
|
2997
|
-
if (length > max) out.push({
|
|
2998
|
-
lineNo: index + 1,
|
|
2999
|
-
chars: length
|
|
3000
|
-
});
|
|
3001
|
-
}
|
|
3002
|
-
return out;
|
|
3003
|
-
}
|
|
3004
|
-
/** Narrow-name shapes detected in a skill name (empty = none). */
|
|
3005
|
-
function narrowNameMatches(name) {
|
|
3006
|
-
return NARROW_NAME_PATTERNS.filter(({ re }) => re.test(name)).map(({ label }) => label);
|
|
3007
|
-
}
|
|
3008
|
-
function supportGroupCount(supportFiles) {
|
|
3009
|
-
const groups = /* @__PURE__ */ new Set();
|
|
3010
|
-
for (const path of supportFiles ?? []) {
|
|
3011
|
-
const head = path.split("/")[0];
|
|
3012
|
-
if (head) groups.add(head);
|
|
3232
|
+
granted: true,
|
|
3233
|
+
key: id,
|
|
3234
|
+
holder: owner
|
|
3235
|
+
};
|
|
3013
3236
|
}
|
|
3014
|
-
return groups.size;
|
|
3015
|
-
}
|
|
3016
|
-
function sig(id, verdict, value, threshold, detail) {
|
|
3017
3237
|
return {
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
threshold,
|
|
3022
|
-
detail
|
|
3238
|
+
granted: false,
|
|
3239
|
+
key: id,
|
|
3240
|
+
holder: current
|
|
3023
3241
|
};
|
|
3024
3242
|
}
|
|
3243
|
+
/** Release only the claim `owner` took — never another instance's. */
|
|
3244
|
+
function releaseInstance(home, key, owner) {
|
|
3245
|
+
const id = instanceClaimKey(home, key);
|
|
3246
|
+
if (claims.get(id) === owner) claims.delete(id);
|
|
3247
|
+
}
|
|
3248
|
+
/** The current holder of `key` at `home`, IN THIS PROCESS, or undefined
|
|
3249
|
+
* (which also covers "another process holds it" — v43 FLOW2-1). */
|
|
3250
|
+
function instanceHolder(home, key) {
|
|
3251
|
+
return claims.get(instanceClaimKey(home, key));
|
|
3252
|
+
}
|
|
3253
|
+
//#endregion
|
|
3254
|
+
//#region lib/types/write-inventory.js
|
|
3025
3255
|
/**
|
|
3026
|
-
*
|
|
3027
|
-
*
|
|
3256
|
+
* B3 / G4 (0.3.78): the persisted-write inventory — WHICH file the family
|
|
3257
|
+
* writes, WHO writes it, and WHAT keeps two writers apart.
|
|
3258
|
+
*
|
|
3259
|
+
* The table lives in `persisted-write-inventory.json` at the package root so
|
|
3260
|
+
* the TypeScript side, the architecture gate (`verify-arch-guards` rule N20)
|
|
3261
|
+
* and the regression specs read ONE file (the row-overrides.json pattern).
|
|
3262
|
+
*
|
|
3263
|
+
* "What keeps two writers apart" has exactly three answers in this family:
|
|
3264
|
+
* - `transact` — the IO backend's cross-process write lock (transactIo);
|
|
3265
|
+
* - `write-lock` — the per-target `<path>.lock` protocol of the skill tree;
|
|
3266
|
+
* - `instance-claim` — the per-home single-instance claim (instance-scope.ts),
|
|
3267
|
+
* for a writer whose sweeps cannot be expressed as one locked file.
|
|
3268
|
+
* A site that answers with NONE of them is the "two instances, one file" class:
|
|
3269
|
+
* a per-instance serial queue looks like serialization and is not.
|
|
3270
|
+
* @module @lmzhen/dsh-evolution-core/src/write-inventory
|
|
3028
3271
|
*/
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3272
|
+
const SITES_URL = new URL("../persisted-write-inventory.json", import.meta.url);
|
|
3273
|
+
const SERIALIZATIONS = [
|
|
3274
|
+
"transact",
|
|
3275
|
+
"write-lock",
|
|
3276
|
+
"instance-claim",
|
|
3277
|
+
"platform-file-lock"
|
|
3278
|
+
];
|
|
3279
|
+
/** Parse + validate the table. A malformed table throws at import: a table the
|
|
3280
|
+
* gate cannot read must never degrade into "no declared write sites". */
|
|
3281
|
+
function parseTable(raw) {
|
|
3282
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) throw new Error("evolution-core: persisted-write-inventory.json must be an object with { symbols, sites }");
|
|
3283
|
+
const table = raw;
|
|
3284
|
+
if (table.symbols === null || typeof table.symbols !== "object" || Array.isArray(table.symbols)) throw new Error("evolution-core: persisted-write-inventory.json needs a symbols legend (the roots every path is written against)");
|
|
3285
|
+
for (const [symbol, entry] of Object.entries(table.symbols)) {
|
|
3286
|
+
const problems = [];
|
|
3287
|
+
if (!symbol.startsWith("<") || !symbol.endsWith(">")) problems.push("symbol name (must be <name>)");
|
|
3288
|
+
if (entry === null || typeof entry !== "object") problems.push("entry");
|
|
3289
|
+
else {
|
|
3290
|
+
const symbolEntry = entry;
|
|
3291
|
+
if (typeof symbolEntry.resolver !== "string" || symbolEntry.resolver === "") problems.push("resolver");
|
|
3292
|
+
if (symbolEntry.segments !== void 0 && (!Array.isArray(symbolEntry.segments) || symbolEntry.segments.some((segment) => typeof segment !== "string"))) problems.push("segments");
|
|
3293
|
+
}
|
|
3294
|
+
if (problems.length > 0) throw new Error(`evolution-core: persisted-write-inventory.json symbol ${symbol} is malformed (missing/invalid: ${problems.join(", ")})`);
|
|
3295
|
+
}
|
|
3296
|
+
if (!Array.isArray(table.sites)) throw new Error("evolution-core: persisted-write-inventory.json needs a sites array");
|
|
3297
|
+
const sites = [];
|
|
3298
|
+
for (const [index, entry] of table.sites.entries()) {
|
|
3299
|
+
const site = entry;
|
|
3300
|
+
const problems = [];
|
|
3301
|
+
if (typeof site.id !== "string" || site.id === "") problems.push("id");
|
|
3302
|
+
if (typeof site.path !== "string" || site.path === "") problems.push("path");
|
|
3303
|
+
if (typeof site.writer !== "string" || site.writer === "") problems.push("writer");
|
|
3304
|
+
if (typeof site.marker !== "string" || site.marker === "") problems.push("marker");
|
|
3305
|
+
if (typeof site.serializedBy !== "string" || !SERIALIZATIONS.includes(site.serializedBy)) problems.push("serializedBy");
|
|
3306
|
+
if (site.serializedBy === "instance-claim" && typeof site.instance !== "string") problems.push("instance");
|
|
3307
|
+
if (!Array.isArray(site.state)) problems.push("state");
|
|
3308
|
+
if (problems.length > 0) throw new Error(`evolution-core: persisted-write-inventory.json entry ${index} is malformed (missing/invalid: ${problems.join(", ")})`);
|
|
3309
|
+
sites.push({
|
|
3310
|
+
id: site.id,
|
|
3311
|
+
path: site.path,
|
|
3312
|
+
writer: site.writer,
|
|
3313
|
+
serializedBy: site.serializedBy,
|
|
3314
|
+
marker: site.marker,
|
|
3315
|
+
...typeof site.instance === "string" ? { instance: site.instance } : {},
|
|
3316
|
+
state: site.state,
|
|
3317
|
+
note: typeof site.note === "string" ? site.note : ""
|
|
3318
|
+
});
|
|
3319
|
+
}
|
|
3320
|
+
if (new Set(sites.map((site) => site.id)).size !== sites.length) throw new Error("evolution-core: persisted-write-inventory.json declares duplicate site ids");
|
|
3039
3321
|
return {
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
const signals = [];
|
|
3043
|
-
const body = snapshot.body;
|
|
3044
|
-
const supportFiles = snapshot.supportFiles ?? [];
|
|
3045
|
-
const supportEnumerated = snapshot.supportFiles !== void 0;
|
|
3046
|
-
const density = assessStructureHealth({
|
|
3047
|
-
skillName: snapshot.name,
|
|
3048
|
-
bodyChars: body.length,
|
|
3049
|
-
bodyText: body,
|
|
3050
|
-
supportGroups: supportGroupCount(supportFiles)
|
|
3051
|
-
}, DEFAULT_HEALTH_THRESHOLDS).dims.stampDensityPerKb;
|
|
3052
|
-
signals.push(density === null ? sig("stamp_density", "pass", "below-min-body") : sig("stamp_density", density >= DEFAULT_HEALTH_THRESHOLDS.stampDensityPerKb ? "over" : "pass", `${density.toFixed(2)}/KB`, `${DEFAULT_HEALTH_THRESHOLDS.stampDensityPerKb}/KB`));
|
|
3053
|
-
const cost = snapshot.cost;
|
|
3054
|
-
const lineTokens = cost === void 0 ? null : tokenLineFor(DEFAULT_HEALTH_THRESHOLDS.softBodyChars, cost);
|
|
3055
|
-
const overLine = cost === void 0 || lineTokens === null ? body.length >= DEFAULT_HEALTH_THRESHOLDS.softBodyChars : cost.tokens >= lineTokens;
|
|
3056
|
-
signals.push(sig("body_size", overLine ? "over" : "pass", cost === void 0 ? `${body.length}` : `${cost.tokens} tokens / ${body.length} chars`, cost === void 0 || lineTokens === null ? `${DEFAULT_HEALTH_THRESHOLDS.softBodyChars}` : `line=${lineTokens} tokens (${DEFAULT_HEALTH_THRESHOLDS.softBodyChars} chars)`, cost === void 0 ? void 0 : `estimate range ${cost.tokensLow}-${cost.tokensHigh} tokens (4 chars/token basis); cjk=${cost.cjk}${lineTokens === null ? "" : `; line=${lineTokens}, body=${(cost.tokens / lineTokens).toFixed(1)}x`}${oversizeSupportNote(snapshot.supportChars)}`));
|
|
3057
|
-
const dupes = duplicateHeadings(body);
|
|
3058
|
-
signals.push(dupes.length === 0 ? sig("dup_heading", "pass", "none") : sig("dup_heading", "over", dupes.map((d) => `${d.heading}(${d.count})`).join(", "), "count >= 2"));
|
|
3059
|
-
const long = overlongLines(body);
|
|
3060
|
-
signals.push(long.length === 0 ? sig("overlong_line", "pass", "none") : sig("overlong_line", "over", long.map((l) => `${l.lineNo}:${l.chars}`).join(", "), `${DRIFT_MAX_LINE_CHARS}`));
|
|
3061
|
-
const missing = supportEnumerated ? missingSupportPointers(body, supportFiles) : void 0;
|
|
3062
|
-
const unhooked = supportEnumerated ? unhookedSupportPointers(body, supportFiles) : [];
|
|
3063
|
-
const unhookedDetail = unhooked.length === 0 ? void 0 : `unhooked=${unhooked.length}: ${unhooked.slice(0, 5).join(", ")}`;
|
|
3064
|
-
signals.push(!supportEnumerated ? sig("pointer_missing", "unknown", "not-enumerated", void 0, "support files not enumerated") : (missing ?? []).length === 0 ? sig("pointer_missing", "pass", "none", void 0, unhookedDetail) : sig("pointer_missing", "over", missing?.join(", ") ?? "", void 0, unhookedDetail));
|
|
3065
|
-
signals.push(citationSignal(snapshot.citations));
|
|
3066
|
-
signals.push(demandSignal(snapshot, supportFiles, supportEnumerated));
|
|
3067
|
-
const narrow = narrowNameMatches(snapshot.name);
|
|
3068
|
-
signals.push(narrow.length === 0 ? sig("narrow_name", "pass", "none") : sig("narrow_name", "over", narrow.join(", "), void 0, `name=${snapshot.name}`));
|
|
3069
|
-
const description = snapshot.description;
|
|
3070
|
-
signals.push(description === void 0 ? sig("description_chars", "unknown", "missing", `60`) : sig("description_chars", description.length > 60 ? "over" : "pass", `${description.length}`, `60`));
|
|
3071
|
-
const quality = snapshot.quality;
|
|
3072
|
-
signals.push(quality === null || quality === void 0 ? sig("quality_low", "unknown", "not-assessed") : sig("quality_low", quality < .3 ? "over" : "pass", quality.toFixed(2), `${LOW_QUALITY_THRESHOLD}`));
|
|
3073
|
-
return {
|
|
3074
|
-
name: snapshot.name,
|
|
3075
|
-
signals,
|
|
3076
|
-
...snapshot.protected !== void 0 && snapshot.protected !== null ? { protected: snapshot.protected } : {},
|
|
3077
|
-
...snapshot.catalogInvalid !== void 0 ? { catalogInvalid: snapshot.catalogInvalid } : {}
|
|
3078
|
-
};
|
|
3079
|
-
})
|
|
3322
|
+
symbols: table.symbols,
|
|
3323
|
+
sites
|
|
3080
3324
|
};
|
|
3081
3325
|
}
|
|
3082
|
-
/**
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
*
|
|
3095
|
-
*
|
|
3096
|
-
*
|
|
3097
|
-
*
|
|
3326
|
+
/** Instance keys held by writer services — the single source shared by the
|
|
3327
|
+
* claim site and the inventory row that declares it (rule N20 checks the row's
|
|
3328
|
+
* `instance` names one of these). */
|
|
3329
|
+
const INSTANCE_KEYS = {
|
|
3330
|
+
/** The per-home curator: report writing + the retention sweep. */
|
|
3331
|
+
curator: "evolution-curator" };
|
|
3332
|
+
let cachedSites;
|
|
3333
|
+
/**
|
|
3334
|
+
* The declared persisted write sites, in file order.
|
|
3335
|
+
*
|
|
3336
|
+
* v43 audit (S2-3 / P1-10): this used to be a module-scope readFileSync plus
|
|
3337
|
+
* parse, so an unshipped asset threw AT IMPORT — one absent file took the whole
|
|
3338
|
+
* family's load down (0.3.79 shipped a tarball without this asset and every
|
|
3339
|
+
* package failed to load). The read is lazy now: importing the package never
|
|
3340
|
+
* fails on this asset, while the first caller still gets a loud, descriptive
|
|
3341
|
+
* failure instead of an empty table ("no declared write sites" would silently
|
|
3342
|
+
* disable rule N20).
|
|
3343
|
+
* @internal S2.4 (PLAN 2026-09-16): no production caller — the arch guard
|
|
3344
|
+
* reads the JSON asset directly; the tests are the only in-tree consumers.
|
|
3345
|
+
* @returns the sites, in file order.
|
|
3098
3346
|
*/
|
|
3099
|
-
function
|
|
3100
|
-
if (
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
unscanned: "citations unscanned"
|
|
3112
|
-
};
|
|
3113
|
-
/** Cold-support-file verdict (design §5.5): zero reads are evidence only while
|
|
3114
|
-
* the observation window is open and the file list is known. */
|
|
3115
|
-
function demandSignal(snapshot, supportFiles, supportEnumerated) {
|
|
3116
|
-
if (!supportEnumerated || supportFiles.length === 0) return sig("demand", "unknown", "not-enumerated", void 0, "support files not enumerated");
|
|
3117
|
-
if (snapshot.usageObserved !== true) return sig("demand", "unknown", "window-closed", void 0, "no observed reads yet: zero is not evidence");
|
|
3118
|
-
const demand = snapshot.demand ?? {};
|
|
3119
|
-
const cold = supportFiles.filter((path) => (demand[path] ?? 0) === 0);
|
|
3120
|
-
const retire = retirementReport(snapshot, supportFiles);
|
|
3121
|
-
const retireDetail = retire.candidates.length === 0 ? `retire: ${RETIREMENT_STATUS_TEXT[retire.status]}` : `retire≥30d: ${retire.candidates.slice(0, 5).map((c) => `${c.path}(${c.idleDays}d)`).join(", ")}`;
|
|
3122
|
-
if (cold.length === 0) return sig("demand", "pass", `${supportFiles.length} warm`, "cold=0", retireDetail);
|
|
3123
|
-
const sample = cold.slice(0, 5).join(", ");
|
|
3124
|
-
return sig("demand", "over", `cold=${cold.length}/${supportFiles.length}`, "cold=0", `never read: ${sample} · ${retireDetail}`);
|
|
3347
|
+
function persistedWriteSites() {
|
|
3348
|
+
if (cachedSites !== void 0) return cachedSites;
|
|
3349
|
+
let raw;
|
|
3350
|
+
try {
|
|
3351
|
+
raw = readFileSync(fileURLToPath(SITES_URL), "utf8");
|
|
3352
|
+
} catch (error) {
|
|
3353
|
+
const cause = error instanceof Error ? error.message : String(error);
|
|
3354
|
+
throw new Error(`evolution-core: persisted-write-inventory.json is unreadable (${cause}) — the package asset is missing or was not shipped; the write-inventory rules cannot be evaluated without it`);
|
|
3355
|
+
}
|
|
3356
|
+
const table = parseTable(JSON.parse(raw));
|
|
3357
|
+
cachedSites = table.sites;
|
|
3358
|
+
return table.sites;
|
|
3125
3359
|
}
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3360
|
+
//#endregion
|
|
3361
|
+
//#region lib/types/scope.js
|
|
3362
|
+
function callingScope(ctx, held) {
|
|
3363
|
+
if (held !== void 0) return held;
|
|
3364
|
+
return scopeOf(ctx);
|
|
3129
3365
|
}
|
|
3130
3366
|
//#endregion
|
|
3131
3367
|
//#region lib/types/store-ledger.js
|
|
@@ -3836,9 +4072,9 @@ const PARAM_EXPOSURE = Object.freeze([
|
|
|
3836
4072
|
owner: "memory-files",
|
|
3837
4073
|
applies: "live",
|
|
3838
4074
|
docAnchor: "PARAMETERS.md#memory",
|
|
3839
|
-
summary: "
|
|
3840
|
-
label: "
|
|
3841
|
-
hint: "
|
|
4075
|
+
summary: "Legacy character budget for MEMORY.md; only an explicit legacy override, otherwise the token budget governs.",
|
|
4076
|
+
label: "记忆库字符上限(旧)",
|
|
4077
|
+
hint: "旧口径:长期记忆文件最多多少字符。设置后按字符模式工作;未设置时按 token 预算。",
|
|
3842
4078
|
control: "number",
|
|
3843
4079
|
unit: "字符",
|
|
3844
4080
|
values: "",
|
|
@@ -3852,14 +4088,46 @@ const PARAM_EXPOSURE = Object.freeze([
|
|
|
3852
4088
|
owner: "memory-files",
|
|
3853
4089
|
applies: "live",
|
|
3854
4090
|
docAnchor: "PARAMETERS.md#memory",
|
|
3855
|
-
summary: "
|
|
3856
|
-
label: "
|
|
3857
|
-
hint: "
|
|
4091
|
+
summary: "Legacy character budget for USER.md; only an explicit legacy override, otherwise the token budget governs.",
|
|
4092
|
+
label: "用户画像字符上限(旧)",
|
|
4093
|
+
hint: "旧口径:用户画像文件最多多少字符。设置后按字符模式工作;未设置时按 token 预算。",
|
|
3858
4094
|
control: "number",
|
|
3859
4095
|
unit: "字符",
|
|
3860
4096
|
values: "",
|
|
3861
4097
|
card: "memory-files"
|
|
3862
4098
|
},
|
|
4099
|
+
{
|
|
4100
|
+
id: "memoryTokens",
|
|
4101
|
+
group: "memory",
|
|
4102
|
+
tier: "E3",
|
|
4103
|
+
authority: "cordis",
|
|
4104
|
+
owner: "memory-files",
|
|
4105
|
+
applies: "live",
|
|
4106
|
+
docAnchor: "PARAMETERS.md#memory",
|
|
4107
|
+
summary: "Estimated token budget for MEMORY.md; the default is derived from the old 2200-character limit.",
|
|
4108
|
+
label: "记忆库 token 上限",
|
|
4109
|
+
hint: "长期记忆按估算 token 计;默认 800,约等于旧英文 2200 字符的上下文成本。",
|
|
4110
|
+
control: "number",
|
|
4111
|
+
unit: "token",
|
|
4112
|
+
values: "",
|
|
4113
|
+
card: "memory-files"
|
|
4114
|
+
},
|
|
4115
|
+
{
|
|
4116
|
+
id: "userTokens",
|
|
4117
|
+
group: "memory",
|
|
4118
|
+
tier: "E3",
|
|
4119
|
+
authority: "cordis",
|
|
4120
|
+
owner: "memory-files",
|
|
4121
|
+
applies: "live",
|
|
4122
|
+
docAnchor: "PARAMETERS.md#memory",
|
|
4123
|
+
summary: "Estimated token budget for USER.md; the default is derived from the old 1375-character limit.",
|
|
4124
|
+
label: "用户画像 token 上限",
|
|
4125
|
+
hint: "用户画像按估算 token 计;默认 500,约等于旧英文 1375 字符的上下文成本。",
|
|
4126
|
+
control: "number",
|
|
4127
|
+
unit: "token",
|
|
4128
|
+
values: "",
|
|
4129
|
+
card: "memory-files"
|
|
4130
|
+
},
|
|
3863
4131
|
{
|
|
3864
4132
|
id: "memoryEnabled",
|
|
3865
4133
|
group: "memory",
|
|
@@ -4059,6 +4327,22 @@ const PARAM_EXPOSURE = Object.freeze([
|
|
|
4059
4327
|
values: "",
|
|
4060
4328
|
card: "evolution-curator"
|
|
4061
4329
|
},
|
|
4330
|
+
{
|
|
4331
|
+
id: "healthSoftBodyTokens",
|
|
4332
|
+
group: "curator",
|
|
4333
|
+
tier: "E3",
|
|
4334
|
+
authority: "cordis",
|
|
4335
|
+
owner: "evolution-curator",
|
|
4336
|
+
applies: "live",
|
|
4337
|
+
docAnchor: "PARAMETERS.md#curator",
|
|
4338
|
+
summary: "Estimated body token line the health view judges against.",
|
|
4339
|
+
label: "正文长度参考(token)",
|
|
4340
|
+
hint: "技能正文超过多少估算 token 算偏长(只用于健康提示);中文约 7.3k 字符、英文约 21.8k 字符触发默认 7,273。",
|
|
4341
|
+
control: "number",
|
|
4342
|
+
unit: "token",
|
|
4343
|
+
values: "",
|
|
4344
|
+
card: "evolution-curator"
|
|
4345
|
+
},
|
|
4062
4346
|
{
|
|
4063
4347
|
id: "healthSoftBodyChars",
|
|
4064
4348
|
group: "curator",
|
|
@@ -4067,9 +4351,9 @@ const PARAM_EXPOSURE = Object.freeze([
|
|
|
4067
4351
|
owner: "evolution-curator",
|
|
4068
4352
|
applies: "live",
|
|
4069
4353
|
docAnchor: "PARAMETERS.md#curator",
|
|
4070
|
-
summary: "
|
|
4071
|
-
label: "
|
|
4072
|
-
hint: "
|
|
4354
|
+
summary: "Legacy body character line; converted once to healthSoftBodyTokens when no token value is set.",
|
|
4355
|
+
label: "正文长度参考(旧字符)",
|
|
4356
|
+
hint: "旧口径:技能正文超过多少字符算偏长。设置后按 2.75 字符/token 换算;未设置时按 token 预算。",
|
|
4073
4357
|
control: "number",
|
|
4074
4358
|
unit: "字符",
|
|
4075
4359
|
values: "",
|
|
@@ -5271,4 +5555,4 @@ function classifySessionEvent(event) {
|
|
|
5271
5555
|
return MODEL_EVENT_TYPES.has(type) ? "model" : "unknown";
|
|
5272
5556
|
}
|
|
5273
5557
|
//#endregion
|
|
5274
|
-
export { AUTHORING_DESCRIPTION_BAR, AUTHORING_SPLIT_LINE_CHARS, AuthorityBusyError, AuthorityOrderError, AuthorityReentryError, CITATION_SUPPORT_DIRS, COMBINED_REVIEW_PROMPT, COMPLETION_SKILL_REVIEW_PROMPT, CONTENT_SPLIT_HINT,
|
|
5558
|
+
export { AUTHORING_DESCRIPTION_BAR, AUTHORING_SPLIT_LINE_CHARS, AuthorityBusyError, AuthorityOrderError, AuthorityReentryError, CITATION_SUPPORT_DIRS, COMBINED_REVIEW_PROMPT, COMPLETION_SKILL_REVIEW_PROMPT, CONTENT_SPLIT_HINT, CURATOR_DRY_RUN_BANNER, CURATOR_PROMPT, DEDUP_MAX_PAIR_COMPARISONS, DEDUP_SIMILARITY_THRESHOLD, 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_MEMORY_TOKENS, DEFAULT_MIN_IDLE_HOURS, DEFAULT_MUTATION_CAP, DEFAULT_PROBE_TIMEOUT_MS, DEFAULT_REFERENCE_REWRITE_POLICY, DEFAULT_REVIEW_MEMORY_INTERVAL, 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_SOFT_BODY_TOKENS, 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_USER_TOKENS, 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, EvolutionGateSet, FAMILY_SESSION_TOOL_NAMES, FORBIDDEN_CONTROL_KEYS, FUZZY_MAX_PATTERN_CHARS, FUZZY_MAX_WORK, GOVERNANCE_PROMPT_TEMPLATE, 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_ENTRY_PREVIEW_GRAPHEMES, MEMORY_GUIDANCE_SECTION_ORDER, MEMORY_REVIEW_PROMPT, MEMORY_TOKENS, MERGE_BODY_PREVIEW_BYTES, 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_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, REVIEW_TEXT_PREVIEW_GRAPHEMES, RUNS_SCHEMA_VERSION, SKILLS_GUIDANCE, SKILLS_GUIDANCE_SECTION_ORDER, SKILL_ACTION_REQUIRED_FIELDS, SKILL_NAME_RE, SKILL_REVIEW_PROMPT, SOFT_BODY_TOKENS, STORE_LEDGER, SUMMARY_DUPLICATE_HINT_THRESHOLD, SUPPORT_DIRS, SUPPORT_SPRAWL_FILES, SUPPRESSED_FILE_VERSION, TEXT_BUDGETS, TEXT_DIFF_MAX_GRAPHEMES, THREAT_EXEMPTION_HINT, ToolDispatchNormalizer, ToolDispatchPayloadError, TransactionNotInvokedError, UPSTREAM_LIMIT_CHARS_PER_TOKEN, USER_TOKENS, VERSION_BODY_PREVIEW_GRAPHEMES, VIEW_WINDOW_DAYS, abortLink, absentHostServices, advanceReview, affinity, allowRowCollisions, appendEvolutionEvent, applyCuratorLifecycleFields, applyCuratorMetaFields, applyNamespaceMigration, applyReferenceRewrite, asRecord, assertDispatchPayload, atomicWriteFiles, authorityFrom, authorityHolder, backupsReachability, buildCuratorRunReport, buildHealthBaseline, buildLearnPrompt, bumpPatch, bumpSupportRead, bumpUse, bumpView, callingScope, claimInstance, clampOnce, clampedNumber, classifyNamespaceMigration, classifySessionEvent, clearReviewChannel, codePointCount, collectReadSkillNames, collectReadSupportFiles, compareTextBudget, computeDedupGroups, computeDriftSignals, computeLifecycleTransitions, computePrefixClusters, computeQualityScores, computeScopeView, conservativeTokenEstimator, contentHash, createGateSet, createSubagentKernel as createSubagentChannel, createSubagentKernel, createSubagentRun, 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, fuzzyPatch, getRecord, graphemeCount, h2Sections, historyReachability, hostSurface, identity, idleDays, initialTurnFold, instanceClaimKey, instanceHolder, isAbsent, isBookkeepingFrame, isCommittedWarning, isDeprecatedParamId, isFileShapedPath, isMissingPath, isPresent, isProcessAlive, isProjectableSession, isRecord, isReviewChannelSession, isSkillReadToolName, isSkillToolName, isUnknown, json, latestActivityAt, leaseAsTreeLock, leaseFile, lifecycleCandidate, listEventArchives, liveBool, liveNumber, loadMutations, loadSuppressedNames, loadUsage, makeSerialQueue, markAgentCreated, markReviewChannel, measureText, measureUnit, memoryRoot, methodNotAllowed, missingSupportPointers, mutateUsage, mutationLockFrom, mutationsFile, narrowNameMatches, nearDuplicateSummaries, newRunRegistry, nodeEvolutionIo, normalizeUsageRecord, observeEvent, overlongLines, ownerCandidatesFromSummaries, paramRowId, paramSettingsId, parseCuratorNominations, parseEvolutionEvents, payloadText, persistedWriteSites, pickWithPolicy, planNamespaceMigration, planReferenceRewrite, planRehoming, policyStageLimits, probeAbsent, probeChannelState, probeList, probeMtime, probePresent, probeReason, probeText, probeUnknown, projectionText, proposalFromPlan, proposalReportDir, proposalReportName, protectedSkillNamesOf, readDispatchSignal, readEvolutionEvents, readEvolutionTimeline, readExternalSupport, readJsonObject, readNumberParam, readParam, readProposalReport, readProposalReports, readingStats, recentViewCount, recordMutation, recordReviewRead, redactSecrets, referencedBlobs, registerHostRoutes, releaseInstance, renameWithRetry, renderCuratorReportMarkdown, reportTime, reportsReachability, reportsSweepLockTarget, resolveCitations, resolveParamId, retainEventArchives, retirementReport, reviewPrompt, runWriteGates, runsFile, saveSuppressedNames, saveUsage, scanBodyHooks, scanContentThreats, scanMemoryThreats, scanThreats, scopeOfNearestManifest, scopedPackageName, scopedProbeReport, selectSections, sessionAudited, sessionEvidenceIndex, sessionLastEventTime, sessionReadNames, sessionSeesFamilyTools, sessionTurnSignals, skillReadNameOf, skillWriteGateContext, supportFileReadFromPath, supportFileReadOf, supportRefs, suppressedFile, sweepReports, sweepReviewChannelSessions, textOfValue, transactIo, trimPatternBoundaries, truncateGraphemes, unhookedSupportPointers, unwrapLive, updateSuppressedNames, usageFile, usageObserved, userSetKeys, utf8ByteLength, verifyPromptBundle, vocabulary, waitForSubagentEnd, withReviewContext, withTreeWrite, writeDurableTmp, writeProposalReport };
|