@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.
- package/LICENSE +176 -0
- package/README.md +163 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/action-authorizer.d.ts +48 -0
- package/dist/runtime/action-authorizer.d.ts.map +1 -0
- package/dist/runtime/action-authorizer.js +231 -0
- package/dist/runtime/action-authorizer.js.map +1 -0
- package/dist/runtime/authority-engine.d.ts +68 -0
- package/dist/runtime/authority-engine.d.ts.map +1 -0
- package/dist/runtime/authority-engine.js +99 -0
- package/dist/runtime/authority-engine.js.map +1 -0
- package/dist/runtime/decision-helpers.d.ts +17 -0
- package/dist/runtime/decision-helpers.d.ts.map +1 -0
- package/dist/runtime/decision-helpers.js +23 -0
- package/dist/runtime/decision-helpers.js.map +1 -0
- package/dist/runtime/index.d.ts +9 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +9 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/proposal-safety.d.ts +18 -0
- package/dist/runtime/proposal-safety.d.ts.map +1 -0
- package/dist/runtime/proposal-safety.js +76 -0
- package/dist/runtime/proposal-safety.js.map +1 -0
- package/dist/runtime/retrieval-router.d.ts +60 -0
- package/dist/runtime/retrieval-router.d.ts.map +1 -0
- package/dist/runtime/retrieval-router.js +223 -0
- package/dist/runtime/retrieval-router.js.map +1 -0
- package/dist/runtime/scope-helpers.d.ts +22 -0
- package/dist/runtime/scope-helpers.d.ts.map +1 -0
- package/dist/runtime/scope-helpers.js +29 -0
- package/dist/runtime/scope-helpers.js.map +1 -0
- package/dist/runtime/visibility-policy.d.ts +29 -0
- package/dist/runtime/visibility-policy.d.ts.map +1 -0
- package/dist/runtime/visibility-policy.js +23 -0
- package/dist/runtime/visibility-policy.js.map +1 -0
- package/dist/runtime/write-gate.d.ts +66 -0
- package/dist/runtime/write-gate.d.ts.map +1 -0
- package/dist/runtime/write-gate.js +293 -0
- package/dist/runtime/write-gate.js.map +1 -0
- package/dist/storage/conflict-registry.d.ts +61 -0
- package/dist/storage/conflict-registry.d.ts.map +1 -0
- package/dist/storage/conflict-registry.js +15 -0
- package/dist/storage/conflict-registry.js.map +1 -0
- package/dist/storage/event-ledger.d.ts +61 -0
- package/dist/storage/event-ledger.d.ts.map +1 -0
- package/dist/storage/event-ledger.js +14 -0
- package/dist/storage/event-ledger.js.map +1 -0
- package/dist/storage/index.d.ts +8 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +8 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/memory-store.d.ts +94 -0
- package/dist/storage/memory-store.d.ts.map +1 -0
- package/dist/storage/memory-store.js +14 -0
- package/dist/storage/memory-store.js.map +1 -0
- package/dist/types/action.d.ts +211 -0
- package/dist/types/action.d.ts.map +1 -0
- package/dist/types/action.js +50 -0
- package/dist/types/action.js.map +1 -0
- package/dist/types/compressed-receipt.d.ts +117 -0
- package/dist/types/compressed-receipt.d.ts.map +1 -0
- package/dist/types/compressed-receipt.js +100 -0
- package/dist/types/compressed-receipt.js.map +1 -0
- package/dist/types/conflict.d.ts +159 -0
- package/dist/types/conflict.d.ts.map +1 -0
- package/dist/types/conflict.js +47 -0
- package/dist/types/conflict.js.map +1 -0
- package/dist/types/coverage.d.ts +52 -0
- package/dist/types/coverage.d.ts.map +1 -0
- package/dist/types/coverage.js +30 -0
- package/dist/types/coverage.js.map +1 -0
- package/dist/types/decision.d.ts +345 -0
- package/dist/types/decision.d.ts.map +1 -0
- package/dist/types/decision.js +88 -0
- package/dist/types/decision.js.map +1 -0
- package/dist/types/enums.d.ts +135 -0
- package/dist/types/enums.d.ts.map +1 -0
- package/dist/types/enums.js +146 -0
- package/dist/types/enums.js.map +1 -0
- package/dist/types/event.d.ts +187 -0
- package/dist/types/event.d.ts.map +1 -0
- package/dist/types/event.js +44 -0
- package/dist/types/event.js.map +1 -0
- package/dist/types/human-receipt.d.ts +108 -0
- package/dist/types/human-receipt.d.ts.map +1 -0
- package/dist/types/human-receipt.js +41 -0
- package/dist/types/human-receipt.js.map +1 -0
- package/dist/types/index.d.ts +25 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +25 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/keys.d.ts +31 -0
- package/dist/types/keys.d.ts.map +1 -0
- package/dist/types/keys.js +53 -0
- package/dist/types/keys.js.map +1 -0
- package/dist/types/memory-atom.d.ts +291 -0
- package/dist/types/memory-atom.d.ts.map +1 -0
- package/dist/types/memory-atom.js +62 -0
- package/dist/types/memory-atom.js.map +1 -0
- package/dist/types/memory-proposal.d.ts +207 -0
- package/dist/types/memory-proposal.d.ts.map +1 -0
- package/dist/types/memory-proposal.js +34 -0
- package/dist/types/memory-proposal.js.map +1 -0
- package/dist/types/packet.d.ts +564 -0
- package/dist/types/packet.d.ts.map +1 -0
- package/dist/types/packet.js +43 -0
- package/dist/types/packet.js.map +1 -0
- package/dist/types/primitives.d.ts +39 -0
- package/dist/types/primitives.d.ts.map +1 -0
- package/dist/types/primitives.js +42 -0
- package/dist/types/primitives.js.map +1 -0
- package/dist/types/status-transitions.d.ts +23 -0
- package/dist/types/status-transitions.d.ts.map +1 -0
- package/dist/types/status-transitions.js +48 -0
- package/dist/types/status-transitions.js.map +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# @aletheia-labs/core
|
|
2
|
+
|
|
3
|
+
The core authority engine of Aletheia: memory as governance for LLM agents.
|
|
4
|
+
|
|
5
|
+
> **Status**: `0.1.0` public baseline. The consumer facade (`AletheiaAuthority`) and strict TypeScript domain/storage/runtime contracts are live.
|
|
6
|
+
|
|
7
|
+
## Quickstart
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @aletheia-labs/core @aletheia-labs/store-sqlite
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { AletheiaAuthority, staticVisibilityPolicy } from '@aletheia-labs/core';
|
|
15
|
+
import { openSqliteStores } from '@aletheia-labs/store-sqlite';
|
|
16
|
+
|
|
17
|
+
const stores = openSqliteStores('./aletheia.sqlite');
|
|
18
|
+
const authority = new AletheiaAuthority({
|
|
19
|
+
eventLedger: stores.eventLedger,
|
|
20
|
+
memoryStore: stores.memoryStore,
|
|
21
|
+
conflictRegistry: stores.conflictRegistry,
|
|
22
|
+
visibilityPolicy: staticVisibilityPolicy([{ kind: 'private:user' }]),
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Hosts provide storage and visibility policy. LLM adapters are optional and live outside core.
|
|
27
|
+
|
|
28
|
+
## Consumer API
|
|
29
|
+
|
|
30
|
+
Parse raw literals through the exported zod schemas when constructing values
|
|
31
|
+
by hand; they preserve the branded ID types used by the runtime contracts.
|
|
32
|
+
This assumes the source event already exists in the ledger and recalled atoms
|
|
33
|
+
have reached an actionable status (`verified` or `trusted`).
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import {
|
|
37
|
+
ActionContextSchema,
|
|
38
|
+
MemoryProposalSchema,
|
|
39
|
+
ProposedActionSchema,
|
|
40
|
+
RecallQuerySchema,
|
|
41
|
+
} from '@aletheia-labs/core';
|
|
42
|
+
|
|
43
|
+
const proposalResult = await authority.propose(
|
|
44
|
+
MemoryProposalSchema.parse({
|
|
45
|
+
proposalId: 'prop-1',
|
|
46
|
+
proposedBy: 'agent-1',
|
|
47
|
+
proposedAt: '2026-05-17T12:00:00Z',
|
|
48
|
+
candidateType: 'preference',
|
|
49
|
+
claim: 'The user prefers concise Spanish progress updates.',
|
|
50
|
+
sourceEventIds: ['evt-1'],
|
|
51
|
+
intendedScope: { kind: 'project', projectId: 'demo' },
|
|
52
|
+
intendedVisibility: { kind: 'private:user' },
|
|
53
|
+
riskLevel: 'low_local',
|
|
54
|
+
knownConflicts: [],
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const recall = await authority.recall(
|
|
59
|
+
RecallQuerySchema.parse({
|
|
60
|
+
agentId: 'agent-1',
|
|
61
|
+
scope: { kind: 'project', projectId: 'demo' },
|
|
62
|
+
limit: 5,
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const action = await authority.tryAct(
|
|
67
|
+
ProposedActionSchema.parse({ classifiedAction: 'local_report', target: 'local summary' }),
|
|
68
|
+
ActionContextSchema.parse({
|
|
69
|
+
agentId: 'agent-1',
|
|
70
|
+
scope: { kind: 'project', projectId: 'demo' },
|
|
71
|
+
citedMemoryIds: recall.atoms.map((atom) => atom.memoryId),
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
console.log(proposalResult.decision.outcome, recall.decision.outcome, action.decision.outcome);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Every call returns a structured decision. Memory text, receipts, model prose, confidence, and consensus never grant permission by themselves.
|
|
79
|
+
|
|
80
|
+
## What this package does
|
|
81
|
+
|
|
82
|
+
- **Domain schemas and types**: `HumanReadableReceipt`, `CompressedReceipt`, `MemoryAtom`, `MemoryProposal`, `ActionContextPacket`, `CoverageReceipt`, `ConflictRecord`, `Decision`, and discriminated unions for status/scope/visibility.
|
|
83
|
+
- **Storage interfaces**: `EventLedger`, `MemoryStore`, and `ConflictRegistry`. Implementations live in other packages.
|
|
84
|
+
- **WriteGate**: validates source events, scope, visibility, risk, and conflict boundaries before memory insertion.
|
|
85
|
+
- **Proposal safety guard**: deterministic checks for credential-like claims, permission-bypass policies, and destructive durable instructions before a proposal can become actionable memory.
|
|
86
|
+
- **RetrievalRouter**: non-semantic recall by visibility, scope, status, type, freshness, optional receipt-derived authority scoring, and conflict state.
|
|
87
|
+
- **ActionAuthorizer**: receiver-side `tryAct()` guard. Sensitive actions always ask human.
|
|
88
|
+
- **AletheiaAuthority**: small facade exposing `propose()`, `recall()`, and `tryAct()`.
|
|
89
|
+
|
|
90
|
+
## Proposal Safety Guard
|
|
91
|
+
|
|
92
|
+
`WriteGate` calls `evaluateProposalSafety()` after visibility/source/scope checks
|
|
93
|
+
and before insertion. The guard can only deny or escalate; it never grants
|
|
94
|
+
authority. Current deterministic canaries cover:
|
|
95
|
+
|
|
96
|
+
- long `sk-...` provider-style tokens, AWS access keys, GitHub tokens, JWT-like compact tokens, PEM private-key headers, and explicit `api_key`/`secret`/`token`/`password` assignments;
|
|
97
|
+
- durable policies that try to bypass receiver-side permission checks;
|
|
98
|
+
- destructive runtime instructions such as deleting repositories or databases.
|
|
99
|
+
|
|
100
|
+
This is not a general DLP system or proof that arbitrary secrets cannot appear
|
|
101
|
+
in source events. It prevents matching proposal claims from becoming actionable
|
|
102
|
+
MemoryAtoms. Hosts that ingest sensitive raw conversations should still redact
|
|
103
|
+
or scope those source events appropriately.
|
|
104
|
+
|
|
105
|
+
## Fail-closed examples
|
|
106
|
+
|
|
107
|
+
- No permitted visibility -> `deny` or `fetch_abstain`.
|
|
108
|
+
- Missing source event -> `deny`.
|
|
109
|
+
- Candidate memory cited for action -> `fetch_abstain`.
|
|
110
|
+
- Sealed or human-required memory -> `ask_human`.
|
|
111
|
+
- Sensitive action (`external_send`, `delete`, `publication`, etc.) -> `ask_human`.
|
|
112
|
+
- Unresolved conflict touching cited memory -> `conflict_boundary_packet`.
|
|
113
|
+
|
|
114
|
+
## What this package does NOT do
|
|
115
|
+
|
|
116
|
+
- No embeddings, vector store, semantic retrieval, or semantic ranking.
|
|
117
|
+
- Optional authority scoring is receipt-derived and runs only after hard visibility/scope/status/freshness filters.
|
|
118
|
+
- No LLM SDK dependency. Use `@aletheia-labs/adapters-anthropic`, `@aletheia-labs/adapters-openai`, or your own adapter.
|
|
119
|
+
- No OAuth, CLI, MCP server, daemon, watcher, or terminal UX.
|
|
120
|
+
- No authorization service. Aletheia classifies memory authority; your host still owns real-world permissions.
|
|
121
|
+
- No automatic promotion to `trusted`.
|
|
122
|
+
|
|
123
|
+
## Stability
|
|
124
|
+
|
|
125
|
+
Public surface for the initial library cycle:
|
|
126
|
+
|
|
127
|
+
- `AletheiaAuthority`
|
|
128
|
+
- `WriteGate`, `RetrievalRouter`, `ActionAuthorizer` from `@aletheia-labs/core/runtime`
|
|
129
|
+
- storage interfaces exported from `@aletheia-labs/core`
|
|
130
|
+
- zod schemas and inferred types from `@aletheia-labs/core` or `@aletheia-labs/core/types`
|
|
131
|
+
- decision outcomes and reason shapes
|
|
132
|
+
|
|
133
|
+
In the `0.x` line, breaking changes are possible but semver-relevant: changes to `propose()`, `recall()`, `tryAct()`, exported schemas, storage interfaces, or decision unions should ship with an explicit version bump and migration notes.
|
|
134
|
+
|
|
135
|
+
Schema changes matter operationally: changing `MemoryAtomSchema` or receipt schemas can affect persisted stores and should be paired with migration/replay guidance.
|
|
136
|
+
|
|
137
|
+
## Development
|
|
138
|
+
|
|
139
|
+
From the repo root:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
pnpm install
|
|
143
|
+
pnpm -F @aletheia-labs/core typecheck
|
|
144
|
+
pnpm -F @aletheia-labs/core test
|
|
145
|
+
pnpm -F @aletheia-labs/core build
|
|
146
|
+
pnpm -F @aletheia-labs/core smoke:e2e
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Publish dry-run:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
pnpm -F @aletheia-labs/core publish --dry-run --no-git-checks
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Specs
|
|
156
|
+
|
|
157
|
+
This package implements:
|
|
158
|
+
|
|
159
|
+
- `specs/aletheia-memory-authority-v0.md` — system architecture.
|
|
160
|
+
- `specs/memory-authority-receipt-v0.md` — receipt contract.
|
|
161
|
+
- `specs/compressed-temporal-receipt-v0.md` — compressed-temporal-receipt format.
|
|
162
|
+
|
|
163
|
+
Where the spec is ambiguous, fix the spec first.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aletheia-labs/core
|
|
3
|
+
*
|
|
4
|
+
* Memory as governance for LLM agents.
|
|
5
|
+
*
|
|
6
|
+
* Phase 1.5 — domain types, storage interfaces, WriteGate, RetrievalRouter,
|
|
7
|
+
* ActionAuthorizer, and AletheiaAuthority are live.
|
|
8
|
+
*
|
|
9
|
+
* Design maxim:
|
|
10
|
+
* "Do not build a memory that remembers more.
|
|
11
|
+
* Build a memory that knows when to distrust itself."
|
|
12
|
+
*/
|
|
13
|
+
export declare const PACKAGE_NAME = "@aletheia-labs/core";
|
|
14
|
+
export declare const PACKAGE_VERSION = "0.1.0";
|
|
15
|
+
export * from './types/index.js';
|
|
16
|
+
export * from './storage/index.js';
|
|
17
|
+
export * from './runtime/index.js';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,YAAY,wBAAwB,CAAC;AAClD,eAAO,MAAM,eAAe,UAAU,CAAC;AAGvC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aletheia-labs/core
|
|
3
|
+
*
|
|
4
|
+
* Memory as governance for LLM agents.
|
|
5
|
+
*
|
|
6
|
+
* Phase 1.5 — domain types, storage interfaces, WriteGate, RetrievalRouter,
|
|
7
|
+
* ActionAuthorizer, and AletheiaAuthority are live.
|
|
8
|
+
*
|
|
9
|
+
* Design maxim:
|
|
10
|
+
* "Do not build a memory that remembers more.
|
|
11
|
+
* Build a memory that knows when to distrust itself."
|
|
12
|
+
*/
|
|
13
|
+
export const PACKAGE_NAME = '@aletheia-labs/core';
|
|
14
|
+
export const PACKAGE_VERSION = '0.1.0';
|
|
15
|
+
// Domain types and schemas — the public protocol surface.
|
|
16
|
+
export * from './types/index.js';
|
|
17
|
+
// Storage interfaces — implementations live in adapter packages.
|
|
18
|
+
export * from './storage/index.js';
|
|
19
|
+
// Runtime governance components — host applications provide stores + policy.
|
|
20
|
+
export * from './runtime/index.js';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,qBAAqB,CAAC;AAClD,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AAEvC,0DAA0D;AAC1D,cAAc,kBAAkB,CAAC;AAEjC,iEAAiE;AACjE,cAAc,oBAAoB,CAAC;AAEnC,6EAA6E;AAC7E,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ActionAuthorizer — receiver-side `tryAct` guard.
|
|
3
|
+
*
|
|
4
|
+
* The Action Context Packet is not a permission token. This guard re-checks
|
|
5
|
+
* the cited atoms against visibility, scope, status, conflicts, and action
|
|
6
|
+
* sensitivity before allowing only local/shadow effects.
|
|
7
|
+
*/
|
|
8
|
+
import type { ConflictRegistry, MemoryStore } from '../storage/index.js';
|
|
9
|
+
import { type ActionContext, type ActionDecision, type ConflictRecord, type MemoryAtom, type ProposedAction } from '../types/index.js';
|
|
10
|
+
import type { Clock } from './decision-helpers.js';
|
|
11
|
+
import { type VisibilityPolicy } from './visibility-policy.js';
|
|
12
|
+
export interface ActionAuthorizerOptions {
|
|
13
|
+
readonly memoryStore: MemoryStore;
|
|
14
|
+
readonly conflictRegistry: ConflictRegistry;
|
|
15
|
+
readonly visibilityPolicy?: VisibilityPolicy;
|
|
16
|
+
readonly clock?: Clock;
|
|
17
|
+
}
|
|
18
|
+
export interface ActionAuthorizationResult {
|
|
19
|
+
readonly decision: ActionDecision;
|
|
20
|
+
readonly citedAtoms: readonly MemoryAtom[];
|
|
21
|
+
readonly conflicts: readonly ConflictRecord[];
|
|
22
|
+
}
|
|
23
|
+
export declare class ActionAuthorizer {
|
|
24
|
+
private readonly options;
|
|
25
|
+
private readonly visibilityPolicy;
|
|
26
|
+
private readonly clock;
|
|
27
|
+
/**
|
|
28
|
+
* Create a receiver-side action guard.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Hosts provide the same memory/conflict stores used for recall plus a
|
|
32
|
+
* visibility policy. The guard has no knowledge of provider tokens, tools,
|
|
33
|
+
* or real-world permissions.
|
|
34
|
+
*/
|
|
35
|
+
constructor(options: ActionAuthorizerOptions);
|
|
36
|
+
/**
|
|
37
|
+
* Decide whether a proposed action may use cited memory as authority.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* Use this after recall and before executing any effect. The implementation
|
|
41
|
+
* parses the action/context, asks human for sensitive actions, denies unknown
|
|
42
|
+
* non-local effects, reloads cited atoms with visibility filtering, checks
|
|
43
|
+
* scope/freshness/status, and blocks unresolved conflicts.
|
|
44
|
+
*/
|
|
45
|
+
tryAct(action: ProposedAction, context: ActionContext): Promise<ActionAuthorizationResult>;
|
|
46
|
+
private loadCitedAtoms;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=action-authorizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-authorizer.d.ts","sourceRoot":"","sources":["../../src/runtime/action-authorizer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,cAAc,EACnB,KAAK,cAAc,EAEnB,KAAK,UAAU,EAEf,KAAK,cAAc,EAMpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAA8B,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE3F,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAC7C,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;CACxB;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,SAAS,UAAU,EAAE,CAAC;IAC3C,QAAQ,CAAC,SAAS,EAAE,SAAS,cAAc,EAAE,CAAC;CAC/C;AAED,qBAAa,gBAAgB;IAYf,OAAO,CAAC,QAAQ,CAAC,OAAO;IAXpC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;IACpD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAE9B;;;;;;;OAOG;gBAC0B,OAAO,EAAE,uBAAuB;IAK7D;;;;;;;;OAQG;IACG,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,yBAAyB,CAAC;YAuOlF,cAAc;CAS7B"}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ActionAuthorizer — receiver-side `tryAct` guard.
|
|
3
|
+
*
|
|
4
|
+
* The Action Context Packet is not a permission token. This guard re-checks
|
|
5
|
+
* the cited atoms against visibility, scope, status, conflicts, and action
|
|
6
|
+
* sensitivity before allowing only local/shadow effects.
|
|
7
|
+
*/
|
|
8
|
+
import { ActionContextSchema, ProposedActionSchema, SAFE_LOCAL_ACTIONS, SENSITIVE_ACTIONS, scopeKey, } from '../types/index.js';
|
|
9
|
+
import { SYSTEM_CLOCK, decision } from './decision-helpers.js';
|
|
10
|
+
import { sameScope } from './scope-helpers.js';
|
|
11
|
+
import { DENY_ALL_VISIBILITY_POLICY } from './visibility-policy.js';
|
|
12
|
+
export class ActionAuthorizer {
|
|
13
|
+
options;
|
|
14
|
+
visibilityPolicy;
|
|
15
|
+
clock;
|
|
16
|
+
/**
|
|
17
|
+
* Create a receiver-side action guard.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Hosts provide the same memory/conflict stores used for recall plus a
|
|
21
|
+
* visibility policy. The guard has no knowledge of provider tokens, tools,
|
|
22
|
+
* or real-world permissions.
|
|
23
|
+
*/
|
|
24
|
+
constructor(options) {
|
|
25
|
+
this.options = options;
|
|
26
|
+
this.visibilityPolicy = options.visibilityPolicy ?? DENY_ALL_VISIBILITY_POLICY;
|
|
27
|
+
this.clock = options.clock ?? SYSTEM_CLOCK;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Decide whether a proposed action may use cited memory as authority.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Use this after recall and before executing any effect. The implementation
|
|
34
|
+
* parses the action/context, asks human for sensitive actions, denies unknown
|
|
35
|
+
* non-local effects, reloads cited atoms with visibility filtering, checks
|
|
36
|
+
* scope/freshness/status, and blocks unresolved conflicts.
|
|
37
|
+
*/
|
|
38
|
+
async tryAct(action, context) {
|
|
39
|
+
const emittedAt = this.clock.now();
|
|
40
|
+
const contextResult = ActionContextSchema.safeParse(context);
|
|
41
|
+
if (!contextResult.success) {
|
|
42
|
+
return {
|
|
43
|
+
decision: decision('fetch_abstain', [
|
|
44
|
+
{
|
|
45
|
+
kind: 'tuple_incomplete',
|
|
46
|
+
missingFields: schemaIssuePaths(contextResult.error.issues, 'context'),
|
|
47
|
+
},
|
|
48
|
+
], [], [], emittedAt),
|
|
49
|
+
citedAtoms: [],
|
|
50
|
+
conflicts: [],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const validContext = contextResult.data;
|
|
54
|
+
const actionResult = ProposedActionSchema.safeParse(action);
|
|
55
|
+
if (!actionResult.success) {
|
|
56
|
+
return {
|
|
57
|
+
decision: decision('ask_human', [{ kind: 'unknown_action', raw: 'invalid proposed action' }], validContext.citedMemoryIds, [], emittedAt),
|
|
58
|
+
citedAtoms: [],
|
|
59
|
+
conflicts: [],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const validAction = actionResult.data;
|
|
63
|
+
if (SENSITIVE_ACTIONS.has(validAction.classifiedAction)) {
|
|
64
|
+
return {
|
|
65
|
+
decision: decision('ask_human', [
|
|
66
|
+
{
|
|
67
|
+
kind: 'sensitive_action',
|
|
68
|
+
actionClass: validAction.classifiedAction,
|
|
69
|
+
},
|
|
70
|
+
], validContext.citedMemoryIds, [], emittedAt),
|
|
71
|
+
citedAtoms: [],
|
|
72
|
+
conflicts: [],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (!SAFE_LOCAL_ACTIONS.has(validAction.classifiedAction)) {
|
|
76
|
+
return {
|
|
77
|
+
decision: decision('deny', [
|
|
78
|
+
{
|
|
79
|
+
kind: 'forbidden_effect_present',
|
|
80
|
+
effect: validAction.classifiedAction,
|
|
81
|
+
},
|
|
82
|
+
], validContext.citedMemoryIds, [], emittedAt),
|
|
83
|
+
citedAtoms: [],
|
|
84
|
+
conflicts: [],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (validContext.citedMemoryIds.length === 0) {
|
|
88
|
+
return {
|
|
89
|
+
decision: decision('fetch_abstain', [{ kind: 'tuple_incomplete', missingFields: ['citedMemoryIds'] }], [], [], emittedAt),
|
|
90
|
+
citedAtoms: [],
|
|
91
|
+
conflicts: [],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const permitted = this.visibilityPolicy.permittedVisibilitiesForAgent(validContext.agentId);
|
|
95
|
+
if (permitted.length === 0) {
|
|
96
|
+
return {
|
|
97
|
+
decision: decision('deny', [
|
|
98
|
+
{
|
|
99
|
+
kind: 'visibility_denied',
|
|
100
|
+
detail: 'actor has no permitted visibility planes',
|
|
101
|
+
},
|
|
102
|
+
], validContext.citedMemoryIds, [], emittedAt),
|
|
103
|
+
citedAtoms: [],
|
|
104
|
+
conflicts: [],
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const atoms = await this.loadCitedAtoms(validContext.citedMemoryIds, permitted);
|
|
108
|
+
if (atoms.length !== validContext.citedMemoryIds.length) {
|
|
109
|
+
return {
|
|
110
|
+
decision: decision('fetch_abstain', [
|
|
111
|
+
{
|
|
112
|
+
kind: 'source_check_failed',
|
|
113
|
+
detail: 'one or more cited memories are missing or not visible',
|
|
114
|
+
},
|
|
115
|
+
], validContext.citedMemoryIds, [], emittedAt),
|
|
116
|
+
citedAtoms: atoms,
|
|
117
|
+
conflicts: [],
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const outOfScope = atoms.find((atom) => !sameScope(atom.scope, validContext.scope));
|
|
121
|
+
if (outOfScope !== undefined) {
|
|
122
|
+
return {
|
|
123
|
+
decision: decision('block_local', [
|
|
124
|
+
{
|
|
125
|
+
kind: 'scope_outside_boundary',
|
|
126
|
+
requestedScope: scopeKey(validContext.scope),
|
|
127
|
+
allowedScope: scopeKey(outOfScope.scope),
|
|
128
|
+
},
|
|
129
|
+
], validContext.citedMemoryIds, [], emittedAt),
|
|
130
|
+
citedAtoms: atoms,
|
|
131
|
+
conflicts: [],
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
const invalidAt = atoms.find((atom) => !atomIsValidAt(atom, emittedAt));
|
|
135
|
+
if (invalidAt !== undefined) {
|
|
136
|
+
return {
|
|
137
|
+
decision: decision('fetch_abstain', [
|
|
138
|
+
{
|
|
139
|
+
kind: 'freshness_not_current',
|
|
140
|
+
observed: `memory ${invalidAt.memoryId} is not valid at ${emittedAt}`,
|
|
141
|
+
},
|
|
142
|
+
], validContext.citedMemoryIds, [], emittedAt),
|
|
143
|
+
citedAtoms: atoms,
|
|
144
|
+
conflicts: [],
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
const statusReason = firstUnsafeStatusReason(atoms);
|
|
148
|
+
if (statusReason !== null) {
|
|
149
|
+
return {
|
|
150
|
+
decision: decision(statusReason.outcome, [statusReason.reason], validContext.citedMemoryIds, [], emittedAt),
|
|
151
|
+
citedAtoms: atoms,
|
|
152
|
+
conflicts: [],
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const conflicts = await this.options.conflictRegistry.query({
|
|
156
|
+
touchingMemoryIds: validContext.citedMemoryIds,
|
|
157
|
+
statuses: ['unresolved', 'requires_human'],
|
|
158
|
+
scope: validContext.scope,
|
|
159
|
+
permittedVisibilities: permitted,
|
|
160
|
+
});
|
|
161
|
+
if (conflicts.length > 0) {
|
|
162
|
+
return {
|
|
163
|
+
decision: decision('conflict_boundary_packet', conflicts.map((conflict) => ({
|
|
164
|
+
kind: 'unresolved_conflict',
|
|
165
|
+
conflictId: conflict.conflictId,
|
|
166
|
+
})), validContext.citedMemoryIds, conflicts.map((conflict) => conflict.conflictId), emittedAt),
|
|
167
|
+
citedAtoms: atoms,
|
|
168
|
+
conflicts,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
decision: decision('allow_local_shadow', [
|
|
173
|
+
{
|
|
174
|
+
kind: 'all_checks_passed',
|
|
175
|
+
citedMemoryIds: validContext.citedMemoryIds,
|
|
176
|
+
},
|
|
177
|
+
], validContext.citedMemoryIds, [], emittedAt),
|
|
178
|
+
citedAtoms: atoms,
|
|
179
|
+
conflicts,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
async loadCitedAtoms(memoryIds, permitted) {
|
|
183
|
+
const atoms = await Promise.all(memoryIds.map((memoryId) => this.options.memoryStore.get(memoryId, permitted)));
|
|
184
|
+
return atoms.filter((atom) => atom !== null);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function firstUnsafeStatusReason(atoms) {
|
|
188
|
+
const humanRequired = atoms.find((atom) => atom.status === 'human_required' || atom.status === 'sealed');
|
|
189
|
+
if (humanRequired !== undefined) {
|
|
190
|
+
return {
|
|
191
|
+
outcome: 'ask_human',
|
|
192
|
+
reason: {
|
|
193
|
+
kind: 'promotion_boundary_blocked',
|
|
194
|
+
detail: `memory ${humanRequired.memoryId} requires human or sealed handling`,
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
const rejected = atoms.find((atom) => atom.status === 'rejected' || atom.status === 'deprecated');
|
|
199
|
+
if (rejected !== undefined) {
|
|
200
|
+
return {
|
|
201
|
+
outcome: 'deny',
|
|
202
|
+
reason: {
|
|
203
|
+
kind: 'promotion_boundary_blocked',
|
|
204
|
+
detail: `memory ${rejected.memoryId} is ${rejected.status}`,
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
const candidate = atoms.find((atom) => atom.status === 'candidate');
|
|
209
|
+
if (candidate !== undefined) {
|
|
210
|
+
return {
|
|
211
|
+
outcome: 'fetch_abstain',
|
|
212
|
+
reason: {
|
|
213
|
+
kind: 'tuple_incomplete',
|
|
214
|
+
missingFields: [`verifiedAuthority:${candidate.memoryId}`],
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
function atomIsValidAt(atom, at) {
|
|
221
|
+
if (atom.validFrom > at)
|
|
222
|
+
return false;
|
|
223
|
+
if (atom.validUntil !== null && atom.validUntil < at)
|
|
224
|
+
return false;
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
function schemaIssuePaths(issues, fallback) {
|
|
228
|
+
const paths = issues.map((issue) => issue.path.length > 0 ? issue.path.map(String).join('.') : fallback);
|
|
229
|
+
return paths.length > 0 ? paths : [fallback];
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=action-authorizer.js.map
|