Skip to content

Commit d4d4bf4

Browse files
authored
Refactor purpose strings in IX handoff definitions
Consolidate purpose strings for clarity and remove redundant line breaks.
1 parent a308b7e commit d4d4bf4

1 file changed

Lines changed: 15 additions & 98 deletions

File tree

src/ix_cognition_kernel/wave6_ix_handoff.py

Lines changed: 15 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ def canonical_payload(self) -> dict[str, Any]:
127127
obligation_id="purpose_discipline",
128128
title="Purpose discipline",
129129
purpose=(
130-
"Declare the measured reason the cognition attempt exists before it "
131-
"runs."
130+
"Declare the measured reason the cognition attempt exists before it runs."
132131
),
133132
evidence_artifacts=("attempt_purpose_record",),
134133
falsification_conditions=("purpose_missing", "purpose_changes_after_result"),
@@ -167,8 +166,7 @@ def canonical_payload(self) -> dict[str, Any]:
167166
obligation_id="measured_outcome_capture",
168167
title="Measured outcome capture",
169168
purpose=(
170-
"Record the observed result used to judge whether the attempt met "
171-
"reality."
169+
"Record the observed result used to judge whether the attempt met reality."
172170
),
173171
evidence_artifacts=("outcome_record",),
174172
falsification_conditions=("outcome_missing", "outcome_not_measured"),
@@ -250,8 +248,7 @@ def canonical_payload(self) -> dict[str, Any]:
250248
obligation_id="contradiction_handling",
251249
title="Contradiction handling",
252250
purpose=(
253-
"Detect contradictions and route them to correction, quarantine, or "
254-
"review."
251+
"Detect contradictions and route them to correction, quarantine, or review."
255252
),
256253
evidence_artifacts=("contradiction_record", "resolution_record"),
257254
falsification_conditions=("contradiction_ignored", "conflict_used_as_truth"),
@@ -293,8 +290,7 @@ def canonical_payload(self) -> dict[str, Any]:
293290
obligation_id="no_self_certification",
294291
title="No self-certification",
295292
purpose=(
296-
"Prevent the system or model from certifying its own AGI-candidate "
297-
"success."
293+
"Prevent the system or model from certifying its own AGI-candidate success."
298294
),
299295
evidence_artifacts=("self_certification_guard_record",),
300296
falsification_conditions=(
@@ -319,8 +315,7 @@ def canonical_payload(self) -> dict[str, Any]:
319315
obligation_id="independent_replay_review",
320316
title="Independent replay and review readiness",
321317
purpose=(
322-
"Produce enough evidence for independent replay, audit, or human "
323-
"review."
318+
"Produce enough evidence for independent replay, audit, or human review."
324319
),
325320
evidence_artifacts=("replay_manifest", "review_packet"),
326321
falsification_conditions=("replay_not_possible", "review_packet_missing"),
@@ -329,8 +324,7 @@ def canonical_payload(self) -> dict[str, Any]:
329324
obligation_id="kernel_handoff_package",
330325
title="Kernel handoff package",
331326
purpose=(
332-
"Export a structured obligation package for IX-CognitionKernel to "
333-
"attempt."
327+
"Export a structured obligation package for IX-CognitionKernel to attempt."
334328
),
335329
evidence_artifacts=("kernel_handoff_package",),
336330
falsification_conditions=("kernel_handoff_missing", "handoff_schema_invalid"),
@@ -344,7 +338,8 @@ def canonical_payload(self) -> dict[str, Any]:
344338
str,
345339
WaveSixIxCanonicalObligationDefinition,
346340
] = {
347-
definition.obligation_id: definition for definition in CANONICAL_IX_COGNITION_OBLIGATIONS
341+
definition.obligation_id: definition
342+
for definition in CANONICAL_IX_COGNITION_OBLIGATIONS
348343
}
349344

350345

@@ -592,7 +587,9 @@ def falsification_gate_ids(self) -> tuple[str, ...]:
592587
"""Return declared falsification gates in deterministic order."""
593588

594589
return _unique_preserving_order(
595-
gate_id for obligation in self.obligations for gate_id in obligation.falsify_if
590+
gate_id
591+
for obligation in self.obligations
592+
for gate_id in obligation.falsify_if
596593
)
597594

