# 005.0-DEV-CONFIGURABLE-AGE-THRESHOLD: Configurable Age Threshold

## Release Goal

**Release 0.4: Configurable Thresholds**

Allow users to customize the maturity age threshold instead of the hardcoded 7-day minimum. This enables teams to apply stricter or more relaxed maturity rules based on their risk tolerance and release cadence.

## How This Story Contributes

Adds flexibility to the maturity filtering by allowing users to specify their own age threshold via CLI flag or configuration file. Different projects have different risk profiles - some may want 14 or 30 day maturity, others may accept 3 days.

## User Story

**Format**: So that I can apply maturity rules that match my project's risk tolerance, as a developer, I want to configure the minimum age threshold for package updates instead of using the hardcoded 7-day default.

**INVEST Criteria Compliance**:

- **Independent**: Builds on existing maturity filtering, doesn't depend on other enhancement stories
- **Negotiable**: Implementation details (CLI flag name, config file format) can be refined
- **Valuable**: Enables customization for different project risk profiles
- **Estimable**: Clear scope - add configuration option and apply it
- **Small**: Single iteration to add configuration support
- **Testable**: Can verify custom thresholds are applied correctly

## Acceptance Criteria

- [ ] **CLI Flag**: Accepts `--min-age=<days>` flag to set custom threshold
- [ ] **Config File Support**: Reads `minAge` from `.dry-aged-deps.json` config file if present
- [ ] **CLI Override**: CLI flag overrides config file value when both present
- [ ] **Default Behavior**: Uses 7 days when no config or flag provided (backward compatible)
- [ ] **Validation**: Rejects invalid values (negative numbers, non-numeric input)
- [ ] **Help Documentation**: `--help` shows the `--min-age` option with description
- [ ] **Output Message**: Indicates which threshold is being applied in output

## Requirements (Current Implementation or To Be Implemented)

- **REQ-CLI-FLAG**: Support `--min-age=<days>` command-line flag
- **REQ-CONFIG-FILE**: Support `.dry-aged-deps.json` config file in project root
- **REQ-CONFIG-SCHEMA**: Config file JSON schema: `{ "minAge": number }`
- **REQ-VALIDATION**: Validate age is positive integer between 1 and 365
- **REQ-DEFAULT-VALUE**: Default to 7 days if not configured
- **REQ-PRECEDENCE**: CLI flag > config file > default value
- **REQ-ERROR-HANDLING**: Clear error messages for invalid configuration

## Dependencies

- **003.0-DEV-FILTER-MATURE-VERSIONS**: Builds on existing maturity filtering

## Definition of Done

- [ ] All acceptance criteria met
- [ ] Code reviewed and approved
- [ ] Unit tests for configuration loading with all precedence scenarios
- [ ] Tests for validation (invalid values rejected)
- [ ] Integration tests with CLI flag and config file
- [ ] Documentation updated (README.md shows --min-age flag)
- [ ] Help text includes --min-age option
- [ ] Backward compatible (no breaking changes)

---

## Story Notes

**Gall's Law Compliance**: Adds configuration layer to existing working maturity filter without changing core filtering logic.

**Backward Compatibility**: Default behavior unchanged (7 days) - existing users see no difference until they opt in to custom thresholds.

**Future Enhancement**: Story 007.0 will build on this to allow separate prod/dev thresholds.
