Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion examples/community-space-brand/constitution.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@
"principle": "principle_habitability",
"severity_on_violation": "high",
"action_on_violation": "revise_response"
},
{
"id": "constraint_continuity_over_one_off_activation",
"constraint_type": "soft",
"rule": "Activation should support return, trust, and relationship depth rather than isolated consumption.",
"principle": "principle_living_community",
"severity_on_violation": "medium",
"action_on_violation": "escalate_to_community_guardian"
}
],
"stakeholders": [
Expand Down Expand Up @@ -151,7 +159,12 @@
"example_purpose": "Real community space brand governance derived from co-design and Specula Method Brand Archeology",
"fictional_example": false,
"client": "Il posto delle fragole — Via Ponchielli 81, Pesaro",
"method_phases_applied": ["1.5", "2", "3_partial", "4"],
"method_phases_applied": [
"1.5",
"2",
"3_partial",
"4"
],
"attribution": "Specula Future Crafting"
}
}
8 changes: 5 additions & 3 deletions examples/community-space-brand/state-machine.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@
"applies_at_state": "generate_response",
"condition": "response_supports_continuity_or_relationship_depth",
"principle": "principle_living_community",
"constraint_ids": [],
"constraint_ids": [
"constraint_continuity_over_one_off_activation"
],
"action_on_violation": "escalate",
"severity": "medium",
"error_message": "The response must support continuity, trust, or relationship depth rather than one-off consumption."
Expand Down Expand Up @@ -279,9 +281,9 @@
"color_weight": {
"sand": 0.5,
"white": 0.15,
"green": 0.15,
"green": 0.2,
"black": 0.1,
"red": 0.1
"red": 0.05
}
}
},
Expand Down
22 changes: 22 additions & 0 deletions tests/test_semantic_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,25 @@ def test_habitability_guards_are_attached_to_runtime_flow():
def test_real_examples_exist():
# Guard against silently testing nothing if the metadata flag changes.
assert REAL_EXAMPLES, "no real (non-fictional) examples found to test"


# Hard constraint (constraint_activation_color_ratio): red activation <= 5%.
MAX_RED_ACTIVATION_RATIO = 0.05


@pytest.mark.parametrize("example_dir", REAL_EXAMPLES, ids=lambda p: p.name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scope the red-ratio check to examples declaring the constraint

When a future non-fictional example defines space_states but does not declare constraint_activation_color_ratio—or intentionally uses a different palette policy—this parametrization still applies the community-space project's 5% threshold and fails CI. REAL_EXAMPLES is selected solely from metadata, so filter based on the paired constitution's constraints or keep this project-specific test scoped to community-space-brand.

Useful? React with 👍 / 👎.

def test_activation_color_ratio_respected_in_space_states(example_dir):
"""Every real example must obey the hard constraint that
guard_activation_color_ratio enforces: red (activation) never exceeds 5%
in any declared space state. Generic across real examples so a future
over-threshold configuration fails CI, not just the current one."""
sm = json.loads((example_dir / "state-machine.json").read_text(encoding="utf-8"))
space_states = sm.get("space_states", {})
if not space_states:
pytest.skip(f"{example_dir.name} declares no space_states")
offenders = {
name: cfg.get("color_weight", {}).get("red", 0.0)
for name, cfg in space_states.items()
if cfg.get("color_weight", {}).get("red", 0.0) > MAX_RED_ACTIVATION_RATIO
}
assert not offenders, f"{example_dir.name} space states exceeding 5% red: {offenders}"
Loading