Repository navigation
fix(collector): read plans in sync and split account-switch gaps for 0.10.3 - #44
Merged
Merged
Conversation
Background sync never received the credential reader, so only `scan` detected plans from the login credential. Wire it into sync, and stop reading it every round: read on a new or changed account, while a plan awaits confirmation, hourly to catch upgrades, and hourly after a failed read. Other rounds reuse the confirmed plan without touching the keychain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An unchanged credential cannot carry a new plan, so the hourly recheck read the token for nothing. Compare the keychain item's modification time (attributes only, no password) or the credential file's status each round, and read the content only when it changed, the account or its fields changed, or a plan awaits confirmation. Without a marker, fall back to a daily recheck. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Usage between the last observation of one account and the first of the next was filed under "unattributed", a phantom account. Split the gap at the switch moment instead: the /login success line in the transcript, else the credential's modification time, else give the whole gap to the new account. Quota samples keep the strict rule. Existing gap events are reattributed once after upgrade. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
scan,每分钟运行的后台sync一次都没读。新版 Claude Code 登录的 Pro、Max 账户在后台同步里仍是未识别套餐。改动
sync也接上凭据读取,与scan使用同一组数据来源(src/collector/main.ts)。src/collector/collect.ts、src/collector/claude-code/credential.ts)。security find-generic-password不带-w,只取条目属性,不取密码,也不需要授权。其他系统看.credentials.json的文件状态。src/collector/attribution.ts、src/collector/claude-code/login.ts)。/login成功的那一行。只认整条消息正好是这段输出的用户行。attribution_rules记录规则版本。采集器本地状态只新增login_hints表,旧版本会忽略它。服务端数据库结构未变。--help、docs/collector.md和 CHANGELOG 已按现行行为更新,版本升到 0.10.3。验证
bun test tests472 个测试通过,bun run typecheck、bun run build、bun run build:collector、所改文件的 Prettier 检查和git diff --check均通过。sync两轮后上报凭据里的team-premium,批次中不含令牌。该测试在旧代码上失败,收到的套餐为null。team-premium。sync,第二轮上报team-premium。dist/meterleaf-collector scan正常识别套餐。已知限制
/login线索,旧空档按「归新账户」处理。🤖 Generated with Claude Code