Persistent snapshot substrate for Dashboard V2. The store backs historical trends, manual baselines, compare/export workflows, and release-gate evidence.
Scope¶
The snapshot layer is no longer a simple time-series cache. It is a metadata-rich evidence store used by:
- Dashboard trends and period comparisons
- Manual project and group snapshots
- Snapshot-to-snapshot compare and export
- Release-gate pre/post evidence capture
- Notification context for release-driven events
Snapshot Model¶
Each snapshot stores both summarized scores and provenance metadata.
Core identity fields:
idscope—project,group, orportfolioscope_ref— canonical target referenceproject_name/group_idwhen applicabletimestamp
Evidence metadata:
reasoninitiatortrigger_sourceanalyzer_versionrule_versionsource_refimmutableretention_class
Payload data:
- health, audit, compliance, release, SCA, and quality summaries
- source bundle used for compare/export
- serialized snapshot payload for later replay
Lifecycle¶
Capture -> Persist -> Compare / Export -> Retain / Cleanup
Capture sources:
- background scheduler
- manual API and CLI calls
- release-gate pre/post automation
Retention rules:
- standard retention uses
dashboard.snapshot_retention_days - snapshots marked
immutableare protected from ordinary cleanup - release-triggered snapshots can use a separate retention class
API Surfaces¶
All endpoints live under /api/v2/dashboard.
Create Manual Snapshot¶
POST /snapshots
Use this to capture a manual baseline for a project, group, or portfolio.
Request fields include:
scopeproject_nameorgroup_idreasontrigger_sourceanalyzer_versionrule_versionsource_refimmutableretention_class
ACL follows the same ProjectContext rules as the underlying project/group.
List Snapshots¶
GET /snapshots
Filters:
scopeproject_namegroup_idlimit
The maximum returned count is bounded by dashboard.snapshot_list_limit.
Snapshot Governance Policy¶
GET /snapshots/policy
Returns the live immutable-governance contract. Current runtime mode is:
immutable_governance_mode = no_delete_policydelete_supported = falsearchival_supported = false- ordinary cleanup still respects
immutable = true
Compare Snapshots¶
POST /snapshots/compare
Supported modes:
- compare by
from_snapshot_idandto_snapshot_id - compare by legacy project timestamps
Compare output includes:
- metric deltas
trend_directiondimension_stateswithimproved,regressed, orunchanged- optional
drilldown_categories - optional
drilldown_previews
Export Snapshot or Compare Report¶
POST /snapshots/{snapshot_id}/export
Supported formats:
jsonmarkdownpdf
If baseline_snapshot_id is provided, export produces a compare report instead of a single-snapshot report.
Trend Endpoints¶
Existing trend endpoints remain available:
GET /snapshots/{project_name}/trendsGET /snapshots/{project_name}/diffGET /snapshots/{project_name}/compare-periods
These routes use persisted snapshot data when available and preserve compatibility with the broader dashboard trend model.
CLI Surfaces¶
Implemented in src/cli/dashboard_commands.py.
Available commands:
dashboard snapshot createdashboard snapshot listdashboard snapshot showdashboard snapshot policydashboard snapshot comparedashboard snapshot export
Examples:
codegraph dashboard snapshot create --scope project --project my-service --reason "pre-hardening"
codegraph dashboard snapshot list --scope portfolio --group team-a --format json
codegraph dashboard snapshot show <snapshot_id> --format json
codegraph dashboard snapshot policy --format json
codegraph dashboard snapshot compare --from-snapshot <id1> --to-snapshot <id2> --include-drilldown
codegraph dashboard snapshot export <snapshot_id> --baseline-snapshot <older_id> --format markdown
Release-Gate Integration¶
POST /api/v1/release/check can create:
presnapshot before evaluationpostsnapshot after evaluation
Response fields:
pre_snapshot_idpost_snapshot_idsnapshot_diff
Release-triggered behavior is controlled by:
dashboard.snapshot_release_pre_enableddashboard.snapshot_release_post_enableddashboard.snapshot_release_immutabledashboard.snapshot_release_retention_class
Notification Integration¶
The notification service consumes snapshot-derived context for release-driven notifications. Current integration passes:
- snapshot IDs
- compare diff summary
- release outcome context
This allows release alerts to point to reproducible state evidence instead of only a status string.
Configuration¶
Relevant dashboard config keys:
snapshot_enabledsnapshot_interval_minutessnapshot_retention_dayssnapshot_db_pathsnapshot_list_limitsnapshot_release_pre_enabledsnapshot_release_post_enabledsnapshot_release_immutablesnapshot_release_retention_class
Operational Notes¶
- The store uses SQLite and is created automatically on first use.
- One active scheduler instance is recommended for steady-state writes.
- Manual snapshots and compare/export flows are safe to run without enabling the background scheduler.
immutablecurrently uses explicitno_delete_policy: runtime does not expose delete or mutation endpoints, and ordinary cleanup skips immutable records.
Source Files¶
| File | Purpose |
|---|---|
src/api/services/dashboard/snapshot_store.py |
Persistent snapshot storage and migration |
src/api/services/dashboard/history.py |
Snapshot compare semantics and drilldown |
src/api/services/dashboard/export.py |
Snapshot and compare export |
src/api/services/dashboard/snapshot_scheduler.py |
Scheduled snapshot collection |
src/api/routers/dashboard_v2.py |
REST endpoints for list/create/compare/export/trends |
src/api/routers/release_gate.py |
Release-triggered pre/post snapshot automation |
tests/unit/test_dashboard_v2/test_snapshot_store.py |
Snapshot store coverage |
tests/unit/test_dashboard_v2/test_history_service.py |
Compare semantics coverage |