dpdpkit-core 0.1.0a1__tar.gz
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.
- dpdpkit_core-0.1.0a1/.gitattributes +3 -0
- dpdpkit_core-0.1.0a1/.github/dependabot.yml +8 -0
- dpdpkit_core-0.1.0a1/.github/workflows/ci.yml +48 -0
- dpdpkit_core-0.1.0a1/.github/workflows/release.yml +124 -0
- dpdpkit_core-0.1.0a1/.gitignore +14 -0
- dpdpkit_core-0.1.0a1/CHANGELOG.md +14 -0
- dpdpkit_core-0.1.0a1/CONTRIBUTING.md +27 -0
- dpdpkit_core-0.1.0a1/LICENSE +202 -0
- dpdpkit_core-0.1.0a1/PKG-INFO +125 -0
- dpdpkit_core-0.1.0a1/README.md +90 -0
- dpdpkit_core-0.1.0a1/SECURITY.md +21 -0
- dpdpkit_core-0.1.0a1/meta/README.md +14 -0
- dpdpkit_core-0.1.0a1/meta/pyproject.toml +24 -0
- dpdpkit_core-0.1.0a1/pyproject.toml +75 -0
- dpdpkit_core-0.1.0a1/scripts/bump-version.sh +10 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/__init__.py +82 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/_util.py +63 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/cli.py +212 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/config.py +135 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/consent.py +224 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/errors.py +76 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/events.py +184 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/export.py +226 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/kit.py +110 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/ledger.py +227 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/models.py +408 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/notices.py +155 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/notify.py +163 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/policy.py +166 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/py.typed +0 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/registry.py +113 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/repository.py +294 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/retention.py +581 -0
- dpdpkit_core-0.1.0a1/src/dpdpkit/rights.py +278 -0
- dpdpkit_core-0.1.0a1/tests/__init__.py +0 -0
- dpdpkit_core-0.1.0a1/tests/conftest.py +86 -0
- dpdpkit_core-0.1.0a1/tests/test_export_events_cli.py +114 -0
- dpdpkit_core-0.1.0a1/tests/test_ledger_consent.py +167 -0
- dpdpkit_core-0.1.0a1/tests/test_policy_registry_notices.py +94 -0
- dpdpkit_core-0.1.0a1/tests/test_retention.py +272 -0
- dpdpkit_core-0.1.0a1/tests/test_rights.py +106 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
env:
|
|
13
|
+
# Sibling repos are installed from main so a core PR is tested against unreleased policy packs.
|
|
14
|
+
SIBLINGS: >-
|
|
15
|
+
dpdpkit-policies @ git+https://github.com/dpdpkit-dev/dpdpkit-policies@main
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
test:
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
strategy:
|
|
21
|
+
fail-fast: false
|
|
22
|
+
matrix:
|
|
23
|
+
python: ["3.10", "3.11", "3.12", "3.13"]
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
- uses: astral-sh/setup-uv@v6
|
|
27
|
+
with:
|
|
28
|
+
python-version: ${{ matrix.python }}
|
|
29
|
+
- name: Install
|
|
30
|
+
run: |
|
|
31
|
+
uv venv
|
|
32
|
+
uv pip install "$SIBLINGS" -e ".[dev]"
|
|
33
|
+
echo "$PWD/.venv/bin" >> "$GITHUB_PATH"
|
|
34
|
+
- name: Lint
|
|
35
|
+
run: ruff check . && ruff format --check .
|
|
36
|
+
- name: Types (mypy --strict)
|
|
37
|
+
run: mypy
|
|
38
|
+
- name: Tests (unit, tamper, property)
|
|
39
|
+
run: pytest --cov --cov-report=xml
|
|
40
|
+
- name: Meta-package builds
|
|
41
|
+
run: uv build meta --out-dir dist-meta
|
|
42
|
+
|
|
43
|
+
audit:
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
steps:
|
|
46
|
+
- uses: actions/checkout@v4
|
|
47
|
+
- uses: astral-sh/setup-uv@v6
|
|
48
|
+
- run: uv venv && uv pip install "$SIBLINGS" -e . pip-audit && .venv/bin/pip-audit --skip-editable
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Release on tag vX.Y.Z. Builds dpdpkit-core and the dpdpkit meta-package at the same version.
|
|
2
|
+
# .devN tags go to TestPyPI; aN, bN, rcN and final tags go to PyPI via trusted publishing.
|
|
3
|
+
# Release-train order: policies (if changed) -> core -> adapters -> JS packages.
|
|
4
|
+
#
|
|
5
|
+
# PyPI trusted publishers (one per project; PyPI rejects two pending publishers with identical settings):
|
|
6
|
+
# dpdpkit-core : repo dpdpkit-dev/dpdpkit-core, workflow release.yml, environment pypi
|
|
7
|
+
# dpdpkit : repo dpdpkit-dev/dpdpkit-core, workflow release.yml, environment pypi-meta
|
|
8
|
+
# (TestPyPI: the same with environments testpypi / testpypi-meta.)
|
|
9
|
+
name: Release
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
push:
|
|
13
|
+
tags: ["v*"]
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
build:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
outputs:
|
|
22
|
+
version: ${{ steps.v.outputs.version }}
|
|
23
|
+
prerelease: ${{ steps.v.outputs.prerelease }}
|
|
24
|
+
target: ${{ steps.v.outputs.target }}
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
- uses: astral-sh/setup-uv@v6
|
|
28
|
+
- id: v
|
|
29
|
+
run: |
|
|
30
|
+
version="${GITHUB_REF_NAME#v}"
|
|
31
|
+
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
32
|
+
if [[ "$version" =~ (a|b|rc|dev)[0-9]*$ ]]; then echo "prerelease=true"; else echo "prerelease=false"; fi >> "$GITHUB_OUTPUT"
|
|
33
|
+
# .devN builds rehearse on TestPyPI; alphas, betas, release candidates and finals go to PyPI.
|
|
34
|
+
if [[ "$version" == *dev* ]]; then echo "target=testpypi"; else echo "target=pypi"; fi >> "$GITHUB_OUTPUT"
|
|
35
|
+
- name: Test against published dependencies
|
|
36
|
+
run: |
|
|
37
|
+
uv venv
|
|
38
|
+
# dpdpkit-policies may have been released moments ago; give PyPI up to ~10 minutes.
|
|
39
|
+
for attempt in $(seq 1 20); do
|
|
40
|
+
uv pip install --refresh -e ".[dev]" ${{ steps.v.outputs.target == 'testpypi' && '--prerelease=allow --index https://test.pypi.org/simple/ --index-strategy unsafe-best-match' || '' }} && break
|
|
41
|
+
if [ "$attempt" = 20 ]; then echo "dependencies not available on the index"; exit 1; fi
|
|
42
|
+
echo "dependencies not on the index yet; retrying in 30s ($attempt/20)"; sleep 30
|
|
43
|
+
done
|
|
44
|
+
.venv/bin/pytest -q
|
|
45
|
+
- name: Build core and meta
|
|
46
|
+
run: |
|
|
47
|
+
uv build --out-dir dist/core
|
|
48
|
+
uv build meta --out-dir dist/meta
|
|
49
|
+
- name: Tag must match both package versions
|
|
50
|
+
run: |
|
|
51
|
+
ls dist/core/dpdpkit_core-${{ steps.v.outputs.version }}-*.whl
|
|
52
|
+
ls dist/meta/dpdpkit-${{ steps.v.outputs.version }}-*.whl
|
|
53
|
+
- name: SBOM
|
|
54
|
+
uses: anchore/sbom-action@v0
|
|
55
|
+
with:
|
|
56
|
+
path: .
|
|
57
|
+
format: spdx-json
|
|
58
|
+
output-file: sbom.spdx.json
|
|
59
|
+
upload-artifact: false
|
|
60
|
+
- uses: actions/upload-artifact@v4
|
|
61
|
+
with:
|
|
62
|
+
name: dist-core
|
|
63
|
+
path: dist/core/
|
|
64
|
+
- uses: actions/upload-artifact@v4
|
|
65
|
+
with:
|
|
66
|
+
name: dist-meta
|
|
67
|
+
path: dist/meta/
|
|
68
|
+
- uses: actions/upload-artifact@v4
|
|
69
|
+
with:
|
|
70
|
+
name: sbom
|
|
71
|
+
path: sbom.spdx.json
|
|
72
|
+
|
|
73
|
+
publish-core:
|
|
74
|
+
needs: build
|
|
75
|
+
runs-on: ubuntu-latest
|
|
76
|
+
environment: ${{ needs.build.outputs.target }}
|
|
77
|
+
permissions:
|
|
78
|
+
id-token: write
|
|
79
|
+
attestations: write
|
|
80
|
+
steps:
|
|
81
|
+
- uses: actions/download-artifact@v4
|
|
82
|
+
with: { name: dist-core, path: dist }
|
|
83
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
84
|
+
with:
|
|
85
|
+
repository-url: ${{ needs.build.outputs.target == 'testpypi' && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}
|
|
86
|
+
|
|
87
|
+
# The meta-package pins dpdpkit-core==X.Y.Z, so it is uploaded only after core is on the index.
|
|
88
|
+
publish-meta:
|
|
89
|
+
needs: [build, publish-core]
|
|
90
|
+
runs-on: ubuntu-latest
|
|
91
|
+
environment: ${{ needs.build.outputs.target }}-meta
|
|
92
|
+
permissions:
|
|
93
|
+
id-token: write
|
|
94
|
+
attestations: write
|
|
95
|
+
steps:
|
|
96
|
+
- uses: actions/download-artifact@v4
|
|
97
|
+
with: { name: dist-meta, path: dist }
|
|
98
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
99
|
+
with:
|
|
100
|
+
repository-url: ${{ needs.build.outputs.target == 'testpypi' && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}
|
|
101
|
+
|
|
102
|
+
github-release:
|
|
103
|
+
needs: [build, publish-core, publish-meta]
|
|
104
|
+
runs-on: ubuntu-latest
|
|
105
|
+
permissions:
|
|
106
|
+
contents: write
|
|
107
|
+
steps:
|
|
108
|
+
- uses: actions/checkout@v4
|
|
109
|
+
- uses: actions/download-artifact@v4
|
|
110
|
+
with: { path: artifacts }
|
|
111
|
+
- name: Release notes from CHANGELOG.md
|
|
112
|
+
run: |
|
|
113
|
+
awk -v v="${{ needs.build.outputs.version }}" '
|
|
114
|
+
$0 ~ "^## " { if (found) exit; if (index($0, v)) { found=1; next } }
|
|
115
|
+
found { print }' CHANGELOG.md > notes.md
|
|
116
|
+
test -s notes.md || echo "See CHANGELOG.md" > notes.md
|
|
117
|
+
- uses: softprops/action-gh-release@v2
|
|
118
|
+
with:
|
|
119
|
+
body_path: notes.md
|
|
120
|
+
prerelease: ${{ needs.build.outputs.prerelease == 'true' }}
|
|
121
|
+
files: |
|
|
122
|
+
artifacts/dist-core/*
|
|
123
|
+
artifacts/dist-meta/*
|
|
124
|
+
artifacts/sbom/sbom.spdx.json
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All code packages in the dpdpkit release train share one version number.
|
|
4
|
+
|
|
5
|
+
## Unreleased
|
|
6
|
+
|
|
7
|
+
## 0.1.0a1 - 2026-09-27
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- `Kit` facade; policy, registry, notices, ledger, consent, rights, retention, events, notify, export modules.
|
|
11
|
+
- Hash-chained consent ledger and audit trail with `verify()`, `verify_report()`, `root_hash()` and `check_root()`.
|
|
12
|
+
- `InMemoryRepository` and the `Repository` protocol for adapters.
|
|
13
|
+
- CLI: `init`, `policy show|list|diff`, `ledger verify|root`, `retention preview|run`, `export`.
|
|
14
|
+
- `dpdpkit` meta-package with the `fastapi` extra.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for helping. A few rules keep dpdpkit trustworthy:
|
|
4
|
+
|
|
5
|
+
1. **Primitives, not promises.** Code, docs and messages never claim that using dpdpkit makes anyone compliant.
|
|
6
|
+
2. **Rules as data.** Every legal number (deadlines, thresholds, ages) comes from a policy pack in
|
|
7
|
+
`dpdpkit-policies`. Do not hard-code them.
|
|
8
|
+
3. **Fail safe.** When delivery or a job fails, hold and alert. Never delete or file anything automatically
|
|
9
|
+
on failure.
|
|
10
|
+
4. **One contract.** HTTP behaviour must match `openapi.yaml` in `dpdpkit-spec`; the conformance suite is the judge.
|
|
11
|
+
5. **Customer data stays put.** No network calls home. Telemetry is opt-in only.
|
|
12
|
+
|
|
13
|
+
## Developer Certificate of Origin
|
|
14
|
+
|
|
15
|
+
Every commit must be signed off (`git commit -s`), certifying the [DCO](https://developercertificate.org/).
|
|
16
|
+
|
|
17
|
+
## Workflow
|
|
18
|
+
|
|
19
|
+
- Open an issue first for anything larger than a bug fix.
|
|
20
|
+
- Rule changes use the `rule-change` label and must link the official notification.
|
|
21
|
+
- Add a `CHANGELOG.md` entry under "Unreleased".
|
|
22
|
+
- CI must pass (lint, types, tests, conformance where applicable).
|
|
23
|
+
|
|
24
|
+
## Multi-repo development
|
|
25
|
+
|
|
26
|
+
dpdpkit is split across several repositories. Clone them side by side and run
|
|
27
|
+
`scripts/dev-setup.sh` from the workspace to get one virtualenv with every package installed in editable mode.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: dpdpkit-core
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Rules engine, consent ledger, rights, retention and CLI for India's DPDP Act and Rules.
|
|
5
|
+
Project-URL: Homepage, https://github.com/dpdpkit-dev/dpdpkit-core
|
|
6
|
+
Project-URL: Documentation, https://dpdpkit.dev
|
|
7
|
+
Project-URL: Changelog, https://github.com/dpdpkit-dev/dpdpkit-core/blob/main/CHANGELOG.md
|
|
8
|
+
Project-URL: Issues, https://github.com/dpdpkit-dev/dpdpkit-core/issues
|
|
9
|
+
Author: dpdpkit maintainers
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: consent,data-protection,dpdp,gdpr,india,privacy
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Security
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: dpdpkit-policies>=2026.10.0a1
|
|
25
|
+
Requires-Dist: pydantic<3,>=2.6
|
|
26
|
+
Requires-Dist: pyyaml>=6.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: hypothesis>=6.100; extra == 'dev'
|
|
29
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest-cov>=5; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
32
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
33
|
+
Requires-Dist: types-pyyaml; extra == 'dev'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# dpdpkit-core
|
|
37
|
+
|
|
38
|
+
The rules engine behind [dpdpkit](https://github.com/dpdpkit-dev). It provides a consent ledger, versioned
|
|
39
|
+
notices, rights requests and grievances, retention and erasure, audit evidence, and a CLI for India's
|
|
40
|
+
Digital Personal Data Protection Act, 2023 and DPDP Rules, 2025.
|
|
41
|
+
|
|
42
|
+
> **Disclaimer.** dpdpkit is software that helps you implement obligations under India's Digital Personal
|
|
43
|
+
> Data Protection Act, 2023 and the DPDP Rules, 2025. It does not provide legal advice and does not
|
|
44
|
+
> guarantee compliance. Decisions about notices, purposes, retention and incident reporting must be made
|
|
45
|
+
> by you or your counsel.
|
|
46
|
+
|
|
47
|
+
Core has no web framework and no database driver. Framework adapters
|
|
48
|
+
([`dpdpkit-fastapi`](https://github.com/dpdpkit-dev/dpdpkit-fastapi), `dpdpkit-django`) implement its
|
|
49
|
+
`Repository` protocol and expose it over the REST contract defined in
|
|
50
|
+
[`dpdpkit-spec`](https://github.com/dpdpkit-dev/dpdpkit-spec).
|
|
51
|
+
|
|
52
|
+
## Install
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install dpdpkit # core + policy packs + CLI
|
|
56
|
+
pip install "dpdpkit[fastapi]" # with the FastAPI adapter
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Use
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from dpdpkit import InMemoryRepository, MemoryNotifier, kit_from_config, load_config, sync_notice
|
|
63
|
+
|
|
64
|
+
config = load_config("dpdpkit.yaml") # `dpdpkit init` writes a starter file
|
|
65
|
+
kit = kit_from_config(config, InMemoryRepository(), notifier=MemoryNotifier(), signing_key="change-me")
|
|
66
|
+
sync_notice(kit, config) # publishes the notice if its text changed
|
|
67
|
+
|
|
68
|
+
kit.consent.grant("u_42", "marketing") # recorded against the current notice version
|
|
69
|
+
kit.consent.check("u_42", "marketing") # True
|
|
70
|
+
kit.consent.withdraw("u_42", "marketing") # one call, same as granting
|
|
71
|
+
kit.rights.open("u_42", "erasure") # due dates come from the policy pack
|
|
72
|
+
kit.retention.run() # warns, then erases only after a delivered warning
|
|
73
|
+
kit.ledger.verify() # raises LedgerTampered(row_id) if a row was edited
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Modules
|
|
77
|
+
|
|
78
|
+
| Module | Responsibility |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| `dpdpkit.policy` | Load and validate a policy pack; typed accessors for every legal number |
|
|
81
|
+
| `dpdpkit.registry` | Purposes, data items, legal basis (consent / DPDP Act s.7), processors, data stores |
|
|
82
|
+
| `dpdpkit.notices` | Versioned notices, content hash, locale fallback, required-link check |
|
|
83
|
+
| `dpdpkit.ledger` | Append-only SHA-256 hash chains (consent + audit) per tenant, `verify()`, root-hash export |
|
|
84
|
+
| `dpdpkit.consent` | `grant`, `deny`, `withdraw`, `check`, current state, signed receipts |
|
|
85
|
+
| `dpdpkit.rights` | Access, correction, completion, updating, erasure, nomination and grievance requests |
|
|
86
|
+
| `dpdpkit.retention` | Erasure schedules, pre-erasure warnings, legal holds, `needs_attention`, processor fan-out |
|
|
87
|
+
| `dpdpkit.events` | In-process event bus and HMAC-signed webhooks |
|
|
88
|
+
| `dpdpkit.notify` | Notifier protocol with delivery receipts; memory, console and SMTP transports |
|
|
89
|
+
| `dpdpkit.export` | Principal export (JSON, HTML) and evidence packs (CSV + PDF zip) |
|
|
90
|
+
|
|
91
|
+
## Fail-safe rules
|
|
92
|
+
|
|
93
|
+
- An erasure runs only after its warning is recorded as **delivered**, and only once the full warning
|
|
94
|
+
period has passed since delivery. Otherwise it moves to a `needs_attention` queue.
|
|
95
|
+
- Missing contact details, failed deliveries, failing erasure handlers and legal holds all stop erasure.
|
|
96
|
+
- Every state change writes a ledger or audit entry before it takes effect.
|
|
97
|
+
- A missing or invalid policy pack means the kit refuses to start. There are no built-in defaults.
|
|
98
|
+
- There is no function that submits anything to an authority.
|
|
99
|
+
|
|
100
|
+
## CLI
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
dpdpkit init # starter dpdpkit.yaml
|
|
104
|
+
dpdpkit policy show | list | diff OLD NEW
|
|
105
|
+
dpdpkit ledger verify --kit myapp.dpdp:kit # exit code 2 if tampered
|
|
106
|
+
dpdpkit retention preview --kit myapp.dpdp:kit
|
|
107
|
+
dpdpkit export --principal u_42 --format html --kit myapp.dpdp:kit
|
|
108
|
+
dpdpkit export --evidence --out evidence.zip --kit myapp.dpdp:kit
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Writing an adapter
|
|
112
|
+
|
|
113
|
+
Implement `dpdpkit.repository.Repository` (see its docstring for the rules) and run the
|
|
114
|
+
`dpdpkit-conformance` suite from `dpdpkit-spec` against your HTTP layer.
|
|
115
|
+
|
|
116
|
+
## Development
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
uv venv && uv pip install -e ../dpdpkit-policies -e ".[dev]"
|
|
120
|
+
pytest && ruff check . && mypy
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Licence
|
|
124
|
+
|
|
125
|
+
Apache-2.0.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# dpdpkit-core
|
|
2
|
+
|
|
3
|
+
The rules engine behind [dpdpkit](https://github.com/dpdpkit-dev). It provides a consent ledger, versioned
|
|
4
|
+
notices, rights requests and grievances, retention and erasure, audit evidence, and a CLI for India's
|
|
5
|
+
Digital Personal Data Protection Act, 2023 and DPDP Rules, 2025.
|
|
6
|
+
|
|
7
|
+
> **Disclaimer.** dpdpkit is software that helps you implement obligations under India's Digital Personal
|
|
8
|
+
> Data Protection Act, 2023 and the DPDP Rules, 2025. It does not provide legal advice and does not
|
|
9
|
+
> guarantee compliance. Decisions about notices, purposes, retention and incident reporting must be made
|
|
10
|
+
> by you or your counsel.
|
|
11
|
+
|
|
12
|
+
Core has no web framework and no database driver. Framework adapters
|
|
13
|
+
([`dpdpkit-fastapi`](https://github.com/dpdpkit-dev/dpdpkit-fastapi), `dpdpkit-django`) implement its
|
|
14
|
+
`Repository` protocol and expose it over the REST contract defined in
|
|
15
|
+
[`dpdpkit-spec`](https://github.com/dpdpkit-dev/dpdpkit-spec).
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install dpdpkit # core + policy packs + CLI
|
|
21
|
+
pip install "dpdpkit[fastapi]" # with the FastAPI adapter
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Use
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from dpdpkit import InMemoryRepository, MemoryNotifier, kit_from_config, load_config, sync_notice
|
|
28
|
+
|
|
29
|
+
config = load_config("dpdpkit.yaml") # `dpdpkit init` writes a starter file
|
|
30
|
+
kit = kit_from_config(config, InMemoryRepository(), notifier=MemoryNotifier(), signing_key="change-me")
|
|
31
|
+
sync_notice(kit, config) # publishes the notice if its text changed
|
|
32
|
+
|
|
33
|
+
kit.consent.grant("u_42", "marketing") # recorded against the current notice version
|
|
34
|
+
kit.consent.check("u_42", "marketing") # True
|
|
35
|
+
kit.consent.withdraw("u_42", "marketing") # one call, same as granting
|
|
36
|
+
kit.rights.open("u_42", "erasure") # due dates come from the policy pack
|
|
37
|
+
kit.retention.run() # warns, then erases only after a delivered warning
|
|
38
|
+
kit.ledger.verify() # raises LedgerTampered(row_id) if a row was edited
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Modules
|
|
42
|
+
|
|
43
|
+
| Module | Responsibility |
|
|
44
|
+
| --- | --- |
|
|
45
|
+
| `dpdpkit.policy` | Load and validate a policy pack; typed accessors for every legal number |
|
|
46
|
+
| `dpdpkit.registry` | Purposes, data items, legal basis (consent / DPDP Act s.7), processors, data stores |
|
|
47
|
+
| `dpdpkit.notices` | Versioned notices, content hash, locale fallback, required-link check |
|
|
48
|
+
| `dpdpkit.ledger` | Append-only SHA-256 hash chains (consent + audit) per tenant, `verify()`, root-hash export |
|
|
49
|
+
| `dpdpkit.consent` | `grant`, `deny`, `withdraw`, `check`, current state, signed receipts |
|
|
50
|
+
| `dpdpkit.rights` | Access, correction, completion, updating, erasure, nomination and grievance requests |
|
|
51
|
+
| `dpdpkit.retention` | Erasure schedules, pre-erasure warnings, legal holds, `needs_attention`, processor fan-out |
|
|
52
|
+
| `dpdpkit.events` | In-process event bus and HMAC-signed webhooks |
|
|
53
|
+
| `dpdpkit.notify` | Notifier protocol with delivery receipts; memory, console and SMTP transports |
|
|
54
|
+
| `dpdpkit.export` | Principal export (JSON, HTML) and evidence packs (CSV + PDF zip) |
|
|
55
|
+
|
|
56
|
+
## Fail-safe rules
|
|
57
|
+
|
|
58
|
+
- An erasure runs only after its warning is recorded as **delivered**, and only once the full warning
|
|
59
|
+
period has passed since delivery. Otherwise it moves to a `needs_attention` queue.
|
|
60
|
+
- Missing contact details, failed deliveries, failing erasure handlers and legal holds all stop erasure.
|
|
61
|
+
- Every state change writes a ledger or audit entry before it takes effect.
|
|
62
|
+
- A missing or invalid policy pack means the kit refuses to start. There are no built-in defaults.
|
|
63
|
+
- There is no function that submits anything to an authority.
|
|
64
|
+
|
|
65
|
+
## CLI
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
dpdpkit init # starter dpdpkit.yaml
|
|
69
|
+
dpdpkit policy show | list | diff OLD NEW
|
|
70
|
+
dpdpkit ledger verify --kit myapp.dpdp:kit # exit code 2 if tampered
|
|
71
|
+
dpdpkit retention preview --kit myapp.dpdp:kit
|
|
72
|
+
dpdpkit export --principal u_42 --format html --kit myapp.dpdp:kit
|
|
73
|
+
dpdpkit export --evidence --out evidence.zip --kit myapp.dpdp:kit
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Writing an adapter
|
|
77
|
+
|
|
78
|
+
Implement `dpdpkit.repository.Repository` (see its docstring for the rules) and run the
|
|
79
|
+
`dpdpkit-conformance` suite from `dpdpkit-spec` against your HTTP layer.
|
|
80
|
+
|
|
81
|
+
## Development
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
uv venv && uv pip install -e ../dpdpkit-policies -e ".[dev]"
|
|
85
|
+
pytest && ruff check . && mypy
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Licence
|
|
89
|
+
|
|
90
|
+
Apache-2.0.
|