From e0d7738eae30484bb480dbdb360aaad2b9df220d Mon Sep 17 00:00:00 2001 From: Tito Date: Thu, 13 Aug 2026 14:06:28 +0200 Subject: [PATCH 1/3] feat: make principle_living_community fully explicit with dedicated constraint Add constraint_continuity_over_one_off_activation (soft, principle_living_community, escalate_to_community_guardian) to the community-space constitution, and link guard_living_community to it via constraint_ids. Completes the principle -> constraint -> guard -> transition chain for all three previously under-covered principles/constraints. Still 0 errors / 0 warnings (strict); pytest 5/5. --- examples/community-space-brand/constitution.json | 15 ++++++++++++++- examples/community-space-brand/state-machine.json | 4 +++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/examples/community-space-brand/constitution.json b/examples/community-space-brand/constitution.json index b58d6a9..b337091 100644 --- a/examples/community-space-brand/constitution.json +++ b/examples/community-space-brand/constitution.json @@ -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": [ @@ -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" } } diff --git a/examples/community-space-brand/state-machine.json b/examples/community-space-brand/state-machine.json index ab835ba..22195b5 100644 --- a/examples/community-space-brand/state-machine.json +++ b/examples/community-space-brand/state-machine.json @@ -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." From 3adf2ff05e875689f7678923cfe2a0f2e16c4bbf Mon Sep 17 00:00:00 2001 From: Tito Date: Thu, 13 Aug 2026 14:10:38 +0200 Subject: [PATCH 2/3] fix: bring gestuale space state within the 5% red activation constraint gestuale declared red: 0.10, violating the hard constraint that guard_activation_color_ratio now enforces (red must never exceed 5%). Lower red 0.10 -> 0.05 and shift the freed weight to green (0.15 -> 0.20), keeping the color_weight sum at 1.0. Add a test asserting every space state respects the <=5% red rule, closing the guard->data loop end to end. --- examples/community-space-brand/state-machine.json | 4 ++-- tests/test_semantic_coverage.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/examples/community-space-brand/state-machine.json b/examples/community-space-brand/state-machine.json index 22195b5..e590394 100644 --- a/examples/community-space-brand/state-machine.json +++ b/examples/community-space-brand/state-machine.json @@ -281,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 } } }, diff --git a/tests/test_semantic_coverage.py b/tests/test_semantic_coverage.py index 0f469d8..e456ca1 100644 --- a/tests/test_semantic_coverage.py +++ b/tests/test_semantic_coverage.py @@ -86,3 +86,17 @@ 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" + + +def test_activation_color_ratio_respected_in_space_states(): + """Data must obey the hard constraint that guard_activation_color_ratio enforces: + red (activation) never exceeds 5% in any declared space state.""" + sm = json.loads( + (EXAMPLES / "community-space-brand" / "state-machine.json").read_text(encoding="utf-8") + ) + offenders = { + name: cfg["color_weight"].get("red", 0.0) + for name, cfg in sm.get("space_states", {}).items() + if cfg.get("color_weight", {}).get("red", 0.0) > 0.05 + } + assert not offenders, f"space states exceeding 5% red: {offenders}" From 8645ab51427e6861885e1cdce0bab0f3e8c5612b Mon Sep 17 00:00:00 2001 From: Tito Date: Thu, 13 Aug 2026 14:11:43 +0200 Subject: [PATCH 3/3] test: enforce 5% red activation constraint across all real examples Generalize the color-ratio test from a single hardcoded example to every real (non-fictional) example, with the threshold as a named constant (MAX_RED_ACTIVATION_RATIO = 0.05). Any future space_state over 5% red in any real example now fails CI, keeping the repo internally consistent with the hard constraint declared in the constitution. --- tests/test_semantic_coverage.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/tests/test_semantic_coverage.py b/tests/test_semantic_coverage.py index e456ca1..c6934f3 100644 --- a/tests/test_semantic_coverage.py +++ b/tests/test_semantic_coverage.py @@ -88,15 +88,23 @@ def test_real_examples_exist(): assert REAL_EXAMPLES, "no real (non-fictional) examples found to test" -def test_activation_color_ratio_respected_in_space_states(): - """Data must obey the hard constraint that guard_activation_color_ratio enforces: - red (activation) never exceeds 5% in any declared space state.""" - sm = json.loads( - (EXAMPLES / "community-space-brand" / "state-machine.json").read_text(encoding="utf-8") - ) +# 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) +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["color_weight"].get("red", 0.0) - for name, cfg in sm.get("space_states", {}).items() - if cfg.get("color_weight", {}).get("red", 0.0) > 0.05 + 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"space states exceeding 5% red: {offenders}" + assert not offenders, f"{example_dir.name} space states exceeding 5% red: {offenders}"