Skip to content

fix(project): project_dirs honours soft-delete and archive; expose project archive/unarchive (#768) - #943

Merged
getappz merged 1 commit into
masterfrom
task/768-project-dirs-survives-project-soft-delet
Oct 21, 2026
Merged

getappz merged 1 commit into
masterfrom
task/768-project-dirs-survives-project-soft-delet

Conversation

@getappz

@getappz getappz commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

agentflare daemon logs was flooded (3,100+ lines) with project <id> is registered at Temp\.tmpXXXX but that folder does not exist — 29 soft-deleted trial projects × every discovery tick. project_dir::list was a bare SELECT over project_dirs: soft-delete never removed the row (only a hard delete cascades) and projects.archived_at was never read anywhere, so archiving had no effect on dispatch.

  • project_dir::list joins projects and skips deleted_at/archived_at rows (used by the discovery tick and review sweep). list_all keeps the raw table for folder/item → project lookups (flare doctor, item controls), which must keep working inside an archived checkout.
  • project::delete also removes the project_dirs row, in the same transaction.
  • project::archive / unarchive in the backend, exposed as agentflare project archive|unarchive <name|id> and MCP project action=archive|unarchive (project = name or UUID, default: this repo's project). Archive is idempotent and keeps the original stamp. Unarchive needs no re-registration since the dir row is left in place.
  • The missing-folder line is logged once per project per daemon session, and again only after the folder came back and went missing a second time.
  • agentflare project list now includes archived_at.

Test plan

  • cargo fmt --all --check — clean
  • cargo clippy --locked --workspace --all-targets --all-features -- -D warnings -A unsafe_code -A clippy::pedantic — clean
  • cargo test -p agentflare-backend project — 22 passed (new: list hides archived + soft-deleted rows while list_all keeps them; soft-delete removes the dir row; archive idempotent / unarchive clears / archive on deleted → NotFound)
  • cargo test --bin agentflare -- project_tests project_rejects multi_project_sweep project_resolution — passed (new: discovery tick skips archived and soft-deleted projects; missing-folder note fires once until the folder is back; MCP archive by name hides the folder from the sweep list, project stays listed, unarchive by UUID restores it, unknown project → invalid_params)
  • CI: all checks green including both OS builds (full cargo test --workspace ran there; locally it exceeded the 10-minute foreground budget on Windows)

Notes for reviewers

  • Risk areas: every caller of project_dir::list now sees only active projects. The two callers that map a folder or item back to its project (cli/git.rs repo-root lookup, job_controls::mcp_for_item) were switched to list_all so an archived project's checkout and item controls keep resolving.
  • Backwards compatibility: no schema change (archived_at already existed). Existing stale project_dirs rows of soft-deleted projects are filtered out by the join; the 29 from the incident were already removed by hand. The project MCP request gains an optional project field with #[serde(default)], so existing info/list calls are unaffected.
  • Not covered: review sweep (collect_review_batches) relies on the same list filter but has no dedicated archived-project test; the discovery-tick test covers the shared path.

Agentflare item #768.

…oject archive/unarchive (#768)

`project_dir::list` was a bare SELECT, so a soft-deleted project's folder
row (only a hard delete cascades) and an archived project's (nothing read
`archived_at`) were swept every discovery tick. 29 stale Temp\.tmp*
registrations flooded `agentflare daemon logs` with "folder does not
exist" every tick.

- `project_dir::list` joins `projects` and skips deleted/archived ones;
  `list_all` keeps the raw table for folder/item -> project lookups
  (`flare doctor`, item controls).
- `project::delete` also removes the `project_dirs` row, in one transaction.
- `project::archive` / `unarchive`, exposed as `agentflare project
  archive|unarchive <name|id>` and MCP `project action=archive|unarchive`
  (`project` = name or UUID, default: this repo's project). Unarchive needs
  no re-registration.
- The missing-folder line is logged once per project per daemon session,
  and again only after the folder has come back and gone missing again.

Agentflare-Agent: claude-code
Agentflare-Branch: task/768-project-dirs-survives-project-soft-delet
Agentflare-Item: 768
Agentflare-Session: e4957d62-33fe-4989-9971-ea9f52c41af2
@getappz

getappz commented Oct 21, 2026

Copy link
Copy Markdown
Owner Author

Tracking this PR for automated review (flared:c997d745ae66).

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: getappz/agentflare/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 1e458b8f-542d-4851-a05c-3213e6b3fc24
📥 Commits

Reviewing files that changed from the base of the PR and between f4068e6 and e0d44d0.

📒 Files selected for processing: 16
  • crates/agentflare-backend/src/project.rs
  • crates/agentflare-backend/src/project_dir.rs
  • src/cli/git.rs
  • src/cli/project.rs
  • src/job_controls.rs
  • src/mcp_server.rs
  • src/mcp_server/chat.rs
  • src/mcp_server/pm.rs
  • src/mcp_server/tests/action_tests.rs
  • src/mcp_server/tests/asset_tests.rs
  • src/mcp_server/tests/item_tests_reporting.rs
  • src/mcp_server/tests/mod.rs
  • src/mcp_server/tests/project_tests.rs
  • src/mcp_server/types.rs
  • src/supervisor.rs
  • src/supervisor/tests/multi_project_sweep_tests.rs

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

📝 Walkthrough

Projects can now be archived and unarchived through the backend, MCP project actions, and CLI. Directory listing and supervisor discovery exclude archived projects, while repository and item lookups can still resolve their registered folders. Project deletion removes its directory entry. Missing-folder warnings are suppressed until a folder returns.

Changes: Project lifecycle and archived-project handling

Layer / File(s) Summary
Project state and directory visibility
crates/agentflare-backend/src/project.rs, crates/agentflare-backend/src/project_dir.rs
Project deletion removes its directory entry in the same transaction. Archive and unarchive operations update archived_at and emit events. Directory listing excludes archived and deleted projects; list_all retains registered folders.
MCP and CLI archive actions
src/mcp_server/types.rs, src/mcp_server.rs, src/cli/project.rs, src/mcp_server/tests/*
Project requests accept an optional project target and the archive and unarchive actions. MCP and CLI route these actions to the backend. Tests cover archive state, name and UUID targets, list visibility, and invalid targets.
Archived-project lookup and discovery
src/cli/git.rs, src/job_controls.rs, src/supervisor.rs, src/supervisor/tests/multi_project_sweep_tests.rs
Repository and item lookups use all registered project directories. Supervisor discovery skips archived and deleted projects while continuing to dispatch active projects.

Missing-folder warning suppression

Layer / File(s) Summary
Missing-folder warning lifecycle
src/supervisor.rs, src/supervisor/tests/multi_project_sweep_tests.rs
Supervisor tracking suppresses repeated missing-folder warnings and resets when a folder returns. Tests cover suppression and logging after recovery.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant MCPProject as MCP project_inner
  participant ProjectBackend as Project backend
  participant Database
  participant ProjectEvents
  Caller->>MCPProject: Send archive or unarchive action and target
  MCPProject->>ProjectBackend: Run operation for resolved project
  ProjectBackend->>Database: Update archived_at
  ProjectBackend->>ProjectEvents: Emit archive or unarchive event
  ProjectBackend-->>MCPProject: Return updated project
  MCPProject-->>Caller: Return project result
Loading
Merge Risk: ⚪ Minimal · up to e0d44

No identified issue blocks merging the project archiving changes after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly summarizes the main changes: project directory handling for soft-deleted and archived projects, plus archive and unarchive support.
Docstring Coverage Passed Docstring coverage is 82.35% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 16 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The pull request description follows the required template. It includes a detailed Summary, a completed Test plan with commands and results, and Notes for reviewers covering risk areas and backwards c…
Full details: Description check

Explanation

The pull request description follows the required template. It includes a detailed Summary, a completed Test plan with commands and results, and Notes for reviewers covering risk areas and backwards compatibility.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@getappz
getappz merged commit 2ac2f56 into master Oct 21, 2026
21 checks passed
@getappz
getappz deleted the task/768-project-dirs-survives-project-soft-delet branch October 21, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant