Record a failed re-block as its own re-block job
Some checks are pending
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint,dependency-freshness) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / web-coverage (push) Waiting to run
repo-contract / repo contract (push) Waiting to run

The web poller filed end-of-window re-block failures under the unblock
command with params.phase=re-block, so the web app showed a failed
Unblock job. Add re-block as a job-only command (like restore-backup):
contract, catalog home, icon registry entry. Its ledger word is left for
kuhy's picker.

Todo: 85af719b

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Krzysztof Rudnicki 2026-11-22 17:57:09 +01:00
parent 0c949d399f
commit 5658331478
8 changed files with 22 additions and 12 deletions

View File

@ -6,9 +6,9 @@ the ``store_unblock`` call itself. A failed end-of-window re-block happens in
the daemon with nobody asking, so a background thread fetches those reports
every minute (``store_reports``) and records each as a failed job.
The re-block job is recorded under the ``unblock`` command with
``params.phase = "re-block"``: the web UI knows only catalog commands, and a
new one would need its own icon.
The re-block job is recorded under its own ``re-block`` command, a job-only
name like ``restore-backup``: the web contract and icon registry list it, the
CLI has no such command.
"""
from __future__ import annotations
@ -64,8 +64,7 @@ def record_reblock_failure(report: Mapping[str, object]) -> str:
log=filing_log(report),
)
created_at = datetime.now().astimezone().isoformat()
params = {"phase": "re-block"}
return record_daemon_job("unblock", params, created_at=created_at, outcome=outcome)
return record_daemon_job("re-block", {}, created_at=created_at, outcome=outcome)
def collect_store_reports() -> int:

View File

@ -112,6 +112,7 @@ def test_collect_records_one_failed_reblock_job_per_report(filer: MagicMock) ->
(job,) = list_jobs()
assert job["summary"] == "Store re-block failed: dns"
assert job["state"] == "failed"
assert job["command"] == "re-block"
filer.assert_called_once_with(report)

View File

@ -32,6 +32,8 @@ export type CommandName =
| 'serve'
/** Job spawned by `POST /api/backups/{id}/restore`, not a CLI command. */
| 'restore-backup'
/** Failed end-of-window store re-block the web server records; never started by hand. */
| 're-block'
/** How the UI surfaces a command. */
export type CommandKind =

View File

@ -43,6 +43,7 @@ export const COMMAND_HOME = {
'gaming-unblock': '/gaming',
serve: '/system',
'restore-backup': '/system',
're-block': '/store',
} as const satisfies Record<CommandName, SectionPath>
/** A command's registered icon id (`cmd.<name>`); the compiler proves every command has one. */

View File

@ -48,9 +48,9 @@ describe('icon words cover the whole UI', () => {
expect(hits, `${hits.length} unregistered icon sites`).toEqual([])
})
it('the first 45 registry entries are the answered pass-1 icons, so the picker opens after them', () => {
it('the first 46 registry entries are the pass-1 icons (all answered but cmd.re-block), then the rest', () => {
const ids = ICONS.map((e) => e.id)
expect(ids.slice(0, 45).filter((id) => /^(nav|palette|cmd|job\.state|notice)\./.test(id))).toHaveLength(45)
expect(ids[44]).toBe('notice.danger')
expect(ids.slice(0, 46).filter((id) => /^(nav|palette|cmd|job\.state|notice)\./.test(id))).toHaveLength(46)
expect(ids[45]).toBe('notice.danger')
})
})

View File

@ -35,6 +35,7 @@
"cmd.gaming-reset": { "glyph": "⏪", "spoken": "Gaming reset", "desc": "Runs gaming reset: resets today's gaming counter as root, after a typed phrase and a five-minute countdown.", "words": ["rewind", "reset", "refill"], "alts": ["⏮️", "🔙", "🔂"] },
"cmd.gaming-unblock": { "glyph": "🔌", "spoken": "Gaming unblock", "desc": "Runs gaming unblock: force-releases the playtime bind mounts. It is the root recovery hatch.", "words": ["release", "unplug", "recover"], "alts": ["🪫", "🆘", "🧯"] },
"cmd.serve": { "glyph": "🌐", "spoken": "Serve", "desc": "Restarts this web UI server. It comes back on the current code by itself.", "words": ["server", "web", "restart"], "alts": ["🕸️", "📶", "🔗"] },
"cmd.re-block": { "glyph": "🔒", "spoken": "Re-block", "desc": "The daemon's end-of-window store re-block. It shows up as a job only when its checks failed.", "words": ["reblock", "relock", "close"], "alts": ["🛒🔒", "🚧", "🔐"] },
"cmd.restore-backup": { "glyph": "🗄️", "spoken": "Restore backup", "desc": "Restores a saved state backup after you type its phrase.", "words": ["restore", "backup", "rollback"], "alts": ["💼", "🧳", "📼"] },
"job.state.queued": { "glyph": "⏸️", "spoken": "Queued", "desc": "Job state badge: the job waits to start.", "words": ["queued", "waiting", "pending"], "alts": ["🕒", "⏳", "💤"] },
"job.state.running": { "glyph": "▶️", "spoken": "Running", "desc": "Job state badge: the job is running now.", "words": ["running", "active", "busy"], "alts": ["🏃", "⚡", "🔵"] },

View File

@ -9,13 +9,13 @@ const JOB_STATES: JobState[] = ['queued', 'running', 'waiting_input', 'succeeded
const TONES: Tone[] = ['info', 'success', 'warning', 'danger']
describe('icon registry', () => {
it('registers pass 1 first (8 nav, the palette, 26 commands, 6 job states, 4 tones), then the rest of the UI', () => {
it('registers pass 1 first (8 nav, the palette, 27 commands, 6 job states, 4 tones), then the rest of the UI', () => {
const ids = ICONS.map((e) => e.id)
expect(new Set(ids).size).toBe(ids.length)
const pass1 = /^(nav|palette|cmd|job\.state|notice)\./
expect(ids.slice(0, 8 + 1 + 26 + 6 + 4).every((id) => pass1.test(id))).toBe(true)
expect(ids.slice(8 + 1 + 26 + 6 + 4).some((id) => pass1.test(id))).toBe(false)
expect(ids.length).toBeGreaterThan(45)
expect(ids.slice(0, 8 + 1 + 27 + 6 + 4).every((id) => pass1.test(id))).toBe(true)
expect(ids.slice(8 + 1 + 27 + 6 + 4).some((id) => pass1.test(id))).toBe(false)
expect(ids.length).toBeGreaterThan(46)
for (const n of NAV) expect(isIconId(n.icon)).toBe(true)
expect(isIconId('palette.open')).toBe(true)
for (const name of Object.keys(COMMAND_HOME) as (keyof typeof COMMAND_HOME)[]) {

View File

@ -30,6 +30,12 @@ describe('job view icons', () => {
expect(word(icon)).toBe('Survey')
})
it('a failed end-of-window re-block shows as its own re-block job', async () => {
const { el } = mountJob({ job: { command: 're-block', state: 'failed' } })
await vi.waitFor(() => { expect(el.querySelector('h3 .sr-only')).toHaveTextContent('Re block') })
expect(el.querySelector('h3 [data-icon="cmd.re-block"]')?.textContent).toBe('🔒')
})
it('the phase mark, the log count and the cancel button use their ids', async () => {
useIcons({ 'job.state.running': { word: 'busy' }, 'jobs.log': { word: 'log' }, 'jobs.cancel': { word: 'stop' } })
const { el, send } = mountJob({ job: { state: 'running' }, cancellable: true })