Browse Source

refactor(atomise): Slim down from 522 to 170 lines

Keep the core AoT machinery, cut the ceremony:
- Preserve: decompose → verify → contract → backtrack loop
- Preserve: atom schema, confidence thresholds, modes
- Add: honest caveat that confidence numbers are heuristic
- Cut: elaborate flowcharts, exhaustive tables, output format specs
- Cut: state persistence details, redundant explanations

The command still works the same - it just doesn't over-explain itself.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
0xDarkMatter 3 months ago
parent
commit
d5e6d637db
1 changed files with 93 additions and 444 deletions
  1. 93 444
      commands/atomise.md

+ 93 - 444
commands/atomise.md

@@ -1,521 +1,170 @@
 ---
-description: "Atom of Thoughts (AoT) reasoning - decompose complex problems into minimal atomic units with confidence tracking, verification, and Markov contraction. Prevents error accumulation via backtracking."
+description: "Atom of Thoughts (AoT) reasoning - decompose complex problems into atomic units with confidence tracking and backtracking. For genuinely complex reasoning, not everyday questions."
 ---
 
 # Atomise - Atom of Thoughts Reasoning
 
-> Decompose complex problems into minimal, self-contained "atomic" units of thought. Unlike chain-of-thought (linear, history-dependent), AoT operates as a Markov process: each state depends only on the current contracted state, not the full history. This prevents error accumulation and enables backtracking.
+Decompose complex problems into minimal, verifiable "atoms" of thought. Unlike chain-of-thought (linear, error-accumulating), AoT treats each step as independently verifiable and backtracks when confidence drops.
 
-```
-/atomise "<problem>" [--mode] [--flags]
-    |
-    +-> Phase 0: SETUP
-    |     +- Restate problem (1 sentence)
-    |     +- Extract premises as atoms (conf=1.0)
-    |     +- Ensemble sketch: Direct / Decompose / Reframe
-    |
-    +-> Phase 1-N: ITERATION LOOP
-    |     |
-    |     +-> ATOMICITY GATE
-    |     |     Can answer from verified atoms? -> SOLVE directly
-    |     |
-    |     +-> DECOMPOSE
-    |     |     Build dependency DAG of atomic subquestions
-    |     |
-    |     +-> SOLVE + VERIFY
-    |     |     +- Solve leaf atoms first, propagate up
-    |     |     +- Every hypothesis needs verification
-    |     |     +- If conf < 0.6, decompose further
-    |     |
-    |     +-> CONTRACT (Markov update)
-    |     |     Create standalone state (drop history)
-    |     |
-    |     +-> EVALUATE
-    |           +- TERMINATE if conf >= MIN_CONFIDENCE
-    |           +- BACKTRACK if conf < 0.5
-    |           +- CONTINUE otherwise
-    |
-    +-> OUTPUT: Answer, confidence, atom table, risks
-```
-
----
-
-## Arguments
+**Use for:** Security analysis, architectural decisions, complex debugging, multi-step proofs.
+**Don't use for:** Simple questions, trivial calculations, information lookup.
 
 ```
-$ARGUMENTS
-
-Depth Modes (pick one):
-  --light              Fast mode: depth 3, confidence 0.70
-  (default)            Standard: depth 5, confidence 0.85
-  --deep               Exhaustive: depth 7, confidence 0.90
-
-Domain Modes (pick one):
-  (none)               General reasoning
-  --math               Mathematical proofs and calculations
-  --logic              Logical arguments and validity
-  --code               Code analysis (types, invariants, tests)
-  --security           Security analysis (threats, attacks)
-  --design             Architecture decisions (tradeoffs, constraints)
-
-Output Control:
-  --verbose            Full atom table with all metadata
-  --quiet              Final conclusion only (no atom table)
-  --json               JSON output for programmatic use
-  --mermaid            Generate Mermaid dependency graph
-
-State Persistence:
-  --save <file>        Save atom chain to JSON for later
-  --load <file>        Resume from saved atom chain
-
-Parameters (advanced):
-  --max-depth N        Override max depth (1-10)
-  --min-confidence N   Override min confidence (0.5-0.99)
+/atomise "<problem>" [--light | --deep] [--math | --code | --security | --design]
 ```
 
 ---
 
-## Atom Schema
-
-Each atom is a minimal, self-contained unit of thought:
+## The Core Loop
 
 ```
-{atomId, atomType, content, dependencies[], confidence, isVerified, depth}
+1. DECOMPOSE → Break into atomic subquestions (1-2 sentences each)
+2. SOLVE      → Answer leaf nodes first, propagate up
+3. VERIFY     → Test each hypothesis (counterexample, consistency, domain check)
+4. CONTRACT   → Summarize verified state in 2 sentences (drop history)
+5. EVALUATE   → Confident enough? Done. Too uncertain? Backtrack and try another path.
 ```
 
