# ADR-047: v0.1.22 Quality & Feature Polish

- **Status**: Proposed
- **Date**: 2026-03-16
- **Deciders**: Project maintainers
- **Related**: ADR-044 (High-Impact Features), ADR-041 (Test Health), ADR-042 (Code Coverage)
- **Branch**: `docs/v0.1.22-release-updates`
- **PR**: [#369](https://github.com/d-o-hub/rust-self-learning-memory/pull/369)
- **Epic**: [#373](https://github.com/d-o-hub/rust-self-learning-memory/issues/373)

## Context

ADR-044 features (Playbooks, Attribution, Checkpoints, Feedback) are code-complete with 43 unit tests across core, MCP, and CLI layers. However, comprehensive codebase analysis on 2026-03-16 reveals several quality gaps that must be addressed before tagging v0.1.22:

1. **2 failing doctests** in new feature modules (attribution, playbook)
2. **1 test timeout** (`quality_gate_no_clippy_warnings` — 120s+)
3. **3 production files exceed 500 LOC** (project invariant violation)
4. **0 snapshot tests** for 6 new MCP tools and 6 new CLI commands
5. **0 property tests** for new feature types
6. **0 integration tests** for end-to-end feature flows
7. **70 `#[allow(dead_code)]`** annotations in production code (target ≤40)
8. **149 broken markdown links** (increased from 89 due to new docs)

## Decision

Structure v0.1.22 as a quality-and-polish sprint with 4 phases:

### Phase 1: Critical Fixes (P0) — Must-Fix Before Tag

| ID | Goal | Issue |
|----|------|-------|
| WG-040 | Fix 2 failing doctests | Attribution doctest: clone before move. Playbook doctest: remove `.await` on sync fn, add missing field. |
| WG-041 | Fix test timeout | Ignore `quality_gate_no_clippy_warnings` (redundant with CI). |
| WG-042 | Split 3 files >500 LOC | `generator.rs` (631→<500), `memory_handlers.rs` (608→<500), `management.rs` (504→<500). |

### Phase 2: Quality Polish (P1) — Should-Fix

| ID | Goal | Target |
|----|------|--------|
| WG-043 | Reduce `#[allow(dead_code)]` | 70 → ≤40 |
| WG-044 | Fix broken markdown links | 149 → ≤80 |
| WG-045 | Add snapshot tests for new features | 65 → ≥80 |
| WG-046 | Add property tests for new features | 10 → ≥13 files |

### Phase 3: Feature Enhancements (P2) — Nice-to-Have

| ID | Goal | Details |
|----|------|---------|
| WG-047 | MCP tool contract parity | Verify 6 new tools in `tool_contract_parity.rs` |
| WG-048 | Integration tests | E2E tests for attribution + checkpoint flows |
| WG-049 | Changelog automation | Wire git-cliff into release workflow |
| WG-050 | Feature documentation | Usage guides for playbook, checkpoint, attribution |

### Phase 4: Infrastructure (P3) — Carried Forward

| ID | Goal | Since |
|----|------|-------|
| WG-051 | Nightly trend tracking | v0.1.20 |
| WG-052 | libsql version monitor | v0.1.20 |
| WG-053 | Structured tech-debt registry | v0.1.17 |

## Quality Gates

All must pass before v0.1.22 tag:

- `cargo fmt --all -- --check`
- `cargo clippy --workspace --tests -- -D warnings`
- `cargo build --all`
- `cargo nextest run --all` (0 timeouts)
- `cargo test --doc --all` (0 failures)
- `./scripts/quality-gates.sh`
- No production source file >500 LOC

## Consequences

### Positive
- v0.1.22 ships with validated, tested features (not just code-complete)
- Broken invariants (>500 LOC, failing doctests) fixed before they accumulate
- New features get proper test coverage (snapshots, property tests, integration)
- Dead code reduced toward maintainability target

### Negative
- Delays v0.1.22 tag by ~2-3 days for Phase 1+2
- Some P1/P2 work may carry forward to v0.1.23

### Risks
- **Mitigated**: File splits may break imports — run full test suite after each split
- **Mitigated**: Dead code removal may remove used code — check callers before deleting

## Estimated Effort

| Phase | Hours | Priority |
|-------|-------|----------|
| Phase 1 | 4-6h | P0 |
| Phase 2 | 6-8h | P1 |
| Phase 3 | 4-6h | P2 |
| Phase 4 | 2-3h | P3 |
| **Total** | **16-23h** | — |

## Cross-References

- **Execution plan**: [../GOAP_EXECUTION_PLAN_v0.1.22.md](../GOAP_EXECUTION_PLAN_v0.1.22.md)
- **Gap analysis**: [../STATUS/GAP_ANALYSIS_LATEST.md](../STATUS/GAP_ANALYSIS_LATEST.md)
- **Goals**: [../GOALS.md](../GOALS.md) (WG-040 through WG-053)
- **Actions**: [../ACTIONS.md](../ACTIONS.md) (ACT-053 through ACT-075)
- **ADR-044**: [ADR-044-High-Impact-Features-v0.1.20.md](ADR-044-High-Impact-Features-v0.1.20.md)
- **ADR-041**: [ADR-041-Test-Health-Remediation-v0.1.20.md](ADR-041-Test-Health-Remediation-v0.1.20.md)
