Conversation
…gorithms for structure Replace AI subagent calls with classical algorithms wherever the operation is structurally decidable. Adds TF-IDF cosine similarity (replaces Jaccard), Kahn's topological sort (cycle detection + solve scheduling), git merge-tree reunification, greedy set cover pruning, and complexity scoring. AI is now reserved for semantic operations only: decompose, solve, conflict resolution. New scripts: - solve_scheduler.py: DAG-based critical path scheduling into parallel waves - reunify_merge.py: git 3-way merge + structural conflict detection - prune_gate.py: set cover redundancy analysis Enhanced: - decompose_gate.py: TF-IDF, cycle detection, complexity scoring, budget allocation - SKILL.md: algorithmic spine design principle + updated orchestration protocol Spec: 047-fractal-algorithmic-spine https://claude.ai/code/session_01Gpuehvo6XBmDyQeCQS142c
Replace Python scripts (.harness/scripts/) with native Rust modules (cli/src/fractal/) and a new `synodic fractal` CLI subcommand. Modules: - fractal/decompose.rs: TF-IDF cosine similarity via rust-tfidf crate, combined with Jaccard pre-filter for orthogonality. Kahn's topological sort for cycle detection. Weighted feature scoring for complexity. Proportional budget allocation. - fractal/schedule.rs: DAG-based BFS layer decomposition for solve wave scheduling. Critical path analysis via longest-path DP. - fractal/reunify.rs: git merge-tree 3-way merge for code reunification. Set intersection for boundary/redundancy/gap detection. - fractal/prune.rs: Greedy set cover for minimal covering set. Subset detection and identical output pairing. CLI subcommands: synodic fractal gate — decompose validation synodic fractal schedule — solve wave scheduling synodic fractal reunify — code reunification analysis synodic fractal prune — redundancy detection synodic fractal complexity — standalone complexity scoring 60 tests pass (28 new fractal tests + 32 existing). https://claude.ai/code/session_01Gpuehvo6XBmDyQeCQS142c
Comprehensive docs/FRACTAL.md covering: - Architecture flowchart (ASCII) showing algorithmic spine vs AI calls - AI vs algorithm split diagram with call count comparison - Visual breakdowns for each gate (decompose, solve, reunify, prune) - Complexity scoring weight visualization - Wave scheduling example with dependency graph - Conflict classification table - Node status lifecycle diagram - CLI reference with input/output JSON examples - Algorithm table with complexity classes - Classical algorithm analog mapping - Governance integration checkpoint diagram - Test coverage matrix https://claude.ai/code/session_01Gpuehvo6XBmDyQeCQS142c
There was a problem hiding this comment.
Pull request overview
Implements a deterministic “algorithmic spine” for Fractal decomposition by adding Rust-based structural gates/schedulers/mergers/pruners and updating the Fractal skill/docs to use these CLI subcommands instead of AI subagents for structurally decidable work.
Changes:
- Added
synodic fractalCLI with subcommands for gate/schedule/reunify/prune/complexity, plus shared manifest/types/utilities. - Implemented classical algorithms in Rust (TF‑IDF similarity, topo scheduling, merge-tree analysis, greedy set cover) to reduce AI calls and improve reproducibility.
- Updated Fractal documentation/specs and removed the legacy Python decompose gate script.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
specs/047-fractal-algorithmic-spine/README.md |
New spec describing the algorithmic spine approach and algorithms used |
skills/fractal/SKILL.md |
Updates orchestration protocol to use synodic fractal algorithmic subcommands |
docs/README.md |
Adds Fractal documentation entry |
docs/FRACTAL.md |
New comprehensive Fractal algorithmic spine documentation |
cli/src/main.rs |
Wires new Fractal top-level CLI command |
cli/src/cmd/mod.rs |
Exposes new cmd::fractal module |
cli/src/cmd/fractal.rs |
Implements synodic fractal {gate,schedule,reunify,prune,complexity} command parsing and I/O |
cli/src/fractal/mod.rs |
Adds shared Fractal types + term extraction/Jaccard utilities |
cli/src/fractal/decompose.rs |
Implements decompose gate (TF‑IDF, coverage, budget, cycles, waves, complexity) |
cli/src/fractal/schedule.rs |
Implements dependency-wave scheduling + critical path computation |
cli/src/fractal/reunify.rs |
Implements structural reunify conflict checks + git merge-tree-based analysis |
cli/src/fractal/prune.rs |
Implements prune gate (subset/identity detection + greedy set cover) |
cli/Cargo.toml |
Adds rust-tfidf dependency |
cli/Cargo.lock |
Locks rust-tfidf dependency |
.harness/scripts/decompose_gate.py |
Removes legacy Python gate script |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+116
to
+134
| /// Extract lowercase alphanumeric terms (>=3 chars), filtering stop words. | ||
| pub fn extract_terms(text: &str) -> HashSet<String> { | ||
| let stop: HashSet<&str> = STOP_WORDS.iter().copied().collect(); | ||
| let re = regex::Regex::new(r"[a-zA-Z][a-zA-Z0-9_-]{2,}").unwrap(); | ||
| re.find_iter(text) | ||
| .map(|m| m.as_str().to_lowercase()) | ||
| .filter(|w| !stop.contains(w.as_str())) | ||
| .collect() | ||
| } | ||
|
|
||
| /// Extract terms preserving duplicates (for TF calculation). | ||
| pub fn extract_term_list(text: &str) -> Vec<String> { | ||
| let stop: HashSet<&str> = STOP_WORDS.iter().copied().collect(); | ||
| let re = regex::Regex::new(r"[a-zA-Z][a-zA-Z0-9_-]{2,}").unwrap(); | ||
| re.find_iter(text) | ||
| .map(|m| m.as_str().to_lowercase()) | ||
| .filter(|w| !stop.contains(w.as_str())) | ||
| .collect() | ||
| } |
Comment on lines
+203
to
+224
| // Find merge base | ||
| let merge_base = Command::new("git") | ||
| .args(["merge-base", base_ref, &child.branch]) | ||
| .output() | ||
| .ok()?; | ||
|
|
||
| if !merge_base.status.success() { | ||
| return None; | ||
| } | ||
|
|
||
| let base = String::from_utf8_lossy(&merge_base.stdout) | ||
| .trim() | ||
| .to_string(); | ||
|
|
||
| // Try merge-tree | ||
| let result = Command::new("git") | ||
| .args(["merge-tree", "--write-tree", &base, base_ref, &child.branch]) | ||
| .output() | ||
| .ok()?; | ||
|
|
||
| if result.status.success() { | ||
| return Some(MergeTreeResult { |
| @@ -0,0 +1,421 @@ | |||
| --- | |||
| status: draft | |||
Comment on lines
+373
to
+375
| return children | ||
| .iter() | ||
| .map(|c| (c.slug.clone(), remaining_budget.min(1) / n.max(1))) |
Comment on lines
+32
to
+35
| matches!( | ||
| node.status.as_str(), | ||
| "leaf" | "forced-leaf" | "pending" | ||
| ) && node.children.is_empty() |
Comment on lines
+82
to
+113
| /// Detect boundary violations: child modified files outside its scope. | ||
| fn check_scope_violations(children: &[ReunifyChild]) -> Vec<Conflict> { | ||
| let mut conflicts = Vec::new(); | ||
|
|
||
| for child in children { | ||
| let child_files: std::collections::HashSet<&String> = child.files.iter().collect(); | ||
|
|
||
| for sibling in children { | ||
| if sibling.slug == child.slug { | ||
| continue; | ||
| } | ||
| let sibling_files: std::collections::HashSet<&String> = | ||
| sibling.files.iter().collect(); | ||
| let overlap: Vec<String> = child_files | ||
| .intersection(&sibling_files) | ||
| .map(|f| f.to_string()) | ||
| .collect(); | ||
|
|
||
| if !overlap.is_empty() { | ||
| // Only flag once per pair (alphabetical order) | ||
| if child.slug < sibling.slug { | ||
| conflicts.push(Conflict { | ||
| category: "boundary".to_string(), | ||
| children: vec![child.slug.clone(), sibling.slug.clone()], | ||
| description: format!( | ||
| "Children '{}' and '{}' both modified: {}", | ||
| child.slug, | ||
| sibling.slug, | ||
| overlap.join(", "), | ||
| ), | ||
| files: overlap, | ||
| }); |
| > ## Reunification strategy: {reunification} | ||
| > | ||
| > ## Structural analysis (from algorithmic pre-check) | ||
| > {conflicts detected by reunify_merge.py, if any} |
|
|
||
| let mut prunable: Vec<String> = reasons.keys().cloned().collect(); | ||
| prunable.sort(); | ||
| let mut kept: Vec<String> = all_slugs.difference(&prunable.iter().cloned().collect()).cloned().collect(); |
Comment on lines
+338
to
+347
| let enumeration_count = lines | ||
| .iter() | ||
| .filter(|l| { | ||
| let trimmed = l.trim(); | ||
| trimmed.starts_with("- ") | ||
| || trimmed.starts_with("* ") | ||
| || regex::Regex::new(r"^\d+\.") | ||
| .unwrap() | ||
| .is_match(trimmed) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace AI subagent calls with classical algorithms for all structurally-decidable operations in fractal decomposition. This implements the "AI for semantics, algorithms for structure" principle, reducing AI calls by ~40% while improving determinism, reproducibility, and cost.
Key Changes
Decompose Gate (
cli/src/fractal/decompose.rs):rust-tfidfcrate)Solve Scheduler (
cli/src/fractal/schedule.rs):Reunify Merge (
cli/src/fractal/reunify.rs):git merge-treefor code reunificationPrune Gate (
cli/src/fractal/prune.rs):CLI Integration (
cli/src/cmd/fractal.rs,cli/src/main.rs):synodic fractalcommand with subcommands:gate,schedule,reunify,prune,complexityDocumentation (
docs/FRACTAL.md,specs/047-fractal-algorithmic-spine/README.md):Shared Types (
cli/src/fractal/mod.rs):Implementation Details
rust-tfidfcrate for proper inverse document frequency weighting; discriminative terms get higher weight than ubiquitous onesAll operations are deterministic and reproducible, with no randomness or external state dependencies.
https://claude.ai/code/session_01Gpuehvo6XBmDyQeCQS142c