-| Field | Type | Description |
-|-------|------|-------------|
-| `atomId` | string | Unique ID: P1, R1, H1, V1, C1 (by type) |
-| `atomType` | enum | premise / reasoning / hypothesis / verification / conclusion |
-| `content` | string | The atomic thought (1-3 sentences max) |
-| `dependencies` | string[] | atomIds this depends on |
-| `confidence` | float | 0.0 to 1.0 |
-| `isVerified` | boolean | Has passed verification? |
-| `depth` | int | Distance from root premises |
-
-### Atom Types
-
-| Type | Prefix | Purpose | Initial Conf |
-|------|--------|---------|--------------|
-| `premise` | P | Given facts, constraints | 1.0 |
-| `reasoning` | R | Logical inference | Derived |
-| `hypothesis` | H | Tentative claim to test | max 0.7 unverified |
-| `verification` | V | Result of testing | Derived |
-| `conclusion` | C | Final answer | Derived |
+Repeat until confident or all paths exhausted.
 
 ---
 
-## Confidence Rules
+## Atoms
 
-### Base Rules
-1. **Premises (given facts):** confidence = 1.0
-2. **Assumptions (not given):** cap at 0.6 until verified
-3. **Derived atoms:** conf = min(parent confs) x verify_factor
-4. **Unverified atoms:** max 0.7 (provisional)
-
-### Verification Factors
-
-| Result | Factor | Effect |
-|--------|--------|--------|
-| Strong confirmation | 1.05 | Slight boost (capped at 1.0) |
-| Confirmed | 1.0 | Maintains confidence |
-| Partial | 0.85 | Reduces confidence |
-| None | 1.0 | No change |
-| Refuted | 0.3 | Major reduction |
-
-### Propagation Formula
+Each atom is a minimal unit:
 
 ```
-atom.confidence = min([dep.confidence for dep in dependencies]) * verify_factor
+{id, type, content, depends_on[], confidence, verified}
 ```
 
-### Backtrack Trigger
+| Type | Purpose | Starting Confidence |
+|------|---------|---------------------|
+| **premise** | Given facts | 1.0 |
+| **reasoning** | Logical inference | Inherited from parents |
+| **hypothesis** | Claim to test | Max 0.7 until verified |
+| **verification** | Test result | Based on test outcome |
+| **conclusion** | Final answer | Propagated from chain |
 
-```
-IF atom.confidence < BACKTRACK_THRESHOLD (default 0.5):
-    prune_descendants(atom)
-    restore_to_last_contraction()
-    try_alternative_from_ensemble()
-```
+**Confidence propagates:** A child can't be more confident than its least-confident parent.
 
 ---
 
-## Execution Protocol
+## Confidence (Honest Caveat)
 
-### Phase 0: Setup
+These numbers are *heuristic*, not calibrated probabilities. They're useful for tracking relative certainty, not for actual risk assessment.
 
-**RESTATE** the problem in 1 sentence.
+| Threshold | Meaning |
+|-----------|---------|
+| **> 0.85** | Confident enough to conclude |
+| **0.6 - 0.85** | Needs more verification |
+| **< 0.6** | Decompose further or backtrack |
+| **< 0.5** | Backtrack - this path isn't working |
 
-**PREMISES** - Extract as atoms:
-- Given facts -> [P1], [P2]... (conf=1.0)
-- Assumptions -> tag "ASSUMPTION" (conf<=0.6)
-
-**ENSEMBLE SKETCH** (2 sentences each):
-- A) **Direct** - Solvable immediately?
-- B) **Decompose** - What subquestions unlock this?
-- C) **Reframe** - Alternative formulation?
-
-Select best approach or hybridize.
-
-### Phase 1-N: Iteration Loop
-
-```
-+-------------------------------------------------------+
-| STEP 1: ATOMICITY GATE                                |
-|                                                       |
-| Can CurrentState be answered from verified atoms?     |
-| - YES -> Jump to STEP 3 (solve directly)              |
-| - NO  -> Continue to STEP 2                           |
-+-------------------------------------------------------+
-                          |
-                          v
-+-------------------------------------------------------+
-| STEP 2: DECOMPOSE                                     |
-|                                                       |
-| Build dependency DAG of atomic subquestions:          |
-|   Atom -> [DependsOn...]                              |
-|                                                       |
-| Rules:                                                |
-| - Each atom: 1-2 sentences or single calculation      |
-| - Leaf nodes have no unresolved dependencies          |
-+-------------------------------------------------------+
-                          |
-                          v
-+-------------------------------------------------------+
-| STEP 3: SOLVE + VERIFY                                |
-|                                                       |
-| - Solve leaf atoms first, propagate upward            |
-| - Every hypothesis needs >=1 verification atom        |
-| - Select verification method based on domain          |
-|                                                       |
-| LOCAL REFINEMENT: If key atom conf < 0.6 ->           |
-|                   decompose that atom further         |
-+-------------------------------------------------------+
-                          |
-                          v
-+-------------------------------------------------------+
-| STEP 4: CONTRACT (Markov update)                      |
-|                                                       |
-| Create ContractedState[depth=N] in <=2 sentences:     |
-| - Verified results needed going forward               |
-| - Remaining unknowns                                  |
-| - Next subgoal                                        |
-|                                                       |
-| DROP all other context - state must be standalone     |
-+-------------------------------------------------------+
-                          |
-                          v
-+-------------------------------------------------------+
-| STEP 5: EVALUATE                                      |
-|                                                       |
-| TERMINATE if:                                         |
-| - Can answer from contracted state                    |
-| - Conclusion confidence >= MIN_CONFIDENCE             |
-|                                                       |
-| BACKTRACK if:                                         |
-| - Best path yields conf < 0.5 after verification      |
-| - Return to previous ContractedState                  |
-| - Try alternative from ensemble sketch                |
-|                                                       |
-| OTHERWISE: Continue to next depth                     |
-+-------------------------------------------------------+
-```
+**Verification adjusts confidence:**
+- Confirmed → maintain or slight boost
+- Partial → reduce ~15%
+- Refuted → major reduction, likely backtrack
 
 ---
 
-## Verification Methods
-
-Select method based on domain mode:
-
-### General (all domains)
-
-| Method | When | How |
-|--------|------|-----|
-| `consistency_check` | Any reasoning | No contradictions with verified atoms |
-| `counterexample_search` | Hypothesis | Try to find case that disproves |
-| `dependency_valid` | Any with deps | All dependencies verified |
-
-### Math Mode (--math)
-
-| Method | When | How |
-|--------|------|-----|
-| `arithmetic_check` | Numeric claims | Step-by-step calculation |
-| `algebraic_verify` | Equations | Substitute and confirm |
-| `proof_check` | Logical steps | Validate inference rules |
-| `boundary_test` | Ranges | Test edge cases |
+## Modes
 
-### Logic Mode (--logic)
+**Depth:**
+- `--light` — Fast: max 3 levels, 0.70 confidence threshold
+- *(default)* — Standard: max 5 levels, 0.85 threshold
+- `--deep` — Exhaustive: max 7 levels, 0.90 threshold
 
-| Method | When | How |
-|--------|------|-----|
-| `contradiction_test` | Any claim | Check if negation contradicts |
-| `completeness_check` | Final reasoning | All cases covered? |
-| `validity_proof` | Arguments | Sound from premises? |
-
-### Code Mode (--code)
-
-| Method | When | How |
-|--------|------|-----|
-| `type_check` | Type claims | Verify compatibility |
-| `invariant_verify` | Loop/state | Confirm invariant holds |
-| `test_case_gen` | Behavior | Generate confirming test |
-| `complexity_check` | Performance | Verify Big-O |
-
-### Security Mode (--security)
-
-| Method | When | How |
-|--------|------|-----|
-| `threat_model` | Security claims | Map to threat categories |
-| `attack_surface` | Defense claims | Enumerate attacks |
-| `adversarial_test` | Any hypothesis | Assume attacker view |
-
-### Design Mode (--design)
-
-| Method | When | How |
-|--------|------|-----|
-| `tradeoff_analysis` | Decisions | Enumerate pros/cons |
-| `constraint_sat` | Architecture | All requirements met? |
-| `feasibility_check` | Implementation | Technically achievable? |
+**Domain** (adjusts verification style):
+- `--math` — Arithmetic checks, proof validation, boundary tests
+- `--code` — Type checking, invariant verification, test generation
+- `--security` — Threat modeling, attack surface, adversarial thinking
+- `--design` — Tradeoff analysis, constraint satisfaction, feasibility
 
 ---
 
