Skip to content

chore(sidekick): remove the dead StandalonePreferences.apply_tokens() - #4474

Merged
dieterolson merged 1 commit into
fix/architecture-guards-always-onfrom
chore/remove-dead-apply-tokens
Aug 14, 2026
Merged

chore(sidekick): remove the dead StandalonePreferences.apply_tokens()#4474
dieterolson merged 1 commit into
fix/architecture-guards-always-onfrom
chore/remove-dead-apply-tokens

Conversation

@dieterolson

Copy link
Copy Markdown
Collaborator

Stacked on #4469base is fix/architecture-guards-always-on, not main. That PR canonicalized this method's import spelling and documented the defect in a .. warning:: block rather than silently "fixing" it, deferring the disposition. This is that follow-up, and it removes the warning block along with the method it describes.

What was wrong

StandalonePreferences.apply_tokens() imported shared.python.theme.sidekick_tokens for COLOR_TOKEN_MAP and DEFAULT_SIDEKICK_TOKENS. That module has never existed in Tools under that spelling or the former bare theme. one, and neither name is defined anywhere in src/, so every call raised ModuleNotFoundError. Zero callers, zero tests.

Why removed rather than reimplemented

  • It is a duplicate, not a capability. The exact algorithm already exists and is importable as sidekick_tokens_from_theme() in UpstreamDrift's src/shared/python/theme/sidekick_tokens.py — the very module this method was written against. That file carries a "canonical changes must be made in the Tools repository" header, but it was never actually synchronized here; that is the root cause. Deleting the broken copy removes a DRY violation rather than a feature.
  • The obvious reimplementation target does not fit the documented contract. sidekick.ui.design_tokens.get_token_dict() returns flat @color_* / @spacing_* / @radius_* QSS placeholders selected by theme name. The docstring specifies the sidekick.color.* namespace mapped from a caller-supplied theme_colors dict. Rebuilding on it would keep the name while changing the meaning, with no consumer to validate against — the "silent fix" fix(ci): run tests/architecture/ guards on every PR, and fix the four they were hiding #4469 deliberately avoided.
  • Theme-token mapping is not a preferences concern. The method never touched self; sidekick/ui/design_tokens.py already owns this.

Public-API contract

tests/sidekick_api_baseline.json is updated. Per the CLAUDE.md policy on removing a public name:

No downstream migration issues filed, deliberately. A name that cannot be called without raising is not in use — removal turns ModuleNotFoundError into AttributeError. Verified no callers in UpstreamDrift or Gasification_Model. UpstreamDrift's tracked shadow copy at src/shared/python/sidekick/standalone/preferences.py is unaffected and still resolves the import locally; vendor/ud-tools picks this change up on the next bump.

The baseline entry was edited in place, not regenerated. Running the documented --regenerate-api-baseline flow is not safe on this branch:

  1. tests/test_sidekick_public_api_stability.py is already red against this branch's base, with 43 unrelated signature drifts across api/, process_calculators/, selected_tab_panel.py, tab_context_menu.py and ui/tools_sidebar/. A regeneration would silently bless all of them.
  2. Its json.dump serializer also reorders every top-level key (__init__.py now sorts before __main__.py) and drops prettier's formatting, producing ~9.3k lines of churn to delete one 18-line block.

The surgical edit yields a 17-line deletion, stays prettier-clean, and the order-independent comparison in the test is unaffected. That baseline staleness is pre-existing and is not addressed here — it deserves its own issue, since it currently makes the documented regeneration workflow a trap.

Verification

Gate Result
tests/unit/sidekick/test_standalone_public_api_baseline.py 10 passed (incl. standalone/preferences.py)
tests/unit/sidekick/test_standalone_runtime.py 7 passed
tests/architecture/ 64 passed
ruff check / ruff format --check @ CI-pinned 0.14.10 clean
prettier@3.1.0 --check on SPEC.md + baseline clean

SPEC.md §12 row added (1.5.7, 2026-08-14).

🤖 Generated with Claude Code

`apply_tokens()` imported `shared.python.theme.sidekick_tokens` for
`COLOR_TOKEN_MAP` and `DEFAULT_SIDEKICK_TOKENS`. That module has never
existed in Tools under that spelling or the former bare `theme.` one, and
neither name is defined anywhere in `src/`, so every call raised
`ModuleNotFoundError`. The method had no callers and no tests here, and
none in UpstreamDrift or Gasification_Model.

