Skip to content

fix(save-more): the session recap check says what it saves, not "not measured yet" (#615) - #683

Merged
amiddavid merged 2 commits into
mainfrom
fix/recap-no-price
Oct 23, 2026
Merged

amiddavid merged 2 commits into
mainfrom
fix/recap-no-price

Conversation

@amiddavid

@amiddavid amiddavid commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The session recap check on the save-more card now says what its fix saves, not "Cost: not measured yet". The recap is one side call that the fix stops, so it needs no price and no attribution. This closes the last open part of #615.

What changed

  • Card: the recap check shows Saves: one small model call each time you come back after a few minutes away. in place of Cost: not measured yet.
  • costly_settings.json: the recap's price has "kind": "avoided_call" and a saves text. The TODO that asked for a request shape is gone.
  • costly.py: a check with kind: avoided_call prints the Saves: line. Every other check is unchanged.
  • dash/costlysettings.go: the comment says the recap has no shape on purpose. No code change: the route still returns measured: false for it.
  • Docs and goldens: docs/plugin/save-more.md (table row and the embedded example) and 3 goldens.
  • The two copies in codex-marketplace/plugins/context-guru/scripts/ are byte-identical to the plugin ones.

Data dependence

No change. The check still reads only the user's own settings, on the user's machine. It is metadata only at every storage level.

How it was tested

  • Python test_costly.py: all pass. The tests now check for the Saves: line, and that the recap never says "not measured yet".
  • Box, -race: ./dash/... targeted costly tests pass. ./context-guru-plugin/... fails only the 2 known box tests (TestInstallRefusesAnUnverifiedDownload, TestInstallReportsPATHFromTheSourceFallbackToo).
  • TestDocsExamplesAreTheGoldens passes: the docs example matches the new golden.
  • gofmt and go vet are clean. go.mod and go.sum are unchanged.

Closes #615.

Merged main after #681 (merge commit, not a rebase: the branch is protected against force-push). The conflicts were in the same card lines #681 touched. Both sides are kept: #681's small-model check (title, cost note, Note line, Go shape, docs row), and this PR's Saves: line, which now replaces only the Cost line for a check with price kind avoided_call. After the merge, Python tests and the costly and golden Go tests pass with -race.

🤖 Generated with Claude Code

…measured yet" (#615)

The recap fix stops one small side call each time the user comes back
after a few minutes away. That saving needs no price and no attribution,
so the check has no price shape on purpose. The card now says
"Saves: one small model call each time you come back after a few minutes
away." in place of "Cost: not measured yet", and the TODO that asked for
a shape is gone.

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 (bob, user of @amiddavid) IBM Bob Shell 1.0.3 offload-review skill, @amiddavid's session fresh 2 of 2 1 of 2 7cd38f55ae31 approve

Verdict: approve

Findings

No blocking issues found.

Non-blocking

None.

What I checked

  • All changed files: Read the full diff covering 11 files across the plugin, Go backend, tests, and documentation.
  • Logic consistency: The new avoided_call mechanism is implemented consistently across both plugin copies (context-guru-plugin and codex-marketplace).
  • Python implementation (costly.py): The lines_for function correctly checks price.get("kind") == "avoided_call" and displays the savings message instead of calling cost_words. The logic is sound.
  • JSON schema (costly_settings.json): The session-recap check now has "kind": "avoided_call" with a clear savings message. The empty shapes array is intentional and correct.
  • Go backend (dash/costlysettings.go): The comment explains why session-recap has no shape. The CostlySettings function correctly handles checks with empty shapes by setting Measured: false and leaving CostUSD as nil.
  • Test coverage (test_costly.py): Tests verify that "Cost: not measured yet" no longer appears for the recap, and "Saves: " appears exactly once. The test for old proxies correctly expects one "Cost: not measured yet" (for betas) and one "Saves: " (for recap).
  • Go test (dash/costlysettings_test.go): TestCostlySettingsUnknownShapeIsNullNotZero verifies that session-recap returns measured=false and cost_usd: null in JSON, which is correct behavior.
  • Sync test: TestCostlyChecksMatchThePluginList ensures the Go CostlyChecks and the plugin's JSON stay synchronized. This test passes with the changes.
  • Golden files: All three golden test files are updated consistently with the new output format.
  • Documentation (docs/plugin/save-more.md): The table correctly states the recap is "not priced" and explains the card shows savings instead of a dollar figure.
  • Fail-open behavior: No changes to error handling. The existing fail-open guarantees remain intact.
  • Data dependence: No change to what data the feature reads or stores.
  • ASD-STE100 style: All new text follows the simple, clear style required by CLAUDE.md.

The change is well-designed: a setting that stops a side call should show what it saves, not a "not measured" placeholder. The implementation is correct, complete, and properly tested.

@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 (bob, user of @amiddavid) IBM Bob Shell 1.0.3 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 2 7cd38f55ae31 approve

Verdict: approve

Findings

No blocking issues found.

Non-blocking

  • The change is well-structured and consistent across all affected files.
  • The new avoided_call kind properly distinguishes settings that prevent a cost rather than incur one.
  • Test coverage is complete, including golden file updates.

What I checked

  • All changed files: Read the complete diff covering 10 files across plugin, proxy, tests, and docs.
  • Logic correctness: The avoided_call check in lines_for() correctly branches before calling cost_words(), preventing "not measured yet" from appearing for the recap setting.
  • Test consistency: All three test methods in test_costly.py were updated correctly:
    • test_cost_in_hindsight_and_not_measured: Now expects "Saves: ..." and counts it once
    • test_old_proxy_shows_settings_with_not_measured: Adjusted count from 2 to 1 (only betas remains unmeasured)
    • Both now verify the "Saves: " string appears exactly once
  • Golden files: All three golden test files updated consistently with the new "Saves: ..." line replacing "Cost: not measured yet"
  • Documentation: docs/plugin/save-more.md table updated to explain the recap is "not priced" with clear reasoning
  • Contract preservation: The Go test TestCostlyChecksMatchThePluginList ensures dash/costlysettings.go and costly_settings.json stay synchronized. The session-recap entry in CostlyChecks has empty Shapes and Also slices, matching the JSON's empty shapes array.
  • Fail-open compliance: The change adds a new branch that displays information differently but does not alter control flow or error handling. If price is missing or malformed, it falls through to the existing cost display path.
  • No data loss: This is a display-only change. No stored data is modified, and no component behavior changes.
  • Security: No credentials, secrets, or user data are exposed. The change only affects how a pre-existing setting is described to the user.
  • Duplication handled correctly: Both context-guru-plugin/ and codex-marketplace/plugins/context-guru/ copies are updated identically, maintaining consistency.
  • ASD-STE100 style: The new "Saves: ..." message is clear, direct, and uses simple words.

Resolve the conflicts with #681 by keeping both sides: main's new
small-model check (its title, cost note and Note line, its Go shape and
its docs row), plus this branch's "Saves:" line for the recap, which
replaces only the Cost line for a check with price kind avoided_call.

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 (bob, user of @amiddavid) IBM Bob Shell 1.0.3 offload-review skill, @amiddavid's session resumed 1 of 2 2 of 2 004a6238f7e8 approve

Verdict: approve

Findings

No blocking issues found.

Non-blocking

  • The merge is clean and well-executed.
  • The new small-model check is comprehensive and properly tested.
  • All integration points between the original change and the new check work correctly.

What I checked

  • Last review: round 1, 7cd38f5, 2026-10-23T12:02:49Z
  • New commits read: 2 commits
    • 004a6238 (merge): Merge origin/main into fix/recap-no-price
    • d722488d (from main): feat(save-more): flag a small model that rejects the free auto-mode check (#680) (#681)
    • Plus e57d4228 (from main): fix(review): say why a backend was skipped (unrelated to this PR)
  • Read in full: 2 reviews (both round 1, both approve), 0 comments, 0 inline comments
  • New items since my last review: The merge commit and the upstream changes from main. No author responses or team comments to address.

Merge correctness

  • Conflict resolution: The merge kept both the original avoided_call logic for session-recap AND the new small-model-rejects-server-check. No conflicts in logic.
  • Original change preserved: The avoided_call check in lines_for() at line 231 is intact and unchanged.
  • Integration verified: The new check's cost_note and note_when features work alongside the existing avoided_call branch without interference.

New small-model check (from PR #681)

  • Detection logic (costly.py lines 119-137): The model_unsupported kind correctly parses Haiku versions using two regex patterns (_HAIKU_NEW and _HAIKU_OLD) and fires only for versions below 5.5. The haiku_version() function handles edge cases (non-strings, non-Haiku models, version-less ids) by returning None.
  • Effective value resolution (lines 154-160): Correctly implements Claude Code's precedence: highest-precedence file wins, then process env. This matches the existing logic for other checks.
  • Multi-key fix (lines 339-457): The new set_env fix kind sets both ANTHROPIC_SMALL_FAST_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL to claude-haiku-5-5. The apply/revert logic groups changes by file and handles multiple keys per file correctly, creating one backup per file and one record per key.
  • Title interpolation (line 227): {model} placeholder is replaced with the actual model names found, making the card message specific.
  • Conditional notes (lines 237-239): The note_when feature shows different messages depending on whether the betas check is also firing. This is correct: the small-model issue matters more when betas is off.
  • Cost note (lines 235-236): Correctly adds a note that these costs are also counted under the betas check, avoiding double-counting confusion.

Go backend integration

  • New shape fields (dash/costlysettings.go lines 28-31): Added Status and SessionHas to CostlyShape. The SessionHas field enables filtering rows by whether their session also contains another shape.
  • Session filtering (lines 124-143): The sessionHasWhere() function correctly builds an EXISTS subquery that checks for another row in the same session, tenant, and time window. The inner shape uses the same column filters as the outer one.
  • Shape matching (lines 104-121): Updated shapeWhere() to take an alias parameter, enabling both outer and inner queries. The Status field is now part of the standard column matching.
  • Check definition (lines 61-69): The new check has one shape with SessionHas pointing to a Haiku 400 row. The comment correctly notes that check 1 (betas) also counts these rows.

Test coverage

  • Python tests (test_costly.py):
    • HaikuVersion class (lines 123-134): Tests 15 model id formats, including edge cases (no version, wrong model, non-strings).
    • SmallModel class (lines 137-294): 18 test methods covering detection, precedence, apply/revert with multiple keys, managed settings, process env, and card rendering.
    • All tests verify the fix sets both keys, creates one backup per file, and handles revert correctly.
  • Go tests (dash/costlysettings_test.go):
    • TestCostlySmallModelCountsClassifiersOnlyInSessionsWithAHaiku400 (lines 246-276): Seeds 13 rows across 7 sessions and 2 tenants, verifying that only classifier rows in sessions with a Haiku 400 are counted. Tests tenant isolation, time window filtering, and that the 400 itself is never counted.
    • TestCostlyChecksMatchThePluginList updated (lines 179-192): Now handles Status and SessionHas fields recursively, ensuring Go and JSON stay synchronized.

Documentation

  • docs/plugin/save-more.md (line 252): New table row explains when the check fires, what it fixes, and where the cost comes from. Notes that the plugin does not verify gateway support for Haiku 5.5.
  • docs/data-dependence.md (line 226): Updated to note the new check uses upstream status (400) and session-level filtering. Still metadata-only.

Fail-open and security

  • No new fail paths: The new detection and fix logic follows the same fail-open pattern as existing checks. A parse failure returns None, which is treated as "check does not fire."
  • No credential exposure: The new check reads only ANTHROPIC_SMALL_FAST_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL, which are model names, not secrets.
  • No data loss: Apply creates backups before writing. Revert refuses if the file changed since apply.

ASD-STE100 compliance

All new text (card messages, risk warnings, documentation) uses short sentences, simple words, and active voice. The note_when messages are clear and direct.

The merge is correct, the new check is well-designed and thoroughly tested, and the original avoided_call change remains intact and functional.

@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 (bob, user of @amiddavid) IBM Bob Shell 1.0.3 offload-review skill, @amiddavid's session resumed 2 of 2 2 of 2 004a6238f7e8 approve

Verdict: approve

Findings

No blocking issues found.

Non-blocking

None.

What I checked

  • Last review: round 1, 7cd38f5, 2026-10-23T12:00:34Z
  • New commits read: 2 commits
    • 004a623: Merge origin/main into fix/recap-no-price (merge commit)
    • e57d422: fix(review): say why a backend was skipped (#682)
    • d7224888: feat(save-more): flag a small model that rejects the free auto-mode check (#681)
  • Read in full: 2 reviews, 0 comments, 0 inline comments (from the three files)
  • New items since my last review: The merge commit and two upstream commits from main

Round 1 findings status

Both round 1 reviews (mine and reviewer 1) approved with no findings. No changes were requested.

Merge resolution

The merge commit 004a623 correctly resolves the conflict between this branch's avoided_call mechanism and main's new small-model-rejects-server-check. The resolution:

  • Keeps the avoided_call branch for the recap check (lines 185-187 in costly.py)
  • Adds the new small-model check with its own pricing logic (lines 188-191)
  • The cost_note field from the small-model check is handled by the same code path that handles regular cost display

New small-model check (from #681)

Detection logic (detect function, lines 118-136):

  • The model_unsupported kind correctly parses Haiku versions using two regex patterns (new and old naming)
  • haiku_version() never guesses: returns None for ambiguous cases like "haiku" alone or dated IDs without versions
  • effective_value() correctly implements Claude Code's precedence: highest-precedence file wins, else process env
  • The detection loops through all files and marks every editable file that holds an old Haiku, which is correct for the apply logic

Apply/revert logic (lines 397-490):

  • The new set_env kind is handled alongside remove_env in _get, _put, _target, and _after
  • Groups edits by file path, then processes each file once with all its keys
  • For each file, builds a todo list of (target key, value before) tuples, deduplicating by target
  • Creates one backup per file, not per key
  • Records one entry per key changed, all pointing to the same backup
  • Revert checks each key's current value matches what was written, refuses if any differs
  • Revert restores all keys in a file atomically

Go backend SessionHas (dash/costlysettings.go, lines 124-143):

  • sessionHasWhere builds an EXISTS subquery on a second alias x of the requests table
  • Correctly filters by: same session_id, non-empty session_id, same tenant (unless TenantAll), same time window, keepalive flag
  • The inner shape is matched on alias x, the outer on alias r
  • shapeWhere now takes an alias parameter and prefixes all column names with it
  • The Status field is added to the column map and handled like other optional fields

Test coverage:

  • HaikuVersion test: 13 cases covering both regex patterns, case insensitivity, edge cases, and non-Haiku models
  • SmallModel test class: 15 test methods covering detection, precedence, apply/revert, multiple keys, file grouping, managed settings, process env
  • TestCostlySmallModelCountsClassifiersOnlyInSessionsWithAHaiku400: 16 test rows covering session matching, tenant isolation, time window, status filtering, and the 400 row itself not being counted
  • TestCostlyChecksMatchThePluginList: Updated to handle the new Status and SessionHas fields, including recursive comparison of the inner shape

Integration with avoided_call:

  • The lines_for function checks price.get("kind") == "avoided_call" first, before the cost display path
  • The small-model check uses the regular cost path, so it gets the cost_note line when measured
  • The note_when field is handled for both checks: it displays different text depending on whether the betas check is also firing
  • The firing set is built once and passed to all lines_for calls

Documentation:

  • docs/plugin/save-more.md table row explains the check, its detection, fix, and cost attribution
  • docs/data-dependence.md updated to mention the Status field and SessionHas test
  • The cost note "(also counted under the betas setting while it is on)" is clear

Correctness checks:

  • The where_words deduplication (dict.fromkeys) prevents duplicate source names when multiple files from the same source fire
  • The title template {model} is replaced with the comma-joined list of detected model values
  • The apply logic never adds a key that is not already set in a file (line 416: if before != want and t not in [x[0] for x in todo])
  • The revert logic checks every key before writing anything (lines 471-473)
  • The backup is created before any writes, and the mode is preserved
  • The atomic write pattern is used throughout

Fail-open compliance:

  • Detection errors return None, not an exception
  • Apply and revert return error messages and exit code 1, never raising
  • The Go backend's SessionHas query failure returns an error from costlyPart, which CostlySettings propagates, and the route returns 500 (correct fail-open: the request is not blocked)

No conflicts with round 1 changes:

  • The avoided_call mechanism from round 1 is untouched
  • The new check uses the regular cost path, so it does not interfere
  • Both checks coexist in the same findings list and card

All changes are correct, well-tested, and properly integrated with the existing code.

@amiddavid
amiddavid merged commit cce938c into main Oct 23, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Oct 23, 2026
OsherElhadad pushed a commit that referenced this pull request Oct 25, 2026
…0.2.5)

Both plugins changed in this release, so installed plugins must update.

- Claude Code plugin: 0.6.0 was set in #694. No change here.
- Codex plugin: 0.2.4 to 0.2.5. The vendored cg.py and costly.py
  and one skill changed in #512, #681, #683, #691, #694 and #698.

Assisted-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Osher Elhadad <[email protected]>
amiddavid pushed a commit that referenced this pull request Oct 26, 2026
…0.2.5) (#701)

chore(plugin): bump the plugins for v0.6.0 (Claude Code 0.6.0, Codex 0.2.5)

Both plugins changed in this release, so installed plugins must update.

- Claude Code plugin: 0.6.0 was set in #694. No change here.
- Codex plugin: 0.2.4 to 0.2.5. The vendored cg.py and costly.py
  and one skill changed in #512, #681, #683, #691, #694 and #698.

Assisted-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Osher Elhadad <[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.

feat(save-more): find client settings that cost money, starting with the betas switch that turns off the free auto-mode check

1 participant