fable-engine 1.3.1__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.
- fable_compressor.py +356 -0
- fable_engine/__init__.py +1 -0
- fable_engine/actions/__init__.py +291 -0
- fable_engine/actions/cas.py +182 -0
- fable_engine/actions/deliberation.py +523 -0
- fable_engine/actions/fleet.py +807 -0
- fable_engine/actions/lifecycle.py +298 -0
- fable_engine/actions/scrapers.py +116 -0
- fable_engine/actions/system3.py +815 -0
- fable_engine/browser.py +824 -0
- fable_engine/cas.py +974 -0
- fable_engine/fable_session.json +510 -0
- fable_engine/guards.py +283 -0
- fable_engine/schema.py +714 -0
- fable_engine/scrapers/__init__.py +32 -0
- fable_engine/scrapers/arxiv.py +115 -0
- fable_engine/scrapers/base.py +386 -0
- fable_engine/scrapers/github.py +129 -0
- fable_engine/scrapers/reddit.py +154 -0
- fable_engine/scrapers/web.py +120 -0
- fable_engine/scrapers/x.py +125 -0
- fable_engine/scrapers/youtube.py +132 -0
- fable_engine/server.py +414 -0
- fable_engine/session.py +1819 -0
- fable_engine/test_server.py +1362 -0
- fable_engine/updater.py +541 -0
- fable_engine-1.3.1.dist-info/LICENSE +22 -0
- fable_engine-1.3.1.dist-info/METADATA +173 -0
- fable_engine-1.3.1.dist-info/RECORD +104 -0
- fable_engine-1.3.1.dist-info/WHEEL +5 -0
- fable_engine-1.3.1.dist-info/entry_points.txt +5 -0
- fable_engine-1.3.1.dist-info/top_level.txt +6 -0
- fable_mode/__init__.py +3 -0
- fable_mode/__main__.py +4 -0
- fable_mode/adapters.py +1014 -0
- fable_mode/installer.py +553 -0
- fable_mode/launcher.py +437 -0
- fable_mode/manifest.py +142 -0
- fable_mode/resources.json +114 -0
- fable_mode/safety.py +103 -0
- fable_mode_entry.py +10 -0
- fable_v2/__init__.py +146 -0
- fable_v2/adapters.py +151 -0
- fable_v2/coder_fleet/__init__.py +100 -0
- fable_v2/coder_fleet/ast_tools.py +158 -0
- fable_v2/coder_fleet/compute.py +199 -0
- fable_v2/coder_fleet/design_engine.py +1316 -0
- fable_v2/coder_fleet/diagnostics.py +293 -0
- fable_v2/coder_fleet/fleet_dispatcher.py +214 -0
- fable_v2/coder_fleet/mock_auditor.py +306 -0
- fable_v2/coder_fleet/mutation.py +216 -0
- fable_v2/coder_fleet/property_oracle.py +260 -0
- fable_v2/coder_fleet/receipt_attestor.py +122 -0
- fable_v2/coder_fleet/red_team_swarm.py +908 -0
- fable_v2/coder_fleet/test_harness.py +198 -0
- fable_v2/coder_fleet/vector_engine.py +1287 -0
- fable_v2/coder_fleet/visual.py +357 -0
- fable_v2/coder_fleet/workspace.py +153 -0
- fable_v2/cortical/__init__.py +20 -0
- fable_v2/cortical/plasticity_engine.py +992 -0
- fable_v2/execution_broker.py +811 -0
- fable_v2/proof_engine.py +1141 -0
- fable_v2/protocol.py +485 -0
- fable_v2/runtime.py +1010 -0
- fable_v2/system3/__init__.py +204 -0
- fable_v2/system3/causal.py +558 -0
- fable_v2/system3/dialectical.py +577 -0
- fable_v2/system3/evolution.py +503 -0
- fable_v2/system3/executive.py +338 -0
- fable_v2/system3/free_energy.py +479 -0
- fable_v2/system3/hyperbolic.py +555 -0
- fable_v2/system3/induction.py +336 -0
- fable_v2/system3/kripke.py +548 -0
- fable_v2/system3/oracle.py +745 -0
- fable_v2/verifiers.py +72 -0
- tests/__init__.py +1 -0
- tests/test_anti_loop_circuit_breaker.py +64 -0
- tests/test_auto_updater.py +407 -0
- tests/test_coder_fleet.py +535 -0
- tests/test_delegation_compiler.py +54 -0
- tests/test_descriptor_boundaries.py +126 -0
- tests/test_design_engine.py +603 -0
- tests/test_epistemic_evidence_validator.py +66 -0
- tests/test_execution_broker.py +233 -0
- tests/test_fable_v2.py +406 -0
- tests/test_fleet_transitions.py +116 -0
- tests/test_fsm_redteam_evolution.py +406 -0
- tests/test_goal_rubric_and_pipeline.py +367 -0
- tests/test_hebbian_plasticity.py +585 -0
- tests/test_packaging_runtime.py +194 -0
- tests/test_proof_engine.py +259 -0
- tests/test_red_team_swarm.py +645 -0
- tests/test_redteam_remediation.py +169 -0
- tests/test_registration_transaction.py +375 -0
- tests/test_requested_regressions.py +467 -0
- tests/test_scrapers.py +370 -0
- tests/test_server_actions.py +93 -0
- tests/test_server_frontier_actions.py +269 -0
- tests/test_server_protocol.py +88 -0
- tests/test_stealth_browser.py +970 -0
- tests/test_system3.py +381 -0
- tests/test_system3_deep_integration.py +385 -0
- tests/test_system3_frontier.py +436 -0
- tests/test_vector_engine.py +608 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
"""System 3 Executive Director & Tri-Level Cognitive Orchestrator.
|
|
2
|
+
|
|
3
|
+
Implements Tri-Level Cognitive Arbitration (System 1 Fast / System 2 Deliberative / System 3 Meta),
|
|
4
|
+
Cognitive Bias Detection (confirmation, anchoring, sunk cost, circularity),
|
|
5
|
+
and Dynamic Search Heuristic Rewriting for MCTS and Pareto optimization.
|
|
6
|
+
Zero external dependencies.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from dataclasses import dataclass, field, asdict
|
|
12
|
+
from enum import Enum
|
|
13
|
+
from typing import Any, Callable, Dict, List, Optional, Set, Tuple
|
|
14
|
+
import copy
|
|
15
|
+
import hashlib
|
|
16
|
+
import json
|
|
17
|
+
import math
|
|
18
|
+
|
|
19
|
+
from .causal import CausalDAG
|
|
20
|
+
from .dialectical import DialecticalSynthesizer, ThesisCandidate, AntithesisCritique, Contradiction
|
|
21
|
+
from .evolution import CognitiveGenePool, CognitiveGenome, PARETO_DIMENSIONS
|
|
22
|
+
from .induction import MetaProofInducer, NeuroSymbolicAxiom
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class CognitiveGear(str, Enum):
|
|
26
|
+
"""Tri-level cognitive operating gear."""
|
|
27
|
+
SYSTEM_1_INTUITIVE = "system_1_intuitive" # Fast heuristics, pattern matching, lightweight scratch
|
|
28
|
+
SYSTEM_2_DELIBERATIVE = "system_2_deliberative" # 8-Pass deliberation, MCTS search, red-teaming, formal proof
|
|
29
|
+
SYSTEM_3_META_COGNITIVE = "system_3_meta_cognitive" # Meta-reflection, causal Pearl do-calculus, TRIZ evolution, axiom induction
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class CognitiveBiasType(str, Enum):
|
|
33
|
+
"""Recognized cognitive biases in reasoning deliberation."""
|
|
34
|
+
CONFIRMATION_BIAS = "confirmation_bias" # Selectively ignoring red-team critiques or failing tests
|
|
35
|
+
ANCHORING_BIAS = "anchoring_bias" # Over-committing to the first candidate archetype
|
|
36
|
+
AVAILABILITY_HEURISTIC = "availability_heuristic" # Defaulting to generic tropes without probing constraints
|
|
37
|
+
SUNK_COST_FALLACY = "sunk_cost_fallacy" # Persisting in failing design despite high contradiction density
|
|
38
|
+
CIRCULAR_REASONING = "circular_reasoning" # Self-justifying claims without external tool receipts
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass
|
|
42
|
+
class CognitiveBiasFinding:
|
|
43
|
+
"""Diagnostic report of a detected cognitive bias during deliberation."""
|
|
44
|
+
bias_type: CognitiveBiasType
|
|
45
|
+
severity: float # [0.0, 1.0]
|
|
46
|
+
detected_in: str
|
|
47
|
+
evidence_trail: str
|
|
48
|
+
mitigation_strategy: str
|
|
49
|
+
|
|
50
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
51
|
+
d = asdict(self)
|
|
52
|
+
d["bias_type"] = self.bias_type.value
|
|
53
|
+
return d
|
|
54
|
+
|
|
55
|
+
@classmethod
|
|
56
|
+
def from_dict(cls, data: Dict[str, Any]) -> "CognitiveBiasFinding":
|
|
57
|
+
data_copy = dict(data)
|
|
58
|
+
if "bias_type" in data_copy and isinstance(data_copy["bias_type"], str):
|
|
59
|
+
data_copy["bias_type"] = CognitiveBiasType(data_copy["bias_type"])
|
|
60
|
+
return cls(**data_copy)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@dataclass
|
|
64
|
+
class SearchHeuristicConfig:
|
|
65
|
+
"""Dynamic hyperparameters governing MCTS exploration, branch pruning, and verification."""
|
|
66
|
+
exploration_temperature: float = 0.75
|
|
67
|
+
pruning_threshold: float = 0.35
|
|
68
|
+
max_branching_factor: int = 4
|
|
69
|
+
pareto_dimension_weights: Dict[str, float] = field(
|
|
70
|
+
default_factory=lambda: {dim: 1.0 / len(PARETO_DIMENSIONS) for dim in PARETO_DIMENSIONS}
|
|
71
|
+
)
|
|
72
|
+
falsification_intensity: float = 0.80
|
|
73
|
+
min_verification_depth: int = 2
|
|
74
|
+
|
|
75
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
76
|
+
return asdict(self)
|
|
77
|
+
|
|
78
|
+
@classmethod
|
|
79
|
+
def from_dict(cls, data: Dict[str, Any]) -> "SearchHeuristicConfig":
|
|
80
|
+
return cls(**data)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class CognitiveBiasDetector:
|
|
84
|
+
"""
|
|
85
|
+
Automated diagnostic auditor inspecting epistemic ledgers, candidate histories,
|
|
86
|
+
and refinement cycles to prevent cognitive biases and logical traps.
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
def audit_session(self, session_data: Dict[str, Any]) -> List[CognitiveBiasFinding]:
|
|
90
|
+
"""Audit session state and return list of detected bias findings with mitigations."""
|
|
91
|
+
findings: List[CognitiveBiasFinding] = []
|
|
92
|
+
|
|
93
|
+
epistemic = session_data.get("epistemic_ledger", [])
|
|
94
|
+
refinements = session_data.get("refinement_cycles", [])
|
|
95
|
+
invariants = session_data.get("invariants", [])
|
|
96
|
+
phase = session_data.get("active_phase", "")
|
|
97
|
+
pacing_used = float(session_data.get("pacing_ratio", 0.0))
|
|
98
|
+
|
|
99
|
+
proven_items = [i for i in epistemic if i.get("tag") == "PROVEN"]
|
|
100
|
+
hypotheses = [i for i in epistemic if i.get("tag") == "HYPOTHESIS"]
|
|
101
|
+
unknowns = [i for i in epistemic if i.get("tag") == "UNKNOWN"]
|
|
102
|
+
|
|
103
|
+
# 1. Check for Confirmation Bias: Only hypotheses or zero unknowns probed
|
|
104
|
+
if len(hypotheses) > 3 and len(unknowns) == 0 and len(proven_items) == 0:
|
|
105
|
+
findings.append(
|
|
106
|
+
CognitiveBiasFinding(
|
|
107
|
+
bias_type=CognitiveBiasType.CONFIRMATION_BIAS,
|
|
108
|
+
severity=0.75,
|
|
109
|
+
detected_in="Epistemic Ledger",
|
|
110
|
+
evidence_trail=f"Found {len(hypotheses)} hypotheses but 0 [UNKNOWN] parameters and 0 [PROVEN] facts probed.",
|
|
111
|
+
mitigation_strategy="Formulate adversarial falsification tests and probe edge cases using run_command terminal tests.",
|
|
112
|
+
)
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
# 2. Check for Anchoring Bias: Advanced past Phase 2 with 0 refinement cycles or 1 candidate
|
|
116
|
+
if "Phase 3" in phase or "Phase 4" in phase:
|
|
117
|
+
if len(refinements) == 0:
|
|
118
|
+
findings.append(
|
|
119
|
+
CognitiveBiasFinding(
|
|
120
|
+
bias_type=CognitiveBiasType.ANCHORING_BIAS,
|
|
121
|
+
severity=0.85,
|
|
122
|
+
detected_in="Phase Progression",
|
|
123
|
+
evidence_trail=f"Session reached '{phase}' without logging any rethink-refine cycles.",
|
|
124
|
+
mitigation_strategy="Execute Multi-Archetype Exploration (Zero-Rush Rule): Evaluate 3-5 distinct paradigms across 10D matrix.",
|
|
125
|
+
)
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
# 3. Check for Sunk Cost Fallacy: Repeating same refinement focus area > 3 times with low progress
|
|
129
|
+
focus_counts: Dict[str, int] = {}
|
|
130
|
+
for r in refinements:
|
|
131
|
+
fa = str(r.get("focus_area", "")).strip().lower()
|
|
132
|
+
if fa:
|
|
133
|
+
focus_counts[fa] = focus_counts.get(fa, 0) + 1
|
|
134
|
+
|
|
135
|
+
for fa, count in focus_counts.items():
|
|
136
|
+
if count >= 3:
|
|
137
|
+
findings.append(
|
|
138
|
+
CognitiveBiasFinding(
|
|
139
|
+
bias_type=CognitiveBiasType.SUNK_COST_FALLACY,
|
|
140
|
+
severity=0.65,
|
|
141
|
+
detected_in=f"Refinement Focus '{fa}'",
|
|
142
|
+
evidence_trail=f"Area '{fa}' scrutinized {count} times consecutively without breakthrough.",
|
|
143
|
+
mitigation_strategy="Shift to System 3 Dialectical Synthesis: apply TRIZ Inversion (Principle 13) or Mechanics Substitution (Principle 28).",
|
|
144
|
+
)
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
# 4. Check for Circular Reasoning: Invariants with tautological proof sketches
|
|
148
|
+
for inv in invariants:
|
|
149
|
+
stmt = str(inv.get("formal_statement", "")).lower()
|
|
150
|
+
proof = str(inv.get("proof_or_rationale", "")).lower()
|
|
151
|
+
if len(proof) > 0 and (stmt == proof or (len(proof) < 20 and stmt in proof)):
|
|
152
|
+
findings.append(
|
|
153
|
+
CognitiveBiasFinding(
|
|
154
|
+
bias_type=CognitiveBiasType.CIRCULAR_REASONING,
|
|
155
|
+
severity=0.80,
|
|
156
|
+
detected_in=f"Invariant '{inv.get('name')}'",
|
|
157
|
+
evidence_trail="Invariant proof simply restates the formal statement without deductive justification or tool receipt.",
|
|
158
|
+
mitigation_strategy="Anchor invariant to concrete ToolReceipt output hash or construct inductive proof sketch via MetaProofInducer.",
|
|
159
|
+
)
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
return findings
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class DynamicSearchHeuristicRewriter:
|
|
166
|
+
"""
|
|
167
|
+
Dynamically adjusts search exploration temperature, pruning cutoffs,
|
|
168
|
+
and multi-objective Pareto weights based on meta-cognitive feedback.
|
|
169
|
+
"""
|
|
170
|
+
|
|
171
|
+
def rewrite_heuristics(
|
|
172
|
+
self,
|
|
173
|
+
current_config: SearchHeuristicConfig,
|
|
174
|
+
contradiction_density: float,
|
|
175
|
+
bias_findings: List[CognitiveBiasFinding],
|
|
176
|
+
brittleness_score: float = 0.0,
|
|
177
|
+
) -> SearchHeuristicConfig:
|
|
178
|
+
"""Calculate updated search heuristic parameters."""
|
|
179
|
+
new_config = copy.deepcopy(current_config)
|
|
180
|
+
|
|
181
|
+
# If high contradiction density or high brittleness, increase exploration temperature
|
|
182
|
+
if contradiction_density > 0.6 or brittleness_score > 0.5:
|
|
183
|
+
new_config.exploration_temperature = min(1.2, round(new_config.exploration_temperature + 0.20, 2))
|
|
184
|
+
new_config.max_branching_factor = min(8, new_config.max_branching_factor + 2)
|
|
185
|
+
new_config.falsification_intensity = min(1.0, round(new_config.falsification_intensity + 0.15, 2))
|
|
186
|
+
else:
|
|
187
|
+
# Settle into focused exploitation
|
|
188
|
+
new_config.exploration_temperature = max(0.3, round(new_config.exploration_temperature - 0.10, 2))
|
|
189
|
+
new_config.pruning_threshold = min(0.6, round(new_config.pruning_threshold + 0.05, 2))
|
|
190
|
+
|
|
191
|
+
# Adjust weights if biases detected
|
|
192
|
+
has_anchoring = any(b.bias_type == CognitiveBiasType.ANCHORING_BIAS for b in bias_findings)
|
|
193
|
+
if has_anchoring:
|
|
194
|
+
# Overweight simplicity, modularity, and testability to force refactoring
|
|
195
|
+
w = dict(new_config.pareto_dimension_weights)
|
|
196
|
+
w["simplicity"] = 1.5
|
|
197
|
+
w["modularity"] = 1.5
|
|
198
|
+
w["testability"] = 1.5
|
|
199
|
+
new_config.pareto_dimension_weights = w
|
|
200
|
+
|
|
201
|
+
return new_config
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
class TriLevelArbitrator:
|
|
205
|
+
"""
|
|
206
|
+
Arbitrates cognitive control among:
|
|
207
|
+
- System 1 (Fast Intuitive / Scratch Heuristics)
|
|
208
|
+
- System 2 (8-Pass Deliberative MCTS & Invariant Proofs)
|
|
209
|
+
- System 3 (Meta-Cognitive Dialectical Evolution & Pearl Do-Calculus)
|
|
210
|
+
"""
|
|
211
|
+
|
|
212
|
+
def arbitrate(
|
|
213
|
+
self,
|
|
214
|
+
task_complexity: float, # [0.0, 1.0]
|
|
215
|
+
contradiction_density: float, # [0.0, 1.0]
|
|
216
|
+
failure_count: int = 0,
|
|
217
|
+
epistemic_uncertainty: float = 0.5,
|
|
218
|
+
) -> Dict[str, Any]:
|
|
219
|
+
"""
|
|
220
|
+
Evaluate task parameters and arbitrate optimal cognitive gear.
|
|
221
|
+
"""
|
|
222
|
+
composite_difficulty = (
|
|
223
|
+
0.35 * task_complexity +
|
|
224
|
+
0.35 * contradiction_density +
|
|
225
|
+
0.15 * min(1.0, failure_count / 3.0) +
|
|
226
|
+
0.15 * epistemic_uncertainty
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
if composite_difficulty >= 0.65 or failure_count >= 2 or contradiction_density >= 0.70:
|
|
230
|
+
gear = CognitiveGear.SYSTEM_3_META_COGNITIVE
|
|
231
|
+
rationale = (
|
|
232
|
+
f"High contradiction density ({contradiction_density:.2f}) and composite difficulty ({composite_difficulty:.2f}). "
|
|
233
|
+
"Engaging System 3 Meta-Cognition: TRIZ Dialectical Synthesis, Pearl Causal Interventions, and Evolutionary Pareto Optimization."
|
|
234
|
+
)
|
|
235
|
+
directives = [
|
|
236
|
+
"Execute System 3 Dialectical Synthesizer across thesis and red-team antithesis.",
|
|
237
|
+
"Construct Pearl Causal DAG and perform counterfactual do(X=x) simulations.",
|
|
238
|
+
"Run Evolutionary Paradigm Engine across 10D Pareto frontier.",
|
|
239
|
+
"Induce formal Neuro-Symbolic Axioms from tool receipts.",
|
|
240
|
+
]
|
|
241
|
+
elif composite_difficulty >= 0.35:
|
|
242
|
+
gear = CognitiveGear.SYSTEM_2_DELIBERATIVE
|
|
243
|
+
rationale = (
|
|
244
|
+
f"Moderate task complexity ({task_complexity:.2f}) and uncertainty ({epistemic_uncertainty:.2f}). "
|
|
245
|
+
"Engaging System 2 Deliberative Reasoning: 8-Pass deepthink, invariant modeling, and adversarial red-teaming."
|
|
246
|
+
)
|
|
247
|
+
directives = [
|
|
248
|
+
"Execute 8-Pass System 2 deliberation chain.",
|
|
249
|
+
"Model formal invariants in architecture domain.",
|
|
250
|
+
"Conduct adversarial glasswing red-teaming.",
|
|
251
|
+
"Perform continuous rethink-refine logging.",
|
|
252
|
+
]
|
|
253
|
+
else:
|
|
254
|
+
gear = CognitiveGear.SYSTEM_1_INTUITIVE
|
|
255
|
+
rationale = (
|
|
256
|
+
f"Low composite complexity ({composite_difficulty:.2f}). "
|
|
257
|
+
"Engaging System 1 Fast Heuristics for straightforward procedural operations."
|
|
258
|
+
)
|
|
259
|
+
directives = [
|
|
260
|
+
"Direct pattern-matching and linear execution plan.",
|
|
261
|
+
"Immediate scratch test validation.",
|
|
262
|
+
]
|
|
263
|
+
|
|
264
|
+
return {
|
|
265
|
+
"recommended_gear": gear.value,
|
|
266
|
+
"composite_difficulty": round(composite_difficulty, 3),
|
|
267
|
+
"rationale": rationale,
|
|
268
|
+
"directives": directives,
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
class System3Executive:
|
|
273
|
+
"""
|
|
274
|
+
Unified System 3 Meta-Cognitive Orchestrator.
|
|
275
|
+
Coordinates Causal DAGs, Dialectical Synthesizers, Evolutionary Gene Pools,
|
|
276
|
+
Neuro-Symbolic Axioms, and Cognitive Bias Detection.
|
|
277
|
+
"""
|
|
278
|
+
|
|
279
|
+
def __init__(self):
|
|
280
|
+
self.bias_detector = CognitiveBiasDetector()
|
|
281
|
+
self.heuristic_rewriter = DynamicSearchHeuristicRewriter()
|
|
282
|
+
self.arbitrator = TriLevelArbitrator()
|
|
283
|
+
self.synthesizer = DialecticalSynthesizer()
|
|
284
|
+
self.inducer = MetaProofInducer()
|
|
285
|
+
self.search_config = SearchHeuristicConfig()
|
|
286
|
+
|
|
287
|
+
def meta_reflect(self, session_data: Dict[str, Any]) -> Dict[str, Any]:
|
|
288
|
+
"""
|
|
289
|
+
Conduct a comprehensive System 3 Meta-Cognitive Audit:
|
|
290
|
+
1. Run cognitive bias detection.
|
|
291
|
+
2. Evaluate tri-level cognitive gear requirements.
|
|
292
|
+
3. Dynamically tune search heuristics.
|
|
293
|
+
4. Produce actionable meta-reflection report.
|
|
294
|
+
"""
|
|
295
|
+
findings = self.bias_detector.audit_session(session_data)
|
|
296
|
+
|
|
297
|
+
# Estimate contradiction density from epistemic counts and refinements
|
|
298
|
+
epistemic = session_data.get("epistemic_ledger", [])
|
|
299
|
+
hypo_count = sum(1 for i in epistemic if i.get("tag") == "HYPOTHESIS")
|
|
300
|
+
unknown_count = sum(1 for i in epistemic if i.get("tag") == "UNKNOWN")
|
|
301
|
+
contra_density = min(1.0, (hypo_count + unknown_count) / max(5, len(epistemic) or 1))
|
|
302
|
+
|
|
303
|
+
# Arbitrate gear
|
|
304
|
+
arb_res = self.arbitrator.arbitrate(
|
|
305
|
+
task_complexity=0.80,
|
|
306
|
+
contradiction_density=contra_density,
|
|
307
|
+
failure_count=len(findings),
|
|
308
|
+
epistemic_uncertainty=0.50,
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
# Update heuristics
|
|
312
|
+
self.search_config = self.heuristic_rewriter.rewrite_heuristics(
|
|
313
|
+
self.search_config,
|
|
314
|
+
contradiction_density=contra_density,
|
|
315
|
+
bias_findings=findings,
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
return {
|
|
319
|
+
"session_name": session_data.get("session_name", "active_session"),
|
|
320
|
+
"cognitive_gear": arb_res["recommended_gear"],
|
|
321
|
+
"arbitration_rationale": arb_res["rationale"],
|
|
322
|
+
"directives": arb_res["directives"],
|
|
323
|
+
"bias_findings": [f.to_dict() for f in findings],
|
|
324
|
+
"contradiction_density": round(contra_density, 3),
|
|
325
|
+
"updated_search_heuristics": self.search_config.to_dict(),
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
329
|
+
return {
|
|
330
|
+
"search_config": self.search_config.to_dict(),
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
@classmethod
|
|
334
|
+
def from_dict(cls, data: Dict[str, Any]) -> "System3Executive":
|
|
335
|
+
exec_instance = cls()
|
|
336
|
+
if "search_config" in data:
|
|
337
|
+
exec_instance.search_config = SearchHeuristicConfig.from_dict(data["search_config"])
|
|
338
|
+
return exec_instance
|