@aiwayds/dsh-topics-memory 0.23.0 → 0.24.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/config.d.ts +18 -1
- package/lib/config.js +13 -0
- package/lib/digest.d.ts +38 -5
- package/lib/digest.js +57 -15
- package/lib/ilog.d.ts +14 -0
- package/lib/index.d.ts +9 -1
- package/lib/index.js +1 -0
- package/lib/okf.d.ts +34 -0
- package/lib/okf.js +41 -0
- package/lib/paths.d.ts +9 -0
- package/lib/paths.js +15 -0
- package/lib/pipeline-events.d.ts +4 -2
- package/lib/pipeline-events.js +2 -0
- package/lib/service.d.ts +88 -3
- package/lib/service.js +435 -19
- package/lib/store.d.ts +30 -3
- package/lib/store.js +28 -1
- package/package.json +2 -2
- package/src/config.ts +15 -0
- package/src/digest.ts +85 -12
- package/src/ilog.ts +9 -0
- package/src/index.ts +9 -0
- package/src/okf.ts +68 -0
- package/src/paths.ts +15 -0
- package/src/pipeline-events.ts +6 -2
- package/src/service.ts +476 -21
- package/src/store.ts +45 -3
package/lib/service.d.ts
CHANGED
|
@@ -36,6 +36,40 @@ export interface SlowDelivery {
|
|
|
36
36
|
/** Producing run's disposition (A4 全留痕) — copied into ilog.slowOutcome. */
|
|
37
37
|
outcome?: SlowOutcome;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* One structured observation from the new repo's signal layer (B1 §2.1
|
|
41
|
+
* whitelist): FEATURES ONLY, never conversation text (红线⑤). Unknown caller
|
|
42
|
+
* fields cannot pass — the whitelist copy in feedObservations is the gate.
|
|
43
|
+
*/
|
|
44
|
+
export interface StructuredObservation {
|
|
45
|
+
/** Signal type from the B1 closed list (`tool-error`, `turn-end-negative`,
|
|
46
|
+
* `unused-injection`, `repeat-call`, `interruption-pair`, `jev-calibration`). */
|
|
47
|
+
type: string;
|
|
48
|
+
/** ISO instant; defaults to now. */
|
|
49
|
+
at?: string;
|
|
50
|
+
sessionId?: string;
|
|
51
|
+
/** Bounded scalar feature fields (toolName/errorName/count/band/...). */
|
|
52
|
+
detail?: Record<string, string | number | boolean>;
|
|
53
|
+
}
|
|
54
|
+
export interface FeedResult {
|
|
55
|
+
accepted: number;
|
|
56
|
+
duplicates: number;
|
|
57
|
+
rejected: number;
|
|
58
|
+
ids: string[];
|
|
59
|
+
/** Present when the call itself was refused (missing/blank actor). */
|
|
60
|
+
error?: 'unauthorized';
|
|
61
|
+
}
|
|
62
|
+
export interface StoreResult {
|
|
63
|
+
ok: boolean;
|
|
64
|
+
slug: string;
|
|
65
|
+
/** Refusal reason; absent on success. */
|
|
66
|
+
reason?: 'unauthorized' | 'not-found' | 'not-a-lesson' | 'invalid-state';
|
|
67
|
+
/** confidence before the transition (when the lesson was read). */
|
|
68
|
+
from?: okf.LessonConfidence;
|
|
69
|
+
/** removed only: bundle-relative archive path (git-revertable). */
|
|
70
|
+
archivedTo?: string;
|
|
71
|
+
committed?: boolean;
|
|
72
|
+
}
|
|
39
73
|
export declare class TopicsService {
|
|
40
74
|
private cache;
|
|
41
75
|
/** mtime-keyed parse of the observations log, grouped by session. */
|
|
@@ -109,8 +143,12 @@ export declare class TopicsService {
|
|
|
109
143
|
private embeddingIndexCacheGet;
|
|
110
144
|
/** Shadow bypass ledger (spec §8.3): one line per shadow round — feature
|
|
111
145
|
* fields only, never query text (jev-log discipline). Silent on failure;
|
|
112
|
-
* 512KB truncation keeps the newest three quarters.
|
|
113
|
-
|
|
146
|
+
* 512KB truncation keeps the newest three quarters. Shared by the package
|
|
147
|
+
* shadow (meta/package-shadow.jsonl) and the lesson shadow (B2,
|
|
148
|
+
* meta/lesson-shadow.jsonl). */
|
|
149
|
+
private appendShadowLedger;
|
|
150
|
+
private packageShadowLedgerPath;
|
|
151
|
+
private lessonShadowLedgerPath;
|
|
114
152
|
/** Boot-time embedding index maintenance (spec §3: boot 校验+增量重建).
|
|
115
153
|
* Provider '' or packageMode off → no-op (default-off byte-for-byte).
|
|
116
154
|
* Full-roster embed on rebuild (A1 §5: ~9.5s for 137 topics). */
|
|
@@ -154,6 +192,7 @@ export declare class TopicsService {
|
|
|
154
192
|
echoed: string[];
|
|
155
193
|
included: string[];
|
|
156
194
|
slowIncluded: string[];
|
|
195
|
+
lessonIncluded: string[];
|
|
157
196
|
};
|
|
158
197
|
/**
|
|
159
198
|
* topic_open tool path (v4 §4.1): full conclusion / open questions /
|
|
@@ -181,9 +220,25 @@ export declare class TopicsService {
|
|
|
181
220
|
private attributeOpen;
|
|
182
221
|
/** Sync roster read (same mtime cache as roster()). */
|
|
183
222
|
rosterSync(): RetrievableTopic[];
|
|
223
|
+
/** Established, scope-passing lesson entries (B2, spec 卷一 §6.3) — sync,
|
|
224
|
+
* sharing the roster's mtime cache. Injection reads ONLY established
|
|
225
|
+
* lessons here (MJ-3: hint 仅供审批队列展示,永不注入); scope filter =
|
|
226
|
+
* workspace lessons must carry the current workspace id (MJ-2); scope=global
|
|
227
|
+
* and legacy entries without a workspaceId pass (fail-open — the filter's
|
|
228
|
+
* default is permissive, the confidence gate is the hard one). */
|
|
229
|
+
lessonsSync(): (RetrievableTopic & {
|
|
230
|
+
confidence: okf.LessonConfidence;
|
|
231
|
+
source: okf.LessonSource;
|
|
232
|
+
scope: okf.LessonScope;
|
|
233
|
+
workspaceId?: string;
|
|
234
|
+
})[];
|
|
184
235
|
private readDocSync;
|
|
185
236
|
private readDoc;
|
|
186
|
-
/** topic_save tool path: create or update with actor stamping.
|
|
237
|
+
/** topic_save tool path: create or update with actor stamping. `kind:
|
|
238
|
+
* 'lesson'` (B2 data plane) switches the OKF type to Lesson and stamps the
|
|
239
|
+
* lesson frontmatter (scope/confidence/source/workspaceId) with the
|
|
240
|
+
* confidence↔status derivation (hint↔draft, established↔stable —
|
|
241
|
+
* confidence is the fact source). */
|
|
187
242
|
saveTopic(input: {
|
|
188
243
|
title: string;
|
|
189
244
|
description?: string;
|
|
@@ -199,6 +254,12 @@ export declare class TopicsService {
|
|
|
199
254
|
recommendations?: string;
|
|
200
255
|
source?: 'model' | 'distill';
|
|
201
256
|
slug?: string;
|
|
257
|
+
/** B2 lesson data plane: entry kind (default topic). */
|
|
258
|
+
kind?: okf.TopicKind;
|
|
259
|
+
scope?: okf.LessonScope;
|
|
260
|
+
confidence?: okf.LessonConfidence;
|
|
261
|
+
/** Lesson provenance (input.source above is the tool-path tag). */
|
|
262
|
+
lessonSource?: okf.LessonSource;
|
|
202
263
|
}): Promise<SaveResult & {
|
|
203
264
|
slug: string;
|
|
204
265
|
}>;
|
|
@@ -208,6 +269,30 @@ export declare class TopicsService {
|
|
|
208
269
|
sessionId?: string;
|
|
209
270
|
source?: 'model' | 'auto';
|
|
210
271
|
}): Promise<Observation>;
|
|
272
|
+
/**
|
|
273
|
+
* ① 观察投喂: structured observations (B1 §2.1 whitelist, FEATURES ONLY —
|
|
274
|
+
* 对话原文禁入, 红线⑤) appended to the observations stream with the `fed`
|
|
275
|
+
* provenance marker and `kind: 'signal'`; each line carries `by: actor`.
|
|
276
|
+
* The whitelist copy drops unknown caller fields, caps detail entries and
|
|
277
|
+
* string sizes, and renders a sorted feature line as the observation text.
|
|
278
|
+
* Duplicates (same type+session+detail in the recent tail) are counted, not
|
|
279
|
+
* appended (重复观察由原仓去重). Fail-soft: one malformed entry is counted
|
|
280
|
+
* as rejected, never sinks the batch.
|
|
281
|
+
*/
|
|
282
|
+
feedObservations(obs: readonly StructuredObservation[], opts: {
|
|
283
|
+
actor: string;
|
|
284
|
+
}): Promise<FeedResult>;
|
|
285
|
+
/**
|
|
286
|
+
* ② lesson 状态变更 (B2/卷二 §6.2): hint→established / →deprecated /
|
|
287
|
+
* →removed. established flips confidence (the FACT source) and derives
|
|
288
|
+
* status (established↔stable); deprecated flips status only (the TTL sweep
|
|
289
|
+
* owns the rest); removed = archive FIRST (byte-exact copy to
|
|
290
|
+
* `archive/lessons/` inside the bundle, git-revertable — 红线④) then out of
|
|
291
|
+
* the roster, one commit. Each call lands a `seam-lesson-status` audit row.
|
|
292
|
+
*/
|
|
293
|
+
setLessonStatus(slug: string, to: 'established' | 'deprecated' | 'removed', opts: {
|
|
294
|
+
actor: string;
|
|
295
|
+
}): Promise<StoreResult>;
|
|
211
296
|
search(query: string, topK?: number): Promise<SearchOutcome>;
|
|
212
297
|
history(slug: string, limit?: number): Promise<{
|
|
213
298
|
entries: {
|