persistent-homology
БесплатноБез исполняемых скриптовНе проверенTopological data analysis for stable feature verification across filtrations of code complexity.
от plurigrid★ 73 звезды на GitHubОб этом скилле
Persistent Homology Skill: Stable Feature Verification
Status: ✅ Production Ready Trit: -1 (MINUS - validator/analyzer) Color: #2626D8 (Blue) Principle: Stable features → Robust structure Frame: Filtration with persistence diagrams
Overview
Persistent Homology identifies topological features that persist across scales. Implements:
- Filtration: Nested sequence of complexes by parameter
- Betti numbers: β₀ (components), β₁ (holes), β₂ (voids)
- Persistence diagrams: Birth-death pairs for features
- radare2 integration: Binary analysis for structure holes
Correct by construction: Features with long persistence are stable/significant; short-lived features are noise.
Core Formula
Filtration: K₀ ⊆ K₁ ⊆ ... ⊆ Kₙ (by threshold ε)
Homology: H_k(K_i) for each level
Persistence: (birth_i, death_j) for each feature
Stability Theorem:
d_B(Dgm(f), Dgm(g)) ≤ ||f - g||_∞
For code complexity:
# Filtration by cyclomatic complexity threshold
filtration = [
threshold_0: simple_functions,
threshold_5: moderate_functions,
threshold_10: complex_functions,
threshold_20: very_complex_functions
]
# Persistent features survive across thresholds
stable_structure = features.select { |f| f.persistence > 5 }
Why Persistent Homology for Code?
- Complexity filtration: Track structure across complexity levels
- Structural holes: β₁ > 0 means cyclic dependencies
- Stability: Long-lived features are fundamental
- Noise filtering: Short-lived features are incidental
Gadgets
1. ComplexityFiltration
Build filtration from code complexity:
filtration = PersistentHomology::ComplexityFiltration.new(
source: :codebase,
metric: :cyclomatic_complexity
)
filtration.add_file("src/core.clj")
filtration.build!
filtration.levels # => [0, 5, 10, 15, 20]
filtration.complex_at(10) # => simplicial complex at threshold 10
filtration.inclusion(5, 10) # => inclusion map K_5 → K_10
2. BettiCalculator
Compute Betti numbers across filtration:
betti = PersistentHomology::BettiCalculator.new(filtration)
betti.compute!
betti.beta_0(level: 5) # => connected components
betti.beta_1(level: 10) # => 1-dimensional holes (cycles)
betti.beta_2(level: 15) # => 2-dimensional voids
betti.euler_characteristic(level: 10) # => χ = β₀ - β₁ + β₂
3. PersistenceDiagram
Track feature birth/death:
diagram = PersistentHomology::PersistenceDiagram.new(filtration)
diagram.compute!
diagram.pairs # => [(birth, death), ...]
diagram.dimension(1) # => 1-dim features only
diagram.persistence(feature) # => death - birth
diagram.stable_features(threshold: 5) # => long-lived only
diagram.bottleneck_distance(other_diagram) # => stability metric
4. Radare2Analyzer
Integration with radare2 for binary analysis:
analyzer = PersistentHomology::Radare2Analyzer.new(
binary_path: "/path/to/binary",
analysis_level: 2
)
analyzer.analyze!
analyzer.function_call_graph # => build complex from CFG
analyzer.complexity_filtration # => filter by function size
analyzer.structural_holes # => β₁ features (circular calls)
analyzer.persistence_diagram # => stable binary structures
5. StabilityVerifier
Verify structural stability:
verifier = PersistentHomology::StabilityVerifier.new
verifier.add_version(:v1, filtration_v1)
verifier.add_version(:v2, filtration_v2)
result = verifier.verify!
result[:bottleneck_distance] # => how different
result[:stable_preserved] # => long-lived features kept
result[:new_stable_features] # => emerged stable features
result[:lost_stable_features] # => disappeared features
result[:gf3_conserved] # => triad conservation
Commands
# Compute persistent features
just homology-persist
# Analyze specific codebase
just homology-filter src/
# Binary analysis with radare2
just homology-binary /path/to/binary
# Compare versions
just homology-diff v1 v2
API
require 'persistent_homology'
# Create analyzer
analyzer = PersistentHomology::Analyzer.new(
trit: -1,
filtration_metric: :complexity
)
# Build filtration
analyzer.add_codebase("src/")
filtration = analyzer.build_filtration!
# Compute persistence
diagram = analyzer.compute_persistence!
# Get stable features
stable = diagram.stable_features(threshold: 5)
stable.each do |feature|
puts "#{feature.dimension}-dim: born=#{feature.birth}, died=#{feature.death}"
end
Integration with GF(3) Triads
Forms valid triads with ERGODIC (0) and PLUS (+1) skills:
persistent-homology (-1) ⊗ acsets (0) ⊗ gay-mcp (+1) = 0 ✓
persistent-homology (-1) ⊗ unworld (0) ⊗ cider-clojure (+1) = 0 ✓
persistent-homology (-1) ⊗ glass-bead-game (0) ⊗ rubato-composer (+1) = 0 ✓
Mathematical Foundation
Simplicial Homology
Chain complex: C_n(K) → C_{n-1}(K) → ... → C_0(K)
Boundary map: ∂_n: C_n → C_{n-1}
Cy
Установить persistent-homology в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл persistent-homology?
Topological data analysis for stable feature verification across filtrations of code complexity.
Как установить скилл persistent-homology?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл persistent-homology запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic