Project: Collect Files
Version: 1.0
Status: Draft
This document defines every configurable aspect of the Collect Files engine.
Configuration determines how the engine behaves.
Configuration never determines what the engine is.
Business logic must remain independent from configuration.
Configuration must satisfy the following principles.
- Explicit
- Immutable during execution
- Strongly typed
- Validated before execution
- Platform-independent
- Deterministic
- Human-readable
- Easy to serialize
Configuration may originate from:
Priority 1
Command-line arguments
Priority 2
Configuration file (future)
Priority 3
Environment variables (future)
Priority 4
Built-in defaults
The highest-priority source always overrides lower priorities.
The Job dataclass is the single source of truth for runtime configuration.
Every pipeline stage receives the same immutable Job instance.
No module may modify it.
Field
source: PathRequirements
- must exist
- must be readable
- must be a directory
- must not be empty string
Field
destination: PathRequirements
- may not exist
- parent directory must be writable
- may equal source only if explicitly supported
Destination creation belongs to the execution stage.
Field
extensions: frozenset[str]Normalization Rules
- lowercase
- unique
- leading dot required
Examples
Valid
.png
.jpg
.pdf
Invalid
PNG
Pdf
jpeg
(after normalization these become valid)
Field
operation: OperationSupported values
MOVE
COPY
Exactly one operation must be selected.
Field
sort_mode: SortModeSupported values
EXIF
CREATED
MODIFIED
NAME
SIZE
Sorting must always be deterministic.
Field
files_per_folder: intRequirements
> 0
Recommended
100
250
500
1000
Field
dry_run: boolBehavior
All planning stages execute.
Filesystem mutations are skipped.
Field
follow_symlinks: boolBehavior
False
Ignore symbolic links.
True
Traverse symbolic links.
Validation occurs before pipeline execution.
Validation failures are fatal.
Rules
Source exists.
Source is directory.
Extensions not empty.
Files per folder > 0.
Operation specified.
Sort mode specified.
Job internally consistent.
Examples
files_per_folder = 0
Rejected.
extensions = {}
Rejected.
source = missing_directory
Rejected.
operation = None
Rejected.
Execution must never begin with an invalid Job.
Recommended defaults
Operation
MOVE
Sort Mode
EXIF
Files per Folder
100
Dry Run
False
Follow Symlinks
False
Defaults may evolve between versions.
Configuration differs from internal constants.
Configuration is user-controlled.
Constants are developer-controlled.
Examples of constants
DEFAULT_BATCH_SIZE
DEFAULT_LOG_LEVEL
DEFAULT_FOLDER_PATTERN
SUPPORTED_TIMESTAMP_FIELDSConstants belong in:
core/constants.py
not inside config.py.
Reserved names
COLLECT_FILES_LOG_LEVEL
COLLECT_FILES_CACHE
COLLECT_FILES_CONFIG
COLLECT_FILES_TEMP
Environment variables must never override explicit CLI arguments.
Preferred format
TOML
Example
[source]
path="/data"
[destination]
path="/archive"
[execution]
operation="move"
sort="exif"
files_per_folder=100
dry_run=falseYAML may be supported later.
JSON is optional.
Example
collect-files \
--source ~/Pictures \
--destination ~/Archive \
--extensions png jpg \
--operation move \
--sort exif \
--batch-size 100maps directly to
Job(...)CLI parsing must never leak into business modules.
After validation,
Job becomes immutable.
Pipeline stages may read configuration.
They may never modify it.
This guarantees deterministic execution.
CLI
↓
Parse
↓
Normalize
↓
Validate
↓
Create Job
↓
Freeze
↓
Execute Engine
Job creation occurs exactly once.
Fatal examples
Invalid directory.
Invalid extension.
Invalid enum.
Negative batch size.
Unknown sort mode.
Unknown operation.
Errors should clearly explain:
- what failed
- expected value
- received value
- suggested correction
Reserved options
Maximum recursion depth.
Ignore hidden files.
Include hidden files.
Minimum file size.
Maximum file size.
Filename filters.
Regex filters.
Timestamp priority list.
Hash duplicate detection.
Plugin configuration.
These additions must preserve backward compatibility.
Configuration must always satisfy:
Exactly one Job.
Immutable during execution.
Validated before pipeline start.
Platform-independent.
Serializable.
Strongly typed.
Independent of CLI implementation.
Free from business logic.