Skip to content

refactor(src): migrate 3 small command files to AppError#78

Merged
saagpatel merged 1 commit into
masterfrom
codex/refactor/app-error-small-files
Apr 22, 2026
Merged

refactor(src): migrate 3 small command files to AppError#78
saagpatel merged 1 commit into
masterfrom
codex/refactor/app-error-small-files

Conversation

@saagpatel
Copy link
Copy Markdown
Owner

Summary

Continuation of ADR 0012 migration. Three small self-contained files, bundled to keep cadence brisk without bloating PRs.

Migrated

  • app_core_commands.rs (4 commands): check_fts5_enabled, check_db_integrity, get_vector_consent, set_vector_consent. All DB-backed one-liners → AppError::db_lock_failed / db_not_initialized / db_query_failed.
  • pilot_feedback.rs (6 commands + require_pilot_logging_enabled helper): policy-refusal now carries SECURITY_PERMISSION_DENIED; a small feedback_err helper routes the three analytics commands through DB_QUERY_FAILED; export_pilot_data routes validation outcomes through matched constructors (path_traversal, invalid_path, sensitive_path).
  • decision_tree_runtime.rs (2 impls) + its 2 Tauri wrappers (list_decision_trees / get_decision_tree) in model_commands.rs. Migrated together to avoid bridge calls.

Progress

AppError-typed signatures: 16 → 23 by the ADR 0012 methodology grep (under-counts nested-generic return types, so real progress is higher).

Remaining runway per ADR 0012: 10 command files still on Result<T, String>. Next sensible bites: startup_commands (3 cmds), backup.rs (4), search_api.rs (7).

Test plan

  • cargo check --all-targets — clean
  • cargo test --lib — 311 pass, 1 ignored (pre-existing)
  • CI backend-tests green
  • CI build green
  • Smoke: Settings → Pilot logging refusal message still shows env-var hint; FTS5 / integrity check still surface useful errors on a bad DB

🤖 Generated with Claude Code

Continue the ADR 0012 migration. Three small self-contained files land
together to keep the cadence brisk without bloating the PR:

1. app_core_commands.rs (4 commands: check_fts5_enabled,
   check_db_integrity, get_vector_consent, set_vector_consent) — all
   database-backed one-liners, now using AppError::db_lock_failed,
   db_not_initialized, and db_query_failed.

2. pilot_feedback.rs (6 commands + require_pilot_logging_enabled
   helper): logging-policy refusals now carry
   SECURITY_PERMISSION_DENIED with retention of the env-var hint.
   Added a small feedback_err helper so the three analytics commands
   surface DB_QUERY_FAILED with detail, and export_pilot_data routes
   validation outcomes through the matching AppError constructors
   (path_traversal, invalid_path, sensitive_path).

3. decision_tree_runtime.rs (2 impls, 2 call sites in
   model_commands.rs). The two Tauri wrappers list_decision_trees /
   get_decision_tree in model_commands.rs migrate alongside so no
   bridge calls are needed.

Verified: cargo check --all-targets clean, cargo test --lib
311 passed, 1 ignored (unchanged). AppError-typed signatures grew from
16 → 23 by the ADR methodology grep.

Remaining runway (per ADR 0012): 10 command files on Result<T, String>.
Next bites: startup_commands (3), backup.rs (4), search_api.rs (7).
@saagpatel saagpatel merged commit 9d8f959 into master Apr 22, 2026
19 of 23 checks passed
@saagpatel saagpatel deleted the codex/refactor/app-error-small-files branch April 22, 2026 11:48
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.

2 participants