financial-data-protocol 0.3.0a3__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.
- financial_data_protocol-0.3.0a3/PKG-INFO +203 -0
- financial_data_protocol-0.3.0a3/README.md +174 -0
- financial_data_protocol-0.3.0a3/pyproject.toml +75 -0
- financial_data_protocol-0.3.0a3/setup.cfg +4 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/__init__.py +187 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/__main__.py +3 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/cli/__init__.py +186 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/cli/__main__.py +3 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/client/__init__.py +25 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/client/client.py +349 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/client/httpclient.py +478 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/client/interfaces.py +149 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/client/protocol_client.py +320 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/client/test_client.py +201 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/constants.py +5 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/models.py +352 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/protocol.py +64 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/py.typed +1 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/__init__.py +12 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/api.py +707 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/app.py +85 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/authority.py +322 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/config.py +162 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/db/__init__.py +1 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/db/mongo/__init__.py +5 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/db/mongo/schema.py +384 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/db/postgres/__init__.py +1 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/db/postgres/migrations/001_initial.sql +164 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/db/postgres/migrations/002_lineage_receipts.sql +9 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/db/postgres/migrations/003_material_handoffs.sql +43 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/db/postgres/migrations/004_disclosures.sql +9 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/db/postgres/migrations/005_domain_authority.sql +9 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/db/postgres/migrations/006_content_blobs.sql +16 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/db/postgres/migrations/__init__.py +1 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/errors.py +51 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/http.py +857 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/logging.py +61 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/object_storage/__init__.py +16 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/object_storage/content_store.py +258 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/object_storage/in_memory_content.py +44 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/object_storage/interfaces.py +28 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/registries/__init__.py +39 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/registries/in_memory_registry.py +768 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/registries/interfaces.py +295 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/registries/mongo_registry.py +1642 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/registries/postgres_registry.py +1875 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/schema.py +73 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/services/__init__.py +37 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/services/artifact_service.py +105 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/services/central_service.py +751 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol/server/services/content_service.py +549 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol.egg-info/PKG-INFO +203 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol.egg-info/SOURCES.txt +68 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol.egg-info/dependency_links.txt +1 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol.egg-info/entry_points.txt +2 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol.egg-info/requires.txt +19 -0
- financial_data_protocol-0.3.0a3/src/financial_data_protocol.egg-info/top_level.txt +1 -0
- financial_data_protocol-0.3.0a3/tests/test_central_api_t563.py +346 -0
- financial_data_protocol-0.3.0a3/tests/test_central_authority_t559.py +439 -0
- financial_data_protocol-0.3.0a3/tests/test_central_disclosure_t558.py +395 -0
- financial_data_protocol-0.3.0a3/tests/test_central_e2e_t579.py +286 -0
- financial_data_protocol-0.3.0a3/tests/test_central_finance_t557.py +362 -0
- financial_data_protocol-0.3.0a3/tests/test_central_http_t576.py +341 -0
- financial_data_protocol-0.3.0a3/tests/test_central_mongo_t564.py +121 -0
- financial_data_protocol-0.3.0a3/tests/test_central_object_store_t562.py +439 -0
- financial_data_protocol-0.3.0a3/tests/test_central_postgres_t561.py +21 -0
- financial_data_protocol-0.3.0a3/tests/test_central_protocol_t554.py +265 -0
- financial_data_protocol-0.3.0a3/tests/test_central_service_t560.py +686 -0
- financial_data_protocol-0.3.0a3/tests/test_central_shadow_t556.py +333 -0
- financial_data_protocol-0.3.0a3/tests/test_central_transport_t577.py +320 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: financial-data-protocol
|
|
3
|
+
Version: 0.3.0a3
|
|
4
|
+
Summary: Financial Data Protocol Central Registry
|
|
5
|
+
Author: Financial Data Protocol contributors
|
|
6
|
+
Classifier: Development Status :: 3 - Alpha
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: <3.15,>=3.14
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Requires-Dist: alibabacloud-oss-v2<2,>=1.4
|
|
12
|
+
Requires-Dist: boto3==1.43.83
|
|
13
|
+
Requires-Dist: fastapi<1,>=0.115
|
|
14
|
+
Requires-Dist: httpx>=0.28.1
|
|
15
|
+
Requires-Dist: loguru<1,>=0.7
|
|
16
|
+
Requires-Dist: psycopg[binary]<4,>=3.2
|
|
17
|
+
Requires-Dist: pymongo<5,>=4.10
|
|
18
|
+
Requires-Dist: pydantic==2.12.5
|
|
19
|
+
Requires-Dist: pytest>=9.1.1
|
|
20
|
+
Requires-Dist: pyyaml<7,>=6.0
|
|
21
|
+
Requires-Dist: uvicorn[standard]<1,>=0.30
|
|
22
|
+
Requires-Dist: trio>=0.34.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
25
|
+
Requires-Dist: jsonschema>=4.23; extra == "dev"
|
|
26
|
+
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
27
|
+
Requires-Dist: pytest>=8.2; extra == "dev"
|
|
28
|
+
Requires-Dist: ruff>=0.5; extra == "dev"
|
|
29
|
+
|
|
30
|
+
# Financial Data Protocol
|
|
31
|
+
|
|
32
|
+
Financial Data Protocol (FDP) is infrastructure for registering and tracing exact financial source
|
|
33
|
+
materials across business systems.
|
|
34
|
+
|
|
35
|
+
FDP answers questions such as:
|
|
36
|
+
|
|
37
|
+
- What exact bytes were registered?
|
|
38
|
+
- Which business Artifact refers to those bytes?
|
|
39
|
+
- Which immutable Package Revision was used?
|
|
40
|
+
- Which system declared a transfer, disclosure, or use?
|
|
41
|
+
- Can the retrieved bytes still be verified against their registered identity?
|
|
42
|
+
|
|
43
|
+
FDP records structure, identity, integrity, provenance, visibility, and immutable history. The
|
|
44
|
+
business system that declares a material remains responsible for its business meaning and truth.
|
|
45
|
+
|
|
46
|
+
## Current deployment profile
|
|
47
|
+
|
|
48
|
+
The current FDP product provides **Central FDP**: a shared service with Registry Spaces,
|
|
49
|
+
PostgreSQL Registry storage, S3-compatible Content custody, authenticated transports, and a typed
|
|
50
|
+
client. The previously described Embedded/local warehouse profile is not part of the current
|
|
51
|
+
product surface.
|
|
52
|
+
|
|
53
|
+
The Central capability milestones are incremental:
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
C0 protocol records and schemas
|
|
57
|
+
-> C1 custody and transaction contract
|
|
58
|
+
-> C2 durable Registry, object custody, and typed client
|
|
59
|
+
-> C3 immutable finance handoffs
|
|
60
|
+
-> C4 disclosure and evidence references
|
|
61
|
+
-> C5 one-writer Space authority cutover
|
|
62
|
+
-> C6 global physical Blob deduplication
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
See [`docs/central-capabilities.md`](docs/central-capabilities.md) for the implementation details
|
|
66
|
+
of these milestones. Version history belongs in [`CHANGELOG.md`](CHANGELOG.md).
|
|
67
|
+
|
|
68
|
+
## Current Central interface
|
|
69
|
+
|
|
70
|
+
The current packaged command is `fdp-central`. Its commands are:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
fdp-central serve
|
|
74
|
+
fdp-central init-db
|
|
75
|
+
fdp-central blob-sweep --month 2026-08
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The Central HTTP service exposes health/readiness/version endpoints, Content staging and
|
|
79
|
+
finalization, verified Content retrieval, Artifact and Package Revision registration, declarations,
|
|
80
|
+
finance handoffs, disclosure operations, and authority operations.
|
|
81
|
+
|
|
82
|
+
Start the configured service with:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
uv sync --locked --extra dev
|
|
86
|
+
uv run fdp-central init-db
|
|
87
|
+
uv run fdp-central serve
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`init-db` initializes the configured MongoDB Registry and is intentionally limited to a database
|
|
91
|
+
without application collections; collections whose names start with `_` are ignored. If
|
|
92
|
+
application collections already exist, delete the database manually before initialization.
|
|
93
|
+
`blob-sweep` reconciles final Blob objects for one UTC month, for example
|
|
94
|
+
`--month 2026-08`; it runs as a dry-run unless `--apply` is supplied.
|
|
95
|
+
|
|
96
|
+
The service reads the root `config.yaml`. Configure PostgreSQL, S3-compatible storage, HTTP
|
|
97
|
+
settings, and machine-token bindings there. Protect this file because it contains deployment
|
|
98
|
+
credentials. Deployment prerequisites and examples are documented in
|
|
99
|
+
[`docs/central-deployment.md`](docs/central-deployment.md).
|
|
100
|
+
|
|
101
|
+
## Python client
|
|
102
|
+
|
|
103
|
+
`CentralClient` sends strict typed requests through a `CentralTransport`. For an in-process test,
|
|
104
|
+
use deterministic in-memory custody implementations:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from financial_data_protocol import (
|
|
108
|
+
CentralClient,
|
|
109
|
+
CentralService,
|
|
110
|
+
ContextSpaceAuthorizer,
|
|
111
|
+
InMemoryContentCustody,
|
|
112
|
+
InMemoryRegistryCustody,
|
|
113
|
+
InProcessCentralTransport,
|
|
114
|
+
StaticMachineTokenAuthenticator,
|
|
115
|
+
StaticMachineTokenBinding,
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
transport = InProcessCentralTransport(
|
|
119
|
+
CentralService(
|
|
120
|
+
registry=InMemoryRegistryCustody(),
|
|
121
|
+
content_custody=InMemoryContentCustody(),
|
|
122
|
+
authorizer=ContextSpaceAuthorizer(),
|
|
123
|
+
),
|
|
124
|
+
StaticMachineTokenAuthenticator((
|
|
125
|
+
StaticMachineTokenBinding(
|
|
126
|
+
"legal-api", "development-token", frozenset({"legal"})
|
|
127
|
+
),
|
|
128
|
+
)),
|
|
129
|
+
)
|
|
130
|
+
client = CentralClient(
|
|
131
|
+
transport,
|
|
132
|
+
machine_token="development-token",
|
|
133
|
+
caller_id="legal-api",
|
|
134
|
+
registry_space_id="legal",
|
|
135
|
+
)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
For a deployed service, use the same `CentralClient` API with `HttpCentralTransport`:
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from financial_data_protocol import CentralClient, HttpCentralTransport
|
|
142
|
+
|
|
143
|
+
client = CentralClient(
|
|
144
|
+
HttpCentralTransport("https://central.example", "machine-token", "legal-api"),
|
|
145
|
+
machine_token="machine-token",
|
|
146
|
+
caller_id="legal-api",
|
|
147
|
+
registry_space_id="legal",
|
|
148
|
+
)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
All writes require a stable idempotency key. Repeating the same canonical request replays its
|
|
152
|
+
original result; reusing a key for a different request returns a conflict. Content uploads and
|
|
153
|
+
retrievals verify the declared size and SHA-256.
|
|
154
|
+
|
|
155
|
+
Central schema revision 6 separates Space-local Content registration from global physical Blob
|
|
156
|
+
custody. `central_contents` keeps each Space's Content identity, while `content_blobs` stores one
|
|
157
|
+
physical object for each global `(sha256, size_bytes)` identity and tracks its reference count.
|
|
158
|
+
The upload/finalize path performs Blob discovery internally, so clients never need cross-Space
|
|
159
|
+
catalog access. Identical bytes registered in different Spaces share one object-store key:
|
|
160
|
+
|
|
161
|
+
```text
|
|
162
|
+
central/<UTC creation date>/<blob_id>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Temporary staged objects are removed after successful finalization, and provisional Blob objects
|
|
166
|
+
are removed if the Registry transaction rejects the finalize request. PostgreSQL and MongoDB both
|
|
167
|
+
support the C6 model. Deployments should initialize a new revision 6 database rather than upgrade
|
|
168
|
+
an older database revision.
|
|
169
|
+
See the C6 section in [`docs/central-capabilities.md`](docs/central-capabilities.md) for the complete
|
|
170
|
+
identity, idempotency, and migration semantics.
|
|
171
|
+
|
|
172
|
+
## Scope
|
|
173
|
+
|
|
174
|
+
FDP does not decide whether a contract is approved or compliant, whether a payment is allowed,
|
|
175
|
+
whether an invoice is valid, or whether an accounting entry is correct. It does not provide IAM,
|
|
176
|
+
Registry federation, a queue, a general RAG system, or downstream workflow and output management.
|
|
177
|
+
See [`docs/product-definition.md`](docs/product-definition.md) for the complete product boundary.
|
|
178
|
+
|
|
179
|
+
## Documentation
|
|
180
|
+
|
|
181
|
+
- [`docs/central-capabilities.md`](docs/central-capabilities.md): Central C0-C6 capability details
|
|
182
|
+
and historical implementation notes.
|
|
183
|
+
- [`docs/api.md`](docs/api.md): Central HTTP API operations.
|
|
184
|
+
- [`docs/central-http-contract.md`](docs/central-http-contract.md): frozen HTTP wire contract.
|
|
185
|
+
- [`docs/central-deployment.md`](docs/central-deployment.md): deployment and operations.
|
|
186
|
+
- [`docs/central-deployment-company-quickstart.md`](docs/central-deployment-company-quickstart.md):
|
|
187
|
+
company deployment quick start.
|
|
188
|
+
- [`docs/central-authority-cutover-runbook.md`](docs/central-authority-cutover-runbook.md): C5
|
|
189
|
+
cutover and rollback procedure.
|
|
190
|
+
- [`docs/central-e2e-scenario.md`](docs/central-e2e-scenario.md): Central end-to-end scenario.
|
|
191
|
+
- [`docs/product-definition.md`](docs/product-definition.md): product role, users, and boundaries.
|
|
192
|
+
- [`docs/roadmap.md`](docs/roadmap.md): phased delivery roadmap.
|
|
193
|
+
- [`CHANGELOG.md`](CHANGELOG.md): release and version history.
|
|
194
|
+
|
|
195
|
+
## Development checks
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
uv sync --locked --extra dev
|
|
199
|
+
uv run python -m pytest -q
|
|
200
|
+
uv run python -m ruff check .
|
|
201
|
+
uv run python -m mypy
|
|
202
|
+
uv run python -m build
|
|
203
|
+
```
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# Financial Data Protocol
|
|
2
|
+
|
|
3
|
+
Financial Data Protocol (FDP) is infrastructure for registering and tracing exact financial source
|
|
4
|
+
materials across business systems.
|
|
5
|
+
|
|
6
|
+
FDP answers questions such as:
|
|
7
|
+
|
|
8
|
+
- What exact bytes were registered?
|
|
9
|
+
- Which business Artifact refers to those bytes?
|
|
10
|
+
- Which immutable Package Revision was used?
|
|
11
|
+
- Which system declared a transfer, disclosure, or use?
|
|
12
|
+
- Can the retrieved bytes still be verified against their registered identity?
|
|
13
|
+
|
|
14
|
+
FDP records structure, identity, integrity, provenance, visibility, and immutable history. The
|
|
15
|
+
business system that declares a material remains responsible for its business meaning and truth.
|
|
16
|
+
|
|
17
|
+
## Current deployment profile
|
|
18
|
+
|
|
19
|
+
The current FDP product provides **Central FDP**: a shared service with Registry Spaces,
|
|
20
|
+
PostgreSQL Registry storage, S3-compatible Content custody, authenticated transports, and a typed
|
|
21
|
+
client. The previously described Embedded/local warehouse profile is not part of the current
|
|
22
|
+
product surface.
|
|
23
|
+
|
|
24
|
+
The Central capability milestones are incremental:
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
C0 protocol records and schemas
|
|
28
|
+
-> C1 custody and transaction contract
|
|
29
|
+
-> C2 durable Registry, object custody, and typed client
|
|
30
|
+
-> C3 immutable finance handoffs
|
|
31
|
+
-> C4 disclosure and evidence references
|
|
32
|
+
-> C5 one-writer Space authority cutover
|
|
33
|
+
-> C6 global physical Blob deduplication
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
See [`docs/central-capabilities.md`](docs/central-capabilities.md) for the implementation details
|
|
37
|
+
of these milestones. Version history belongs in [`CHANGELOG.md`](CHANGELOG.md).
|
|
38
|
+
|
|
39
|
+
## Current Central interface
|
|
40
|
+
|
|
41
|
+
The current packaged command is `fdp-central`. Its commands are:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
fdp-central serve
|
|
45
|
+
fdp-central init-db
|
|
46
|
+
fdp-central blob-sweep --month 2026-08
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The Central HTTP service exposes health/readiness/version endpoints, Content staging and
|
|
50
|
+
finalization, verified Content retrieval, Artifact and Package Revision registration, declarations,
|
|
51
|
+
finance handoffs, disclosure operations, and authority operations.
|
|
52
|
+
|
|
53
|
+
Start the configured service with:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
uv sync --locked --extra dev
|
|
57
|
+
uv run fdp-central init-db
|
|
58
|
+
uv run fdp-central serve
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`init-db` initializes the configured MongoDB Registry and is intentionally limited to a database
|
|
62
|
+
without application collections; collections whose names start with `_` are ignored. If
|
|
63
|
+
application collections already exist, delete the database manually before initialization.
|
|
64
|
+
`blob-sweep` reconciles final Blob objects for one UTC month, for example
|
|
65
|
+
`--month 2026-08`; it runs as a dry-run unless `--apply` is supplied.
|
|
66
|
+
|
|
67
|
+
The service reads the root `config.yaml`. Configure PostgreSQL, S3-compatible storage, HTTP
|
|
68
|
+
settings, and machine-token bindings there. Protect this file because it contains deployment
|
|
69
|
+
credentials. Deployment prerequisites and examples are documented in
|
|
70
|
+
[`docs/central-deployment.md`](docs/central-deployment.md).
|
|
71
|
+
|
|
72
|
+
## Python client
|
|
73
|
+
|
|
74
|
+
`CentralClient` sends strict typed requests through a `CentralTransport`. For an in-process test,
|
|
75
|
+
use deterministic in-memory custody implementations:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from financial_data_protocol import (
|
|
79
|
+
CentralClient,
|
|
80
|
+
CentralService,
|
|
81
|
+
ContextSpaceAuthorizer,
|
|
82
|
+
InMemoryContentCustody,
|
|
83
|
+
InMemoryRegistryCustody,
|
|
84
|
+
InProcessCentralTransport,
|
|
85
|
+
StaticMachineTokenAuthenticator,
|
|
86
|
+
StaticMachineTokenBinding,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
transport = InProcessCentralTransport(
|
|
90
|
+
CentralService(
|
|
91
|
+
registry=InMemoryRegistryCustody(),
|
|
92
|
+
content_custody=InMemoryContentCustody(),
|
|
93
|
+
authorizer=ContextSpaceAuthorizer(),
|
|
94
|
+
),
|
|
95
|
+
StaticMachineTokenAuthenticator((
|
|
96
|
+
StaticMachineTokenBinding(
|
|
97
|
+
"legal-api", "development-token", frozenset({"legal"})
|
|
98
|
+
),
|
|
99
|
+
)),
|
|
100
|
+
)
|
|
101
|
+
client = CentralClient(
|
|
102
|
+
transport,
|
|
103
|
+
machine_token="development-token",
|
|
104
|
+
caller_id="legal-api",
|
|
105
|
+
registry_space_id="legal",
|
|
106
|
+
)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
For a deployed service, use the same `CentralClient` API with `HttpCentralTransport`:
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from financial_data_protocol import CentralClient, HttpCentralTransport
|
|
113
|
+
|
|
114
|
+
client = CentralClient(
|
|
115
|
+
HttpCentralTransport("https://central.example", "machine-token", "legal-api"),
|
|
116
|
+
machine_token="machine-token",
|
|
117
|
+
caller_id="legal-api",
|
|
118
|
+
registry_space_id="legal",
|
|
119
|
+
)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
All writes require a stable idempotency key. Repeating the same canonical request replays its
|
|
123
|
+
original result; reusing a key for a different request returns a conflict. Content uploads and
|
|
124
|
+
retrievals verify the declared size and SHA-256.
|
|
125
|
+
|
|
126
|
+
Central schema revision 6 separates Space-local Content registration from global physical Blob
|
|
127
|
+
custody. `central_contents` keeps each Space's Content identity, while `content_blobs` stores one
|
|
128
|
+
physical object for each global `(sha256, size_bytes)` identity and tracks its reference count.
|
|
129
|
+
The upload/finalize path performs Blob discovery internally, so clients never need cross-Space
|
|
130
|
+
catalog access. Identical bytes registered in different Spaces share one object-store key:
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
central/<UTC creation date>/<blob_id>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Temporary staged objects are removed after successful finalization, and provisional Blob objects
|
|
137
|
+
are removed if the Registry transaction rejects the finalize request. PostgreSQL and MongoDB both
|
|
138
|
+
support the C6 model. Deployments should initialize a new revision 6 database rather than upgrade
|
|
139
|
+
an older database revision.
|
|
140
|
+
See the C6 section in [`docs/central-capabilities.md`](docs/central-capabilities.md) for the complete
|
|
141
|
+
identity, idempotency, and migration semantics.
|
|
142
|
+
|
|
143
|
+
## Scope
|
|
144
|
+
|
|
145
|
+
FDP does not decide whether a contract is approved or compliant, whether a payment is allowed,
|
|
146
|
+
whether an invoice is valid, or whether an accounting entry is correct. It does not provide IAM,
|
|
147
|
+
Registry federation, a queue, a general RAG system, or downstream workflow and output management.
|
|
148
|
+
See [`docs/product-definition.md`](docs/product-definition.md) for the complete product boundary.
|
|
149
|
+
|
|
150
|
+
## Documentation
|
|
151
|
+
|
|
152
|
+
- [`docs/central-capabilities.md`](docs/central-capabilities.md): Central C0-C6 capability details
|
|
153
|
+
and historical implementation notes.
|
|
154
|
+
- [`docs/api.md`](docs/api.md): Central HTTP API operations.
|
|
155
|
+
- [`docs/central-http-contract.md`](docs/central-http-contract.md): frozen HTTP wire contract.
|
|
156
|
+
- [`docs/central-deployment.md`](docs/central-deployment.md): deployment and operations.
|
|
157
|
+
- [`docs/central-deployment-company-quickstart.md`](docs/central-deployment-company-quickstart.md):
|
|
158
|
+
company deployment quick start.
|
|
159
|
+
- [`docs/central-authority-cutover-runbook.md`](docs/central-authority-cutover-runbook.md): C5
|
|
160
|
+
cutover and rollback procedure.
|
|
161
|
+
- [`docs/central-e2e-scenario.md`](docs/central-e2e-scenario.md): Central end-to-end scenario.
|
|
162
|
+
- [`docs/product-definition.md`](docs/product-definition.md): product role, users, and boundaries.
|
|
163
|
+
- [`docs/roadmap.md`](docs/roadmap.md): phased delivery roadmap.
|
|
164
|
+
- [`CHANGELOG.md`](CHANGELOG.md): release and version history.
|
|
165
|
+
|
|
166
|
+
## Development checks
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
uv sync --locked --extra dev
|
|
170
|
+
uv run python -m pytest -q
|
|
171
|
+
uv run python -m ruff check .
|
|
172
|
+
uv run python -m mypy
|
|
173
|
+
uv run python -m build
|
|
174
|
+
```
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=69", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "financial-data-protocol"
|
|
7
|
+
version = "0.3.0a3"
|
|
8
|
+
description = "Financial Data Protocol Central Registry"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.14,<3.15"
|
|
11
|
+
authors = [{name = "Financial Data Protocol contributors"}]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 3 - Alpha",
|
|
14
|
+
"Programming Language :: Python :: 3.14",
|
|
15
|
+
"Operating System :: OS Independent",
|
|
16
|
+
]
|
|
17
|
+
dependencies = [
|
|
18
|
+
"alibabacloud-oss-v2>=1.4,<2",
|
|
19
|
+
"boto3==1.43.83",
|
|
20
|
+
"fastapi>=0.115,<1",
|
|
21
|
+
"httpx>=0.28.1",
|
|
22
|
+
"loguru>=0.7,<1",
|
|
23
|
+
"psycopg[binary]>=3.2,<4",
|
|
24
|
+
"pymongo>=4.10,<5",
|
|
25
|
+
"pydantic==2.12.5",
|
|
26
|
+
"pytest>=9.1.1",
|
|
27
|
+
"pyyaml>=6.0,<7",
|
|
28
|
+
"uvicorn[standard]>=0.30,<1",
|
|
29
|
+
"trio>=0.34.0",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.scripts]
|
|
33
|
+
fdp-central = "financial_data_protocol.cli:main"
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
dev = ["build>=1.2", "jsonschema>=4.23", "mypy>=1.10", "pytest>=8.2", "ruff>=0.5"]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
[tool.setuptools]
|
|
40
|
+
package-dir = {"" = "src"}
|
|
41
|
+
|
|
42
|
+
[tool.setuptools.packages.find]
|
|
43
|
+
where = ["src"]
|
|
44
|
+
|
|
45
|
+
[tool.setuptools.package-data]
|
|
46
|
+
financial_data_protocol = ["server/db/postgres/migrations/*.sql"]
|
|
47
|
+
|
|
48
|
+
[tool.pytest.ini_options]
|
|
49
|
+
addopts = "-ra"
|
|
50
|
+
markers = [
|
|
51
|
+
"integration: disposable PostgreSQL or MongoDB integration coverage",
|
|
52
|
+
]
|
|
53
|
+
testpaths = ["tests"]
|
|
54
|
+
|
|
55
|
+
[tool.ruff]
|
|
56
|
+
line-length = 100
|
|
57
|
+
target-version = "py314"
|
|
58
|
+
|
|
59
|
+
[tool.ruff.lint]
|
|
60
|
+
select = ["E", "F", "I", "UP", "B", "SIM", "RUF"]
|
|
61
|
+
|
|
62
|
+
[tool.mypy]
|
|
63
|
+
python_version = "3.14"
|
|
64
|
+
strict = true
|
|
65
|
+
packages = ["financial_data_protocol"]
|
|
66
|
+
|
|
67
|
+
[[tool.uv.index]]
|
|
68
|
+
name = "pypi"
|
|
69
|
+
url = "https://pypi.org/simple"
|
|
70
|
+
explicit = true
|
|
71
|
+
|
|
72
|
+
[[tool.uv.index]]
|
|
73
|
+
name = "tencent"
|
|
74
|
+
url = "https://mirrors.cloud.tencent.com/pypi/simple"
|
|
75
|
+
default = true
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"""Financial Data Protocol public package."""
|
|
2
|
+
|
|
3
|
+
from .client import FdpClient, FdpConfig
|
|
4
|
+
from .client.protocol_client import CentralClient, CentralClientError
|
|
5
|
+
from .constants import API_SCHEMA_VERSION, CENTRAL_SCHEMA_REVISION, CENTRAL_SCHEMA_VERSION
|
|
6
|
+
from .models import (
|
|
7
|
+
Artifact,
|
|
8
|
+
Content,
|
|
9
|
+
DeclarationProvenance,
|
|
10
|
+
DisclosurePackageRevision,
|
|
11
|
+
DisclosureReceipt,
|
|
12
|
+
DisclosureRevocation,
|
|
13
|
+
EvidenceReference,
|
|
14
|
+
LineageDeclaration,
|
|
15
|
+
LineageRelationType,
|
|
16
|
+
MaterialTransfer,
|
|
17
|
+
Package,
|
|
18
|
+
PackageMember,
|
|
19
|
+
PackageRevision,
|
|
20
|
+
RegistrySpace,
|
|
21
|
+
SpaceAccess,
|
|
22
|
+
UsageReceipt,
|
|
23
|
+
WriteConflict,
|
|
24
|
+
WriteCreated,
|
|
25
|
+
WriteIdempotent,
|
|
26
|
+
WriteResult,
|
|
27
|
+
)
|
|
28
|
+
from .server.api import (
|
|
29
|
+
ApiFailure,
|
|
30
|
+
ApiRequest,
|
|
31
|
+
ApiResponse,
|
|
32
|
+
ApiSuccess,
|
|
33
|
+
CentralTransport,
|
|
34
|
+
InProcessCentralTransport,
|
|
35
|
+
StaticMachineTokenAuthenticator,
|
|
36
|
+
StaticMachineTokenBinding,
|
|
37
|
+
)
|
|
38
|
+
from .server.authority import (
|
|
39
|
+
AuthorityCutoverRecord,
|
|
40
|
+
AuthorityRollbackPointRecord,
|
|
41
|
+
AuthorityRollbackRecord,
|
|
42
|
+
DomainAuthorityGate,
|
|
43
|
+
DomainAuthorityReadback,
|
|
44
|
+
DomainAuthorityState,
|
|
45
|
+
ShadowComparison,
|
|
46
|
+
)
|
|
47
|
+
from .server.config import CentralSettings
|
|
48
|
+
from .server.db.mongo.schema import CENTRAL_MONGO_SCHEMA_REVISION
|
|
49
|
+
from .server.errors import (
|
|
50
|
+
AuthorizationError,
|
|
51
|
+
ContentIntegrityError,
|
|
52
|
+
NotFoundError,
|
|
53
|
+
OperationStateError,
|
|
54
|
+
ServiceError,
|
|
55
|
+
)
|
|
56
|
+
from .server.http import CentralHttpApp, HttpCentralTransport, create_app
|
|
57
|
+
from .server.object_storage import (
|
|
58
|
+
AlibabaCloudOssObjectStore,
|
|
59
|
+
InMemoryObjectStore,
|
|
60
|
+
ObjectStore,
|
|
61
|
+
S3ObjectStore,
|
|
62
|
+
StreamingObjectStore,
|
|
63
|
+
)
|
|
64
|
+
from .server.registries import (
|
|
65
|
+
CentralOperationState,
|
|
66
|
+
CleanupUploadRequest,
|
|
67
|
+
FinalizedUpload,
|
|
68
|
+
FinalizeUploadRequest,
|
|
69
|
+
IdempotencyRecord,
|
|
70
|
+
InMemoryRegistryCustody,
|
|
71
|
+
RegistryCustody,
|
|
72
|
+
StagedUpload,
|
|
73
|
+
StageUploadRequest,
|
|
74
|
+
)
|
|
75
|
+
from .server.registries.mongo_registry import CentralMongoRegistry
|
|
76
|
+
from .server.registries.postgres_registry import (
|
|
77
|
+
CENTRAL_POSTGRES_SCHEMA_REVISION,
|
|
78
|
+
CentralPostgresRegistry,
|
|
79
|
+
)
|
|
80
|
+
from .server.schema import export_all_json_schemas, export_json_schema, schema_names
|
|
81
|
+
from .server.services import (
|
|
82
|
+
ArtifactService,
|
|
83
|
+
BackupRestoreReadiness,
|
|
84
|
+
CentralAccessContext,
|
|
85
|
+
CentralService,
|
|
86
|
+
ContextSpaceAuthorizer,
|
|
87
|
+
RecoveryContentCheck,
|
|
88
|
+
RecoveryRecordCheck,
|
|
89
|
+
RecoveryRecordState,
|
|
90
|
+
RecoveryReport,
|
|
91
|
+
SpaceAuthorizer,
|
|
92
|
+
)
|
|
93
|
+
from .server.services.content_service import (
|
|
94
|
+
ContentVerificationState,
|
|
95
|
+
FinalizedContentInspection,
|
|
96
|
+
OrphanedObject,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
__all__ = [
|
|
100
|
+
"API_SCHEMA_VERSION",
|
|
101
|
+
"CENTRAL_MONGO_SCHEMA_REVISION",
|
|
102
|
+
"CENTRAL_POSTGRES_SCHEMA_REVISION",
|
|
103
|
+
"CENTRAL_SCHEMA_REVISION",
|
|
104
|
+
"CENTRAL_SCHEMA_VERSION",
|
|
105
|
+
"AlibabaCloudOssObjectStore",
|
|
106
|
+
"ApiFailure",
|
|
107
|
+
"ApiRequest",
|
|
108
|
+
"ApiResponse",
|
|
109
|
+
"ApiSuccess",
|
|
110
|
+
"Artifact",
|
|
111
|
+
"ArtifactService",
|
|
112
|
+
"AuthorityCutoverRecord",
|
|
113
|
+
"AuthorityRollbackPointRecord",
|
|
114
|
+
"AuthorityRollbackRecord",
|
|
115
|
+
"AuthorizationError",
|
|
116
|
+
"BackupRestoreReadiness",
|
|
117
|
+
"CentralAccessContext",
|
|
118
|
+
"CentralClient",
|
|
119
|
+
"CentralClientError",
|
|
120
|
+
"CentralHttpApp",
|
|
121
|
+
"CentralMongoRegistry",
|
|
122
|
+
"CentralOperationState",
|
|
123
|
+
"CentralPostgresRegistry",
|
|
124
|
+
"CentralService",
|
|
125
|
+
"CentralSettings",
|
|
126
|
+
"CentralTransport",
|
|
127
|
+
"CleanupUploadRequest",
|
|
128
|
+
"Content",
|
|
129
|
+
"ContentIntegrityError",
|
|
130
|
+
"ContentVerificationState",
|
|
131
|
+
"ContextSpaceAuthorizer",
|
|
132
|
+
"DeclarationProvenance",
|
|
133
|
+
"DisclosurePackageRevision",
|
|
134
|
+
"DisclosureReceipt",
|
|
135
|
+
"DisclosureRevocation",
|
|
136
|
+
"DomainAuthorityGate",
|
|
137
|
+
"DomainAuthorityReadback",
|
|
138
|
+
"DomainAuthorityState",
|
|
139
|
+
"EvidenceReference",
|
|
140
|
+
"FdpClient",
|
|
141
|
+
"FdpConfig",
|
|
142
|
+
"FinalizeUploadRequest",
|
|
143
|
+
"FinalizedContentInspection",
|
|
144
|
+
"FinalizedUpload",
|
|
145
|
+
"HttpCentralTransport",
|
|
146
|
+
"IdempotencyRecord",
|
|
147
|
+
"InMemoryObjectStore",
|
|
148
|
+
"InMemoryRegistryCustody",
|
|
149
|
+
"InProcessCentralTransport",
|
|
150
|
+
"LineageDeclaration",
|
|
151
|
+
"LineageRelationType",
|
|
152
|
+
"MaterialTransfer",
|
|
153
|
+
"NotFoundError",
|
|
154
|
+
"ObjectStore",
|
|
155
|
+
"OperationStateError",
|
|
156
|
+
"OrphanedObject",
|
|
157
|
+
"Package",
|
|
158
|
+
"PackageMember",
|
|
159
|
+
"PackageRevision",
|
|
160
|
+
"RecoveryContentCheck",
|
|
161
|
+
"RecoveryRecordCheck",
|
|
162
|
+
"RecoveryRecordState",
|
|
163
|
+
"RecoveryReport",
|
|
164
|
+
"RegistryCustody",
|
|
165
|
+
"RegistrySpace",
|
|
166
|
+
"S3ObjectStore",
|
|
167
|
+
"ServiceError",
|
|
168
|
+
"ShadowComparison",
|
|
169
|
+
"SpaceAccess",
|
|
170
|
+
"SpaceAuthorizer",
|
|
171
|
+
"StageUploadRequest",
|
|
172
|
+
"StagedUpload",
|
|
173
|
+
"StaticMachineTokenAuthenticator",
|
|
174
|
+
"StaticMachineTokenBinding",
|
|
175
|
+
"StreamingObjectStore",
|
|
176
|
+
"UsageReceipt",
|
|
177
|
+
"WriteConflict",
|
|
178
|
+
"WriteCreated",
|
|
179
|
+
"WriteIdempotent",
|
|
180
|
+
"WriteResult",
|
|
181
|
+
"create_app",
|
|
182
|
+
"export_all_json_schemas",
|
|
183
|
+
"export_json_schema",
|
|
184
|
+
"schema_names",
|
|
185
|
+
]
|
|
186
|
+
|
|
187
|
+
__version__ = "0.3.0a2"
|