-## Output Format
-
-### Standard Output
+## Output
 
 ```
-ANSWER: {clear result}
-CONFIDENCE: {0.0-1.0} - {1-2 sentence justification}
-
-KEY ATOMS: [P1, R2, H1, V1, C1]
+ANSWER: {result}
+CONFIDENCE: {0.0-1.0} - {why}
 
-CONTRACTIONS:
-- depth 0: {original problem}
-- depth 1: {contracted state after first iteration}
-- depth N: {final contracted state}
+KEY CHAIN: P1 → R1 → H1 → V1 → C1
 
 ATOMS:
-| atomId | type | content | deps | conf | verified |
-|--------|------|---------|------|------|----------|
-| P1 | premise | ... | [] | 1.0 | Y |
-| P2 | premise | ... | [] | 1.0 | Y |
-| R1 | reasoning | ... | [P1,P2] | 0.95 | Y |
-| H1 | hypothesis | ... | [R1] | 0.85 | Y |
-| V1 | verification | ... | [H1] | 0.90 | Y |
-| C1 | conclusion | ... | [H1,V1] | 0.88 | Y |
-
-OPEN RISKS: {what would raise or lower confidence}
-```
-
-### Verbose Output (--verbose)
+| id | type | content | conf | verified |
+|----|------|---------|------|----------|
+| P1 | premise | Given: ... | 1.0 | Y |
+| R1 | reasoning | Therefore: ... | 0.95 | Y |
+| ... | ... | ... | ... | ... |
 
-Adds:
-- Full dependency graph
-- Each verification step with reasoning
-- Confidence propagation log
-- Backtrack history (if any)
-- Alternative paths considered
-
-### Quiet Output (--quiet)
-
-```
-ANSWER: {result}
-CONFIDENCE: {0.0-1.0}
-```
-
-### JSON Output (--json)
-
-```json
-{
-  "problem": "...",
-  "parameters": {"maxDepth": 5, "minConfidence": 0.85, "domain": null},
-  "atoms": [
-    {"atomId": "P1", "atomType": "premise", "content": "...", "dependencies": [], "confidence": 1.0, "isVerified": true, "depth": 0}
-  ],
-  "contractions": [
-    {"depth": 0, "state": "..."},
-    {"depth": 1, "state": "..."}
-  ],
-  "backtracks": [],
-  "conclusion": {"content": "...", "confidence": 0.88, "supportingAtoms": ["P1", "R1", "H1"]}
-}
+RISKS: {what could change this}
 ```
 
-### Mermaid Output (--mermaid)
-
-```mermaid
-flowchart TD
-    P1[P1: Premise<br/>conf: 1.00] --> R1
-    P2[P2: Premise<br/>conf: 1.00] --> R1
-    R1[R1: Reasoning<br/>conf: 0.95] --> H1
-    H1[H1: Hypothesis<br/>conf: 0.85] --> V1
-    V1[V1: Verified<br/>conf: 0.90] --> C1
-    C1[C1: Conclusion<br/>conf: 0.88]
-
-    style P1 fill:#90EE90
-    style P2 fill:#90EE90
-    style C1 fill:#87CEEB
-```
+Add `--verbose` for full trace, `--quiet` for just the answer.
 
 ---
 
-## State Persistence
+## Execution Guide
 
-### Save State
+### Phase 0: Setup
 
-```bash
-/atomise "Complex problem" --save atoms.json
-```
+1. **Restate** the problem in one sentence
+2. **Extract premises** as atoms (given facts = 1.0, assumptions = 0.6)
+3. **Sketch approaches:** Direct solve? Decompose? Reframe? Pick best.
 
-Saves to `.claude/atomise/atoms.json`:
-```json
-{
-  "problem": "...",
-  "timestamp": "2025-12-14T10:30:00Z",
-  "currentDepth": 3,
-  "atoms": [...],
-  "contractions": [...],
-  "nextSubgoal": "..."
-}
-```
+### Phase 1+: Iterate
 
-### Load and Resume
+1. **Atomicity gate:** Can you answer from verified atoms? Yes → solve. No → decompose.
+2. **Decompose:** Build dependency tree of atomic subquestions
+3. **Solve + Verify:** Leaves first, propagate up. Every hypothesis needs verification.
+4. **Contract:** Summarize in ≤2 sentences. Drop everything else.
+5. **Evaluate:**
+   - Confident? → Terminate
+   - Uncertain but viable? → Continue
+   - Low confidence? → Backtrack, try alternative
 
-```bash
-/atomise --load atoms.json
-```
+### Backtracking
 
-Resumes from saved contracted state, continuing the iteration loop.
+When a path yields confidence < 0.5 after verification:
+1. Prune that branch
+2. Restore to last contracted state
+3. Try alternative from initial sketch
 
 ---
 
