Skip to content

feat(cli): add vault maintenance automation commands#20

Merged
epicsagas merged 8 commits into
mainfrom
worktree-orbit-maintenance-automation
May 23, 2026
Merged

feat(cli): add vault maintenance automation commands#20
epicsagas merged 8 commits into
mainfrom
worktree-orbit-maintenance-automation

Conversation

@epicsagas

Copy link
Copy Markdown
Owner

Summary

Implements MAINTENANCE.md vault maintenance automation as 4 new CLI commands for obsidian-forge.

Spec

  • ID: SPEC-20260522-maintenance-automation
  • Pipeline: PIPELINE-20260522133040
  • Requirements: R1 (check-tags), R2 (check-links), R3 (normalize-frontmatter), R4 (orphans filters)

Changes

  • New: src/check_tags.rs -- of check-tags --fix --scope vault
  • New: src/check_links.rs -- of check-links --fix
  • New: src/frontmatter.rs -- of normalize-frontmatter --dry-run
  • Extended: src/graph/orphans.rs -- of graph orphans --exclude-seeded --min-importance N
  • Modified: src/main.rs -- 3 new CLI subcommands + orphans flag extensions

Acceptance Criteria Verified

  • AC1: check-tags --dry-run reports missing tags, --fix auto-adds
  • AC2: check-links detects broken links, --fix renames files
  • AC3: normalize-frontmatter --dry-run detects malforms, runs without flag fixes
  • AC4: graph orphans --exclude-seeded --min-importance 100 filters correctly
  • AC5: 30 new unit tests (128 total), all passing
  • AC6: cargo clippy -D warnings + cargo fmt pass

Test Plan

  • Unit tests pass (128/128)
  • cargo clippy -- -D warnings clean
  • cargo fmt clean
  • Release build succeeds

epicsagas added 5 commits May 22, 2026 22:48
Implements vault maintenance automation from MAINTENANCE.md:
- of check-tags --fix --scope vault: scans PRIMARY docs for missing
  layer/raw, type/{doc-type}, and project tags; auto-injects with --fix
- of check-links --fix: detects broken wikilinks, auto-fixes filename
  mismatches (spaces<->hyphens) and .txt->.md extensions
- of normalize-frontmatter --dry-run: detects YAML malformations
  (closing brace, broken list, empty tags, missing frontmatter)
- of graph orphans --exclude-seeded --min-importance N: filters seeded
  paths and files below minimum character threshold
… naming

- Extract shared EXCLUDED_DIRS, frontmatter_re(), doc_type_tag() into
  new vault_utils.rs module (was duplicated across 3 modules)
- Fix fix_broken_yaml_list() which silently skipped instead of replacing
  bare tags: with tags: []
- Remove module-level #![allow(dead_code)] from check_links.rs
- Change check-tags --scope from string to TagScope enum
- Rename graph orphans --min-importance to --min-chars for clarity
- Unify normalize-frontmatter from --dry-run to --fix for CLI consistency
- Add reverse index (BTreeMap) for O(1) wikilink target resolution
- Eliminate double txt_stems linear search in check_links
- Remove unused PRIMARY_FILES/SUPPLEMENTARY_DIRS constants
- Track per-issue fixed status instead of batch marking all issues
- Simplify orphans regex: [\s\S]*? → .*? with (?s) flag
- Add frontmatter_re() regex safety comment
…p tests

- Replace trim_end_matches(".md") with strip_suffix(".md") to prevent
  incorrect truncation (e.g. "README.md" → "READ")
- Add collision guard for .txt→.md rename when .md already exists
- Fix /seeded/ path matching to handle root-level and backslash paths
- Migrate check_links tests from manual temp dirs to tempfile::TempDir
- Fix collect_txt_stems doc comment (set → map)
- Add regression test for strip_suffix behavior
- Add stem collision warning in build_stem_index (check_links.rs)
- Extract check_missing_tag and apply_tag_fixes helpers (check_tags.rs)
- Decompose check_links into handle_extension_mismatch + handle_filename_mismatch
- Replace BrokenLink.issue String with LinkIssue enum for type safety
- Add fs::metadata pre-filter in detect_orphans before reading content
@epicsagas

Copy link
Copy Markdown
Owner Author

PR 리뷰 피드백 반영 (commit 024b08a)

PR 리뷰에서 지적된 이슈 1~5를 모두 수정했습니다.

이슈 수정 내용 파일
#1 build_stem_index에서 duplicate short stem 충돌 시 tracing::warn 로그 추가 check_links.rs
#2 check_missing_tag, apply_tag_fixes 공유 헬퍼 추출로 ~100줄 중복 제거 check_tags.rs
#3 check_linkshandle_extension_mismatch + handle_filename_mismatch로 분해 (메인 함수 86줄) check_links.rs
#4 BrokenLink.issue: StringLinkIssue enum으로 타입 안전성 확보 check_links.rs
#5 detect_orphans에서 fs::metadata로 파일 크기 사전 필터링 후에만 read_to_string 호출 orphans.rs

검증: 131/131 테스트 통과, clippy clean, fmt clean

epicsagas and others added 3 commits May 23, 2026 18:39
- Extract check_and_fix_tags + apply_no_frontmatter_fixes in check_tags.rs,
  eliminating duplicated tag-check/fix-marking logic between scan_project_docs
  and scan_resource_docs (R2)
- Extract check_file_links helper from check_links loop body, reducing
  check_links from 85 to 43 lines (R3)
- Guard fs::rename in handle_filename_mismatch with target existence
  check to prevent silent data loss
- Unify scan_project_docs no-frontmatter handling with shared
  check_missing_tag + apply_no_frontmatter_fixes pattern
- Replace info! with warn! on failure paths in check_links
- Add test for rename content preservation
- Add test for project doc no-frontmatter fix

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@epicsagas epicsagas merged commit 2fcde67 into main May 23, 2026
10 checks passed
@epicsagas epicsagas deleted the worktree-orbit-maintenance-automation branch May 23, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant