Spaces:
Sleeping
Sleeping
File size: 14,865 Bytes
41016fc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | from __future__ import annotations
from typing import Any
def _event_text(event: dict[str, Any]) -> str:
time = event.get("event_time") or event.get("observed_time") or "time not supplied"
return f"[{event.get('event_id')}] {time}: {event.get('description', '').strip()}"
def _has_event(events: list[dict[str, Any]], event_type: str) -> bool:
return any(event.get("event_type") == event_type for event in events)
def collapse_causal_families(capsule: dict[str, Any]) -> list[dict[str, Any]]:
events = capsule.get("temporal_events", [])
definitions = [
("CF_DISTRIBUTION_STATE", {"BASELINE", "REACH_CHANGE", "ANALYTICS_SNAPSHOT", "RECOVERY", "FOLLOWER_COUNT_CHANGE"}, "Visible distribution baseline, breakpoint, persistence, and recovery state."),
("CF_ENFORCEMENT_RESTORATION", {"ACCOUNT_LABEL", "REVIEW_CLEARANCE", "SUPPORT_RESPONSE"}, "Platform label, review, clearance, support, and downstream restoration sequence."),
("CF_RELATIONAL_RETURN", {"FOLLOWER_REPORT", "NOTIFICATION_OMISSION", "NOTIFICATION_DELAY"}, "Follower delivery, notification return, and creator reciprocity surface."),
("CF_CONTROL_CONDITIONS", {"NEUTRAL_CONTROL"}, "Neutral or matched control conditions used to test non-platform explanations."),
("CF_PUBLIC_CHALLENGE", {"PUBLIC_COMPLAINT"}, "Public complaint or challenge events that may affect temporal interpretation but do not establish retaliation."),
("CF_CORRECTION_RATCHET", {"CREATOR_CORRECTION"}, "Append-only corrections preserving ancestor events."),
]
families: list[dict[str, Any]] = []
assigned: set[str] = set()
for family_id, types, description in definitions:
members = [e.get("event_id") for e in events if e.get("event_type") in types]
if members:
assigned.update(members)
families.append({
"causal_family_id": family_id,
"description": description,
"member_event_ids": members,
"state": "COLLAPSED_FOR_SINGLE_CASE_REVIEW",
})
unassigned = [e.get("event_id") for e in events if e.get("event_id") not in assigned]
if unassigned:
families.append({
"causal_family_id": "CF_OTHER_UNCOLLAPSED",
"description": "Events not yet assigned to a governed causal family.",
"member_event_ids": unassigned,
"state": "HELD",
})
return families
def freeze_discriminator_predictions(capsule: dict[str, Any], causal_families: list[dict[str, Any]]) -> list[dict[str, Any]]:
family_ids = {f["causal_family_id"] for f in causal_families}
predictions = [
{
"prediction_id": "PRED_MATCHED_CONTROLS",
"statement": "If the transition is platform-wide rather than account-conditioned, matched accounts and comparable surfaces should exhibit a similar time-aligned change.",
"required_sources": ["Matched comparison capsules", "Platform-wide change logs"],
"state": "FROZEN_HELD",
},
{
"prediction_id": "PRED_ACCOUNT_STATE",
"statement": "If an account-conditioned state contributed, account-level eligibility or ranking records should show a transition near the documented breakpoint.",
"required_sources": ["Account recommendation-eligibility history", "Ranking/cohort state history"],
"state": "FROZEN_HELD",
},
{
"prediction_id": "PRED_RESTORATION",
"statement": "If review clearance fully restored the prior state, downstream eligibility records or normalized distribution should evidence restoration after clearance.",
"required_sources": ["Before/after enforcement-state diff", "Restoration execution receipt"],
"state": "FROZEN_HELD",
},
{
"prediction_id": "PRED_NOTIFICATION_ROUTE",
"statement": "If relational return was degraded at notification routing, thread-visible interactions and notification-delivery logs should diverge in a reproducible way.",
"required_sources": ["Notification generation and delivery logs", "Thread interaction export"],
"state": "FROZEN_HELD",
},
]
if "CF_ENFORCEMENT_RESTORATION" not in family_ids:
predictions[2]["state"] = "FROZEN_LOW_SIGNAL"
if "CF_RELATIONAL_RETURN" not in family_ids:
predictions[3]["state"] = "FROZEN_LOW_SIGNAL"
return predictions
def build_hypotheses(capsule: dict[str, Any]) -> list[dict[str, Any]]:
events = capsule.get("temporal_events", [])
subject_change = str(capsule.get("content_topology", {}).get("subject_change_near_event", "")).lower()
stable_subject = any(token in subject_change for token in ("no", "none", "stable", "unchanged"))
has_reach_change = _has_event(events, "REACH_CHANGE")
has_label = _has_event(events, "ACCOUNT_LABEL")
has_clearance = _has_event(events, "REVIEW_CLEARANCE")
has_recovery = _has_event(events, "RECOVERY")
has_notification = _has_event(events, "NOTIFICATION_OMISSION") or _has_event(events, "NOTIFICATION_DELAY")
has_control = _has_event(events, "NEUTRAL_CONTROL")
ordinary_fit = "LOW" if has_reach_change and (has_control or has_notification) else "HELD"
creator_change_fit = "LOW" if stable_subject else "HELD"
account_state_fit = "MEDIUM" if has_reach_change and (has_label or has_notification) else "HELD"
enforcement_fit = "MEDIUM" if has_reach_change and has_label and has_clearance and not has_recovery else "HELD"
return [
{
"hypothesis": "H0 — ordinary audience variation or post-level performance variance",
"fit": ordinary_fit,
"supporting_observations": [
"Single-account metrics can vary for reasons not visible in the packet."
],
"falsifiers": [
"A persistent account-level breakpoint across comparable content and matched controls.",
"Platform records showing an account-conditioned recommendation or distribution state."
],
},
{
"hypothesis": "H1 — creator posting cadence, format, or subject-mix change",
"fit": creator_change_fit,
"supporting_observations": [
"Changes in creator behavior can alter visible distribution."
],
"falsifiers": [
"Receipts showing materially stable cadence, format, and subject topology across the breakpoint.",
"Comparable content performing differently before and after the breakpoint."
],
},
{
"hypothesis": "H2 — platform-wide recommender or demand change",
"fit": "HELD",
"supporting_observations": [
"A platform-wide change can affect many creators simultaneously."
],
"falsifiers": [
"Matched comparison accounts not exhibiting the same transition during the same period.",
"Platform change logs excluding the relevant surface or account cohort."
],
},
{
"hypothesis": "H3 — account-conditioned distribution or recommendation state",
"fit": account_state_fit,
"supporting_observations": [
"An abrupt persistent reach change can be generated by an account-level hidden state.",
"Notification or label events may identify a candidate state transition."
],
"falsifiers": [
"Account-level eligibility history showing no relevant state change.",
"A complete organic explanation reproducing the observed breakpoint and persistence."
],
},
{
"hypothesis": "H4 — enforcement, label, or review state coupled to distribution and incomplete restoration",
"fit": enforcement_fit,
"supporting_observations": [
"A label-clearance sequence without demonstrated recovery is a candidate causal family."
],
"falsifiers": [
"Records showing full downstream restoration at clearance time.",
"Evidence that the reach change preceded and was independent of the enforcement state."
],
},
{
"hypothesis": "H5 — recurrent extraction-with-relational-severance phenotype across creators",
"fit": "HELD",
"supporting_observations": [
"The creator's work may remain platform-readable while human relational return contracts."
],
"falsifiers": [
"Cross-account comparison showing no recurrent phenotype after normalization and controls.",
"Evidence that platform/machine access declined proportionally with human reach."
],
},
]
def build_minimum_cut_candidates(capsule: dict[str, Any]) -> list[dict[str, Any]]:
events = capsule.get("temporal_events", [])
candidates = [
{
"candidate_id": "CUT_RECOMMENDATION_ELIGIBILITY",
"candidate_cut": "Account-level recommendation or discovery eligibility",
"preserved_path": "Creator content remains hosted and platform-readable.",
"potentially_degraded_path": "Independent human discovery beyond the existing audience.",
"required_source_return": "Account recommendation-eligibility and distribution-state history.",
"state": "HELD",
},
{
"candidate_id": "CUT_DISTRIBUTION_MULTIPLIER",
"candidate_cut": "Account- or post-conditioned distribution multiplier",
"preserved_path": "Content remains available for engagement, indexing, and machine retrieval.",
"potentially_degraded_path": "The number or diversity of humans to whom the content is delivered.",
"required_source_return": "Ranking feature values, cohort assignment, and multiplier history.",
"state": "HELD",
},
{
"candidate_id": "CUT_NOTIFICATION_RETURN",
"candidate_cut": "Notification and reply-return routing",
"preserved_path": "Replies or platform interactions can exist on-thread.",
"potentially_degraded_path": "The creator's awareness of and ability to reciprocate human interaction.",
"required_source_return": "Notification-generation, suppression, deduplication, and delivery logs.",
"state": "HELD",
},
{
"candidate_id": "CUT_RESTORATION_STATE",
"candidate_cut": "Downstream restoration after label removal, appeal, or clearance",
"preserved_path": "The visible label can be removed.",
"potentially_degraded_path": "Prior recommendation and distribution state may remain unrestored.",
"required_source_return": "Before/after enforcement state diff and restoration execution receipt.",
"state": "HELD",
},
]
if not any(e.get("event_type") in {"ACCOUNT_LABEL", "REVIEW_CLEARANCE"} for e in events):
candidates[-1]["state"] = "LOW_SIGNAL"
return candidates
def build_dpio_read(capsule: dict[str, Any], controls: list[str], creator_context: list[str]) -> dict[str, Any]:
events = capsule.get("temporal_events", [])
assets = capsule.get("evidence_assets", [])
claims = capsule.get("claims", [])
observed_facts = [_event_text(e) for e in events if e.get("state") == "OBSERVED"]
observed_facts.extend(
f"[{a.get('asset_id')}] Source artifact preserved: {a.get('original_filename')} (SHA-256 {a.get('sha256')})."
for a in assets
)
reported = list(creator_context)
reported.extend(_event_text(e) for e in events if e.get("state") == "CREATOR_REPORTED")
reported.insert(0, capsule.get("content_topology", {}).get("creator_exact_description", ""))
reported = [item for item in reported if str(item).strip()]
supported_inferences = [
c.get("statement", "")
for c in claims
if c.get("claim_level") in {"L2_REPEATED_PATTERN", "L3_STRUCTURAL_INFERENCE", "L4_BEST_FIT_MECHANISM"}
and c.get("state") in {"SUPPORTED", "PROVISIONAL", "STRAINED"}
]
source_returns = capsule.get("source_return_request", []) or []
unresolved = [
"The exact internal platform mechanism remains unresolved without platform-controlled records.",
"Executive knowledge, authorization, purpose, and intent are not established by this single-case packet.",
]
if source_returns:
unresolved.append("The packet identifies source-return requests that remain outstanding.")
causal_families = collapse_causal_families(capsule)
frozen_predictions = freeze_discriminator_predictions(capsule, causal_families)
hypotheses = build_hypotheses(capsule)
minimum_cuts = build_minimum_cut_candidates(capsule)
execution_order = [
{"sequence": 1, "stage": "SOURCE_REGISTERED", "state": "PASS"},
{"sequence": 2, "stage": "EVENTS_REGISTERED", "state": "PASS"},
{"sequence": 3, "stage": "CHRONOLOGY_MAPPED", "state": "PASS"},
{"sequence": 4, "stage": "CAUSAL_FAMILIES_COLLAPSED", "state": "PASS"},
{"sequence": 5, "stage": "PREDICTIONS_FROZEN", "state": "PASS"},
{"sequence": 6, "stage": "HYPOTHESES_FROZEN", "state": "PASS"},
{"sequence": 7, "stage": "PRESSURE_TESTED", "state": "PASS_WITH_HELD_CAUSES"},
]
return {
"dpio_read_version": "v0.1.0",
"creator_capsule_id": capsule.get("capsule_id"),
"procedure": "SOURCE_BOUND_SINGLE_CASE_DETERMINISTIC_READ",
"execution_order_receipt": execution_order,
"observed_facts": observed_facts,
"creator_reported_context": reported,
"supported_inferences": supported_inferences,
"unresolved_causes": unresolved,
"controls_and_competing_conditions": controls,
"causal_families": causal_families,
"frozen_discriminator_predictions": frozen_predictions,
"competing_hypotheses": hypotheses,
"pressure_test_results": [
{
"hypothesis": h["hypothesis"],
"current_fit": h["fit"],
"result": "HELD_PENDING_FALSIFIERS_AND_SOURCE_RETURN",
} for h in hypotheses
],
"minimum_cut_candidates": minimum_cuts,
"source_return_requests": source_returns,
"claim_ceiling": "L1_DIRECT_OBSERVATION_AUTOMATIC; L2-L4 HUMAN_CONFIRMATION; L5-L6 BLOCKED",
"human_review_required": True,
"closure_state": capsule.get("loop_state"),
"false_closure_blocked": bool(capsule.get("review_pack", {}).get("closure_blockers", [])),
}
|