@aletheia-labs/core 0.1.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.
Files changed (119) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +163 -0
  3. package/dist/index.d.ts +18 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +21 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/runtime/action-authorizer.d.ts +48 -0
  8. package/dist/runtime/action-authorizer.d.ts.map +1 -0
  9. package/dist/runtime/action-authorizer.js +231 -0
  10. package/dist/runtime/action-authorizer.js.map +1 -0
  11. package/dist/runtime/authority-engine.d.ts +68 -0
  12. package/dist/runtime/authority-engine.d.ts.map +1 -0
  13. package/dist/runtime/authority-engine.js +99 -0
  14. package/dist/runtime/authority-engine.js.map +1 -0
  15. package/dist/runtime/decision-helpers.d.ts +17 -0
  16. package/dist/runtime/decision-helpers.d.ts.map +1 -0
  17. package/dist/runtime/decision-helpers.js +23 -0
  18. package/dist/runtime/decision-helpers.js.map +1 -0
  19. package/dist/runtime/index.d.ts +9 -0
  20. package/dist/runtime/index.d.ts.map +1 -0
  21. package/dist/runtime/index.js +9 -0
  22. package/dist/runtime/index.js.map +1 -0
  23. package/dist/runtime/proposal-safety.d.ts +18 -0
  24. package/dist/runtime/proposal-safety.d.ts.map +1 -0
  25. package/dist/runtime/proposal-safety.js +76 -0
  26. package/dist/runtime/proposal-safety.js.map +1 -0
  27. package/dist/runtime/retrieval-router.d.ts +60 -0
  28. package/dist/runtime/retrieval-router.d.ts.map +1 -0
  29. package/dist/runtime/retrieval-router.js +223 -0
  30. package/dist/runtime/retrieval-router.js.map +1 -0
  31. package/dist/runtime/scope-helpers.d.ts +22 -0
  32. package/dist/runtime/scope-helpers.d.ts.map +1 -0
  33. package/dist/runtime/scope-helpers.js +29 -0
  34. package/dist/runtime/scope-helpers.js.map +1 -0
  35. package/dist/runtime/visibility-policy.d.ts +29 -0
  36. package/dist/runtime/visibility-policy.d.ts.map +1 -0
  37. package/dist/runtime/visibility-policy.js +23 -0
  38. package/dist/runtime/visibility-policy.js.map +1 -0
  39. package/dist/runtime/write-gate.d.ts +66 -0
  40. package/dist/runtime/write-gate.d.ts.map +1 -0
  41. package/dist/runtime/write-gate.js +293 -0
  42. package/dist/runtime/write-gate.js.map +1 -0
  43. package/dist/storage/conflict-registry.d.ts +61 -0
  44. package/dist/storage/conflict-registry.d.ts.map +1 -0
  45. package/dist/storage/conflict-registry.js +15 -0
  46. package/dist/storage/conflict-registry.js.map +1 -0
  47. package/dist/storage/event-ledger.d.ts +61 -0
  48. package/dist/storage/event-ledger.d.ts.map +1 -0
  49. package/dist/storage/event-ledger.js +14 -0
  50. package/dist/storage/event-ledger.js.map +1 -0
  51. package/dist/storage/index.d.ts +8 -0
  52. package/dist/storage/index.d.ts.map +1 -0
  53. package/dist/storage/index.js +8 -0
  54. package/dist/storage/index.js.map +1 -0
  55. package/dist/storage/memory-store.d.ts +94 -0
  56. package/dist/storage/memory-store.d.ts.map +1 -0
  57. package/dist/storage/memory-store.js +14 -0
  58. package/dist/storage/memory-store.js.map +1 -0
  59. package/dist/types/action.d.ts +211 -0
  60. package/dist/types/action.d.ts.map +1 -0
  61. package/dist/types/action.js +50 -0
  62. package/dist/types/action.js.map +1 -0
  63. package/dist/types/compressed-receipt.d.ts +117 -0
  64. package/dist/types/compressed-receipt.d.ts.map +1 -0
  65. package/dist/types/compressed-receipt.js +100 -0
  66. package/dist/types/compressed-receipt.js.map +1 -0
  67. package/dist/types/conflict.d.ts +159 -0
  68. package/dist/types/conflict.d.ts.map +1 -0
  69. package/dist/types/conflict.js +47 -0
  70. package/dist/types/conflict.js.map +1 -0
  71. package/dist/types/coverage.d.ts +52 -0
  72. package/dist/types/coverage.d.ts.map +1 -0
  73. package/dist/types/coverage.js +30 -0
  74. package/dist/types/coverage.js.map +1 -0
  75. package/dist/types/decision.d.ts +345 -0
  76. package/dist/types/decision.d.ts.map +1 -0
  77. package/dist/types/decision.js +88 -0
  78. package/dist/types/decision.js.map +1 -0
  79. package/dist/types/enums.d.ts +135 -0
  80. package/dist/types/enums.d.ts.map +1 -0
  81. package/dist/types/enums.js +146 -0
  82. package/dist/types/enums.js.map +1 -0
  83. package/dist/types/event.d.ts +187 -0
  84. package/dist/types/event.d.ts.map +1 -0
  85. package/dist/types/event.js +44 -0
  86. package/dist/types/event.js.map +1 -0
  87. package/dist/types/human-receipt.d.ts +108 -0
  88. package/dist/types/human-receipt.d.ts.map +1 -0
  89. package/dist/types/human-receipt.js +41 -0
  90. package/dist/types/human-receipt.js.map +1 -0
  91. package/dist/types/index.d.ts +25 -0
  92. package/dist/types/index.d.ts.map +1 -0
  93. package/dist/types/index.js +25 -0
  94. package/dist/types/index.js.map +1 -0
  95. package/dist/types/keys.d.ts +31 -0
  96. package/dist/types/keys.d.ts.map +1 -0
  97. package/dist/types/keys.js +53 -0
  98. package/dist/types/keys.js.map +1 -0
  99. package/dist/types/memory-atom.d.ts +291 -0
  100. package/dist/types/memory-atom.d.ts.map +1 -0
  101. package/dist/types/memory-atom.js +62 -0
  102. package/dist/types/memory-atom.js.map +1 -0
  103. package/dist/types/memory-proposal.d.ts +207 -0
  104. package/dist/types/memory-proposal.d.ts.map +1 -0
  105. package/dist/types/memory-proposal.js +34 -0
  106. package/dist/types/memory-proposal.js.map +1 -0
  107. package/dist/types/packet.d.ts +564 -0
  108. package/dist/types/packet.d.ts.map +1 -0
  109. package/dist/types/packet.js +43 -0
  110. package/dist/types/packet.js.map +1 -0
  111. package/dist/types/primitives.d.ts +39 -0
  112. package/dist/types/primitives.d.ts.map +1 -0
  113. package/dist/types/primitives.js +42 -0
  114. package/dist/types/primitives.js.map +1 -0
  115. package/dist/types/status-transitions.d.ts +23 -0
  116. package/dist/types/status-transitions.d.ts.map +1 -0
  117. package/dist/types/status-transitions.js +48 -0
  118. package/dist/types/status-transitions.js.map +1 -0
  119. package/package.json +57 -0
