Dev-Team Session — FileCleaner v1.0.0 Architecture & Scope Alignment¶
Date: 2026-11-20
Topic: FileCleaner v1.0.0 Architecture, Safety Invariants, Cross-Platform Probes & Scope Alignment
Participants: Product Manager (PM), Principal Architect (Architect), Senior Rust Developer (Developer), Quality Assurance Lead (QA), Swarm Coordinator
Normative Downstream Artifacts: docs/en/SPECIFICATIONS.md · docs/fr/SPECIFICATIONS.md
1. Purpose of Session¶
Align the multi-disciplinary engineering team before implementation waves begin on FileCleaner (filecleaner v1.0.0, pure-Rust retention, backup safety guardrail, in-use detection, lifecycle action pipeline, and daemon engine). Because FileCleaner executes destructive and transformative filesystem operations (Delete, Trash, Move, CopyTruncate, Compress, RenameByDate), every ambiguity in rule precedence, cross-platform lock semantics, dry-run parity, or hook failure handling constitutes a direct data-loss risk.
2. Persona Assessments¶
2.1 Product Manager (PM)¶
- First Reaction: Ambitious v1.0.0 scope bundling retention policies, backup dead-man's-switches, 5+ layer in-use file detection, logrotate-style transforms, external hook scripts, and a cross-platform daemon; user trust, dry-run predictability, and clear precedence rules matter most.
- Key Concerns:
- Scope Density: Delivering all subsystems with bilingual EN/FR documentation and \(\ge 90\%\) line coverage simultaneously risks delivery drag without modularization.
- Precedence & Auditability: Users need deterministic, easy-to-explain outcomes when
max_files,max_age,max_total_size,min_keep_files, and staleness gates interact, backed by strict dry-run guarantees and append-only audit logs. - Cross-Platform Lock Divergence: Ensuring consistent user expectations across Linux, macOS, and Windows despite differing OS file-locking semantics.
- First Action: Define explicit user personas, rule-evaluation precedence, dry-run parity guarantees, and stable CLI exit-code contracts.
- Open Question Raised: What could move to v1.1 if cutting roughly a third of initial scope?
2.2 Principal Architect (Architect)¶
- First Reaction: Destructive data-lifecycle engine where a single precedence flaw or TOCTOU race condition can wipe active files or sole remaining backups; demands strict fail-closed architectural boundaries from day one.
- Key Concerns:
- Deterministic Pipeline &
CopyTruncateRace: ThePlan -> Executepipeline must produce identical decisions in dry-run (plan/--dry-run) and live execution;CopyTruncatecarries an inherent write-vs-truncate tail window. - Cross-OS Divergence &
EXDEV: Windows exclusive share-mode locks vs Unixflockvs permission-gated Linux/proc/*/fd; non-atomic cross-filesystem moves (EXDEV); differing daemon service managers (systemd,launchd, Windows Task Scheduler). - Testability: Injectable traits (
Fs,Clock,LockProbe/InUseProbe,HookRunner) are mandatory to achieve \(\ge 90\%\) deterministic line coverage. - First Action: Lock the
Scan -> InUseProbe -> BackupGuard -> RetentionEval -> PreHook -> Executepipeline order, symlink non-traversal defaults, and explicit error-handling policies. - Open Questions Raised: When
/procreturnsEACCES, should FileCleaner fail-closed and skip? ShouldCopyTruncaterequire explicit configuration opt-in?
2.3 Senior Rust Developer (Developer)¶
- First Reaction: Retention selection math is straightforward in Rust; cross-platform lock detection, race-free transforms (
CopyTruncate, streaming compression, cross-FS SHA-256 verified moves), and backup safety gates carry the real engineering complexity. - Key Concerns:
- OS Probe & Growth-Window Mechanics: Reconciling Windows
share_mode(0), POSIXflock(LOCK_EX | LOCK_NB), Linux/proc/*/fdinode matching,CopyTruncateEOF-to-truncate windows, and batching the two-point stability window to avoid sequential sleep latency. - Idempotent Execution &
EXDEVSafety: Deterministic ordering, crash-safe.fc-tmpstaging, symlink non-traversal, and fail-closed error handling. - Pure-Rust Portability: Zero C
-syscrates (flate2withminiz_oxide,lz4_flex,brotli,zipwith pure-Rustdeflate) to support 9-target cross-compilation cleanly, plus trait-abstracted OS calls. - First Action: Implement the
discover -> lock-probe -> safety-gate -> transform/prunestate machine, lock pure-Rust compression codecs, and ship--dry-run/planparity prior to the daemon loop. - Open Question Raised: Do transformed outputs (renamed or compressed files) remaining in the same monitored directory count toward
min_keep_filesandrequire_newer_within?
2.4 Quality Assurance Lead (QA)¶
- First Reaction: Destructive retention combined with cross-platform lock probes,
CopyTruncate, and external veto hooks creates high failure-surface risk; achieving \(\ge 90\%\) coverage across Linux, macOS, Windows, and ARM targets requires deterministic fixtures. - Key Concerns:
- Lock-Detection Gaps & TOCTOU Races:
/proc/*/fdis Linux-only and privilege-scoped; Windows and POSIX enforce locking differently; files can transition between idle and active between scan and unlink. - Edge-Case Traps: Trailing-byte loss during
CopyTruncate, symlinks, hardlinks, sparse files, zero-byte or truncated backup stubs satisfying naive file-count floors, and hung pre-delete veto scripts. - Cross-OS Verification Parity: Deterministic
mtime/permission assertions, failure-injection tests (checksum mismatch, simulatedEXDEV, hook timeout), and strict--dry-runvs live parity. - First Action: Build a destructive-safety test matrix covering dry-run/live parity, active-writer fixtures per probe strategy, staleness and zero-byte backup traps, and hook timeout termination.
- Open Question Raised: When constraints conflict (e.g.,
max_total_sizeormax_filesremains exceeded becausemin_keep_filesor in-use locks block eviction), what are the exact rule outcome, exit code, and daemon alert contract?
3. Coordinator Synthesis & Architectural Resolutions¶
The following resolutions are normative and directly govern docs/en/SPECIFICATIONS.md, docs/fr/SPECIFICATIONS.md, and all v1.0.0 implementation and verification waves.
Resolution 1 — Lock Divergence, /proc EACCES, and CopyTruncate Opt-In (4/4 Consensus)¶
- Fail-Closed Active Probes: Any active-writer trigger across sidecars, Unix
flock(LOCK_EX | LOCK_NB), Linux/proc/*/fd, Windowsshare_mode(0),min_idle_age, or the two-point(size, mtime)stability window unconditionally places the file in \(S_{\text{busy}}\), guaranteeing \(E \cap S_{\text{busy}} = \emptyset\). - Linux
/proc/*/fdPrivilege Boundary: When non-owned PID directories under/proc/<pid>/fdreturnEACCESorEPERM, FileCleaner logs a diagnostic telemetry note (and does not treat unprivilegedEACCESon unrelated system processes as a blanket lock on every file, becauseflock,min_idle_age, sidecars, and stability window remain active); however, any direct probe failure on the target candidate itself (e.g., unreadable/un-stat-able candidate or failingflockwithEWOULDBLOCK/EACCES) fails closed and places the file in \(S_{\text{busy}}\). - Injectable Test Traits:
Clock,LockProbe/InUseProbe,FsOps, andHookRunnerMUST be abstracted behind traits so unit tests deterministically simulate time progression, cross-FSEXDEV, lock contention, and hook timeouts. - Explicit
CopyTruncateOpt-In:ActionStep::CopyTruncateMUST be explicitly opted into by the user inRuleConfig.actions(inittemplates never enable it by default). Specifications andvalidatewarnings MUST explicitly document the inherent copy-to-truncate tail-byte race window for active append writers.
Resolution 2 — Strict Pipeline Precedence, Dry-Run Parity & Constrained Conflict Contract (4/4 Consensus)¶
- Mandatory Pipeline Order: Every rule sweep MUST execute phases in strict order:
Scan(discovery, symlink non-traversal default, glob/regex include-exclude, timestamp resolution & deterministic ordering)InUseProbe(partitioning \(S_{\text{busy}}\))BackupGuard(evaluating \(\mathcal{F}_{\text{valid}} = \{f \in \mathcal{F} \mid \text{size}(f) \ge B_{\min}\}\), staleness freeze, and protected floor \(P_{\text{floor}}\))RetentionEval(computing eviction set \(E \subseteq \mathcal{F} \setminus (P_{\text{floor}} \cup S_{\text{busy}})\) and deterministicSweepPlan)PreHook(synchronous external check per candidate in \(E\), skipped during dry-run unlessrun_in_dry_run = true)Execute(orderedActionSteptransformations/deletions, or zero-mutationWouldActemission inplan/--dry-run)- Strict Dry-Run / Live Parity:
filecleaner planandfilecleaner run --dry-runexecute phases 1–4 identically to livefilecleaner run, yielding an identicalSweepPlanwithout any filesystem mutation. - Conflict Resolution (
RuleOutcome::Constrained): Whenmax_total_sizeormax_filesremains exceeded after selecting all eligible evictions becauseBackupGuard(\(P_{\text{floor}}\)) and/orInUseProbe(\(S_{\text{busy}}\)) prevented further deletions: - Safety invariants (
BackupGuardandInUseProbe) ALWAYS win. - The rule finishes with
RuleOutcome::Constrained. - Excess diagnostics (
remaining_files,target_max_files,remaining_bytes,target_max_total_size,protected_floor_count,busy_skipped_count) are recorded in the JSONL audit log, the daemon live JSON state file (constrained_rules), andplan/runoutput. - Default process exit code remains
0so non-fatal safety protections do not trigger false cron failures; passing--strict-constraintselevatesConstrainedto exit code3(matching strict safety gate enforcement alongside--fail-on-freeze). - Transformed Outputs & Backup Counting: Files produced by in-place transforms (
RenameByDate,Compress) that remain inside the monitoredrule.path, continue to match the rule's include/exclude filters, and have \(\text{size}(f) \ge \text{min\_valid\_backup\_bytes}\) continue to count towardmin_keep_filesand staleness (t_max). Files relocated outsiderule.pathviaMoveorTrashleave \(\mathcal{F}\) and no longer count toward that rule's monitored floor.
Resolution 3 — Pure-Rust Portability & \(\ge 90\%\) Line Coverage (3/4 Consensus)¶
- Zero C
-sysCrates: Compression and hashing MUST rely exclusively on pure-Rust crates (flate2defaultminiz_oxide,lz4_flex,brotli,zipwithdefault-features = false+deflate,sha2) to guarantee seamless 9-target cross-compilation includingmusland ARM64. - CI Coverage Gate:
cargo llvm-cov --fail-under-lines 90enforced across the workspace.
Resolution 4 — Full v1.0.0 Scope Retained via Parallel Swarm Execution¶
- PM Cutline Proposal vs User Mandate: Although the PM identified
daemonmode and secondary codecs (lz4,brotli,zip) as candidates for deferral to v1.1, the Coordinator resolved to retain the full v1.0.0 scope (RenameByDate,Compressacross all 4 codecs,Movewith SHA-256 verification,CopyTruncate,Trash,Delete,PreHook, anddaemonwithinterval/notify/hybridmodes and OS service templates) by modularizing implementation across parallel swarm workers followed by a dedicated verification pass.
4. Actionable Traceability Matrix¶
| Resolution ID | Owner Module(s) | Specification Section (EN & FR) |
|---|---|---|
RES-01 Fail-closed probes & /proc EACCES |
src/in_use.rs, src/traits.rs |
Section 5 (Multi-Probe In-Use Matrix) & Section 9.4 |
RES-02 Strict 6-phase pipeline & DryRun parity |
src/planner.rs, src/engine.rs |
Section 1.2, Section 4, Section 7.3 |
RES-03 RuleOutcome::Constrained & exit codes |
src/planner.rs, src/cli.rs, src/audit.rs, src/daemon.rs |
Section 4.6, Section 8.3, Section 9.2, Section 9.3 |
| RES-04 Transformed outputs in monitored directory | src/scanner.rs, src/retention.rs, src/actions.rs |
Section 4.2, Section 7.1, Section 7.2 |
RES-05 Explicit CopyTruncate opt-in & race bounds |
src/config.rs, src/actions.rs |
Section 2.5, Section 7.2.4 |
RES-06 Pure-Rust stack & \(\ge 90\%\) llvm-cov |
Cargo.toml, tests/ |
Section 1.4, Section 7.2.2 |