lcp-reference-platform 1.1.0__tar.gz → 1.2.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.
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/.gitignore +3 -1
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/PKG-INFO +1 -1
- lcp_reference_platform-1.2.0/lcp_platform/__init__.py +45 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/config.py +108 -2
- lcp_reference_platform-1.2.0/lcp_platform/database.py +30 -0
- lcp_reference_platform-1.2.0/lcp_platform/doctor.py +1045 -0
- lcp_reference_platform-1.2.0/lcp_platform/matching.py +894 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/messages.py +57 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/postgres.py +28 -2
- lcp_reference_platform-1.2.0/lcp_platform/router.py +4921 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/service.py +152 -14
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/storage.py +1733 -13
- lcp_reference_platform-1.2.0/lcp_platform/validation.py +1067 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/pyproject.toml +2 -1
- lcp_reference_platform-1.2.0/tests/conftest.py +15 -0
- lcp_reference_platform-1.2.0/tests/test_batch_submission.py +472 -0
- lcp_reference_platform-1.2.0/tests/test_doctor.py +325 -0
- lcp_reference_platform-1.2.0/tests/test_entry_emission.py +211 -0
- lcp_reference_platform-1.2.0/tests/test_event_subscriptions.py +668 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_gap_intake_error_codes.py +6 -5
- lcp_reference_platform-1.2.0/tests/test_negotiation.py +818 -0
- lcp_reference_platform-1.2.0/tests/test_pii_classes.py +236 -0
- lcp_reference_platform-1.2.0/tests/test_post_response_deadline.py +187 -0
- lcp_reference_platform-1.2.0/tests/test_requirement_profiles.py +677 -0
- lcp_reference_platform-1.2.0/tests/test_retention_archive.py +625 -0
- lcp_reference_platform-1.2.0/tests/test_v12_contract.py +603 -0
- lcp_reference_platform-1.1.0/lcp_platform/__init__.py +0 -17
- lcp_reference_platform-1.1.0/lcp_platform/database.py +0 -18
- lcp_reference_platform-1.1.0/lcp_platform/matching.py +0 -198
- lcp_reference_platform-1.1.0/lcp_platform/router.py +0 -2303
- lcp_reference_platform-1.1.0/lcp_platform/validation.py +0 -212
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/Dockerfile +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/README.md +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/docker-compose.yml +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/kubernetes/README.md +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/kubernetes/configmap.yaml +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/kubernetes/deployment.yaml +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/kubernetes/hpa.example.yaml +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/kubernetes/network-policy.example.yaml +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/kubernetes/pod-disruption-budget.yaml +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/kubernetes/pvc.example.yaml +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/kubernetes/secret.example.yaml +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/kubernetes/service.yaml +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/kubernetes/tests/verify-images/README.md +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/kubernetes/tests/verify-images/kyverno-test.yaml +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/kubernetes/tests/verify-images/provenance-policy.yaml +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/kubernetes/tests/verify-images/resources.yaml +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/kubernetes/tests/verify-images/sbom-policy.yaml +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/kubernetes/tests/verify-images/signature-policy.yaml +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/kubernetes/verify-images-kyverno.example.yaml +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/admin.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/api_keys.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/attachments.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/attestation.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/auth.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/crypto.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/extensions.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/history.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/mapping.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/observability.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/offer_extensions.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/pii.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/secrets.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/security.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/server.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/worker.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/lcp_platform/wsgi.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_adversarial_e2e.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_api_keys.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_attestation_resolver.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_attestation_verification.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_auth_code_assignment.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_event_details_pii.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_event_final_pricing.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_gap_compliance_lifecycle_offers.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_gap_enum_message.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_gap_errors_caps.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_gap_security.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_history_surface.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_lead_extensions.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_new_flows.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_offer_extensions.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_phase0_advertisement.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_platform.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_postgres_integration.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_pricing_duplicate_resub.py +0 -0
- {lcp_reference_platform-1.1.0 → lcp_reference_platform-1.2.0}/tests/test_wsgi.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: lcp-reference-platform
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: Production-oriented reference platform and router for LCP Lead Context Protocol deployments.
|
|
5
5
|
Project-URL: Documentation, https://github.com/SpearSystems/LCP
|
|
6
6
|
Project-URL: Source, https://github.com/SpearSystems/LCP
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Production-oriented reference LCP platform.
|
|
2
|
+
|
|
3
|
+
Public names are resolved lazily so importing a submodule (for example
|
|
4
|
+
``lcp_platform.matching`` from a benchmark) does not pull the HTTP, storage,
|
|
5
|
+
and crypto stack at package-import time.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from importlib import import_module
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
_EXPORTS = {
|
|
14
|
+
"MappingError": "mapping",
|
|
15
|
+
"MappingRegistry": "mapping",
|
|
16
|
+
"PublisherNormalizer": "mapping",
|
|
17
|
+
"Platform": "router",
|
|
18
|
+
"RequestError": "router",
|
|
19
|
+
"PlatformConfig": "config",
|
|
20
|
+
"PlatformService": "service",
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"MappingError",
|
|
25
|
+
"MappingRegistry",
|
|
26
|
+
"Platform",
|
|
27
|
+
"PlatformConfig",
|
|
28
|
+
"PlatformService",
|
|
29
|
+
"PublisherNormalizer",
|
|
30
|
+
"RequestError",
|
|
31
|
+
]
|
|
32
|
+
__version__ = "1.0.2"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def __getattr__(name: str) -> Any:
|
|
36
|
+
module = _EXPORTS.get(name)
|
|
37
|
+
if module is not None:
|
|
38
|
+
return getattr(import_module(f".{module}", __name__), name)
|
|
39
|
+
if name.startswith("_"):
|
|
40
|
+
raise AttributeError(name)
|
|
41
|
+
# ``from lcp_platform import attestation`` still resolves the submodule.
|
|
42
|
+
try:
|
|
43
|
+
return import_module(f".{name}", __name__)
|
|
44
|
+
except ModuleNotFoundError as exc:
|
|
45
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") from exc
|
|
@@ -22,6 +22,14 @@ def _csv(name: str, default: str = "") -> tuple[str, ...]:
|
|
|
22
22
|
)
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
# W4-03: datasets ship in the repository's ``data/service-areas`` directory.
|
|
26
|
+
# A missing directory yields an empty catalog, so a reference fails closed with
|
|
27
|
+
# ``service_area_unknown`` rather than matching everything.
|
|
28
|
+
_DEFAULT_SERVICE_AREA_DIRECTORY = (
|
|
29
|
+
Path(__file__).resolve().parents[3] / "data" / "service-areas"
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
25
33
|
@dataclass(frozen=True)
|
|
26
34
|
class PlatformConfig:
|
|
27
35
|
database_path: Path
|
|
@@ -36,6 +44,9 @@ class PlatformConfig:
|
|
|
36
44
|
require_auth: bool = True
|
|
37
45
|
replay_window_seconds: int = 300
|
|
38
46
|
webhook_timeout_seconds: float = 10.0
|
|
47
|
+
# SPEC §9: the window a consumer has to acknowledge a delivered post
|
|
48
|
+
# before the lead expires. Separate from the HTTP read timeout above.
|
|
49
|
+
post_response_timeout_seconds: float = 30.0
|
|
39
50
|
max_delivery_attempts: int = 5
|
|
40
51
|
worker_interval_seconds: float = 1.0
|
|
41
52
|
max_body_bytes: int = 2_000_000
|
|
@@ -46,12 +57,66 @@ class PlatformConfig:
|
|
|
46
57
|
# ceiling stays the transport body cap above, so a larger value here is
|
|
47
58
|
# redundant rather than unsafe.
|
|
48
59
|
max_extension_bytes: int = 32_768
|
|
60
|
+
# D7/v1.2: an FX rate older than this (seconds) makes a cross-currency
|
|
61
|
+
# offer NON-COMPARABLE in the auction. The default matches the decision
|
|
62
|
+
# record; never compare with a guessed rate.
|
|
63
|
+
fx_max_age_seconds: int = 300
|
|
64
|
+
# W4-03: versioned service-area datasets (countries/regions/postal codes)
|
|
65
|
+
# are loaded from this directory and cached until a file changes.
|
|
66
|
+
service_area_directory: Path = _DEFAULT_SERVICE_AREA_DIRECTORY
|
|
67
|
+
# I8/W4-02: the match audit record (profile id+version and one entry per
|
|
68
|
+
# predicate) is retention bounded like decision history. The worker purges
|
|
69
|
+
# rows older than this many days.
|
|
70
|
+
match_audit_retention_days: int = 90
|
|
71
|
+
# W4-06: encrypted envelope ciphertext (leads, pings, bids, lifecycle
|
|
72
|
+
# events, terminal deliveries) is redacted by the retention sweep once the
|
|
73
|
+
# row is older than this many days. The row survives for accounting; the
|
|
74
|
+
# payload does not.
|
|
75
|
+
envelope_retention_days: int = 90
|
|
76
|
+
# W4-06: decision/history rows (match_decisions, match_audits,
|
|
77
|
+
# audit_events) are unreadable past this many days and deleted by the same
|
|
78
|
+
# sweep.
|
|
79
|
+
history_retention_days: int = 365
|
|
80
|
+
# W4-05: history/decision/audit writes are handed to a bounded queue and
|
|
81
|
+
# flushed by the worker, so intake never blocks on the audit trail. See
|
|
82
|
+
# ``Store.enqueue_history`` for the saturation policy.
|
|
83
|
+
history_queue_capacity: int = 1_024
|
|
49
84
|
max_header_bytes: int = 16_384
|
|
50
85
|
max_webhook_response_bytes: int = 262_144
|
|
51
86
|
rate_limit_per_minute: int = 600
|
|
52
87
|
allow_insecure_webhooks: bool = False
|
|
53
88
|
webhook_host_allowlist: tuple[str, ...] = ()
|
|
54
89
|
test_mode: bool = False
|
|
90
|
+
# LEP-0001 compensating constraint 2: batch submission ships OFF by
|
|
91
|
+
# default. Off means no `features.batch` advertisement and no intake — the
|
|
92
|
+
# route answers exactly like an endpoint this build does not have.
|
|
93
|
+
feature_batch: bool = False
|
|
94
|
+
# LEP-0009 C3: the negotiation surface (`quote`/`counter`, token minting
|
|
95
|
+
# and redemption, the `features.negotiation` advertisement) ships OFF by
|
|
96
|
+
# default. Off means no advertisement, no intake, and no state written —
|
|
97
|
+
# the routes answer exactly like an endpoint this build does not have.
|
|
98
|
+
feature_negotiation: bool = False
|
|
99
|
+
# LEP-0001 W3: event subscriptions (registration, signed at-least-once
|
|
100
|
+
# delivery, cursor replay) ship OFF by default. Off means no
|
|
101
|
+
# `features.event_subscriptions` advertisement, no registration or read
|
|
102
|
+
# routes, and no event-stream writes — the routes answer exactly like an
|
|
103
|
+
# endpoint this build does not have.
|
|
104
|
+
feature_events: bool = False
|
|
105
|
+
# LEP-0003 W6-07 (§9-gated): email/form-relay entry emission. OFF by
|
|
106
|
+
# default. Off means no `features.email_form_entry` advertisement, and a
|
|
107
|
+
# lead from a declared relay publisher that carries no client capture is
|
|
108
|
+
# REFUSED rather than recorded under a `source_type` the platform did not
|
|
109
|
+
# observe — fail closed, never a fabricated provenance.
|
|
110
|
+
feature_email_form_entry: bool = False
|
|
111
|
+
# The entry-surface declaration: sender ids whose leads arrive through an
|
|
112
|
+
# email/form relay. Only these can receive a platform-recorded entry, so an
|
|
113
|
+
# empty list keeps intake bit-for-bit v1.2 whatever the flag says.
|
|
114
|
+
email_form_publisher_ids: tuple[str, ...] = ()
|
|
115
|
+
# LEP-0001 W3-03 / I8: the event stream and its cursors are retention
|
|
116
|
+
# bounded. A cursor older than this is refused with an explicit error;
|
|
117
|
+
# stream rows past the same bound are purged by the worker. The default
|
|
118
|
+
# (24 h) matches the Phase 4 retention work item's starting bound.
|
|
119
|
+
event_cursor_ttl_seconds: int = 86_400
|
|
55
120
|
# LEP-0008 agent attestation verification (§4/§5/§7): "observe" verifies and
|
|
56
121
|
# audits but still accepts (Rollout Phase 2); "enforce" (default at ship)
|
|
57
122
|
# rejects on any §5 failure. Skew cap <= 30 s is a §7 configuration-time
|
|
@@ -95,12 +160,26 @@ class PlatformConfig:
|
|
|
95
160
|
attachment_clamav_port: int = 3310
|
|
96
161
|
|
|
97
162
|
def __post_init__(self) -> None:
|
|
163
|
+
if self.post_response_timeout_seconds <= 0:
|
|
164
|
+
raise ValueError("The post response timeout must be positive")
|
|
98
165
|
if self.max_body_bytes <= 0 or self.max_header_bytes <= 0:
|
|
99
166
|
raise ValueError("Request size limits must be positive")
|
|
100
167
|
if self.max_extension_bytes <= 0:
|
|
101
168
|
# The bound is a policy target, not a transport rule: a value above
|
|
102
169
|
# max_body_bytes is unreachable, never unsafe, so it is not refused.
|
|
103
170
|
raise ValueError("The extensions policy bound must be positive")
|
|
171
|
+
if self.fx_max_age_seconds <= 0:
|
|
172
|
+
raise ValueError("LCP_FX_MAX_AGE_SECONDS must be positive")
|
|
173
|
+
if self.match_audit_retention_days <= 0:
|
|
174
|
+
raise ValueError("LCP_MATCH_AUDIT_RETENTION_DAYS must be positive")
|
|
175
|
+
if self.envelope_retention_days <= 0:
|
|
176
|
+
raise ValueError("LCP_ENVELOPE_RETENTION_DAYS must be positive")
|
|
177
|
+
if self.history_retention_days <= 0:
|
|
178
|
+
raise ValueError("LCP_HISTORY_RETENTION_DAYS must be positive")
|
|
179
|
+
if self.history_queue_capacity <= 0:
|
|
180
|
+
raise ValueError("LCP_HISTORY_QUEUE_CAPACITY must be positive")
|
|
181
|
+
if self.event_cursor_ttl_seconds <= 0:
|
|
182
|
+
raise ValueError("LCP_EVENT_CURSOR_TTL_SECONDS must be positive")
|
|
104
183
|
if self.max_webhook_response_bytes <= 0:
|
|
105
184
|
raise ValueError("Webhook response limit must be positive")
|
|
106
185
|
if self.max_attachment_bytes <= 0:
|
|
@@ -192,13 +271,32 @@ class PlatformConfig:
|
|
|
192
271
|
webhook_timeout_seconds=float(
|
|
193
272
|
os.environ.get("LCP_WEBHOOK_TIMEOUT_SECONDS", "10")
|
|
194
273
|
),
|
|
274
|
+
post_response_timeout_seconds=float(
|
|
275
|
+
os.environ.get("LCP_POST_RESPONSE_TIMEOUT_SECONDS", "30")
|
|
276
|
+
),
|
|
195
277
|
max_delivery_attempts=int(os.environ.get("LCP_MAX_DELIVERY_ATTEMPTS", "5")),
|
|
196
278
|
worker_interval_seconds=float(
|
|
197
279
|
os.environ.get("LCP_WORKER_INTERVAL_SECONDS", "1")
|
|
198
280
|
),
|
|
199
281
|
max_body_bytes=int(os.environ.get("LCP_MAX_BODY_BYTES", "2000000")),
|
|
200
|
-
max_extension_bytes=int(
|
|
201
|
-
|
|
282
|
+
max_extension_bytes=int(os.environ.get("LCP_MAX_EXTENSION_BYTES", "32768")),
|
|
283
|
+
fx_max_age_seconds=int(os.environ.get("LCP_FX_MAX_AGE_SECONDS", "300")),
|
|
284
|
+
service_area_directory=Path(
|
|
285
|
+
os.environ.get(
|
|
286
|
+
"LCP_SERVICE_AREA_DIRECTORY", str(_DEFAULT_SERVICE_AREA_DIRECTORY)
|
|
287
|
+
)
|
|
288
|
+
),
|
|
289
|
+
match_audit_retention_days=int(
|
|
290
|
+
os.environ.get("LCP_MATCH_AUDIT_RETENTION_DAYS", "90")
|
|
291
|
+
),
|
|
292
|
+
envelope_retention_days=int(
|
|
293
|
+
os.environ.get("LCP_ENVELOPE_RETENTION_DAYS", "90")
|
|
294
|
+
),
|
|
295
|
+
history_retention_days=int(
|
|
296
|
+
os.environ.get("LCP_HISTORY_RETENTION_DAYS", "365")
|
|
297
|
+
),
|
|
298
|
+
history_queue_capacity=int(
|
|
299
|
+
os.environ.get("LCP_HISTORY_QUEUE_CAPACITY", "1024")
|
|
202
300
|
),
|
|
203
301
|
max_header_bytes=int(os.environ.get("LCP_MAX_HEADER_BYTES", "16384")),
|
|
204
302
|
max_webhook_response_bytes=int(
|
|
@@ -210,6 +308,14 @@ class PlatformConfig:
|
|
|
210
308
|
allow_insecure_webhooks=_bool("LCP_ALLOW_INSECURE_WEBHOOKS", False),
|
|
211
309
|
webhook_host_allowlist=_csv("LCP_WEBHOOK_HOST_ALLOWLIST"),
|
|
212
310
|
test_mode=_bool("LCP_TEST_MODE", False),
|
|
311
|
+
feature_batch=_bool("LCP_FEATURE_BATCH", False),
|
|
312
|
+
feature_negotiation=_bool("LCP_FEATURE_NEGOTIATION", False),
|
|
313
|
+
feature_events=_bool("LCP_FEATURE_EVENTS", False),
|
|
314
|
+
feature_email_form_entry=_bool("LCP_FEATURE_EMAIL_FORM_ENTRY", False),
|
|
315
|
+
email_form_publisher_ids=_csv("LCP_EMAIL_FORM_PUBLISHER_IDS"),
|
|
316
|
+
event_cursor_ttl_seconds=int(
|
|
317
|
+
os.environ.get("LCP_EVENT_CURSOR_TTL_SECONDS", "86400")
|
|
318
|
+
),
|
|
213
319
|
attestation_mode=os.environ.get("LCP_ATTESTATION_MODE", "enforce").lower(),
|
|
214
320
|
attestation_clock_skew_seconds=int(
|
|
215
321
|
os.environ.get("LCP_ATTESTATION_CLOCK_SKEW_SECONDS", "0")
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Database backend selection."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from .config import PlatformConfig
|
|
8
|
+
from .storage import Store
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def create_store(config: PlatformConfig) -> Any:
|
|
12
|
+
# W4-05/W4-06: the deferred-write queue and both retention windows are
|
|
13
|
+
# store state, so the backend choice cannot change their meaning.
|
|
14
|
+
if config.database_url:
|
|
15
|
+
from .postgres import PostgresStore
|
|
16
|
+
|
|
17
|
+
return PostgresStore(
|
|
18
|
+
config.database_url,
|
|
19
|
+
pii_encryption_key=config.pii_encryption_key,
|
|
20
|
+
history_queue_capacity=config.history_queue_capacity,
|
|
21
|
+
envelope_retention_days=config.envelope_retention_days,
|
|
22
|
+
history_retention_days=config.history_retention_days,
|
|
23
|
+
)
|
|
24
|
+
return Store(
|
|
25
|
+
config.database_path,
|
|
26
|
+
pii_encryption_key=config.pii_encryption_key,
|
|
27
|
+
history_queue_capacity=config.history_queue_capacity,
|
|
28
|
+
envelope_retention_days=config.envelope_retention_days,
|
|
29
|
+
history_retention_days=config.history_retention_days,
|
|
30
|
+
)
|