@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,42 @@
1
+ /**
2
+ * Primitive value objects shared across all domain types.
3
+ *
4
+ * All identifiers are zod-branded strings: at runtime a `MemoryId` and an
5
+ * `EventId` are both strings; TypeScript enforces nominal separation so they
6
+ * cannot be mixed. The single source of truth is the zod schema — types are
7
+ * derived from it via `z.infer`.
8
+ */
9
+ import { z } from 'zod';
10
+ // -- Branded IDs (one brand system: zod) -------------------------------------
11
+ const idShape = z.string().min(1).max(256);
12
+ export const MemoryIdSchema = idShape.brand();
13
+ export const EventIdSchema = idShape.brand();
14
+ export const ProposalIdSchema = idShape.brand();
15
+ export const ConflictIdSchema = idShape.brand();
16
+ export const AgentIdSchema = idShape.brand();
17
+ export const SourceArtifactIdSchema = idShape.brand();
18
+ export const ReceiptIdSchema = idShape.brand();
19
+ // -- Timestamps --------------------------------------------------------------
20
+ /** ISO-8601 UTC timestamp. We never accept partial dates or local timezones. */
21
+ export const IsoTimestampSchema = z
22
+ .string()
23
+ .datetime({ offset: false, message: 'must be ISO-8601 in UTC (e.g. 2026-05-16T12:00:00Z)' });
24
+ // -- Hash digests ------------------------------------------------------------
25
+ /**
26
+ * Content digest of a source artifact. We accept any well-formed hex hash
27
+ * (sha256, blake3, etc.) — the algorithm is implicit in the lane that produced it.
28
+ */
29
+ export const HashDigestSchema = z
30
+ .string()
31
+ .regex(/^[a-f0-9]{32,128}$/i, 'must be a hex digest between 32 and 128 chars');
32
+ // -- Source paths / lanes ----------------------------------------------------
33
+ /**
34
+ * Path or registry lane to the source artifact. NOT prose: must be resolvable
35
+ * to a real artifact by the source-lane resolver.
36
+ */
37
+ export const SourcePathSchema = z
38
+ .string()
39
+ .min(1)
40
+ .max(1024)
41
+ .refine((s) => !s.includes('\n'), 'source path cannot contain newlines');
42
+ //# sourceMappingURL=primitives.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitives.js","sourceRoot":"","sources":["../../src/types/primitives.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAEx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
2
+ * Allowed status transitions for a MemoryAtom.
3
+ *
4
+ * Phase 1 matrix is intentionally strict; Phase 2 (memory dynamics) will
5
+ * relax some terminal states via reconsolidation events.
6
+ *
7
+ * Sealed is terminal-from-without — only an authorized operator can move
8
+ * a sealed atom, and that path doesn't go through `transitionStatus`.
9
+ */
10
+ import type { MemoryStatus } from './enums.js';
11
+ /**
12
+ * Check whether moving from `from` to `to` is a valid transition.
13
+ *
14
+ * Returns `true` for legal transitions and `false` for illegal ones.
15
+ * Does NOT consider permissions, evidence, or conflicts — those are the
16
+ * caller's responsibility (typically the WriteGate or MemoryStore wrapper).
17
+ */
18
+ export declare function isAllowedTransition(from: MemoryStatus, to: MemoryStatus): boolean;
19
+ /**
20
+ * Get the set of statuses an atom can legally transition to from `from`.
21
+ */
22
+ export declare function allowedTransitionsFrom(from: MemoryStatus): ReadonlySet<MemoryStatus>;
23
+ //# sourceMappingURL=status-transitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-transitions.d.ts","sourceRoot":"","sources":["../../src/types/status-transitions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAyB/C;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,YAAY,GAAG,OAAO,CAEjF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,YAAY,GAAG,WAAW,CAAC,YAAY,CAAC,CAEpF"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Allowed status transitions for a MemoryAtom.
3
+ *
4
+ * Phase 1 matrix is intentionally strict; Phase 2 (memory dynamics) will
5
+ * relax some terminal states via reconsolidation events.
6
+ *
7
+ * Sealed is terminal-from-without — only an authorized operator can move
8
+ * a sealed atom, and that path doesn't go through `transitionStatus`.
9
+ */
10
+ const TRANSITIONS = {
11
+ candidate: new Set([
12
+ 'verified',
13
+ 'deprecated',
14
+ 'rejected',
15
+ 'sealed',
16
+ 'human_required',
17
+ ]),
18
+ verified: new Set([
19
+ 'trusted',
20
+ 'deprecated',
21
+ 'rejected',
22
+ 'sealed',
23
+ 'human_required',
24
+ ]),
25
+ trusted: new Set(['deprecated', 'rejected', 'sealed']),
26
+ deprecated: new Set(['verified', 'rejected']),
27
+ rejected: new Set(),
28
+ // Sealed has no outward transitions through this API. Special path required.
29
+ sealed: new Set(),
30
+ human_required: new Set(['candidate', 'verified', 'rejected']),
31
+ };
32
+ /**
33
+ * Check whether moving from `from` to `to` is a valid transition.
34
+ *
35
+ * Returns `true` for legal transitions and `false` for illegal ones.
36
+ * Does NOT consider permissions, evidence, or conflicts — those are the
37
+ * caller's responsibility (typically the WriteGate or MemoryStore wrapper).
38
+ */
39
+ export function isAllowedTransition(from, to) {
40
+ return TRANSITIONS[from].has(to);
41
+ }
42
+ /**
43
+ * Get the set of statuses an atom can legally transition to from `from`.
44
+ */
45
+ export function allowedTransitionsFrom(from) {
46
+ return TRANSITIONS[from];
47
+ }
48
+ //# sourceMappingURL=status-transitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-transitions.js","sourceRoot":"","sources":["../../src/types/status-transitions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,MAAM,WAAW,GAA8D;IAC7E,SAAS,EAAE,IAAI,GAAG,CAAe;QAC/B,UAAU;QACV,YAAY;QACZ,UAAU;QACV,QAAQ;QACR,gBAAgB;KACjB,CAAC;IACF,QAAQ,EAAE,IAAI,GAAG,CAAe;QAC9B,SAAS;QACT,YAAY;QACZ,UAAU;QACV,QAAQ;QACR,gBAAgB;KACjB,CAAC;IACF,OAAO,EAAE,IAAI,GAAG,CAAe,CAAC,YAAY,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IACpE,UAAU,EAAE,IAAI,GAAG,CAAe,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC3D,QAAQ,EAAE,IAAI,GAAG,EAAgB;IACjC,6EAA6E;IAC7E,MAAM,EAAE,IAAI,GAAG,EAAgB;IAC/B,cAAc,EAAE,IAAI,GAAG,CAAe,CAAC,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;CAC7E,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAkB,EAAE,EAAgB;IACtE,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAkB;IACvD,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@aletheia-labs/core",
3
+ "version": "0.1.0",
4
+ "description": "Aletheia core — types and runtime for memory as governance in LLM agents.",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ },
15
+ "./types": {
16
+ "types": "./dist/types/index.d.ts",
17
+ "import": "./dist/types/index.js"
18
+ },
19
+ "./runtime": {
20
+ "types": "./dist/runtime/index.d.ts",
21
+ "import": "./dist/runtime/index.js"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "README.md",
27
+ "LICENSE"
28
+ ],
29
+ "dependencies": {
30
+ "zod": "^3.23.8"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^22.10.0",
34
+ "typescript": "^5.6.3",
35
+ "vitest": "^2.1.8"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "keywords": [
41
+ "llm",
42
+ "memory",
43
+ "agents",
44
+ "ai",
45
+ "authority",
46
+ "governance",
47
+ "receipts",
48
+ "fail-closed"
49
+ ],
50
+ "scripts": {
51
+ "build": "tsc -p tsconfig.json",
52
+ "typecheck": "tsc -p tsconfig.json --noEmit",
53
+ "smoke:e2e": "tsc -p examples/tsconfig.json && vitest run --config examples/vitest.config.ts",
54
+ "test": "vitest run",
55
+ "test:watch": "vitest"
56
+ }
57
+ }