Skip to content

usage: a forked hand's spend is counted twice in the day total #168

Closed

Description

@santoshkumarradha

Follow-up from #141 (found by the #145 lane, PR #153, not fixed there).

What happened

internal/session/fork.go:993 foldHandUsage folds a forked hand's spend into the conversation through addAuxiliaryUsageAs, which writes a ledger line. But the hand's own turns already wrote their lines as they happened — under Session: "unfiled", because a hand has no SessionFile. So the machine-wide day total (the figure the per-day wallet cap reads) counts a forked hand's spend twice. Harmless to the conversation's own rollup (UsageTree joins on Root), real for the day figure and the /cost split.

Also found: the comment on SubjectSpend.Session says it is "the conversation a task's work was journaled under". It is the node's own journal id. Nothing is broken by it (the spend place joins on ID alone) — the prose is wrong.

The mechanism

  • A hand's turns write their lines once, carrying UsageLine.Root = the conversation they were forked from (the same field Spend is visible live at the tree, not at task close #153 gave task nodes), and the fold at close writes no line — fold-at-close is a settlement step, exactly as foldTaskUsage already is.
  • SubjectSpend.Session's comment says what the field holds.

Where

internal/session/fork.go (foldHandUsage, the hand's Config), internal/session/usage_ledger.go, usage_spend.go.

Acceptance

  • A forked hand that spends $X raises the day ledger by $X, not $2X; a test pins it through the same reader the day cap uses.
  • A hand's ledger lines carry the root conversation rather than unfiled, so /cost's tree total includes a live hand; a test pins it.
  • The SubjectSpend.Session comment is corrected.

Drafted with CodeAF · reviewed and owned by the author

Activity

  1. added 2 commits that reference this issue on Sep 1, 2026
    e517ae0
    5838268
  2. added
    bug
    area:session
    on Oct 3, 2026
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

    area:sessionbug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions