socialcli 0.3.0__py3-none-any.whl
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.
Potentially problematic release.
This version of socialcli might be problematic. Click here for more details.
- socialcli-0.3.0.dist-info/METADATA +168 -0
- socialcli-0.3.0.dist-info/RECORD +224 -0
- socialcli-0.3.0.dist-info/WHEEL +4 -0
- socialcli-0.3.0.dist-info/entry_points.txt +3 -0
- socialcli-0.3.0.dist-info/licenses/LICENSE +21 -0
- socialctl/__init__.py +0 -0
- socialctl/__main__.py +6 -0
- socialctl/adapters/__init__.py +6 -0
- socialctl/adapters/base.py +68 -0
- socialctl/adapters/errores.py +56 -0
- socialctl/adapters/facebook.py +180 -0
- socialctl/adapters/instagram.py +442 -0
- socialctl/adapters/tiktok.py +535 -0
- socialctl/adapters/youtube.py +331 -0
- socialctl/agent_errors.py +176 -0
- socialctl/agent_guide.py +23 -0
- socialctl/approval_cli.py +27 -0
- socialctl/auth.py +139 -0
- socialctl/authflow.py +344 -0
- socialctl/brands.py +194 -0
- socialctl/capabilities.py +57 -0
- socialctl/capabilities.yml +5945 -0
- socialctl/cli.py +1766 -0
- socialctl/connection_service/__init__.py +0 -0
- socialctl/connection_service/__main__.py +33 -0
- socialctl/connection_service/app.py +496 -0
- socialctl/connection_service/assets/PLATFORM-LOGOS-LICENSE.txt +50 -0
- socialctl/connection_service/assets/connection.css +75 -0
- socialctl/connection_service/assets/facebook.webp +0 -0
- socialctl/connection_service/assets/instagram.svg +194 -0
- socialctl/connection_service/assets/socialcli-logo.png +0 -0
- socialctl/connection_service/assets/tiktok.png +0 -0
- socialctl/connection_service/assets/youtube.svg +1 -0
- socialctl/connection_service/landing.py +146 -0
- socialctl/connection_service/legacy.py +48 -0
- socialctl/connection_service/peer.py +13 -0
- socialctl/connection_service/providers.py +324 -0
- socialctl/connection_service/settings.py +76 -0
- socialctl/connection_service/store.py +124 -0
- socialctl/connections/__init__.py +0 -0
- socialctl/connections/account_cli.py +438 -0
- socialctl/connections/cli.py +379 -0
- socialctl/connections/client.py +126 -0
- socialctl/connections/credential_cli.py +224 -0
- socialctl/connections/credential_store.py +49 -0
- socialctl/connections/file_store.py +193 -0
- socialctl/connections/keychain.py +78 -0
- socialctl/connections/meta_user.py +81 -0
- socialctl/connections/rotation_cli.py +116 -0
- socialctl/connections/saas_client.py +91 -0
- socialctl/connections/temporary_media.py +62 -0
- socialctl/delivery_options.py +70 -0
- socialctl/engagement.py +200 -0
- socialctl/engagement_cli.py +50 -0
- socialctl/executor.py +135 -0
- socialctl/formatter.py +291 -0
- socialctl/hosted_media.py +152 -0
- socialctl/identity.py +200 -0
- socialctl/inbox.py +298 -0
- socialctl/inbox_cli.py +46 -0
- socialctl/inventory.py +155 -0
- socialctl/inventory_cli.py +171 -0
- socialctl/inventory_sources.py +101 -0
- socialctl/management/__init__.py +1 -0
- socialctl/management/batch_cli.py +115 -0
- socialctl/management/batches.py +325 -0
- socialctl/management/changes.py +485 -0
- socialctl/management/cli.py +227 -0
- socialctl/management/comments_cli.py +352 -0
- socialctl/management/community_batch_cli.py +63 -0
- socialctl/management/community_batches.py +294 -0
- socialctl/management/community_changes.py +370 -0
- socialctl/management/community_cli.py +142 -0
- socialctl/management/community_schema.py +119 -0
- socialctl/management/facebook_groups.py +1118 -0
- socialctl/management/groups_cli.py +274 -0
- socialctl/management/inbox_readers.py +87 -0
- socialctl/management/meta_changes.py +197 -0
- socialctl/management/meta_cli.py +342 -0
- socialctl/management/meta_client.py +631 -0
- socialctl/management/meta_comment_inbox.py +565 -0
- socialctl/management/meta_comments.py +587 -0
- socialctl/management/meta_errors.py +59 -0
- socialctl/management/meta_pagination.py +52 -0
- socialctl/management/meta_schema.py +128 -0
- socialctl/management/meta_webhooks.py +147 -0
- socialctl/management/metadata_parts.py +144 -0
- socialctl/management/owned_assets.py +85 -0
- socialctl/management/owned_changes.py +470 -0
- socialctl/management/owned_cli.py +128 -0
- socialctl/management/owned_reorder.py +62 -0
- socialctl/management/owned_schema.py +368 -0
- socialctl/management/reply_context.py +24 -0
- socialctl/management/reply_evidence.py +80 -0
- socialctl/management/resource_changes.py +407 -0
- socialctl/management/resource_cli.py +136 -0
- socialctl/management/snippet_readback.py +26 -0
- socialctl/management/stories.py +713 -0
- socialctl/management/stories_cli.py +172 -0
- socialctl/management/youtube.py +323 -0
- socialctl/management/youtube_community.py +326 -0
- socialctl/management/youtube_metadata.py +122 -0
- socialctl/management/youtube_owned.py +259 -0
- socialctl/management/youtube_resources.py +305 -0
- socialctl/media.py +269 -0
- socialctl/media_cli.py +183 -0
- socialctl/media_ingress.py +211 -0
- socialctl/media_preflight.py +114 -0
- socialctl/media_registry.py +301 -0
- socialctl/media_requirements.py +52 -0
- socialctl/metricas/__init__.py +6 -0
- socialctl/metricas/almacen.py +133 -0
- socialctl/metricas/analytics_changes.py +295 -0
- socialctl/metricas/analytics_cli.py +191 -0
- socialctl/metricas/analytics_client.py +304 -0
- socialctl/metricas/analytics_ingest.py +260 -0
- socialctl/metricas/analytics_schema.py +174 -0
- socialctl/metricas/base.py +147 -0
- socialctl/metricas/facebook.py +418 -0
- socialctl/metricas/insights.py +227 -0
- socialctl/metricas/instagram.py +133 -0
- socialctl/metricas/modelos.py +87 -0
- socialctl/metricas/piezas.py +134 -0
- socialctl/metricas/reach.py +94 -0
- socialctl/metricas/reporting_client.py +112 -0
- socialctl/metricas/resumen.py +251 -0
- socialctl/metricas/slugs.py +89 -0
- socialctl/metricas/tiktok.py +185 -0
- socialctl/metricas/youtube.py +403 -0
- socialctl/migration_cli.py +60 -0
- socialctl/migration_files.py +68 -0
- socialctl/models.py +150 -0
- socialctl/native_schedule/__init__.py +13 -0
- socialctl/native_schedule/api_delivery.py +15 -0
- socialctl/native_schedule/api_reconcile.py +40 -0
- socialctl/native_schedule/approval.py +160 -0
- socialctl/native_schedule/cadence.py +73 -0
- socialctl/native_schedule/cli.py +510 -0
- socialctl/native_schedule/dispatcher.py +120 -0
- socialctl/native_schedule/facebook.py +112 -0
- socialctl/native_schedule/facebook_reels.py +140 -0
- socialctl/native_schedule/first_comment.py +181 -0
- socialctl/native_schedule/handoff.py +193 -0
- socialctl/native_schedule/instagram_delivery.py +224 -0
- socialctl/native_schedule/instagram_runtime.py +66 -0
- socialctl/native_schedule/inventory.py +70 -0
- socialctl/native_schedule/migration.py +310 -0
- socialctl/native_schedule/models.py +103 -0
- socialctl/native_schedule/reconcile.py +83 -0
- socialctl/native_schedule/remote_data.py +177 -0
- socialctl/native_schedule/report.py +151 -0
- socialctl/native_schedule/store.py +560 -0
- socialctl/native_schedule/verification.py +32 -0
- socialctl/native_schedule/youtube.py +339 -0
- socialctl/operation_output.py +87 -0
- socialctl/plantillas/accounts.yml +33 -0
- socialctl/plantillas/brand.md +95 -0
- socialctl/plantillas/estrategia.md +64 -0
- socialctl/postfile.py +240 -0
- socialctl/preflight.py +73 -0
- socialctl/publication_policy.py +34 -0
- socialctl/publication_status.py +75 -0
- socialctl/publication_steps.py +398 -0
- socialctl/publish_output.py +96 -0
- socialctl/publisher.py +445 -0
- socialctl/queue_migration.py +302 -0
- socialctl/read_budget.py +224 -0
- socialctl/read_reports.py +91 -0
- socialctl/rutas.py +103 -0
- socialctl/saas/__init__.py +1 -0
- socialctl/saas/access.py +75 -0
- socialctl/saas/auth.py +213 -0
- socialctl/saas/backup.py +124 -0
- socialctl/saas/billing.py +327 -0
- socialctl/saas/billing_enrollment.py +1237 -0
- socialctl/saas/billing_enrollment_schema.py +519 -0
- socialctl/saas/billing_inventory.py +775 -0
- socialctl/saas/billing_reconcile.py +127 -0
- socialctl/saas/billing_routes.py +27 -0
- socialctl/saas/budget.py +66 -0
- socialctl/saas/connections.py +374 -0
- socialctl/saas/consent.py +52 -0
- socialctl/saas/lifecycle.py +341 -0
- socialctl/saas/mail.py +89 -0
- socialctl/saas/maintenance.py +68 -0
- socialctl/saas/meta_user.py +298 -0
- socialctl/saas/meta_webhooks.py +358 -0
- socialctl/saas/migration.py +107 -0
- socialctl/saas/models.py +8 -0
- socialctl/saas/operations.py +102 -0
- socialctl/saas/pages.py +126 -0
- socialctl/saas/pairing.py +158 -0
- socialctl/saas/permissions.py +57 -0
- socialctl/saas/reminders.py +128 -0
- socialctl/saas/renewal.py +74 -0
- socialctl/saas/restore_guard.py +229 -0
- socialctl/saas/revocation.py +97 -0
- socialctl/saas/rotation.py +114 -0
- socialctl/saas/routes.py +221 -0
- socialctl/saas/settings.py +34 -0
- socialctl/saas/store.py +106 -0
- socialctl/saas/temporary_media.py +245 -0
- socialctl/saas/webhooks.py +76 -0
- socialctl/schedule_remote.py +262 -0
- socialctl/schedule_sqlite.py +44 -0
- socialctl/scheduler.py +581 -0
- socialctl/scheduler_launchd.py +319 -0
- socialctl/scheduler_systemd.py +167 -0
- socialctl/source_links.py +119 -0
- socialctl/ui/__init__.py +1 -0
- socialctl/ui/assets/agent-manual.md +850 -0
- socialctl/ui/assets/agents.md +27 -0
- socialctl/ui/assets/components.css +20 -0
- socialctl/ui/assets/connection-layout.css +53 -0
- socialctl/ui/assets/otp.template.html +10 -0
- socialctl/ui/assets/tokens.css +1 -0
- socialctl/ui/assets/trial.template.html +11 -0
- socialctl/ui/assets/web-layout.css +38 -0
- socialctl/ui/email/otp.html +10 -0
- socialctl/ui/email/trial.html +11 -0
- socialctl/upload_consent.py +13 -0
- socialctl/workspace.py +8 -0
- socialctl/youtube_data.py +471 -0
- socialctl/youtube_data_service.py +225 -0
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
"""Closed v1 private artifact contracts; parsing never establishes authority.
|
|
2
|
+
|
|
3
|
+
Artifact hashes cover the original bytes, not a model serialization. Structural
|
|
4
|
+
validation is deliberately separate from custody and semantic eligibility.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
from typing import Annotated, Literal, TypeVar, get_args, get_origin
|
|
10
|
+
|
|
11
|
+
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
12
|
+
|
|
13
|
+
from . import billing_inventory as inventory
|
|
14
|
+
|
|
15
|
+
Digest = Annotated[str, Field(pattern=r'^[0-9a-f]{64}$')]
|
|
16
|
+
Timestamp = Annotated[int, Field(ge=0)]
|
|
17
|
+
Identifier = Annotated[str, Field(pattern=r'^[A-Za-z0-9_:-]{1,512}$')]
|
|
18
|
+
Account = Annotated[str, Field(pattern=r'^acct_[A-Za-z0-9_]+$')]
|
|
19
|
+
Selector = Annotated[str, Field(pattern=r'^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*$', max_length=512)]
|
|
20
|
+
Role = Literal['inventory', 'provider', 'configuration', 'deployment', 'initial_empty',
|
|
21
|
+
'owner_instruction', 'authority', 'auth_authority', 'backup', 'freeze',
|
|
22
|
+
'source', 'image', 'policy', 'rehearsal', 'compatibility', 'documentary_review']
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class Closed(BaseModel):
|
|
26
|
+
model_config = ConfigDict(extra='forbid', strict=True, frozen=True)
|
|
27
|
+
|
|
28
|
+
@field_validator('*', mode='before')
|
|
29
|
+
@classmethod
|
|
30
|
+
def strict_literals(cls, value, info):
|
|
31
|
+
annotation = cls.model_fields[info.field_name].annotation
|
|
32
|
+
if get_origin(annotation) is Literal:
|
|
33
|
+
if not any(type(value) is type(item) and value == item for item in get_args(annotation)):
|
|
34
|
+
raise ValueError('Invalid artifact.')
|
|
35
|
+
return value
|
|
36
|
+
|
|
37
|
+
@field_validator('*')
|
|
38
|
+
@classmethod
|
|
39
|
+
def no_credential_identifiers(cls, value):
|
|
40
|
+
if isinstance(value, str) and value.startswith(('sk_', 'rk_', 'whsec_')):
|
|
41
|
+
raise ValueError('Invalid artifact.')
|
|
42
|
+
return value
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class Artifact(Closed):
|
|
46
|
+
id: Identifier
|
|
47
|
+
sha256: Digest
|
|
48
|
+
role: Role
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class Ref(Closed):
|
|
52
|
+
artifact_id: Identifier
|
|
53
|
+
selector: Selector
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class Row(Closed):
|
|
57
|
+
table: Identifier
|
|
58
|
+
key_sha256: Digest
|
|
59
|
+
row_sha256: Digest
|
|
60
|
+
|
|
61
|
+
@field_validator('table')
|
|
62
|
+
@classmethod
|
|
63
|
+
def known_table(cls, value):
|
|
64
|
+
if value not in inventory._SOURCE_METADATA_ROOTS:
|
|
65
|
+
raise ValueError('Invalid artifact.')
|
|
66
|
+
return value
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class RecordRef(Closed):
|
|
70
|
+
kind: Identifier
|
|
71
|
+
id: Identifier
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class Transition(Closed):
|
|
75
|
+
id: Identifier
|
|
76
|
+
from_id: Identifier
|
|
77
|
+
to_id: Identifier
|
|
78
|
+
kind: Literal['initial', 'deployment', 'migration', 'restore', 'import']
|
|
79
|
+
account_id: Account
|
|
80
|
+
mode: Literal['test']
|
|
81
|
+
receipts: list[Ref]
|
|
82
|
+
# Reviewed explanatory text stays in the source receipt, not this artifact.
|
|
83
|
+
# This reference/code cannot accidentally export an email or a raw payload.
|
|
84
|
+
limitation: Annotated[str, Field(pattern=r'^[A-Za-z0-9_:-]{0,512}$')]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class Lineage(Closed):
|
|
88
|
+
id: Identifier
|
|
89
|
+
category: Literal['billing', 'event', 'paid_provider', 'paid_manual', 'intent']
|
|
90
|
+
rows: list[Row]
|
|
91
|
+
record_refs: list[RecordRef]
|
|
92
|
+
user_id: Identifier
|
|
93
|
+
account_id: Account | None
|
|
94
|
+
mode: Literal['test'] | None
|
|
95
|
+
origin_transition_id: Identifier
|
|
96
|
+
historical_refs: list[Ref]
|
|
97
|
+
provider_refs: list[Ref]
|
|
98
|
+
owner_instruction_refs: list[Ref]
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class Uncertainty(Closed):
|
|
102
|
+
id: Identifier
|
|
103
|
+
row_refs: list[Row]
|
|
104
|
+
record_refs: list[RecordRef]
|
|
105
|
+
reason_code: Identifier
|
|
106
|
+
provenance_lineage_ids: list[Identifier]
|
|
107
|
+
preserved: Literal[True]
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class TableRoot(Closed):
|
|
111
|
+
name: Identifier
|
|
112
|
+
count: Timestamp
|
|
113
|
+
sha256: Digest
|
|
114
|
+
|
|
115
|
+
@field_validator('name')
|
|
116
|
+
@classmethod
|
|
117
|
+
def known_table(cls, value):
|
|
118
|
+
return Row.known_table(value)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
class Root(Closed):
|
|
122
|
+
algorithm: Literal['inventory-typed-root-v1']
|
|
123
|
+
schema_variant: Literal['schema10_deployed_rc15', 'schema10_candidate_receiver']
|
|
124
|
+
schema_sha256: Digest
|
|
125
|
+
state_sha256: Digest
|
|
126
|
+
tables: list[TableRoot]
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class Target(Closed):
|
|
130
|
+
host_authority_id: Identifier
|
|
131
|
+
service_id: Identifier
|
|
132
|
+
mount_id: Identifier
|
|
133
|
+
database_path: str
|
|
134
|
+
device: Timestamp
|
|
135
|
+
inode: Timestamp
|
|
136
|
+
account_id: Account
|
|
137
|
+
mode: Literal['test']
|
|
138
|
+
|
|
139
|
+
@field_validator('database_path')
|
|
140
|
+
@classmethod
|
|
141
|
+
def absolute_path(cls, value):
|
|
142
|
+
# Existing-file/custody checks are performed at use time, not parsing.
|
|
143
|
+
from pathlib import PurePosixPath
|
|
144
|
+
path = PurePosixPath(value)
|
|
145
|
+
if (not path.is_absolute() or '..' in path.parts or str(path) != value
|
|
146
|
+
or any(c in value for c in '?#') or any(ord(c) < 32 for c in value)):
|
|
147
|
+
raise ValueError('Invalid artifact.')
|
|
148
|
+
return value
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class Evidence(Closed):
|
|
152
|
+
schema_version: Literal['socialcli-legacy-enrollment-evidence/v1'] = Field(alias='schema')
|
|
153
|
+
bundle_id: Annotated[str, Field(pattern=r'^bundle_[0-9a-f]{32}$')]
|
|
154
|
+
created_at: Timestamp
|
|
155
|
+
artifacts: list[Artifact]
|
|
156
|
+
transitions: list[Transition]
|
|
157
|
+
lineages: list[Lineage]
|
|
158
|
+
uncertainties: list[Uncertainty]
|
|
159
|
+
documentary_review_ref: Ref
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class BindingPayload(Closed):
|
|
163
|
+
account_id: Account
|
|
164
|
+
mode: Literal['test']
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
class Binding(Closed):
|
|
168
|
+
kind: Literal['saas-billing-environment']
|
|
169
|
+
id: Literal['active']
|
|
170
|
+
payload: BindingPayload
|
|
171
|
+
expires: Literal[253402300799]
|
|
172
|
+
credential_hash: Literal['']
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
class Manifest(Closed):
|
|
176
|
+
schema_version: Literal['socialcli-legacy-enrollment-manifest/v1'] = Field(alias='schema')
|
|
177
|
+
nonce: Annotated[str, Field(pattern=r'^enrollment_[0-9a-f]{32}$')]
|
|
178
|
+
created_at: Timestamp
|
|
179
|
+
expires_at: Timestamp
|
|
180
|
+
target: Target
|
|
181
|
+
baseline: Root
|
|
182
|
+
evidence_sha256: Digest
|
|
183
|
+
documentary_approval_sha256: list[Digest]
|
|
184
|
+
source_sha256: Digest
|
|
185
|
+
tool_sha256: Digest
|
|
186
|
+
image_sha256: Digest
|
|
187
|
+
config_sha256: Digest
|
|
188
|
+
policy_sha256: Digest
|
|
189
|
+
inventory_sha256: Digest
|
|
190
|
+
authority_ref: Ref
|
|
191
|
+
authority_observed_at: Timestamp
|
|
192
|
+
auth_authority_ref: Ref
|
|
193
|
+
backup_ref: Ref
|
|
194
|
+
freeze_ref: Ref
|
|
195
|
+
freeze_started_at: Timestamp
|
|
196
|
+
provider_ref: Ref
|
|
197
|
+
provider_observed_at: Timestamp
|
|
198
|
+
rehearsal_ref: Ref
|
|
199
|
+
compatibility_ref: Ref
|
|
200
|
+
binding: Binding
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
class Approval(Closed):
|
|
204
|
+
schema_version: Literal['socialcli-legacy-enrollment-approval/v1'] = Field(alias='schema')
|
|
205
|
+
approval_id: Annotated[str, Field(pattern=r'^approval_[0-9a-f]{32}$')]
|
|
206
|
+
principal_id: Identifier
|
|
207
|
+
role: Literal['owner', 'independent_reviewer']
|
|
208
|
+
scope: Literal['documentary_review', 'enrollment_manifest']
|
|
209
|
+
subject_sha256: Digest
|
|
210
|
+
policy_sha256: Digest
|
|
211
|
+
created_at: Timestamp
|
|
212
|
+
expires_at: Timestamp
|
|
213
|
+
decision: Literal['approve']
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
class Receipt(Closed):
|
|
217
|
+
schema_version: Literal['socialcli-legacy-enrollment-receipt/v1'] = Field(alias='schema')
|
|
218
|
+
nonce: Annotated[str, Field(pattern=r'^enrollment_[0-9a-f]{32}$')]
|
|
219
|
+
manifest_sha256: Digest
|
|
220
|
+
evidence_sha256: Digest
|
|
221
|
+
approval_sha256: list[Digest]
|
|
222
|
+
target: Target
|
|
223
|
+
committed_at: Timestamp
|
|
224
|
+
baseline: Root
|
|
225
|
+
post: Root
|
|
226
|
+
post_excluding_binding: Root
|
|
227
|
+
binding_ciphertext_sha256: Digest
|
|
228
|
+
result: Literal['one_binding_insert_verified']
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
class Verification(Closed):
|
|
232
|
+
schema_version: Literal['socialcli-legacy-enrollment-verification/v1'] = Field(alias='schema')
|
|
233
|
+
manifest_sha256: Digest
|
|
234
|
+
receipt_sha256: Digest
|
|
235
|
+
verified_at: Timestamp
|
|
236
|
+
result: Literal['exact_delta_verified']
|
|
237
|
+
post: Root
|
|
238
|
+
post_excluding_binding: Root
|
|
239
|
+
binding_ciphertext_sha256: Digest
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
Model = TypeVar('Model', bound=Closed)
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def _unique_object(pairs):
|
|
246
|
+
result = {}
|
|
247
|
+
for key, value in pairs:
|
|
248
|
+
if key in result:
|
|
249
|
+
raise ValueError('Invalid artifact.')
|
|
250
|
+
result[key] = value
|
|
251
|
+
return result
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def _nonfinite(_):
|
|
255
|
+
raise ValueError('Invalid artifact.')
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def parse_artifact(raw: bytes, model: type[Model]) -> Model:
|
|
259
|
+
"""Reject duplicate keys and ambiguous JSON before strict model validation."""
|
|
260
|
+
try:
|
|
261
|
+
if type(raw) is not bytes or raw.startswith(b'\xef\xbb\xbf'):
|
|
262
|
+
raise ValueError()
|
|
263
|
+
value = json.loads(raw.decode('utf-8'), object_pairs_hook=_unique_object,
|
|
264
|
+
parse_constant=_nonfinite)
|
|
265
|
+
return model.model_validate(value)
|
|
266
|
+
except Exception:
|
|
267
|
+
raise ValueError('Invalid artifact.') from None
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
def json_schema(model: type[Closed]) -> dict:
|
|
271
|
+
return {'$schema': 'https://json-schema.org/draft/2020-12/schema',
|
|
272
|
+
**model.model_json_schema(by_alias=True)}
|
|
273
|
+
|
|
274
|
+
# Implementation contract extension: protected typed assertions. They are
|
|
275
|
+
# documentary facts subject to independent review, never provider/human proofs.
|
|
276
|
+
class Principal(Closed):
|
|
277
|
+
id: Identifier
|
|
278
|
+
role: Literal['owner', 'independent_reviewer']
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
class Policy(Closed):
|
|
282
|
+
schema_version: Literal['socialcli-legacy-enrollment-policy/v1'] = Field(alias='schema')
|
|
283
|
+
custody_directory: str
|
|
284
|
+
registry_path: str
|
|
285
|
+
target: Target
|
|
286
|
+
principals: list[Principal]
|
|
287
|
+
source_sha256: Digest
|
|
288
|
+
tool_sha256: Digest
|
|
289
|
+
image_sha256: Digest
|
|
290
|
+
config_sha256: Digest
|
|
291
|
+
collector_sha256: Digest
|
|
292
|
+
app_id: Identifier
|
|
293
|
+
provider_max_age: Literal[900]
|
|
294
|
+
authority_max_age: Literal[300]
|
|
295
|
+
manifest_max_age: Literal[300]
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
class RegistryEntry(Closed):
|
|
299
|
+
id: Identifier
|
|
300
|
+
filename: Annotated[str, Field(pattern=r'^[A-Za-z0-9_-]+\.json$')]
|
|
301
|
+
sha256: Digest
|
|
302
|
+
role: Role | Literal['evidence', 'manifest', 'approval', 'receipt']
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
class Registry(Closed):
|
|
306
|
+
schema_version: Literal['socialcli-legacy-enrollment-registry/v1'] = Field(alias='schema')
|
|
307
|
+
entries: list[RegistryEntry]
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
class InitialEmptyFacts(Closed):
|
|
311
|
+
source_receipt_sha256: Digest
|
|
312
|
+
endpoint_id: Identifier
|
|
313
|
+
account_id: Account
|
|
314
|
+
mode: Literal['test']
|
|
315
|
+
observed_at: Timestamp
|
|
316
|
+
billing_rows: Literal[0]
|
|
317
|
+
event_rows: Literal[0]
|
|
318
|
+
paid_state_rows: Literal[0]
|
|
319
|
+
encrypted_records: Literal[0]
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
class ContinuityFacts(Closed):
|
|
323
|
+
source_receipt_sha256: Digest
|
|
324
|
+
transition_id: Identifier
|
|
325
|
+
from_id: Identifier
|
|
326
|
+
to_id: Identifier
|
|
327
|
+
kind: Literal['initial', 'deployment', 'migration', 'restore', 'import']
|
|
328
|
+
account_id: Account
|
|
329
|
+
mode: Literal['test']
|
|
330
|
+
observed_at: Timestamp
|
|
331
|
+
finding: Literal['continuous', 'unresolved', 'contradictory']
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
class ProviderObject(Closed):
|
|
335
|
+
request_id: Identifier
|
|
336
|
+
response_sha256: Digest
|
|
337
|
+
reference_id: Identifier
|
|
338
|
+
requested_id: Identifier
|
|
339
|
+
returned_id: Identifier
|
|
340
|
+
object_type: Literal['account', 'customer', 'subscription', 'checkout', 'invoice',
|
|
341
|
+
'event', 'price', 'portal', 'line_item']
|
|
342
|
+
account_id: Account
|
|
343
|
+
mode: Literal['test']
|
|
344
|
+
user_id: Identifier | None
|
|
345
|
+
app_id: Identifier
|
|
346
|
+
customer_id: Identifier | None
|
|
347
|
+
subscription_id: Identifier | None
|
|
348
|
+
checkout_id: Identifier | None
|
|
349
|
+
invoice_id: Identifier | None
|
|
350
|
+
price_id: Identifier | None
|
|
351
|
+
event_object_id: Identifier | None
|
|
352
|
+
observed_at: Timestamp
|
|
353
|
+
outcome: Literal['present', 'retained_terminal']
|
|
354
|
+
retained_refs: list[Ref]
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
class ProviderCollection(Closed):
|
|
358
|
+
collection: Literal['subscriptions', 'sessions', 'invoices', 'line_items']
|
|
359
|
+
parent_id: Identifier
|
|
360
|
+
object_ids: list[Identifier]
|
|
361
|
+
pagination: Literal['complete', 'partial']
|
|
362
|
+
observed_at: Timestamp
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
class ProviderFacts(Closed):
|
|
366
|
+
objects: list[ProviderObject]
|
|
367
|
+
collections: list[ProviderCollection]
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
class DocumentaryFacts(Closed):
|
|
371
|
+
account_id: Account
|
|
372
|
+
mode: Literal['test']
|
|
373
|
+
original_empty_id: Identifier
|
|
374
|
+
current_authority_id: Identifier
|
|
375
|
+
transition_ids: list[Identifier]
|
|
376
|
+
lineage_ids: list[Identifier]
|
|
377
|
+
rows: list[Row]
|
|
378
|
+
record_refs: list[RecordRef]
|
|
379
|
+
uncertainty_ids: list[Identifier]
|
|
380
|
+
evidence_sha256: list[Digest]
|
|
381
|
+
findings: list[Literal['unresolved_provenance', 'contradictory_history',
|
|
382
|
+
'missing_relationship', 'incomplete_mapping']]
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
class AuthorityFacts(Closed):
|
|
386
|
+
target: Target
|
|
387
|
+
endpoint_id: Identifier
|
|
388
|
+
observed_at: Timestamp
|
|
389
|
+
expires_at: Timestamp
|
|
390
|
+
state: Literal['authoritative']
|
|
391
|
+
competing_authority_ids: list[Identifier]
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
class FreezeWriter(Closed):
|
|
395
|
+
name: Literal['ingress', 'webhooks', 'workers', 'schedulers', 'deletion', 'revocation', 'reminders']
|
|
396
|
+
state: Literal['drained', 'active', 'uncertain']
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
class FreezeFacts(Closed):
|
|
400
|
+
target: Target
|
|
401
|
+
freeze_id: Identifier
|
|
402
|
+
started_at: Timestamp
|
|
403
|
+
observed_at: Timestamp
|
|
404
|
+
writers: list[FreezeWriter]
|
|
405
|
+
arrivals: Literal['durable_external', 'reject_for_retry']
|
|
406
|
+
network: Literal['deny_all']
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
class ConfigurationFacts(Closed):
|
|
410
|
+
account_id: Account
|
|
411
|
+
mode: Literal['test']
|
|
412
|
+
app_id: Identifier
|
|
413
|
+
price_id: Identifier
|
|
414
|
+
portal_id: Identifier
|
|
415
|
+
observed_at: Timestamp
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
class OwnerInstructionFacts(Closed):
|
|
419
|
+
user_id: Identifier
|
|
420
|
+
rows: list[Row]
|
|
421
|
+
conversation_receipt_sha256: Digest
|
|
422
|
+
observed_at: Timestamp
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
class BackupFacts(Closed):
|
|
426
|
+
target: Target
|
|
427
|
+
authority_id: Identifier
|
|
428
|
+
auth_authority_id: Identifier
|
|
429
|
+
sqlite_snapshot_sha256: Digest
|
|
430
|
+
auth_snapshot_sha256: Digest
|
|
431
|
+
verified_at: Timestamp
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
class CopyIdentity(Closed):
|
|
435
|
+
device: Timestamp
|
|
436
|
+
inode: Timestamp
|
|
437
|
+
owner: Timestamp
|
|
438
|
+
group: Timestamp
|
|
439
|
+
mode: Literal[384]
|
|
440
|
+
links: Literal[1]
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
class PreparationChange(Closed):
|
|
444
|
+
table: Identifier
|
|
445
|
+
before: TableRoot | None
|
|
446
|
+
after: TableRoot
|
|
447
|
+
reason: Literal['access_cleanup', 'session_invalidation', 'deletion_authority',
|
|
448
|
+
'revocation_authority', 'legacy_cleanup', 'restore_guard']
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
class PreparedCopy(Closed):
|
|
452
|
+
source_target: Target
|
|
453
|
+
source_authority_id: Identifier
|
|
454
|
+
source_baseline: Root
|
|
455
|
+
target: Target
|
|
456
|
+
identity: CopyIdentity
|
|
457
|
+
baseline: Root
|
|
458
|
+
preparation_receipt_sha256: Digest
|
|
459
|
+
prepared_at: Timestamp
|
|
460
|
+
snapshot_created_at: Timestamp
|
|
461
|
+
changes: list[PreparationChange]
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
class RehearsalDelta(Closed):
|
|
465
|
+
post: Root
|
|
466
|
+
post_excluding_binding: Root
|
|
467
|
+
binding: Binding
|
|
468
|
+
binding_ciphertext_sha256: Digest
|
|
469
|
+
result: Literal['one_binding_insert_verified']
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
class RehearsalFacts(Closed):
|
|
473
|
+
source_sha256: Digest
|
|
474
|
+
image_sha256: Digest
|
|
475
|
+
previous_image_sha256: Digest
|
|
476
|
+
prepared_copy: PreparedCopy
|
|
477
|
+
enrollment_delta: RehearsalDelta
|
|
478
|
+
baseline_sha256: Digest
|
|
479
|
+
exact_delta_sha256: Digest
|
|
480
|
+
matching_test_startup: Literal['accepted']
|
|
481
|
+
foreign_account_startup: Literal['rejected_before_provider']
|
|
482
|
+
live_startup: Literal['rejected_before_provider']
|
|
483
|
+
network: Literal['deny_all']
|
|
484
|
+
restore: Literal['ready']
|
|
485
|
+
uncertainty_ids: list[Identifier]
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
class CompatibilityFacts(Closed):
|
|
489
|
+
previous_image_sha256: Digest
|
|
490
|
+
rehearsal_sha256: Digest
|
|
491
|
+
copy_target: Target
|
|
492
|
+
before: Root
|
|
493
|
+
after: Root
|
|
494
|
+
binding_ciphertext_sha256: Digest
|
|
495
|
+
binding: Literal['preserved']
|
|
496
|
+
baseline: Literal['preserved']
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
class SourceFile(Closed):
|
|
500
|
+
name: Literal['billing_enrollment.py', 'billing_enrollment_schema.py',
|
|
501
|
+
'billing_inventory.py', 'enroll_legacy_test_billing.py']
|
|
502
|
+
sha256: Digest
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
class SourceFacts(Closed):
|
|
506
|
+
files: list[SourceFile]
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
class ImageFacts(Closed):
|
|
510
|
+
image_digest: Digest
|
|
511
|
+
source_sha256: Digest
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
class FactReport(Closed):
|
|
515
|
+
schema_version: Literal['socialcli-legacy-enrollment-facts/v1'] = Field(alias='schema')
|
|
516
|
+
collector_sha256: Digest
|
|
517
|
+
# Role is pinned separately by the protected registry. No caller-selected
|
|
518
|
+
# discriminator can substitute provider facts for a documentary review.
|
|
519
|
+
facts: InitialEmptyFacts | ContinuityFacts | ProviderFacts | DocumentaryFacts | AuthorityFacts | FreezeFacts | ConfigurationFacts | OwnerInstructionFacts | BackupFacts | RehearsalFacts | CompatibilityFacts | SourceFacts | ImageFacts
|