chimera-memory-types 0.1.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.
- chimera_memory_types/__init__.py +47 -0
- chimera_memory_types/falsifier.py +27 -0
- chimera_memory_types/finding.py +89 -0
- chimera_memory_types/knowledge.py +176 -0
- chimera_memory_types/optimization.py +161 -0
- chimera_memory_types/py.typed +0 -0
- chimera_memory_types/reality_class.py +35 -0
- chimera_memory_types/settlement.py +81 -0
- chimera_memory_types/temporal.py +43 -0
- chimera_memory_types/warrant.py +52 -0
- chimera_memory_types-0.1.0.dist-info/METADATA +34 -0
- chimera_memory_types-0.1.0.dist-info/RECORD +14 -0
- chimera_memory_types-0.1.0.dist-info/WHEEL +4 -0
- chimera_memory_types-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""chimera-memory-types — minimal public schema types for chimera-memory."""
|
|
2
|
+
|
|
3
|
+
from chimera_memory_types.falsifier import Falsifier, SettlementWindow
|
|
4
|
+
from chimera_memory_types.finding import EvidenceRef, EvidenceRefType
|
|
5
|
+
from chimera_memory_types.knowledge import (
|
|
6
|
+
Claim,
|
|
7
|
+
ClaimStatus,
|
|
8
|
+
ClaimType,
|
|
9
|
+
EvidenceBundle,
|
|
10
|
+
)
|
|
11
|
+
from chimera_memory_types.optimization import Intervention
|
|
12
|
+
from chimera_memory_types.reality_class import RealityClass, SubstrateLayer
|
|
13
|
+
from chimera_memory_types.settlement import (
|
|
14
|
+
ScoreConfig,
|
|
15
|
+
ScoredOutcome,
|
|
16
|
+
ScoreFamily,
|
|
17
|
+
SettlementEvent,
|
|
18
|
+
SettlementRecord,
|
|
19
|
+
SettlementState,
|
|
20
|
+
SettlementStatus,
|
|
21
|
+
)
|
|
22
|
+
from chimera_memory_types.temporal import LeakageStatus, TemporalSeal
|
|
23
|
+
from chimera_memory_types.warrant import Warrant
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"Claim",
|
|
27
|
+
"ClaimStatus",
|
|
28
|
+
"ClaimType",
|
|
29
|
+
"EvidenceBundle",
|
|
30
|
+
"EvidenceRef",
|
|
31
|
+
"EvidenceRefType",
|
|
32
|
+
"Falsifier",
|
|
33
|
+
"Intervention",
|
|
34
|
+
"LeakageStatus",
|
|
35
|
+
"RealityClass",
|
|
36
|
+
"ScoreConfig",
|
|
37
|
+
"ScoreFamily",
|
|
38
|
+
"ScoredOutcome",
|
|
39
|
+
"SettlementEvent",
|
|
40
|
+
"SettlementRecord",
|
|
41
|
+
"SettlementState",
|
|
42
|
+
"SettlementStatus",
|
|
43
|
+
"SettlementWindow",
|
|
44
|
+
"SubstrateLayer",
|
|
45
|
+
"TemporalSeal",
|
|
46
|
+
"Warrant",
|
|
47
|
+
]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Falsifier schema models."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
from typing import Any, Literal
|
|
7
|
+
|
|
8
|
+
from pydantic import BaseModel, Field
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class SettlementWindow(BaseModel):
|
|
12
|
+
opens_at: datetime | None = None
|
|
13
|
+
closes_at: datetime | None = None
|
|
14
|
+
max_delay_seconds: int | None = Field(default=None, ge=0)
|
|
15
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class Falsifier(BaseModel):
|
|
19
|
+
predicate: str
|
|
20
|
+
predicate_kind: Literal["threshold", "boolean", "membership", "absence"]
|
|
21
|
+
settlement_window: SettlementWindow | None = None
|
|
22
|
+
vacuous: bool = False
|
|
23
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
24
|
+
|
|
25
|
+
def require_promotable(self) -> None:
|
|
26
|
+
if self.vacuous:
|
|
27
|
+
raise ValueError("vacuous falsifier cannot be promoted")
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""Finding, EvidencePack, Scorecard — the output contracts of a run."""
|
|
2
|
+
|
|
3
|
+
import uuid
|
|
4
|
+
from datetime import UTC, datetime
|
|
5
|
+
from enum import StrEnum
|
|
6
|
+
from typing import Any, Literal
|
|
7
|
+
|
|
8
|
+
from pydantic import BaseModel, Field
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class FindingSeverity(StrEnum):
|
|
12
|
+
BLOCKER = "blocker"
|
|
13
|
+
WARNING = "warning"
|
|
14
|
+
INFO = "info"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class EvidenceRefType(StrEnum):
|
|
18
|
+
"""Discriminant for a typed evidence reference."""
|
|
19
|
+
|
|
20
|
+
SESSION = "session"
|
|
21
|
+
ARTIFACT = "artifact"
|
|
22
|
+
SPAN = "span"
|
|
23
|
+
FINDING = "finding"
|
|
24
|
+
RUN = "run"
|
|
25
|
+
EXTERNAL = "external"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class EvidenceRef(BaseModel):
|
|
29
|
+
"""Typed, machine-parseable reference to a piece of evidence."""
|
|
30
|
+
|
|
31
|
+
ref_type: EvidenceRefType
|
|
32
|
+
ref_id: str
|
|
33
|
+
available_at: datetime | None = None
|
|
34
|
+
content_hash: str | None = None
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class BaselineComparison(BaseModel):
|
|
38
|
+
baseline_run_id: str
|
|
39
|
+
was_present_in_baseline: bool
|
|
40
|
+
severity_change: Literal["new", "worsened", "unchanged", "improved"] | None = None
|
|
41
|
+
delta_summary: str | None = None
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class Finding(BaseModel):
|
|
45
|
+
finding_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
46
|
+
run_id: str
|
|
47
|
+
severity: FindingSeverity
|
|
48
|
+
category: str
|
|
49
|
+
title: str
|
|
50
|
+
summary: str
|
|
51
|
+
evidence_refs: list[str] = []
|
|
52
|
+
typed_evidence_refs: list[EvidenceRef] = []
|
|
53
|
+
reproduction_path: list[str] = []
|
|
54
|
+
affected_segments: list[str] = []
|
|
55
|
+
root_cause_hypothesis: str | None = None
|
|
56
|
+
suggested_fix: str | None = None
|
|
57
|
+
confidence: float = Field(ge=0.0, le=1.0)
|
|
58
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
59
|
+
baseline_comparison: BaselineComparison | None = None
|
|
60
|
+
branch_id: str | None = None
|
|
61
|
+
divergence_point: int | None = None
|
|
62
|
+
branch_lineage_ref: str | None = None
|
|
63
|
+
determinism_certificate_id: str | None = None
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class ArtifactRef(BaseModel):
|
|
67
|
+
artifact_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
68
|
+
artifact_type: str
|
|
69
|
+
storage_uri: str
|
|
70
|
+
content_hash: str
|
|
71
|
+
run_id: str
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class Scorecard(BaseModel):
|
|
75
|
+
run_id: str
|
|
76
|
+
overall_result: Literal["pass", "block", "review_required"]
|
|
77
|
+
metric_results: dict[str, float] = {}
|
|
78
|
+
rule_results: dict[str, Any] = {}
|
|
79
|
+
finding_count_by_severity: dict[str, int] = {}
|
|
80
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class EvidencePack(BaseModel):
|
|
84
|
+
evidence_pack_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
85
|
+
run_id: str
|
|
86
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
87
|
+
artifact_refs: list[ArtifactRef] = []
|
|
88
|
+
span_refs: list[str] = []
|
|
89
|
+
scorecard: Scorecard | None = None
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"""Knowledge layer contracts for chimera-memory-types."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import uuid
|
|
6
|
+
from datetime import UTC, datetime
|
|
7
|
+
from enum import StrEnum
|
|
8
|
+
from typing import Any, Literal
|
|
9
|
+
|
|
10
|
+
from pydantic import BaseModel, Field
|
|
11
|
+
|
|
12
|
+
from chimera_memory_types.falsifier import Falsifier
|
|
13
|
+
from chimera_memory_types.finding import EvidenceRef
|
|
14
|
+
from chimera_memory_types.optimization import Intervention
|
|
15
|
+
from chimera_memory_types.reality_class import RealityClass
|
|
16
|
+
from chimera_memory_types.settlement import SettlementState
|
|
17
|
+
from chimera_memory_types.temporal import TemporalSeal
|
|
18
|
+
from chimera_memory_types.warrant import Warrant
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ClaimType(StrEnum):
|
|
22
|
+
INTERVENTION_EFFECT = "intervention_effect"
|
|
23
|
+
FAILURE_PATTERN = "failure_pattern"
|
|
24
|
+
REGRESSION_RISK = "regression_risk"
|
|
25
|
+
TRADEOFF_PATTERN = "tradeoff_pattern"
|
|
26
|
+
DOMINANCE_PATTERN = "dominance_pattern"
|
|
27
|
+
BACKTESTED_PREDICTION = "backtested_prediction"
|
|
28
|
+
CAUSAL_POINT = "causal_point"
|
|
29
|
+
CAUSAL_BOUNDED = "causal_bounded"
|
|
30
|
+
NEGATIVE = "negative"
|
|
31
|
+
ADMISSIBLE_WORLD = "admissible_world"
|
|
32
|
+
UNANSWERABLE = "unanswerable"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class ClaimStatus(StrEnum):
|
|
36
|
+
PROPOSED = "proposed"
|
|
37
|
+
SUPPORTED = "supported"
|
|
38
|
+
VALIDATED = "validated"
|
|
39
|
+
STALE = "stale"
|
|
40
|
+
CONTRADICTED = "contradicted"
|
|
41
|
+
REJECTED = "rejected"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class DriftStatus(StrEnum):
|
|
45
|
+
FRESH = "fresh"
|
|
46
|
+
AGING = "aging"
|
|
47
|
+
STALE = "stale"
|
|
48
|
+
CONTRADICTED = "contradicted"
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class PatternType(StrEnum):
|
|
52
|
+
REPEATED_FINDING = "repeated_finding"
|
|
53
|
+
REPEATED_SUCCESS = "repeated_success"
|
|
54
|
+
REPEATED_FAILURE = "repeated_failure"
|
|
55
|
+
REPEATED_TRADEOFF = "repeated_tradeoff"
|
|
56
|
+
DOMINANCE_CLUSTER = "dominance_cluster"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class EvidenceBundle(BaseModel):
|
|
60
|
+
"""A traceable collection of evidence linked to a Claim or Pattern."""
|
|
61
|
+
|
|
62
|
+
bundle_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
63
|
+
run_ids: list[str] = Field(default_factory=list)
|
|
64
|
+
finding_ids: list[str] = Field(default_factory=list)
|
|
65
|
+
recommendation_ids: list[str] = Field(default_factory=list)
|
|
66
|
+
branch_refs: list[str] = Field(default_factory=list)
|
|
67
|
+
artifact_refs: list[str] = Field(default_factory=list)
|
|
68
|
+
evidence_refs: list[EvidenceRef] = Field(default_factory=list)
|
|
69
|
+
summary: str = ""
|
|
70
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
71
|
+
reality_class: RealityClass = RealityClass.INFERRED
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class ValidityRange(BaseModel):
|
|
75
|
+
world_types: list[str] = Field(default_factory=list)
|
|
76
|
+
context_signature_ids: list[str] = Field(default_factory=list)
|
|
77
|
+
min_evidence_count: int = 1
|
|
78
|
+
expires_after_runs: int | None = None
|
|
79
|
+
scope_note: str = ""
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class ContextSignature(BaseModel):
|
|
83
|
+
signature_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
84
|
+
world_type: str
|
|
85
|
+
target_class: str | None = None
|
|
86
|
+
actor_mix: dict[str, Any] = Field(default_factory=dict)
|
|
87
|
+
scenario_family: str | None = None
|
|
88
|
+
mutation_family: str | None = None
|
|
89
|
+
objective_family: str | None = None
|
|
90
|
+
complexity_bucket: str | None = None
|
|
91
|
+
resource_regime: dict[str, Any] = Field(default_factory=dict)
|
|
92
|
+
dimensions: dict[str, Any] = Field(default_factory=dict)
|
|
93
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class Claim(BaseModel):
|
|
97
|
+
"""An evidence-backed assertion about world behavior."""
|
|
98
|
+
|
|
99
|
+
claim_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
100
|
+
claim_type: ClaimType
|
|
101
|
+
claim_status: ClaimStatus = ClaimStatus.PROPOSED
|
|
102
|
+
title: str
|
|
103
|
+
summary: str
|
|
104
|
+
evidence: EvidenceBundle
|
|
105
|
+
context_signature_id: str | None = None
|
|
106
|
+
validity_range: ValidityRange = Field(default_factory=ValidityRange)
|
|
107
|
+
confidence: float = Field(ge=0.0, le=1.0, default=0.5)
|
|
108
|
+
formal_statement: str | None = None
|
|
109
|
+
temporal_seal: TemporalSeal | None = None
|
|
110
|
+
warrant: Warrant | None = None
|
|
111
|
+
falsifier: Falsifier | None = None
|
|
112
|
+
settlement: SettlementState | None = None
|
|
113
|
+
world_version: str | None = None
|
|
114
|
+
model_version: str | None = None
|
|
115
|
+
registry_record_id: str | None = None
|
|
116
|
+
drift_status: DriftStatus = DriftStatus.FRESH
|
|
117
|
+
supporting_run_ids: list[str] = Field(default_factory=list)
|
|
118
|
+
contradicting_run_ids: list[str] = Field(default_factory=list)
|
|
119
|
+
linked_intervention_ids: list[str] = Field(default_factory=list)
|
|
120
|
+
linked_pattern_ids: list[str] = Field(default_factory=list)
|
|
121
|
+
world_type: str
|
|
122
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
123
|
+
updated_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
124
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
125
|
+
reality_class: RealityClass = RealityClass.INFERRED
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class Pattern(BaseModel):
|
|
129
|
+
pattern_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
130
|
+
pattern_type: PatternType
|
|
131
|
+
title: str
|
|
132
|
+
description: str
|
|
133
|
+
supporting_claim_ids: list[str] = Field(default_factory=list)
|
|
134
|
+
occurrence_count: int = 1
|
|
135
|
+
world_type: str
|
|
136
|
+
context_signature_id: str | None = None
|
|
137
|
+
confidence: float = Field(ge=0.0, le=1.0, default=0.5)
|
|
138
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
139
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
140
|
+
reality_class: RealityClass = RealityClass.INFERRED
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class InterventionEvaluation(BaseModel):
|
|
144
|
+
optimization_run_id: str
|
|
145
|
+
candidate_id: str
|
|
146
|
+
score_delta: dict[str, float] = Field(default_factory=dict)
|
|
147
|
+
status: str = "scored"
|
|
148
|
+
rank: int | None = None
|
|
149
|
+
accepted: bool = False
|
|
150
|
+
evaluated_at: datetime | None = None
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class InterventionMemory(BaseModel):
|
|
154
|
+
memory_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
155
|
+
intervention: Intervention
|
|
156
|
+
world_type: str
|
|
157
|
+
context_signature_id: str | None = None
|
|
158
|
+
evaluations: list[InterventionEvaluation] = Field(default_factory=list)
|
|
159
|
+
claim_ids: list[str] = Field(default_factory=list)
|
|
160
|
+
pattern_ids: list[str] = Field(default_factory=list)
|
|
161
|
+
times_tried: int = 0
|
|
162
|
+
times_succeeded: int = 0
|
|
163
|
+
times_failed: int = 0
|
|
164
|
+
times_dominated: int = 0
|
|
165
|
+
last_evaluated_at: datetime | None = None
|
|
166
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
167
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class KnowledgeRef(BaseModel):
|
|
171
|
+
ref_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
172
|
+
ref_type: Literal["claim", "pattern", "intervention_memory"]
|
|
173
|
+
ref_target_id: str
|
|
174
|
+
world_type: str
|
|
175
|
+
context_note: str = ""
|
|
176
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"""Optimization and decision layer contracts."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import uuid
|
|
6
|
+
from datetime import UTC, datetime
|
|
7
|
+
from enum import StrEnum
|
|
8
|
+
from typing import Any, Literal
|
|
9
|
+
|
|
10
|
+
from pydantic import BaseModel, Field
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class OptimizationStatus(StrEnum):
|
|
14
|
+
PENDING = "pending"
|
|
15
|
+
RUNNING = "running"
|
|
16
|
+
COMPLETED = "completed"
|
|
17
|
+
FAILED = "failed"
|
|
18
|
+
CANCELLED = "cancelled"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
OPTIMIZATION_STATUS_TRANSITIONS: dict[OptimizationStatus, set[OptimizationStatus]] = {
|
|
22
|
+
OptimizationStatus.PENDING: {OptimizationStatus.RUNNING, OptimizationStatus.CANCELLED},
|
|
23
|
+
OptimizationStatus.RUNNING: {
|
|
24
|
+
OptimizationStatus.COMPLETED,
|
|
25
|
+
OptimizationStatus.FAILED,
|
|
26
|
+
OptimizationStatus.CANCELLED,
|
|
27
|
+
},
|
|
28
|
+
OptimizationStatus.COMPLETED: set(),
|
|
29
|
+
OptimizationStatus.FAILED: set(),
|
|
30
|
+
OptimizationStatus.CANCELLED: set(),
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def validate_optimization_status_transition(
|
|
35
|
+
current: OptimizationStatus,
|
|
36
|
+
target: OptimizationStatus,
|
|
37
|
+
) -> None:
|
|
38
|
+
allowed = OPTIMIZATION_STATUS_TRANSITIONS.get(current, set())
|
|
39
|
+
if target not in allowed:
|
|
40
|
+
raise ValueError(f"Invalid OptimizationStatus transition: {current.value} → {target.value}")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class Intervention(BaseModel):
|
|
44
|
+
"""A generic change applied to a world snapshot."""
|
|
45
|
+
|
|
46
|
+
intervention_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
47
|
+
intervention_type: str
|
|
48
|
+
target: str
|
|
49
|
+
parameters: dict[str, Any] = Field(default_factory=dict)
|
|
50
|
+
label: str = ""
|
|
51
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class InterventionSet(BaseModel):
|
|
55
|
+
set_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
56
|
+
label: str
|
|
57
|
+
interventions: list[Intervention]
|
|
58
|
+
world_type: str
|
|
59
|
+
version: str = "0.1.0"
|
|
60
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class CandidateIntervention(BaseModel):
|
|
64
|
+
candidate_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
65
|
+
intervention: Intervention
|
|
66
|
+
run_id: str | None = None
|
|
67
|
+
score_delta: dict[str, float] = Field(default_factory=dict)
|
|
68
|
+
scorecard: dict[str, Any] = Field(default_factory=dict)
|
|
69
|
+
rank: int | None = None
|
|
70
|
+
status: Literal["pending", "running", "simulation_launched", "scored", "failed", "skipped"] = (
|
|
71
|
+
"pending"
|
|
72
|
+
)
|
|
73
|
+
error: str | None = None
|
|
74
|
+
evaluated_at: datetime | None = None
|
|
75
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class Constraint(BaseModel):
|
|
79
|
+
constraint_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
80
|
+
label: str
|
|
81
|
+
metric: str
|
|
82
|
+
operator: Literal["gte", "lte", "gt", "lt", "eq", "neq"]
|
|
83
|
+
threshold: float
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class Objective(BaseModel):
|
|
87
|
+
objective_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
88
|
+
label: str
|
|
89
|
+
metric: str
|
|
90
|
+
direction: Literal["maximize", "minimize"]
|
|
91
|
+
weight: float = 1.0
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class SearchStrategy(StrEnum):
|
|
95
|
+
NONE = "none"
|
|
96
|
+
RANDOM = "random"
|
|
97
|
+
GRID = "grid"
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class OptimizationSpec(BaseModel):
|
|
101
|
+
spec_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
102
|
+
world_type: str
|
|
103
|
+
snapshot_id: str
|
|
104
|
+
baseline_run_id: str
|
|
105
|
+
objectives: list[Objective]
|
|
106
|
+
constraints: list[Constraint] = Field(default_factory=list)
|
|
107
|
+
candidates: list[CandidateIntervention]
|
|
108
|
+
search_budget: int = 20
|
|
109
|
+
seed: int = 0
|
|
110
|
+
search_strategy: SearchStrategy = SearchStrategy.NONE
|
|
111
|
+
warm_start_candidates: list[Intervention] = Field(default_factory=list)
|
|
112
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class Recommendation(BaseModel):
|
|
116
|
+
recommendation_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
117
|
+
title: str
|
|
118
|
+
summary: str
|
|
119
|
+
intervention: Intervention
|
|
120
|
+
evidence_run_ids: list[str]
|
|
121
|
+
tradeoffs: dict[str, Any] = Field(default_factory=dict)
|
|
122
|
+
confidence: float = Field(ge=0.0, le=1.0)
|
|
123
|
+
rank: int
|
|
124
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class TradeoffSummary(BaseModel):
|
|
128
|
+
summary_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
129
|
+
optimization_run_id: str
|
|
130
|
+
dominated_pairs: list[dict[str, Any]] = Field(default_factory=list)
|
|
131
|
+
pareto_front_candidate_ids: list[str] = Field(default_factory=list)
|
|
132
|
+
metric_improvements: dict[str, int] = Field(default_factory=dict)
|
|
133
|
+
narrative: str = ""
|
|
134
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class OptimizationResult(BaseModel):
|
|
138
|
+
result_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
139
|
+
optimization_run_id: str
|
|
140
|
+
top_candidates: list[CandidateIntervention]
|
|
141
|
+
recommendations: list[Recommendation]
|
|
142
|
+
tradeoff_summary: TradeoffSummary | None = None
|
|
143
|
+
candidates_evaluated: int
|
|
144
|
+
candidates_skipped: int
|
|
145
|
+
status: OptimizationStatus
|
|
146
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class DecisionMemoryEntry(BaseModel):
|
|
150
|
+
entry_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
151
|
+
optimization_run_id: str
|
|
152
|
+
candidate_id: str
|
|
153
|
+
intervention: Intervention
|
|
154
|
+
world_type: str
|
|
155
|
+
snapshot_id: str
|
|
156
|
+
run_id: str
|
|
157
|
+
score_delta: dict[str, float] = Field(default_factory=dict)
|
|
158
|
+
passed_constraints: bool = True
|
|
159
|
+
rank: int | None = None
|
|
160
|
+
context: dict[str, Any] = Field(default_factory=dict)
|
|
161
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Reality classification enum for chimera-memory-types.
|
|
2
|
+
|
|
3
|
+
Standalone copy — no chimera_substrate dependency.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from enum import StrEnum
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class RealityClass(StrEnum):
|
|
12
|
+
"""Explicit classification of what kind of truth a record represents."""
|
|
13
|
+
|
|
14
|
+
OBSERVED = "observed"
|
|
15
|
+
SIMULATED = "simulated"
|
|
16
|
+
COUNTERFACTUAL = "counterfactual"
|
|
17
|
+
INFERRED = "inferred"
|
|
18
|
+
RECOMMENDED = "recommended"
|
|
19
|
+
|
|
20
|
+
@classmethod
|
|
21
|
+
def require(cls, value: RealityClass | str | None) -> RealityClass:
|
|
22
|
+
if value is None:
|
|
23
|
+
raise ValueError("reality_class is required.")
|
|
24
|
+
if isinstance(value, cls):
|
|
25
|
+
return value
|
|
26
|
+
return cls(value)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class SubstrateLayer(StrEnum):
|
|
30
|
+
"""Which logical substrate layer produced or owns a record."""
|
|
31
|
+
|
|
32
|
+
CANONICAL = "canonical"
|
|
33
|
+
SIGNAL = "signal"
|
|
34
|
+
PROJECTION = "projection"
|
|
35
|
+
CONTROL = "control"
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Settlement and wealth bookkeeping schema models."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import uuid
|
|
6
|
+
from datetime import UTC, datetime
|
|
7
|
+
from enum import StrEnum
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from pydantic import BaseModel, Field
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ScoreFamily(StrEnum):
|
|
14
|
+
BRIER = "brier"
|
|
15
|
+
LOG = "log"
|
|
16
|
+
CRPS_GAUSSIAN = "crps_gaussian"
|
|
17
|
+
CRPS_ENSEMBLE = "crps_ensemble"
|
|
18
|
+
INTERVAL = "interval"
|
|
19
|
+
NEGATIVE_DEPTH = "negative_depth"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ScoreConfig(BaseModel):
|
|
23
|
+
family: ScoreFamily = ScoreFamily.BRIER
|
|
24
|
+
params: dict[str, Any] = Field(default_factory=dict)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ScoredOutcome(BaseModel):
|
|
28
|
+
value: Any
|
|
29
|
+
observed_at: datetime | None = None
|
|
30
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class SettlementStatus(StrEnum):
|
|
34
|
+
PENDING = "pending"
|
|
35
|
+
SETTLED = "settled"
|
|
36
|
+
VALIDATED = "validated"
|
|
37
|
+
CONTRADICTED = "contradicted"
|
|
38
|
+
INCONCLUSIVE = "inconclusive"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class SettlementEvent(BaseModel):
|
|
42
|
+
event_key: str
|
|
43
|
+
observed_at: datetime
|
|
44
|
+
outcome: Any
|
|
45
|
+
source_ref: str | None = None
|
|
46
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class WealthUpdate(BaseModel):
|
|
50
|
+
event_key: str
|
|
51
|
+
proper_score: float | None = None
|
|
52
|
+
wealth_multiplier: float = Field(default=1.0, gt=0.0)
|
|
53
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
54
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class WealthState(BaseModel):
|
|
58
|
+
wealth: float = Field(default=1.0, gt=0.0)
|
|
59
|
+
log_wealth: float = 0.0
|
|
60
|
+
updates: list[WealthUpdate] = Field(default_factory=list)
|
|
61
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class SettlementState(BaseModel):
|
|
65
|
+
status: SettlementStatus = SettlementStatus.PENDING
|
|
66
|
+
score_config: ScoreConfig = Field(default_factory=ScoreConfig)
|
|
67
|
+
events: list[SettlementEvent] = Field(default_factory=list)
|
|
68
|
+
scored_outcomes: list[ScoredOutcome] = Field(default_factory=list)
|
|
69
|
+
proper_score: float | None = None
|
|
70
|
+
wealth: WealthState = Field(default_factory=WealthState)
|
|
71
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class SettlementRecord(BaseModel):
|
|
75
|
+
record_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
76
|
+
claim_id: str
|
|
77
|
+
settlement: SettlementState
|
|
78
|
+
content_hash: str | None = None
|
|
79
|
+
signature: str | None = None
|
|
80
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
81
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Temporal sealing schema models."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from datetime import UTC, datetime
|
|
6
|
+
from enum import StrEnum
|
|
7
|
+
|
|
8
|
+
from pydantic import BaseModel, Field, model_validator
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class LeakageStatus(StrEnum):
|
|
12
|
+
CLEAN = "clean"
|
|
13
|
+
POISONED = "poisoned"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class TemporalSeal(BaseModel):
|
|
17
|
+
seal_id: str | None = None
|
|
18
|
+
claim_time: datetime
|
|
19
|
+
evidence_window_start: datetime | None = None
|
|
20
|
+
evidence_window_end: datetime | None = None
|
|
21
|
+
outcome_time: datetime | None = None
|
|
22
|
+
leakage_status: LeakageStatus = LeakageStatus.CLEAN
|
|
23
|
+
metadata: dict[str, str] = Field(default_factory=dict)
|
|
24
|
+
|
|
25
|
+
@model_validator(mode="after")
|
|
26
|
+
def compute_leakage_status(self) -> TemporalSeal:
|
|
27
|
+
if self.claim_time.tzinfo is None:
|
|
28
|
+
self.claim_time = self.claim_time.replace(tzinfo=UTC)
|
|
29
|
+
if self.evidence_window_start is not None and self.evidence_window_start.tzinfo is None:
|
|
30
|
+
self.evidence_window_start = self.evidence_window_start.replace(tzinfo=UTC)
|
|
31
|
+
if self.evidence_window_end is not None and self.evidence_window_end.tzinfo is None:
|
|
32
|
+
self.evidence_window_end = self.evidence_window_end.replace(tzinfo=UTC)
|
|
33
|
+
if self.outcome_time is not None and self.outcome_time.tzinfo is None:
|
|
34
|
+
self.outcome_time = self.outcome_time.replace(tzinfo=UTC)
|
|
35
|
+
|
|
36
|
+
poisoned = False
|
|
37
|
+
if self.evidence_window_end is not None:
|
|
38
|
+
poisoned = self.evidence_window_end > self.claim_time
|
|
39
|
+
if self.outcome_time is not None:
|
|
40
|
+
poisoned = poisoned or self.outcome_time <= self.claim_time
|
|
41
|
+
|
|
42
|
+
self.leakage_status = LeakageStatus.POISONED if poisoned else LeakageStatus.CLEAN
|
|
43
|
+
return self
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Warrant schema models."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from enum import StrEnum
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from pydantic import BaseModel, Field, model_validator
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ComputabilityVerdict(StrEnum):
|
|
12
|
+
COMPUTABLE = "computable"
|
|
13
|
+
APPROXIMABLE = "approximable"
|
|
14
|
+
UNCOMPUTABLE = "uncomputable"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class CausalVerdict(StrEnum):
|
|
18
|
+
IDENTIFIED = "identified"
|
|
19
|
+
BOUNDED = "bounded"
|
|
20
|
+
UNIDENTIFIABLE = "unidentifiable"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ExperimentSpec(BaseModel):
|
|
24
|
+
name: str
|
|
25
|
+
design: str
|
|
26
|
+
assignment_unit: str | None = None
|
|
27
|
+
outcome_metric: str | None = None
|
|
28
|
+
minimum_sample_size: int | None = Field(default=None, ge=1)
|
|
29
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Warrant(BaseModel):
|
|
33
|
+
computability: ComputabilityVerdict = ComputabilityVerdict.COMPUTABLE
|
|
34
|
+
causal_verdict: CausalVerdict
|
|
35
|
+
estimand: str | None = None
|
|
36
|
+
bounds: tuple[float, float] | None = None
|
|
37
|
+
experiment_spec: ExperimentSpec | None = None
|
|
38
|
+
assumptions: list[str] = Field(default_factory=list)
|
|
39
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
40
|
+
|
|
41
|
+
@model_validator(mode="after")
|
|
42
|
+
def validate_verdict_requirements(self) -> Warrant:
|
|
43
|
+
if self.causal_verdict is CausalVerdict.IDENTIFIED and self.estimand is None:
|
|
44
|
+
raise ValueError("IDENTIFIED warrant requires estimand")
|
|
45
|
+
if self.causal_verdict is CausalVerdict.BOUNDED and self.bounds is None:
|
|
46
|
+
raise ValueError("BOUNDED warrant requires bounds")
|
|
47
|
+
if (
|
|
48
|
+
self.causal_verdict is CausalVerdict.UNIDENTIFIABLE
|
|
49
|
+
and self.experiment_spec is None
|
|
50
|
+
):
|
|
51
|
+
raise ValueError("UNIDENTIFIABLE warrant requires experiment_spec")
|
|
52
|
+
return self
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: chimera-memory-types
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Minimal schema types for chimera-memory — claims, settlements, evidence refs, and temporal seals
|
|
5
|
+
License: MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2026 Chimera / ORIAS
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Classifier: Development Status :: 3 - Alpha
|
|
28
|
+
Classifier: Intended Audience :: Developers
|
|
29
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
30
|
+
Classifier: Programming Language :: Python :: 3
|
|
31
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
32
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
33
|
+
Requires-Python: >=3.12
|
|
34
|
+
Requires-Dist: pydantic>=2.9.0
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
chimera_memory_types/__init__.py,sha256=NarE4vdEbSRWnHD7hZa6p6CHMBUSn0KcVhqNY8JOd4g,1212
|
|
2
|
+
chimera_memory_types/falsifier.py,sha256=vVuib4baCdJDvmYVY2p4TO-Iw1p-_-gKTCV868thbSo,804
|
|
3
|
+
chimera_memory_types/finding.py,sha256=vXGrpl2yUpdR6feq7HNb3gU3r6ImJIHXZk6Z9MRAoUs,2585
|
|
4
|
+
chimera_memory_types/knowledge.py,sha256=QnqEPfhzJp5Pr83MqoXDs8qQp633dkx2pC0bCMPa7nE,6438
|
|
5
|
+
chimera_memory_types/optimization.py,sha256=Jkqa4b4qPp9RwAZp854nV07JUvg6b84CG2VU-zjiEOU,5234
|
|
6
|
+
chimera_memory_types/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
chimera_memory_types/reality_class.py,sha256=-PjmENypT4511ASj_JpcRAFbcZ4t6Hu33HknvV4In8E,902
|
|
8
|
+
chimera_memory_types/settlement.py,sha256=fvTW_4mAJKNjbtZrUrZjbAfCiDhJ1TqJUtFYpl2VQ9U,2403
|
|
9
|
+
chimera_memory_types/temporal.py,sha256=SdcXAb63cQ-jRiqu5X2_UMK5E4OB5VtZH4zKBwjJkyQ,1688
|
|
10
|
+
chimera_memory_types/warrant.py,sha256=znIanJOvaAJOwvB5r9zzqzbnSg_5j3AzDFCLmqNAfXw,1701
|
|
11
|
+
chimera_memory_types-0.1.0.dist-info/METADATA,sha256=RP8pk3tYfLFo8H4YziwhqxAp1H_5G7SDFS71rJsjI7g,1801
|
|
12
|
+
chimera_memory_types-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
13
|
+
chimera_memory_types-0.1.0.dist-info/licenses/LICENSE,sha256=_SDgjN43B53BtJt-gcEICy1qICF5rkA2mzHRNarsz70,1072
|
|
14
|
+
chimera_memory_types-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Chimera / ORIAS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|