@lmzhen/dsh-evolution-core 0.1.0-rc.9 → 0.2.0-rc.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/index.js +2627 -501
- package/lib/types/constants.d.ts +53 -0
- package/lib/types/curator.d.ts +75 -4
- package/lib/types/events.d.ts +18 -10
- package/lib/types/evolution-events.d.ts +133 -0
- package/lib/types/gates.d.ts +38 -0
- package/lib/types/index.d.ts +7 -0
- package/lib/types/io.d.ts +31 -4
- package/lib/types/learn-prompt.d.ts +19 -0
- package/lib/types/memory-store.d.ts +55 -12
- package/lib/types/mutations.d.ts +24 -0
- package/lib/types/prompts.d.ts +26 -6
- package/lib/types/quality.d.ts +70 -0
- package/lib/types/skill-health.d.ts +52 -0
- package/lib/types/skill-store.d.ts +216 -21
- package/lib/types/state-store.d.ts +2 -15
- package/lib/types/threats.d.ts +16 -4
- package/lib/types/usage.d.ts +77 -2
- package/package.json +5 -5
package/lib/types/usage.d.ts
CHANGED
|
@@ -16,13 +16,63 @@ export interface UsageRecord {
|
|
|
16
16
|
state: SkillState;
|
|
17
17
|
pinned: boolean;
|
|
18
18
|
archived_at: string | null;
|
|
19
|
-
quality_score?: number;
|
|
20
|
-
quality_warn?: boolean;
|
|
19
|
+
quality_score?: number | undefined;
|
|
20
|
+
quality_warn?: boolean | undefined;
|
|
21
21
|
}
|
|
22
22
|
export type UsageMap = Map<string, UsageRecord>;
|
|
23
23
|
export declare function usageFile(root: string): string;
|
|
24
24
|
export declare function emptyRecord(): UsageRecord;
|
|
25
|
+
/**
|
|
26
|
+
* Field-level normalization for one sidecar record (rc.42 audit P2-3): the
|
|
27
|
+
* spread used to copy any junk through verbatim, so a corrupted file could
|
|
28
|
+
* carry `use_count: "3"` into the quality math and lifecycle comparisons as
|
|
29
|
+
* NaN. Every field falls back to its `emptyRecord()` baseline unless it has
|
|
30
|
+
* exactly the declared type; an invalid `created_at` anchors the age clock at
|
|
31
|
+
* now (first-sight defer semantics for a record whose age is unknowable).
|
|
32
|
+
* Timestamps additionally require a parseable date (N-3): `"not-a-date"`
|
|
33
|
+
* would otherwise survive the type check as Invalid Date.
|
|
34
|
+
* Pure — exported for unit tests; `loadUsage` is the production caller.
|
|
35
|
+
*/
|
|
36
|
+
export declare function normalizeUsageRecord(record: unknown): UsageRecord;
|
|
25
37
|
export declare function loadUsage(root: string, io?: EvolutionIoLike): Promise<UsageMap>;
|
|
38
|
+
/**
|
|
39
|
+
* Atomic read-modify-write on the usage sidecar (rc.50 P2-2): `task` receives
|
|
40
|
+
* the map parsed from the current on-disk state and may mutate it; the result
|
|
41
|
+
* is persisted inside the same transact so a second process sharing DSH_HOME
|
|
42
|
+
* cannot interleave its RMW and lose a counter update. Callers keep their own
|
|
43
|
+
* single-process serialize chain as the second layer.
|
|
44
|
+
*/
|
|
45
|
+
export declare function mutateUsage(root: string, io: EvolutionIoLike, task: (map: UsageMap) => void | Promise<void>): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Curator-owned usage fields (rc.67 K-2): the curator writes ONLY this set —
|
|
48
|
+
* lifecycle state, archive stamp, the six-factor quality pair, and the
|
|
49
|
+
* marker-mirrored pin flag. Counter and activity-stamp fields belong to the
|
|
50
|
+
* tool-telemetry side (skill-usage / tool-skill-manage), which bumps them
|
|
51
|
+
* through its own transact-backed RMW. A whole-record overwrite by either
|
|
52
|
+
* side would clobber the other side's concurrent increment, so cross-side
|
|
53
|
+
* folds copy this set only.
|
|
54
|
+
*/
|
|
55
|
+
export declare function applyCuratorFields(disk: UsageRecord, curated: UsageRecord): void;
|
|
56
|
+
/** Copy only the lifecycle pair (state/archived_at) — see the ownership split
|
|
57
|
+
* rationale on {@link applyCuratorMetaFields}. */
|
|
58
|
+
export declare function applyCuratorLifecycleFields(disk: UsageRecord, curated: UsageRecord): void;
|
|
59
|
+
/**
|
|
60
|
+
* Copy the recomputed meta pair (quality_score/quality_warn + the
|
|
61
|
+
* marker-mirrored pin flag) — refreshed tree-wide each run by design, so a
|
|
62
|
+
* concurrent curator run's lifecycle changes are never reverted by them.
|
|
63
|
+
*/
|
|
64
|
+
export declare function applyCuratorMetaFields(disk: UsageRecord, curated: UsageRecord): void;
|
|
65
|
+
/**
|
|
66
|
+
* Fold a curator run-start snapshot onto the current on-disk map (rc.67 K-2):
|
|
67
|
+
* each curated record is projected onto its disk peer by copying only the
|
|
68
|
+
* curator-owned fields, so a concurrent tool-side bump between snapshot and
|
|
69
|
+
* save survives. Records absent from the snapshot are left untouched; a
|
|
70
|
+
* curated record with no disk peer is seeded from the snapshot. `stateOwned`
|
|
71
|
+
* (rc.72 H-1) restricts the lifecycle pair to the names this run ACTUALLY
|
|
72
|
+
* transitioned — a concurrent curator run's archive/restore is never reverted
|
|
73
|
+
* by a stale snapshot; without it both pairs apply everywhere.
|
|
74
|
+
*/
|
|
75
|
+
export declare function foldCuratorFields(disk: UsageMap, curated: UsageMap, stateOwned?: ReadonlySet<string>): void;
|
|
26
76
|
export declare function saveUsage(root: string, map: UsageMap, io?: EvolutionIoLike): Promise<void>;
|
|
27
77
|
export declare function getRecord(map: UsageMap, name: string): UsageRecord;
|
|
28
78
|
export declare function bumpView(map: UsageMap, name: string, when?: Date): void;
|
|
@@ -30,4 +80,29 @@ export declare function bumpUse(map: UsageMap, name: string, when?: Date): void;
|
|
|
30
80
|
export declare function bumpPatch(map: UsageMap, name: string, when?: Date): void;
|
|
31
81
|
export declare function markAgentCreated(map: UsageMap, name: string): void;
|
|
32
82
|
export declare function latestActivityAt(record: UsageRecord): string | null;
|
|
83
|
+
/**
|
|
84
|
+
* Whether the library has ANY observed read evidence (C observation window):
|
|
85
|
+
* reads were invisible to the usage sidecar before A2, so `view_count` zero
|
|
86
|
+
* means "never read" ONLY after the first observed read exists anywhere in
|
|
87
|
+
* the map. Before that, churn-based signals (write-ghost) are untrustworthy
|
|
88
|
+
* and callers must suppress them. Pure and derived — never persisted.
|
|
89
|
+
*/
|
|
90
|
+
export declare function usageObserved(usage: ReadonlyMap<string, UsageRecord>): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Curator suppression sidecar: built-in skills the curator has archived stay
|
|
93
|
+
* suppressed across re-seeds, so the lifecycle never fights a re-created
|
|
94
|
+
* bundled skill. Best-effort load/save, mirroring the usage sidecar posture.
|
|
95
|
+
* Versioned shape ({ version, names }) with legacy plain-array compat.
|
|
96
|
+
*/
|
|
97
|
+
export declare const SUPPRESSED_FILE_VERSION = 1;
|
|
98
|
+
export declare function suppressedFile(root: string): string;
|
|
99
|
+
export declare function loadSuppressedNames(root: string, io?: EvolutionIoLike): Promise<ReadonlySet<string>>;
|
|
100
|
+
export declare function saveSuppressedNames(root: string, names: ReadonlySet<string>, io?: EvolutionIoLike): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Atomic read-modify-write on the suppression sidecar (rc.50 P2-2): `task`
|
|
103
|
+
* receives the set parsed from the current on-disk state and may mutate it;
|
|
104
|
+
* the result is persisted inside the same transact so a second process
|
|
105
|
+
* sharing DSH_HOME cannot interleave its RMW. Best-effort posture unchanged.
|
|
106
|
+
*/
|
|
107
|
+
export declare function updateSuppressedNames(root: string, io: EvolutionIoLike, task: (names: Set<string>) => void | Promise<void>): Promise<void>;
|
|
33
108
|
//# sourceMappingURL=usage.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-core",
|
|
3
3
|
"description": "Shared stores, prompts, signals and lifecycle logic for the dsh-evolution plugin family (community build)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0-rc.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
],
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@deepseek-ai/dsh-invariants": "^0.1.
|
|
35
|
+
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
36
36
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
37
|
-
"@deepseek-ai/dsh-session": "^0.1.
|
|
37
|
+
"@deepseek-ai/dsh-session": "^0.1.1-rc.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@deepseek-ai/dsh-invariants": "^0.1.
|
|
40
|
+
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
41
41
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
42
|
-
"@deepseek-ai/dsh-session": "^0.1.
|
|
42
|
+
"@deepseek-ai/dsh-session": "^0.1.1-rc.2"
|
|
43
43
|
}
|
|
44
44
|
}
|