96 lines
3.0 KiB
Markdown
96 lines
3.0 KiB
Markdown
---
|
|
phase: 06-history-api
|
|
plan: 01
|
|
subsystem: api
|
|
tags: [fastapi, sqlalchemy, pagination, timeline, rbac]
|
|
|
|
# Dependency graph
|
|
requires:
|
|
- phase: 05-diff-engine
|
|
provides: router_config_changes and router_config_diffs tables with parsed change data
|
|
provides:
|
|
- GET /api/tenants/{tid}/devices/{did}/config-history endpoint
|
|
- get_config_history service function with pagination
|
|
affects: [06-02, frontend-config-history]
|
|
|
|
# Tech tracking
|
|
tech-stack:
|
|
added: []
|
|
patterns: [raw SQL text() joins for timeline queries, same RBAC pattern as config_backups]
|
|
|
|
key-files:
|
|
created:
|
|
- backend/app/services/config_history_service.py
|
|
- backend/app/routers/config_history.py
|
|
- backend/tests/test_config_history_service.py
|
|
modified:
|
|
- backend/app/main.py
|
|
|
|
key-decisions:
|
|
- "Raw SQL text() for JOIN query consistent with config_diff_service.py pattern"
|
|
- "Pagination defaults: limit=50, offset=0 with validation (ge=1, le=200 for limit)"
|
|
|
|
patterns-established:
|
|
- "Config history queries use JOIN between changes and diffs tables for timeline view"
|
|
|
|
requirements-completed: [API-01, API-04]
|
|
|
|
# Metrics
|
|
duration: 2min
|
|
completed: 2026-03-13
|
|
---
|
|
|
|
# Phase 6 Plan 1: Config History Timeline Summary
|
|
|
|
**GET /config-history endpoint returning paginated change timeline with component, summary, timestamp, and diff metadata via JOIN query**
|
|
|
|
## Performance
|
|
|
|
- **Duration:** 2 min
|
|
- **Started:** 2026-03-13T03:58:03Z
|
|
- **Completed:** 2026-03-13T04:00:00Z
|
|
- **Tasks:** 2
|
|
- **Files modified:** 4
|
|
|
|
## Accomplishments
|
|
- Config history service querying router_config_changes JOIN router_config_diffs for timeline entries
|
|
- REST endpoint with viewer+ RBAC and config:read scope enforcement
|
|
- 4 unit tests covering formatting, empty results, pagination, and ordering
|
|
- Router registered in main.py alongside existing config routers
|
|
|
|
## Task Commits
|
|
|
|
Each task was committed atomically:
|
|
|
|
1. **Task 1: Config history service and tests (TDD)** - `f7d5aec` (feat)
|
|
2. **Task 2: Config history router and main.py registration** - `5c56344` (feat)
|
|
|
|
## Files Created/Modified
|
|
- `backend/app/services/config_history_service.py` - Query function for paginated config change timeline
|
|
- `backend/app/routers/config_history.py` - REST endpoint with RBAC, pagination query params
|
|
- `backend/tests/test_config_history_service.py` - 4 unit tests with AsyncMock sessions
|
|
- `backend/app/main.py` - Router import and registration
|
|
|
|
## Decisions Made
|
|
- Used raw SQL text() for the JOIN query, consistent with config_diff_service.py pattern
|
|
- Pagination limit constrained to 1-200 via FastAPI Query validation
|
|
- Copied _check_tenant_access helper (same pattern as config_backups.py)
|
|
|
|
## Deviations from Plan
|
|
|
|
None - plan executed exactly as written.
|
|
|
|
## Issues Encountered
|
|
None
|
|
|
|
## User Setup Required
|
|
None - no external service configuration required.
|
|
|
|
## Next Phase Readiness
|
|
- Config history timeline endpoint ready for frontend consumption
|
|
- Plan 06-02 can build on this for detailed diff view endpoints
|
|
|
|
---
|
|
*Phase: 06-history-api*
|
|
*Completed: 2026-03-13*
|