Repository navigation
fix(cost): preserve worker activity when a session log is unreadable - #970
mldangelo-oai merged 9 commits into
Conversation
|
Flagging an overlap I should have caught before opening this. Staff PR #465 — function isSessionAccessDenied(error: unknown): boolean {
return (
isRecord(error) && (error["code"] === "EACCES" || error["code"] === "EPERM")
);
}and calls To be precise about the current state: If #465 lands first, though, this one is redundant and should be closed rather than rebased. I have not closed it myself because #465 is still open, so the fix is not on The note in the description about #224 stands: it was closed by its author on 2026-09-01 with no maintainer decision recorded. |
|
CI is green here (one check, passing), and this has been sitting since 18 September. The change is one guard: Is there anything you would like changed before this can go in? |
readSessionUsage quarantines a log it cannot parse, so the guard at the top of the function skips it on later polls, but a log it cannot open records nothing. The next poll opens the same file and fails identically for the life of the scan, and because an unopenable log never produced a thread id, the failure also escapes the thread-tree filter in #readSessions. stop() awaits refresh() unguarded, so the final poll can reject after the turn completed and discard the caller's usage. Quarantine the session on an access refusal the process cannot clear by retrying, mirroring the parse-failure exit. Other open failures keep retrying: a process-wide shortage such as EMFILE clears on its own, and retiring a session for it would stop observing usage that could still be read.
a2485be to
3bcc75d
Compare
…-inaccessible-session-log # Conflicts: # sdk/typescript/src/cost.ts # sdk/typescript/tests-ts/cost.test.ts
…naccessible-session-log # Conflicts: # sdk/typescript/src/cost.ts
|
Thanks! |
Summary
An unreadable session log could hide progress from healthy workers in the same scan. A scan without a spending limit can now deliver activity, progress, and session events from workers it can read while cost accounting is unavailable. Issue #223
This is the smaller alternative to #2178 for #223. Merge only one. #2178 also limits repeated denied opens and tracks changing diagnostics across individual files.
Changes
When an observer requests worker events, an uncapped poll delivers the available events before returning the original read error. If permission is denied for an unidentified session, its error still takes priority, even when a later directory or resource error stops the search. Later polls retry denied file reads, so verified accounting can resume when access returns. A denied
staton a directory entry stops traversal immediately, avoiding repeated metadata calls against its siblings.Testing
On current main, an inaccessible session prevented delivery for both
EACCESandEPERM. On the reviewed branch the cost suite and the SDK/CLI cost controls passed. Nine installed-package checks on Linux covered permission failures, real file-descriptor exhaustion, and error order in capped and uncapped scans.Risk and rollout
With an explicit spending limit, or when only accounting is requested, the poll stops as soon as it establishes that usage cannot be verified, including during replay of an associated session. Failed polls publish no new cost or usage total. The scan API continues to suppress repeated optional warnings for denied opens on the same path. PR #977
Public disclosure review