@kindgi/memory 0.1.4-rc.5 → 0.1.5-rc.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/src/types.ts CHANGED
@@ -31,8 +31,73 @@ export interface MemoryScope {
31
31
  readonly projectId?: ProjectId;
32
32
  readonly threadId?: ThreadId;
33
33
  readonly sessionId?: SessionId;
34
+ /**
35
+ * An app's end user, by the app's own opaque id (as conversations and
36
+ * judgments name them): a fact about or for one person who isn't a
37
+ * Kindgi user. A participant's facts are private to that participant's
38
+ * runs. Needs `projectId`: an app's end users belong to a project.
39
+ */
40
+ readonly participantId?: string;
41
+ }
42
+
43
+ /**
44
+ * Who can see which facts: the containers a reader may read, worked out
45
+ * by the server from the run or the caller (never from a request body),
46
+ * and applied inside every query. A fact is readable when each container
47
+ * its scope names is one the reader has: its project, org, user,
48
+ * participant and thread (a fact naming none of them is tenant-wide, and
49
+ * every reader in the tenant sees it). A missing field grants none.
50
+ */
51
+ export interface MemoryReaders {
52
+ /** Every fact in the tenant (a tenant admin). The other fields are then ignored. */
53
+ readonly all?: true;
54
+ /** Projects whose facts it reads. */
55
+ readonly projectIds?: readonly ProjectId[];
56
+ /** Orgs whose org-wide facts (no project) it reads: a run's project's org. */
57
+ readonly orgIds?: readonly OrgId[];
58
+ /** Kindgi users whose personal facts it reads. */
59
+ readonly userIds?: readonly UserId[];
60
+ /** End users (participants) whose facts it reads. */
61
+ readonly participantIds?: readonly string[];
62
+ /** Conversations whose thread facts it reads. */
63
+ readonly threadIds?: readonly ThreadId[];
64
+ /**
65
+ * Projects where it reads every participant's and every thread's facts:
66
+ * an app's own credential, acting for all of its end users.
67
+ */
68
+ readonly onBehalfOfProjectIds?: readonly ProjectId[];
69
+ }
70
+
71
+ /**
72
+ * How far a fact is trusted. `verified`: a person with the right checked
73
+ * it. `asserted`: an app or a person wrote it. `unverified`: an agent
74
+ * remembered it during a conversation.
75
+ */
76
+ export type FactTrust = 'verified' | 'asserted' | 'unverified';
77
+
78
+ /** Whom a fact is about: what access and erasure requests by person find. */
79
+ export interface FactSubject {
80
+ readonly kind: 'participant' | 'user' | 'external';
81
+ readonly id: string;
82
+ }
83
+
84
+ /** Who asserted a fact (PROV `wasAttributedTo`), set by the server from the writer. */
85
+ export interface FactAttribution {
86
+ readonly kind: 'user' | 'service' | 'agent';
87
+ readonly id: string;
88
+ readonly agentVersion?: string;
89
+ }
90
+
91
+ /** The run step that wrote a fact (PROV `wasGeneratedBy`), for one an agent wrote. */
92
+ export interface FactGeneratedBy {
93
+ readonly runId: string;
94
+ readonly stepId?: string;
95
+ readonly toolCallId?: string;
34
96
  }
35
97
 
98
+ /** Why a revision stopped being current. */
99
+ export type FactInvalidationReason = 'superseded' | 'deleted' | 'erased' | 'expired';
100
+
36
101
  /**
37
102
  * Retention override at the fact level. Tenant policy sets defaults; a
38
103
  * fact-level override wins if present.
@@ -86,7 +151,13 @@ export interface SourceRefresh {
86
151
  * per-fact retrieval hint.
87
152
  */
88
153
  export interface Fact<TContent = unknown> {
154
+ /**
155
+ * The fact, across its revisions: superseding keeps it. (For a fact that
156
+ * was never superseded it is also its one revision's id.)
157
+ */
89
158
  readonly id: FactId;
159
+ /** This revision's own id; absent where it equals `id`. */
160
+ readonly revisionId?: string;
90
161
  /**
91
162
  * Fact type identifier. Packs define their own; a few general-purpose
92
163
  * names are conventional ('working-memory', 'user-profile', 'summary',
@@ -94,7 +165,7 @@ export interface Fact<TContent = unknown> {
94
165
  */
95
166
  readonly type: string;
96
167
  readonly scope: MemoryScope;
97
- /** Monotonic version within `(scope, id)`. Supersession increments. */
168
+ /** The revision number within the fact: 1, then one more per supersede or verify. */
98
169
  readonly version: number;
99
170
  readonly createdAt: Timestamp;
100
171
  readonly updatedAt?: Timestamp;
@@ -110,5 +181,31 @@ export interface Fact<TContent = unknown> {
110
181
  readonly retention?: Retention;
111
182
  readonly source?: Source;
112
183
  readonly causedByLogId?: readonly string[];
184
+ /** The revision this one replaced (PROV `wasRevisionOf`). */
113
185
  readonly supersedes?: FactId;
186
+ /** How far it's trusted. Absent on facts from before trust was recorded: `asserted`. */
187
+ readonly trust?: FactTrust;
188
+ readonly verifiedBy?: string;
189
+ readonly verifiedAt?: Timestamp;
190
+ readonly attributedTo?: FactAttribution;
191
+ readonly generatedBy?: FactGeneratedBy;
192
+ readonly subjects?: readonly FactSubject[];
193
+ /** When the fact is true in the world (application time); absent: always. */
194
+ readonly validFrom?: Timestamp;
195
+ readonly validUntil?: Timestamp;
196
+ /** When it was said or seen. */
197
+ readonly observedAt?: Timestamp;
198
+ /** When this revision stopped being current (record time), by whom, and why; absent: current. */
199
+ readonly invalidatedAt?: Timestamp;
200
+ readonly invalidatedBy?: string;
201
+ readonly invalidationReason?: FactInvalidationReason;
202
+ /** `pending` while a person must approve it: a pending fact is never retrieved. */
203
+ readonly review?: 'pending';
204
+ /**
205
+ * When this revision stops being readable: from its retention
206
+ * (`keepUntil`, or `keepDays` from the fact's first write), or an
207
+ * agent-remembered fact's unverified window. No read returns it after.
208
+ * Absent: it doesn't expire.
209
+ */
210
+ readonly expiresAt?: Timestamp;
114
211
  }