Repository navigation
fix(plugin): the band's window saving survives the #989 change - #1035
Merged
Merged
Conversation
cg.py defined tokens_text twice. #1018 added tokens_text(stats, human) for the band. #989 added tokens_text(st) later in the file. The later one shadowed the first, so status_extras raised a TypeError, swallowed it, and left window_saved empty. Rename the band's helper to band_tokens_text. The Codex copy is the same. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
amiddavid
commented
Nov 10, 2026
amiddavid
left a comment
Collaborator
Author
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | 753bcc4430ed |
approve |
Verdict: approve
Findings
None. The change is correct and complete.
What the PR fixes
The base tree had two module-level functions named tokens_text in scripts/cg.py:
cg.py:259— the band's helper, 2 args (stats,human), added by #1018.cg.py:572— the status/insights helper, 1 arg (st), added by #989.
Python binds the later def, so the 1-arg function won. The call in status_extras
(cg.py:302) passed 2 args. That raised TypeError. The broad except Exception
in status_extras swallowed it. Result: doc["window_saved"] was never set, and
the band lost its 5-hour window saving figure, in silence.
This PR renames the band's helper to band_tokens_text. The later def no longer
shadows it, so the call works again.
What I checked
- The full diff: 6 lines, 2 files. Both are the same file kept in two copies.
- The bug at the base:
git show a3495863:.../cg.pyconfirms bothdef tokens_text
lines and the 2-arg call. The trace above follows from Python's def order. - Every reference to the old name, repo-wide (Go tests, hooks TypeScript, docs):
only the three sites this PR updates. The 1-argtokens_textcallers
(cg.py:602, 605, 677, 678, 730) are unchanged and still correct. - The two
cg.pycopies are byte-identical after the change (diffclean). - No other duplicate module-level name remains in
cg.py(checked all 95defs
and module constants for duplicates: none). - The existing Go tests cover the fixed path:
cg_cachestate_test.go:19and:42assertwindow_saved. Their own comment
says they exist to catch exactly this silent-blank failure. No new test needed. python3 -m py_compilepasses on both files (syntax only; live tests not run,
as this review does not approve them).
Non-blocking
- The collision was introduced by #1018 (d058b33), and the tests that cover it
already existed then. They should have failed on #1018's head. Confirm those
tests run in CI on PRs that touchcg.py; if they were green on #1018, they are
not running where they should. - The two names stay close (
tokens_textvsband_tokens_text), so the same
collision can recur. A redefinition check (ruff F811) overscripts/*.pywould
catch this class at write time. No lint config covers the plugin scripts today.
amiddavid
commented
Nov 10, 2026
amiddavid
left a comment
Collaborator
Author
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | 753bcc4430ed |
approve |
Verdict: approve
Findings
None. The fix is correct, complete, and covered by tests that already exist.
Non-blocking
- Why was #1018 CI green? The tests
TestCGCachestateCarriesTheStatusLinesExtrasandTestCGCachestateWindowTokensByCasecame in with #1018, and they runpython3 scripts/cg.py cachestateas a real subprocess. With the shadowing bug, both must fail:window_savedstays empty. Yet #1018 reports "CI green". Something in that CI run did not run these tests, or ran a stale tree. Please open an issue for it. The same blind spot can hide the next bug.
What I checked
- The defect, proven. At base
a3495863,cg.pydefinestokens_texttwice at module level: line 259 with 2 arguments (from #1018) and line 572 with 1 argument (from #989). I confirmed this with a Python AST scan ofgit show a3495863:context-guru-plugin/scripts/cg.py. Python binds the laterdef, so the calltokens_text(mine, sl._human)at line 302 raisesTypeError. Theexcept Exception: passat line 305 swallows it.window_savedis never set, so the band loses its window saving. This matches the commit message. - The fix, verified. At HEAD the 2-argument function is
band_tokens_text(line 259). It has exactly one caller, line 302, with 2 arguments. The 1-argumenttokens_text(line 572) keeps its callers at lines 602, 605, 677, 678, 730 — all pass 1 argument. A repo-wide grep finds no other reference to either name, in Python, TypeScript, docs, or JSON. - No other shadowing. An AST scan of
cg.pyandstatusline.pyat HEAD finds no other duplicate top-level names. - Both copies match.
codex-marketplace/plugins/context-guru/scripts/cg.pyandcontext-guru-plugin/scripts/cg.pyare byte-identical.TestCGScriptsAreVendoredIntoCodexenforces this. - Tests cover the fix. The two cachestate tests run the real script against a stub proxy and assert
window_savedby tier, including the pre-#999 fallback. They fail at base and pass with the rename. The PR needs no new test: it restores behavior that #1018's tests already pin. - Repo rules. Fail-open is untouched:
status_extrasstill swallows decoration errors by design, and the band still shows the rest of the doc. No data-dependence change: metadata only, same as before. No behavior change beyond restoring what #1018 documented and the owner approved. Commit has the DCO sign-off andAssisted-By:attribution.
boazdavid
added a commit
that referenced
this pull request
Nov 10, 2026
Brings the band window-saving fix (#1035). Assisted-By: Claude (Anthropic AI) <[email protected]>
This was referenced Nov 10, 2026
Merged
amiddavid
added a commit
that referenced
this pull request
Nov 11, 2026
…0.2.12, Pi 0.1.1) Claude Code plugin 0.6.7 -> 0.7.2: - #981, #989, #1018, #1035: subscription band and savings show saved tokens. - #1038: insights drop the finding that credits a user's own removal. - #1039, #1040: dash and keep-alive fixes that touch the plugin files. Codex plugin 0.2.11 -> 0.2.12: - #1051: read the cache strategies and presets from the proxy. - The vendored cg.py gets the same plugin changes. Pi package 0.1.0 -> 0.1.1: - #1010: chain the proxy in front of an existing base URL. - #1011: check the proxy at session start and restart it once. - #1049, #1058: write the cache strategy by name; review fixes. OpenCode plugin (#483): new in v0.7.2, no version file, not changed. Bob plugin 0.1.0: no change since v0.7.1, not changed. Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
amiddavid
added a commit
that referenced
this pull request
Nov 11, 2026
Bump the plugin versions for v0.7.2. - Claude Code plugin 0.6.7 -> 0.7.2: #981, #989, #1018, #1035 (savings in tokens on a subscription), #1038, #1039, #1040, #1055 (cache strategies read from the proxy). - Codex plugin 0.2.11 -> 0.2.12: #1051 (cache strategies and presets read from the proxy), plus the vendored cg.py changes. - Pi package 0.1.0 -> 0.1.1: #1010, #1011, #1049, #1058, and the #1040 README line. - OpenCode plugin: new in v0.7.2 (#483), no version file. Its first start now downloads proxy v0.7.2 (was v0.7.1). Nothing compares against PINNED_VERSION; the floor stays "v0.7.1 or later". The README lines, the install guide and 3 tests follow. - Bob plugin: 0.1.0, no change since v0.7.1. Behavior change: the OpenCode plugin's first download is proxy v0.7.2, not v0.7.1. Owner's yes, 2026-11-11, in the integrator session: "option1 it is"; the version bumps: "I approve the version bumps for the plugins". Data dependence: none. Reviews: 3 offload review rounds (GLM; round 3 pre-approved by the owner). Both reviewers approve at 3cf6176, which is the PR head. Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5 <[email protected]>
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.
Summary
context-guru-plugin:TestCGCachestateCarriesTheStatusLinesExtrasandTestCGCachestateWindowTokensByCase.window_savedcomes out empty in the band.Why it happens
tokens_text(stats, human)tocg.py(line 259).tokens_text(st)to the same file (line 572).status_extraspasses 2 arguments, gets a TypeError, andstatus_extrasswallows every error.What changed
band_tokens_textand its one call and doc mention. feat(plugin): status and insights savings show saved tokens on a subscription #989'stokens_textstays.cg.py.Behavior change: none intended; it restores the band's window saving that #1018 added (the owner approved #1018).
Data dependence: none.
How it was tested
band_tokens_textgivessaved 85.0k wr · 2.0k wr1h · 1.2M rd · 5 in · cost 600 wrfor the first case, and None for a proxy before feat(dash): store the accountant's tier tokens and serve them from /api/stats #999.go test -race -count=1 ./context-guru-pluginpasses (all tests).🤖 Generated with Claude Code