trellisd 0.1.0__py3-none-any.whl
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.
- trellisd/__init__.py +37 -0
- trellisd/_examples/lakehouse/agents.yaml +9 -0
- trellisd/_examples/lakehouse/catalogs.yaml +12 -0
- trellisd/_examples/lakehouse/contracts/cash_positions.odcs.yaml +37 -0
- trellisd/_examples/lakehouse/contracts/finance.gl.yaml +25 -0
- trellisd/_examples/lakehouse/people.yaml +8 -0
- trellisd/_examples/three-keys/access.yaml +22 -0
- trellisd/_examples/three-keys/agents.yaml +17 -0
- trellisd/_examples/three-keys/catalog.yaml +30 -0
- trellisd/_examples/three-keys/identity.yaml +13 -0
- trellisd/_examples/three-keys/people.yaml +10 -0
- trellisd/_examples/three-keys/purposes.yaml +13 -0
- trellisd/app.py +630 -0
- trellisd/catalog.py +340 -0
- trellisd/cli.py +1346 -0
- trellisd/compiler.py +348 -0
- trellisd/config.py +460 -0
- trellisd/db.py +148 -0
- trellisd/demo_idp.py +313 -0
- trellisd/enforce.py +200 -0
- trellisd/engine.py +545 -0
- trellisd/export.py +155 -0
- trellisd/fake_iceberg.py +223 -0
- trellisd/fake_idp.py +230 -0
- trellisd/grants.py +243 -0
- trellisd/iceberg.py +335 -0
- trellisd/identity.py +321 -0
- trellisd/ledger.py +471 -0
- trellisd/mcp_middleware.py +110 -0
- trellisd/odcs.py +203 -0
- trellisd/py.typed +0 -0
- trellisd/server.py +284 -0
- trellisd/signing.py +80 -0
- trellisd/trace.py +182 -0
- trellisd-0.1.0.dist-info/METADATA +240 -0
- trellisd-0.1.0.dist-info/RECORD +39 -0
- trellisd-0.1.0.dist-info/WHEEL +4 -0
- trellisd-0.1.0.dist-info/entry_points.txt +2 -0
- trellisd-0.1.0.dist-info/licenses/LICENSE +202 -0
trellisd/__init__.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""Trellis: delegated access control and a tamper-evident audit ledger for AI agents.
|
|
2
|
+
|
|
3
|
+
The package, import and CLI name is ``trellisd``.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from trellisd.app import Trellis
|
|
7
|
+
from trellisd.catalog import Catalog, ConfigCatalog, TableInfo
|
|
8
|
+
from trellisd.config import ConfigError, TrellisConfig, load_config
|
|
9
|
+
from trellisd.db import Database
|
|
10
|
+
from trellisd.engine import CheckResult, Decision, Engine
|
|
11
|
+
from trellisd.grants import Grant, GrantError, GrantStore, IssuedGrant
|
|
12
|
+
from trellisd.ledger import Ledger, LedgerEvent, LedgerUnavailable, VerifyResult
|
|
13
|
+
|
|
14
|
+
__version__ = "0.1.0"
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"Catalog",
|
|
18
|
+
"CheckResult",
|
|
19
|
+
"ConfigCatalog",
|
|
20
|
+
"ConfigError",
|
|
21
|
+
"Database",
|
|
22
|
+
"Decision",
|
|
23
|
+
"Engine",
|
|
24
|
+
"Grant",
|
|
25
|
+
"GrantError",
|
|
26
|
+
"GrantStore",
|
|
27
|
+
"IssuedGrant",
|
|
28
|
+
"Ledger",
|
|
29
|
+
"LedgerEvent",
|
|
30
|
+
"LedgerUnavailable",
|
|
31
|
+
"TableInfo",
|
|
32
|
+
"Trellis",
|
|
33
|
+
"TrellisConfig",
|
|
34
|
+
"VerifyResult",
|
|
35
|
+
"__version__",
|
|
36
|
+
"load_config",
|
|
37
|
+
]
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Catalogs Trellis reads tags from. Read-only: Trellis never writes to them.
|
|
2
|
+
# `trellisd demo catalog-says-pii` points this at a local catalog it starts itself.
|
|
3
|
+
catalogs:
|
|
4
|
+
lakehouse:
|
|
5
|
+
type: iceberg-rest
|
|
6
|
+
uri: http://localhost:8181
|
|
7
|
+
namespaces: [finance]
|
|
8
|
+
ttl_seconds: 300 # a pushed change evicts sooner (Trellis.tags_changed)
|
|
9
|
+
stale_after_seconds: 900 # past this with the catalog down, every call is denied
|
|
10
|
+
|
|
11
|
+
# The ranked scale, lowest first. A resource keeps the highest level any source gives it.
|
|
12
|
+
levels: [public, internal, confidential, restricted]
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# An ODCS v3 contract, read through Trellis's ODCS adapter (no rewrite needed).
|
|
2
|
+
apiVersion: v3.0.2
|
|
3
|
+
kind: DataContract
|
|
4
|
+
id: treasury-cash-positions
|
|
5
|
+
name: Cash positions
|
|
6
|
+
version: 1.2.0
|
|
7
|
+
status: active
|
|
8
|
+
domain: treasury
|
|
9
|
+
team:
|
|
10
|
+
- username: treasury-owner@example.com
|
|
11
|
+
role: owner
|
|
12
|
+
servers:
|
|
13
|
+
- server: lakehouse
|
|
14
|
+
type: iceberg
|
|
15
|
+
schema: finance.treasury
|
|
16
|
+
tags: [finance]
|
|
17
|
+
schema:
|
|
18
|
+
- name: cash_positions
|
|
19
|
+
physicalName: cash_positions
|
|
20
|
+
logicalType: object
|
|
21
|
+
classification: confidential
|
|
22
|
+
properties:
|
|
23
|
+
- name: account
|
|
24
|
+
logicalType: string
|
|
25
|
+
tags: [pii]
|
|
26
|
+
- name: balance
|
|
27
|
+
logicalType: number
|
|
28
|
+
roles:
|
|
29
|
+
- role: treasury
|
|
30
|
+
access: read
|
|
31
|
+
customProperties:
|
|
32
|
+
- property: trellis.mask
|
|
33
|
+
value: [pii]
|
|
34
|
+
quality:
|
|
35
|
+
- type: library
|
|
36
|
+
rule: rowCount
|
|
37
|
+
mustBeGreaterThan: 0
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# The general ledger's contract, written by its owner. The source of truth for what the
|
|
2
|
+
# table is and who may read it; a catalog can add tags to it, never take them away.
|
|
3
|
+
contract: urn:contract:finance.gl
|
|
4
|
+
version: 3
|
|
5
|
+
kind: table
|
|
6
|
+
description: Posted journal entries, one row per line.
|
|
7
|
+
bindings:
|
|
8
|
+
- finance.gl.journal_entries
|
|
9
|
+
- mcp://ledger/journal_entries
|
|
10
|
+
owner: finance-owner@example.com
|
|
11
|
+
steward: finance-steward@example.com
|
|
12
|
+
tags: [finance, internal]
|
|
13
|
+
elements:
|
|
14
|
+
entry_id: []
|
|
15
|
+
amount: []
|
|
16
|
+
region: []
|
|
17
|
+
approver_email: []
|
|
18
|
+
purposes: [financial_close]
|
|
19
|
+
access:
|
|
20
|
+
analysts:
|
|
21
|
+
who: [group:finance-analysts]
|
|
22
|
+
actions: [read, query]
|
|
23
|
+
mask: [pii]
|
|
24
|
+
rows:
|
|
25
|
+
- "region = {person.region}"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# What people may read. Contracts add to this in M3.
|
|
2
|
+
access:
|
|
3
|
+
- id: finance-gl
|
|
4
|
+
description: Finance analysts read the general ledger for their own region, PII masked.
|
|
5
|
+
who: [group:finance-analysts]
|
|
6
|
+
resources: [finance.gl]
|
|
7
|
+
tags: [finance]
|
|
8
|
+
mask: [pii]
|
|
9
|
+
row_filter: "region = {person.region}"
|
|
10
|
+
- id: treasury
|
|
11
|
+
who: [group:treasury]
|
|
12
|
+
resources: [finance.treasury]
|
|
13
|
+
tags: [finance]
|
|
14
|
+
- id: ana-hr
|
|
15
|
+
description: Ana covers HR reporting this quarter.
|
|
16
|
+
who: [user:ana@example.com]
|
|
17
|
+
resources: [hr]
|
|
18
|
+
tags: [hr]
|
|
19
|
+
- id: quality
|
|
20
|
+
who: [group:quality]
|
|
21
|
+
resources: [quality]
|
|
22
|
+
tags: [quality]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Each agent's owner sets its ceiling: the most it may ever touch, whoever it works for.
|
|
2
|
+
agents:
|
|
3
|
+
report-bot:
|
|
4
|
+
owner: ana@example.com
|
|
5
|
+
description: Drafts finance reports.
|
|
6
|
+
identities: [local:report-bot] # the client it signs in as (see identity.yaml)
|
|
7
|
+
ceiling:
|
|
8
|
+
actions: [read, query]
|
|
9
|
+
tags: [finance, pii, hr]
|
|
10
|
+
never: [export_controlled]
|
|
11
|
+
inspector-bot:
|
|
12
|
+
owner: quality-lead@example.com
|
|
13
|
+
description: Reviews one inspection record when it is filed.
|
|
14
|
+
identities: [local:inspector-bot]
|
|
15
|
+
ceiling:
|
|
16
|
+
actions: [read]
|
|
17
|
+
tags: [quality]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Tables and their tags. M3 reads these from contracts and the Iceberg REST catalog.
|
|
2
|
+
catalog:
|
|
3
|
+
finance.gl.journal_entries:
|
|
4
|
+
tags: [finance]
|
|
5
|
+
columns:
|
|
6
|
+
entry_id: []
|
|
7
|
+
amount: []
|
|
8
|
+
region: []
|
|
9
|
+
approver_email: [pii]
|
|
10
|
+
finance.gl.export_ledger:
|
|
11
|
+
tags: [finance, export_controlled]
|
|
12
|
+
columns:
|
|
13
|
+
shipment_id: []
|
|
14
|
+
eccn: []
|
|
15
|
+
finance.treasury.cash_positions:
|
|
16
|
+
tags: [finance]
|
|
17
|
+
columns:
|
|
18
|
+
account: []
|
|
19
|
+
balance: []
|
|
20
|
+
hr.payroll:
|
|
21
|
+
tags: [hr, pii]
|
|
22
|
+
columns:
|
|
23
|
+
employee: []
|
|
24
|
+
salary: []
|
|
25
|
+
quality.inspections:
|
|
26
|
+
tags: [quality]
|
|
27
|
+
columns:
|
|
28
|
+
inspection_id: []
|
|
29
|
+
result: []
|
|
30
|
+
inspector_email: [pii]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Sign-in: the IdPs whose tokens Trellis accepts. Trellis brokers sign-in; it never holds
|
|
2
|
+
# passwords or creates users. A person is named by their email claim and must be under
|
|
3
|
+
# people; an agent signs in as a client listed in its identities (agents.yaml).
|
|
4
|
+
#
|
|
5
|
+
# This one is the Keycloak realm in examples/idp/keycloak (see demo/M4.md). Any OIDC IdP
|
|
6
|
+
# works the same way; for Entra, set exchange: entra-obo, and for Okta or Ping, rfc8693.
|
|
7
|
+
idps:
|
|
8
|
+
local:
|
|
9
|
+
issuer: http://localhost:8183/realms/trellis
|
|
10
|
+
audience: trellis
|
|
11
|
+
exchange: rfc8693 # how Trellis gets a downstream token for the person
|
|
12
|
+
client_id: trellis # Trellis's own client at the IdP
|
|
13
|
+
client_secret_env: TRELLIS_IDP_SECRET
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# The directory. In M4 an identity provider replaces this file.
|
|
2
|
+
people:
|
|
3
|
+
ana@example.com:
|
|
4
|
+
groups: [finance-analysts]
|
|
5
|
+
attributes: {region: emea}
|
|
6
|
+
tom@example.com:
|
|
7
|
+
groups: [treasury]
|
|
8
|
+
attributes: {region: amer}
|
|
9
|
+
quality-lead@example.com:
|
|
10
|
+
groups: [quality]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Purpose grants: standing scope for process agents, each with a named human owner.
|
|
2
|
+
purposes:
|
|
3
|
+
inspection-review:
|
|
4
|
+
owner: quality-lead@example.com
|
|
5
|
+
description: Review each inspection when it is filed.
|
|
6
|
+
agents: [inspector-bot]
|
|
7
|
+
actions: [read]
|
|
8
|
+
resources: [quality]
|
|
9
|
+
tags: [quality]
|
|
10
|
+
trigger:
|
|
11
|
+
type: inspection
|
|
12
|
+
tags: [quality]
|
|
13
|
+
row_filter: "inspection_id = {trigger.record}"
|