# Story Series 6.0: Complexity Reduction & Enterprise API Exposure

## Overview

This series addresses findings from the Complexity & Over-Engineering Audit conducted in January 2026. The goal is to reduce internal implementation debt while properly exposing enterprise-grade features to users.

## Guiding Principles

1. **Enterprise features are valuable** — Audit trails, resilience patterns, rich errors are appropriate for an enterprise logging library
2. **Hidden features provide no value** — Infrastructure that users can't discover or use should be exposed or removed
3. **Duplication is debt** — Internal code duplication creates maintenance burden without user benefit
4. **Dead code is noise** — Unused implementations confuse contributors and inflate the codebase
5. **Logging libraries should minimize dependencies** — Prefer protocols over forced dependencies

## Stories

### Quick Wins (6.1 - 6.7)

| Story | Title                                        | Risk | LOC Impact  | Status      |
| ----- | -------------------------------------------- | ---- | ----------- | ----------- |
| 6.1   | Remove Unused Concurrency Primitives         | Low  | -415        | Complete    |
| 6.2   | Consolidate Cache Error Classes              | Low  | -60         | Complete    |
| 6.3   | Extract Shared Plugin Stop Logic             | Low  | -50         | Complete    |
| 6.4   | Create AuditSink Plugin Wrapper              | Low  | +150        | Complete    |
| 6.5   | Document Environment Variable Aliases        | Low  | +100 (docs) | Complete    |
| 6.6   | Add Explicit Public API Exports              | Low  | +30         | Complete    |
| 6.7   | Simplify Resilience + Tenacity Compatibility | Low  | -1300       | **Decided** |

### Bigger Bets (6.8 - 6.10)

| Story | Title                                    | Risk   | LOC Impact | Status        |
| ----- | ---------------------------------------- | ------ | ---------- | ------------- |
| 6.8   | Unify Logger Facade Implementations      | Medium | -329       | Complete      |
| 6.9   | Expose Resilience Patterns as Public API | Low    | N/A        | **CANCELLED** |
| 6.10  | Unify get_logger/get_async_logger Setup  | Low    | -100       | Complete      |

## Key Decision: Story 6.7 (Resilience API)

**Decision:** Lean Internal + Protocol Escape Hatch

| Action                                                  | Rationale                          |
| ------------------------------------------------------- | ---------------------------------- |
| **Remove** `fallback.py` (638 lines)                    | Unused, adds complexity            |
| **Remove** `AsyncCircuitBreaker` + manager (~413 lines) | Unused                             |
| **Keep** `SinkCircuitBreaker` (80 lines)                | Used internally                    |
| **Simplify** `retry.py` (~530 → ~250 lines)             | Remove unused strategies           |
| **Add** `RetryCallable` protocol                        | Enable Tenacity without dependency |

This decision **cancels Story 6.9** — Fapilog will not expose a full resilience API. Instead, enterprise users can plug in Tenacity via the protocol if needed.

## Success Metrics

- [ ] Total lines of code reduced by ~2000-2500 (including 6.7 decision)
- [ ] No unused classes in `core/` directory
- [ ] All enterprise features discoverable via `__all__` or documentation
- [ ] Zero duplicated methods between sync/async facades
- [ ] Full test coverage maintained
- [ ] Tenacity integration documented

## Dependencies

- Stories 6.1-6.3 can proceed in parallel
- Story 6.7 decision is **complete** — implementation can proceed
- Story 6.9 is **cancelled** (superseded by 6.7)
- Story 6.8 is independent but highest impact
- Story 6.10 can proceed after 6.8 (may share patterns)

## Out of Scope

- New feature development
- Performance optimization
- API breaking changes to public interfaces
- Adding Tenacity as a dependency (protocol only)
