plugins/hermes-achievements/docs/achievements-performance-implementation-spec.md
This document is implementation-facing detail to execute the performance refactor later.
Decision scope: keep only Achievements tab flow; remove /overview + top-banner slot integration.
evaluate_all() performs:
scan_sessions()SessionDB.list_sessions_rich(...)db.get_messages(session_id) for each session/overview and /achievements both currently call evaluate_all() directly.sessions:top, analytics:top) currently invoke /overview.Consequence: repeated full recomputes and contention.
GET /overviewSummarySlot componentregisterSlot("sessions:top")registerSlot("analytics:top")"slots": ["sessions:top", "analytics:top"]/achievements endpoint and full tab renderingSnapshotStoreResponsibilities:
Storage path:
~/.hermes/plugins/hermes-achievements/scan_snapshot.jsonMethods (conceptual):
get() -> snapshot | nullset(snapshot)is_stale(ttl_seconds)ScanCoordinatorResponsibilities:
Methods:
run_if_needed(force: bool = false)get_status()State fields:
state: idle|running|failedstarted_at, finished_atlast_errorrun_countbuild_snapshot()Responsibilities:
/achievementsOutput:
achievementsscan_meta/overview)| Endpoint | Cache fresh | Cache stale | No cache | Force rescan |
|---|---|---|---|---|
/achievements | return cached | return stale + trigger bg refresh | blocking bootstrap scan | n/a |
/rescan | trigger refresh | trigger refresh | trigger refresh | yes |
/scan-status | status only | status only | status only | status only |
Notes:
{
"generated_at": 0,
"is_stale": false,
"scan_meta": {
"duration_ms": 0,
"sessions_scanned": 0,
"messages_scanned": 0,
"mode": "full",
"error": null
},
"achievements": [],
"unlocked_count": 0,
"discovered_count": 0,
"secret_count": 0,
"total_count": 0,
"error": null
}
Compatibility guidance:
/achievements keys.Checkpoint file (new):
~/.hermes/plugins/hermes-achievements/scan_checkpoint.jsonSuggested checkpoint shape:
{
"schema_version": 1,
"generated_at": 0,
"sessions": {
"<session_id>": {
"fingerprint": {
"updated_at": 0,
"message_count": 0,
"hash": "optional"
},
"contribution": {
"metrics": {}
}
}
}
}
Notes:
is_stale=true and error metadatascan-status should always return last known state/error./achievements/overview route removedsessions:top/analytics:top slotsapi("/overview") calls/achievements responsedashboard/plugin_api.pydashboard/perf_snapshot.pydashboard/perf_scan_coordinator.pydashboard/dist/index.js (or source if available)dashboard/manifest.json~/.hermes/plugins/hermes-achievements/state.json (existing unlock state)~/.hermes/plugins/hermes-achievements/scan_snapshot.json (new)~/.hermes/plugins/hermes-achievements/scan_checkpoint.json (new)Record:
/achievements timings (cold/warm)