Spaces:
Sleeping
Sleeping
Commit
·
706af58
1
Parent(s):
69ed576
fix: resolve formatting inconsistencies between make format and pre-commit
Browse files- Update ruff version in pre-commit-config.yaml to v0.11.13 to match local ruff
- Fix version mismatch that caused disagreement between make format and pre-commit
- Standardize assert formatting throughout test_architectural_constraints.py
- Both commands now run without making any formatting changes
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
.pre-commit-config.yaml
CHANGED
|
@@ -10,7 +10,7 @@ repos:
|
|
| 10 |
- id: debug-statements
|
| 11 |
|
| 12 |
- repo: https://github.com/astral-sh/ruff-pre-commit
|
| 13 |
-
rev: v0.
|
| 14 |
hooks:
|
| 15 |
- id: ruff
|
| 16 |
args: [--fix, --exit-non-zero-on-fix]
|
|
|
|
| 10 |
- id: debug-statements
|
| 11 |
|
| 12 |
- repo: https://github.com/astral-sh/ruff-pre-commit
|
| 13 |
+
rev: v0.11.13
|
| 14 |
hooks:
|
| 15 |
- id: ruff
|
| 16 |
args: [--fix, --exit-non-zero-on-fix]
|
tests/test_architectural_constraints.py
CHANGED
|
@@ -25,15 +25,16 @@ class TestArchitecturalConstraints:
|
|
| 25 |
fields = BeliefUpdate.__dataclass_fields__
|
| 26 |
|
| 27 |
# Should only contain comparison_result
|
| 28 |
-
assert (
|
| 29 |
-
len(fields)
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
| 37 |
|
| 38 |
def test_environment_evidence_dataclass_structure(self):
|
| 39 |
"""Test that EnvironmentEvidence contains both dice_roll and comparison_result."""
|
|
@@ -41,13 +42,14 @@ class TestArchitecturalConstraints:
|
|
| 41 |
fields = EnvironmentEvidence.__dataclass_fields__
|
| 42 |
|
| 43 |
# Should contain both fields
|
| 44 |
-
assert (
|
| 45 |
-
len(fields)
|
| 46 |
-
|
|
|
|
| 47 |
assert "dice_roll" in fields, "EnvironmentEvidence must contain dice_roll field"
|
| 48 |
-
assert (
|
| 49 |
-
"comparison_result"
|
| 50 |
-
)
|
| 51 |
|
| 52 |
def test_belief_state_methods_no_dice_roll_parameters(self):
|
| 53 |
"""Test that BayesianBeliefState methods don't accept dice_roll parameters."""
|
|
@@ -61,9 +63,9 @@ class TestArchitecturalConstraints:
|
|
| 61 |
signature = inspect.signature(method)
|
| 62 |
param_names = list(signature.parameters.keys())
|
| 63 |
|
| 64 |
-
assert (
|
| 65 |
-
"
|
| 66 |
-
)
|
| 67 |
|
| 68 |
def test_belief_update_creation_without_dice_roll(self):
|
| 69 |
"""Test that BeliefUpdate can be created without dice_roll."""
|
|
@@ -98,12 +100,12 @@ class TestArchitecturalConstraints:
|
|
| 98 |
|
| 99 |
# Verify that evidence history in belief domain contains only comparison results
|
| 100 |
for evidence in game.belief_state.evidence_history:
|
| 101 |
-
assert hasattr(
|
| 102 |
-
evidence
|
| 103 |
-
)
|
| 104 |
-
assert not hasattr(
|
| 105 |
-
evidence
|
| 106 |
-
)
|
| 107 |
|
| 108 |
def test_domain_import_isolation(self):
|
| 109 |
"""Test that belief domain doesn't import environment domain."""
|
|
@@ -113,12 +115,12 @@ class TestArchitecturalConstraints:
|
|
| 113 |
belief_source = inspect.getsource(belief_module)
|
| 114 |
|
| 115 |
# Should not import environment domain
|
| 116 |
-
assert (
|
| 117 |
-
"
|
| 118 |
-
)
|
| 119 |
-
assert (
|
| 120 |
-
"import
|
| 121 |
-
)
|
| 122 |
|
| 123 |
def test_proper_bayesian_calculation_structure(self):
|
| 124 |
"""Test that belief updates use probabilistic calculations."""
|
|
@@ -135,9 +137,9 @@ class TestArchitecturalConstraints:
|
|
| 135 |
prob_6 = belief_state.get_belief_for_target(6)
|
| 136 |
|
| 137 |
assert prob_1 > prob_6, "Higher evidence should favor lower targets"
|
| 138 |
-
assert (
|
| 139 |
-
|
| 140 |
-
)
|
| 141 |
|
| 142 |
def test_coordination_layer_responsibility(self):
|
| 143 |
"""Test that coordination layer properly orchestrates without leaking information."""
|
|
@@ -148,21 +150,21 @@ class TestArchitecturalConstraints:
|
|
| 148 |
state = game.play_round()
|
| 149 |
|
| 150 |
# Game state should have full information (for display)
|
| 151 |
-
assert hasattr(
|
| 152 |
-
state
|
| 153 |
-
)
|
| 154 |
-
assert hasattr(
|
| 155 |
-
state
|
| 156 |
-
)
|
| 157 |
|
| 158 |
# But belief state should only have comparison results
|
| 159 |
belief_evidence = game.belief_state.evidence_history[0]
|
| 160 |
-
assert hasattr(
|
| 161 |
-
|
| 162 |
-
)
|
| 163 |
-
assert not hasattr(
|
| 164 |
-
|
| 165 |
-
)
|
| 166 |
|
| 167 |
def test_no_hard_coded_probabilities(self):
|
| 168 |
"""Test that belief calculations are dynamic, not hard-coded."""
|
|
@@ -181,10 +183,10 @@ class TestArchitecturalConstraints:
|
|
| 181 |
|
| 182 |
# Target 1 should have highest probability for "higher" evidence
|
| 183 |
|
| 184 |
-
assert (
|
| 185 |
-
|
| 186 |
-
)
|
| 187 |
-
assert (
|
| 188 |
-
|
| 189 |
-
)
|
| 190 |
assert prob_1 > 0, "Target 1 should have non-zero probability"
|
|
|
|
| 25 |
fields = BeliefUpdate.__dataclass_fields__
|
| 26 |
|
| 27 |
# Should only contain comparison_result
|
| 28 |
+
assert len(fields) == 1, (
|
| 29 |
+
f"BeliefUpdate should have exactly 1 field, got {len(fields)}: "
|
| 30 |
+
f"{list(fields.keys())}"
|
| 31 |
+
)
|
| 32 |
+
assert "comparison_result" in fields, (
|
| 33 |
+
"BeliefUpdate must contain comparison_result field"
|
| 34 |
+
)
|
| 35 |
+
assert "dice_roll" not in fields, (
|
| 36 |
+
"BeliefUpdate MUST NOT contain dice_roll field"
|
| 37 |
+
)
|
| 38 |
|
| 39 |
def test_environment_evidence_dataclass_structure(self):
|
| 40 |
"""Test that EnvironmentEvidence contains both dice_roll and comparison_result."""
|
|
|
|
| 42 |
fields = EnvironmentEvidence.__dataclass_fields__
|
| 43 |
|
| 44 |
# Should contain both fields
|
| 45 |
+
assert len(fields) == 2, (
|
| 46 |
+
f"EnvironmentEvidence should have exactly 2 fields, got {len(fields)}: "
|
| 47 |
+
f"{list(fields.keys())}"
|
| 48 |
+
)
|
| 49 |
assert "dice_roll" in fields, "EnvironmentEvidence must contain dice_roll field"
|
| 50 |
+
assert "comparison_result" in fields, (
|
| 51 |
+
"EnvironmentEvidence must contain comparison_result field"
|
| 52 |
+
)
|
| 53 |
|
| 54 |
def test_belief_state_methods_no_dice_roll_parameters(self):
|
| 55 |
"""Test that BayesianBeliefState methods don't accept dice_roll parameters."""
|
|
|
|
| 63 |
signature = inspect.signature(method)
|
| 64 |
param_names = list(signature.parameters.keys())
|
| 65 |
|
| 66 |
+
assert "dice_roll" not in param_names, (
|
| 67 |
+
f"Method {method_name} MUST NOT have dice_roll parameter"
|
| 68 |
+
)
|
| 69 |
|
| 70 |
def test_belief_update_creation_without_dice_roll(self):
|
| 71 |
"""Test that BeliefUpdate can be created without dice_roll."""
|
|
|
|
| 100 |
|
| 101 |
# Verify that evidence history in belief domain contains only comparison results
|
| 102 |
for evidence in game.belief_state.evidence_history:
|
| 103 |
+
assert hasattr(evidence, "comparison_result"), (
|
| 104 |
+
"Belief evidence must have comparison_result"
|
| 105 |
+
)
|
| 106 |
+
assert not hasattr(evidence, "dice_roll"), (
|
| 107 |
+
"Belief evidence MUST NOT have dice_roll"
|
| 108 |
+
)
|
| 109 |
|
| 110 |
def test_domain_import_isolation(self):
|
| 111 |
"""Test that belief domain doesn't import environment domain."""
|
|
|
|
| 115 |
belief_source = inspect.getsource(belief_module)
|
| 116 |
|
| 117 |
# Should not import environment domain
|
| 118 |
+
assert "from domains.environment" not in belief_source, (
|
| 119 |
+
"Belief domain MUST NOT import environment domain"
|
| 120 |
+
)
|
| 121 |
+
assert "import domains.environment" not in belief_source, (
|
| 122 |
+
"Belief domain MUST NOT import environment domain"
|
| 123 |
+
)
|
| 124 |
|
| 125 |
def test_proper_bayesian_calculation_structure(self):
|
| 126 |
"""Test that belief updates use probabilistic calculations."""
|
|
|
|
| 137 |
prob_6 = belief_state.get_belief_for_target(6)
|
| 138 |
|
| 139 |
assert prob_1 > prob_6, "Higher evidence should favor lower targets"
|
| 140 |
+
assert abs(prob_6 - 0.0) < 1e-10, (
|
| 141 |
+
"Target 6 should have zero probability after 'higher' evidence"
|
| 142 |
+
)
|
| 143 |
|
| 144 |
def test_coordination_layer_responsibility(self):
|
| 145 |
"""Test that coordination layer properly orchestrates without leaking information."""
|
|
|
|
| 150 |
state = game.play_round()
|
| 151 |
|
| 152 |
# Game state should have full information (for display)
|
| 153 |
+
assert hasattr(state.evidence_history[0], "dice_roll"), (
|
| 154 |
+
"Game state should maintain full evidence for display"
|
| 155 |
+
)
|
| 156 |
+
assert hasattr(state.evidence_history[0], "comparison_result"), (
|
| 157 |
+
"Game state should maintain comparison results"
|
| 158 |
+
)
|
| 159 |
|
| 160 |
# But belief state should only have comparison results
|
| 161 |
belief_evidence = game.belief_state.evidence_history[0]
|
| 162 |
+
assert hasattr(belief_evidence, "comparison_result"), (
|
| 163 |
+
"Belief evidence must have comparison_result"
|
| 164 |
+
)
|
| 165 |
+
assert not hasattr(belief_evidence, "dice_roll"), (
|
| 166 |
+
"Belief evidence MUST NOT have dice_roll"
|
| 167 |
+
)
|
| 168 |
|
| 169 |
def test_no_hard_coded_probabilities(self):
|
| 170 |
"""Test that belief calculations are dynamic, not hard-coded."""
|
|
|
|
| 183 |
|
| 184 |
# Target 1 should have highest probability for "higher" evidence
|
| 185 |
|
| 186 |
+
assert prob_1 > prob_last, (
|
| 187 |
+
f"Target 1 should be more likely than target {dice_sides}"
|
| 188 |
+
)
|
| 189 |
+
assert abs(prob_last - 0.0) < 1e-10, (
|
| 190 |
+
f"Target {dice_sides} should have zero probability"
|
| 191 |
+
)
|
| 192 |
assert prob_1 > 0, "Target 1 should have non-zero probability"
|