The **Coherence Composer** is an epistemological skill that validates structural consistency and explores counterfactual worlds while respecting constraints from both **Commitment Tracker** (ontology) and **Opacity Detector** (epistemology).
Scanned 9/6/2026
Install to Claude Code
npx -y skills add plurigrid/asi --skill coherence-composer --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Coherence Composer?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/plurigrid-coherence-composer)More formats (shields.io, HTML) on the badges page.
---
name: coherence-composer
description: The **Coherence Composer** is an epistemological skill that validates structural consistency and explores counterfactual worlds while respecting constraints from both **Commitment Tracker** (ontology) and **Opacity Detector** (epistemology).
---
# Coherence Composer Skill: Complete Technical Documentation
**Skill 3 of 3** | Possibility Coordination | Status: ✅ Production-Ready
---
## What It Does
The **Coherence Composer** is an epistemological skill that validates structural consistency and explores counterfactual worlds while respecting constraints from both **Commitment Tracker** (ontology) and **Opacity Detector** (epistemology).
Given:
- A system with structural constraints (causality, logic, commitments, accessibility, conservation)
- Proposed counterfactual worlds
It answers: **"What COULD BE TRUE while respecting all constraints?"**
The skill validates that counterfactuals satisfy the **sheaf condition** — all constraints glue consistently — and explores the valid variant space that remains possible.
---
## The Problem It Solves
When agents explore counterfactual scenarios, they need to ask:
- "Is this alternative world logically possible?"
- "Does it respect our shared commitments?"
- "Can all observers access the knowledge they need?"
- "Would natural laws still hold?"
**Without the skill**: Agents propose counterfactuals that violate basic logic, contradict shared commitments, or require omniscience from bounded observers.
**With the skill**:
1. Extract explicit constraints (temporal, logical, ontological, epistemic, conservational)
2. Verify closure: does each counterfactual satisfy ALL constraints simultaneously?
3. Find minimal worlds: what's the simplest way to achieve a counterfactual?
4. Explore valid space: what variant histories remain genuinely possible?
**Result**: Counterfactuals grounded in reality, respecting both physics and agreement.
---
## The 2-Monad Structure
### Objects: Constraint Boundaries
Each system has a **constraint boundary** — the set of structural requirements that limit what can be true.
```
ComputerGraphics System:
├─ Constraint 1 (critical): Temporal causality
│ ├─ No time paradoxes
│ ├─ Effects after causes
│ └─ Predicates: {cause-before-effect, temporal-order, no-self-loops}
│
├─ Constraint 2 (critical): Logical consistency
│ ├─ Non-contradiction
│ ├─ Excluded middle
│ └─ Predicates: {non-contradiction, excluded-middle, modus-ponens}
│
├─ Constraint 3 (high): Ontological commitment
│ ├─ Must preserve: {composition, structure, harmony}
│ └─ Predicates: {commitment-preservation, ontological-stability}
│
├─ Constraint 4 (high): Epistemic accessibility
│ ├─ Must respect boundaries of: {computational, embodied, temporal}
│ └─ Predicates: {boundary-respect, bridging-feature-use}
│
└─ Constraint 5 (medium): Conservation laws
├─ Information/value conserved
└─ Predicates: {conservation-law, symmetry-preservation, invariant-preservation}
```
### 1-Cells: Closure Relations
A **1-cell** between two boundaries is a closure relation — a proposed counterfactual that either satisfies all constraints (closed) or violates some (open).
```clojure
Counterfactual X:
temporal constraint: ✓ satisfied (cause-before-effect: true)
logical constraint: ✓ satisfied (consistent: true)
commitment constraint: ✓ satisfied (ontology-preserved: true)
accessibility constraint:✓ satisfied (boundaries-respected: true)
conserved constraint: ✓ satisfied (conserved: true)
──────────────────────────────────────────────────────
CLOSURE: ✓ CLOSED (5/5 constraints verified)
```
### 2-Cells: Natural Transformations (The Coherence Cycle)
Three 2-cells that compose via monad multiplication:
**γ₋₍: Hidden Constraints → Explicit Boundaries**
- Input: System description
- Output: Constraint boundary with explicit predicates
- Transforms: Implicit structure → visible constraints
**γ₍₊: Boundaries → Closure Conditions**
- Input: Constraint boundary
- Output: Conditions each counterfactual must satisfy
- Transforms: Constraints → closure requirements
**γ₊₋: Closures → Valid Counterfactuals**
- Input: Verified closures
- Output: Valid variant space
- Transforms: Verified closures → explored possibilities
**μ: Monad Multiplication (Coherence Cycle Closes)**
```
Hidden Constraints
│
↓ γ₋₍
Explicit Boundaries (5 constraints listed)
│
↓ γ₍₊
Closure Verification (all satisfied? yes/no)
│
↓ γ₊₋
Valid Counterfactuals (variant space enumerated)
│
↓ μ (monad mult)
Back to Hidden (but now with possibility map)
```
---
## Five Core Constraints
### 1. Temporal Constraint (Critical)
**Question**: Does causality hold? Can effects precede causes?
**Predicates**:
- `cause-before-effect`: Every effect has a prior cause
- `temporal-order`: Timeline is consistent
- `no-self-loops`: No cycles in causal graph
**Failure**: Time paradoxes (killing grandfather, etc.)
### 2. Logical Constraint (Critical)
**Question**: Is the world logically consistent? Can something be both true and false?
**Predicates**:
- `non-contradiction`: ¬(P ∧ ¬P)
- `excluded-middle`: P ∨ ¬P
- `modus-ponens`: (P → Q) ∧ P ⟹ Q
**Failure**: Contradictory propositions both holding
### 3. Commitment Constraint (High)
**Question**: Does the counterfactual respect ontological commitments from Skill 1?
**Preserves**: Shared ontology (e.g., "composition", "structure", "harmony")
**Predicates**:
- `commitment-preservation`: All agreed-upon entities still exist
- `ontological-stability`: What we said exists still exists
**Failure**: Violating shared assumptions about reality
### 4. Accessibility Constraint (High)
**Question**: Can all observers verify the counterfactual? Does it respect epistemic boundaries from Skill 2?
**Preserves**: Epistemic boundaries of all observers
- Computational observer: Can verify logical structure
- Embodied observer: Can verify sensory features
- Temporal observer: Can verify narrative coherence
**Predicates**:
- `boundary-respect`: Don't ask observers to verify beyond their access
- `bridging-feature-use`: Use features both can access for verification
**Failure**: Counterfactual requires omniscience
### 5. Conservation Constraint (Medium)
**Question**: Are conserved properties preserved?
**Conserved**:
- Information (Landauer's principle)
- Energy (thermodynamics)
- Charge (physics)
- Value (economics)
**Predicates**:
- `conservation-law`: Total conserved quantity unchanged
- `symmetry-preservation`: Symmetries remain intact
- `invariant-preservation`: Invariant properties unchanged
**Failure**: Violating fundamental conservation laws
---
## The Four Games
### Game 1: Constraint Disclosure
**Input**: System description (ontology, observers, etc.)
**Output**: Explicit constraint boundaries
**Time**: < 1 ms
Shows what constraints the system imposes:
```
System: music-composition
Total constraints: 5
Critical constraints: 2
Constraint: temporal
Severity: :critical
Description: Causality: effects cannot precede causes
Predicates: cause-before-effect, temporal-order, no-self-loops
Constraint: logical
Severity: :critical
Description: Logic: propositions cannot be both true and false
Predicates: non-contradiction, excluded-middle, modus-ponens
...
```
**Insight**: Transparency. You know exactly what limits what's possible.
### Game 2: Closure Verification
**Input**: Constraint boundaries + candidate counterfactuals
**Output**: Verification results (closed/open)
**Time**: < 1 ms per counterfactual
Tests whether each counterfactual satisfies **all** constraints:
```
Counterfactual: world-A
Closure: ✓ CLOSED
Satisfied: 5/5 (100%)
temporal: ✓
logical: ✓
commitment: ✓
accessibility: ✓
conserved: ✓
Counterfactual: world-B
Closure: ✗ OPEN
Satisfied: 4/5 (80%)
temporal: ✓
logical: ✗ ← Failed!
commitment: ✓
accessibility: ✓
conserved: ✓
```
**Insight**: The sheaf condition. Constraints must glue consistently — partial satisfaction isn't enough.
### Game 3: Minimal World Construction
**Input**: Constraint boundaries + desired outcome
**Output**: Simplest counterfactual achieving it
**Time**: < 5 ms
Applies **Occam's razor**: prefer counterfactuals with fewest/smallest changes.
```
World: minimal-63
Based on: current-world
Changes: 2
Magnitude: 1.5
Explanation: Changed 2 properties with magnitude 1.5
World: minimal-81
Based on: current-world
Changes: 2
Magnitude: 1.5
World: minimal-57
Based on: current-world
Changes: 2
Magnitude: 1.5
Minimal world selected: minimal-63
```
**Insight**: Not all possible worlds are equally elegant. Simpler changes are preferable.
### Game 4: Historical Branching
**Input**: Constraint boundaries + enumeration parameters
**Output**: Valid variant space (all consistent alternatives)
**Time**: < 10 ms for N candidates
Explores what alternative histories genuinely remain possible:
```
Total candidates: 3
Valid variants: 3
Validity rate: 100%
Valid variants:
• minimal-63 (Satisfaction: 5/5)
• minimal-81 (Satisfaction: 5/5)
• minimal-57 (Satisfaction: 5/5)
Interpretation: These counterfactual worlds could exist
within the constraint structure while respecting:
- Temporal coherence (causality)
- Logical consistency
- Commitment preservation
- Epistemic boundaries
- Conservation laws
```
**Insight**: The valid variant space is often much smaller than the space of conceivable worlds.
---
## Sheaf Condition and Closure
### What is a Sheaf?
A **sheaf** is a structure where local data glue together to form consistent global data.
In Coherence Composer, a counterfactual is "sheaf-like" if:
- Locally (per observer, per constraint): the counterfactual is consistent
- Globally: all local consistencies glue into a single coherent world
### Closure vs. Open
**Closed counterfactual**: All constraints satisfied simultaneously (sheaf condition holds)
**Open counterfactual**: Some constraints violated (gluing fails)
The closure verification tests: "Does this counterfactual form a coherent whole?"
### Example
```
World-C seems okay locally:
- Temporal: ✗ (has paradox) ← PROBLEM
- Logical: ✓
- Commitment: ✗ (violates ontology) ← PROBLEM
- Accessibility: ✓
- Conservation: ✓
Globally: This world doesn't cohere. It's impossible.
Status: OPEN (cannot exist)
```
---
## Technical Implementation
### Babashka (Interactive)
**File**: `.topos/coherence_composer_2monad.bb` (290 lines)
Functions:
```clojure
(temporal-constraint seed)
(logical-constraint seed)
(commitment-constraint seed ontology)
(accessibility-constraint seed accessibility)
(conserved-constraint seed)
(map-constraint-boundaries system seed ontology accessibility)
→ boundaries with 5 constraints
(check-closure counterfactual constraints)
→ ValidationResult with satisfaction ratio
(minimal-counterfactual base-world changes seed)
(enumerate-counterfactuals base-world boundaries seed)
→ Vector of counterfactuals
(game-constraint-disclosure system seed ontology accessibility)
(game-closure-verification system seed ontology accessibility)
(game-minimal-world system seed ontology accessibility)
(game-historical-branching system seed ontology accessibility)
```
**Run**:
```bash
bb .topos/coherence_composer_2monad.bb constraints
bb .topos/coherence_composer_2monad.bb closure
bb .topos/coherence_composer_2modan.bb minimal
bb .topos/coherence_composer_2modan.bb branching
bb .topos/coherence_composer_2modan.bb all
```
### Julia (Production)
**File**: `rio/Gay.jl/src/coherence_composer.jl` (400+ lines)
Types:
```julia
@enum ConstraintSeverity critical high medium low
struct Constraint
name::String
id::UInt32
description::String
predicates::Set{String}
severity::ConstraintSeverity
ontology::Union{Vector{String}, Nothing}
accessibility::Union{Vector{String}, Nothing}
end
struct ConstraintBoundary
system::String
constraints::Vector{Constraint}
total_constraints::Int
critical_count::Int
all_predicates::Set{String}
seed::UInt64
end
struct Counterfactual
name::String
based_on::String
changes::Vector{Tuple{String, Float64}}
change_count::Int
change_magnitude::Float64
# Constraint satisfaction flags:
cause_before_effect::Bool
consistent::Bool
# ... more flags
end
struct ValidationResult
counterfactual::String
closure_verified::Bool
satisfied_constraints::Int
total_constraints::Int
satisfaction_ratio::Float64
details::Dict{String, Bool}
end
```
Functions:
```julia
extract_constraints(system, seed, ontology, accessibility)
→ ConstraintBoundary
verify_closure(counterfactual, constraints)
→ ValidationResult
compose_counterfactuals(system, seed, ontology, accessibility)
→ Dict{String, Any}
world_coherence_composer(; seed, system, ontology, accessibility)
→ world result (for worlds.jl)
world_full_skill_integration(; seed, ontology, accessibility)
→ trialectic result (all three skills)
```
---
## Integration Points
### With Commitment Tracker (Skill 1)
**Commitment Tracker handles**: Ontology ("What exists?")
- Extracts commitments from agents
- Negotiates shared reality
**Coherence Composer uses**: Commitment preservation constraint
- Verifies counterfactuals don't violate agreed-upon ontology
- Asks: "Does this alternative world preserve what we agreed is real?"
```
Commitment: "compositions exist"
Counterfactual: "A world with no compositions"
Verification: ✗ FAILS commitment constraint
Result: This counterfactual is OPEN (impossible given our agreements)
```
### With Opacity Detector (Skill 2)
**Opacity Detector handles**: Epistemology ("What can we know?")
- Maps epistemic boundaries of each observer
- Finds bridging features
**Coherence Composer uses**: Accessibility constraint
- Verifies counterfactuals respect epistemic boundaries
- Asks: "Can all observers verify this counterfactual with their knowledge access?"
```
Observer: computational (can access: logic, patterns, structure)
Counterfactual: "A world where 2+2=5"
Verification: ✗ FAILS logical constraint
✗ FAILS accessibility constraint (no observer can verify this)
Result: This counterfactual is OPEN (impossible given what we can know)
```
### With worlds.jl (Julia)
Integration for parallel world spawning:
```julia
result = world_coherence_composer(
seed=0x285508656870f24a,
system="music-composition",
ontology=["composition", "structure", "harmony"],
accessibility=["computational", "embodied", "temporal"]
)
# Returns: Dict with constraints, validations, valid_count, etc.
# Parallelizable:
results = fork_all([
() -> world_coherence_composer(seed=s, system=system)
for s in seeds
])
```
### Full Trialectic Integration
```julia
result = world_full_skill_integration(
seed=0x285508656870f24a,
ontology=["composition", "structure", "harmony"],
accessibility=["computational", "embodied", "temporal"]
)
# Demonstrates all three skills:
# Level 1 (Commitment): "What exists?" → ontology
# Level 2 (Opacity): "What can we know?" → epistemology
# Level 3 (Coherence): "What could be true?" → possibility
```
---
## Testing Guide
### Test 1: Constraint Disclosure
```bash
bb .topos/coherence_composer_2monad.bb constraints
```
**Check**:
- [ ] All 5 constraints listed
- [ ] Severity levels correct (2 critical, 2 high, 1 medium)
- [ ] Predicates shown for each constraint
- [ ] All predicates listed at bottom
### Test 2: Closure Verification
```bash
bb .topos/coherence_composer_2monad.bb closure
```
**Check**:
- [ ] Three counterfactuals tested
- [ ] world-A shows 5/5 satisfied (CLOSED)
- [ ] world-B shows 4/5 satisfied (OPEN) ← logical constraint fails
- [ ] world-C shows 3/5 satisfied (OPEN) ← temporal and commitment fail
- [ ] Closure status matches satisfaction ratio
### Test 3: Minimal World Construction
```bash
bb .topos/coherence_composer_2modan.bb minimal
```
**Check**:
- [ ] Three minimal worlds shown
- [ ] Each has 2 property changes
- [ ] Magnitude around 1.5
- [ ] Worlds sorted by fewest changes
- [ ] "Minimal world selected" identifies simplest
### Test 4: Historical Branching
```bash
bb .topos/coherence_composer_2modan.bb branching
```
**Check**:
- [ ] Total candidates (3)
- [ ] Valid variants (3)
- [ ] Validity rate (100%)
- [ ] Each valid variant shows 5/5 satisfaction
- [ ] All 5 constraint types mentioned in interpretation
---
## Limitations and Future Work
### Current Limitations
1. **Binary constraint satisfaction**: Constraints are either satisfied or not (no partial credit)
- Future: Probabilistic constraints with confidence scores
2. **Hand-defined constraints**: Constraints are specified manually per system
- Future: Learn constraints from data via causal inference
3. **Enumeration-based exploration**: Valid space found by enumerating candidates
- Future: Constraint satisfaction solver (SAT/SMT) for principled search
4. **No temporal dynamics**: Constraints assumed fixed
- Future: Allow constraints to evolve as dialogue progresses
5. **Static change magnitudes**: Changes have fixed cost
- Future: Context-dependent change costs (some worlds cheaper to reach)
6. **No preference ordering**: All valid variants treated equally
- Future: Aesthetic/pragmatic preferences on valid space
### Future Enhancements
- [ ] **SAT Solver Integration**: Use constraint satisfaction to guarantee completeness
- [ ] **Probabilistic Constraints**: Soft constraints with confidence
- [ ] **Constraint Learning**: Discover constraints from execution traces
- [ ] **Preference Modeling**: Order valid variants by agent preferences
- [ ] **Temporal Dynamics**: Constraints that evolve with narrative
- [ ] **Cost Models**: Context-dependent change costs
- [ ] **Multi-Agent Coherence**: Reconcile counterfactuals across multiple agents
- [ ] **Phenomenological Grounding**: Connect constraints to human experience
- [ ] **Cross-Domain Application**: Apply to medicine, ecology, policy, etc.
---
## Performance Characteristics
| Operation | Time | Space |
|-----------|------|-------|
| Extract constraints (1 system) | < 1ms | O(n) |
| Verify closure (1 counterfactual) | < 1ms | O(n) |
| Verify all (3 counterfactuals) | < 5ms | O(n²) |
| Enumerate variants (3 variants) | < 10ms | O(n) |
| Full scenario (all 4 games) | < 25ms | O(n) |
Where n = number of constraints (typically 5-10).
---
## Key Insights
### 1. Constraints Delimit Possibility
Not everything is possible. Constraints (temporal, logical, ontological, epistemic, conservational) narrow the space of valid counterfactuals dramatically.
### 2. Closure is Objective
A counterfactual either satisfies all constraints (closed) or violates some (open). This is not a matter of opinion—it's structural.
### 3. The Sheaf Condition Matters
Local consistency (each constraint satisfied) ≠ Global coherence (all constraints glue). Coherence Composer verifies both.
### 4. Minimal Worlds are Preferable
Among valid counterfactuals, prefer those requiring fewest/smallest changes (Occam's razor). Simplicity is a virtue.
### 5. Three Skills Form a Complete System
- **Commitment Tracker**: Negotiates what's real
- **Opacity Detector**: Respects what's knowable
- **Coherence Composer**: Validates what's possible
Together they enable principled multi-agent coordination across ontology, epistemology, and possibility.
---
## References
- **Constraint Satisfaction**: Dechter, R. (2003). *Constraint Processing*
- **Sheaf Theory**: MacLane, S. & Moerdijk, I. (1992). *Sheaves in Geometry and Logic*
- **Counterfactuals**: Lewis, D. (1973). *Counterfactuals*
- **Possible Worlds**: Kripke, S. (1980). *Naming and Necessity*
- **Modal Logic**: Hughes, G. E. & Cresswell, M. J. (2012). *A New Introduction to Modal Logic*
- **Causal Models**: Pearl, J. (2009). *Causality: Models, Reasoning, and Inference*
---
## Key Takeaway
The **Coherence Composer** transforms **incompatible counterfactuals** into **valid variant spaces** by:
1. Extracting explicit constraints (temporal, logical, ontological, epistemic, conservational)
2. Verifying closure (all constraints satisfied simultaneously)
3. Constructing minimal worlds (fewest changes required)
4. Exploring valid space (what alternatives remain genuinely possible)
This allows multi-agent systems to reason about counterfactuals **not as fantasy, but as structural possibilities** constrained by reality, agreement, and knowledge.
---
**Status**: ✅ Production Ready (v1.0)
**Maturity**: 1.0 (complete implementation)
**Maintenance**: bmorphism
**License**: Plurigrid Collective (AGPL-3.0-or-later)
*Built for the **Counterfactual Worlds** project as the third of three skills distilled from the greatest increments to ontology, epistemology, and possibility.*
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!