Skip to content

fix(stats): finish report bookkeeping after pull timeout - #562

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
linjinglan:codex/fix-usage-report-timeout
Sep 15, 2026
Merged

jeff-r2026 merged 1 commit into
Tencent:mainfrom
linjinglan:codex/fix-usage-report-timeout

Conversation

@linjinglan

Copy link
Copy Markdown
Contributor

Summary

A stats push taking longer than five seconds could succeed after pull had abandoned local acknowledgement, causing the next pull to count the same session data again. Bound the wait around the complete reporting batch, so late success still advances reported snapshots and consumes the reported usage prefix. Keep partition sync locks until that work settles.

Reporting now returns an explicit success result. A failed or skipped push preserves local events and snapshots. Restore the stats input after a failed reports-branch push so a normal retry does not add its delta twice; allow that retry to push an existing commit even when its reconstructed tree is unchanged. Existing callers retain their default no-op behavior.

English and Chinese usage documentation and the affected design document describe the wait boundary and remaining limitations.

Type of Change

  • Bug fix

Test Plan

  • npm run build passed using worktree-local, lockfile-pinned dependencies.
  • node node_modules/typescript/bin/tsc --noEmit passed.
  • 40 related unit and real-Git tests passed: team-push-interventions (8), reports-branch-readonly (6), intervention-report (7), pull-scope-isolation (9), git-kind-reports (6), pull-learnings-deletion (1), self-mode-no-business-reset (3).
  • Real built CLI: 12 slow-push combinations passed across Claude, Codex, CodeBuddy, OpenCode and git, gitlab, github configuration. A local Git receiver delays pushes by seven seconds. At timeout, events and locks remain; after success, all three reported snapshots advance, appended events survive cleanup, and repeat pulls do not duplicate session totals.
  • Real built CLI: rejected push preserves local events and snapshots; a later successful retry reports the stats once.
  • git diff --check passed.

One pre-existing test, pull scope isolation > project mode: inherits user resources only when explicitly enabled, fails on this Windows environment because the expected deployed skill is absent. The same failure was reproduced on unmodified main. The passing scope run excluded that test; it is not claimed as passing. An exploratory broader run also encountered the existing Windows-invalid gstack:tdd fixture in usage-tracking; no change to that test is included.

CLI test commands (retries disabled; the two selections together cover all 13 cases):

node node_modules/vitest/vitest.mjs run --config vitest.e2e.config.ts src/__tests__/e2e/report-timeout.test.ts -t 'git/codex|retains a rejected' --retry 0
node node_modules/vitest/vitest.mjs run --config vitest.e2e.config.ts src/__tests__/e2e/report-timeout.test.ts -t 'acknowledges slow pushes once: (git/(claude|codebuddy|opencode)|gitlab/|github/)' --retry 0

Notes for Reviewers

This remains best-effort delivery. There is no durable batch journal or remote deduplication for a process terminated between pushing and local acknowledgement, or for partially successful multi-target batches. Five seconds bounds the reporting batch wait; it does not cancel Git or guarantee process exit while subprocesses remain active.

The CLI matrix uses isolated homes and local Git remotes. Agent and provider configurations are exercised, not live Agent GUIs or hosted-provider authentication. The installed CLI and main working tree were not patched.

@jeff-r2026
jeff-r2026 self-requested a review September 15, 2026 06:28
@jeff-r2026
jeff-r2026 merged commit 434de41 into Tencent:main Sep 15, 2026
7 checks passed
jimpablo added a commit to jimpablo/teamai-cli that referenced this pull request Sep 15, 2026
Resolve the conflict with Tencent#562 in reports-branch-readonly tests by using
path.join for the reports worktree path. Keep Tencent#560's read-only refresh
and autostash recovery together with Tencent#562's pushIfUnchanged retry and
pull report-timeout bookkeeping.

The late-report isolation test now only asserts that partition sync-locks
stay held; .reports-lock is released after the earlier read-only refresh.
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants