Repository navigation
Agent usage: config-dir cache key and owner-only modes - #12265
chessing234 wants to merge 10 commits into
Conversation
Recommendation: fix the Codex syntax error and update permission testsFinding 1: the Codex collector cannot start
Impact: failure occurs before any collector code executes, not just when writing a cache. Requested change: correct the indentation without restoring public-read permissions, then rerun the scanner suite. Finding 2: scanner tests still require the old permissionsThe Claude scanner reaches its mode assertion with the intended 0600 output but fails because it expects 0644. Codex has the same stale expectation, currently hidden by the syntax failure. Requested change: update both scanner assertions to expect owner-only files. Verified: Claude caches are isolated by configuration directoryTwo directories share a cache root; synthetic HTTP returns A=10% and B=80%: Test scope: synthetic HTTP, not live accounts. Codex permission behavior remains unverified until it can parse. These results do not establish retroactive hardening of existing or abandoned caches. Automated AI review: Astra inspected the PR, Fable 5.1 and a separate Astra session reviewed it independently, then findings were checked against targeted tests. |
|
fixed the codex indent and kept cache files at 0600 |
Folded from omacom#9855.
tmp.replace was over-indented so the scanner could not start.
mkdir(exist_ok) left older 0755 trees alone, and prior runs wrote 0644 cache files. Create the directory at 0700 and tighten any world bits on existing files so plan/usage details stay private after upgrade.
Assert two CLAUDE_CONFIG_DIR accounts get distinct digests, the unkeyed claude-limits.json is removed, the cache dir stays 0700, and the Codex scanner expects 0600 instead of the old world-readable mode.
ec686f6 to
a83e319
Compare
[Medium impact] The PR appears safe to merge; no new actionable issue or outstanding previous finding remains. Findings
SummaryThe PR isolates Claude limits caches by account configuration and makes agent-usage caches owner-only. Since the previous review, the accounts test now supplies a primary-cache value and requires the collector to return it when it inherits another account’s configuration. Reviews (6) · Last reviewed commit: "Assert the primary account keeps its own..." · Reviewed by Greptile |
With no recorded account identity the primary account fell back on the default cache name, which collect_limits keys by config_dir() -- the collector's inherited CLAUDE_CONFIG_DIR rather than the home it just read credentials from. Run with CLAUDE_CONFIG_DIR pointing at an added account, the primary account would then show that account's cached allowance as its own when its probe failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| collector.main() | ||
| PY | ||
| ) | ||
| [[ $(jq -c '.accounts[0].limits | map(.percent)' <<<"$inherited") != *0.66* ]] || |
There was a problem hiding this comment.
The primary account’s probe is made to fail, but this assertion passes even if the collector returns no limits. That means the test does not verify its stated behavior: retaining the primary account’s own cached limits when CLAUDE_CONFIG_DIR points to another account. Check for the expected cached percentage as well as the absence of the other account’s percentage.
Knowledge Base Used: Agent accounts and provider usage
The inherited CLAUDE_CONFIG_DIR test only checked the other account's percentage was absent, so a collector returning no limits at all would pass. Seed the primary's own cache and expect its value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed and verified at 67ccd48; it fixes #9382. I pushed one fix and a test to your branch. Reproduced on a worker built from the Omarchy ISO. Two Fixed on your branch (f994279, 67ccd48): a registered primary account with no recorded account UUID went through the default cache name, and that name is keyed by the collector's Second opinion: Codex Medium reviewed the whole diff and both commits, in two rounds. It agreed on the fix, and its independence is not guaranteed. It also noted that the permission sweep in This now waits on the maintainer. |
|
This branch no longer merges into What What
Second opinion: Codex Medium read this branch, Thanks @chessing234, this found a real bug, and the two pieces above are still worth having. This now waits on the maintainer, and my recommendation is to close it in favour of #14040, with the identity-less fallback and the cache modes left to fresh changes against |
|
closing this. quattro fixes #9382 by the account uuid, which is the case this was opened for. a no-uuid home and the cache file modes are a different change. |
Summary
CLAUDE_CONFIG_DIR, keep usage caches at 0600.claude-limits.jsonso it cannot keep leaking the last account that wrote it.Test plan
bash test/shell.d/agent-usage-claude-limits-test.sh(includes dualCLAUDE_CONFIG_DIRisolation + legacy unlink + 0700 dir)bash test/shell.d/agent-usage-claude-scanner-test.sh(concurrent write leaves 0600)cache_root/write_jsonclamp to 0700/0600agent-usage-codex-scanner-test.sh(expects cache mode 600; needs Linuxstat -c)