@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 @@
1
+ {"version":3,"file":"action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AAG,EAAE;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,IAAI,IAAI,CAAC,UAAU,GAAG,EAAE;QAAE,OAAO,KAAK,CAAC;IACnE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,gBAAgB,CACvB,MAAkE,EAClE,QAAgB;IAEhB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACjC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CACpE,CAAC;IACF,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Small facade over the Phase 1.5 runtime components.
3
+ *
4
+ * Hosts can wire the components individually, or use this class when they want
5
+ * the roadmap-shaped API: propose(), recall(), tryAct().
6
+ */
7
+ import type { ActionContext, MemoryProposal, ProposedAction, RecallQuery } from '../types/index.js';
8
+ import { type ActionAuthorizationResult, ActionAuthorizer } from './action-authorizer.js';
9
+ import type { Clock } from './decision-helpers.js';
10
+ import { type RetrievalResult, RetrievalRouter, type RetrievalRouterOptions } from './retrieval-router.js';
11
+ import type { VisibilityPolicy } from './visibility-policy.js';
12
+ import { WriteGate, type WriteGateOptions, type WriteGateResult, type WriteGateStores } from './write-gate.js';
13
+ export interface AletheiaAuthorityOptions extends WriteGateStores {
14
+ readonly visibilityPolicy?: VisibilityPolicy;
15
+ readonly clock?: Clock;
16
+ readonly memoryIdForProposal?: WriteGateOptions['memoryIdForProposal'];
17
+ readonly topicMatcher?: RetrievalRouterOptions['topicMatcher'];
18
+ readonly authorityScorer?: RetrievalRouterOptions['authorityScorer'];
19
+ }
20
+ export declare class AletheiaAuthority {
21
+ /** Lower-level proposal gate, exposed for hosts that need detailed write control. */
22
+ readonly writeGate: WriteGate;
23
+ /** Lower-level recall router, exposed for hosts that compose retrieval manually. */
24
+ readonly retrievalRouter: RetrievalRouter;
25
+ /** Lower-level action guard, exposed for hosts that build their own facade. */
26
+ readonly actionAuthorizer: ActionAuthorizer;
27
+ /**
28
+ * Create the high-level authority facade from host-provided stores and policy.
29
+ *
30
+ * @remarks
31
+ * This is the composition root for most consumers. The facade does not own
32
+ * storage, authentication, provider clients, or background work; it wires the
33
+ * three runtime use cases over the supplied ports.
34
+ */
35
+ constructor(options: AletheiaAuthorityOptions);
36
+ /**
37
+ * Submit a memory proposal to the WriteGate.
38
+ *
39
+ * @remarks
40
+ * Use this after a host or adapter has already recorded the source event(s).
41
+ * The method validates proposal shape, source existence, visibility, scope,
42
+ * and conflict boundaries before inserting an atom. It never promotes beyond
43
+ * candidate authority by itself.
44
+ *
45
+ * @returns A structured write decision plus the inserted atom when one was
46
+ * recorded.
47
+ */
48
+ propose(proposal: MemoryProposal): Promise<WriteGateResult>;
49
+ /**
50
+ * Recall governed memory for a caller, scope, and optional filters.
51
+ *
52
+ * @remarks
53
+ * Use this before giving memory text to a model. Visibility and scope are
54
+ * checked before status/type/topic filtering, and unresolved conflicts block
55
+ * local use.
56
+ */
57
+ recall(query: RecallQuery): Promise<RetrievalResult>;
58
+ /**
59
+ * Authorize a proposed action against the memories the agent cites.
60
+ *
61
+ * @remarks
62
+ * Use this immediately before acting on recalled memory. The receiver-side
63
+ * action classification is re-checked here; sensitive actions always ask a
64
+ * human even when every cited memory is valid.
65
+ */
66
+ tryAct(action: ProposedAction, context: ActionContext): Promise<ActionAuthorizationResult>;
67
+ }
68
+ //# sourceMappingURL=authority-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authority-engine.d.ts","sourceRoot":"","sources":["../../src/runtime/authority-engine.ts"],"names":[],"mappings":"AAAA;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,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC;IAIpD;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAG3F"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Small facade over the Phase 1.5 runtime components.
3
+ *
4
+ * Hosts can wire the components individually, or use this class when they want
5
+ * the roadmap-shaped API: propose(), recall(), tryAct().
6
+ */
7
+ import { ActionAuthorizer, } from './action-authorizer.js';
8
+ import { RetrievalRouter, } from './retrieval-router.js';
9
+ import { WriteGate, } from './write-gate.js';
10
+ export class AletheiaAuthority {
11
+ /** Lower-level proposal gate, exposed for hosts that need detailed write control. */
12
+ writeGate;
13
+ /** Lower-level recall router, exposed for hosts that compose retrieval manually. */
14
+ retrievalRouter;
15
+ /** Lower-level action guard, exposed for hosts that build their own facade. */
16
+ actionAuthorizer;
17
+ /**
18
+ * Create the high-level authority facade from host-provided stores and policy.
19
+ *
20
+ * @remarks
21
+ * This is the composition root for most consumers. The facade does not own
22
+ * storage, authentication, provider clients, or background work; it wires the
23
+ * three runtime use cases over the supplied ports.
24
+ */
25
+ constructor(options) {
26
+ this.writeGate = new WriteGate({
27
+ eventLedger: options.eventLedger,
28
+ memoryStore: options.memoryStore,
29
+ conflictRegistry: options.conflictRegistry,
30
+ ...(options.visibilityPolicy !== undefined
31
+ ? { visibilityPolicy: options.visibilityPolicy }
32
+ : {}),
33
+ ...(options.clock !== undefined ? { clock: options.clock } : {}),
34
+ ...(options.memoryIdForProposal !== undefined
35
+ ? { memoryIdForProposal: options.memoryIdForProposal }
36
+ : {}),
37
+ });
38
+ const sharedRouterOptions = {
39
+ memoryStore: options.memoryStore,
40
+ conflictRegistry: options.conflictRegistry,
41
+ ...(options.visibilityPolicy !== undefined
42
+ ? { visibilityPolicy: options.visibilityPolicy }
43
+ : {}),
44
+ ...(options.clock !== undefined ? { clock: options.clock } : {}),
45
+ ...(options.topicMatcher !== undefined ? { topicMatcher: options.topicMatcher } : {}),
46
+ ...(options.authorityScorer !== undefined
47
+ ? { authorityScorer: options.authorityScorer }
48
+ : {}),
49
+ };
50
+ this.retrievalRouter = new RetrievalRouter(sharedRouterOptions);
51
+ const actionOptions = {
52
+ memoryStore: options.memoryStore,
53
+ conflictRegistry: options.conflictRegistry,
54
+ ...(options.visibilityPolicy !== undefined
55
+ ? { visibilityPolicy: options.visibilityPolicy }
56
+ : {}),
57
+ ...(options.clock !== undefined ? { clock: options.clock } : {}),
58
+ };
59
+ this.actionAuthorizer = new ActionAuthorizer(actionOptions);
60
+ }
61
+ /**
62
+ * Submit a memory proposal to the WriteGate.
63
+ *
64
+ * @remarks
65
+ * Use this after a host or adapter has already recorded the source event(s).
66
+ * The method validates proposal shape, source existence, visibility, scope,
67
+ * and conflict boundaries before inserting an atom. It never promotes beyond
68
+ * candidate authority by itself.
69
+ *
70
+ * @returns A structured write decision plus the inserted atom when one was
71
+ * recorded.
72
+ */
73
+ propose(proposal) {
74
+ return this.writeGate.propose(proposal);
75
+ }
76
+ /**
77
+ * Recall governed memory for a caller, scope, and optional filters.
78
+ *
79
+ * @remarks
80
+ * Use this before giving memory text to a model. Visibility and scope are
81
+ * checked before status/type/topic filtering, and unresolved conflicts block
82
+ * local use.
83
+ */
84
+ recall(query) {
85
+ return this.retrievalRouter.recall(query);
86
+ }
87
+ /**
88
+ * Authorize a proposed action against the memories the agent cites.
89
+ *
90
+ * @remarks
91
+ * Use this immediately before acting on recalled memory. The receiver-side
92
+ * action classification is re-checked here; sensitive actions always ask a
93
+ * human even when every cited memory is valid.
94
+ */
95
+ tryAct(action, context) {
96
+ return this.actionAuthorizer.tryAct(action, context);
97
+ }
98
+ }
99
+ //# sourceMappingURL=authority-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authority-engine.js","sourceRoot":"","sources":["../../src/runtime/authority-engine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH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MAAsB,EAAE,OAAsB;QACnD,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;CACF"}
@@ -0,0 +1,17 @@
1
+ import { type ConflictId, type Decision, type DecisionOutcome, type DecisionReason, type IsoTimestamp, type MemoryId } from '../types/index.js';
2
+ export interface Clock {
3
+ /** Return the logical timestamp used for emitted decisions and transitions. */
4
+ now(): IsoTimestamp;
5
+ }
6
+ export declare const SYSTEM_CLOCK: Clock;
7
+ /**
8
+ * Construct and validate a decision envelope.
9
+ *
10
+ * @remarks
11
+ * Runtime components use this instead of hand-building decision objects so
12
+ * every allow/deny/abstain path conforms to the exported zod schema. Callers
13
+ * should treat the returned value as the auditable result of the authority
14
+ * check.
15
+ */
16
+ export declare function decision(outcome: DecisionOutcome, reasons: readonly DecisionReason[], relatedMemoryIds: readonly MemoryId[], relatedConflictIds: readonly ConflictId[], emittedAt: IsoTimestamp): Decision;
17
+ //# sourceMappingURL=decision-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision-helpers.d.ts","sourceRoot":"","sources":["../../src/runtime/decision-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,cAAc,EAEnB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,KAAK;IACpB,+EAA+E;IAC/E,GAAG,IAAI,YAAY,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,EAAE,KAE1B,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,SAAS,cAAc,EAAE,EAClC,gBAAgB,EAAE,SAAS,QAAQ,EAAE,EACrC,kBAAkB,EAAE,SAAS,UAAU,EAAE,EACzC,SAAS,EAAE,YAAY,GACtB,QAAQ,CAQV"}
@@ -0,0 +1,23 @@
1
+ import { DecisionSchema, } from '../types/index.js';
2
+ export const SYSTEM_CLOCK = {
3
+ now: () => new Date().toISOString(),
4
+ };
5
+ /**
6
+ * Construct and validate a decision envelope.
7
+ *
8
+ * @remarks
9
+ * Runtime components use this instead of hand-building decision objects so
10
+ * every allow/deny/abstain path conforms to the exported zod schema. Callers
11
+ * should treat the returned value as the auditable result of the authority
12
+ * check.
13
+ */
14
+ export function decision(outcome, reasons, relatedMemoryIds, relatedConflictIds, emittedAt) {
15
+ return DecisionSchema.parse({
16
+ outcome,
17
+ reasons,
18
+ relatedMemoryIds,
19
+ relatedConflictIds,
20
+ emittedAt,
21
+ });
22
+ }
23
+ //# sourceMappingURL=decision-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision-helpers.js","sourceRoot":"","sources":["../../src/runtime/decision-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,cAAc,GAGf,MAAM,mBAAmB,CAAC;AAO3B,MAAM,CAAC,MAAM,YAAY,GAAU;IACjC,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAkB;CACpD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CACtB,OAAwB,EACxB,OAAkC,EAClC,gBAAqC,EACrC,kBAAyC,EACzC,SAAuB;IAEvB,OAAO,cAAc,CAAC,KAAK,CAAC;QAC1B,OAAO;QACP,OAAO;QACP,gBAAgB;QAChB,kBAAkB;QAClB,SAAS;KACV,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,9 @@
1
+ export * from './action-authorizer.js';
2
+ export * from './authority-engine.js';
3
+ export * from './decision-helpers.js';
4
+ export * from './proposal-safety.js';
5
+ export * from './retrieval-router.js';
6
+ export * from './scope-helpers.js';
7
+ export * from './visibility-policy.js';
8
+ export * from './write-gate.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,9 @@
1
+ export * from './action-authorizer.js';
2
+ export * from './authority-engine.js';
3
+ export * from './decision-helpers.js';
4
+ export * from './proposal-safety.js';
5
+ export * from './retrieval-router.js';
6
+ export * from './scope-helpers.js';
7
+ export * from './visibility-policy.js';
8
+ export * from './write-gate.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { DecisionReason, MemoryProposal } from '../types/index.js';
2
+ export type ProposalSafetyOutcome = 'deny' | 'ask_human';
3
+ export interface ProposalSafetyFinding {
4
+ readonly outcome: ProposalSafetyOutcome;
5
+ readonly reason: DecisionReason;
6
+ }
7
+ /**
8
+ * Deterministic proposal safety policy for claims that should not become
9
+ * actionable memory even if a model proposes them.
10
+ *
11
+ * @remarks
12
+ * This is deliberately small and receipt-adjacent: it catches credential-like
13
+ * material, durable permission-bypass policies, and destructive runtime
14
+ * instructions before a MemoryAtom can become actionable. It does not rank,
15
+ * embed, or infer relevance.
16
+ */
17
+ export declare function evaluateProposalSafety(proposal: MemoryProposal): ProposalSafetyFinding | null;
18
+ //# sourceMappingURL=proposal-safety.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proposal-safety.d.ts","sourceRoot":"","sources":["../../src/runtime/proposal-safety.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExE,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,WAAW,CAAC;AAEzD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;CACjC;AA6BD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,cAAc,GAAG,qBAAqB,GAAG,IAAI,CAmC7F"}
@@ -0,0 +1,76 @@
1
+ const SECRET_PATTERNS = [
2
+ /\bsk-[A-Za-z0-9_-]{16,}\b/,
3
+ /\bAKIA[0-9A-Z]{16}\b/,
4
+ /\bgh[pousr]_[A-Za-z0-9_]{20,}\b/,
5
+ /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/,
6
+ /-----BEGIN [A-Z ]*PRIVATE KEY-----/,
7
+ /\b(?:api[_-]?key|secret|token|password)\s*[:=]\s*["']?[^"'\s]{8,}/i,
8
+ ];
9
+ const PERMISSION_BYPASS_PATTERNS = [
10
+ /\bact(?:uar)?\s+sin\s+pedir\s+permiso\b/,
11
+ /\bsin\s+(?:pedir|requerir)\s+permiso\b/,
12
+ /\bwithout\s+(?:asking|requiring)\s+permission\b/,
13
+ /\bbypass\s+(?:approval|permission|human)\b/,
14
+ /\bignore\s+(?:approval|permission|human)\b/,
15
+ /\bdo\s+not\s+ask\s+(?:for\s+)?permission\b/,
16
+ ];
17
+ const DESTRUCTIVE_EFFECT_PATTERNS = [
18
+ /\brm\s+-rf\b/,
19
+ /\bdelete\s+(?:the\s+)?(?:repo|repository|database|production)\b/,
20
+ /\bdrop\s+database\b/,
21
+ /\bformat\s+(?:the\s+)?disk\b/,
22
+ /\bborra\s+(?:todo\s+)?(?:el\s+)?repo\b/,
23
+ /\belimina\s+(?:todo\s+)?(?:el\s+)?repo\b/,
24
+ ];
25
+ /**
26
+ * Deterministic proposal safety policy for claims that should not become
27
+ * actionable memory even if a model proposes them.
28
+ *
29
+ * @remarks
30
+ * This is deliberately small and receipt-adjacent: it catches credential-like
31
+ * material, durable permission-bypass policies, and destructive runtime
32
+ * instructions before a MemoryAtom can become actionable. It does not rank,
33
+ * embed, or infer relevance.
34
+ */
35
+ export function evaluateProposalSafety(proposal) {
36
+ const claim = proposal.claim;
37
+ const normalizedClaim = normalizeClaim(claim);
38
+ if (matchesAny(claim, SECRET_PATTERNS) || matchesAny(normalizedClaim, SECRET_PATTERNS)) {
39
+ return {
40
+ outcome: 'deny',
41
+ reason: {
42
+ kind: 'promotion_boundary_blocked',
43
+ detail: 'proposal claim contains credential-like material and was not stored',
44
+ },
45
+ };
46
+ }
47
+ if (matchesAny(normalizedClaim, DESTRUCTIVE_EFFECT_PATTERNS)) {
48
+ return {
49
+ outcome: 'deny',
50
+ reason: {
51
+ kind: 'forbidden_effect_present',
52
+ effect: 'destructive_runtime_instruction',
53
+ },
54
+ };
55
+ }
56
+ if (matchesAny(normalizedClaim, PERMISSION_BYPASS_PATTERNS)) {
57
+ return {
58
+ outcome: 'ask_human',
59
+ reason: {
60
+ kind: 'promotion_boundary_blocked',
61
+ detail: 'proposal attempts to weaken receiver-side permission checks',
62
+ },
63
+ };
64
+ }
65
+ return null;
66
+ }
67
+ function normalizeClaim(value) {
68
+ return value
69
+ .normalize('NFD')
70
+ .replace(/\p{Diacritic}/gu, '')
71
+ .toLowerCase();
72
+ }
73
+ function matchesAny(value, patterns) {
74
+ return patterns.some((pattern) => pattern.test(value));
75
+ }
76
+ //# sourceMappingURL=proposal-safety.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proposal-safety.js","sourceRoot":"","sources":["../../src/runtime/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d,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,KAAK;SACT,SAAS,CAAC,KAAK,CAAC;SAChB,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC;SAC9B,WAAW,EAAE,CAAC;AACnB,CAAC;AAED,SAAS,UAAU,CAAC,KAAa,EAAE,QAA2B;IAC5D,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AACzD,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * RetrievalRouter — authority-first recall.
3
+ *
4
+ * This is deliberately not semantic search. Routing order is permission,
5
+ * status/scope/type, conflict state, then optional host-provided exact topic
6
+ * matching. Without a topic matcher, topic queries fail closed.
7
+ */
8
+ import type { ConflictRegistry, MemoryStore } from '../storage/index.js';
9
+ import type { ConflictRecord, IsoTimestamp, MemoryAtom, RecallQuery, RetrievalDecision } from '../types/index.js';
10
+ import type { Clock } from './decision-helpers.js';
11
+ import { type VisibilityPolicy } from './visibility-policy.js';
12
+ export type RetrievalAuthorityScorer = (atom: MemoryAtom, now: IsoTimestamp) => number;
13
+ export interface RetrievalRouterOptions {
14
+ readonly memoryStore: MemoryStore;
15
+ readonly conflictRegistry: ConflictRegistry;
16
+ readonly visibilityPolicy?: VisibilityPolicy;
17
+ readonly topicMatcher?: (atom: MemoryAtom, topic: string) => boolean;
18
+ /**
19
+ * Optional authority ranking hook applied only after visibility, scope,
20
+ * status, freshness, type, and topic filters.
21
+ *
22
+ * @remarks
23
+ * This hook is for receipt-derived ranking within already-authorized
24
+ * candidates. It must not grant permission, perform semantic retrieval, or
25
+ * treat confidence/consensus/prose as authority.
26
+ */
27
+ readonly authorityScorer?: RetrievalAuthorityScorer;
28
+ readonly clock?: Clock;
29
+ }
30
+ export interface RetrievalResult {
31
+ readonly decision: RetrievalDecision;
32
+ readonly atoms: readonly MemoryAtom[];
33
+ readonly conflicts: readonly ConflictRecord[];
34
+ }
35
+ export declare class RetrievalRouter {
36
+ private readonly options;
37
+ private readonly visibilityPolicy;
38
+ private readonly clock;
39
+ /**
40
+ * Create an authority-first recall router.
41
+ *
42
+ * @remarks
43
+ * The optional topic matcher is an exact host-provided predicate, not an
44
+ * embedding or semantic ranking hook. If a topic query is supplied without a
45
+ * matcher, recall fails closed.
46
+ */
47
+ constructor(options: RetrievalRouterOptions);
48
+ /**
49
+ * Recall atoms that are visible, in scope, currently valid, and actionable.
50
+ *
51
+ * @remarks
52
+ * Implementation order is permission before semantics: caller visibility is
53
+ * resolved first, then the store query applies scope/status/freshness, then
54
+ * optional type/topic filtering, then conflict checks. The returned decision
55
+ * must be inspected before passing atoms to a model.
56
+ */
57
+ recall(query: RecallQuery): Promise<RetrievalResult>;
58
+ private loadAtoms;
59
+ }
60
+ //# sourceMappingURL=retrieval-router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retrieval-router.d.ts","sourceRoot":"","sources":["../../src/runtime/retrieval-router.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EACV,cAAc,EAEd,YAAY,EACZ,UAAU,EAEV,WAAW,EACX,iBAAiB,EAElB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAA8B,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE3F,MAAM,MAAM,wBAAwB,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC;AAEvF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,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