Skip to content

netclaw stats skills_loaded resets on daemon restart — read from daily_stats instead #593

Description

@Aaronontheweb

Problem

DailyStatsActor._totalSkillsLoaded is a process-lifetime, non-persisted counter. The field comment at src/Netclaw.Daemon/Gateway/DailyStatsActor.cs:22 says it explicitly: "Process-lifetime totals (never reset, never persisted — lost on restart)". netclaw stats reads this value via DaemonStatsService.SkillsLoadedTotalDailyStatsActor.QueryProcessStatsProcessStatsResult.SkillsLoadedTotal.

Result: every daemon restart silently resets the displayed lifetime counter to 0, masking real activity from before the restart. The daily_stats SQLite table already has historical per-day totals that would survive a restart, but they're not surfaced through netclaw stats.

Evidence

daily_stats shows non-zero historical skills_loaded:

date_key skills_loaded
2026-04-08 1
2026-04-09 1
2026-04-10 0
2026-04-11 0

But netclaw stats always shows 0 because the daemon restarted at 2026-04-10 22:14 UTC, wiping the in-memory lifetime counter.

Options

  1. Sum from daily_stats on query. In DailyStatsActor, change QueryProcessStats to read persisted rows + any unflushed in-memory _pending accumulators. Most accurate; no new state.
  2. Persist lifetime totals to a new table. Write a lifetime_totals row that gets updated on each flush. Simpler to query but adds schema.
  3. Display both "today" and "lifetime" in netclaw stats. Keep the volatile counter for the process-lifetime number but add a persisted total read from daily_stats.

Option 1 is simplest and doesn't require schema changes.

Affected

  • src/Netclaw.Daemon/Gateway/DailyStatsActor.csQueryProcessStats handler, _totalSkillsLoaded field
  • src/Netclaw.Daemon/Gateway/DaemonStatsService.cs:32-33,57 — query call site
  • src/Netclaw.Cli/Tui/StatsPage.cs:144 — display (no change needed if upstream value becomes correct)
  • src/Netclaw.Cli/Program.cs:1227netclaw stats plain-CLI path (no change if upstream fixed)

Related

Discovered while investigating netclaw stats Skills loaded: 0 under milestone 0.12.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions