fix(sdk): align scan session attribution rules - #599
Conversation
Share scan-directory matching and timestamp parsing between live cost tracking and saved logs. Preserve millisecond precision for ownership checks while keeping replay boundaries in seconds. Require directory-associated sessions to be independent and follow known parent links for child sessions. Cover subsecond and invalid timestamps, unrelated and delayed parents, Windows drive and case handling, and packaged helper availability.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7f4244cc8a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Share parent extraction between live costs and saved logs, including forked_from_id and the bundled workbench's parent-field precedence. Cover legitimate descendants, unrelated forks, and inherited usage replay for all three supported parent metadata formats.
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Keep all seven parent-format checks in the existing cost suite so this follow-up does not reshuffle unrelated Windows CI shards. Production code and assertions are unchanged.
|
@codex review Please review current head 77d3b57, including timestamp units, parent-field precedence, and inherited-history replay. The final commit keeps the seven parent-metadata checks in the existing cost suite so Windows CI shard assignments stay unchanged; production code and assertions are unchanged from the previously reviewed runtime fix. |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Follow-up to #589. Thanks to @Drewwb for the original directory-attribution fix and regression test.
Share the directory predicate between live cost tracking and saved logs, and fix the remaining timestamp and parentage cases that could include unrelated sessions in scan costs and trigger a budget limit early.
Changes
source.subagent.thread_spawn.parent_thread_id, directparent_thread_id, andforked_from_id, in that order, matching the bundled workbench. Ignore empty parent fields when considering a fallback.Testing
Local macOS verification with Bun 1.3.14 and Node 24.15.0:
12345and4081297345.pnpm run typesandpnpm run format: passed.pnpm packandpnpm run check:package: passed, including the installed public import, CLI, bundled plugin, and nested-worker smoke checks.git diff --check: passed.The local Windows path checks use
path.win32. The committed cross-drive and case-normalization fixtures are included in Windows CI. Those fixtures use synthetic session metadata and do not require a second physical drive or paid model calls.Risk and rollout
No public CLI, API, schema, dependency, or output-format changes. Cost tracking rejects independently inferred sessions when a scan or session timestamp is unknown/invalid, the session predates the scan, or it declares an unrelated parent. Legitimate descendants still follow their parent association. Existing archived-scan handling and completed-scan time bounds remain unchanged in the log reader.
This aligns the shared directory and live-session metadata rules; it does not replace the historical log reader's additional selection rules.
Public disclosure review