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
34 changes: 19 additions & 15 deletions .github/workflows/validate-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ on:
- "examples/**"
- "references/**"
- "scripts/validate_specula.py"
- "tests/**"
- ".github/workflows/validate-examples.yml"
pull_request:
paths:
- "examples/**"
- "references/**"
- "scripts/validate_specula.py"
- "tests/**"
- ".github/workflows/validate-examples.yml"
workflow_dispatch:

Expand All @@ -30,28 +32,30 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -r requirements.txt pytest

- name: Validate every example (constitution + state machine + integration)
- name: Validate examples (strict for real, lenient for fictional)
shell: bash
run: |
set -euo pipefail
status=0
for dir in examples/*/; do
const="${dir}constitution.json"
sm="${dir}state-machine.json"
if [[ -f "$const" && -f "$sm" ]]; then
echo "::group::Validating ${dir}"
if ! python scripts/validate_specula.py \
--constitution "$const" \
--state-machine "$sm"; then
status=1
fi
echo "::endgroup::"
[[ -f "$const" && -f "$sm" ]] || continue
# Real examples (metadata.fictional_example == false) must be warning-free.
fictional=$(python -c "import json,sys; print(json.load(open('$sm')).get('metadata',{}).get('fictional_example'))")
strict=""
if [[ "$fictional" == "False" ]]; then strict="--strict"; fi
echo "::group::Validating ${dir} (strict=${strict:-no})"
if ! python scripts/validate_specula.py $strict \
--constitution "$const" --state-machine "$sm"; then
status=1
fi
echo "::endgroup::"
done
if [[ "$status" -ne 0 ]]; then
echo "One or more examples failed schema/consistency validation."
exit 1
fi
echo "All examples passed schema and consistency validation."
[[ "$status" -eq 0 ]] || { echo "Example validation failed."; exit 1; }
echo "All examples passed (real examples are warning-free)."

- name: Run semantic coverage tests
run: pytest tests/ -q
64 changes: 59 additions & 5 deletions examples/community-space-brand/state-machine.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,20 @@
"id": "transition_state_to_generate",
"from_state": "space_state_selection",
"to_state": "generate_response",
"trigger": "space_state_selected"
"trigger": "space_state_selected",
"guard_ids": [
"guard_relational_quality",
"guard_activation_color_ratio"
]
},
{
"id": "transition_generate_to_ready",
"from_state": "generate_response",
"to_state": "response_ready",
"trigger": "response_validated",
"guard_ids": [
"guard_no_performance_pressure"
"guard_no_performance_pressure",
"guard_living_community"
]
},
{
Expand All @@ -163,7 +168,10 @@
"condition": "no_stigmatizing_language AND no_moralizing_tone AND people_before_labels",
"principle": "principle_non_judgment",
"action_on_violation": "block",
"severity": "high"
"severity": "high",
"constraint_ids": [
"constraint_no_stigmatizing_language"
]
},
{
"id": "guard_enabling",
Expand All @@ -173,7 +181,10 @@
"condition": "response_provides_infrastructure OR response_provides_tools OR response_provides_access",
"principle": "principle_enabling",
"action_on_violation": "escalate",
"severity": "medium"
"severity": "medium",
"constraint_ids": [
"constraint_no_ownership_asymmetry"
]
},
{
"id": "guard_no_performance_pressure",
Expand All @@ -183,7 +194,50 @@
"condition": "content_non_competitive AND no_achievement_framing AND no_ranking",
"principle": "principle_imagination_in_practice",
"action_on_violation": "retry",
"severity": "high"
"severity": "high",
"constraint_ids": [
"constraint_no_performance_pressure"
]
},
{
"id": "guard_relational_quality",
"name": "Relational Quality Guard",
"applies_to": "transition",
"applies_at_state": "space_state_selection",
"condition": "attendance_optimization_does_not_reduce_relational_quality OR community_guardian_review_required",
"principle": "principle_habitability",
"constraint_ids": [
"constraint_relational_quality_over_attendance"
],
"action_on_violation": "escalate",
"severity": "medium",
"error_message": "Attendance cannot be optimized at the expense of quality of shared presence."
},
{
"id": "guard_activation_color_ratio",
"name": "Activation Color Ratio Guard",
"applies_to": "output",
"applies_at_state": "space_state_selection",
"condition": "red_color_ratio <= 0.05",
"principle": "principle_habitability",
"constraint_ids": [
"constraint_activation_color_ratio"
],
"action_on_violation": "retry",
"severity": "high",
"error_message": "Red activation color must not exceed five percent of visual or spatial presence."
},
{
"id": "guard_living_community",
"name": "Living Community Continuity Guard",
"applies_to": "transition",
"applies_at_state": "generate_response",
"condition": "response_supports_continuity_or_relationship_depth",
"principle": "principle_living_community",
"constraint_ids": [],
"action_on_violation": "escalate",
"severity": "medium",
"error_message": "The response must support continuity, trust, or relationship depth rather than one-off consumption."
}
],
"space_states": {
Expand Down
60 changes: 47 additions & 13 deletions examples/luxury-fashion-brand/state-machine.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,61 @@
"id": "receive_customer_inquiry",
"name": "Receive Customer Inquiry",
"type": "normal",
"allowed_transitions": ["classify_customer_tier"]
"allowed_transitions": [
"classify_customer_tier"
]
},
"classify_customer_tier": {
"id": "classify_customer_tier",
"name": "Classify Customer Tier",
"type": "normal",
"allowed_transitions": ["brand_voice_alignment_check"]
"allowed_transitions": [
"brand_voice_alignment_check"
]
},
"brand_voice_alignment_check": {
"id": "brand_voice_alignment_check",
"name": "Brand Voice Alignment Check",
"type": "normal",
"allowed_transitions": ["heritage_compatibility_check", "escalate_brand_guardian"]
"allowed_transitions": [
"heritage_compatibility_check",
"escalate_brand_guardian"
]
},
"heritage_compatibility_check": {
"id": "heritage_compatibility_check",
"name": "Heritage Compatibility Check",
"type": "normal",
"allowed_transitions": ["personalization_depth_selection", "escalate_brand_guardian"]
"allowed_transitions": [
"personalization_depth_selection",
"escalate_brand_guardian"
]
},
"personalization_depth_selection": {
"id": "personalization_depth_selection",
"name": "Personalization Depth Selection",
"type": "normal",
"allowed_transitions": ["generate_response", "escalate_brand_guardian"]
"allowed_transitions": [
"generate_response",
"escalate_brand_guardian"
]
},
"generate_response": {
"id": "generate_response",
"name": "Generate Response",
"type": "normal",
"allowed_transitions": ["response_ready", "escalate_brand_guardian"]
"allowed_transitions": [
"response_ready",
"escalate_brand_guardian"
]
},
"escalate_brand_guardian": {
"id": "escalate_brand_guardian",
"name": "Escalate to Brand Guardian",
"type": "escalation",
"allowed_transitions": ["response_ready"]
"allowed_transitions": [
"response_ready"
]
},
"response_ready": {
"id": "response_ready",
Expand All @@ -71,21 +89,27 @@
"from_state": "brand_voice_alignment_check",
"to_state": "heritage_compatibility_check",
"trigger": "voice_guard_passed",
"guard_ids": ["guard_brand_voice_alignment"]
"guard_ids": [
"guard_brand_voice_alignment"
]
},
{
"id": "transition_heritage_to_personalization",
"from_state": "heritage_compatibility_check",
"to_state": "personalization_depth_selection",
"trigger": "heritage_guard_passed",
"guard_ids": ["guard_heritage_alignment"]
"guard_ids": [
"guard_heritage_alignment"
]
},
{
"id": "transition_personalization_to_generate",
"from_state": "personalization_depth_selection",
"to_state": "generate_response",
"trigger": "exclusivity_guard_passed",
"guard_ids": ["guard_exclusivity_enforcement"]
"guard_ids": [
"guard_exclusivity_enforcement"
]
},
{
"id": "transition_generate_to_ready",
Expand All @@ -110,7 +134,10 @@
"condition": "brand_voice_compliant == true",
"principle": "principle_brand_voice",
"action_on_violation": "block",
"severity": "high"
"severity": "high",
"constraint_ids": [
"constraint_brand_tone"
]
},
{
"id": "guard_heritage_alignment",
Expand All @@ -120,7 +147,10 @@
"condition": "heritage_alignment_passed == true",
"principle": "principle_heritage_respect",
"action_on_violation": "escalate",
"severity": "critical"
"severity": "critical",
"constraint_ids": [
"constraint_heritage_consistency"
]
},
{
"id": "guard_exclusivity_enforcement",
Expand All @@ -130,7 +160,11 @@
"condition": "personalization_depth >= required_depth",
"principle": "principle_customer_exclusivity",
"action_on_violation": "escalate",
"severity": "high"
"severity": "high",
"constraint_ids": [
"constraint_core_collection_premium",
"constraint_vip_personalization_depth"
]
}
],
"metadata": {
Expand Down
Loading
Loading