-## Usage Examples
-
-### Basic Usage
+## Examples
 
 ```bash
-# Simple question
-/atomise "What causes a deadlock in concurrent programming?"
-
-# Mathematical proof
-/atomise "Prove that the sum of angles in a triangle is 180 degrees" --math
+# Complex debugging
+/atomise "Why does this function return null on the second call?" --code
 
-# Code debugging
-/atomise "Why does this function return null unexpectedly?" --code
-```
-
-### Light Mode (Quick Analysis)
+# Security review
+/atomise "Is this authentication flow vulnerable to session fixation?" --security
 
-```bash
-# Fast decision
-/atomise "Should I use useState or useReducer here?" --light
+# Architecture decision
+/atomise "Should we use event sourcing for this domain?" --deep --design
 
-# Quick security check
-/atomise "Is this input validation sufficient?" --light --security
+# Quick decision (light mode)
+/atomise "Redis vs Memcached for this cache layer?" --light
 ```
 
-### Deep Mode (Exhaustive)
-
-```bash
-# Critical architecture decision
-/atomise "Should we migrate to microservices?" --deep --design
-
-# Security audit
-/atomise "Is this authentication flow secure?" --deep --security
-```
-
-### With Visualization
-
-```bash
-# See dependency graph
-/atomise "Trace the data flow in this component" --mermaid --code
-
-# Full reasoning trace
-/atomise "Optimal algorithm for this problem?" --verbose --math
-```
-
-### Multi-Session
-
-```bash
-# Save for later
-/atomise "Design the new API schema" --save api-design.json
-
-# Resume tomorrow
-/atomise --load api-design.json
-```
-
----
-
-## Light vs Deep Comparison
-
-| Aspect | Light | Default | Deep |
-|--------|-------|---------|------|
-| Max Depth | 3 | 5 | 7 |
-| Min Confidence | 0.70 | 0.85 | 0.90 |
-| Backtrack Threshold | 0.50 | 0.60 | 0.70 |
-| Verification | Basic | Standard | Exhaustive |
-| Use Case | Quick decisions | General | Critical analysis |
-
----
-
-## Integration
-
-### With TodoWrite
-
-For actionable conclusions, automatically creates tasks:
-
-```
-TodoWrite:
-  - content: "Implement: [AoT conclusion step 1]"
-    status: "pending"
-    activeForm: "Implementing AoT conclusion"
-```
-
-### With Code Problems (--code)
-
-1. Reads relevant source files via Read tool
-2. Extracts function signatures as premises
-3. Maps type constraints
-4. Generates test cases for verification
-
 ---
 
 ## Anti-Patterns
 
 ```
-BAD:  /atomise "What's 2+2?"
-      Too trivial - just answer directly
-
-BAD:  /atomise "Design entire system" --light
-      Too complex for light mode
-
-BAD:  /atomise "Is this SQL safe?" (no domain)
-GOOD: /atomise "Is this SQL safe?" --security --code
-
-BAD:  Ignoring low confidence and forcing conclusion
-GOOD: Let AoT backtrack and explore alternatives
+BAD:  /atomise "What's 2+2?"           → Just answer it
+BAD:  /atomise "Rewrite this function" → That's implementation, not reasoning
+BAD:  Forcing conclusion despite low confidence → Let it backtrack
+GOOD: /atomise for genuine uncertainty requiring structured decomposition
 ```
 
 ---
 
-## When to Use AoT
-
-| Scenario | Use AoT? |
-|----------|----------|
-| Complex multi-step reasoning | Yes |
-| Debugging with unclear root cause | Yes |
-| Architecture decisions | Yes |
-| Security analysis | Yes |
-| Simple factual questions | No |
-| Trivial calculations | No |
-| Pure information lookup | No |
-
----
-
 ## Remember
 
-1. **Atomic = Minimal.** Each atom should be 1-2 sentences max.
-2. **Verify everything.** Hypotheses need verification atoms.
-3. **Contract aggressively.** Drop context, keep only what's needed.
-4. **Backtrack freely.** Low confidence = try another path.
-5. **Confidence propagates.** Children can't exceed parent confidence.
+1. **Atomic = minimal.** 1-2 sentences per atom.
+2. **Verify everything.** Hypotheses need tests.
+3. **Contract aggressively.** Keep only what's needed for next step.
+4. **Backtrack freely.** Low confidence means try another path.
+5. **Confidence is heuristic.** Useful for structure, not actual probabilities.