The preceding commit canonicalized the import spelling and documented the
defect in a `.. warning::` block rather than silently "fixing" it, leaving
the disposition to be tracked separately. This is that follow-up.

Removed rather than reimplemented, for three reasons:

- It is a duplicate, not a capability. The exact algorithm already exists
  and is importable as `sidekick_tokens_from_theme()` in UpstreamDrift's
  `src/shared/python/theme/sidekick_tokens.py` — the module `apply_tokens()`
  was written against, which was never synchronized into Tools despite that
  file's own "canonical changes must be made in the Tools repository"
  header. Deleting the broken copy removes a DRY violation.

- The obvious reimplementation target does not fit the documented contract.
  `sidekick.ui.design_tokens.get_token_dict()` returns flat `@color_*` /
  `@spacing_*` / `@radius_*` QSS placeholders selected by theme *name*; the
  docstring specifies the `sidekick.color.*` namespace mapped from a
  caller-supplied `theme_colors` dict. Rebuilding on it would keep the name
  while changing the meaning, with no consumer to validate against.

- Theme-token mapping is not a preferences concern. The method never
  touched `self`, and `sidekick/ui/design_tokens.py` already owns this.

Not a downstream break: a name that cannot be called without raising is
not in use. Removal turns `ModuleNotFoundError` into `AttributeError`.
UpstreamDrift's tracked shadow copy at
`src/shared/python/sidekick/standalone/preferences.py` is unaffected and
still resolves the import locally; `vendor/ud-tools` picks this up on the
next bump.

The `tests/sidekick_api_baseline.json` entry was edited in place instead of
regenerated via `--regenerate-api-baseline`. Regeneration is not safe here:
`tests/test_sidekick_public_api_stability.py` is already red against this
branch's base with 43 unrelated signature drifts across `api/`,
`process_calculators/`, `selected_tab_panel.py`, `tab_context_menu.py` and
`ui/tools_sidebar/`, which a regeneration would silently bless, and its
`json.dump` serializer also reorders every top-level key (~9.3k lines of
churn). That staleness is pre-existing and left untouched.

Verified: `tests/unit/sidekick/test_standalone_public_api_baseline.py`
(10 passed, `standalone/preferences.py` included),
`tests/unit/sidekick/test_standalone_runtime.py` (7 passed),
`tests/architecture/` (64 passed), and `ruff check` / `ruff format --check`
at the CI-pinned 0.14.10.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

Tools/SPEC.md

Line 1733 in 0e054cb

| 2026-08-14 | 1.5.7 | chore(sidekick): remove the dead `StandalonePreferences.apply_tokens()` method and its `tests/sidekick_api_baseline.json` entry, completing the defect deferred by the preceding row. The method imported `shared.python.theme.sidekick_tokens`, which has never existed in this repo under that spelling or the former bare `theme.` one, so every call raised `ModuleNotFoundError`; it had no callers and no tests in Tools, and none in UpstreamDrift or Gasification_Model. Its algorithm is already provided, and importable, by `sidekick_tokens_from_theme()` in UpstreamDrift's `src/shared/python/theme/sidekick_tokens.py`, so this removes a broken duplicate rather than a capability, and no downstream migration is required — an unreachable name becomes `AttributeError` instead of `ModuleNotFoundError`. The baseline entry was edited in place rather than regenerated with `--regenerate-api-baseline`: `tests/test_sidekick_public_api_stability.py` is red against `main` with 43 unrelated signature drifts that a full regeneration would silently bless, and its serializer also reorders every top-level key. That staleness remains open and is not addressed here. |

P1 Badge Preserve the public method through a deprecation cycle

This deliberately removes a baseline-advertised public method without the deprecation path or downstream coordination required by CLAUDE.md:78 and CLAUDE.md:87-96. When a consumer updates to this revision, accessing StandalonePreferences.apply_tokens changes immediately to AttributeError; editing the baseline merely prevents the stability test from detecting that break. Keep a deprecated compatibility shim for at least one minor release, coordinate the downstream migrations, and place the shared token mapping in Tools rather than leaving its implementation only downstream.

AGENTS.md reference: AGENTS.md:L122-L127

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dieterolson
dieterolson merged commit 1d3d7ea into fix/architecture-guards-always-on Aug 14, 2026
5 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant