problem-frame-gate 0.3.0__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.
Files changed (45) hide show
  1. problem_frame_gate-0.3.0/.gitignore +23 -0
  2. problem_frame_gate-0.3.0/CITATION.cff +14 -0
  3. problem_frame_gate-0.3.0/LICENSE +175 -0
  4. problem_frame_gate-0.3.0/NOTICE +4 -0
  5. problem_frame_gate-0.3.0/PKG-INFO +153 -0
  6. problem_frame_gate-0.3.0/README.md +116 -0
  7. problem_frame_gate-0.3.0/SECURITY.md +27 -0
  8. problem_frame_gate-0.3.0/docs/ai-agent-quickstart.md +21 -0
  9. problem_frame_gate-0.3.0/docs/json-format.md +78 -0
  10. problem_frame_gate-0.3.0/docs/operations.md +24 -0
  11. problem_frame_gate-0.3.0/docs/pypi-release.md +45 -0
  12. problem_frame_gate-0.3.0/docs/quickstart.md +32 -0
  13. problem_frame_gate-0.3.0/docs/schema.md +10 -0
  14. problem_frame_gate-0.3.0/docs/security.md +41 -0
  15. problem_frame_gate-0.3.0/docs/theory-mapping.md +90 -0
  16. problem_frame_gate-0.3.0/examples/ai_agent_gate.py +75 -0
  17. problem_frame_gate-0.3.0/pyproject.toml +104 -0
  18. problem_frame_gate-0.3.0/schemas/envelope-log.schema.json +27 -0
  19. problem_frame_gate-0.3.0/schemas/gate-request.schema.json +36 -0
  20. problem_frame_gate-0.3.0/schemas/horizon.schema.json +41 -0
  21. problem_frame_gate-0.3.0/src/problem_frame_gate/__init__.py +104 -0
  22. problem_frame_gate-0.3.0/src/problem_frame_gate/_version.py +1 -0
  23. problem_frame_gate-0.3.0/src/problem_frame_gate/certificates.py +116 -0
  24. problem_frame_gate-0.3.0/src/problem_frame_gate/cli.py +183 -0
  25. problem_frame_gate-0.3.0/src/problem_frame_gate/digest.py +69 -0
  26. problem_frame_gate-0.3.0/src/problem_frame_gate/errors.py +17 -0
  27. problem_frame_gate-0.3.0/src/problem_frame_gate/fold.py +425 -0
  28. problem_frame_gate-0.3.0/src/problem_frame_gate/formation.py +155 -0
  29. problem_frame_gate-0.3.0/src/problem_frame_gate/gate.py +365 -0
  30. problem_frame_gate-0.3.0/src/problem_frame_gate/join.py +150 -0
  31. problem_frame_gate-0.3.0/src/problem_frame_gate/model.py +441 -0
  32. problem_frame_gate-0.3.0/src/problem_frame_gate/patch.py +191 -0
  33. problem_frame_gate-0.3.0/src/problem_frame_gate/py.typed +1 -0
  34. problem_frame_gate-0.3.0/src/problem_frame_gate/records.py +210 -0
  35. problem_frame_gate-0.3.0/src/problem_frame_gate/result.py +148 -0
  36. problem_frame_gate-0.3.0/src/problem_frame_gate/risk.py +203 -0
  37. problem_frame_gate-0.3.0/src/problem_frame_gate/security.py +88 -0
  38. problem_frame_gate-0.3.0/src/problem_frame_gate/verifier.py +594 -0
  39. problem_frame_gate-0.3.0/tests/test_digest_security.py +16 -0
  40. problem_frame_gate-0.3.0/tests/test_docs_examples.py +14 -0
  41. problem_frame_gate-0.3.0/tests/test_formation_risk_cli.py +170 -0
  42. problem_frame_gate-0.3.0/tests/test_gate_patch_join.py +187 -0
  43. problem_frame_gate-0.3.0/tests/test_public_api_edges.py +761 -0
  44. problem_frame_gate-0.3.0/tests/test_records_and_strictness.py +279 -0
  45. problem_frame_gate-0.3.0/tests/test_verifier.py +64 -0
