Repository navigation
feat(#353): dream cycle — coordinated maintenance pipeline - #390
Merged
Merged
Conversation
Add 'uteke dream', a single command that runs all 6 maintenance phases
in dependency order: lint → backlinks → dedup → orphans → compact → verify.
All local, zero LLM. Inspired by GBrain's overnight dream cycle.
Core (uteke-core):
- New dream.rs module:
- DreamPhase enum (6 phases) with all_in_order() + from_str_opt()
- DreamReport with per-phase results, totals, dry_run flag, duration
- PhaseResult / PhaseStatus types
- Uteke::dream(namespace, dry_run, phases) orchestrator
- Lint: count memories with unknown memory_type values
- Backlinks: rebuild_backlinks() (#350)
- Dedup: consolidate(threshold=0.92)
- Orphans: inline SQL count (degrades gracefully if #351 not merged)
- Compact: prune(TTL=30d)
- Verify: existing verify() (db/index consistency)
CLI (uteke-cli):
- New 'uteke dream [--phases P1,P2] [--skip P3] [--dry-run] [--quiet]'
- Exits non-zero on errors (cron-friendly)
- --quiet shows only warnings/errors
Tests (+4 new): phase roundtrip, phase order, dry-run, phase filter
Closes #353
🔍 Cora AI Code Review❌ Blocked — critical issues found. 🔴 Error (2)
Review powered by cora-cli · BYOK · MIT |
CodeCora #390 flagged two issues: 1. dream() propagated the first phase error via '?', aborting the whole pipeline. Fix: wrap each phase in a match — failures are recorded as a PhaseStatus::Error result but subsequent phases still run. 2. phase_lint loaded every memory into RAM via load_all() just to count bad types. Fix: use SQL COUNT with NOT IN (...) — O(1) memory, no deserialization overhead.
…te SQL errors CodeCora #390 found three issues: 1. Invalid --phases names were silently dropped via filter_map, causing 'uteke dream --phases bogus' to run ALL phases. Fix: return error listing valid phase names. 2. phase_orphans ignored the namespace parameter (_namespace). Running 'uteke dream --namespace X' counted orphans globally. Fix: add 'AND m.namespace = ?2' when namespace is provided. 3. Multiple SQL queries used unwrap_or(0) which masked database errors as 'clean' results. Fix: propagate via map_err → Error::db. Pipeline catch loop converts to PhaseStatus::Error without aborting.
CodeCora #390 r2: 1. phase_lint ignored namespace, running global COUNT regardless of the --namespace flag. Fix: add WHERE namespace = ?1 when namespace is provided. 2. phase_orphans SQL didn't exclude deprecated memories, matching the same bug fixed in #351. Fix: add AND m.deprecated = 0 to both namespace and global queries.
CodeCora #390 r3: phase_dedup set warnings=1 when duplicates were found but couldn't be merged (dry-run or threshold too high), yet status remained Ok. Inconsistent with phase_lint and phase_orphans which return Warning status for the same pattern. Fix: set PhaseStatus::Warning when has_warnings is true.
CodeCora #390 r3 raised two architectural concerns: 1. Backlinks phase is global, not namespace-scoped. This is by design — rebuild_backlinks() operates on the edge graph which is not namespace- partitioned. Documented in the dream() doc comment. 2. Orphan detection in dry-run doesn't reflect projected post-maintenance state. This is by design — dry-run reports against current state. Documented in the dream() doc comment. No code changes — documentation only.
CodeCora #390 r4: if user passed --phases verify,lint,backlinks, phases executed in that order instead of dependency order. verify before lint makes no sense and could produce misleading results. Fix: sort selected phases by canonical position in all_in_order(), and dedup duplicates. Added 2 tests: reversed order, and duplicate phases.
CodeCora #390 r4: phase_compact always printed 'memories pruned' even in dry-run mode, implying destructive changes already happened. Fix: print 'would be pruned' when dry_run is true.
cli.rs: added Dream command alongside Orphans and Timeline. commands/mod.rs: added dream dispatch alongside orphans and timeline. CHANGELOG: added #353 dream cycle section at top. Now that #351 (orphans) is merged into develop, dream's inline SQL orphan detection coexists with the proper find_orphans() API.
| ) -> Result<DreamReport, Error> { | ||
| let start = std::time::Instant::now(); | ||
| let mut selected: Vec<DreamPhase> = if phases.is_empty() { | ||
| DreamPhase::all_in_order().to_vec() |
| .store | ||
| .conn | ||
| .query_row("SELECT COUNT(*) FROM memories", [], |r| r.get(0)) | ||
| .map_err(|e| Error::db("dream lint total count", e))?; |
ajianaz
added a commit
that referenced
this pull request
Aug 13, 2026
* feat(#353): dream cycle — coordinated maintenance pipeline Add 'uteke dream', a single command that runs all 6 maintenance phases in dependency order: lint → backlinks → dedup → orphans → compact → verify. All local, zero LLM. Inspired by GBrain's overnight dream cycle. Core (uteke-core): - New dream.rs module: - DreamPhase enum (6 phases) with all_in_order() + from_str_opt() - DreamReport with per-phase results, totals, dry_run flag, duration - PhaseResult / PhaseStatus types - Uteke::dream(namespace, dry_run, phases) orchestrator - Lint: count memories with unknown memory_type values - Backlinks: rebuild_backlinks() (#350) - Dedup: consolidate(threshold=0.92) - Orphans: inline SQL count (degrades gracefully if #351 not merged) - Compact: prune(TTL=30d) - Verify: existing verify() (db/index consistency) CLI (uteke-cli): - New 'uteke dream [--phases P1,P2] [--skip P3] [--dry-run] [--quiet]' - Exits non-zero on errors (cron-friendly) - --quiet shows only warnings/errors Tests (+4 new): phase roundtrip, phase order, dry-run, phase filter Closes #353 * fix(#353): don't abort dream on phase error + lint via SQL CodeCora #390 flagged two issues: 1. dream() propagated the first phase error via '?', aborting the whole pipeline. Fix: wrap each phase in a match — failures are recorded as a PhaseStatus::Error result but subsequent phases still run. 2. phase_lint loaded every memory into RAM via load_all() just to count bad types. Fix: use SQL COUNT with NOT IN (...) — O(1) memory, no deserialization overhead. * fix(#353): error on invalid phase + namespace-aware orphans + propagate SQL errors CodeCora #390 found three issues: 1. Invalid --phases names were silently dropped via filter_map, causing 'uteke dream --phases bogus' to run ALL phases. Fix: return error listing valid phase names. 2. phase_orphans ignored the namespace parameter (_namespace). Running 'uteke dream --namespace X' counted orphans globally. Fix: add 'AND m.namespace = ?2' when namespace is provided. 3. Multiple SQL queries used unwrap_or(0) which masked database errors as 'clean' results. Fix: propagate via map_err → Error::db. Pipeline catch loop converts to PhaseStatus::Error without aborting. * fix(#353): namespace-aware lint + exclude deprecated in orphan count CodeCora #390 r2: 1. phase_lint ignored namespace, running global COUNT regardless of the --namespace flag. Fix: add WHERE namespace = ?1 when namespace is provided. 2. phase_orphans SQL didn't exclude deprecated memories, matching the same bug fixed in #351. Fix: add AND m.deprecated = 0 to both namespace and global queries. * fix(#353): dedup phase returns Warning status when duplicates found CodeCora #390 r3: phase_dedup set warnings=1 when duplicates were found but couldn't be merged (dry-run or threshold too high), yet status remained Ok. Inconsistent with phase_lint and phase_orphans which return Warning status for the same pattern. Fix: set PhaseStatus::Warning when has_warnings is true. * docs(#353): document namespace scope and dry-run semantics CodeCora #390 r3 raised two architectural concerns: 1. Backlinks phase is global, not namespace-scoped. This is by design — rebuild_backlinks() operates on the edge graph which is not namespace- partitioned. Documented in the dream() doc comment. 2. Orphan detection in dry-run doesn't reflect projected post-maintenance state. This is by design — dry-run reports against current state. Documented in the dream() doc comment. No code changes — documentation only. * fix(#353): canonical phase order + dedup CodeCora #390 r4: if user passed --phases verify,lint,backlinks, phases executed in that order instead of dependency order. verify before lint makes no sense and could produce misleading results. Fix: sort selected phases by canonical position in all_in_order(), and dedup duplicates. Added 2 tests: reversed order, and duplicate phases. * fix(#353): compact phase shows 'would be pruned' in dry-run CodeCora #390 r4: phase_compact always printed 'memories pruned' even in dry-run mode, implying destructive changes already happened. Fix: print 'would be pruned' when dry_run is true.
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.
Closes #353. Single command that runs all 6 maintenance phases in dependency order (lint → backlinks → dedup → orphans → compact → verify). 4 new tests, clippy + fmt clean.