@sparkelf/dsh-knowledge-base 0.6.2 → 0.6.3

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.
@@ -12,8 +12,13 @@ export declare const SYSTEM_POLICY_MARKER = "system policy overrides personal me
12
12
  * `personal` is the user's own `MemoryStore` snapshot (`偏好.md`, `踩坑.md`,
13
13
  * `事实.md`, `SOP/`, daily logs). It has no binding and no graph-side authority:
14
14
  * it is always advisory, so it can never outrank a department/global redline.
15
+ *
16
+ * `shared` is an approved department/global promotion read from the scope's
17
+ * `记忆共享/` graph. It needs no binding either, but unlike personal memory it is
18
+ * published policy-shaped content: still advisory, still below redline/canonical,
19
+ * yet kept when the user pauses personal memory.
15
20
  */
16
- export type MemoryContextMode = 'subscribe' | 'internalize' | 'personal';
21
+ export type MemoryContextMode = 'subscribe' | 'internalize' | 'personal' | 'shared';
17
22
  /** Where one resolved context entry came from. */
18
23
  export type MemoryContextSourceType = BindingSourceType | 'entry';
19
24
  /** One resolved node/edge/memory the runtime may inject. */
@@ -42,6 +47,8 @@ export interface MemoryContextEntry {
42
47
  to?: string;
43
48
  /** Personal-memory privacy label; absent on graph bindings. */
44
49
  privacy?: Privacy;
50
+ /** `global` or `department:<code>` for a shared-memory document. */
51
+ scope?: string;
45
52
  /** Last update of a personal entry; absent on graph bindings. */
46
53
  updatedAt?: string;
47
54
  body: string;
@@ -67,6 +74,8 @@ export interface MemoryContextResult {
67
74
  redlineCount: number;
68
75
  /** Number of selected entries that came from the caller's own `MemoryStore`. */
69
76
  personalCount: number;
77
+ /** Number of selected entries read from a department/global `记忆共享/` graph. */
78
+ sharedCount: number;
70
79
  /** Non-empty when at least one redline is present. */
71
80
  systemPolicy: string;
72
81
  }
@@ -87,6 +96,15 @@ export interface MemoryContextInput {
87
96
  * example a paused memory setting).
88
97
  */
89
98
  personalMemoryRoot?: string;
99
+ /**
100
+ * Personal memory is paused for this caller.
101
+ *
102
+ * Design §22.2: pausing stops personal memory from influencing answers, but
103
+ * department/global policy — and every redline — still applies. The resolver
104
+ * therefore skips the caller's internalized branches and personal store while
105
+ * keeping department/global subscriptions and shared memory.
106
+ */
107
+ paused?: boolean;
90
108
  /** Prompt budget; defaults to {@link DEFAULT_MEMORY_CONTEXT_MAX_CHARS}. */
91
109
  maxChars?: number;
92
110
  }
@@ -0,0 +1,57 @@
1
+ import type { LoadedGraph, MemoryAuthority, MemoryOrigin, MemoryReviewStatus } from './graphModel.ts';
2
+ import { type Privacy } from './memoryTypes.ts';
3
+ /** The caller fields the shared scope roots are derived from. */
4
+ export interface SharedMemoryCaller {
5
+ departmentCode?: string;
6
+ departmentPathCodes?: readonly string[];
7
+ }
8
+ /** One scope root that may hold a shared-memory graph. */
9
+ export interface SharedMemoryScopeRoot {
10
+ scope: 'global' | 'department';
11
+ /** Scope-relative root without a trailing slash (`global`, `department/A/B`). */
12
+ relPath: string;
13
+ /** Leaf department code for a department root. */
14
+ departmentCode?: string;
15
+ }
16
+ /**
17
+ * The shared-memory scope roots a caller may own content under.
18
+ *
19
+ * `global` is always a candidate (subject to `canRead`); the department root is
20
+ * the caller's own organization chain, never a sibling. Order is global first,
21
+ * then department, so the rendered context is deterministic.
22
+ *
23
+ * @param caller - the authenticated caller's department projection.
24
+ * @returns Scope roots in a stable order.
25
+ */
26
+ export declare function sharedMemoryScopeRoots(caller: SharedMemoryCaller): SharedMemoryScopeRoot[];
27
+ /** One shared document a caller may inject, before context-level dedupe/sort. */
28
+ export interface SharedMemoryCandidate {
29
+ /** Node id (`mem-mp-…`); also the dedupe key against a subscription binding. */
30
+ id: string;
31
+ title: string;
32
+ /** Graph node type (`topic`, `fact`, `case`, `procedure`, `policy`, `skill`). */
33
+ type: string;
34
+ authority: MemoryAuthority;
35
+ origin: MemoryOrigin;
36
+ reviewStatus: MemoryReviewStatus;
37
+ privacy: Privacy;
38
+ /** Scope-relative document path (`记忆共享/<id>.md`). */
39
+ path: string;
40
+ /** `global` or `department:<code>` from the manifest. */
41
+ scope: string;
42
+ status: 'active';
43
+ version: number;
44
+ body: string;
45
+ }
46
+ /**
47
+ * Read every injectable node of one shared-memory graph.
48
+ *
49
+ * A missing or unreadable document is skipped (fail soft): one broken promotion
50
+ * must not hide a redline or fail the whole context. A graph that is not the
51
+ * shared-memory graph, or whose manifest scope is neither `global` nor
52
+ * `department:<code>`, contributes nothing.
53
+ *
54
+ * @param graph - the loaded graph; its `root` must be the scope root.
55
+ * @returns Candidates in manifest node order, already privacy-filtered.
56
+ */
57
+ export declare function readSharedMemoryCandidates(graph: LoadedGraph): Promise<SharedMemoryCandidate[]>;
@@ -42,6 +42,14 @@ export interface MemoryToolHost {
42
42
  personalMemoryRoot?(viewer: GraphViewer): string;
43
43
  /** Every graph the caller may read. Implementations must not return a denied graph. */
44
44
  loadGraphs(viewer: GraphViewer): Promise<LoadedGraph[]>;
45
+ /**
46
+ * Department/global shared-memory graphs the caller may read (`shared-memory`
47
+ * under the caller's own department chain and the global scope).
48
+ *
49
+ * This is a separate seam from {@link loadGraphs} so the guardian pass keeps its
50
+ * existing graph scope: shared memory is runtime context, not a graph to bind.
51
+ */
52
+ loadSharedGraphs?(viewer: GraphViewer): Promise<LoadedGraph[]>;
45
53
  /** Whether the caller holds the memory-management capability (`kb:config:manage`). */
46
54
  canManage(viewer: GraphViewer): Promise<boolean> | boolean;
47
55
  /** Whether personal memory is enabled for this caller; a paused user gets no personal entries. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparkelf/dsh-knowledge-base",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "DataOps-backed knowledge base for DeepSeek Harness: a left-sidebar destination, Settings configuration, and index tooling over a mounted NAS view.",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",