@@ -0,0 +1,207 @@
1
+ /**
2
+ * MemoryProposal — what an agent submits to the WriteGate.
3
+ * Source: specs/aletheia-memory-authority-v0.md §2 "Memory Proposal Layer".
4
+ *
5
+ * Proposals are NOT memories yet. The WriteGate produces (or rejects)
6
+ * the MemoryAtom from a proposal.
7
+ */
8
+ import { z } from 'zod';
9
+ /**
10
+ * A reference to a memory the proposer knows about as a known conflict source.
11
+ * The proposer is responsible for surfacing known contradictions; the
12
+ * ConflictRegistry can also discover them.
13
+ */
14
+ export declare const KnownConflictSchema: z.ZodObject<{
15
+ conflictingMemoryId: z.ZodBranded<z.ZodString, "MemoryId">;
16
+ rationale: z.ZodString;
17
+ }, "strip", z.ZodTypeAny, {
18
+ conflictingMemoryId: string & z.BRAND<"MemoryId">;
19
+ rationale: string;
20
+ }, {
21
+ conflictingMemoryId: string;
22
+ rationale: string;
23
+ }>;
24
+ export type KnownConflict = z.infer<typeof KnownConflictSchema>;
25
+ export declare const MemoryProposalSchema: z.ZodObject<{
26
+ proposalId: z.ZodBranded<z.ZodString, "ProposalId">;
27
+ proposedBy: z.ZodBranded<z.ZodString, "AgentId">;
28
+ proposedAt: z.ZodString;
29
+ candidateType: z.ZodEnum<["observation", "claim", "preference", "policy", "decision", "task_state", "warning", "skill"]>;
30
+ /** The claim text the proposer wants stored. */
31
+ claim: z.ZodString;
32
+ /** Raw events this proposal is grounded in (must be non-empty). */
33
+ sourceEventIds: z.ZodArray<z.ZodBranded<z.ZodString, "EventId">, "many">;
34
+ intendedScope: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
35
+ kind: z.ZodLiteral<"local">;
36
+ }, "strip", z.ZodTypeAny, {
37
+ kind: "local";
38
+ }, {
39
+ kind: "local";
40
+ }>, z.ZodObject<{
41
+ kind: z.ZodLiteral<"project">;
42
+ projectId: z.ZodString;
43
+ }, "strip", z.ZodTypeAny, {
44
+ kind: "project";
45
+ projectId: string;
46
+ }, {
47
+ kind: "project";
48
+ projectId: string;
49
+ }>, z.ZodObject<{
50
+ kind: z.ZodLiteral<"user">;
51
+ userId: z.ZodString;
52
+ }, "strip", z.ZodTypeAny, {
53
+ kind: "user";
54
+ userId: string;
55
+ }, {
56
+ kind: "user";
57
+ userId: string;
58
+ }>, z.ZodObject<{
59
+ kind: z.ZodLiteral<"team">;
60
+ teamId: z.ZodString;
61
+ }, "strip", z.ZodTypeAny, {
62
+ kind: "team";
63
+ teamId: string;
64
+ }, {
65
+ kind: "team";
66
+ teamId: string;
67
+ }>, z.ZodObject<{
68
+ kind: z.ZodLiteral<"global">;
69
+ }, "strip", z.ZodTypeAny, {
70
+ kind: "global";
71
+ }, {
72
+ kind: "global";
73
+ }>]>;
74
+ intendedVisibility: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
75
+ kind: z.ZodLiteral<"private:agent">;
76
+ }, "strip", z.ZodTypeAny, {
77
+ kind: "private:agent";
78
+ }, {
79
+ kind: "private:agent";
80
+ }>, z.ZodObject<{
81
+ kind: z.ZodLiteral<"private:user">;
82
+ }, "strip", z.ZodTypeAny, {
83
+ kind: "private:user";
84
+ }, {
85
+ kind: "private:user";
86
+ }>, z.ZodObject<{
87
+ kind: z.ZodLiteral<"team">;
88
+ name: z.ZodString;
89
+ }, "strip", z.ZodTypeAny, {
90
+ kind: "team";
91
+ name: string;
92
+ }, {
93
+ kind: "team";
94
+ name: string;
95
+ }>, z.ZodObject<{
96
+ kind: z.ZodLiteral<"global:safe">;
97
+ }, "strip", z.ZodTypeAny, {
98
+ kind: "global:safe";
99
+ }, {
100
+ kind: "global:safe";
101
+ }>, z.ZodObject<{
102
+ kind: z.ZodLiteral<"sealed:sensitive">;
103
+ }, "strip", z.ZodTypeAny, {
104
+ kind: "sealed:sensitive";
105
+ }, {
106
+ kind: "sealed:sensitive";
107
+ }>, z.ZodObject<{
108
+ kind: z.ZodLiteral<"ephemeral">;
109
+ }, "strip", z.ZodTypeAny, {
110
+ kind: "ephemeral";
111
+ }, {
112
+ kind: "ephemeral";
113
+ }>]>;
114
+ riskLevel: z.ZodEnum<["low_local", "medium_local", "sensitive"]>;
115
+ knownConflicts: z.ZodArray<z.ZodObject<{
116
+ conflictingMemoryId: z.ZodBranded<z.ZodString, "MemoryId">;
117
+ rationale: z.ZodString;
118
+ }, "strip", z.ZodTypeAny, {
119
+ conflictingMemoryId: string & z.BRAND<"MemoryId">;
120
+ rationale: string;
121
+ }, {
122
+ conflictingMemoryId: string;
123
+ rationale: string;
124
+ }>, "many">;
125
+ }, "strip", z.ZodTypeAny, {
126
+ claim: string;
127
+ sourceEventIds: (string & z.BRAND<"EventId">)[];
128
+ proposalId: string & z.BRAND<"ProposalId">;
129
+ proposedBy: string & z.BRAND<"AgentId">;
130
+ proposedAt: string;
131
+ candidateType: "observation" | "claim" | "preference" | "policy" | "decision" | "task_state" | "warning" | "skill";
132
+ intendedScope: {
133
+ kind: "local";
134
+ } | {
135
+ kind: "project";
136
+ projectId: string;
137
+ } | {
138
+ kind: "user";
139
+ userId: string;
140
+ } | {
141
+ kind: "team";
142
+ teamId: string;
143
+ } | {
144
+ kind: "global";
145
+ };
146
+ intendedVisibility: {
147
+ kind: "private:agent";
148
+ } | {
149
+ kind: "private:user";
150
+ } | {
151
+ kind: "team";
152
+ name: string;
153
+ } | {
154
+ kind: "global:safe";
155
+ } | {
156
+ kind: "sealed:sensitive";
157
+ } | {
158
+ kind: "ephemeral";
159
+ };
160
+ riskLevel: "low_local" | "medium_local" | "sensitive";
161
+ knownConflicts: {
162
+ conflictingMemoryId: string & z.BRAND<"MemoryId">;
163
+ rationale: string;
164
+ }[];
165
+ }, {
166
+ claim: string;
167
+ sourceEventIds: string[];
168
+ proposalId: string;
169
+ proposedBy: string;
170
+ proposedAt: string;
171
+ candidateType: "observation" | "claim" | "preference" | "policy" | "decision" | "task_state" | "warning" | "skill";
172
+ intendedScope: {
173
+ kind: "local";
174
+ } | {
175
+ kind: "project";
176
+ projectId: string;
177
+ } | {
178
+ kind: "user";
179
+ userId: string;
180
+ } | {
181
+ kind: "team";
182
+ teamId: string;
183
+ } | {
184
+ kind: "global";
185
+ };
186
+ intendedVisibility: {
187
+ kind: "private:agent";
188
+ } | {
189
+ kind: "private:user";
190
+ } | {
191
+ kind: "team";
192
+ name: string;
193
+ } | {
194
+ kind: "global:safe";
195
+ } | {
196
+ kind: "sealed:sensitive";
197
+ } | {
198
+ kind: "ephemeral";
199
+ };
200
+ riskLevel: "low_local" | "medium_local" | "sensitive";
201
+ knownConflicts: {
202
+ conflictingMemoryId: string;
203
+ rationale: string;
204
+ }[];
205
+ }>;
206
+ export type MemoryProposal = z.infer<typeof MemoryProposalSchema>;
207
+ //# sourceMappingURL=memory-proposal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-proposal.d.ts","sourceRoot":"","sources":["../../src/types/memory-proposal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;EAG9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,oBAAoB;;;;;IAK/B,gDAAgD;;IAEhD,mEAAmE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMnE,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * MemoryProposal — what an agent submits to the WriteGate.
3
+ * Source: specs/aletheia-memory-authority-v0.md §2 "Memory Proposal Layer".
4
+ *
5
+ * Proposals are NOT memories yet. The WriteGate produces (or rejects)
6
+ * the MemoryAtom from a proposal.
7
+ */
8
+ import { z } from 'zod';
9
+ import { MemoryTypeSchema, RiskTierSchema, ScopeSchema, VisibilitySchema } from './enums.js';
10
+ import { AgentIdSchema, EventIdSchema, IsoTimestampSchema, MemoryIdSchema, ProposalIdSchema, } from './primitives.js';
11
+ /**
12
+ * A reference to a memory the proposer knows about as a known conflict source.
13
+ * The proposer is responsible for surfacing known contradictions; the
14
+ * ConflictRegistry can also discover them.
15
+ */
16
+ export const KnownConflictSchema = z.object({
17
+ conflictingMemoryId: MemoryIdSchema,
18
+ rationale: z.string().min(1).max(2048),
19
+ });
20
+ export const MemoryProposalSchema = z.object({
21
+ proposalId: ProposalIdSchema,
22
+ proposedBy: AgentIdSchema,
23
+ proposedAt: IsoTimestampSchema,
24
+ candidateType: MemoryTypeSchema,
25
+ /** The claim text the proposer wants stored. */
26
+ claim: z.string().min(1).max(16_384),
27
+ /** Raw events this proposal is grounded in (must be non-empty). */
28
+ sourceEventIds: z.array(EventIdSchema).min(1),
29
+ intendedScope: ScopeSchema,
30
+ intendedVisibility: VisibilitySchema,
31
+ riskLevel: RiskTierSchema,
32
+ knownConflicts: z.array(KnownConflictSchema),
33
+ });
34
+ //# sourceMappingURL=memory-proposal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-proposal.js","sourceRoot":"","sources":["../../src/types/memory-proposal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC7F,OAAO,EACL,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,mBAAmB,EAAE,cAAc;IACnC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;CACvC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,UAAU,EAAE,gBAAgB;IAC5B,UAAU,EAAE,aAAa;IACzB,UAAU,EAAE,kBAAkB;IAC9B,aAAa,EAAE,gBAAgB;IAC/B,gDAAgD;IAChD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;IACpC,mEAAmE;IACnE,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7C,aAAa,EAAE,WAAW;IAC1B,kBAAkB,EAAE,gBAAgB;IACpC,SAAS,EAAE,cAAc;IACzB,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC;CAC7C,CAAC,CAAC"}