openspec(fix-cognito-signin): config-flow tasks verified; hygiene notes
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -198,6 +198,8 @@ When the user corrects your approach, append a one-line rule here before ending
|
||||
- **All five files in `openspec/specs/` fail `openspec validate --specs`** for a missing `## Purpose` section. Pre-existing and repo-wide as of 2026-09-06, so a failing spec validation is not necessarily caused by your change — check whether the error is only the Purpose one before chasing it.
|
||||
- **TODO — own OpenSpec change: persist Cognito-refreshed tokens back to the config entry.** `PerfectDraftApiClient.refresh_access_token()` updates `_access_token`/`_id_token` in memory only, so every HA restart reloads the stale access token and burns a wasted 401-plus-refresh round trip before the first successful poll. Harmless today because the refresh token is what actually gates reauth and Cognito's `REFRESH_TOKEN_AUTH` never issues a new one, so nothing is lost — just wasteful. Deferred out of `fix-reauth-flow` to keep that diff surgical.
|
||||
- **TODO — housekeeping, after `fix-cognito-signin` / `add-keg-48180` ship: take the GitHub token out of the `github` remote URLs** in both this repo and `Hassio-PerfectDraftPro-Component`. Not a leak (never committed; `.git/` is untracked), but `git remote -v` prints it. Order matters: first change `credential.helper` to an **absolute** path (`store --file=/home/rick/Lab/Dev/<repo>/.git/credentials`) — the current relative `.git/credentials` resolves against the worktree root, where `.git` is a file, so pushes from `.worktree/<topic>` only work today because the URL carries the token. Then strip the URL, run `git ls-remote github` from a worktree to prove auth, and update the `AGENTS.md` helper command to the absolute form.
|
||||
- **Config-flow tests run in `.venv-test` (main checkout) on the system Python 3.14** with `pytest-homeassistant-custom-component==0.13.375` (core 2026.10.4). Run them from a worktree as `../../.venv-test/bin/pytest tests/`. Do not pin a harness that needs Python 3.12: there is no 3.12 and no C compiler on the dev host, so old numpy cannot build.
|
||||
- **In Chromium's DevTools console, `copy()` only exists while the typed command is evaluating** — inside a `.then` or after any `await` it is `undefined`. Capture it up front: `(c => promise.then(t => c(t)))(copy)`. Verified 2026-11-07 via CDP `replMode` + `includeCommandLineAPI`.
|
||||
- **`gh` is not installed; use the GitHub REST API with `curl`.** Get the token with `printf 'protocol=https\nhost=github.com\n\n' | git credential fill`. The token is fine-grained: since 2026-11-07 it has Issues and Pull requests read/write in addition to admin/push. A `403 Resource not accessible by personal access token` means a permission is missing on the token, not a bad token.
|
||||
- **TODO — own OpenSpec change + release: remove pour-count-based keg detection** from `PerfectDraftKegFreshnessSensor` in `sensor.py`: trigger (a) `pours == 0 && kegVolume > 5.5 && last_pours != 0`, plus the `_last_pours` field and its restore/exposure/rebaseline. It can false-fire on a power cycle while the keg is above ~92% full, and adds nothing the volume triggers (b/c) and the Mark Keg Changed button don't already cover.
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
|
||||
## 3. Config flow errors
|
||||
|
||||
- [ ] 3.1 In `async_step_token`, map `err.kind` to `token_rejected` / `invalid_credentials` / `invalid_auth`; on `invalid_credentials` re-show the `user` form (setup) or `reauth_confirm` form (reauth) with the error instead of the token form
|
||||
- [ ] 3.2 Pass `description_placeholders={"reason": ...}` on every `async_show_form` for `user`, `reauth_confirm` and `token` (empty string when there is no error)
|
||||
- [x] 3.1 In `async_step_token`, map `err.kind` to `token_rejected` / `invalid_credentials` / `invalid_auth`; on `invalid_credentials` re-show the `user` form (setup) or `reauth_confirm` form (reauth) with the error instead of the token form
|
||||
- [x] 3.2 Pass `description_placeholders={"reason": ...}` on every `async_show_form` for `user`, `reauth_confirm` and `token` (empty string when there is no error)
|
||||
- [x] 3.3 In `strings.json` and `translations/en.json`, reword `invalid_auth` to include `{reason}` and add `invalid_credentials` and `token_rejected`; verify the two files stay identical (`diff`)
|
||||
- [ ] 3.4 Extend `tests/test_config_flow.py`: one test per error key (setup and reauth), asserting the form step, the error key and the `reason` placeholder; update `test_reauth_bad_token_keeps_old_tokens` for the new key; add a check that every `errors["base"]` value in `config_flow.py` exists in both translation files; verify `.venv-test/bin/pytest tests/` passes
|
||||
- [x] 3.4 Extend `tests/test_config_flow.py`: one test per error key (setup and reauth), asserting the form step, the error key and the `reason` placeholder; update `test_reauth_bad_token_keeps_old_tokens` for the new key; add a check that every `errors["base"]` value in `config_flow.py` exists in both translation files; verify `.venv-test/bin/pytest tests/` passes (harness bumped to 0.13.375 / core 2026.10.4, see branch commit)
|
||||
|
||||
## 4. README
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
- [ ] 5.2 Install the branch build on Home Assistant and add the integration from scratch with a fresh README token; confirm the entry is created and sensors populate
|
||||
- [ ] 5.3 With a deliberately wrong password, confirm the flow returns to the credentials form showing `invalid_credentials` and Cognito's reason; with a stale (>2 min) token, confirm `token_rejected` on the token form
|
||||
- [ ] 5.4 Trigger a reauth on the existing entry and confirm it succeeds; if a keg is fitted, also confirm Keg Freshness keeps its countdown and clear that TODO in `PROJECT_HYGIENE.md`
|
||||
- [ ] 5.5 Run the full suite (`.venv-test/bin/pytest tests/` and `python3 -m unittest discover -s tests`) and confirm green
|
||||
- [x] 5.5 Run the full suite (`.venv-test/bin/pytest tests/` and `python3 -m unittest discover -s tests`) and confirm green
|
||||
|
||||
## Workflow follow-up
|
||||
|
||||
|
||||
Reference in New Issue
Block a user