Skip to content

Latest commit

 

History

History
253 lines (198 loc) · 7.64 KB

File metadata and controls

253 lines (198 loc) · 7.64 KB

Predicate Logging - Complete System Summary

What You Get

Three Skills in One Package

  1. predicate-logging.skill (Latest, most complete)

    • All 9 formal principles
    • Operational loop (fail-upward development)
    • Runtime validation library
    • Migration guide
    • Complete synthesis
  2. semantic-logging.skill (Practical patterns)

    • The "catastrophic 200" problem
    • State-conditional logging
    • Language-specific implementations
    • Good starting point for basic concepts

What's Inside predicate-logging.skill

predicate-logging.skill/
├── SKILL.md (Main specification)
│   ├── The 9 Core Principles
│   ├── Implementation Patterns (TS/JS/Python)
│   ├── Real-world Examples
│   └── The Operational Loop (overview)
│
└── references/
    ├── operational-loop.md ⭐ MOST IMPORTANT
    │   ├── Fail-upward development methodology
    │   ├── How to deliberately test and fail
    │   ├── Real iteration examples
    │   └── Production monitoring loop
    │
    ├── runtime-validation.md
    │   ├── Enforcement library (TypeScript + Python)
    │   ├── Automatic hierarchy validation
    │   ├── Proof tree visualization
    │   └── Integration with monitoring
    │
    └── migration-guide.md
        ├── 7-phase incremental adoption
        ├── How to retrofit existing code
        ├── Common pitfalls
        └── Success metrics

The Operational Loop (The Secret Sauce)

This is what makes predicate logging a development methodology, not just better logging.

The Loop

Development Phase:
1. Define predicates first ← Your assumptions about what should be true
2. Implement with logging ← Log each predicate as you check it
3. Test by deliberately breaking things ← Break each predicate on purpose
4. Read the proof tree ← See exactly which predicate failed
5. Fix the specific predicate ← Not the whole system
6. Repeat until all predicates pass ← Each failure teaches you something

Production Phase:
7. Monitor predicate pass rates ← Which ones are dropping?
8. Investigate failures ← What's the new failure mode?
9. Add predicates ← Fill gaps you discovered
10. Fix and repeat ← Continuous improvement

Why This Works

Traditional: Hope your code works, debug blindly when it doesn't
Predicate: Declare what should be true, test each assumption, know exactly what failed

You're not trying to write perfect code first try. You're building a system that tells you exactly what's wrong when reality diverges from your assumptions.

The Nine Principles (Quick Reference)

  1. Claim Rule - A log is a single predicate
  2. Honesty Rule - Only log what you actually checked
  3. Atomic First - Composite truths are inferred
  4. Hierarchy Rule - Children only in valid parent worlds
  5. Scope Rule - Be explicit about your world
  6. Correlation Rule - Claims belong to a specific run
  7. Modular Worlds - Valid subtrees are real logic
  8. Required Shape First - Stable schemas as contracts
  9. Shakespeare Monkeys - Small steps, smart environment

Quick Start

1. Upload the skill

Upload predicate-logging.skill to Claude

2. Ask Claude to add predicate logging

"Add predicate logging to this authentication function"

Claude will:

  • Map the predicate tree
  • Add typed log claims
  • Structure parent/child relationships
  • Include correlation IDs
  • Use the validation library

3. Use the operational loop

Read references/operational-loop.md and:

  • Define predicates before implementing
  • Test each predicate's failure mode deliberately
  • Read the proof tree to see what failed
  • Fix the specific predicate
  • Repeat

Key Documents

For Understanding the Concept

  1. Traditional-vs-Predicate-Comparison.md - Visual side-by-side comparison
  2. README-predicate-logging.md - Overview and philosophy

For Implementation

  1. SKILL.md - Complete specification with all 9 principles
  2. operational-loop.md - HOW to actually use this in development
  3. runtime-validation.md - Enforcement library implementation
  4. migration-guide.md - How to retrofit existing codebases

For Quick Reference

  • This file (you are here)

The Philosophy

Traditional Logging

log.info("API call completed");  // 200 OK
// (data.user is null, app crashes)

Problem: Technical success ≠ Semantic success

Predicate Logging

logSemantic({
  predicate: "user_data_present",
  passed: !!data.user,
  correlationId
});
// If it fails, you know EXACTLY why

Solution: Each log is a falsifiable claim about state

The Result

Traditional:

  • 3 hours to find root cause
  • "Can't reproduce"
  • "Works on my machine"
  • Blind debugging

Predicate:

  • 30 seconds to find root cause
  • Exact predicate that failed
  • Proof tree shows the path
  • Structured debugging

Real Impact

Before (Traditional)

Metrics: 99.9% success rate
Users: "Nothing works!"
You: "But the metrics say it's working... 🤷"
Debug time: 3-4 hours per issue

After (Predicate)

Metrics:
  http_request_successful: 99.9% ✅
  response_parseable: 99.8% ✅
  user_data_present: 95.2% ⚠️ ← The problem!

Alert: "user_data_present dropped below threshold"
Investigation: Logs show { error: "User deleted" }
Root cause: Not handling deleted users
Fix: Add user_not_deleted predicate
Debug time: 10 minutes

Who Should Use This

Use predicate logging when:

  • Building systems with external dependencies (APIs, databases)
  • Multi-step workflows where failure can happen anywhere
  • Need to distinguish technical vs semantic success
  • Want formal guarantees about runtime behavior
  • Teams developing independently need coordination
  • Production debugging is currently painful

Migration Timeline

Week 1: Pick one critical flow, map predicates
Week 2: Implement root predicates, test deliberately
Week 3: Complete predicate tree, add validation
Week 4: Build monitoring dashboard
Week 5-6: Prove value in production
Week 7+: Expand to next critical flow

Effort: 1-2 engineers, 4-6 weeks for first complete flow

The Ultimate Insight

Logs aren't debug noise. They're how you build the app.

When you declare predicates first, you're forced to articulate:

  • What should be true
  • How to detect when it's not
  • What the failure modes are

This is design by contract + test-driven development + formal verification rolled into one.

Each log is a monkey with a constrained typewriter.
The environment is smart and scoped.
Shakespeare emerges from composition of tiny, honest, checkable claims.

Next Steps

  1. Read the comparison - Traditional-vs-Predicate-Comparison.md
  2. Understand the loop - references/operational-loop.md
  3. Upload the skill - predicate-logging.skill
  4. Pick one flow - Start small
  5. Define predicates - What should be true?
  6. Test deliberately - Break each predicate
  7. Fix and learn - Each failure teaches you something

Remember: You're not trying to avoid failures. You're trying to make failures informative.

That's fail-upward development.


Credits

This system synthesizes:

  • Formal logic (predicates, hierarchies, worlds)
  • Practical engineering (catastrophic 200 problem, real patterns)
  • Runtime validation (self-enforcing rules)
  • Development methodology (operational loop, fail-upward)

It's the bridge between elegant theory and "teams can actually use this."


"Each monkey is dumb. The environment is smart and scoped. Reliability emerges from tiny, honest, checkable claims."