598595
@property
@@ -699,7 +696,9 @@ def __post_init__(self) -> None:
699696
)
700697
if not self.packages:
701698
raise ValueError("IX handoff bundle requires at least one package.")
702-
sorted_packages = tuple(sorted(self.packages, key=lambda package: package.attempt))
699+
sorted_packages = tuple(
700+
sorted(self.packages, key=lambda package: package.attempt)
701+
)
703702
_require_unique_text(
704703
(package.attempt for package in sorted_packages),
705704
label="attempt",
@@ -815,8 +814,7 @@ def _canonical_definition_for_payload(
815814
raise ValueError(f"Unknown IX cognition obligation: {obligation_id}")
816815
if payload != definition.canonical_payload():
817816
raise ValueError(
818-
"IX canonical obligation definition drift detected for "
819-
f"{obligation_id}."
817+
f"IX canonical obligation definition drift detected for {obligation_id}."
820818
)
821819
return definition
822820

@@ -987,87 +985,6 @@ def _require_unique_text(values: Iterable[str], *, label: str) -> None:
987985
seen.add(value)
988986

989987

990-
def _stable_sha256(payload: Mapping[str, Any]) -> str:
991-
"""Return deterministic SHA-256 over a canonical JSON payload."""
992-
993-
encoded = json.dumps(payload, sort_keys=True, separators=(",", ":")).encode("utf-8")
994-
return hashlib.sha256(encoded).hexdigest()
995-
def _probe_id(contract_artifact_id: str, obligation: WaveSixIxObligation) -> str:
996-
"""Return deterministic falsification-probe id for an IX obligation."""
997-
998-
return f"ix-obligation-probe:{contract_artifact_id}:{obligation.obligation_id}"
999-
1000-
1001-
def _sort_pressures_by_canonical_order(
1002-
pressures: Iterable[WaveSixIxObligationPressure],
1003-
) -> tuple[WaveSixIxObligationPressure, ...]:
1004-
"""Return pressure records sorted by canonical IX obligation order."""
1005-
1006-
by_id: dict[str, WaveSixIxObligationPressure] = {}
1007-
for pressure in pressures:
1008-
if pressure.obligation_id in by_id:
1009-
raise ValueError(
1010-
f"Duplicate IX obligation pressure: {pressure.obligation_id}"
1011-
)
1012-
by_id[pressure.obligation_id] = pressure
1013-
return tuple(
1014-
by_id[obligation_id]
1015-
for obligation_id in canonical_ix_cognition_obligation_ids()
1016-
if obligation_id in by_id
1017-
)
1018-
1019-
1020-
def _require_exact_obligation_ids(obligation_ids: tuple[str, ...]) -> None:
1021-
"""Require pressure coverage for every canonical IX cognition obligation."""
1022-
1023-
expected = set(canonical_ix_cognition_obligation_ids())
1024-
actual = set(obligation_ids)
1025-
missing = tuple(
1026-
obligation_id
1027-
for obligation_id in canonical_ix_cognition_obligation_ids()
1028-
if obligation_id not in actual
1029-
)
1030-
extra = tuple(sorted(actual - expected))
1031-
if missing:
1032-
raise ValueError(f"Missing IX obligation pressure: {missing[0]}")
1033-
if extra:
1034-
raise ValueError(f"Unknown IX obligation pressure: {extra[0]}")
1035-
1036-
1037-
def _unique_preserving_order(values: Iterable[str]) -> tuple[str, ...]:
1038-
"""Return unique text values while preserving first-seen order."""
1039-
1040-
seen: set[str] = set()
1041-
unique: list[str] = []
1042-
for value in values:
1043-
if value not in seen:
1044-
unique.append(value)
1045-
seen.add(value)
1046-
return tuple(unique)
1047-
1048-
1049-
def _require_non_empty(value: str, label: str) -> str:
1050-
"""Return stripped text or raise when empty."""
1051-
1052-
normalized = value.strip()
1053-
if not normalized:
1054-
raise ValueError(f"{label} must not be empty.")
1055-
return normalized
1056-
1057-
1058-
def _require_sha256(value: str, label: str) -> str:
1059-
"""Require a deterministic SHA-256 fingerprint value."""
1060-
1061-
normalized = _require_non_empty(value, label)
1062-
if len(normalized) != 64:
1063-
raise ValueError(f"{label} must be a SHA-256 fingerprint.")
1064-
try:
1065-
int(normalized, 16)
1066-
except ValueError as exc:
1067-
raise ValueError(f"{label} must be hexadecimal.") from exc
1068-
return normalized
1069-
1070-
1071988
def _stable_sha256(payload: Mapping[str, Any]) -> str:
1072989
"""Return deterministic SHA-256 over a canonical JSON payload."""
1073990

0 commit comments

Comments
 (0)