flowharness-core 0.1.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.
@@ -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,24 @@
1
+ Metadata-Version: 2.4
2
+ Name: flowharness-core
3
+ Version: 0.1.0
4
+ Summary: Shared core for flowharness — domain primitives, Finding, Check/Gate ports
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Programming Language :: Python :: 3.12
9
+ Classifier: Programming Language :: Python :: 3.13
10
+ Requires-Dist: sqlalchemy>=2.0
11
+ Requires-Python: >=3.12
12
+ Project-URL: Homepage, https://github.com/flowharness-ai
13
+ Description-Content-Type: text/markdown
14
+
15
+ # flowharness-core
16
+
17
+ Shared core domain kernel for flowharness — provides canonical Finding objects, Check/Gate/UnitOfWork ports, canonical JSON serialization, HMAC signing/verification, and value objects (Severity, Verdict, BasisPoints) that every bounded context depends on.
18
+
19
+ This is an **internal library package** of the FlowHarness toolchain, published to PyPI as a transitive dependency of [`flowharness`](https://github.com/flowharness-ai) (the scan CLI) and [`flowharness-ci-runner`](https://github.com/flowharness-ai). Install those packages instead of depending on `flowharness-core` directly.
20
+
21
+ > **Note:** this package currently installs a top-level module named `core`. Prefer `uvx` (isolated environments) over `pip install` into a shared venv until the 0.2 module-namespace rename lands.
22
+
23
+ **License:** Apache-2.0
24
+ **Homepage:** https://github.com/flowharness-ai
@@ -0,0 +1,10 @@
1
+ # flowharness-core
2
+
3
+ Shared core domain kernel for flowharness — provides canonical Finding objects, Check/Gate/UnitOfWork ports, canonical JSON serialization, HMAC signing/verification, and value objects (Severity, Verdict, BasisPoints) that every bounded context depends on.
4
+
5
+ This is an **internal library package** of the FlowHarness toolchain, published to PyPI as a transitive dependency of [`flowharness`](https://github.com/flowharness-ai) (the scan CLI) and [`flowharness-ci-runner`](https://github.com/flowharness-ai). Install those packages instead of depending on `flowharness-core` directly.
6
+
7
+ > **Note:** this package currently installs a top-level module named `core`. Prefer `uvx` (isolated environments) over `pip install` into a shared venv until the 0.2 module-namespace rename lands.
8
+
9
+ **License:** Apache-2.0
10
+ **Homepage:** https://github.com/flowharness-ai
@@ -0,0 +1,54 @@
1
+ [project]
2
+ name = "flowharness-core"
3
+ version = "0.1.0"
4
+ readme = "README.md"
5
+ description = "Shared core for flowharness — domain primitives, Finding, Check/Gate ports"
6
+ requires-python = ">=3.12"
7
+ license = "Apache-2.0"
8
+ license-files = ["LICENSE"]
9
+ classifiers = [
10
+ "Development Status :: 3 - Alpha",
11
+ "Programming Language :: Python :: 3.12",
12
+ "Programming Language :: Python :: 3.13",
13
+ ]
14
+ dependencies = ["sqlalchemy>=2.0"]
15
+
16
+ [project.urls]
17
+ Homepage = "https://github.com/flowharness-ai"
18
+
19
+ [build-system]
20
+ requires = ["uv_build>=0.9.0,<0.10.0"]
21
+ build-backend = "uv_build"
22
+
23
+ [tool.uv.build-backend]
24
+ module-name = "core"
25
+ source-exclude = [
26
+ "src/core/access.py",
27
+ "src/core/access_resolvers.py",
28
+ "src/core/canonical_payload.py",
29
+ "src/core/contracts_adapters",
30
+ "src/core/entitlements.py",
31
+ "src/core/ids.py",
32
+ "src/core/journal_store.py",
33
+ "src/core/messagebus.py",
34
+ "src/core/rls.py",
35
+ "src/core/sharing.py",
36
+ "src/core/sql_reads.py",
37
+ "src/core/sql_unit_of_work.py",
38
+ "src/core/sqlite_engine.py",
39
+ ]
40
+ wheel-exclude = [
41
+ "core/access.py",
42
+ "core/access_resolvers.py",
43
+ "core/canonical_payload.py",
44
+ "core/contracts_adapters",
45
+ "core/entitlements.py",
46
+ "core/ids.py",
47
+ "core/journal_store.py",
48
+ "core/messagebus.py",
49
+ "core/rls.py",
50
+ "core/sharing.py",
51
+ "core/sql_reads.py",
52
+ "core/sql_unit_of_work.py",
53
+ "core/sqlite_engine.py",
54
+ ]
@@ -0,0 +1,73 @@
1
+ [project]
2
+ name = "flowharness-core"
3
+ version = "0.1.0"
4
+ readme = "README.md"
5
+ description = "Shared core for flowharness — domain primitives, Finding, Check/Gate ports"
6
+ requires-python = ">=3.12"
7
+ license = "Apache-2.0"
8
+ license-files = ["LICENSE"]
9
+ classifiers = [
10
+ "Development Status :: 3 - Alpha",
11
+ "Programming Language :: Python :: 3.12",
12
+ "Programming Language :: Python :: 3.13",
13
+ ]
14
+ # SQLAlchemy backs ONLY core.journal_store (the shared Event-Journal + sharing-surface schema every
15
+ # context's UoW writes); the pure-domain `core` package itself stays import-light (§6.1, D5-1).
16
+ dependencies = ["sqlalchemy>=2.0"]
17
+
18
+ [project.urls]
19
+ Homepage = "https://github.com/flowharness-ai"
20
+
21
+ [build-system]
22
+ requires = ["uv_build>=0.9.0,<0.10.0"]
23
+ build-backend = "uv_build"
24
+
25
+ [tool.uv.build-backend]
26
+ module-name = "core"
27
+ # --- Pruned public surface (decision 2026-07-30: funnel-open / platform-closed) -------
28
+ # `flowharness-core` is published to PyPI only to make the two OSS CLIs installable, so it
29
+ # ships ONLY the modules in their derived import closure plus the trust primitives
30
+ # (canonical JSON, content hashing, signing/verification, Finding/Severity/Verdict/Cell/
31
+ # BasisPoints, external_findings, errors). Everything platform-only is pruned:
32
+ # entitlements — enumerates the paid editions/features. The single most important cut.
33
+ # access, access_resolvers, sharing — the authorization + sharing-surface model.
34
+ # ids — platform tenancy ids (OrgId/ProjectId/TeamId/...); no OSS caller.
35
+ # messagebus — the platform-internal bus (§8.1); no OSS caller.
36
+ # canonical_payload — platform ratification payload wrapper; no OSS caller.
37
+ # contracts_adapters/* — the proto/wire bindings for flowharness.governance.v1.
38
+ # journal_store, rls, sql_reads, sql_unit_of_work, sqlite_engine — SQL/RLS plumbing.
39
+ # `core/__init__.py` guards the platform-only re-exports so `import core` still works here.
40
+ # BOTH lists are required: `source-exclude` prunes the sdist (sdists are source too) and
41
+ # `uv build --wheel` builds straight from the tree, so `wheel-exclude` must mirror it.
42
+ # Enforced by tests/packaging/test_public_surface_manifest.py — adding a module to either
43
+ # dist turns that test red until the manifest is consciously updated.
44
+ source-exclude = [
45
+ "src/core/access.py",
46
+ "src/core/access_resolvers.py",
47
+ "src/core/canonical_payload.py",
48
+ "src/core/contracts_adapters",
49
+ "src/core/entitlements.py",
50
+ "src/core/ids.py",
51
+ "src/core/journal_store.py",
52
+ "src/core/messagebus.py",
53
+ "src/core/rls.py",
54
+ "src/core/sharing.py",
55
+ "src/core/sql_reads.py",
56
+ "src/core/sql_unit_of_work.py",
57
+ "src/core/sqlite_engine.py",
58
+ ]
59
+ wheel-exclude = [
60
+ "core/access.py",
61
+ "core/access_resolvers.py",
62
+ "core/canonical_payload.py",
63
+ "core/contracts_adapters",
64
+ "core/entitlements.py",
65
+ "core/ids.py",
66
+ "core/journal_store.py",
67
+ "core/messagebus.py",
68
+ "core/rls.py",
69
+ "core/sharing.py",
70
+ "core/sql_reads.py",
71
+ "core/sql_unit_of_work.py",
72
+ "core/sqlite_engine.py",
73
+ ]
@@ -0,0 +1,180 @@
1
+ """flowharness shared core (FLOWHARNESS_SPEC.md §6.1).
2
+
3
+ Domain primitives shared by every bounded context. This facade re-exports the
4
+ pure (stdlib-only) modules; SQL infrastructure (core.sql_unit_of_work,
5
+ core.sqlite_engine, core.journal_store, core.rls) is imported by its submodule
6
+ path, never from here. Kept true by tests/architecture/test_domain_purity.py.
7
+
8
+ Two re-export tiers, split by the *published* public surface:
9
+
10
+ * The unconditional block is the OSS surface — the trust primitives the two
11
+ published CLIs (`flowharness`, `flowharness-ci`) and the published contexts
12
+ (inspection, portability, evaluation.domain) actually need.
13
+ * The guarded block below is PLATFORM-ONLY. Those modules are pruned out of the
14
+ `flowharness-core` wheel/sdist (see `[tool.uv.build-backend]` in
15
+ platform/core/pyproject.toml), so on a PyPI install the imports raise
16
+ ModuleNotFoundError and are swallowed — `import core` still works and the OSS
17
+ names still resolve. In the workspace every module is present, so dev
18
+ behaviour is byte-identical to before. `__all__` deliberately keeps listing
19
+ the platform-only names: it documents the *workspace* surface, and the
20
+ published surface is pinned separately by tests/packaging/test_public_surface_manifest.py.
21
+ """
22
+
23
+ from core.actors import Actor, ActorKind, Money, actor_from_json, actor_to_json
24
+ from core.aggregate import EventRecorder
25
+ from core.candidate import CandidateKind, CandidateRef
26
+ from core.cell import Cell
27
+ from core.content_hash import ContentHashable
28
+ from core.errors import DomainError
29
+ from core.external_findings import (
30
+ EXTERNAL_SEVERITY_MAP_VERSION,
31
+ SeverityResolution,
32
+ canonical_tool_slug,
33
+ normalize_tool_slug,
34
+ resolve_external_severity,
35
+ )
36
+ from core.findings import EvidenceBundle, EvidenceRef, Finding, SourceAnchor
37
+ from core.journal import (
38
+ GENESIS_HASH,
39
+ DomainEventEnvelope,
40
+ canonical_json,
41
+ ensure_json_canonical,
42
+ entry_hash,
43
+ )
44
+ from core.messages import Command, Event
45
+ from core.ports import (
46
+ Check,
47
+ Corpus,
48
+ EvidenceSource,
49
+ Gate,
50
+ GateOutcome,
51
+ GatePolicy,
52
+ IndexReader,
53
+ SignalSink,
54
+ UnitOfWork,
55
+ )
56
+ from core.signing import sign_report, verify_signature
57
+ from core.values import BasisPoints, Severity, Verdict
58
+
59
+ # --- Platform-only re-exports (pruned from the published `flowharness-core` dist) ---
60
+ # Provenance: public-surface decision 2026-07-30 (funnel-open / platform-closed). The
61
+ # `as X` aliases are load-bearing: mypy runs with no_implicit_reexport=true, and inside a
62
+ # try/except mypy cannot rely on `__all__`, so each name needs the PEP 484 explicit
63
+ # re-export form. Do NOT collapse them.
64
+ try:
65
+ from core.access import AccessDenied as AccessDenied
66
+ from core.access import AccessPolicy as AccessPolicy
67
+ from core.access import AccessRequest as AccessRequest
68
+ from core.access import Decision as Decision
69
+ from core.access_resolvers import DEFAULT_RESOLVERS as DEFAULT_RESOLVERS
70
+ from core.access_resolvers import ActorAccess as ActorAccess
71
+ from core.access_resolvers import GrantRecord as GrantRecord
72
+ from core.access_resolvers import SubjectContext as SubjectContext
73
+ from core.access_resolvers import grant_resolver as grant_resolver
74
+ from core.access_resolvers import namespace_can_use as namespace_can_use
75
+ from core.access_resolvers import namespace_resolver as namespace_resolver
76
+ from core.access_resolvers import project_link_resolver as project_link_resolver
77
+ from core.canonical_payload import CanonicalPayload as CanonicalPayload
78
+ from core.entitlements import Edition as Edition
79
+ from core.entitlements import Entitlement as Entitlement
80
+ from core.entitlements import EntitlementError as EntitlementError
81
+ from core.entitlements import EntitlementPolicy as EntitlementPolicy
82
+ from core.ids import ApiTokenId as ApiTokenId
83
+ from core.ids import AssetId as AssetId
84
+ from core.ids import MemberId as MemberId
85
+ from core.ids import OrgId as OrgId
86
+ from core.ids import ProjectId as ProjectId
87
+ from core.ids import TeamId as TeamId
88
+ from core.ids import TraceId as TraceId
89
+ from core.messagebus import MessageBus as MessageBus
90
+ from core.sharing import Grantee as Grantee
91
+ from core.sharing import GranteeKind as GranteeKind
92
+ from core.sharing import Namespace as Namespace
93
+ from core.sharing import NamespaceKind as NamespaceKind
94
+ from core.sharing import Permission as Permission
95
+ from core.sharing import ScopeKind as ScopeKind
96
+ from core.sharing import ScopeSelector as ScopeSelector
97
+ from core.sharing import SubjectRef as SubjectRef
98
+ from core.sharing import Visibility as Visibility
99
+ from core.sharing import permission_rank as permission_rank
100
+ except ModuleNotFoundError: # pragma: no cover — only on a pruned PyPI install
101
+ pass
102
+
103
+ __all__ = [
104
+ "DEFAULT_RESOLVERS",
105
+ "EXTERNAL_SEVERITY_MAP_VERSION",
106
+ "GENESIS_HASH",
107
+ "AccessDenied",
108
+ "AccessPolicy",
109
+ "AccessRequest",
110
+ "Actor",
111
+ "ActorAccess",
112
+ "ActorKind",
113
+ "ApiTokenId",
114
+ "AssetId",
115
+ "BasisPoints",
116
+ "CandidateKind",
117
+ "CandidateRef",
118
+ "CanonicalPayload",
119
+ "Cell",
120
+ "Check",
121
+ "Command",
122
+ "ContentHashable",
123
+ "Corpus",
124
+ "Decision",
125
+ "DomainError",
126
+ "DomainEventEnvelope",
127
+ "Edition",
128
+ "Entitlement",
129
+ "EntitlementError",
130
+ "EntitlementPolicy",
131
+ "Event",
132
+ "EventRecorder",
133
+ "EvidenceBundle",
134
+ "EvidenceRef",
135
+ "EvidenceSource",
136
+ "Finding",
137
+ "Gate",
138
+ "GateOutcome",
139
+ "GatePolicy",
140
+ "GrantRecord",
141
+ "Grantee",
142
+ "GranteeKind",
143
+ "IndexReader",
144
+ "MemberId",
145
+ "MessageBus",
146
+ "Money",
147
+ "Namespace",
148
+ "NamespaceKind",
149
+ "OrgId",
150
+ "Permission",
151
+ "ProjectId",
152
+ "ScopeKind",
153
+ "ScopeSelector",
154
+ "Severity",
155
+ "SeverityResolution",
156
+ "SignalSink",
157
+ "SourceAnchor",
158
+ "SubjectContext",
159
+ "SubjectRef",
160
+ "TeamId",
161
+ "TraceId",
162
+ "UnitOfWork",
163
+ "Verdict",
164
+ "Visibility",
165
+ "actor_from_json",
166
+ "actor_to_json",
167
+ "canonical_json",
168
+ "canonical_tool_slug",
169
+ "ensure_json_canonical",
170
+ "entry_hash",
171
+ "grant_resolver",
172
+ "namespace_can_use",
173
+ "namespace_resolver",
174
+ "normalize_tool_slug",
175
+ "permission_rank",
176
+ "project_link_resolver",
177
+ "resolve_external_severity",
178
+ "sign_report",
179
+ "verify_signature",
180
+ ]
@@ -0,0 +1,68 @@
1
+ """Actor and Money value objects (FLOWHARNESS_SPEC.md §6.0, §6.1).
2
+
3
+ Every state transition records an Actor (no anonymous writes, §6.1 global invariants).
4
+ Money is float-free: integer micro-units (1_000_000 == 1.00) at a single currency.
5
+ """
6
+
7
+ from dataclasses import dataclass
8
+ from enum import StrEnum
9
+
10
+ from core.errors import DomainError
11
+
12
+
13
+ class ActorKind(StrEnum):
14
+ HUMAN = "human"
15
+ AGENT = "agent"
16
+ SYSTEM = "system"
17
+
18
+
19
+ @dataclass(frozen=True, slots=True)
20
+ class Actor:
21
+ actor_id: str
22
+ kind: ActorKind
23
+ display_ref: str
24
+
25
+ def __post_init__(self) -> None:
26
+ if not self.actor_id:
27
+ raise DomainError("actor_id_blank")
28
+
29
+
30
+ @dataclass(frozen=True, slots=True)
31
+ class Money:
32
+ micro_units: int # 1_000_000 == 1.00; may be negative for credits
33
+ currency: str # ISO 4217 alpha-3
34
+
35
+ def __post_init__(self) -> None:
36
+ if not (len(self.currency) == 3 and self.currency.isalpha() and self.currency.isupper()):
37
+ raise DomainError("money_currency_not_iso_4217")
38
+
39
+
40
+ # --- R05.3 (D-R5-4): the canonical Actor⇄dict codec ---
41
+ #
42
+ # The journal envelope contract is a THREE-KEY dict: {"actor_id", "kind", "display_ref"}.
43
+ # Six modules had their own encode/decode helpers with subtly different names; this is
44
+ # the one shape. `actor_to_json` is byte-identical to every prior helper.
45
+ # `actor_from_json` is STRICT (no coercion of malformed input) — untrusted-input paths
46
+ # (e.g. catalog closure restore) keep their local `str(...)` coercion before delegating.
47
+
48
+
49
+ def actor_to_json(actor: Actor) -> dict[str, str]:
50
+ """Encode an Actor to the journal envelope's actor sub-dict."""
51
+ return {
52
+ "actor_id": actor.actor_id,
53
+ "kind": actor.kind.value,
54
+ "display_ref": actor.display_ref,
55
+ }
56
+
57
+
58
+ def actor_from_json(value: object) -> Actor:
59
+ """Decode the journal envelope's actor sub-dict back to an Actor. Strict on
60
+ types — malformed input raises. Untrusted-input paths (air-gap bundles) MUST
61
+ coerce inputs BEFORE calling this."""
62
+ if not isinstance(value, dict):
63
+ raise DomainError("actor_from_json_not_a_dict")
64
+ return Actor(
65
+ actor_id=value["actor_id"],
66
+ kind=ActorKind(value["kind"]),
67
+ display_ref=value["display_ref"],
68
+ )
@@ -0,0 +1,26 @@
1
+ """Aggregate-root event recording (FLOWHARNESS_SPEC.md §6.1, §8.1).
2
+
3
+ `EventRecorder` is the mixin aggregate roots use to record past-tense events + a monotonic
4
+ `sequence_no`, drained via `pull_events`. Extracted at the third aggregate (Organization, ApiToken,
5
+ now Team/Project) so it lives once, in `core`, so any context reuses it without importing another.
6
+ The concrete aggregate (a slotted dataclass) supplies `_events` + `sequence_no`; this mixin adds
7
+ the methods (empty `__slots__` → no instance state, no layout conflict).
8
+ """
9
+
10
+ from core.messages import Event
11
+
12
+
13
+ class EventRecorder:
14
+ __slots__ = ()
15
+
16
+ _events: list[Event]
17
+ sequence_no: int
18
+
19
+ def _record(self, event: Event) -> None:
20
+ self._events.append(event)
21
+ self.sequence_no += 1 # type: ignore[misc] # WHY: mixin contract — the concrete slotted dataclass supplies _events/sequence_no slots (module docstring)
22
+
23
+ def pull_events(self) -> list[Event]:
24
+ drained = self._events
25
+ self._events = [] # type: ignore[misc] # WHY: mixin contract — the concrete slotted dataclass supplies _events/sequence_no slots (module docstring)
26
+ return drained
@@ -0,0 +1,26 @@
1
+ """CandidateRef — an opaque cross-context pointer to what an EvalRun evaluates (§6.6).
2
+
3
+ `RELEASE` / `PROPOSAL` only in p1 (the `reranker_version` candidate arrives with the Selection
4
+ context, phase 4). `ref` is an opaque id string — Evaluation never imports Catalog (§5), so it
5
+ cannot (and must not) dereference it; the edge / gate resolve liveness when needed.
6
+ """
7
+
8
+ from dataclasses import dataclass
9
+ from enum import Enum
10
+
11
+ from core.errors import DomainError
12
+
13
+
14
+ class CandidateKind(Enum):
15
+ RELEASE = "release"
16
+ PROPOSAL = "proposal"
17
+
18
+
19
+ @dataclass(frozen=True, slots=True)
20
+ class CandidateRef:
21
+ kind: CandidateKind
22
+ ref: str
23
+
24
+ def __post_init__(self) -> None:
25
+ if not self.ref:
26
+ raise DomainError("candidate_ref_blank")