@lmzhen/dsh-evolution-core 0.46.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/authority-plugin.js +1 -1
- package/lib/composition/index.js +3 -3
- package/lib/{composition-Da8NfRI7.js → composition-Cqjbho0t.js} +1 -1
- package/lib/{ensure-C5Mo1dbB.js → ensure-CAjLGd9f.js} +1 -2
- package/lib/http-routes.js +21 -96
- package/lib/index.js +26 -138
- package/lib/{io-AmUf4lVY.js → io-BCBSr6Ot.js} +1 -63
- package/lib/io-node.js +1 -1
- package/lib/io-registry.js +14 -29
- package/lib/{mutation-authority-DeJ_Wz14.js → mutation-authority-CM6wRgyK.js} +4 -14
- package/lib/{mutations-DwvbjRHF.js → mutations-DihgpfgG.js} +1 -1
- package/lib/runtime/plugin.js +1 -1
- package/lib/{session-projection-EB7mUOlJ.js → session-projection-BhlDXqws.js} +2 -2
- package/lib/{skill-health-D1pZGk5V.js → skill-health-BzkUQDi7.js} +3 -24
- package/lib/{skill-history-CjypdYqv.js → skill-history-RWt1-kbZ.js} +14 -54
- package/lib/skills.js +7 -7
- package/lib/subagent/index.js +4 -10
- package/lib/types/composition/preset-ids.d.ts +0 -1
- package/lib/types/composition/preset-ids.js +0 -1
- package/lib/types/curator.d.ts +0 -1
- package/lib/types/curator.js +0 -1
- package/lib/types/document-body.d.ts +0 -12
- package/lib/types/document-body.js +0 -14
- package/lib/types/http-routes.d.ts +9 -4
- package/lib/types/http-routes.js +36 -116
- package/lib/types/index.d.ts +0 -3
- package/lib/types/index.js +0 -3
- package/lib/types/io-registry.d.ts +11 -11
- package/lib/types/io-registry.js +13 -16
- package/lib/types/io.d.ts +0 -53
- package/lib/types/io.js +0 -56
- package/lib/types/journal-protocol.d.ts +0 -15
- package/lib/types/journal-protocol.js +1 -19
- package/lib/types/lease-store.d.ts +1 -1
- package/lib/types/lease-store.js +4 -15
- package/lib/types/live.d.ts +0 -12
- package/lib/types/live.js +0 -18
- package/lib/types/memory-store.d.ts +0 -1
- package/lib/types/memory-store.js +0 -1
- package/lib/types/mutation-unit.js +5 -4
- package/lib/types/probe.d.ts +0 -3
- package/lib/types/probe.js +0 -7
- package/lib/types/run-registry.js +10 -12
- package/lib/types/session-fold.d.ts +0 -8
- package/lib/types/session-fold.js +0 -5
- package/lib/types/session-projection.js +2 -2
- package/lib/types/skill-discovery.d.ts +0 -2
- package/lib/types/skill-discovery.js +1 -2
- package/lib/types/skill-history.d.ts +0 -24
- package/lib/types/skill-history.js +0 -41
- package/lib/types/skill-lint.d.ts +0 -3
- package/lib/types/skill-lint.js +0 -12
- package/lib/types/subagent/readiness.d.ts +0 -1
- package/lib/types/subagent/readiness.js +2 -8
- package/lib/types/unit-journal.d.ts +1 -1
- package/lib/types/unit-journal.js +2 -4
- package/lib/types/unit-storage.d.ts +1 -1
- package/lib/types/unit-storage.js +5 -16
- package/lib/write.js +2 -2
- package/package.json +1 -1
- package/persisted-write-inventory.json +47 -2
- package/lib/types/fold-untrusted.d.ts +0 -35
- package/lib/types/fold-untrusted.js +0 -44
- package/lib/types/unit-recovery.d.ts +0 -5
- package/lib/types/unit-recovery.js +0 -12
|
@@ -668,47 +668,6 @@ export function textDiffFacts(before, after, path, maxLines = TEXT_DIFF_MAX_LINE
|
|
|
668
668
|
truncated: oldWindow.cut || newWindow.cut,
|
|
669
669
|
};
|
|
670
670
|
}
|
|
671
|
-
/** Characters one generated summary may carry. */
|
|
672
|
-
export const VERSION_SUMMARY_MAX_CHARS = 80;
|
|
673
|
-
/**
|
|
674
|
-
* The fixed prompt the optional per-write summarizer runs (registry `skillVersionSummary`).
|
|
675
|
-
*
|
|
676
|
-
* Model-visible, so it is written from the model’s perspective and pinned: the tests assert that it
|
|
677
|
-
* carries the skill name, the character cap and both bodies, because a silent change to a prompt is a
|
|
678
|
-
* silent change to what every recorded version says.
|
|
679
|
-
* @param input - the skill, the action, and the two bodies (null when absent).
|
|
680
|
-
* @returns the prompt text.
|
|
681
|
-
*/
|
|
682
|
-
export function versionSummaryPrompt(input) {
|
|
683
|
-
return [
|
|
684
|
-
'You are writing ONE line that tells a reader what this single edit to the agent skill',
|
|
685
|
-
'"' + input.name + '" changed. The edit action was "' + input.action + '".',
|
|
686
|
-
'Rules: at most ' + String(VERSION_SUMMARY_MAX_CHARS) + ' characters; the same language as the body;',
|
|
687
|
-
'name the decision, number or section that moved (for example "keeps 30 days instead of 90 days");',
|
|
688
|
-
'never say merely that something changed; no preamble, quotes, markdown or trailing period.',
|
|
689
|
-
'',
|
|
690
|
-
'Body BEFORE the edit:',
|
|
691
|
-
input.before ?? '(the skill did not exist before this edit)',
|
|
692
|
-
'',
|
|
693
|
-
'Body AFTER the edit:',
|
|
694
|
-
input.after ?? '(the skill does not exist after this edit)',
|
|
695
|
-
].join('\n');
|
|
696
|
-
}
|
|
697
|
-
/**
|
|
698
|
-
* Reduce a model answer to the one line the index stores.
|
|
699
|
-
* @param raw - the model’s answer, whatever shape it came in.
|
|
700
|
-
* @param maxChars - the character cap.
|
|
701
|
-
* @returns the one line, or undefined when there is nothing usable (callers store no summary).
|
|
702
|
-
*/
|
|
703
|
-
export function normalizeVersionSummary(raw, maxChars = VERSION_SUMMARY_MAX_CHARS) {
|
|
704
|
-
const firstLine = raw.split('\n').map(line => line.trim()).find(line => line !== '');
|
|
705
|
-
if (firstLine === undefined)
|
|
706
|
-
return undefined;
|
|
707
|
-
const stripped = firstLine.replace(/^["'`*•s]+/u, '').replace(/["'`*s]+$/u, '').replace(/[。.]$/u, '').trim();
|
|
708
|
-
if (stripped === '')
|
|
709
|
-
return undefined;
|
|
710
|
-
return stripped.length > maxChars ? stripped.slice(0, maxChars - 1) + '…' : stripped;
|
|
711
|
-
}
|
|
712
671
|
/**
|
|
713
672
|
* How long ago an ISO timestamp was, as a bucket plus a count — never as a sentence.
|
|
714
673
|
*
|
|
@@ -54,8 +54,5 @@ export declare function diffFindings(before: readonly LintFinding[], after: read
|
|
|
54
54
|
worsened: LintFinding[];
|
|
55
55
|
resolved: string[];
|
|
56
56
|
};
|
|
57
|
-
/** Support files = markdown files under references/ (contract §4: unit frozen, underscore-prefixed
|
|
58
|
-
* excluded). Paths are supplied by the caller — this module never touches the filesystem. */
|
|
59
|
-
export declare function countReferenceFiles(paths: readonly string[]): number;
|
|
60
57
|
export {};
|
|
61
58
|
//# sourceMappingURL=skill-lint.d.ts.map
|
package/lib/types/skill-lint.js
CHANGED
|
@@ -108,16 +108,4 @@ export function diffFindings(before, after) {
|
|
|
108
108
|
const resolved = before.filter(f => !afterByRule.has(f.rule)).map(f => f.rule);
|
|
109
109
|
return { introduced, worsened, resolved };
|
|
110
110
|
}
|
|
111
|
-
/** Support files = markdown files under references/ (contract §4: unit frozen, underscore-prefixed
|
|
112
|
-
* excluded). Paths are supplied by the caller — this module never touches the filesystem. */
|
|
113
|
-
export function countReferenceFiles(paths) {
|
|
114
|
-
return paths.filter((p) => {
|
|
115
|
-
const n = p.replace(/\\/g, '/');
|
|
116
|
-
const inReferences = n.includes('/references/') || n.startsWith('references/');
|
|
117
|
-
if (!inReferences || !n.endsWith('.md'))
|
|
118
|
-
return false;
|
|
119
|
-
const base = n.slice(n.lastIndexOf('/') + 1);
|
|
120
|
-
return !base.startsWith('_');
|
|
121
|
-
}).length;
|
|
122
|
-
}
|
|
123
111
|
//# sourceMappingURL=skill-lint.js.map
|
|
@@ -2,5 +2,4 @@ import type { Context } from '@deepseek-ai/cordis';
|
|
|
2
2
|
import type { ChannelKind, ChannelState } from './types.ts';
|
|
3
3
|
/** Pure derivation (no side effects): the doctor reads this, the channel re-probes on every run. */
|
|
4
4
|
export declare function probeChannelState(ctx: Context, kind: ChannelKind): ChannelState;
|
|
5
|
-
export declare function subagentChannelState(ctx: Context, kind: ChannelKind): ChannelState;
|
|
6
5
|
//# sourceMappingURL=readiness.d.ts.map
|
|
@@ -3,9 +3,6 @@ import { restrictedPresetId } from "../composition/preset-ids.js";
|
|
|
3
3
|
function serviceOf(ctx, name) {
|
|
4
4
|
return ctx.get(name);
|
|
5
5
|
}
|
|
6
|
-
function kindOf(kind) {
|
|
7
|
-
return kind === 'reviewer' ? 'reviewer' : 'maintainer';
|
|
8
|
-
}
|
|
9
6
|
/** Pure derivation (no side effects): the doctor reads this, the channel re-probes on every run. */
|
|
10
7
|
export function probeChannelState(ctx, kind) {
|
|
11
8
|
const subagents = serviceOf(ctx, 'subagents');
|
|
@@ -25,11 +22,8 @@ export function probeChannelState(ctx, kind) {
|
|
|
25
22
|
if (agentPresets === undefined || typeof agentPresets.readDocument !== 'function' || typeof agentPresets.register !== 'function') {
|
|
26
23
|
return { kind: 'unavailable', code: 'E-323', reason: 'agentPresets service unavailable or incomplete' };
|
|
27
24
|
}
|
|
28
|
-
const id = restrictedPresetId(
|
|
29
|
-
const state = restrictedPresetState(ctx,
|
|
25
|
+
const id = restrictedPresetId(kind);
|
|
26
|
+
const state = restrictedPresetState(ctx, kind);
|
|
30
27
|
return { kind: 'available', provider: 'spawn', preset: { id, registered: state?.kind === 'ready' } };
|
|
31
28
|
}
|
|
32
|
-
export function subagentChannelState(ctx, kind) {
|
|
33
|
-
return probeChannelState(ctx, kind);
|
|
34
|
-
}
|
|
35
29
|
//# sourceMappingURL=readiness.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type EvolutionIoLike } from './io.ts';
|
|
2
2
|
export declare const UNIT_JOURNAL_SCHEMA_VERSION = 1;
|
|
3
3
|
export declare const UNIT_JOURNAL_PHASES: readonly ["prepared", "target-pending", "target-written", "source-archiving", "support-pending", "sources-archived", "unit-written", "committed", "failed", "rolled-back"];
|
|
4
4
|
export type UnitJournalPhase = typeof UNIT_JOURNAL_PHASES[number];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** G2 unit journal: intent/phase/checkpoint only, never evidence bodies. */
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
+
import { transactIo } from "./io.js";
|
|
4
5
|
export const UNIT_JOURNAL_SCHEMA_VERSION = 1;
|
|
5
6
|
export const UNIT_JOURNAL_PHASES = [
|
|
6
7
|
'prepared',
|
|
@@ -41,10 +42,7 @@ export async function writeUnitJournal(io, home, journal, scope = 'merge') {
|
|
|
41
42
|
if (existing !== null)
|
|
42
43
|
assertUnitJournalTransition(existing.phase, journal.phase);
|
|
43
44
|
const content = JSON.stringify(journal, null, 2) + '\n';
|
|
44
|
-
|
|
45
|
-
await io.transact(path, () => content);
|
|
46
|
-
else
|
|
47
|
-
await io.writeText(path, content);
|
|
45
|
+
await transactIo(io, path, () => content);
|
|
48
46
|
return path;
|
|
49
47
|
}
|
|
50
48
|
export async function readUnitJournal(io, home, unitId, scope = 'merge') {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** G2 unit storage: opaque unitId -> Windows-safe storage key. */
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
+
import { transactIo } from "./io.js";
|
|
4
5
|
export const UNIT_STORAGE_SCHEMA_VERSION = 1;
|
|
5
6
|
/** Stable, filesystem-safe key; unitId stays opaque (may contain ':' or '/'). */
|
|
6
7
|
export function unitStorageKey(unitId) {
|
|
@@ -21,10 +22,7 @@ export function unitIndexPath(home) {
|
|
|
21
22
|
export async function writeUnitSnapshot(io, home, snapshot, scope = 'merge') {
|
|
22
23
|
const path = unitSnapshotPath(home, snapshot.unitId, scope);
|
|
23
24
|
const content = JSON.stringify(snapshot, null, 2) + '\n';
|
|
24
|
-
|
|
25
|
-
await io.transact(path, () => content);
|
|
26
|
-
else
|
|
27
|
-
await io.writeText(path, content);
|
|
25
|
+
await transactIo(io, path, () => content);
|
|
28
26
|
return path;
|
|
29
27
|
}
|
|
30
28
|
export async function readUnitSnapshot(io, home, unitId, scope = 'merge') {
|
|
@@ -41,10 +39,7 @@ export async function readUnitSnapshot(io, home, unitId, scope = 'merge') {
|
|
|
41
39
|
export async function writeUnitEvidence(io, home, evidence) {
|
|
42
40
|
const path = unitEvidencePath(home, evidence.unitId);
|
|
43
41
|
const content = JSON.stringify(evidence, null, 2) + '\n';
|
|
44
|
-
|
|
45
|
-
await io.transact(path, () => content);
|
|
46
|
-
else
|
|
47
|
-
await io.writeText(path, content);
|
|
42
|
+
await transactIo(io, path, () => content);
|
|
48
43
|
await upsertUnitIndex(io, home, {
|
|
49
44
|
unitId: evidence.unitId,
|
|
50
45
|
storageKey: unitStorageKey(evidence.unitId),
|
|
@@ -93,10 +88,7 @@ export async function upsertUnitIndex(io, home, entry) {
|
|
|
93
88
|
const next = entries.filter(item => item.unitId !== entry.unitId).concat(entry);
|
|
94
89
|
return JSON.stringify({ schemaVersion: UNIT_STORAGE_SCHEMA_VERSION, entries: next }, null, 2) + '\n';
|
|
95
90
|
};
|
|
96
|
-
|
|
97
|
-
await io.transact(path, content);
|
|
98
|
-
else
|
|
99
|
-
await io.writeText(path, content(await io.readText(path)));
|
|
91
|
+
await transactIo(io, path, content);
|
|
100
92
|
}
|
|
101
93
|
export function unitReceiptPath(home, unitId) {
|
|
102
94
|
return join(home, 'merge', 'unit-receipts', unitStorageKey(unitId) + '.json');
|
|
@@ -104,10 +96,7 @@ export function unitReceiptPath(home, unitId) {
|
|
|
104
96
|
export async function writeUnitReceipt(io, home, receipt) {
|
|
105
97
|
const path = unitReceiptPath(home, receipt.unitId);
|
|
106
98
|
const text = JSON.stringify(receipt, null, 2) + '\n';
|
|
107
|
-
|
|
108
|
-
await io.transact(path, () => text);
|
|
109
|
-
else
|
|
110
|
-
await io.writeText(path, text);
|
|
99
|
+
await transactIo(io, path, () => text);
|
|
111
100
|
return path;
|
|
112
101
|
}
|
|
113
102
|
export async function readUnitReceipt(io, home, unitId) {
|
package/lib/write.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as contentHash } from "./mutations-
|
|
2
|
-
import { $ as
|
|
1
|
+
import { r as contentHash } from "./mutations-DihgpfgG.js";
|
|
2
|
+
import { $ as validateMutationRequest, A as UNIT_JOURNAL_SCHEMA_VERSION, B as readUnitSnapshot, D as unitJournalPort, E as pruneTreeChangeUnits, F as writeUnitJournal, G as unitSnapshotsDir, H as unitIndexPath, I as UNIT_STORAGE_SCHEMA_VERSION, J as writeUnitEvidence, K as unitStorageKey, L as readUnitEvidence, M as readUnitJournal, N as unitJournalPath, O as unitSnapshotPort, P as unitJournalPhaseRank, Q as fileMutationLock, R as readUnitIndex, U as unitReceiptPath, V as unitEvidencePath, W as unitSnapshotPath, X as writeUnitSnapshot, Y as writeUnitReceipt, Z as MutationUnit, d as entryTarget, et as WriteKernel, j as assertUnitJournalTransition, k as UNIT_JOURNAL_PHASES, q as upsertUnitIndex, z as readUnitReceipt } from "./skill-history-RWt1-kbZ.js";
|
|
3
3
|
//#region lib/types/unit-undo.js
|
|
4
4
|
/**
|
|
5
5
|
* Cross-skill unit undo executor.
|
package/package.json
CHANGED
|
@@ -114,9 +114,9 @@
|
|
|
114
114
|
"path": "<skillsRoot>/**",
|
|
115
115
|
"writer": "evolution-core/src/skill-store.ts",
|
|
116
116
|
"serializedBy": "write-lock",
|
|
117
|
-
"marker": "
|
|
117
|
+
"marker": "withMutationLock(",
|
|
118
118
|
"state": [],
|
|
119
|
-
"note": "The skill tree itself. G1: ordinary byte writers take the root mutation lock (
|
|
119
|
+
"note": "The skill tree itself. G1: ordinary byte writers take the root mutation lock through withMutationLock (the injected authority lock) and still run their per-file read-modify-write through `transact`; the root lock is what keeps extract/restructure/update/patch/create from interleaving. Destructive movers refuse only when a support directory cannot be listed (fail-closed). N20 (W11 E): the marker is the PRODUCTION symbol withMutationLock; lockPort()'s test fallback (fileMutationLock) is not evidence for a production write."
|
|
120
120
|
},
|
|
121
121
|
{
|
|
122
122
|
"id": "activity-log-fenced",
|
|
@@ -279,6 +279,51 @@
|
|
|
279
279
|
"marker": "transactIo(io, pairIndexPath(home)",
|
|
280
280
|
"state": [],
|
|
281
281
|
"note": "pairKey → result/runId/target index; RMW under the same IO lock so two merge runs cannot lose each other's entries."
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
"id": "unit-snapshot-and-evidence",
|
|
285
|
+
"path": "<evolutionHome>/merge/unit-snapshots/** | <evolutionHome>/units/skill/snapshots/** | <evolutionHome>/merge/units/**/evidence.json",
|
|
286
|
+
"writer": "evolution-core/src/unit-storage.ts",
|
|
287
|
+
"serializedBy": "transact",
|
|
288
|
+
"marker": "transactIo(io, path, () => content)",
|
|
289
|
+
"state": [],
|
|
290
|
+
"note": "Unit snapshot + evidence writes (W11 E): both go through transactIo now instead of a conditional io.transact/writeText fallback, so a committed-fsync warning is tolerated uniformly and a byte-identical write is a no-op."
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"id": "unit-index",
|
|
294
|
+
"path": "<evolutionHome>/merge/unit-index.json",
|
|
295
|
+
"writer": "evolution-core/src/unit-storage.ts",
|
|
296
|
+
"serializedBy": "transact",
|
|
297
|
+
"marker": "transactIo(io, path, content)",
|
|
298
|
+
"state": [],
|
|
299
|
+
"note": "The unit index is a read-modify-write of the shared entries array; the task reads the current value inside the transaction (no lost update)."
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"id": "unit-receipt",
|
|
303
|
+
"path": "<evolutionHome>/merge/unit-receipts/**",
|
|
304
|
+
"writer": "evolution-core/src/unit-storage.ts",
|
|
305
|
+
"serializedBy": "transact",
|
|
306
|
+
"marker": "transactIo(io, path, () => text)",
|
|
307
|
+
"state": [],
|
|
308
|
+
"note": "Receipts are written once per unit; the path is derived from the hashed unit id."
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"id": "unit-journal",
|
|
312
|
+
"path": "<evolutionHome>/merge/unit-journals/** | <evolutionHome>/units/skill/journals/**",
|
|
313
|
+
"writer": "evolution-core/src/unit-journal.ts",
|
|
314
|
+
"serializedBy": "transact",
|
|
315
|
+
"marker": "transactIo(io, path, () => content)",
|
|
316
|
+
"state": [],
|
|
317
|
+
"note": "Phase transitions are validated against the existing journal before the transaction; the write itself is the shared transactIo path."
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"id": "run-lease",
|
|
321
|
+
"path": "<evolutionHome>/leases/**",
|
|
322
|
+
"writer": "evolution-core/src/lease-store.ts",
|
|
323
|
+
"serializedBy": "transact",
|
|
324
|
+
"marker": "transactIo(this.io, path, (raw)",
|
|
325
|
+
"state": [],
|
|
326
|
+
"note": "Lease acquire/heartbeat/release all use transactIo now: the old private fallback did not tolerate a committed-fsync warning, so acquire could report failure after the active lease had landed."
|
|
282
327
|
}
|
|
283
328
|
]
|
|
284
329
|
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Untrusted text rendered as prompt lines (T3-03/A31) — ONE folding rule.
|
|
3
|
-
*
|
|
4
|
-
* The background-review digest embeds conversation text and tool output into a
|
|
5
|
-
* plain-text prompt whose PRODUCT is a plan with write permission. Anything the
|
|
6
|
-
* session ingested (a fetched page, a file body, command output) can therefore
|
|
7
|
-
* carry a newline plus a line shaped like the prompt's own structure — a
|
|
8
|
-
* `SYSTEM:`/`Review kind:` header, a `[result]` evidence line, a second copy
|
|
9
|
-
* of the closing instruction — and forge structure or inject instructions.
|
|
10
|
-
*
|
|
11
|
-
* FOLDING, not deleting: the reader (the model) must still SEE what the data
|
|
12
|
-
* said, it just must never become structure. Line separators become a visible
|
|
13
|
-
* `⏎`, and a line that would read as a role/evidence header gets a visible
|
|
14
|
-
* marker in front of it. Every original character stays in place.
|
|
15
|
-
*
|
|
16
|
-
* The boundary is the separator itself, not only a real newline: a payload can
|
|
17
|
-
* paste the separator verbatim, so neutralization matches after `⏎` whether it
|
|
18
|
-
* came from the fold or from the data. Both edits are idempotent (a second pass
|
|
19
|
-
* cannot add a second marker).
|
|
20
|
-
*
|
|
21
|
-
* Scope: text rendered as its OWN line(s) of a prompt. `render-facts`'
|
|
22
|
-
* sanitizer (evolution-maintenance) is the same posture for `key=value` fields
|
|
23
|
-
* and additionally escapes its block delimiter; it is not superseded here.
|
|
24
|
-
* @module @lmzhen/dsh-evolution-core
|
|
25
|
-
*/
|
|
26
|
-
/** Visible stand-in for a folded line separator: one character that cannot be read as line structure. */
|
|
27
|
-
export declare const UNTRUSTED_LINE_BREAK = " \u23CE ";
|
|
28
|
-
/** Visible marker prefixed to a line that would otherwise read as a role/structure header. */
|
|
29
|
-
export declare const UNTRUSTED_LINE_MARK = "\u00B7 ";
|
|
30
|
-
/**
|
|
31
|
-
* Fold untrusted `text` so it cannot become structure, then bound it to `limit`
|
|
32
|
-
* visible characters. A non-positive `limit` means "no truncation".
|
|
33
|
-
*/
|
|
34
|
-
export declare function foldUntrustedLines(text: string, limit: number): string;
|
|
35
|
-
//# sourceMappingURL=fold-untrusted.d.ts.map
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Untrusted text rendered as prompt lines (T3-03/A31) — ONE folding rule.
|
|
3
|
-
*
|
|
4
|
-
* The background-review digest embeds conversation text and tool output into a
|
|
5
|
-
* plain-text prompt whose PRODUCT is a plan with write permission. Anything the
|
|
6
|
-
* session ingested (a fetched page, a file body, command output) can therefore
|
|
7
|
-
* carry a newline plus a line shaped like the prompt's own structure — a
|
|
8
|
-
* `SYSTEM:`/`Review kind:` header, a `[result]` evidence line, a second copy
|
|
9
|
-
* of the closing instruction — and forge structure or inject instructions.
|
|
10
|
-
*
|
|
11
|
-
* FOLDING, not deleting: the reader (the model) must still SEE what the data
|
|
12
|
-
* said, it just must never become structure. Line separators become a visible
|
|
13
|
-
* `⏎`, and a line that would read as a role/evidence header gets a visible
|
|
14
|
-
* marker in front of it. Every original character stays in place.
|
|
15
|
-
*
|
|
16
|
-
* The boundary is the separator itself, not only a real newline: a payload can
|
|
17
|
-
* paste the separator verbatim, so neutralization matches after `⏎` whether it
|
|
18
|
-
* came from the fold or from the data. Both edits are idempotent (a second pass
|
|
19
|
-
* cannot add a second marker).
|
|
20
|
-
*
|
|
21
|
-
* Scope: text rendered as its OWN line(s) of a prompt. `render-facts`'
|
|
22
|
-
* sanitizer (evolution-maintenance) is the same posture for `key=value` fields
|
|
23
|
-
* and additionally escapes its block delimiter; it is not superseded here.
|
|
24
|
-
* @module @lmzhen/dsh-evolution-core
|
|
25
|
-
*/
|
|
26
|
-
/** Visible stand-in for a folded line separator: one character that cannot be read as line structure. */
|
|
27
|
-
export const UNTRUSTED_LINE_BREAK = ' ⏎ ';
|
|
28
|
-
/** Visible marker prefixed to a line that would otherwise read as a role/structure header. */
|
|
29
|
-
export const UNTRUSTED_LINE_MARK = '· ';
|
|
30
|
-
const NEWLINES = /\r\n|\r|\n/g;
|
|
31
|
-
/** A line that reads as structure: a `Label:` head (SYSTEM:, Review kind:, Signals:) or a digest evidence tag.
|
|
32
|
-
* The head is case-TOLERANT on purpose: this family's own prompt labels are mixed case, so an
|
|
33
|
-
* uppercase-only rule neutralized SYSTEM: while leaving a forged "Review kind:" untouched. */
|
|
34
|
-
const STRUCTURAL_HEAD = /(^|⏎)([ \t]*)((?:[A-Za-z][A-Za-z0-9 _]{2,}:|\[result\]|\[call\]))/g;
|
|
35
|
-
/**
|
|
36
|
-
* Fold untrusted `text` so it cannot become structure, then bound it to `limit`
|
|
37
|
-
* visible characters. A non-positive `limit` means "no truncation".
|
|
38
|
-
*/
|
|
39
|
-
export function foldUntrustedLines(text, limit) {
|
|
40
|
-
const folded = text.replace(NEWLINES, UNTRUSTED_LINE_BREAK);
|
|
41
|
-
const marked = folded.replace(STRUCTURAL_HEAD, (_match, boundary, spaces, head) => `${boundary}${spaces}${UNTRUSTED_LINE_MARK}${head}`);
|
|
42
|
-
return limit > 0 ? marked.slice(0, limit) : marked;
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=fold-untrusted.js.map
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** G2 recovery arbitration: unit journal/evidence wins over a legacy commit journal. */
|
|
2
|
-
import type { EvolutionIoLike } from './io.ts';
|
|
3
|
-
export type UnitAuthority = 'unit' | 'legacy' | 'none';
|
|
4
|
-
export declare function resolveUnitAuthority(io: EvolutionIoLike, home: string, unitId: string, legacyExists: boolean): Promise<UnitAuthority>;
|
|
5
|
-
//# sourceMappingURL=unit-recovery.d.ts.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { readUnitEvidence, readUnitSnapshot } from "./unit-storage.js";
|
|
2
|
-
import { readUnitJournal } from "./unit-journal.js";
|
|
3
|
-
export async function resolveUnitAuthority(io, home, unitId, legacyExists) {
|
|
4
|
-
if (await readUnitEvidence(io, home, unitId) !== null)
|
|
5
|
-
return 'unit';
|
|
6
|
-
if (await readUnitJournal(io, home, unitId) !== null)
|
|
7
|
-
return 'unit';
|
|
8
|
-
if (await readUnitSnapshot(io, home, unitId) !== null)
|
|
9
|
-
return 'unit';
|
|
10
|
-
return legacyExists ? 'legacy' : 'none';
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=unit-recovery.js.map
|