@@ -0,0 +1,23 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .pytest_cache/
6
+ .mypy_cache/
7
+ .ruff_cache/
8
+ .coverage
9
+ coverage.xml
10
+ dist/
11
+ build/
12
+ .env
13
+ .env.*
14
+ !.env.example
15
+ *.pem
16
+ *.key
17
+ *.p12
18
+ *.pfx
19
+ id_rsa
20
+ id_ed25519
21
+ *.sqlite
22
+ *.db
23
+ site/
@@ -0,0 +1,14 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use this software, cite the theory paper and this repository."
3
+ title: "Problem Frame Gate"
4
+ version: "0.3.0"
5
+ license: Apache-2.0
6
+ repository-code: "https://github.com/kadubon/problem-frame-gate"
7
+ references:
8
+ - type: article
9
+ title: "Problemogenesis Theory: A Finite Proof-Carrying Audit Calculus for Problem-Frame Activation"
10
+ authors:
11
+ - family-names: "Takahashi"
12
+ given-names: "K."
13
+ doi: "10.5281/zenodo.20913669"
14
+ date-released: "2026-06-26"
@@ -0,0 +1,175 @@
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
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean any work of authorship, including
48
+ the original version of the Work and any modifications or additions
49
+ to that Work or Derivative Works thereof, that is intentionally
50
+ submitted to Licensor for inclusion in the Work by the copyright owner
51
+ or by an individual or Legal Entity authorized to submit on behalf of
52
+ the copyright owner. For the purposes of this definition, "submitted"
53
+ means any form of electronic, verbal, or written communication sent
54
+ to the Licensor or its representatives, including but not limited to
55
+ communication on electronic mailing lists, source code control systems,
56
+ and issue tracking systems that are managed by, or on behalf of, the
57
+ Licensor for the purpose of discussing and improving the Work, but
58
+ excluding communication that is conspicuously marked or otherwise
59
+ designated in writing by the copyright owner as "Not a Contribution."
60
+
61
+ "Contributor" shall mean Licensor and any individual or Legal Entity
62
+ on behalf of whom a Contribution has been received by Licensor and
63
+ subsequently incorporated within the Work.
64
+
65
+ 2. Grant of Copyright License. Subject to the terms and conditions of
66
+ this License, each Contributor hereby grants to You a perpetual,
67
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
68
+ copyright license to reproduce, prepare Derivative Works of,
69
+ publicly display, publicly perform, sublicense, and distribute the
70
+ Work and such Derivative Works in Source or Object form.
71
+
72
+ 3. Grant of Patent License. Subject to the terms and conditions of
73
+ this License, each Contributor hereby grants to You a perpetual,
74
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
75
+ (except as stated in this section) patent license to make, have made,
76
+ use, offer to sell, sell, import, and otherwise transfer the Work,
77
+ where such license applies only to those patent claims licensable
78
+ by such Contributor that are necessarily infringed by their
79
+ Contribution(s) alone or by combination of their Contribution(s)
80
+ with the Work to which such Contribution(s) was submitted. If You
81
+ institute patent litigation against any entity (including a
82
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
83
+ or a Contribution incorporated within the Work constitutes direct
84
+ or contributory patent infringement, then any patent licenses
85
+ granted to You under this License for that Work shall terminate
86
+ as of the date such litigation is filed.
87
+
88
+ 4. Redistribution. You may reproduce and distribute copies of the
89
+ Work or Derivative Works thereof in any medium, with or without
90
+ modifications, and in Source or Object form, provided that You
91
+ meet the following conditions:
92
+
93
+ (a) You must give any other recipients of the Work or
94
+ Derivative Works a copy of this License; and
95
+
96
+ (b) You must cause any modified files to carry prominent notices
97
+ stating that You changed the files; and
98
+
99
+ (c) You must retain, in the Source form of any Derivative Works
100
+ that You distribute, all copyright, patent, trademark, and
101
+ attribution notices from the Source form of the Work,
102
+ excluding those notices that do not pertain to any part of
103
+ the Derivative Works; and
104
+
105
+ (d) If the Work includes a "NOTICE" text file as part of its
106
+ distribution, then any Derivative Works that You distribute must
107
+ include a readable copy of the attribution notices contained
108
+ within such NOTICE file, excluding those notices that do not
109
+ pertain to any part of the Derivative Works, in at least one
110
+ of the following places: within a NOTICE text file distributed
111
+ as part of the Derivative Works; within the Source form or
112
+ documentation, if provided along with the Derivative Works; or,
113
+ within a display generated by the Derivative Works, if and
114
+ wherever such third-party notices normally appear. The contents
115
+ of the NOTICE file are for informational purposes only and
116
+ do not modify the License. You may add Your own attribution
117
+ notices within Derivative Works that You distribute, alongside
118
+ or as an addendum to the NOTICE text from the Work, provided
119
+ that such additional attribution notices cannot be construed
120
+ as modifying the License.
121
+
122
+ You may add Your own copyright statement to Your modifications and
123
+ may provide additional or different license terms and conditions
124
+ for use, reproduction, or distribution of Your modifications, or
125
+ for any such Derivative Works as a whole, provided Your use,
126
+ reproduction, and distribution of the Work otherwise complies with
127
+ the conditions stated in this License.
128
+
129
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
130
+ any Contribution intentionally submitted for inclusion in the Work
131
+ by You to the Licensor shall be under the terms and conditions of
132
+ this License, without any additional terms or conditions.
133
+ Notwithstanding the above, nothing herein shall supersede or modify
134
+ the terms of any separate license agreement you may have executed
135
+ with Licensor regarding such Contributions.
136
+
137
+ 6. Trademarks. This License does not grant permission to use the trade
138
+ names, trademarks, service marks, or product names of the Licensor,
139
+ except as required for reasonable and customary use in describing the
140
+ origin of the Work and reproducing the content of the NOTICE file.
141
+
142
+ 7. Disclaimer of Warranty. Unless required by applicable law or
143
+ agreed to in writing, Licensor provides the Work (and each
144
+ Contributor provides its Contributions) on an "AS IS" BASIS,
145
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
146
+ implied, including, without limitation, any warranties or conditions
147
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
148
+ PARTICULAR PURPOSE. You are solely responsible for determining the
149
+ appropriateness of using or redistributing the Work and assume any
150
+ risks associated with Your exercise of permissions under this License.
151
+
152
+ 8. Limitation of Liability. In no event and under no legal theory,
153
+ whether in tort (including negligence), contract, or otherwise,
154
+ unless required by applicable law (such as deliberate and grossly
155
+ negligent acts) or agreed to in writing, shall any Contributor be
156
+ liable to You for damages, including any direct, indirect, special,
157
+ incidental, or consequential damages of any character arising as a
158
+ result of this License or out of the use or inability to use the
159
+ Work (including but not limited to damages for loss of goodwill,
160
+ work stoppage, computer failure or malfunction, or any and all
161
+ other commercial damages or losses), even if such Contributor
162
+ has been advised of the possibility of such damages.
163
+
164
+ 9. Accepting Warranty or Additional Liability. While redistributing
165
+ the Work or Derivative Works thereof, You may choose to offer,
166
+ and charge a fee for, acceptance of support, warranty, indemnity,
167
+ or other liability obligations and/or rights consistent with this
168
+ License. However, in accepting such obligations, You may act only
169
+ on Your own behalf and on Your sole responsibility, not on behalf
170
+ of any other Contributor, and only if You agree to indemnify,
171
+ defend, and hold each Contributor harmless for any liability
172
+ incurred by, or claims asserted against, such Contributor by reason
173
+ of your accepting any such warranty or additional liability.
174
+
175
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,4 @@
1
+ Problem Frame Gate
2
+ Copyright 2026 Problem Frame Gate contributors
3
+
4
+ This product includes software developed under the Apache License, Version 2.0.
@@ -0,0 +1,153 @@
1
+ Metadata-Version: 2.4
2
+ Name: problem-frame-gate
3
+ Version: 0.3.0
4
+ Summary: Audit logs and action gates for safer AI agents.
5
+ Project-URL: Homepage, https://github.com/kadubon/problem-frame-gate
6
+ Project-URL: Documentation, https://github.com/kadubon/problem-frame-gate/tree/main/docs
7
+ Project-URL: Issues, https://github.com/kadubon/problem-frame-gate/issues
8
+ Project-URL: Source, https://github.com/kadubon/problem-frame-gate
9
+ Author: Problem Frame Gate contributors
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ Keywords: ai,ai-agents,audit-log,authorization,open-source,provenance,pypi,python,risk-management,security
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: License :: OSI Approved :: Apache Software License
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Security
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Classifier: Typing :: Typed
27
+ Requires-Python: >=3.10
28
+ Provides-Extra: dev
29
+ Requires-Dist: bandit>=1.8.6; extra == 'dev'
30
+ Requires-Dist: build>=1.2.2; extra == 'dev'
31
+ Requires-Dist: mypy>=1.16.0; extra == 'dev'
32
+ Requires-Dist: pip-audit>=2.9.0; extra == 'dev'
33
+ Requires-Dist: pytest-cov>=6.2.0; extra == 'dev'
34
+ Requires-Dist: pytest>=8.4.0; extra == 'dev'
35
+ Requires-Dist: ruff>=0.12.0; extra == 'dev'
36
+ Description-Content-Type: text/markdown
37
+
38
+ # Problem Frame Gate
39
+
40
+ Problem Frame Gate is a Python library and CLI for finite, proof-carrying audit
41
+ checks around AI decision frames and external action gates. It implements the
42
+ audit-calculus concepts in:
43
+
44
+ Takahashi, K. (2026). *Problemogenesis Theory: A Finite Proof-Carrying Audit
45
+ Calculus for Problem-Frame Activation*. Zenodo.
46
+ https://doi.org/10.5281/zenodo.20913669
47
+
48
+ The package is strict by default. A log is not considered safe unless a finite
49
+ manifest declares writer authority, protected action constructors, capacities,
50
+ certificate families, risk modes, and gate bundle policy.
51
+
52
+ ## Install
53
+
54
+ ```bash
55
+ uv sync --all-extras
56
+ uv run pytest
57
+ ```
58
+
59
+ From PyPI:
60
+
61
+ ```bash
62
+ pip install problem-frame-gate
63
+ pfg init-manifest > horizon.json
64
+ ```
65
+
66
+ ## Safe Quickstart
67
+
68
+ Create a strict manifest:
69
+
70
+ ```bash
71
+ pfg init-manifest > horizon.json
72
+ ```
73
+
74
+ Validate and fold a log:
75
+
76
+ ```bash
77
+ pfg validate-schema horizon horizon.json
78
+ pfg validate-schema log log.json
79
+ pfg verify-log --horizon horizon.json log.json
80
+ pfg fold --horizon horizon.json log.json
81
+ ```
82
+
83
+ Check an action gate and emit the atomic bundle:
84
+
85
+ ```bash
86
+ pfg validate-schema gate-request gate-request.json
87
+ pfg check-gate --horizon horizon.json --bundle gate-request.json log.json
88
+ ```
89
+
90
+ The generated bundle contains exactly five protected rows:
91
+
92
+ 1. `GateCheck`
93
+ 2. `OutboxClaim`
94
+ 3. `UseCap`
95
+ 4. `ConsumeResource`
96
+ 5. `RiskClose`
97
+
98
+ Each row must be written by the executor writer and committed in one atomic
99
+ group. A standalone `OutboxClaim` is rejected.
100
+
101
+ ## Python Example
102
+
103
+ ```python
104
+ from problem_frame_gate import Envelope, EnvelopeClass, ExecutorGate, GateRequest, Horizon
105
+
106
+ horizon = Horizon.strict_default(agent_writers=("agent",))
107
+
108
+ def env(eid: str, commit: int, kind: str, **payload: object) -> Envelope:
109
+ return Envelope(eid, eid, "0", commit, "agent", "agent", 1, EnvelopeClass.NORMAL, {"kind": kind, **payload})
110
+
111
+ log = [
112
+ env("e0", 0, "Frame", frame_id="p1", scope="lab", goal="test anomaly",
113
+ evidence_ids=["u1"], actions=["run-check"], acceptance=["review"], risk_ids=["r1"]),
114
+ env("e1", 1, "Evidence", evidence_id="u1", digest="sha256:source"),
115
+ env("e2", 2, "Issue", cert_id="c-risk", family="risk", issuer="agent", expires_at=99, family_check=True),
116
+ env("e3", 3, "Activated", frame_id="p1"),
117
+ env("e4", 4, "RiskReg", hypothesis_id="h1", family="fixed"),
118
+ env("e5", 5, "RiskReserve", risk_id="r1", hypothesis_id="h1", frame_id="p1", eta="1/100"),
119
+ env("e6", 6, "RiskSpend", risk_id="r1", hypothesis_id="h1", frame_id="p1",
120
+ eta="1/100", mode="fixed", cert_id="c-risk"),
121
+ env("e7", 7, "ReserveResource", lease_id="lease1", token_id="tool", frame_id="p1"),
122
+ env("e8", 8, "MintCap", capability_id="cap1", frame_id="p1", action="run-check"),
123
+ env("e9", 9, "AuthorizeOutbox", outbox_id="out1", frame_id="p1", action="run-check"),
124
+ ]
125
+
126
+ request = GateRequest(
127
+ gate_id="gate1", bundle_id="bundle1", frame_id="p1", action="run-check",
128
+ outbox_id="out1", capability_id="cap1", lease_id="lease1",
129
+ risk_id="r1", hypothesis_id="h1", risk_mode="fixed", risk_cert_id="c-risk",
130
+ source_time=9, commit_time=10,
131
+ )
132
+
133
+ gate = ExecutorGate()
134
+ assert gate.check(horizon, log, request).ok
135
+ bundle = gate.create_bundle(horizon, log, request)
136
+ assert bundle.verify(horizon, log).ok
137
+ ```
138
+
139
+ ## Security Boundary
140
+
141
+ The library proves finite audit consistency. It does not prove external truth,
142
+ cryptographic collision resistance, statistical model validity, or physical
143
+ effect. Those are explicit assumptions in checker results.
144
+
145
+ See `docs/quickstart.md`, `docs/schema.md`, `docs/theory-mapping.md`, and
146
+ `docs/operations.md` for operational use.
147
+
148
+ ## Release
149
+
150
+ The canonical repository is `https://github.com/kadubon/problem-frame-gate`.
151
+ Versioned releases are published by GitHub Actions through PyPI Trusted
152
+ Publishing from `.github/workflows/workflow.yml`; no long-lived PyPI token is
153
+ required.
@@ -0,0 +1,116 @@
1
+ # Problem Frame Gate
2
+
3
+ Problem Frame Gate is a Python library and CLI for finite, proof-carrying audit
4
+ checks around AI decision frames and external action gates. It implements the
5
+ audit-calculus concepts in:
6
+
7
+ Takahashi, K. (2026). *Problemogenesis Theory: A Finite Proof-Carrying Audit
8
+ Calculus for Problem-Frame Activation*. Zenodo.
9
+ https://doi.org/10.5281/zenodo.20913669
10
+
11
+ The package is strict by default. A log is not considered safe unless a finite
12
+ manifest declares writer authority, protected action constructors, capacities,
13
+ certificate families, risk modes, and gate bundle policy.
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ uv sync --all-extras
19
+ uv run pytest
20
+ ```
21
+
22
+ From PyPI:
23
+
24
+ ```bash
25
+ pip install problem-frame-gate
26
+ pfg init-manifest > horizon.json
27
+ ```
28
+
29
+ ## Safe Quickstart
30
+
31
+ Create a strict manifest:
32
+
33
+ ```bash
34
+ pfg init-manifest > horizon.json
35
+ ```
36
+
37
+ Validate and fold a log:
38
+
39
+ ```bash
40
+ pfg validate-schema horizon horizon.json
41
+ pfg validate-schema log log.json
42
+ pfg verify-log --horizon horizon.json log.json
43
+ pfg fold --horizon horizon.json log.json
44
+ ```
45
+
46
+ Check an action gate and emit the atomic bundle:
47
+
48
+ ```bash
49
+ pfg validate-schema gate-request gate-request.json
50
+ pfg check-gate --horizon horizon.json --bundle gate-request.json log.json
51
+ ```
52
+
53
+ The generated bundle contains exactly five protected rows:
54
+
55
+ 1. `GateCheck`
56
+ 2. `OutboxClaim`
57
+ 3. `UseCap`
58
+ 4. `ConsumeResource`
59
+ 5. `RiskClose`
60
+
61
+ Each row must be written by the executor writer and committed in one atomic
62
+ group. A standalone `OutboxClaim` is rejected.
63
+
64
+ ## Python Example
65
+
66
+ ```python
67
+ from problem_frame_gate import Envelope, EnvelopeClass, ExecutorGate, GateRequest, Horizon
68
+
69
+ horizon = Horizon.strict_default(agent_writers=("agent",))
70
+
71
+ def env(eid: str, commit: int, kind: str, **payload: object) -> Envelope:
72
+ return Envelope(eid, eid, "0", commit, "agent", "agent", 1, EnvelopeClass.NORMAL, {"kind": kind, **payload})
73
+
74
+ log = [
75
+ env("e0", 0, "Frame", frame_id="p1", scope="lab", goal="test anomaly",
76
+ evidence_ids=["u1"], actions=["run-check"], acceptance=["review"], risk_ids=["r1"]),
77
+ env("e1", 1, "Evidence", evidence_id="u1", digest="sha256:source"),
78
+ env("e2", 2, "Issue", cert_id="c-risk", family="risk", issuer="agent", expires_at=99, family_check=True),
79
+ env("e3", 3, "Activated", frame_id="p1"),
80
+ env("e4", 4, "RiskReg", hypothesis_id="h1", family="fixed"),
81
+ env("e5", 5, "RiskReserve", risk_id="r1", hypothesis_id="h1", frame_id="p1", eta="1/100"),
82
+ env("e6", 6, "RiskSpend", risk_id="r1", hypothesis_id="h1", frame_id="p1",
83
+ eta="1/100", mode="fixed", cert_id="c-risk"),
84
+ env("e7", 7, "ReserveResource", lease_id="lease1", token_id="tool", frame_id="p1"),
85
+ env("e8", 8, "MintCap", capability_id="cap1", frame_id="p1", action="run-check"),
86
+ env("e9", 9, "AuthorizeOutbox", outbox_id="out1", frame_id="p1", action="run-check"),
87
+ ]
88
+
89
+ request = GateRequest(
90
+ gate_id="gate1", bundle_id="bundle1", frame_id="p1", action="run-check",
91
+ outbox_id="out1", capability_id="cap1", lease_id="lease1",
92
+ risk_id="r1", hypothesis_id="h1", risk_mode="fixed", risk_cert_id="c-risk",
93
+ source_time=9, commit_time=10,
94
+ )
95
+
96
+ gate = ExecutorGate()
97
+ assert gate.check(horizon, log, request).ok
98
+ bundle = gate.create_bundle(horizon, log, request)
99
+ assert bundle.verify(horizon, log).ok
100
+ ```
101
+
102
+ ## Security Boundary
103
+
104
+ The library proves finite audit consistency. It does not prove external truth,
105
+ cryptographic collision resistance, statistical model validity, or physical
106
+ effect. Those are explicit assumptions in checker results.
107
+
108
+ See `docs/quickstart.md`, `docs/schema.md`, `docs/theory-mapping.md`, and
109
+ `docs/operations.md` for operational use.
110
+
111
+ ## Release
112
+
113
+ The canonical repository is `https://github.com/kadubon/problem-frame-gate`.
114
+ Versioned releases are published by GitHub Actions through PyPI Trusted
115
+ Publishing from `.github/workflows/workflow.yml`; no long-lived PyPI token is
116
+ required.
@@ -0,0 +1,27 @@
1
+ # Security Policy
2
+
3
+ Report vulnerabilities through a private security advisory when the repository
4
+ is hosted on GitHub, or contact the maintainers through the published package
5
+ metadata.
6
+
7
+ ## Scope
8
+
9
+ This project protects the audit layer. It checks for secret-looking fields,
10
+ private key blocks, common API key formats, and machine-local paths before
11
+ payloads are accepted by the legal-log verifier.
12
+
13
+ The package does not provide cryptographic key management, hardware isolation,
14
+ or physical actuator safety by itself. Those must be supplied by the deployment
15
+ and cited as explicit assumptions in the audit transcript.
16
+
17
+ ## Baseline Checks
18
+
19
+ Run before publishing or deploying:
20
+
21
+ ```bash
22
+ uv run ruff check .
23
+ uv run mypy
24
+ uv run pytest
25
+ uv run bandit -c pyproject.toml -r src
26
+ uv run pip-audit
27
+ ```
@@ -0,0 +1,21 @@
1
+ # AI Agent Quickstart
2
+
3
+ Use this package as a final gate before an agent writes to an external system,
4
+ calls a tool with real side effects, starts an experiment, or sends a command to
5
+ an actuator.
6
+
7
+ ## Recommended Flow
8
+
9
+ 1. Append evidence and certificates as envelopes.
10
+ 2. Define a decision frame with goal, scope, allowed actions, acceptance
11
+ criteria, risk ids, and obligations.
12
+ 3. Activate the frame only after `check_formation` accepts.
13
+ 4. Reserve risk and resources before action.
14
+ 5. Mint a single-use capability for one frame and one action.
15
+ 6. Authorize one outbox entry.
16
+ 7. Call `ExecutorGate.check`.
17
+ 8. Append the generated `GateBundle` atomically.
18
+ 9. Dispatch only after the bundle is committed.
19
+
20
+ The key rule is simple: the model may propose actions, but only the gate writes
21
+ the externally actionable claim.
@@ -0,0 +1,78 @@
1
+ # JSON Format
2
+
3
+ All persistent data is ordinary JSON. Digests use sorted object keys,
4
+ no insignificant whitespace, UTF-8, and SHA-256 with the prefix `sha256:`.
5
+
6
+ ## Horizon
7
+
8
+ ```json
9
+ {
10
+ "strict": true,
11
+ "events": ["e0", "e1"],
12
+ "causal_order": [["e0", "e1"]],
13
+ "availability_order": [["e0", "e1"]],
14
+ "audit_order": [["e0", "e1"]],
15
+ "capacities": {"normal": 100, "abort": 10, "failClosed": 1},
16
+ "writer_authority": {
17
+ "*": ["agent", "executor-gate"],
18
+ "OutboxClaim": ["executor-gate"]
19
+ },
20
+ "version_intervals": {"*": [1, 1]},
21
+ "commit_groups": {
22
+ "bundle1": ["bundle1:0", "bundle1:1", "bundle1:2", "bundle1:3", "bundle1:4"]
23
+ },
24
+ "protected_constructors": {
25
+ "GateCheck": ["executor-gate"],
26
+ "OutboxClaim": ["executor-gate"],
27
+ "UseCap": ["executor-gate"],
28
+ "ConsumeResource": ["executor-gate"],
29
+ "RiskClose": ["executor-gate"]
30
+ },
31
+ "gate_bundle_kinds": ["GateCheck", "OutboxClaim", "UseCap", "ConsumeResource", "RiskClose"],
32
+ "executor_writer": "executor-gate",
33
+ "clock_policy": "integer-commit-time",
34
+ "certificate_families": {"risk": ["agent"]},
35
+ "risk_modes": ["fixed", "selectedEvent", "conditionalSelective", "anytime"],
36
+ "codebook": ["fixed", "selectedEvent", "conditionalSelective", "anytime"],
37
+ "allow_local_paths": false
38
+ }
39
+ ```
40
+
41
+ Empty safety tables are rejected in strict mode. Use `pfg init-manifest` to
42
+ generate a safe starter manifest.
43
+
44
+ ## Envelope
45
+
46
+ ```json
47
+ {
48
+ "eid": "e8",
49
+ "event": "e8",
50
+ "slot": "0",
51
+ "commit": 8,
52
+ "writer": "agent",
53
+ "owner": "agent",
54
+ "version": 1,
55
+ "class": "normal",
56
+ "payload": {
57
+ "kind": "MintCap",
58
+ "capability_id": "cap1",
59
+ "frame_id": "p1",
60
+ "action": "run-check"
61
+ },
62
+ "dependencies": [{"eid": "e3"}],
63
+ "commit_group": "optional-group"
64
+ }
65
+ ```
66
+
67
+ `payload.kind` is required. Known object identifiers include `frame_id`,
68
+ `cert_id`, `capability_id`, `risk_id`, `outbox_id`, `lease_id`, `evidence_id`,
69
+ `source_id`, `gate_id`, and `object`.
70
+
71
+ ## CLI
72
+
73
+ ```bash
74
+ pfg digest horizon.json
75
+ pfg scan log.json
76
+ pfg verify-log --horizon horizon.json log.json
77
+ pfg fold --horizon horizon.json log.json
78
+ ```
@@ -0,0 +1,24 @@
1
+ # Operations
2
+
3
+ Recommended release checks:
4
+
5
+ ```bash
6
+ uv run ruff check .
7
+ uv run ruff format --check .
8
+ uv run mypy
9
+ uv run pytest
10
+ uv run bandit -c pyproject.toml -r src
11
+ uv run pip-audit
12
+ uv build
13
+ ```
14
+
15
+ Use PyPI trusted publishing. Avoid long-lived publishing tokens.
16
+
17
+ Production manifests should pin:
18
+
19
+ - executor writer id;
20
+ - certificate family issuers;
21
+ - protected action constructors;
22
+ - capacity limits;
23
+ - risk modes;
24
+ - environment assumptions.