phlo-api 0.17.0__tar.gz → 0.18.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.
- {phlo_api-0.17.0 → phlo_api-0.18.0}/PKG-INFO +10 -3
- {phlo_api-0.17.0 → phlo_api-0.18.0}/pyproject.toml +18 -3
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/Dockerfile +7 -5
- phlo_api-0.18.0/src/phlo_api/api/asset_preview_filters.py +55 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/api/authentication.py +82 -20
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/api/authoring.py +21 -16
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/api/authorization.py +2 -2
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/api/continuity.py +25 -9
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/api/maintenance.py +10 -9
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/api/observability.py +46 -31
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/api/operation_controls.py +301 -139
- phlo_api-0.18.0/src/phlo_api/api/v1.py +575 -0
- phlo_api-0.18.0/src/phlo_api/api/v1_admin_audit.py +318 -0
- phlo_api-0.18.0/src/phlo_api/api/v1_admin_identity.py +827 -0
- phlo_api-0.18.0/src/phlo_api/api/v1_assets.py +3707 -0
- phlo_api-0.18.0/src/phlo_api/api/v1_audit_proposals.py +320 -0
- phlo_api-0.18.0/src/phlo_api/api/v1_branch_workflows.py +1676 -0
- phlo_api-0.18.0/src/phlo_api/api/v1_datasets.py +73 -0
- phlo_api-0.18.0/src/phlo_api/api/v1_git_review.py +325 -0
- phlo_api-0.18.0/src/phlo_api/api/v1_jobs.py +1637 -0
- phlo_api-0.18.0/src/phlo_api/api/v1_query.py +850 -0
- phlo_api-0.18.0/src/phlo_api/api/v1_query_sql.py +46 -0
- phlo_api-0.18.0/src/phlo_api/api/v1_staging.py +848 -0
- phlo_api-0.18.0/src/phlo_api/api/v1_wap.py +232 -0
- phlo_api-0.18.0/src/phlo_api/branch_schema_resolution.py +390 -0
- phlo_api-0.18.0/src/phlo_api/entrypoint.sh +53 -0
- phlo_api-0.18.0/src/phlo_api/errors.py +87 -0
- phlo_api-0.18.0/src/phlo_api/incidents.py +1542 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/main.py +87 -20
- phlo_api-0.18.0/src/phlo_api/observatory_api/_loki_regex_worker.py +68 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/contributing.py +48 -42
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/dagster.py +135 -635
- phlo_api-0.18.0/src/phlo_api/observatory_api/http_client.py +32 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/lineage.py +5 -5
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/loki.py +230 -110
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/observatory.py +133 -113
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/observatory_models.py +89 -12
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/observatory_search.py +55 -52
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/observatory_services.py +161 -162
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/observatory_workflow_wizard.py +97 -54
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/orchestrator_operations.py +1 -2
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/package_install.py +4 -2
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/run_action_contract.py +1 -1
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/run_report.py +9 -1
- phlo_api-0.18.0/src/phlo_api/observatory_api/service_payloads.py +100 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/settings.py +165 -1
- phlo_api-0.18.0/src/phlo_api/observatory_api/trino.py +317 -0
- phlo_api-0.18.0/src/phlo_api/observatory_api/v1_preview.py +356 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/security_manifest.py +564 -82
- phlo_api-0.18.0/src/phlo_api/service.yaml +275 -0
- phlo_api-0.18.0/src/phlo_api/settings.py +292 -0
- phlo_api-0.18.0/src/phlo_api/sql/001_incidents.sql +93 -0
- phlo_api-0.18.0/src/phlo_api/sql/002_query_usage.sql +26 -0
- phlo_api-0.18.0/src/phlo_api/sql/003_incident_query_parity.sql +57 -0
- phlo_api-0.18.0/src/phlo_api/usage.py +365 -0
- phlo_api-0.18.0/src/phlo_api/v1_contract.py +111 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api.egg-info/PKG-INFO +10 -3
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api.egg-info/SOURCES.txt +63 -7
- phlo_api-0.18.0/src/phlo_api.egg-info/requires.txt +24 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_api_backend_endpoints.py +4 -2
- phlo_api-0.18.0/tests/test_api_settings.py +129 -0
- phlo_api-0.18.0/tests/test_asset_operations.py +710 -0
- phlo_api-0.18.0/tests/test_asset_read_parity.py +604 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_auth_helper_meta.py +9 -0
- phlo_api-0.18.0/tests/test_authentication_api.py +446 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_authoring_api.py +27 -2
- phlo_api-0.18.0/tests/test_branch_schema_resolution.py +282 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_dataset_cutover_parity.py +45 -0
- phlo_api-0.18.0/tests/test_error_envelope.py +226 -0
- phlo_api-0.18.0/tests/test_governance_settings.py +856 -0
- phlo_api-0.18.0/tests/test_identity_authority_postgres.py +79 -0
- phlo_api-0.18.0/tests/test_incident_query_parity.py +507 -0
- phlo_api-0.18.0/tests/test_incident_signed_resolution_postgres.py +175 -0
- phlo_api-0.18.0/tests/test_incidents_postgres.py +325 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_integration_api.py +50 -17
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_loki_api.py +3 -1
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_maintenance_api.py +7 -9
- phlo_api-0.18.0/tests/test_no_fork_multiprocessing.py +27 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_observability_api.py +7 -5
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_observatory_api.py +273 -42
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_observatory_legacy_api.py +23 -129
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_observatory_package_install.py +2 -1
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_observatory_run_action_contract.py +14 -6
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_observatory_surfaces.py +11 -3
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_observatory_workflow_wizard.py +109 -3
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_operation_controls.py +128 -39
- phlo_api-0.18.0/tests/test_operation_controls_postgres.py +295 -0
- phlo_api-0.18.0/tests/test_operational_observations.py +854 -0
- phlo_api-0.18.0/tests/test_require_scope.py +240 -0
- phlo_api-0.18.0/tests/test_route_inventory.py +212 -0
- phlo_api-0.18.0/tests/test_run_report_postgres_recovery.py +78 -0
- phlo_api-0.18.0/tests/test_security_manifest_action_dispatch.py +182 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_service_url_resolution.py +4 -7
- phlo_api-0.18.0/tests/test_trino_defaults.py +102 -0
- phlo_api-0.18.0/tests/test_trino_query_bound.py +98 -0
- phlo_api-0.18.0/tests/test_trino_sql.py +57 -0
- phlo_api-0.18.0/tests/test_usage.py +260 -0
- phlo_api-0.18.0/tests/test_usage_trino_integration.py +493 -0
- phlo_api-0.18.0/tests/test_v1_admin_audit.py +255 -0
- phlo_api-0.18.0/tests/test_v1_admin_identity.py +333 -0
- phlo_api-0.18.0/tests/test_v1_api.py +3416 -0
- phlo_api-0.18.0/tests/test_v1_asset_row_count.py +242 -0
- phlo_api-0.18.0/tests/test_v1_audit_parity.py +222 -0
- phlo_api-0.18.0/tests/test_v1_branch_workflows.py +660 -0
- phlo_api-0.18.0/tests/test_v1_contract.py +280 -0
- phlo_api-0.18.0/tests/test_v1_git_review.py +222 -0
- phlo_api-0.18.0/tests/test_v1_jobs_read.py +1231 -0
- phlo_api-0.18.0/tests/test_v1_preview.py +347 -0
- phlo_api-0.18.0/tests/test_v1_query_api.py +448 -0
- phlo_api-0.18.0/tests/test_v1_query_sql.py +52 -0
- phlo_api-0.18.0/tests/test_v1_staging.py +649 -0
- phlo_api-0.18.0/tests/test_v1_wap.py +247 -0
- phlo_api-0.18.0/tests/test_workflow_wizard_boundaries.py +138 -0
- phlo_api-0.17.0/src/phlo_api/entrypoint.sh +0 -41
- phlo_api-0.17.0/src/phlo_api/observatory_api/iceberg.py +0 -536
- phlo_api-0.17.0/src/phlo_api/observatory_api/nessie.py +0 -410
- phlo_api-0.17.0/src/phlo_api/observatory_api/quality.py +0 -606
- phlo_api-0.17.0/src/phlo_api/observatory_api/search.py +0 -169
- phlo_api-0.17.0/src/phlo_api/observatory_api/trino.py +0 -742
- phlo_api-0.17.0/src/phlo_api/observatory_api/trino_sql.py +0 -213
- phlo_api-0.17.0/src/phlo_api/service.yaml +0 -103
- phlo_api-0.17.0/src/phlo_api.egg-info/requires.txt +0 -15
- phlo_api-0.17.0/tests/test_authentication_api.py +0 -188
- phlo_api-0.17.0/tests/test_lakehouse_compatibility.py +0 -104
- phlo_api-0.17.0/tests/test_trino_defaults.py +0 -222
- phlo_api-0.17.0/tests/test_trino_sql.py +0 -90
- {phlo_api-0.17.0 → phlo_api-0.18.0}/README.md +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/setup.cfg +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/__init__.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/api/__init__.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/__init__.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/extension_settings.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/extensions.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/observatory_actions.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/observatory_cache.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/observatory_capabilities.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/observatory_durable_state.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/observatory_metadata.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/observatory_operation_journal.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/observatory_runs.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/observatory_api/observatory_saved_queries.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/pagination.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/plugin.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/regulated_surface_adapter.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api/run_evidence.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api.egg-info/dependency_links.txt +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api.egg-info/entry_points.txt +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/src/phlo_api.egg-info/top_level.txt +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_api_import_boundaries.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_authorization_api.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_continuity_api.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_cors.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_dataset_overlay_retirement.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_lineage_api.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_observatory_actions.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_observatory_capabilities.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_observatory_operation_journal.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_observatory_read_models.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_pagination.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_security_manifest.py +0 -0
- {phlo_api-0.17.0 → phlo_api-0.18.0}/tests/test_service_correlation_runtime.py +0 -0
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: phlo-api
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.18.0
|
|
4
4
|
Summary: Phlo API - Backend service exposing Phlo internals to Observatory
|
|
5
5
|
Author-email: Phlo Team <team@phlo.dev>
|
|
6
6
|
License: MIT
|
|
7
7
|
Requires-Python: >=3.12
|
|
8
8
|
Description-Content-Type: text/plain
|
|
9
|
-
Requires-Dist: phlo<0.
|
|
10
|
-
Requires-Dist: fastapi
|
|
9
|
+
Requires-Dist: phlo<0.19,>=0.18.0
|
|
10
|
+
Requires-Dist: fastapi<0.137,>=0.127.0
|
|
11
11
|
Requires-Dist: httpx>=0.28.1
|
|
12
12
|
Requires-Dist: anyio>=4.14.2
|
|
13
13
|
Requires-Dist: psycopg2-binary>=2.9.11
|
|
14
|
+
Requires-Dist: phlo-pandera<0.17,>=0.16.1
|
|
15
|
+
Requires-Dist: phlo-postgres<0.18,>=0.17.0
|
|
14
16
|
Requires-Dist: pydantic>=2.0
|
|
15
17
|
Requires-Dist: pyyaml>=6.0.1
|
|
18
|
+
Requires-Dist: sqlglot<31,>=30.2.1
|
|
16
19
|
Requires-Dist: uvicorn>=0.38.0
|
|
20
|
+
Provides-Extra: dagster
|
|
21
|
+
Requires-Dist: phlo-dagster>=0.3.2; extra == "dagster"
|
|
17
22
|
Provides-Extra: dev
|
|
18
23
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
19
24
|
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
25
|
+
Provides-Extra: iceberg
|
|
26
|
+
Requires-Dist: phlo-iceberg<0.18,>=0.17.0; extra == "iceberg"
|
|
20
27
|
Provides-Extra: lineage
|
|
21
28
|
Requires-Dist: phlo-lineage>=0.1.0; extra == "lineage"
|
|
22
29
|
|
|
@@ -7,19 +7,22 @@ requires = [
|
|
|
7
7
|
|
|
8
8
|
[project]
|
|
9
9
|
dependencies = [
|
|
10
|
-
"phlo>=0.
|
|
11
|
-
"fastapi>=0.127.0",
|
|
10
|
+
"phlo>=0.18.0,<0.19",
|
|
11
|
+
"fastapi>=0.127.0,<0.137",
|
|
12
12
|
"httpx>=0.28.1",
|
|
13
13
|
"anyio>=4.14.2",
|
|
14
14
|
"psycopg2-binary>=2.9.11",
|
|
15
|
+
"phlo-pandera>=0.16.1,<0.17",
|
|
16
|
+
"phlo-postgres>=0.17.0,<0.18",
|
|
15
17
|
"pydantic>=2.0",
|
|
16
18
|
"pyyaml>=6.0.1",
|
|
19
|
+
"sqlglot>=30.2.1,<31",
|
|
17
20
|
"uvicorn>=0.38.0",
|
|
18
21
|
]
|
|
19
22
|
description = "Phlo API - Backend service exposing Phlo internals to Observatory"
|
|
20
23
|
name = "phlo-api"
|
|
21
24
|
requires-python = ">=3.12"
|
|
22
|
-
version = "0.
|
|
25
|
+
version = "0.18.0"
|
|
23
26
|
|
|
24
27
|
[[project.authors]]
|
|
25
28
|
email = "team@phlo.dev"
|
|
@@ -32,16 +35,27 @@ phlo-api = "phlo_api.plugin:PhloApiServicePlugin"
|
|
|
32
35
|
text = "MIT"
|
|
33
36
|
|
|
34
37
|
[project.optional-dependencies]
|
|
38
|
+
dagster = ["phlo-dagster>=0.3.2"]
|
|
35
39
|
dev = [
|
|
36
40
|
"pytest>=7.0",
|
|
37
41
|
"ruff>=0.1.0",
|
|
38
42
|
]
|
|
43
|
+
iceberg = ["phlo-iceberg>=0.17.0,<0.18"]
|
|
39
44
|
lineage = ["phlo-lineage>=0.1.0"]
|
|
40
45
|
|
|
41
46
|
[project.readme]
|
|
42
47
|
content-type = "text/plain"
|
|
43
48
|
text = "Phlo API backend for Observatory."
|
|
44
49
|
|
|
50
|
+
[tool.mutmut]
|
|
51
|
+
only_mutate = ["src/phlo_api/observatory_api/trino.py"]
|
|
52
|
+
pytest_add_cli_args = [
|
|
53
|
+
"--confcutdir=.",
|
|
54
|
+
"--import-mode=importlib",
|
|
55
|
+
]
|
|
56
|
+
pytest_add_cli_args_test_selection = ["tests/test_trino_sql.py"]
|
|
57
|
+
source_paths = ["src/"]
|
|
58
|
+
|
|
45
59
|
[tool.ruff]
|
|
46
60
|
line-length = 100
|
|
47
61
|
target-version = "py312"
|
|
@@ -55,6 +69,7 @@ phlo_api = [
|
|
|
55
69
|
"Dockerfile",
|
|
56
70
|
"entrypoint.sh",
|
|
57
71
|
"observatory_api/**/*.py",
|
|
72
|
+
"sql/*.sql",
|
|
58
73
|
]
|
|
59
74
|
|
|
60
75
|
[tool.setuptools.package-dir]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
FROM python:3.12-alpine AS phlo-build-context
|
|
1
|
+
FROM python:3.12-alpine@sha256:1b668429b3511ab407d8e00648891631b0b1a4d7e15e3ca70f38ab5b91ad4ab4 AS phlo-build-context
|
|
2
2
|
|
|
3
3
|
WORKDIR /opt/phlo-build-context
|
|
4
4
|
|
|
@@ -8,7 +8,7 @@ RUN set -eux; \
|
|
|
8
8
|
install -m 0755 "$entrypoint" /opt/phlo-build-context/phlo-api-entrypoint.sh; \
|
|
9
9
|
mkdir -p /opt/phlo-build-context/wheelhouse
|
|
10
10
|
|
|
11
|
-
FROM python:3.12-alpine AS runtime
|
|
11
|
+
FROM python:3.12-alpine@sha256:1b668429b3511ab407d8e00648891631b0b1a4d7e15e3ca70f38ab5b91ad4ab4 AS runtime
|
|
12
12
|
|
|
13
13
|
WORKDIR /app
|
|
14
14
|
|
|
@@ -18,8 +18,8 @@ ARG PHLO_WHEELHOUSE=
|
|
|
18
18
|
|
|
19
19
|
# Alpine packages stay unpinned: the branch archive drops superseded versions,
|
|
20
20
|
# so an exact version becomes a hard build failure for consumers running
|
|
21
|
-
# `phlo services start --build` weeks after the phlo release.
|
|
22
|
-
#
|
|
21
|
+
# `phlo services start --build` weeks after the phlo release. `apk upgrade`
|
|
22
|
+
# below resolves the current branch versions even with a digest-pinned base.
|
|
23
23
|
# hadolint ignore=DL3018
|
|
24
24
|
RUN apk upgrade --no-cache \
|
|
25
25
|
&& apk add --no-cache ca-certificates \
|
|
@@ -35,6 +35,7 @@ COPY --from=phlo-build-context /opt/phlo-build-context/wheelhouse /opt/phlo-whee
|
|
|
35
35
|
|
|
36
36
|
# Phlo currently pins the unpublished observe packages by URL. uv requires
|
|
37
37
|
# transitive URL dependencies to be repeated as direct installation inputs.
|
|
38
|
+
# Keep the if block outside an && chain, which would disable set -e inside it.
|
|
38
39
|
RUN set -eux; \
|
|
39
40
|
PHLO_REQUIREMENT="phlo"; \
|
|
40
41
|
if [ -n "$PHLO_VERSION" ]; then PHLO_REQUIREMENT="phlo==$PHLO_VERSION"; fi; \
|
|
@@ -54,7 +55,8 @@ RUN set -eux; \
|
|
|
54
55
|
uv pip install --system --no-deps phlo; \
|
|
55
56
|
python -c 'import importlib.metadata as md; print("\n".join(r.split(";", 1)[0].strip() for r in (md.metadata("phlo").get_all("Requires-Dist") or []) if " @ " in r))' > /tmp/phlo-url-requirements.txt; \
|
|
56
57
|
uv pip install --system --requirement /tmp/phlo-url-requirements.txt phlo "$PHLO_API_REQUIREMENT"; \
|
|
57
|
-
fi
|
|
58
|
+
fi; \
|
|
59
|
+
apk del .build-deps
|
|
58
60
|
|
|
59
61
|
# Do not retain uv's downloaded archives in the runtime image; they are not needed to run Phlo.
|
|
60
62
|
RUN rm -rf /root/.cache/uv
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Compile bounded typed preview predicates without accepting SQL fragments."""
|
|
2
|
+
|
|
3
|
+
from typing import Annotated, Literal
|
|
4
|
+
|
|
5
|
+
from pydantic import (
|
|
6
|
+
BaseModel,
|
|
7
|
+
ConfigDict,
|
|
8
|
+
Field,
|
|
9
|
+
StrictBool,
|
|
10
|
+
StrictFloat,
|
|
11
|
+
StrictInt,
|
|
12
|
+
StrictStr,
|
|
13
|
+
TypeAdapter,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ComparisonFilter(BaseModel):
|
|
18
|
+
model_config = ConfigDict(extra="forbid", allow_inf_nan=False)
|
|
19
|
+
column: str = Field(min_length=1, max_length=256)
|
|
20
|
+
operator: Literal["eq", "ne", "lt", "lte", "gt", "gte"]
|
|
21
|
+
value: StrictStr | StrictInt | StrictFloat | StrictBool
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class NullFilter(BaseModel):
|
|
25
|
+
model_config = ConfigDict(extra="forbid")
|
|
26
|
+
column: str = Field(min_length=1, max_length=256)
|
|
27
|
+
operator: Literal["is_null", "is_not_null"]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
PreviewFilter = ComparisonFilter | NullFilter
|
|
31
|
+
preview_filters = TypeAdapter(Annotated[list[PreviewFilter], Field(max_length=20)])
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def preview_where(filters: list[PreviewFilter], columns: set[str]) -> str:
|
|
35
|
+
predicates = []
|
|
36
|
+
operators = {"eq": "=", "ne": "<>", "lt": "<", "lte": "<=", "gt": ">", "gte": ">="}
|
|
37
|
+
for predicate in filters:
|
|
38
|
+
if predicate.column not in columns or "\x00" in predicate.column:
|
|
39
|
+
raise ValueError("Filter column is not in the selected table schema.")
|
|
40
|
+
column = '"' + predicate.column.replace('"', '""') + '"'
|
|
41
|
+
if isinstance(predicate, NullFilter):
|
|
42
|
+
expression = "IS NULL" if predicate.operator == "is_null" else "IS NOT NULL"
|
|
43
|
+
else:
|
|
44
|
+
value = predicate.value
|
|
45
|
+
if isinstance(value, str):
|
|
46
|
+
if len(value) > 2048 or "\x00" in value:
|
|
47
|
+
raise ValueError("Filter value exceeds the supported text budget.")
|
|
48
|
+
literal = "'" + value.replace("'", "''") + "'"
|
|
49
|
+
elif isinstance(value, bool):
|
|
50
|
+
literal = "TRUE" if value else "FALSE"
|
|
51
|
+
else:
|
|
52
|
+
literal = str(value)
|
|
53
|
+
expression = f"{operators[predicate.operator]} {literal}"
|
|
54
|
+
predicates.append(f"{column} {expression}")
|
|
55
|
+
return " WHERE " + " AND ".join(predicates) if predicates else ""
|
|
@@ -32,7 +32,6 @@ Example:
|
|
|
32
32
|
|
|
33
33
|
from __future__ import annotations
|
|
34
34
|
|
|
35
|
-
import os
|
|
36
35
|
from typing import Any
|
|
37
36
|
|
|
38
37
|
from fastapi import HTTPException, Request
|
|
@@ -40,13 +39,16 @@ from fastapi import HTTPException, Request
|
|
|
40
39
|
from phlo.capabilities import (
|
|
41
40
|
AuthPrincipal,
|
|
42
41
|
AuthResult,
|
|
42
|
+
AuthenticatedSession,
|
|
43
43
|
AuthenticationProvider,
|
|
44
44
|
RequestContext,
|
|
45
45
|
list_capabilities,
|
|
46
46
|
resolve_capability,
|
|
47
47
|
)
|
|
48
48
|
from phlo.infrastructure.config import get_configured_authentication_provider_name
|
|
49
|
+
from phlo.config.process import get_process_settings
|
|
49
50
|
from phlo.logging import get_logger
|
|
51
|
+
from phlo.security.oidc_identity import OIDCVerificationUnavailable
|
|
50
52
|
|
|
51
53
|
logger = get_logger(__name__)
|
|
52
54
|
|
|
@@ -108,6 +110,10 @@ def create_request_context(request: Request) -> RequestContext:
|
|
|
108
110
|
headers_dict: dict[str, str] = {}
|
|
109
111
|
for key, value in request.headers.items():
|
|
110
112
|
headers_dict[key.lower()] = value
|
|
113
|
+
if "authorization" not in headers_dict:
|
|
114
|
+
access_token = headers_dict.get("x-auth-request-access-token", "")
|
|
115
|
+
if access_token and "\r" not in access_token and "\n" not in access_token:
|
|
116
|
+
headers_dict["authorization"] = f"Bearer {access_token}"
|
|
111
117
|
cookies_dict = dict(request.cookies)
|
|
112
118
|
query_params_dict = dict(request.query_params)
|
|
113
119
|
|
|
@@ -134,6 +140,12 @@ def authenticate_request(request: Request) -> AuthResult:
|
|
|
134
140
|
if hasattr(request.state, _AUTH_RESULT_CACHE_KEY):
|
|
135
141
|
return request.state[_AUTH_RESULT_CACHE_KEY]
|
|
136
142
|
|
|
143
|
+
managed_account = _authenticate_managed_service_account(request)
|
|
144
|
+
if managed_account is not None:
|
|
145
|
+
request.state[_AUTH_RESULT_CACHE_KEY] = managed_account
|
|
146
|
+
request.state[_AUTH_PRINCIPAL_CACHE_KEY] = managed_account.principal
|
|
147
|
+
return managed_account
|
|
148
|
+
|
|
137
149
|
provider = get_authentication_provider()
|
|
138
150
|
if provider is None:
|
|
139
151
|
result = AuthResult(
|
|
@@ -144,7 +156,13 @@ def authenticate_request(request: Request) -> AuthResult:
|
|
|
144
156
|
return result
|
|
145
157
|
|
|
146
158
|
request_context = create_request_context(request)
|
|
147
|
-
|
|
159
|
+
try:
|
|
160
|
+
result = provider.authenticate(request_context)
|
|
161
|
+
except OIDCVerificationUnavailable as exc:
|
|
162
|
+
raise HTTPException(
|
|
163
|
+
status_code=503,
|
|
164
|
+
detail={"error": "service_unavailable", "reason": "oidc_verification_unavailable"},
|
|
165
|
+
) from exc
|
|
148
166
|
request.state[_AUTH_RESULT_CACHE_KEY] = result
|
|
149
167
|
return result
|
|
150
168
|
|
|
@@ -158,17 +176,68 @@ def get_request_principal(request: Request) -> AuthPrincipal | None:
|
|
|
158
176
|
if hasattr(request.state, _AUTH_PRINCIPAL_CACHE_KEY):
|
|
159
177
|
return request.state[_AUTH_PRINCIPAL_CACHE_KEY]
|
|
160
178
|
|
|
179
|
+
managed_account = _authenticate_managed_service_account(request)
|
|
180
|
+
if managed_account is not None:
|
|
181
|
+
request.state[_AUTH_RESULT_CACHE_KEY] = managed_account
|
|
182
|
+
request.state[_AUTH_PRINCIPAL_CACHE_KEY] = managed_account.principal
|
|
183
|
+
return managed_account.principal
|
|
184
|
+
|
|
161
185
|
provider = get_authentication_provider()
|
|
162
186
|
if provider is None:
|
|
163
187
|
request.state[_AUTH_PRINCIPAL_CACHE_KEY] = None
|
|
164
188
|
return None
|
|
165
189
|
|
|
166
|
-
|
|
167
|
-
|
|
190
|
+
try:
|
|
191
|
+
principal = provider.current_principal(create_request_context(request))
|
|
192
|
+
except OIDCVerificationUnavailable as exc:
|
|
193
|
+
raise HTTPException(
|
|
194
|
+
status_code=503,
|
|
195
|
+
detail={"error": "service_unavailable", "reason": "oidc_verification_unavailable"},
|
|
196
|
+
) from exc
|
|
168
197
|
request.state[_AUTH_PRINCIPAL_CACHE_KEY] = principal
|
|
169
198
|
return principal
|
|
170
199
|
|
|
171
200
|
|
|
201
|
+
def _authenticate_managed_service_account(request: Request) -> AuthResult | None:
|
|
202
|
+
"""Authenticate a Phlo-issued service secret against its stored hash."""
|
|
203
|
+
if not get_process_settings().phlo_identity_authority_enabled:
|
|
204
|
+
return None
|
|
205
|
+
authorization = request.headers.get("authorization", "")
|
|
206
|
+
if not authorization.startswith("Bearer "):
|
|
207
|
+
return None
|
|
208
|
+
|
|
209
|
+
from phlo.identity.authority import IdentityAuthority
|
|
210
|
+
from phlo.plugins.observatory_settings import StorageUnavailableError
|
|
211
|
+
|
|
212
|
+
try:
|
|
213
|
+
matched = IdentityAuthority().authenticate_service_token(authorization[7:])
|
|
214
|
+
except StorageUnavailableError as exc:
|
|
215
|
+
raise HTTPException(
|
|
216
|
+
status_code=503,
|
|
217
|
+
detail={"error": "service_unavailable", "reason": "identity_authority_unavailable"},
|
|
218
|
+
) from exc
|
|
219
|
+
if matched is None:
|
|
220
|
+
return None
|
|
221
|
+
|
|
222
|
+
subject, name = matched
|
|
223
|
+
principal = AuthPrincipal(
|
|
224
|
+
subject=subject,
|
|
225
|
+
principal_type="service",
|
|
226
|
+
issuer="phlo-identity-authority",
|
|
227
|
+
attributes={"name": name, "authentication_source": "phlo-service-account"},
|
|
228
|
+
)
|
|
229
|
+
return AuthResult(
|
|
230
|
+
authenticated=True,
|
|
231
|
+
principal=principal,
|
|
232
|
+
session=AuthenticatedSession(
|
|
233
|
+
principal=principal,
|
|
234
|
+
auth_method="bearer_token",
|
|
235
|
+
provider_name="phlo_identity_authority",
|
|
236
|
+
),
|
|
237
|
+
reason_code="authenticated",
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
|
|
172
241
|
def require_principal(request: Request) -> AuthPrincipal:
|
|
173
242
|
"""Get the authenticated principal from the request or raise 401.
|
|
174
243
|
|
|
@@ -184,19 +253,7 @@ def require_principal(request: Request) -> AuthPrincipal:
|
|
|
184
253
|
detail={"error": "unauthorized", "reason": "no_auth_result"},
|
|
185
254
|
)
|
|
186
255
|
|
|
187
|
-
|
|
188
|
-
result = request.state[_AUTH_RESULT_CACHE_KEY]
|
|
189
|
-
else:
|
|
190
|
-
provider = get_authentication_provider()
|
|
191
|
-
if provider is None:
|
|
192
|
-
logger.warning("authentication_provider_not_configured")
|
|
193
|
-
raise HTTPException(
|
|
194
|
-
status_code=401,
|
|
195
|
-
detail={"error": "unauthorized", "reason": "provider_unavailable"},
|
|
196
|
-
)
|
|
197
|
-
request_context = create_request_context(request)
|
|
198
|
-
result = provider.authenticate(request_context)
|
|
199
|
-
request.state[_AUTH_RESULT_CACHE_KEY] = result
|
|
256
|
+
result = authenticate_request(request)
|
|
200
257
|
|
|
201
258
|
if not result.authenticated:
|
|
202
259
|
logger.warning(
|
|
@@ -229,8 +286,13 @@ def optional_authenticate(request: Request) -> AuthPrincipal | None:
|
|
|
229
286
|
if provider is None:
|
|
230
287
|
return None
|
|
231
288
|
|
|
232
|
-
|
|
233
|
-
|
|
289
|
+
try:
|
|
290
|
+
result = provider.authenticate(create_request_context(request))
|
|
291
|
+
except OIDCVerificationUnavailable as exc:
|
|
292
|
+
raise HTTPException(
|
|
293
|
+
status_code=503,
|
|
294
|
+
detail={"error": "service_unavailable", "reason": "oidc_verification_unavailable"},
|
|
295
|
+
) from exc
|
|
234
296
|
|
|
235
297
|
if result.authenticated and result.principal is not None:
|
|
236
298
|
return result.principal
|
|
@@ -241,7 +303,7 @@ def optional_authenticate(request: Request) -> AuthPrincipal | None:
|
|
|
241
303
|
def get_capabilities_metadata() -> dict[str, Any]:
|
|
242
304
|
"""Get metadata about available authentication capabilities."""
|
|
243
305
|
available_providers = list_capabilities("authentication_provider")
|
|
244
|
-
current_provider =
|
|
306
|
+
current_provider = get_process_settings().phlo_authentication_provider
|
|
245
307
|
|
|
246
308
|
return {
|
|
247
309
|
"available_providers": available_providers,
|
|
@@ -32,6 +32,7 @@ from phlo.cli.commands.workflow import (
|
|
|
32
32
|
_validate_workflow_file,
|
|
33
33
|
)
|
|
34
34
|
from phlo.cli.templates.registry import list_templates as list_project_templates
|
|
35
|
+
from phlo.config.process import get_process_settings
|
|
35
36
|
from phlo.workflow_authoring import WorkflowAuthoringError, create_workflow_with_provider
|
|
36
37
|
|
|
37
38
|
router = APIRouter(tags=["authoring"])
|
|
@@ -58,7 +59,7 @@ class PathValidationRequest(BaseModel):
|
|
|
58
59
|
|
|
59
60
|
|
|
60
61
|
def _project_root() -> Path:
|
|
61
|
-
return Path(
|
|
62
|
+
return Path(get_process_settings().get("PHLO_PROJECT_PATH", ".")).resolve()
|
|
62
63
|
|
|
63
64
|
|
|
64
65
|
def _resolve_project_path(path: str) -> Path:
|
|
@@ -96,6 +97,24 @@ def create_workflow(request: CreateWorkflowRequest, http_request: Request) -> di
|
|
|
96
97
|
"""Create a workflow scaffold in the current project."""
|
|
97
98
|
auth = require_scope(http_request, "project:write")
|
|
98
99
|
enforce_rate_limit(auth["subject"], "create_workflow")
|
|
100
|
+
return replay_or_execute(
|
|
101
|
+
idempotency_key=None,
|
|
102
|
+
operation="create_workflow",
|
|
103
|
+
target=f"{request.domain}/{request.table}",
|
|
104
|
+
execute=lambda: _create_workflow_files(request, auth),
|
|
105
|
+
audit=lambda response: audit_operation(
|
|
106
|
+
operation="create_workflow",
|
|
107
|
+
target=f"{request.domain}/{request.table}",
|
|
108
|
+
dry_run=False,
|
|
109
|
+
auth=auth,
|
|
110
|
+
payload=request.model_dump(mode="json"),
|
|
111
|
+
result=response,
|
|
112
|
+
),
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _create_workflow_files(request: CreateWorkflowRequest, auth: dict[str, Any]) -> dict[str, Any]:
|
|
117
|
+
"""Create files only after operation controls have claimed the target."""
|
|
99
118
|
try:
|
|
100
119
|
result = create_workflow_with_provider(
|
|
101
120
|
project_root=_project_root(),
|
|
@@ -140,7 +159,7 @@ def create_workflow(request: CreateWorkflowRequest, http_request: Request) -> di
|
|
|
140
159
|
result=payload,
|
|
141
160
|
)
|
|
142
161
|
raise HTTPException(status_code=422, detail=payload) from exc
|
|
143
|
-
|
|
162
|
+
return {
|
|
144
163
|
"workflow_type": result.workflow_type,
|
|
145
164
|
"provider": result.provider,
|
|
146
165
|
"domain": result.domain,
|
|
@@ -149,20 +168,6 @@ def create_workflow(request: CreateWorkflowRequest, http_request: Request) -> di
|
|
|
149
168
|
"next_steps": result.next_steps,
|
|
150
169
|
"metadata": result.metadata,
|
|
151
170
|
}
|
|
152
|
-
return replay_or_execute(
|
|
153
|
-
idempotency_key=None,
|
|
154
|
-
operation="create_workflow",
|
|
155
|
-
target=f"{request.domain}/{request.table}",
|
|
156
|
-
execute=lambda: payload,
|
|
157
|
-
audit=lambda response: audit_operation(
|
|
158
|
-
operation="create_workflow",
|
|
159
|
-
target=f"{request.domain}/{request.table}",
|
|
160
|
-
dry_run=False,
|
|
161
|
-
auth=auth,
|
|
162
|
-
payload=request.model_dump(mode="json"),
|
|
163
|
-
result=response,
|
|
164
|
-
),
|
|
165
|
-
)
|
|
166
171
|
|
|
167
172
|
|
|
168
173
|
@router.post("/workflows/validate")
|
|
@@ -37,7 +37,6 @@ Example:
|
|
|
37
37
|
|
|
38
38
|
from __future__ import annotations
|
|
39
39
|
|
|
40
|
-
import os
|
|
41
40
|
from uuid import uuid4
|
|
42
41
|
from typing import Any, Callable, TypeVar
|
|
43
42
|
|
|
@@ -54,6 +53,7 @@ from phlo.capabilities import (
|
|
|
54
53
|
resolve_capability,
|
|
55
54
|
)
|
|
56
55
|
from phlo.logging import get_logger
|
|
56
|
+
from phlo.config.process import get_process_settings
|
|
57
57
|
from phlo.security import enforce, is_regulated
|
|
58
58
|
from phlo.security.mode import requires_http_authorization
|
|
59
59
|
from phlo.infrastructure.config import (
|
|
@@ -136,7 +136,7 @@ def get_authorization_mode() -> str:
|
|
|
136
136
|
when production HTTP authorization is required (ADR 0047) and to
|
|
137
137
|
``optional`` otherwise, so development stays opt-in.
|
|
138
138
|
"""
|
|
139
|
-
configured_mode =
|
|
139
|
+
configured_mode = get_process_settings().phlo_authorization_mode
|
|
140
140
|
if configured_mode is not None:
|
|
141
141
|
configured_mode = configured_mode.strip() or None
|
|
142
142
|
if configured_mode is None:
|
|
@@ -24,19 +24,17 @@ The vocabulary is explain > confirm > act > verify:
|
|
|
24
24
|
|
|
25
25
|
from __future__ import annotations
|
|
26
26
|
|
|
27
|
-
import os
|
|
28
27
|
from pathlib import Path
|
|
29
28
|
from typing import Any
|
|
30
29
|
|
|
31
30
|
from fastapi import APIRouter, HTTPException, Request
|
|
32
|
-
from pydantic import BaseModel
|
|
33
|
-
|
|
34
31
|
from phlo.capabilities.continuity import (
|
|
35
32
|
BACKUP_PROVIDER_ORDER,
|
|
36
33
|
RestoreTarget,
|
|
37
34
|
canonical_json_bytes,
|
|
38
35
|
sha256_bytes,
|
|
39
36
|
)
|
|
37
|
+
from phlo.config.process import get_process_settings
|
|
40
38
|
from phlo.operations.backup import create_backup_set, default_backup_contributors
|
|
41
39
|
from phlo.operations.journal import (
|
|
42
40
|
OperationJournalError,
|
|
@@ -62,12 +60,16 @@ from phlo.operations.upgrade import (
|
|
|
62
60
|
upgrade_apply,
|
|
63
61
|
upgrade_operation_id,
|
|
64
62
|
)
|
|
63
|
+
from pydantic import BaseModel
|
|
64
|
+
|
|
65
65
|
from phlo_api.api.operation_controls import (
|
|
66
|
+
IdempotencyConflict,
|
|
66
67
|
audit_operation,
|
|
67
68
|
enforce_rate_limit,
|
|
68
69
|
idempotency_key_target,
|
|
69
|
-
require_scope,
|
|
70
70
|
replay_or_execute,
|
|
71
|
+
require_scope,
|
|
72
|
+
shared_operation_controls,
|
|
71
73
|
)
|
|
72
74
|
|
|
73
75
|
router = APIRouter(tags=["continuity"])
|
|
@@ -171,15 +173,19 @@ class ContinuityApplyRequest(BaseModel):
|
|
|
171
173
|
# --- shared guards ----------------------------------------------------------
|
|
172
174
|
|
|
173
175
|
|
|
174
|
-
def _durable_journal() ->
|
|
176
|
+
def _durable_journal() -> OperationJournalStore:
|
|
175
177
|
"""Resolve the configured durable journal; fail closed when none is present.
|
|
176
178
|
|
|
177
179
|
An authorized mutation must never silently fall back to an ephemeral
|
|
178
180
|
in-memory journal, or the exactly-once contract disappears with the
|
|
179
|
-
process.
|
|
180
|
-
|
|
181
|
+
process. Shared API controls own the journal in PostgreSQL when configured.
|
|
182
|
+
Local mode uses the CLI's file journal; do not run file-backed CLI operations
|
|
183
|
+
concurrently with shared-store API operations on the same target.
|
|
181
184
|
"""
|
|
182
|
-
|
|
185
|
+
shared = shared_operation_controls()
|
|
186
|
+
if shared is not None:
|
|
187
|
+
return shared
|
|
188
|
+
directory = get_process_settings().phlo_operations_journal_dir
|
|
183
189
|
if not directory:
|
|
184
190
|
raise HTTPException(
|
|
185
191
|
status_code=503,
|
|
@@ -236,8 +242,8 @@ def _parsed_plan(plan: dict[str, Any] | None, cls: type[RestorePlan] | type[Upgr
|
|
|
236
242
|
|
|
237
243
|
|
|
238
244
|
def _maintenance_executor(operation: str) -> Any:
|
|
245
|
+
from phlo.application.discovery import discover_capabilities
|
|
239
246
|
from phlo.capabilities import resolve_capability
|
|
240
|
-
from phlo.capabilities.discovery import discover_capabilities
|
|
241
247
|
|
|
242
248
|
discover_capabilities()
|
|
243
249
|
resolution = resolve_capability("maintenance_executor", operation)
|
|
@@ -488,6 +494,7 @@ def post_continuity_apply(request: ContinuityApplyRequest, http_request: Request
|
|
|
488
494
|
idempotency_key=request.idempotency_key,
|
|
489
495
|
operation=operation,
|
|
490
496
|
target=target,
|
|
497
|
+
exclusion_target=target,
|
|
491
498
|
execute=execute,
|
|
492
499
|
audit=lambda result: audit_operation(
|
|
493
500
|
operation=operation,
|
|
@@ -498,6 +505,15 @@ def post_continuity_apply(request: ContinuityApplyRequest, http_request: Request
|
|
|
498
505
|
result=result,
|
|
499
506
|
),
|
|
500
507
|
)
|
|
508
|
+
except IdempotencyConflict as exc:
|
|
509
|
+
if isinstance(exc.detail, dict) and exc.detail.get("error") in {
|
|
510
|
+
"operation_pending",
|
|
511
|
+
"operation_unknown",
|
|
512
|
+
}:
|
|
513
|
+
raise _error(409, "conflicting_claim", (target,)) from exc
|
|
514
|
+
if isinstance(exc.detail, dict) and exc.detail.get("error") == "target_mismatch":
|
|
515
|
+
raise _error(409, "idempotency_key_conflict", (target,)) from exc
|
|
516
|
+
raise
|
|
501
517
|
except OperationJournalError as exc:
|
|
502
518
|
raise _continuity_error(exc) from exc
|
|
503
519
|
except (RestoreError, UpgradeError) as exc:
|
|
@@ -40,17 +40,18 @@ Example:
|
|
|
40
40
|
|
|
41
41
|
from __future__ import annotations
|
|
42
42
|
|
|
43
|
-
import os
|
|
44
43
|
from datetime import datetime
|
|
45
44
|
from typing import Any
|
|
46
45
|
|
|
47
46
|
from fastapi import APIRouter
|
|
48
47
|
from fastapi.responses import PlainTextResponse
|
|
49
|
-
from
|
|
50
|
-
|
|
48
|
+
from phlo.application.discovery import discover_capabilities
|
|
51
49
|
from phlo.capabilities import MaintenanceReadModel, list_capabilities, resolve_capability
|
|
52
|
-
from phlo.capabilities.discovery import discover_capabilities
|
|
53
50
|
from phlo.logging import get_logger
|
|
51
|
+
from pydantic import BaseModel
|
|
52
|
+
|
|
53
|
+
from phlo_api.errors import BackendUnavailableError
|
|
54
|
+
from phlo_api.settings import get_process_settings
|
|
54
55
|
|
|
55
56
|
logger = get_logger(__name__)
|
|
56
57
|
|
|
@@ -61,7 +62,7 @@ _DEFAULT_READ_MODEL_ENV = "PHLO_MAINTENANCE_READ_MODEL"
|
|
|
61
62
|
def _resolve_maintenance_read_model() -> MaintenanceReadModel:
|
|
62
63
|
"""Resolve the configured maintenance read-model capability."""
|
|
63
64
|
discover_capabilities()
|
|
64
|
-
name =
|
|
65
|
+
name = get_process_settings().phlo_maintenance_read_model
|
|
65
66
|
resolution = resolve_capability("maintenance_read_model", name)
|
|
66
67
|
if resolution is None:
|
|
67
68
|
available = list_capabilities("maintenance_read_model")
|
|
@@ -108,8 +109,8 @@ class MaintenanceStatusSnapshot(BaseModel):
|
|
|
108
109
|
operations: list[MaintenanceOperationStatus]
|
|
109
110
|
|
|
110
111
|
|
|
111
|
-
@router.get("/status", response_model=MaintenanceStatusSnapshot
|
|
112
|
-
def get_maintenance_status() -> MaintenanceStatusSnapshot
|
|
112
|
+
@router.get("/status", response_model=MaintenanceStatusSnapshot)
|
|
113
|
+
def get_maintenance_status() -> MaintenanceStatusSnapshot:
|
|
113
114
|
"""Get maintenance status snapshot from the read model."""
|
|
114
115
|
try:
|
|
115
116
|
snapshot = _resolve_maintenance_read_model().load_maintenance_status()
|
|
@@ -117,7 +118,7 @@ def get_maintenance_status() -> MaintenanceStatusSnapshot | dict[str, str]:
|
|
|
117
118
|
return _serialize_snapshot(snapshot)
|
|
118
119
|
except Exception as exc:
|
|
119
120
|
logger.exception("maintenance_status_load_failed")
|
|
120
|
-
|
|
121
|
+
raise BackendUnavailableError("Maintenance read model is unavailable.") from exc
|
|
121
122
|
|
|
122
123
|
|
|
123
124
|
@router.get("/metrics", response_class=PlainTextResponse)
|
|
@@ -129,7 +130,7 @@ def get_maintenance_metrics() -> PlainTextResponse:
|
|
|
129
130
|
return PlainTextResponse(metrics_payload)
|
|
130
131
|
except Exception as exc:
|
|
131
132
|
logger.exception("maintenance_metrics_render_failed")
|
|
132
|
-
|
|
133
|
+
raise BackendUnavailableError("Maintenance read model is unavailable.") from exc
|
|
133
134
|
|
|
134
135
|
|
|
135
136
|
def _serialize_snapshot(snapshot: Any) -> MaintenanceStatusSnapshot:
|