Tenancy primitives for Flametrench: organizations, memberships, and atomic invitation acceptance with the mem_/tup_ duality.
Project description
flametrench-tenancy
Python SDK for the Flametrench tenancy specification: organizations, memberships (with the mem_/tup_ duality), and atomic invitation acceptance.
Status: v0.2.0 (stable). Includes the production-ready PostgresTenancyStore alongside the in-memory reference store. Per ADR 0013 the Postgres adapter cooperates with adopter-side outer transactions via savepoints when nested (psycopg3 connection.transaction() handles this automatically).
The same behavioral guarantees that gate @flametrench/tenancy (Node), flametrench/tenancy (PHP), and dev.flametrench:tenancy (Java) hold here:
- Revoke-and-re-add on role changes, with a
replaceschain for audit history. - Sole-owner protection on every path that could leave an org without an active owner (change_role, suspend_membership, self_leave).
- Atomic invitation acceptance — user creation, membership insertion, owner-role tuple, AND pre-tuple expansion all in one transition.
- Role hierarchy on
admin_remove— admins cannot remove peers or higher-ranked members. - mem_/tup_ duality — every active membership is shadowed by a corresponding
(usr, role, org)tuple, kept in lockstep withmem.status.
from datetime import datetime, timedelta, timezone
from flametrench_ids import generate
from flametrench_tenancy import InMemoryTenancyStore, PreTuple, Role
store = InMemoryTenancyStore()
alice = generate("usr")
result = store.create_org(alice)
print(result.org.id, result.owner_membership.role) # → org_..., Role.OWNER
# Invite a new user and pre-attach an editor grant on a project.
project_id = generate("org")[4:]
inv = store.create_invitation(
org_id=result.org.id,
identifier="newbie@example.com",
role=Role.MEMBER,
invited_by=alice,
expires_at=datetime.now(timezone.utc) + timedelta(days=7),
pre_tuples=[PreTuple(relation="editor", object_type="proj", object_id=project_id)],
)
out = store.accept_invitation(inv.id)
print(out.membership.role, out.materialized_tuples)
Installation
pip install flametrench-tenancy
Requires Python 3.11+. Depends on flametrench-ids for usr_/org_/mem_/inv_ id generation.
License
Apache-2.0. See LICENSE and NOTICE.
Copyright 2026 NDC Digital, LLC.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flametrench_tenancy-0.4.0.tar.gz.
File metadata
- Download URL: flametrench_tenancy-0.4.0.tar.gz
- Upload date:
- Size: 32.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1a76d097abf500e293fe61e5028de7249fbdb6a3eba985c7ba9cca9f52cd9ff
|
|
| MD5 |
92b2b9a50139ea4ef517909d9da68dab
|
|
| BLAKE2b-256 |
e03ddb1532f073945a1c85932c200c1b576a1564ef10d9e7d16c222d5a71c7cb
|
Provenance
The following attestation bundles were made for flametrench_tenancy-0.4.0.tar.gz:
Publisher:
publish.yml on flametrench/tenancy-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flametrench_tenancy-0.4.0.tar.gz -
Subject digest:
b1a76d097abf500e293fe61e5028de7249fbdb6a3eba985c7ba9cca9f52cd9ff - Sigstore transparency entry: 1749706060
- Sigstore integration time:
-
Permalink:
flametrench/tenancy-python@afe1081469c070cd5257c702dc5dce2f303f9502 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/flametrench
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@afe1081469c070cd5257c702dc5dce2f303f9502 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file flametrench_tenancy-0.4.0-py3-none-any.whl.
File metadata
- Download URL: flametrench_tenancy-0.4.0-py3-none-any.whl
- Upload date:
- Size: 27.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab84862b20a35e08951fd4c47520fe35b829d31317d449ff01286b033033b6b0
|
|
| MD5 |
bc71504b5df1b0d98d87d3eba46aa88a
|
|
| BLAKE2b-256 |
cc18f244c66e51c3ec0ac9b435cd52580fdc1f677fa4d0df73592c9b5a0f6c13
|
Provenance
The following attestation bundles were made for flametrench_tenancy-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on flametrench/tenancy-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flametrench_tenancy-0.4.0-py3-none-any.whl -
Subject digest:
ab84862b20a35e08951fd4c47520fe35b829d31317d449ff01286b033033b6b0 - Sigstore transparency entry: 1749706144
- Sigstore integration time:
-
Permalink:
flametrench/tenancy-python@afe1081469c070cd5257c702dc5dce2f303f9502 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/flametrench
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@afe1081469c070cd5257c702dc5dce2f303f9502 -
Trigger Event:
workflow_dispatch
-
Statement type: