Skip to content

Resumed sessions are counted repeatedly in cumulative usage totals #413

Open

Description

@DivyamTalwar

Problem

Every SessionEnd reparses the full transcript and appends a cumulative record. The reader currently sums all records, so ending and resuming the same session counts its earlier usage again and inflates both usage and session totals.

Observed on upstream ce30de7ca94115cb73fa991538c6d2595ac2622a.

Focused correction

Keep the last valid appended record for each nonempty session ID when reading. Leave storage append-only, preserve anonymous legacy rows individually, and retain missing-counter defaults. Tests include a real transcript parse/append/resume/read lifecycle.

Validation

The repository-native focused tests report 5 failures and 23 passing controls on unchanged production source; the prepared correction passes all 28 focused tests. The final commit is independently validated by the full Node 22/Linux suite with coverage, typecheck, build, duplication guard and critical-only bundle audit. The workflow enforces zero failed and zero skipped tests.

Prepared commit: d94330c04ae2f75c1510f706cbe017547f7a0981. Exact validation job and logs.

I am taking the implementation because the regression is reproducible and the change can remain focused. I will link the corresponding pull request.

Scope

The latest appended record is treated as the cumulative snapshot for that session, matching the current SessionEnd producer. This does not reconcile out-of-order writers or a transcript reset under a reused session ID; the log format and savings formula are unchanged.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions