Skip to content

feat(plugin): read the cache strategies from the proxy - #1055

Merged
amiddavid merged 11 commits into
mainfrom
feat/cc-plugin-reads-proxy-strategies
Nov 11, 2026
Merged

amiddavid merged 11 commits into
mainfrom
feat/cc-plugin-reads-proxy-strategies

Conversation

@amiddavid

@amiddavid amiddavid commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Behavior change: the strategy commands need a proxy of v0.7.1 or later.

  • Who it affects: users whose proxy binary is older than v0.7.1 (v0.7.0 included), or who have no proxy binary yet.
  • What changes: strategy list, strategy set (except none) and strategy show of a name now ask the proxy (context-guru-proxy strategies). An older binary gets this message: "update the proxy to v0.7.1 or later (/context-guru:update)". There is no fallback table. This is the owner's decision.
  • What does not change: presets. preset set still saves the choice when no proxy can list presets (no binary, or one older than v0.7.1). It prints warning=preset_unchecked. The check against the proxy's presets list runs when a proxy can answer. preset list falls back to the plugin's short list with the same warning. This is the owner's choice.
  • strategy set --name none works with any binary.
  • Attach mode with no local binary: auto (the plugin's own default) and none install unchecked, because the remote proxy checks the name when it loads the setting. Any other name is refused with reason=strategy_unchecked. --plan follows the same rule.
  • How to fix it: update the proxy with /context-guru:update.
  • Data dependence: none. docs/data-dependence.md stays as it is.

Release note: The Claude Code plugin now reads the cache strategies from the proxy. Update the proxy to v0.7.1 or later to list or change a strategy.

Refs #980. Follow-up 1 (Claude Code plugin). The Codex plugin is a separate PR.

Summary

  • The Claude Code plugin drops its copy of the strategy table. It reads the table from the proxy.
  • The plugin offers only strategies for anthropic or any. 30-min-ping does not appear.
  • The strategy file now holds cache: strategy: <name>. The proxy fills in the keys.
  • Names, descriptions, spends flags, the default auto and the alias 5-min-ping stay the same.

What changed

  • settings.py
    • Runs context-guru-proxy strategies with a 5 s time limit and LISTEN_ADDR=127.0.0.1:0 (feat(opencode): OpenCode plugin for context-guru #483: a v0.7.0 binary ignores the word and serves). "No valid JSON" means an old binary. Every bad answer (garbage, not an object, wrong types, bytes that are not UTF-8) gives the same advice.
    • The probe writes no state. Its env drops DASHBOARD_*, SESSION_STATE*, CONTROL_DB, UPSTREAMS, CG_RECORD_*, ARCHIVE_* (ARCHIVE_REMOTE uploads data), STORE and IDLE_EXIT, and sets DASHBOARD=0. It runs in a fresh empty temp dir.
    • Finds the binary: --bin, CONTEXT_GURU_BIN, PATH, then ~/.local/bin. A named path that exists but is not executable is an error. It does not fall through to PATH.
    • Caches the result per process by binary path and mtime.
    • CONTEXT_GURU_STRATEGIES_TIMEOUT (seconds) sets the limit. It is a test and debug setting.
    • strategy list prints only the offered strategies. strategy set refuses others (reason=not_offered).
    • preset list/set/restart: a proxy that answers and lacks a picker preset gives reason=preset_unknown_to_proxy. With no proxy that can answer, they warn and go on as before.
  • install.sh reads names, aliases and spends from strategy list.
    • With no binary yet, a local install checks the name after step 1.
    • In attach mode, a name other than none or auto is refused with reason=strategy_unchecked and the advice to install proxy v0.7.1+ or use --cache-strategy none. --plan with no binary reports strategy_unchecked=true.
    • The consent question is vaguer on a first install ("spend status unknown, treat it as spending"). This is deliberate and safe.
  • strategy sync renames an old strategy=5-min-ping marker to auto (the marker name only). strategy show maps it locally.
  • cache-strategy-picker skill: no table. It runs strategy list. It documents proxy_too_old, no_proxy_binary and proxy_unrunnable.
  • config/strategy_test.go (Claude Code part only): removed TestStrategyTableMatchesPlugin, added TestEveryStrategyHasTheSameEffectiveConfigAsItsOldKeys. The Codex test is untouched.
  • docs/how-to/install-plugin.md: the proxy owns the strategies. A new-form file needs proxy v0.7.1+, so do not downgrade the proxy after you switch strategy.

Same effective config

  • config/testdata/cc-old-strategy-files/ holds the files the old plugin wrote for auto, 1-ping, 2-ping, 1-hour-head.
  • For each, Resolved() of the old file equals Resolved() of cache: strategy: <name>. Mutating the Go table makes it fail.
  • The released v0.7.1 binary loaded a strategy: 2-ping file: keepalive=true keepalive_idle_seconds=240 keepalive_max_pings=2.

Existing strategy files

  • Files with explicit keys stay as they are. strategy sync moves only their preset: line (and an old alias name in the marker). It does not call the binary.
  • A file marked "1h keys omitted" moves to the new form once the recorded proxy is v0.7.1 or later.
  • strategy set writes the new form.

How it was tested

  • See the final test run in the PR reply below. go vet and go test -race for ./config/... and ./context-guru-plugin/....
  • Round 1 added tests for: unchecked name in attach mode and in --plan; bad proxy output (garbage, list, string, non-UTF-8, bad aliases, bad presets); the probe env and cwd; preset with no proxy; non-executable named binary; alias marker rename. Each has a mutation that fails it.

Open questions

  • The Codex PR also edits config/strategy_test.go. This PR changes only the Claude Code part. Expect a small merge conflict in that file.

🤖 Generated with Claude Code

The Claude Code plugin no longer keeps its own copy of the cache strategy
table. It runs `context-guru-proxy strategies` and offers the strategies
whose providers include anthropic or any.

- settings.py reads the table from the binary (short time limit, loopback
  port 0, cached per binary path and mtime). A binary without the
  `strategies` command gives a clear error: update the proxy to v0.7.1 or
  later. There is no fallback table.
- `strategy set` writes `cache: strategy: <name>`. The proxy fills the keys.
  Files written earlier keep their explicit keys and keep working.
- `strategy sync` leaves an old-form file's keys alone and moves only its
  `preset:` line. It moves a legacy-marked file to the new form once the
  recorded proxy is v0.7.1 or later.
- The plugin checks each preset in its picker list against the proxy's
  `presets` list.
- config: replace the Python drift test with a test that the effective
  config of each old-form file equals the `strategy: <name>` form.

Refs #980

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 1c6c18f621c8 blocking

Verdict: blocking

Findings

  1. context-guru-plugin/scripts/settings.py:3705 — load_strategy_table crashes with an uncaught AttributeError when the proxy binary exits 0 with output that is not a JSON object.

    • What fails: a binary that prints non-JSON (or a JSON list or string) to stdout and exits 0 makes table None (or a non-dict). The ok = expression then calls table.get("default") on it. Python raises AttributeError, which nothing catches. strategy list, strategy set, strategy show, preset list/set/restart and insights.py (via default_strategy) all crash with a traceback and exit 1. The clean result=error reason=proxy_too_old with the update advice never prints. install.sh then reads no result= line at all, so route_main misclassifies the crash as strategy_list_unavailable with an empty cause.
    • Proof: reproduced on this machine with a stub binary that echoes one line and exits 0:
      CONTEXT_GURU_BIN=<stub> python3 -I .../settings.py strategy list exits 1 with
      AttributeError: 'NoneType' object has no attribute 'get' at settings.py:3705.
      The short-circuit saves only the timeout case (code == -1); exit 0 is the unprotected side. Non-UTF-8 stdout raises UnicodeDecodeError in the same function (text=True), same family.
    • Fix: add isinstance(table, dict) to the ok chain before any .get, so every bad output becomes StrategyTableError. Add a test with a stub that exits 0 printing garbage.
  2. context-guru-plugin/scripts/install.sh:1053 — with no local proxy binary, --cache-strategy is never validated in attach mode (and not before a --plan).

    • What fails: route_main defers the name check to the post-install block (line 1053), which runs only under if [ "$R_MODE" = local ]. In attach mode nothing installs a binary, so the check never runs. --plan also exits at line 935, before step 1. A typo'd or stale --cache-strategy name (or a bad saved option_cache_strategy) then reaches the plan and the consent question as fact (cache_strategy=<name>, "SPEND STATUS UNKNOWN"), and the attach install finishes with result=routed. Only strategy_warning=no_proxy_binary hints at it, and the warning names the binary, not the unknown name. The base refused this input as unknown_strategy before anything was written — the exact "dropped decision that reports success" shape this script's own comments call a defect.
    • Proof: route_main (install.sh:742-753) sets R_STRATLIST_DEFERRED=1 on no_proxy_binary and skips route_check_strategy. The deferred check at 1053 sits inside the R_MODE = local block at 1034. Attach mode has no other call to route_check_strategy or route_check_strategy_late. Step 4b strategy set fails with no_proxy_binary and its result lands in strategy_warning= only.
    • Fix: when the list is deferred and the mode is attach (or the run is --plan), refuse with a named reason, or validate the name wherever a binary is first askable. At minimum, say in the plan and the consent question that the strategy name is unchecked.

Non-blocking

  • Stale comments name removed code: install.sh:507 cites the deleted STRATEGIES dict; start-proxy.sh:1090-1094 cites settings.py ONE_HOUR_DEFAULTS and "only a non-default value is ever written" — the plugin now writes no _1h key at all. _render_strategy's docstring (settings.py:3826) says "strategy sync re-renders them to this form", but the sync MIGRATION comment says the opposite, and the code follows the MIGRATION comment.
  • strategy sync no longer rewrites an old strategy=5-min-ping marker to auto. The startup note and statusline will show the old alias name indefinitely. It works: the proxy resolves the alias. Cosmetic.
  • The picker SKILL.md documents only reason=proxy_too_old. no_proxy_binary and proxy_unrunnable are undocumented outcomes for the model that reads it.
  • preset list/set/restart now exit 3 when the proxy cannot be asked (no binary, or one older than v0.7.1). Before, preset set succeeded and start-proxy.sh fell back to preset off at launch with a note. This is a user-visible behavior change (CLAUDE.md / RELEASING.md rule); confirm the owner named and approved it on the PR.
  • load_strategy_table validates the row shape but not aliases / presets. A dict answer with aliases as a list crashes .items() later. Same trust boundary as finding 1; narrower.

What I checked

  • Read the full diff base..HEAD and the code around every change: config/strategy.go and its tests, the four old-form fixtures, settings.py (table loading, strategy list/show/set/clear/sync, preset gating, --bin), install.sh (route_main, both check functions, step 1 and 4b), start-proxy.sh recovery paths, insights.py, SKILL.md, plugin_test.go, and the two new test files.
  • Verified the version claim: strategies subcommand and cache.strategy config support landed together in b49cbeb, first released in the v0.7.1 tag, so STRATEGY_MIN_PROXY = "v0.7.1" is correct for both the subcommand and the strategy: key the stale-marker migration writes.
  • Traced the sync paths: new-form re-render, old-form preset-line-only edit, --legacy-binary _1h stripping, and the stale-marker move to the new form at a recorded v0.7.1+. Each matches its test.
  • Confirmed the old fixtures match what the base plugin rendered (keys, omitted default _1h values), so TestEveryStrategyHasTheSameEffectiveConfigAsItsOldKeys compares the right things.
  • Confirmed sync never runs the proxy binary, so SessionStart stays fast with any binary — the design goal.
  • Confirmed none needs no table, and 30-min-ping is refused for this plugin (not_offered).
  • Reproduced finding 1 live with python3 (no Go was built or run; live Go tests are not approved).
  • Did not read the other reviewer's folder or any PR comments before posting this.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 1c6c18f621c8 blocking

Verdict: blocking

Findings

  1. context-guru-plugin/scripts/install.sh:1053 — in attach mode with no proxy binary, an unknown --cache-strategy name is never checked, and the install reports success
    • What fails: install.sh --mode attach --base-url <url> --cache-strategy 5-minute-ping on a machine with no context-guru-proxy binary. strategy list fails with no_proxy_binary, so line 745 sets R_STRATLIST_DEFERRED=1 and skips the name check. The only re-check (line 1053) sits inside if [ "$R_MODE" = local ] (line 1034), so attach mode never runs it. Step 4b's strategy set then fails with no_proxy_binary, and the catch-all at line 1083 turns that into strategy_warning=. The install finishes with result=routed and cache_strategy=5-minute-ping as a fact, while no strategy file exists and the name is not a strategy. This is the exact "dropped decision that reports success" shape the comment above line 729 says this check exists to prevent. Before this PR, the plugin's own table answered the list in every mode, so the name was refused in attach mode too. Also, even a valid name is no longer armed in this mode; before, the file was written.
    • Proof: line 745 sets the deferred flag for no_proxy_binary; lines 1034/1053 run route_check_strategy_late only when R_MODE = local; line 1083 maps the strategy set failure to strategy_warning; route_report (line 633) emits cache_strategy=$R_STRATEGY.
    • Fix: when R_STRATLIST_DEFERRED=1 and R_MODE = attach and R_STRATEGY != none, either refuse before routing is written (same shape as route_check_strategy_late), or state in the report that the strategy was neither checked nor armed, and stop emitting cache_strategy= as a fact.

Non-blocking

  • install.sh consent question (line 516): on a first install there is no binary yet, so R_SPENDS is unset and the question says "SPEND STATUS UNKNOWN - treat it as spending" for every non-none strategy, including the default auto. Before, it said what the strategy spends. The direction is safe and the code comment says it is deliberate, but every fresh install now consents to a vaguer sentence.
  • settings.py _render_strategy docstring: it says "strategy sync re-renders them to this form". Sync keeps old-form files and moves only the preset: line; only the stale-marker path re-renders. The comment inside cmd_strategy says this correctly.
  • A new-form file plus a binary older than v0.7.1 has no recovery. The binary rejects the strategy: key itself, and start-proxy.sh's recovery grep matches only the _1h key names, so the session is left with no proxy. The strategy set hard stop makes this reachable only by downgrading the binary after a new-form file was written. Worth a note in the docs, not a code change.
  • settings.py strategy show with no readable table: the recorded name is reported raw, so an old strategy=5-min-ping marker shows 5-min-ping, not auto. Display only; set and sync are unaffected.
  • settings.py find_proxy_binary: an explicit --bin or CONTEXT_GURU_BIN path that exists but is not executable is silently skipped, and a different binary on PATH can answer in its place. Edge case; install.sh always passes a binary it just ran.

What I checked

  • The full diff (15 files) and the code around every hunk: config/strategy.go, config/strategy_test.go, the four YAML fixtures, settings.py (table load, find_proxy_binary, cmd_strategy list/show/sync/set/clear, cmd_preset, _presets_known_to_proxy, argparse), install.sh (route_main, route_check_strategy, route_check_strategy_late, step 1 and step 4b, consent gate order), insights.py, start-proxy.sh (sync call, 1h-key and preset recoveries), SKILL.md, plugin.json, and all new and changed tests.
  • That the proxy side already exists at the base commit: config.StrategiesJSON, LookupStrategy, the Providers field, and the strategies subcommand in cmd/context-guru-proxy/main.go. The JSON shape matches what load_strategy_table validates (default, aliases, strategies[].name/providers/spends/desc, presets).
  • That no leftover reference to the removed names (DEFAULT_STRATEGY, STRATEGIES, STRATEGY_ALIASES, ONE_HOUR_DEFAULTS) remains in the plugin scripts.
  • The sync state machine by hand for every file shape: old-form with and without the legacy marker, new form, --legacy-binary, stale marker with version below and at or above v0.7.1, and the missing version file. The TestTheLegacyMarkerEndsWhenTheProxyIsUpdated sequence (v0.4.2 → v0.5.0 → v0.7.1) traces correctly: synced, unchanged, moved to the new form.
  • That strategy sync (the SessionStart path) never runs the proxy binary, and that the statusline, cmd_show, cmd_config, and start-proxy.sh read the strategy name from the file, so no hook spawns the binary per render.
  • That the new fixtures match what the old plugin wrote (the _1h defaults omitted, only keepalive_max_pings_1h: 2 for 2-ping), and that Resolved() fills the omitted _1h values from defaults equal to the table, so TestEveryStrategyHasTheSameEffectiveConfigAsItsOldKeys compares like with like.
  • That every test helper that runs strategy or preset ops now provides a binary (settingsIn, settingsInDir, presetIn, routeEnv, fakeProxyDir, the two preset set call sites, preset_restart_test), and that routeEnv callers with an empty extraPath are plan, refuse, or attach paths only.
  • The old-binary path (#483): an ignored strategies argument makes the binary serve; the run uses LISTEN_ADDR=127.0.0.1:0, stdin=DEVNULL, a time limit, and subprocess.run kills the child on timeout. none needs no table, so turning pings off works with any binary.
  • The PR description: the v0.7.1 hard stop is named at the top as a behavior change, and the data-dependence statement (none) matches the code.
  • I did not run the Go tests (live tests not approved; Go is not on this machine). The PR reports go test -race ./config/... and ./context-guru-plugin/... as passing; I verified the test code and helpers by reading only.

- install.sh: an unchecked --cache-strategy name (attach mode, or --plan
  with no binary) is refused with reason=strategy_unchecked, or marked
  unchecked in the plan. It is no longer reported as a fact.
- settings.py: every bad answer from the proxy (garbage, JSON that is not
  an object, bad aliases or presets, bytes that are not UTF-8) becomes the
  proxy_too_old advice.
- The strategies probe runs in a scrubbed env (no dashboard, record, store
  or hosted-mode settings) and in a fresh empty directory.
- Presets keep the old behavior: saved and warned when no proxy can list
  presets. The check runs when a proxy answers.
- sync renames an old 5-min-ping marker to auto; show maps it locally.
- A named binary that is not executable is an error.
- Comments, picker skill and docs match the code.

Refs #980

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Round 1 is fixed at 15c177f8 (new commits on top, fast-forward push). All findings, both reviewers and the integrator:

Blocking

  1. R1 and R2, attach mode and --plan never check --cache-strategy with no binary. Fixed. Attach mode refuses a name other than none with reason=strategy_unchecked and the advice to install proxy v0.7.1+ or use --cache-strategy none. --plan with no binary prints strategy_unchecked=true and says the name is checked after install. The name is never reported as a fact. Tests: TestAttachModeRefusesAnUncheckedStrategyName, TestPlanWithNoBinarySaysTheStrategyIsUnchecked. Mutations N1, N2 fail them.
  2. R2, load_strategy_table crash on bad output. Fixed. Bytes are decoded with errors="replace". The result must be a dict, and aliases and presets must have the right types. Every bad output gives proxy_too_old. Test: TestBadProxyOutputIsTheCleanAdviceNotACrash (garbage, list, string, non-UTF-8, bad aliases, bad presets). Mutations N3, N4, N5.
  3. Integrator, the probe must not write state. Fixed. The probe env drops DASHBOARD*, SESSION_STATE*, CONTROL_DB, UPSTREAMS, CG_RECORD*, STORE, IDLE_EXIT. It sets DASHBOARD=0, keeps LISTEN_ADDR=127.0.0.1:0 and CONFIG=, and runs in a fresh temp dir. Test: TestTheProbeRunsInAScrubbedEnvAndAFreshDirectory. Mutations N6 (scrub) and N7 (cwd).
  4. Owner decision, presets keep the old behavior. Done. preset list/set/restart warn (warning=preset_unchecked) and go on when no proxy can answer. preset list falls back to the plugin's short list. A proxy that answers and lacks a preset still errors. Test: TestPresetSetSavesAndWarnsWhenNoProxyCanListPresets (no binary, old binary, and preset set medium). Mutation N8.

Non-blocking

  • Stale comments in install.sh, start-proxy.sh and the _render_strategy docstring: fixed.
  • strategy sync renames an old 5-min-ping marker to auto (marker name only, no re-render). strategy show maps it locally. Test TestSyncRenamesAnOldAliasMarker, mutation N9.
  • Picker SKILL.md documents no_proxy_binary and proxy_unrunnable: fixed.
  • A named binary that exists but is not executable is now proxy_unrunnable, with no PATH fall-through. Test TestANonExecutableNamedBinaryIsAnError, mutation N10.
  • Docs: a new-form file needs proxy v0.7.1+, so do not downgrade the proxy. Fixed.
  • CONTEXT_GURU_STRATEGIES_TIMEOUT: kept, documented as a test and debug setting.
  • Kept: the vaguer consent sentence on a first install. With no binary, the spend status is unknown. The sentence says to treat it as spending. This is the safe direction, and a copy of the table to fix it is what the owner ruled out.
  • R1 note on "new-form file plus an older binary has no recovery": a docs note only, as the reviewer said. strategy set stops on such a binary, so only a downgrade reaches it.

Tests (box dir ~/cc-strategies)

  • go vet: clean for ./config/... and ./context-guru-plugin/....
  • go test -race ./config/...: ok, 79 s.
  • go test -race ./context-guru-plugin/...: ok, 549 s. One earlier run failed TestStatuslineV2OneTimerNoColdPingedCyan ("stats loading…", a load timing issue in code this PR does not touch). It passed 3 of 3 alone and in the full rerun.
  • Mutations: 10 of 10 caught.

The PR body now has the exact behavior change, the probe scrub and the release-note line.

A proxy older than v0.7.1 reads ARCHIVE_REMOTE and six other ARCHIVE_*
settings. ARCHIVE_REMOTE uploads data. The probe now drops them, and the
test sets ARCHIVE_REMOTE in the parent env and checks the probe does not
see it.

Refs #980

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Also: the earlier "wip: test url" commit (strategies_round1_test.go, 2
lines) changed the test base URL to http://127.0.0.1:9/anthropic. It was
a fix to my own test, not to the product: install.sh refuses an attach
URL whose path is not /anthropic, so the first version of the test hit
invalid_base_url before it reached the strategy check. This commit adds
a comment that says so.

Refs #980

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 resumed 1 of 2 2 of 2 b30b7bd2c98e approve

Verdict: approve

Findings

None. Every round-1 finding is fixed, and the fix commits introduce no new defect I can show.

Earlier findings, and their status

  1. Mine, install.sh attach mode never checks --cache-strategy with no binary — fixed. install.sh:753 now refuses a non-none name in attach mode with reason=strategy_unchecked and the advice to install proxy v0.7.1+ or pass --cache-strategy none. route_needs refuses before the consent gate and before step 0, so nothing is written (exit 2, result=refused), and under --plan it is needs_decision at exit 0. A local --plan with no binary prints strategy_unchecked=true with a note that matches what the post-install check does. Verified the placement: the elif fires only for no_proxy_binary (the only deferred reason), and none is exempt. Tests: TestAttachModeRefusesAnUncheckedStrategyName, TestPlanWithNoBinarySaysTheStrategyIsUnchecked.
  2. Reviewer 2, finding 1: load_strategy_table crashes on non-dict JSON — fixed. The ok chain now starts with isinstance(table, dict), and aliases/presets are type-checked before .items() iterates them (the and chain short-circuits, so a list aliases never reaches .items()). Stdout is decoded with errors="replace", so non-UTF-8 bytes become a ValueError in json.loads, not a traceback. Every bad answer raises StrategyTableError with the update advice. Test: TestBadProxyOutputIsTheCleanAdviceNotACrash (garbage, list, string, non-UTF-8, bad aliases, bad presets), run for both list and set.
  3. Reviewer 2, finding 2: same attach/plan gap as mine — fixed, see item 1.
  4. Integrator, the probe must not write state — fixed. _PROBE_DROP removes DASHBOARD*, SESSION_STATE*, CONTROL_DB, UPSTREAMS, CG_RECORD*, ARCHIVE_*, STORE, IDLE_EXIT; the probe sets DASHBOARD=0, keeps LISTEN_ADDR=127.0.0.1:0 and CONFIG=, and runs in a fresh cg-strategies-* directory. I checked every dropped name against the Go tree: all are real proxy settings (ARCHIVE_REMOTE, CG_RECORD_DIR, CONTROL_DB, DASHBOARD_DB, SESSION_STATE, STORE, IDLE_EXIT, UPSTREAMS all appear as read env vars). Test: TestTheProbeRunsInAScrubbedEnvAndAFreshDirectory.
  5. Owner decision, presets keep the old behavior — done. _presets_known_to_proxy warns (warning=preset_unchecked) and returns 0 when no proxy can answer; a proxy that answers and lacks a preset still errors with exit 3. preset set saves again with no binary, as before this PR. Test: TestPresetSetSavesAndWarnsWhenNoProxyCanListPresets. This resolves reviewer 2's non-blocking behavior-change question: the owner named it in the fix comment.
  6. My non-blocking items — all fixed or accepted. _render_strategy docstring now matches the sync code. The docs say a new-form file needs v0.7.1+ and not to downgrade. find_proxy_binary raises proxy_unrunnable for a named, existing, non-executable binary, with no PATH fall-through. strategy show maps 5-min-ping → auto without a table, and sync renames the marker (test TestSyncRenamesAnOldAliasMarker). The vaguer consent sentence is kept by owner decision: no binary means the spend status is unknown, and the sentence says to treat it as spending. I accept that; a table copy is what this PR removes.
  7. Reviewer 2's non-blocking items — all fixed. Stale comments in install.sh and start-proxy.sh rewritten. SKILL.md documents no_proxy_binary and proxy_unrunnable. The aliases/presets validation is part of fix 2.

Non-blocking

  • settings.py _presets_known_to_proxy: the proxy_too_old message ends with "nothing was changed" (from _update_hint), but preset set then saves the preset. The warning sentence is false in that one output. Use a hint without that clause for the warning.
  • install.sh:753: attach mode with no local binary now refuses every non-none strategy, including the default auto. A user who never asked about strategies must pass --cache-strategy none. Honest, and the advice is actionable, but it is a change to the plain attach flow.
  • install.sh:753: the attach strategy check runs before the --base-url validation, so a typo'd URL plus an unchecked strategy reports the strategy reason first. Diagnostic order only; both refuse.
  • settings.py LEGACY_NAME_ALIASES: a one-entry copy of the proxy's alias map, for display only. If the proxy adds an alias, strategy show without a table reports the raw name again. The comment says the proxy stays the authority; accepted.
  • The wip: test url commit title is not a conventional-commit type. History noise only.

What I checked

  • Last review: round 1, 1c6c18f, 2026-11-10T15:50:03Z
  • New commits read: 4 — 4ca63870 fix(plugin): review round 1 of the strategies change; 15c177f8 wip: test url; a285034a fix(plugin): drop ARCHIVE_* from the strategies probe env; b30b7bd2 docs(plugin): say why the attach test URLs end in /anthropic
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files in my folder)
  • New items since my last review: reviewer 2's round-1 review (2 findings, 5 non-blocking — checked each, statuses above); the author's fix comment at 2026-11-10T22:37:56Z (checked every claim it makes against the code); the 4 fix commits (read the full diff and the code around each hunk).
  • The attach fix: traced route_needs/route_refuse exit codes (2 refused, 0 needs_decision under --plan), the elif guard conditions, and that the refusal lands before the consent gate and step 0. Confirmed --no-health-check and every test helper used by the new tests exists (statsPresetStub, routedProject, runRoute, settingsWithBin, oldProxyBin, strategyCfg).
  • The crash fix: checked the and chain order so no .get/.items() runs on a non-dict, and that run.stdout is bytes (the text=True flag is gone) with errors="replace" decoding.
  • The probe scrub: matched every _PROBE_DROP name against env vars the Go proxy reads, and read the scrub test's env assertions (dropped vars absent, DASHBOARD=0, KEEP_ME=yes, fresh cg-strategies- cwd).
  • The sync alias rename: traced name = LEGACY_NAME_ALIASES.get(recorded, recorded) through all three branches (new form, stale marker, old form). The marker rename uses a plain string replace on line 1 only, and _is_new_form still compares against the recorded name so a new-form file is not misdetected.
  • The preset warn path: confirmed preset list falls back to the plugin's short list, preset set saves with the warning, and a proxy that answers with a missing preset still errors (the round-1 test TestEveryPickerPresetIsKnownToTheProxy still covers that side).
  • Confirmed noBinaryEnv's appended PATH and CONTEXT_GURU_BIN= win over routeEnv's values: Go's os/exec keeps the last duplicate key in Cmd.Env.
  • I did not run the Go tests (live tests not approved; Go is not on this machine). The author reports go vet clean, both -race runs ok, and 10 of 10 mutations caught; I verified the fixes by reading only.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 resumed 2 of 2 2 of 2 b30b7bd2c98e approve

Verdict: approve

Findings

None. Both round-1 blocking findings are fixed and verified. No new defect in the four new commits.

Earlier findings

  • R2-1 / R1-1, attach mode and --plan never check --cache-strategy with no binary: fixed. install.sh:753-759 refuses attach mode with a non-none name and no binary, reason=strategy_unchecked, before anything is written. A local --plan emits strategy_unchecked=true with a note (install.sh:943-945). Verified live: attach plan returns result=needs_decision reason=strategy_unchecked and no cache_strategy= line; local plan returns planned with strategy_unchecked=true. none still installs. Tests: TestAttachModeRefusesAnUncheckedStrategyName, TestPlanWithNoBinarySaysTheStrategyIsUnchecked.
  • R2-2, load_strategy_table crash on bad output: fixed. settings.py:3718-3726 now requires isinstance(table, dict) before any .get, validates aliases and presets types, and decodes stdout as bytes with errors="replace". Verified live with stub binaries: garbage, a JSON list and non-UTF-8 output all give result=error reason=proxy_too_old with the update advice, exit 3. No traceback. Test: TestBadProxyOutputIsTheCleanAdviceNotACrash (six cases, both list and set).
  • Integrator, the probe must not write state: fixed. _PROBE_DROP (settings.py:3669) drops DASHBOARD*, SESSION_STATE*, CONTROL_DB, UPSTREAMS, CG_RECORD*, ARCHIVE_*, STORE, IDLE_EXIT; the probe sets DASHBOARD=0 and runs in a fresh temp cwd. I checked the drop list against every env var the proxy reads (envOr/Getenv in cmd/, proxy/): every startup write path needs one of the dropped vars, or lands on a relative default path (the dashboard DB default is ./...), which the fresh cwd absorbs. parseBool("0") is false, so DASHBOARD=0 keeps the dashboard off. HOME-derived paths in the proxy are reads only. Test: TestTheProbeRunsInAScrubbedEnvAndAFreshDirectory.
  • My non-blocking items: all fixed. Stale comments in install.sh, start-proxy.sh and the _render_strategy docstring are corrected. strategy sync renames a 5-min-ping marker to auto via LEGACY_NAME_ALIASES (marker only, keys untouched), and strategy show maps it without a table. SKILL.md documents no_proxy_binary and proxy_unrunnable. aliases/presets types are validated.
  • My preset-gating concern: resolved by owner decision. preset list/set/restart warn (warning=preset_unchecked) and proceed when no proxy can answer, and still error when an answering proxy lacks a preset. That restores the base behavior, which was my ask. Test: TestPresetSetSavesAndWarnsWhenNoProxyCanListPresets.
  • R1 non-blocking, vaguer consent sentence: kept, and I accept the reason. With no binary the spend status is unknown; the sentence says to treat it as spending. The safe direction, and a table copy is what the owner ruled out.
  • R1 non-blocking, new-form file plus an older binary: docs note added (install-plugin.md: "Do not downgrade the proxy after you switch strategy"). As the reviewer asked.

Non-blocking

  • A local --plan with no binary still emits cache_strategy=<name> (route_report), next to strategy_unchecked=true. The pair is honest and the confirming run refuses an unknown name before routing. But the fix note's claim "the name is never reported as a fact" holds only for the attach path, not the local plan.
  • strategies_round1_test.go:117 — TestTheProbeRunsInAScrubbedEnvAndAFreshDirectory compares lines[0] == here where here is a temp dir nothing passed to the probe. That clause can never fire; the real assertion is the cg-strategies- prefix. Dead check, slightly misleading to a reader.
  • Commit 15c177f8 is titled wip: test url, which breaks the repo's conventional-commit rule. It is inside the PR history; harmless if the merge squashes.

What I checked

  • Last review: round 1, 1c6c18f, 2026-11-10T15:46:01Z
  • New commits read: 4 (4ca63870 fix(plugin): review round 1 of the strategies change; 15c177f8 wip: test url; a285034a fix(plugin): drop ARCHIVE_* from the strategies probe env; b30b7bd2 docs(plugin): say why the attach test URLs end in /anthropic)
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review: reviewer 1's round-1 review (their finding matches my finding 2, now fixed; their non-blocking items each addressed above); the author's fix-summary comment (every claim checked against the code); the four commits (full diff read, plus the changed files around each hunk).
  • Verified the fix code paths by hand: the new ok chain in load_strategy_table, find_proxy_binary's exists-but-not-executable error, the probe env scrub and temp cwd, _presets_known_to_proxy's warn-and-continue, the sync alias rename (_is_new_form on the recorded name, strategy=<old> replaced once in the marker), and route_needs' plan/refuse split behind strategy_unchecked.
  • Verified the new tests trace to real behavior: noBinaryEnv really removes every binary source (sandboxEnv drops CONTEXT_GURU_BIN, PATH and DEST overridden), the attach test's refusal and the none exception, the six bad-output stubs against the validation chain, and the probe-scrub assertions against the env the stub records.
  • Reproduced both round-1 defects' fixes live with python3 and bash (no Go built or run; live Go tests are not approved): garbage/list/non-UTF-8 binaries give the clean advice, preset list warns and succeeds, attach plan refuses with strategy_unchecked, local plan emits the unchecked flag.
  • Confirmed the probe drop list against every env var the proxy reads, that DASHBOARD=0 parses false, and that no HOME-derived startup write path exists.

Conflicts: config/strategy.go (kept the main text on the floors, plus this
branch's sentence that the plugin reads the table) and settings.py (kept
the removal of the Python table, which main still held). Also two small
fixes: the preset warning no longer says nothing was changed, and a dead
clause is gone from a probe test.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
The preset warning used a nested double quote inside an f-string, which
is a syntax error before Python 3.12. Use a plain variable.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
…able

The plugin now writes the strategy name, so the file pins no floor. The
test checks that, and that the proxy resolves 80000 and 20000.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Owner decision. Attach mode installs no binary, so a strategy name cannot
be checked. `auto` is the plugin's own default and the remote proxy checks
the name when it loads the setting, so `auto` and `none` pass unchecked.
Any other name is refused with reason=strategy_unchecked. The same rule
applies to --plan: `auto` and `none` are not reported as unchecked.

Refs #980

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Conflict in config/strategy_test.go, resolved by keeping both removals:
main removed the Codex drift test and the os import, and edited a comment
inside the Claude Code drift test; this branch removes that test and its
Python parser. The result keeps this branch's side of both conflict
blocks (the os import and the effective-config test) and every other
test from main.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 resumed 2 of 2 3 of 3 65d5651406c4 approve

Verdict: approve

Findings

None. The round-3 commits fix the open non-blocking items and the two merges, and they introduce no defect I can show.

This round's changes, checked one by one

  1. 32e47671 fix(plugin): keep settings.py parseable on Python 3.9 — correct. The round-2 fix for the false "nothing was changed" warning used a nested double quote inside an f-string, which Python before 3.12 cannot parse. The commit rewrites it to strip the suffix with a plain variable: why = why[: -len("; nothing was changed")]. The old construct was a Python 3.12+ parse (PEP 701); str.endswith plus slicing is valid on every Python 3, and from __future__ import annotations (line 31) keeps the dict | None annotations safe too. I also parsed settings.py with python3 -I on this machine: no syntax error. The strip runs only when the suffix is present, so other messages pass through unchanged.
  2. 335894c4 fix(plugin): allow auto in attach mode with no local binary — correct, owner decision. install.sh now exempts auto and none from the attach-mode strategy_unchecked refusal, in both the refusal (elif [ "$R_MODE" = attach ] && [ "$R_STRATEGY" != none ] && [ "$R_STRATEGY" != auto ]) and the --plan emit. auto is the plugin's own default, so a user who never named a strategy is not stopped. A named strategy other than none and auto is still refused. The install still reports strategy_warning, so the name stays marked unchecked. New test TestAttachModeWithNoBinaryAllowsAutoAndRefusesOtherNames covers both sides: auto and none route, 2-ping exits 2 with strategy_unchecked and writes no settings file.
  3. 5d3a7b3a test(plugin): re-anchor the tool-wait floor test — correct. The branch deleted main's TestStrategyFileHasNoToolWaitFloor when it removed the local table. The commit re-adds it, adapted: the strategy file must contain no tool_wait_min_prefix or keepalive_min_prefix_tokens key, must end with cache:\n strategy: auto\n, and config.LoadBytes → Resolved() must still give the same floors (80000 / 20000). So the floors stay asserted, now against the proxy's own config code instead of a table copy. That is the right anchor for this PR.
  4. Merge 82aa98fc and merge 65d56514 — resolutions verified. The PR was merged with origin/main twice; the base moved from 87b29db to 9d34f00. I read both merge diffs and the conflicts they resolved. In config/strategy_test.go, 65d56514 keeps this branch's removal of TestStrategyTableMatchesPlugin while taking main's move of the Codex drift test to config/strategy_codex_test.go. In strategies_round1_test.go, 82aa98fc removes the dead lines[0] == here clause I flagged in round 2. I diffed the PR against the new base 9d34f00: the 18 changed files are the previously reviewed content plus the three commits above. The only other change in a PR-touched file is insights.py, and it comes from main (e842294a), not from this branch.

Reviewer 1's round-2 review, checked

  • Their non-blocking item on the false "nothing was changed" warning is the same as the fix in item 1. Fixed.
  • Their non-blocking item on attach mode refusing the default auto is item 2. Fixed by owner decision.
  • Their remaining notes (diagnostic order, the one-entry LEGACY_NAME_ALIASES copy, the wip: test url title) are accepted as-is by both of us. I agree; none is a defect.

Non-blocking

  • A local --plan with no binary still emits cache_strategy=<name> next to strategy_unchecked=true. The pair is honest and the confirming run refuses an unknown name. Unchanged from round 2; accepted.
  • Commit 15c177f8 (wip: test url) still breaks the conventional-commit rule. History noise only, as in round 2.

What I checked

  • Last review: round 2, b30b7bd, 2026-11-10T22:46:48Z
  • New commits read: 3 on the branch (32e47671 fix(plugin): keep settings.py parseable on Python 3.9; 5d3a7b3a test(plugin): re-anchor the tool-wait floor test on the proxy-owned table; 335894c4 fix(plugin): allow auto in attach mode with no local binary) plus the merges 82aa98fc and 65d56514 and the main history they pulled in
  • Read in full: 4 reviews, 1 comment, 0 inline comments (from the three files in my folder)
  • New items since my last review: reviewer 1's round-2 review (checked every claim and every non-blocking item against the code); no new author comment; no inline comments.
  • The Python 3.9 fix: read the rewritten block in _presets_known_to_proxy, compared it with the removed nested-quote form, and parsed the file with python3 -I (syntax check only; no Go was built or run, live Go tests are not approved).
  • The attach-mode auto exemption: traced the elif guard and the --plan emit in install.sh, and read TestAttachModeWithNoBinaryAllowsAutoAndRefusesOtherNames against the noBinaryEnv helper (PATH and CONTEXT_GURU_DEST overridden, CONTEXT_GURU_BIN= empty).
  • The re-anchored floor test: checked the file assertions and that config.LoadBytes/Resolved() are the proxy's own code path, so the test fails if the proxy changes the floors.
  • The merges: listed every commit between my last reviewed head and the new head, read both merge diffs, and diffed the PR against the new base to confirm no unreviewed content rides in.
  • I did not run the Go tests (live tests not approved; Go is not on this machine). The author's round-1 report covers the box runs; this round's commits are small and I verified them by reading and a Python syntax check.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 resumed 1 of 2 3 of 3 65d5651406c4 approve

Verdict: approve

Findings

None. The three new commits fix my round-2 notes, and the two merges bring main in without breaking this PR's code. I found no new defect.

New commits, and what they do

  1. 32e47671 fix(plugin): keep settings.py parseable on Python 3.9 — good, and it fixes my round-2 note. The old warning line used a double quote inside an f-string, which is a syntax error before Python 3.12. The new code uses a plain variable. It also strips the false "; nothing was changed" clause from the preset_unchecked warning, which was my round-2 note. I checked the final code at HEAD: the strip runs before the message is built, and removesuffix (Python 3.9+) is gone from all plugin scripts. I scanned settings.py, insights.py, statusline.py and cg.py for the same nested-quote shape: none left.
  2. 5d3a7b3a test(plugin): re-anchor the tool-wait floor test — good. The plugin now writes cache: strategy: auto, so the old test's "the file states 80000" was wrong. The new test checks the file names the strategy and pins no floor, then loads it with config.LoadBytes and asserts 80000 / 20000. I traced it: _render_strategy ends the file with cache:\n strategy: auto\n (the HasSuffix check matches), applyStrategy fills 80000 from the table, and the tool-wait floor comes from the default. New config tests pin both floors to their defaults.
  3. 335894c4 fix(plugin): allow auto in attach mode with no local binary — good, and it fixes my round-2 note. This is an owner decision, named in the commit and in the PR body. Attach mode installs no binary, so a name cannot be checked. auto (the plugin's own default) and none now pass unchecked; any other name is still refused with reason=strategy_unchecked. --plan follows the same rule. I read the guard at HEAD: the elif adds only the auto exception, the refusal text and exit codes are unchanged, and the local-mode late check still validates every name (including auto) once the binary is installed. The new test traces correctly, and its helpers and flags exist.
  4. 82aa98fc and 65d56514, merges of main — resolutions verified. Main brought the tool-wait floor work, the self_removed removal (#584) and the Codex strategies PR (#1051, the new base 9d34f00f). I checked the merged files at HEAD:
    • config/strategy.go: the rows are unchanged; only comment and auto desc text moved. The JSON contract the plugin reads (name, providers, spends, desc, cache, presets) is unchanged.
    • config/strategy_test.go: both sides removed the Codex drift test; the merge kept that. The os import is still used by the old-form test, and the new floor-pinning tests from main are present.
    • settings.py: keeps this branch's removal of the Python table; main never re-added it.
    • Provider filtering still works: _offered keeps rows for anthropic or any, so the Codex 30-min-ping row does not appear for this plugin.

Earlier findings and notes, and their status

  • Round 1 and 2 blocking findings: still fixed. No commit this round touched the fix code paths except to add the auto exception, which I verified above.
  • My round-2 notes: 2 fixed, 3 accepted as-is. The false "nothing was changed" clause: fixed (32e47671). Attach mode refusing the default auto: fixed by owner decision (335894c4). The attach check still runs before --base-url validation: unchanged, diagnostic order only. LEGACY_NAME_ALIASES drift: unchanged, accepted in round 2. The wip: test url commit title: still in the history.
  • Reviewer 2's round-2 notes: 1 fixed, 2 as they were. The dead lines[0] == here clause in the probe test: gone at HEAD; the assertion now checks the cg-strategies- prefix. A local --plan still emits cache_strategy=<name> next to strategy_unchecked=true: still true, and the pair is honest. The wip commit title: as above.

Non-blocking

  • A local --plan with no binary and --cache-strategy auto now emits cache_strategy=auto with no unchecked flag. The confirming run checks the name after step 1, so the plan claim is true. Note only.
  • In attach mode with auto and no local binary, the report emits cache_strategy=auto as a fact while no local file was written (strategy_warning=no_proxy_binary). The remote proxy checks the name when it loads the setting — the owner's recorded reason. I accept it.

What I checked

  • Last review: round 2, b30b7bd2c98ec84e67d6a1bea82f7b3c14d1730d, 2026-11-10T22:45:54Z
  • New commits read: 5 — 82aa98fc merge origin/main; 32e47671 fix(plugin): keep settings.py parseable on Python 3.9; 5d3a7b3a test(plugin): re-anchor the tool-wait floor test on the proxy-owned table; 335894c4 fix(plugin): allow auto in attach mode with no local binary; 65d56514 merge origin/main (new base 9d34f00f, the merged Codex PR #1051)
  • Read in full: 4 reviews, 1 comment, 0 inline comments (from the three files in my folder)
  • New items since my last review and what I did:
    • Reviewer 2's round-2 review (2026-11-10T22:46:48Z, approve, 3 non-blocking) — checked each note against the code at HEAD; statuses above.
    • The 5 new commits — read every full diff and the merged files around each hunk.
    • The PR body's new attach-mode rule — matched it against the code.
  • Verified 335894c4 at HEAD: the attach elif adds only the auto exception; the plan emit excludes auto from strategy_unchecked; the local-mode late check at line 1064 still checks every name once a binary exists; the new test's helpers (runRoute, noBinaryEnv) and flags (--no-health-check, --i-consent-to-traffic-interception) all exist.
  • Verified 32e47671 at HEAD: the warning strip runs before the emit, and a scan of all four plugin scripts found no pre-3.12-illegal nested-quote f-string. ast.parse is clean on the local Python.
  • Verified 5d3a7b3a at HEAD: _render_strategy output matches the test's HasSuffix; config.LoadBytes on that file resolves 80000 / 20000, pinned by TestStrategiesPinTheGeneralFloorToTheDefault and TestToolWaitMinPrefixDefaultAndOverride.
  • Verified the merge resolutions: config/strategy_test.go (both drift tests removed, os import used, main's new tests kept), config/strategy.go (rows unchanged, JSON contract unchanged), settings.py (table removal kept), provider filtering (_offered, not_offered).
  • Checked that no PR doc or skill text still says attach mode refuses auto.
  • I did not run the Go tests (live tests not approved; Go is not on this machine). I ran only local Python syntax and text scans.

The Pi drift guard read STRATEGIES from the Claude Code plugin's
settings.py. This PR removes that table, so the guard failed with a
KeyError in CI (TestPiControllerPythonTests).

Move the guard to a Go test in pi-package. It dumps pi_plugin.STRATEGIES
with python3 and compares each name's spends flag and cache keys with
config.Strategies, which is the table the proxy owns. The Python test
that read settings.py is removed. No product code changes. Three stale
comments and one test message that named the removed Python table now
name the proxy table.

Refs #980

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 resumed 1 of 2 4 of 4 d1ff1e5618b6 approve

Verdict: approve

Findings

None. The one new commit is a test move, and I found no defect in it.

The new commit, checked

d1ff1e56 test(pi): check the Pi strategy table against the proxy table — correct.

  • What it does: this PR removed STRATEGIES from settings.py, so the old Pi drift guard (a Python test that ran settings.py and read m['STRATEGIES']) fails in CI with a KeyError. The commit deletes that Python test and adds pi-package/strategies_test.go, a Go test that dumps pi_plugin.STRATEGIES with python3 and compares each name's spends flag and cache keys with config.Strategies. No product code changes.
  • The CI-failure claim is right: settings.py no longer defines STRATEGIES, so runpy.run_path(...)['STRATEGIES'] raises KeyError.
  • I verified the guard passes: I ran the test's dump snippet with the local python3. The Pi table (none, auto, 1-ping, 2-ping) matches the proxy table on every key and value, including spends. none compares two empty key sets.
  • The test is wired like its neighbours: package pipackage matches pi_test.go, the dump's relative scripts path matches how TestPiControllerPythonTests already runs python3 from the package directory, and a missing python3 is a fatal, not a skip (the comment says a skip would prove nothing).
  • The comparison is sound: same key count plus a per-key marshal compare catches a changed value, a missing key and an extra key on either side (json.Marshal(nil) is null, never a proxy value).
  • The three comment fixes and the one test-message fix name the proxy table where they named the removed Python table. I grepped the repo for other references to a plugin-local STRATEGIES: none left (the bob-plugin constant is that plugin's own, unrelated).

Earlier findings and notes, and their status

  • All blocking findings from rounds 1 and 2: still fixed. The new commit touches no product code path.
  • My round-3 non-blocking notes: unchanged, still accepted (the local-plan cache_strategy= pair; LEGACY_NAME_ALIASES drift; the wip: test url commit title).
  • Reviewer 2's round-3 review (approve, no findings): I checked its four per-commit claims myself in my round-3 review of the same commits. I agree with its verdict and add nothing.

Non-blocking

  • The new guard checks one direction only: every Pi strategy must exist in the proxy table. A strategy the proxy adds and Pi lacks is not caught. The old Python test had the same direction, so this is no loss. Note only.
  • The dump runs python3 -c without -I. It imports only repo files from pi-package/scripts, and TestPiControllerPythonTests already runs python3 the same way. No change asked.

What I checked

  • Last review: round 3, 65d5651406c44b9cd830e14fdfa56b7428e3b7c0, 2026-11-11T05:51:15Z
  • New commits read: 1 — d1ff1e56 test(pi): check the Pi strategy table against the proxy table
  • Read in full: 6 reviews, 1 comment, 0 inline comments (from the three files in my folder)
  • New items since my last review and what I did:
    • Commit d1ff1e56 — read the full diff and every changed file around the changes.
    • Reviewer 2's round-3 review (2026-11-11T05:49:27Z, approve) — new to me this round; its claims cover the same three commits and two merges I verified myself in round 3, so nothing new to check beyond the confirmation above.
    • No new author comment and no inline comments.
  • Ran the new test's python3 dump snippet locally and compared its output with config/strategy.go by hand (Python only; no Go was built or run, live Go tests are not approved).
  • Checked the package name, the relative scripts path and the python3 requirement against the existing pi-package/pi_test.go.
  • Grepped the repo for leftover references to the removed STRATEGIES table in settings.py.
  • Confirmed the PR-wide diff against the base 9d34f00f is the round-3 state plus this one commit (22 files; the only new file is pi-package/strategies_test.go).

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 resumed 2 of 2 4 of 4 d1ff1e5618b6 approve

Verdict: approve

Findings

None. The one new commit is a test move with comment fixes, and it is correct.

The new commit, checked

d1ff1e56 test(pi): check the Pi strategy table against the proxy table — correct.

  • The CI-failure claim is right. The old guard (test_strategies_match_the_claude_code_plugin in pi-package/scripts/test_pi_plugin.py) ran runpy.run_path on settings.py and read m['STRATEGIES']. This PR removed that table, so the test raises KeyError. TestPiControllerPythonTests (pi-package/pi_test.go:12) runs the Python tests in CI, so the branch was red. The commit deletes the test and moves the guard.
  • The new guard is sound. pi-package/strategies_test.go dumps pi_plugin.STRATEGIES with python3 -c and compares each name with config.LookupStrategy. I verified the comparison shape: LookupStrategy exists in config/strategy.go:147 and returns the row with Spends and Cache []StrategyKey. The test checks spends, the key count, then every key's marshalled value. A missing pi key gives json.Marshal(nil) = null, which never equals a proxy value, so a changed value, a missing key and an extra key are all caught.
  • The guard passes today. I ran the test's dump snippet with the local python3 from pi-package/: the Pi table (none, auto, 1-ping, 2-ping) matches the proxy table on every key and value, including spends. none compares two empty key sets. The numbers marshal equal on both sides (0.5, 240, 80000, 3540).
  • The wiring matches its neighbours. Package pipackage, the relative scripts path, and the python3 requirement all match pi_test.go. json and subprocess are still used elsewhere in test_pi_plugin.py, so the removed test leaves no dead imports.
  • No product code changes. The pi_plugin.py and savings.js hunks are comments only. I grepped the repo for references to the removed plugin table (settings.py STRATEGIES, m['STRATEGIES'], the old test name): none left.
  • The PR diff against the base 9d34f00 is the round-3 state plus this one commit (22 files; the only new file is pi-package/strategies_test.go). Nothing unreviewed rides in.

Reviewer 1's round-3 and round-4 reviews, checked

  • Round 3 (approve): their per-commit claims match what I verified myself in my round-3 review of the same commits. I agree and add nothing.
  • Round 4 (approve): their check of d1ff1e56 matches mine above. Their two non-blocking notes (one-direction guard, python3 without -I) are right; I agree with both. The one-direction note is no loss: the old Python test iterated Pi's table only, same direction.

Earlier findings and notes, and their status

  • All blocking findings from rounds 1 and 2: still fixed. This commit touches no product code path.
  • My round-3 non-blocking notes: unchanged and still accepted (the local-plan cache_strategy= pair; the wip: test url commit title).

Non-blocking

  • The new test makes a missing python3 a fatal failure, while its neighbour TestPiControllerPythonTests skips. The comment in the test says a skip would prove nothing, so this is deliberate. Note only.
  • The guard checks one direction: every Pi strategy must exist in the proxy table. A proxy strategy Pi lacks is not caught. The old test had the same direction. Note only.

What I checked

  • Last review: round 3, 65d5651, 2026-11-11T05:49:27Z
  • New commits read: 1 — d1ff1e56 test(pi): check the Pi strategy table against the proxy table
  • Read in full: 6 reviews, 1 comment, 0 inline comments (from the three files in my folder)
  • New items since my last review and what I did:
    • Commit d1ff1e56 — read the full diff and every changed file around the changes.
    • Reviewer 1's round-3 review (2026-11-11T05:51:15Z, approve) — their claims cover the commits I verified myself in round 3; nothing new to check.
    • Reviewer 1's round-4 review (2026-11-11T06:29:48Z, approve) — same commit as mine; I verified each of its claims myself above.
    • No new author comment and no inline comments.
  • Verified LookupStrategy, the Strategy/StrategyKey types and the table rows in config/strategy.go against the test's field use.
  • Ran the test's python3 dump snippet from pi-package/ on this machine and compared its output with the proxy table by hand (Python only; no Go was built or run, live Go tests are not approved).
  • Checked the removed Python test's imports against the rest of test_pi_plugin.py, and grepped the repo for leftover references to the removed STRATEGIES table.
  • Confirmed the PR-wide diff against the base 9d34f00f is the round-3 state plus this one commit.

@amiddavid
amiddavid merged commit 2f61a32 into main Nov 11, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 11, 2026
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]>
amiddavid added a commit that referenced this pull request Nov 12, 2026
…py of the table (#1113)

The Pi package reads the cache strategies from the proxy's table
(`context-guru-proxy strategies`) and keeps no copy, like the Claude
Code (#1055), Codex (#1051), OpenCode and Bob (#1093) plugins.

- STRATEGIES is removed from pi_plugin.py; the TypeScript extension
  gets its list from `configure --list`. The consent question uses the
  proxy's text.
- The probe follows #1055/#1051: a 5-second limit, the scrubbed
  environment, DASHBOARD=0, LISTEN_ADDR=127.0.0.1:0, an empty CONFIG,
  closed stdin and a fresh temp cwd. Bad output gives a clean error.
- Pi offers a strategy only when it serves both providers it routes
  (tagged any, or anthropic and openai). A proxy older than v0.7.1 gets
  the update hint; none always works.
- pi-package/strategies_test.go is gone: Pi has no table to pin.

Behavior change: Pi users. Old: the package used its own table. New: it
reads the proxy's table. With the tag fix (#1115), Pi offers none,
auto, 1-ping and 2-ping on a v0.7.4 proxy. Owner's decisions,
2026-11-11 (issue #1062: no fallback, provider tags, generic texts) and
2026-11-12, in the integrator session: "since Pi is new and there is
no user base, u can just do a, u dont even need to require it. just
assume that this is the defacto" (no version gate; ships with #1115).

Data dependence: none. Row:
docs/data-dependence/features/pi-proxy-check.md.

Fixes #1062.

Reviews: 3 offload review rounds (GLM). Round 3: both approve at
cc6e1bc, which is the PR head. It covers the merge of main (only the
generated docs/data-dependence.md, rebuilt with cmd/gen-datadep) and
the fix for a CI-only failure: the consent question printed an empty
"What it does, from the proxy:" when no proxy binary was found.

Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant