@atlasauth/pca-rag 0.1.0 → 0.2.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 +21 -0
- package/README.md +55 -0
- package/package.json +28 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Atlas Authorization
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# @atlasauth/pca-rag
|
|
2
|
+
|
|
3
|
+
Fine-grained authorization for RAG, built on Proof-Carrying Authority (PCA). At retrieval time it filters candidate documents down to the ones a given principal may see, deciding each one with the PCA policy engine. Every filtering decision is recorded with a content-addressed digest, so you can show the model was handed only authorized data.
|
|
4
|
+
|
|
5
|
+
- Documents carry ACL metadata: a `{ relation, object }` entry, or `relation:object` tag strings.
|
|
6
|
+
- Policy is either raw PCA predicates or an OpenFGA / Zanzibar model plus tuples (compiled through `@atlasauth/pca-policy-bridge`, including relation closures such as "viewer from parent").
|
|
7
|
+
- **Fails closed**: a document is admitted only when a permit predicate matches and no deny matches. No ACL, an unresolved relation, a malformed document, or an incomplete policy translation drops the document.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm i @atlasauth/pca-rag
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Depends on `@atlasauth/pca` and `@atlasauth/pca-policy-bridge`.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { filterDocuments, withPcaFilter } from '@atlasauth/pca-rag';
|
|
21
|
+
|
|
22
|
+
const policy = { openfga: { model, tuples } }; // OpenFGA authorization model + relationship tuples
|
|
23
|
+
|
|
24
|
+
const candidates = [
|
|
25
|
+
{ id: 'readme', text: '...', acl: { relation: 'can_view', object: 'document:readme' } },
|
|
26
|
+
{ id: 'spec', text: '...', tags: ['can_view:document:spec'] },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const { documents, decision } = filterDocuments('user:alice', candidates, policy);
|
|
30
|
+
decision.allowedIds; // ids the model may see
|
|
31
|
+
decision.droppedIds; // ids dropped, with a reason per document in decision.decisions
|
|
32
|
+
decision.digest; // b64u commitment to the decision set, bindable into a receipt or proof
|
|
33
|
+
|
|
34
|
+
// Or wrap any retriever so results are filtered before they reach the model:
|
|
35
|
+
const safe = withPcaFilter(retriever, 'user:alice', policy); // retriever.retrieve(query, k)
|
|
36
|
+
const docs = await safe.retrieve('how do I deploy?');
|
|
37
|
+
safe.lastDecision(); // audit trail for the last call
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Compile once with `compilePolicy(policy)` and reuse the result to avoid recompiling per call. To derive the principal from a verified PCActn, use `principalFromPCActn(pcactn, { id })`.
|
|
41
|
+
|
|
42
|
+
## API
|
|
43
|
+
|
|
44
|
+
- `filterDocuments(principal, candidates, policy, opts?)` returns `{ documents, decision }`
|
|
45
|
+
- `withPcaFilter(retriever, principal, policy, opts?)` generic retriever wrapper
|
|
46
|
+
- `withLangChainPcaFilter(...)`, `withLlamaIndexPcaFilter(...)` structural adapters for LangChain and LlamaIndex retrievers (no dependency on either library)
|
|
47
|
+
- `compilePolicy`, `aclsFromMetadata`, `principalFromPCActn`
|
|
48
|
+
|
|
49
|
+
## Status
|
|
50
|
+
|
|
51
|
+
Part of [Proof-Carrying Authority](https://github.com/Atlas-Authorization/pca). This filters retrieval results; it does not control what a model does with documents it is allowed to see. PCA's cryptography has not been independently audited.
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
MIT - see LICENSE
|
package/package.json
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlasauth/pca-rag",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "FGA-for-RAG for PCA: retrieval-time, per-principal document filtering driven by the PCA policy engine, with the filtering decision captured in the proof trace (provable: the model only saw authorized data).",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"rag",
|
|
7
|
+
"retrieval",
|
|
8
|
+
"document filtering",
|
|
9
|
+
"fine-grained authorization",
|
|
10
|
+
"agent authorization",
|
|
11
|
+
"proof-carrying authority",
|
|
12
|
+
"pca",
|
|
13
|
+
"ai agents"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"homepage": "https://github.com/Atlas-Authorization/pca#readme",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/Atlas-Authorization/pca/issues"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/Atlas-Authorization/pca.git",
|
|
23
|
+
"directory": "packages/pca-rag"
|
|
24
|
+
},
|
|
5
25
|
"main": "./dist/index.js",
|
|
6
26
|
"types": "./dist/index.d.ts",
|
|
7
27
|
"exports": {
|
|
@@ -12,8 +32,8 @@
|
|
|
12
32
|
"./package.json": "./package.json"
|
|
13
33
|
},
|
|
14
34
|
"dependencies": {
|
|
15
|
-
"@atlasauth/pca": "0.
|
|
16
|
-
"@atlasauth/pca-policy-bridge": "0.
|
|
35
|
+
"@atlasauth/pca": "0.2.0",
|
|
36
|
+
"@atlasauth/pca-policy-bridge": "0.2.0"
|
|
17
37
|
},
|
|
18
38
|
"devDependencies": {
|
|
19
39
|
"typescript": "^5.6.3",
|
|
@@ -21,8 +41,12 @@
|
|
|
21
41
|
},
|
|
22
42
|
"files": [
|
|
23
43
|
"dist",
|
|
24
|
-
"README.md"
|
|
44
|
+
"README.md",
|
|
45
|
+
"LICENSE"
|
|
25
46
|
],
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=20"
|
|
49
|
+
},
|
|
26
50
|
"publishConfig": {
|
|
27
51
|
"access": "public"
|
|
28
52
|
},
|