Skip to content

Theme the whole Companion window for the Integrator on screen - #13

Merged
sodre merged 16 commits into
mainfrom
t3/companion-integrator-theming
Nov 18, 2026
Merged

sodre merged 16 commits into
mainfrom
t3/companion-integrator-theming

Conversation

@sodre

@sodre sodre commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Stacked on #11. Implements the approved Companion redesign (prototype v5, "Middle ground" mode) and amends the design record to match.

What changes for the user

  • Whole-app theming. While an Integrator's request, pairing confirmation or detail view is on screen, the whole window takes that Integrator's colours, with its logo, name and copy in the header next to the verified origin chip. Lists, Settings, the empty state and Integrators without a manifest use the Countersign theme (purple #2b0548, green #224805 / dark #a1ca7c).
  • Fixed in every theme: the -_ | countersign plate, the verified origin beside the name, the request facts, warnings and errors (fixed component with an icon), Deny/Approve (fixed labels, Deny first, equal size, Deny outlined), certificate details at full contrast, and the "Now showing a request from …" banner with Approve locked for about 1 s.
  • Tabs: Requests / Integrators / Settings. Requests show one at a time, oldest first, with "N more waiting". A new request opens the Requests tab.
  • Durations: 15 min, 1 h, 8 h and Custom. Presets above maxDuration are disabled. A prominent "Access ends" line, plus a warning when the certificate's own expiry shortens access.
  • Certificates: same-named certificates highlight where their fingerprints first differ, next to a fingerprint pattern.
  • Pairing: a large, grouped code with an accessible label.
  • Integrator details: status, approvals with revoke/retry, devices with This computer flagged, readable security notices, and the branding review (current vs proposed) with Accept new branding and Keep current.
  • In-app dialogs replace every window.confirm.

Implementation

  • src/palette.js (new, shared by main and renderer): OKLCH derivation and WCAG AA clamps, ported from the prototype. Change from the prototype: fit() clamps against every background a colour sits on (for example, muted text on ground, surface and accent-soft), not just one.
  • src/queue.js (new): oldest-first ordering and the head-change rules (lock, banner).
  • theme.js: optional colors.dark: { accent, background }, validated like the other colours. It is part of the normalized theme and the digest. A manifest without it produces the same digest as before, so existing pairings get no spurious review. reviewTheme() and a declinedTheme digest back Keep current: the same proposal is not offered again, but a later change is.
  • main.js and preload.cjs: new keepTheme and appearance IPC. appearance(pairingId | null) only names a pairing. The main process computes the window backgroundColor from that pairing's stored theme and nativeTheme.shouldUseDarkColors, and repaints when nativeTheme updates. The snapshot orders offers oldest first, carries pairing and received, gives the pairing confirmation its theme, and reports self on devices.
  • The renderer applies the palette as CSS custom properties built from validated hex values, under the existing CSP (no new unsafe-*). Theme data still never reaches notifications.

Decisions and deviations

  • This computer is determined locally: the device whose binding matches this pairing's own pairing. No Broker change was needed.
  • Approve lock on every new request, not only on an Integrator switch. Any newly shown request locks Approve for about 1 s, and the banner appears only when the Integrator changes. This covers a request sliding under the cursor from the same Integrator.
  • Logos in the branding review. The logo never appears in the approval content. The review shows small header-band previews of the current and proposed branding, including their logos. Without that, a logo-only change could not be reviewed, which the spec requires.
  • After a decision, a short Approved/Denied panel (as in the prototype) offers Next request · host or View Integrators.
  • Fonts: system font stacks instead of Figtree/Inter/JetBrains Mono. The CSP forbids remote fonts, and I did not bundle font files.
  • The demo manifest (Harbor Ledger) now sets colors.dark to show the field. Lantern Audit sets none, so its dark palette is derived.

Docs

  • Design spec: "Companion branding and notification channels" now describes whole-app theming and the fixed-in-every-theme list, replacing "Render theme inside a bounded presentation area". It also documents colors.dark, Keep current, and the window background following nativeTheme.
  • docs/reference/widget.md, "Brand the Companion prompt": colors.dark, how the palette is derived and clamped, and the fixed list.
  • docs/companion.md: tabs, queue, presets, the switch banner, Integrator details, dialogs, and branding review with Keep current. docs/try.md and docs/develop.md are updated to match.
  • All Companion screenshots were recaptured from the real renderer in light and dark and embedded as #gh-light-mode-only / #gh-dark-mode-only pairs. The README uses <picture>. New shots: branding-none (no manifest), queue-switch, integrators-list, integrator-detail, branding-review and dialog-remove. I looked at every PNG and moved callouts that overlapped content.

Verification

  • pnpm lint and pnpm test pass. New Companion tests in test/theming.test.js:
    • AA clamps over more than 100k pairs, light and dark, with and without colors.dark.
    • Fallback to the Countersign theme when the theme is invalid; fixed colours ignore the manifest.
    • colors.dark validation and digest, including an unchanged digest when it is absent.
    • The Keep-current path through Session.reviewBrand, including stale digests.
    • Queue order and head-change rules.
  • mkdocs build --strict passes.
  • Real runs on Linux ARM64 against the unpacked Companion (electron-builder --dir with the debug native addon):
    • e2e.py --count 2: PASS: revoked access and suppressed automatic retry; selected one of 2 native identities; isolated curl and upstream confirmed 0e8d4d52…
    • e2e.py --count 3: PASS: … selected one of 3 native identities; isolated curl and upstream confirmed 01f38e0d…
    • compose_demo.py --verify: Compose mTLS accepted selected SHA-256 ada43aeb… and Job page shows the fingerprint the site received
  • The selectors changed with the new layout:
    • The pairing code is read from #pairing .code, with spaces removed.
    • The fingerprint is joined from .fp-g, and the tests assert it is 64 characters.
    • Revocation goes through Integrators → the row → Revoke access, with #detail.
    • The final no-retry check now also asserts that the detail view is still showing and that the Requests badge is hidden. A new request would switch tabs and raise the count, so the check is stricter than before.
  • Not verified: dark mode inside the packaged app (the screenshots cover the renderer in both modes), and the main-process backgroundColor repaint on an OS theme switch.

Design reference

🤖 Generated with Claude Code

sodre and others added 15 commits November 18, 2026 01:44
Sequence diagrams: Mermaid measured text with its default font while
drawing DejaVu, so labels overflowed and lifelines struck through them.
Match the measuring font, halo message labels, group steps into labelled
phase bands, drop mirrored actors and trim margins so both diagrams fit
the content column at 1:1.

All diagram colours now come from docs/assets/diagrams/palette.json.
Hand-drawn SVGs use var(--token) only, carry an in-image legend, and
scripts/render_diagrams.py writes a -dark variant of every diagram.
Pages embed both with #gh-light-mode-only/#gh-dark-mode-only, which
GitHub and the Material theme toggle both honour; the handbook CSS no
longer stretches diagrams or paints them white.

Screenshots: raw captures move to screenshots/raw/ (excluded from the
build) and scripts/annotate_screenshots.py draws callouts on the copies
the pages embed. The branding reference gets its own annotated copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The widget now draws a card with the purple Countersign band, a headline
slot and green primary button, using a constructed stylesheet so it also
applies under a strict style-src CSP. Buttons expose button/pair/connect/
push/primary parts, a paired attribute moves the primary emphasis to
Request access, and colours follow the page's color-scheme. The existing
actions/status/launch parts and --countersign-font/--countersign-accent
keep working.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The demo site becomes a fictional 'Harbor Ledger' workspace with its own
harbor-blue palette, light and dark themes and system fonts only (the CSP
stays default-src 'self'). It shows sign-in, pairing, pending (with an
offline warning), approved, ended and device pages from the backend's
existing /api data, beside the Countersign widget.

The backend serves the static map from site-files.js (shared with the
screenshot script), brands its Companion manifest as Harbor Ledger with a
logo, returns the Context details in /api/session, and adds /api/job,
which reads the last curl result that compose_demo.py now records so the
/job page can compare the fingerprint the site received.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scripts/capture_screenshots.mjs drives the real Companion renderer (with a
stubbed preload API) and the demo Integrator page (with fixture /api
responses) in Chromium at 2x with a frozen clock, writes raw captures plus
light/dark variants of the demo shots, and records the boxes of the
elements to highlight in raw/boxes.json. annotate_screenshots.py reads
those boxes instead of hard-coded coordinates. 'pnpm screenshots' runs
both.

Adds access-active, access-ended and job-result shots, embeds dark
variants with the gh-light/dark-mode-only suffixes, drops display from the
screenshot CSS rule so Material can hide the off-theme copy, and updates
alt text, the widget styling reference and the develop guide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After the user approved in the Companion, the demo page switched to
Access approved but the widget kept its Open Companion link and the
status 'Review this request in your Companion.' until a reload. Reset
the widget through its documented adapter replacement when the page
leaves the pending view.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--verify approved the request and compared the Workload's fingerprint,
but never recorded job.json, so the new /api/job route, the result file
mount and the /job page went untested against the real stack. Record the
result as the interactive launcher does and confirm the page shows and
matches the fingerprint the site received.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ended view had its own "Request access again" button next to the
widget's "Request access", and both called the same connect flow. Drop
the page's copy, point the explanation at the widget, and move the
handbook callout to the widget button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The same account can pair several computers with one Integrator, so a
paired widget keeps pairing available but demotes it to a secondary
link (part `link`) after Request access. Update the widget docs, test
and the screenshots that show a paired widget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
While an Integrator's request, pairing confirmation or detail view is
on screen, the window takes that Integrator's colours, derived from its
manifest in OKLCH and clamped to WCAG AA in light and dark. Lists,
Settings and Integrators without a manifest use the Countersign theme.
The countersign plate, verified origin, request facts, warnings,
Deny/Approve, certificate details and the queue-switch banner stay
fixed in every theme.

The window now has Requests, Integrators and Settings tabs. Requests
show one at a time, oldest first, with duration presets, an Access ends
line and highlighted fingerprint differences. Integrator details hold
approvals, devices (flagging this computer), notices and the branding
review, which gains Keep current. In-app dialogs replace window.confirm.
The manifest accepts an optional colors.dark pair, and the main process
follows nativeTheme for the window background.

The design record, Companion guide and widget reference describe the
new layout, and every Companion screenshot now has a dark twin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/assets/screenshots/approval-branding.png
#	docs/assets/screenshots/approval-selected.png
#	docs/assets/screenshots/approval-unselected.png
#	docs/assets/screenshots/branding-alternate.png
#	docs/assets/screenshots/pairing-browser.png
#	docs/assets/screenshots/pairing-companion.png
#	docs/assets/screenshots/raw/approval-selected.png
#	docs/assets/screenshots/raw/approval-unselected.png
#	docs/assets/screenshots/raw/branding-alternate.png
#	docs/assets/screenshots/raw/pairing-browser.png
#	docs/assets/screenshots/raw/pairing-companion.png
#	docs/assets/screenshots/raw/scope-wildcard.png
#	docs/assets/screenshots/raw/widget.png
#	docs/assets/screenshots/scope-wildcard.png
#	docs/assets/screenshots/widget.png
#	docs/develop.md
#	docs/reference/widget.md
#	scripts/annotate_screenshots.py
The Companion mockup the owner approved shows Harbor Ledger in teal
(#0f6b6b on #eef6f4; #5cc8bd on #0f1f1e in dark), but the demo site,
its logo and its branding manifest were still harbor blue. Switch all
three and recapture the screenshots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Harbor Ledger's manifest now uses the approved teal (#0f6b6b on #eef6f4,
dark #5cc8bd on #0f1f1e) and Lantern Audit the mockup's orange (#d9822b
on #fdf6ee). Recapture every screenshot and fix the alt text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copy the source of the two approved prototypes (Companion theming and
the demo Integrator) into docs/specs/mockups with a README that links
the published artifacts, says which mode is the design, and notes that
Harbor Ledger is now teal. The handbook build already skips docs/specs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The README hero pointed at the annotated approval screenshot, whose
callouts its alt text doesn't describe; use the unannotated raw capture.
Give the architecture diagram the same light/dark pair as the handbook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sodre
sodre changed the base branch from t3/restyle-demo-widget-screenshots to main November 18, 2026 08:27
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	README.md
#	docs/assets/screenshots/approval-branding.png
#	docs/assets/screenshots/approval-selected.png
#	docs/assets/screenshots/approval-unselected.png
#	docs/assets/screenshots/branding-alternate.png
#	docs/assets/screenshots/pairing-companion.png
#	docs/assets/screenshots/raw/approval-selected.png
#	docs/assets/screenshots/raw/approval-unselected.png
#	docs/assets/screenshots/raw/boxes.json
#	docs/assets/screenshots/raw/branding-alternate.png
#	docs/assets/screenshots/raw/pairing-companion.png
#	docs/assets/screenshots/raw/scope-wildcard.png
#	docs/assets/screenshots/scope-wildcard.png
#	docs/companion.md
#	docs/develop.md
#	docs/reference/widget.md
#	docs/try.md
#	examples/demo-integrator/site-files.js
#	scripts/annotate_screenshots.py
#	scripts/capture_screenshots.mjs
@sodre
sodre merged commit 1de8a65 into main Nov 18, 2026
32 checks passed
sodre added a commit that referenced this pull request Nov 18, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sodre added a commit that referenced this pull request Nov 21, 2026
…ificate was approved (#39)

Closes #12

## Summary

An Integrator's backend can now read, from the approval status call, when a grant's approved access ends (`expires_at_ms`) and which client certificate the user approved (`certificate`: its `sha256`, the fingerprint the Companion shows, plus its subject, issuer and expiry). A new `approvals/current` call finds a Workload's current approval without creating one, and the demo Integrator uses both to count down to the deadline and check the fingerprint itself.

```diff
 POST /v1/backend/status
 {
   "id": "…", "state": "approved", "ready": true,
+  "expires_at_ms": 1795470000000,
+  "certificate": { "sha256": "c64a4b8b…f00b",
+                   "subject": "CN=Demo user", "issuer": "CN=Countersign demo client-ca",
+                   "not_after_ms": 1826000000000 },
   "upstream_mtls_accepted": true, "ingress_closed_count": 0, "egress_closed_count": 0
 }
+POST /v1/backend/approvals/current   { binding, host }  -> the same view, or 404; never creates
```

```text
status(approval)
  LEFT JOIN approved_grant            # the row outlives the approval's end
  grant row present  -> expires_at_ms, certificate {sha256[, subject, issuer, not_after_ms]}
  no grant row       -> both omitted  # pending, denied, expired/cancelled before approval,
                                      # or the grant record removed by audit retention

demo Integrator
  job.json changes (watchFile, 1 s)  -> pin approvals/current's id for that result
  GET /api/job                       -> { result, approval: status(pinned id) }
  Job page                           -> match if approval.certificate.sha256 == result.fingerprint
```

Choices the ticket left open, decided here:

- **Which states carry the fields.** Approved and replaced approvals carry them, as the ticket asks. So do `expired` and `cancelled` ones that had a grant, because the same grant row describes them.
- **`expires_at_ms` is the approved deadline**, not the effective lease deadline. `docs/reference/api.md` says that a revocation, a renewal or a Gateway lease can end access sooner, and that `state` says whether the grant is still in force.
- **The leaf's names are kept with the grant.** `approved_grant` gains `subject`, `issuer` and `not_after`, added in place on open without bumping `user_version`, so an older Broker can still open the store. A grant recorded before this change reports `{sha256}` only.
- **The names are in encoding order** (`C=US, O=…, CN=…`), as x509-parser prints them, joined with ", ". `api.md` says so.
- **`approvals/current` answers 404 for an unknown host or another Integrator's binding.** It matches the authenticated Integrator, and returns the same view `status` does.
- **CI installs Playwright's Chromium** before `pnpm test`, for the demo's new page tests.

### Extras for the owner

- **The demo Integrator follow-up: a countdown, an automatic fingerprint check, and screenshot fixtures with the new fields.** The ticket's sixth criterion, "Follow-up in the demo Integrator (#11 or later)".
  - [x] Widen #12
  - [ ] A new ticket (recommended: the ticket itself calls it a follow-up, and it is separate demo and screenshot work on top of this API)
  - [ ] Record only
  - Applied: built here after all (criterion 4 was already on #12, so nothing was added to it), reviewed in round 3
- **The optional `certificate.subject`, `issuer` and `not_after_ms`.** The ticket marks them optional: "If keeping them means persisting the chain, ship `sha256` alone first."
  - [x] Widen #12
  - [ ] A new ticket
  - [ ] Record only (recommended: the ticket makes them optional and conditional, and no consumer asks for them yet)
  - Applied: criteria added to #12, reviewed in round 3
- **The Job page compares against the approval the job ran under (round 3, Correctness #13).** The page compared against the approval the browser tab remembered, which the job's own request never gives it. No source settles it.
  - [x] Widen #12
  - [ ] A new ticket
  - [ ] Record only (recommended: the demo's main flow starts its approval from the job's own request)
  - Applied: the owner chose it in the session; criterion 5 added to #12 (`approvals/current`), reviewed in round 4
- **The approval is pinned when the job's result lands (round 4, Correctness #20).** The page looked up the current approval when it opened, not when the job ran, so a renewal in between changed what it compared. No source settles it.
  - [x] Widen #12
  - [ ] A new ticket
  - [ ] Record only (recommended: criterion 5 says "the approval the job ran under")
  - Applied: the owner chose it in the session; criterion 5's wording covers it, reviewed in round 5
- **A job result identical to the last one is not pinned again (round 5, Correctness #28 and #35).** The pin is keyed on `job.json`'s text. A mismatch run under one approval, then a renewal approving the job's certificate and a rerun, writes the same text, so the page keeps comparing against the first approval and still says the fingerprints differ. Criterion 5: "compares against the approval the job ran under". Pinning on the file's mtime as well fixes it, with a unit test for an identical rerun, plus a review round.
  - [x] Widen #12 (recommended: it is a criterion's own words, and the fix is a few lines)
  - [ ] A new ticket
  - [ ] Record only
  - Applied: built here after all (criterion 5 already covers it, so nothing was added to #12): the pin is keyed on the text and the file's mtime, reviewed in round 6

## Evidence

| Criterion | Ticked | Shown by |
|---|---|---|
| The Broker returns `expires_at_ms` and `certificate.sha256` for approvals that have a grant, and omits them for approvals that don't | yes | `status_reports_grant_expiry_and_certificate_once_a_grant_exists`; `authenticated_consent_signing_reconnect_and_revocation` (cancelled) |
| Broker tests cover approved, expired, replaced and pending approvals | yes | `status_reports_grant_expiry_and_certificate_once_a_grant_exists` |
| `docs/reference/api.md` documents the fields | yes | `docs/reference/api.md`, "Read approval status", read by the Spec reviewer in rounds 1, 3 and 4 |
| `certificate` also carries `subject`, `issuer` and `not_after_ms`, kept with the grant | yes | `status_reports_grant_expiry_and_certificate_once_a_grant_exists`; `opening_an_older_store_adds_the_leaf_columns_to_existing_grants` |
| The backend can read the current approval without creating one, so the Job page compares against the approval the job ran under | yes | `examples/demo-integrator/compose_demo.py --verify` (the wiring, live); the four `job-approval.test.js` tests (the pinning); `status_reports_grant_expiry_and_certificate_once_a_grant_exists` (the lookup) |
| Follow-up in the demo Integrator: countdown, automatic compare without the paste box, screenshot fixtures | yes | `the Access approved page counts down to the grant deadline`; `the Job result page compares the fingerprints without a paste box`; `node scripts/capture_screenshots.mjs` |

All six boxes are ticked with `tick-criteria.py`, after the ticket's section heading was renamed from `## Acceptance` to `## Acceptance criteria`.

| Test | Red | Green |
|---|---|---|
| `status_reports_grant_expiry_and_certificate_once_a_grant_exists`: pending omits the fields; approved carries them | With the handler change reverted: `service.rs:707 left: Null right: Object {"sha256": …}` | ok |
| Same test: a denied renewal carries no grant fields | Handler forced to add `certificate` for `denied`: panicked at `service.rs:786` | ok |
| Same test: an approval that expired before anyone approved it carries no grant fields | Handler forced to add `certificate` for a grant-less `expired`: panicked at `service.rs:814` | ok |
| Same test: approved deadline equals the Companion's activation deadline, in whole seconds | Handler adding 1000 ms: panicked at `service.rs:723` | ok |
| Same test: `certificate` names the leaf's subject, issuer and expiry | Before the leaf was persisted: `service.rs:732 left: {"sha256": …} right: {"issuer": "CN=Broker integration test CA", "not_after_ms": 4070908800000, "sha256": …, "subject": "CN=Broker integration test user"}` | ok |
| Same test: a grant recorded before the change reports `{sha256}` only | Handler adding `subject` for it: `service.rs:850 left: {"sha256": …, "subject": Null}` | ok |
| Same test: `approvals/current` finds the approval, and 404s without creating one | With the route removed: panicked at `service.rs:654` | ok |
| Same test: `approvals/current` refuses another Integrator's binding | With the guard removed, the query on the authenticated Integrator alone: `service.rs:803 left: 200 right: 404` | ok |
| `authenticated_consent_signing_reconnect_and_revocation`: a cancelled approval keeps its grant's values | With the handler change reverted: panicked at `service.rs:467` | ok |
| `opening_an_older_store_adds_the_leaf_columns_to_existing_grants` | Before the in-place `ALTER`: panicked at `approvals.rs:489` | ok |
| `the Access approved page counts down to the grant deadline` | Before the countdown: `waiting for locator('#access-ends').getByText('14:30 left')`, timeout | ok |
| `the Job result page compares the fingerprints without a paste box` | Before the automatic compare: `waiting for locator('#match') to be visible`, timeout | ok |
| `the Job result page says when the job has no approved certificate to compare` | Before `#no-compare` existed: failed with a timeout | ok |
| `a job keeps the approval that was current when its result landed`; `a job read before anything noticed it pins the approval current at that read` | With pinning disabled (every read looks up the current approval): `actual: 'B'` | ok |
| `no job, or a Broker that could not answer, leaves nothing pinned for good` | Red only as `ERR_MODULE_NOT_FOUND` before `job-approval.js` existed | ok |
| `a rerun that writes the same result again pins the approval current then` | With the pin keyed on the text alone: `actual: 'A', expected: 'B'` | ok |
| `the image copies every local module the servers import` | Against the Dockerfile before 17a55a6: `+ actual: ['job-approval.js']`; the live run had exited with the integrator container `exited (1)`, and `node -e "import('./job-approval.js')"` in that image printed `ERR_MODULE_NOT_FOUND` | ok |

On 81c52af (17a55a6 changes only the demo's Dockerfile and a test): `cargo test -p countersign-broker`: lib 6, approvals 8, service 4 passed; 0 skipped, 0 failed. `cargo clippy -p countersign-broker --all-targets -- -D warnings` and `cargo fmt --all --check` are clean. `pnpm test` in `examples/demo-integrator` on 17a55a6: 8 passed, 0 skipped, 0 failed; `pnpm lint` is clean. `node scripts/capture_screenshots.mjs` re-rendered `access-active` (light and dark) and `job-result`: the first shows "59:30 left · until …" under the grant row, the second the job's fingerprint beside the approved certificate's, with "Same SHA-256" shown. The Companion formats the fingerprint as lowercase hex (`packages/companion/src/main.js:120`), so the docs' "without its spaces" holds.

`xvfb-run -a .venv/bin/python examples/demo-integrator/compose_demo.py --app packages/companion/dist/linux-arm64-unpacked/countersign-companion --verify` on 17a55a6, with a Companion built from this branch: exit 0, printing `Compose mTLS accepted selected SHA-256 99f4b3e3…5c09` and `Job page matched the fingerprint the site received with the approval`. It paired, approved, ran the job's `curl` through the Gateway (the job's own request started the approval), and opened `/job`, which showed `#job-approved` with the fingerprint and `#match`.

Not run: the Gateway runtime test and the Companion and widget suites, because nothing they cover changed.

## Merge Danger

**Door:** two-way. A revert removes the response fields, the `approvals/current` route and the demo changes. The three `approved_grant` columns stay in any store this Broker opened; the older Broker ignores them.

**Blast Radius:** Integrator backends that read approval status; the demo Integrator.

The merge ships a Broker whose status response has more fields, a new backend route, and an in-place column migration on open (no `user_version` bump). CI gains a Playwright Chromium install step. No flag.

## Reviews

<details>
<summary>Correctness, Standards, Spec and Security, seven rounds: 36 findings, each with its outcome</summary>

**Correctness, round 1**

1. The retention purge deletes `approved_grant` while the approval row can survive, so the fields vanish against the docs' promise. Fixed: `docs/reference/api.md` says the fields are absent once audit retention removes an ended approval's grant record.
2. The docs said every `expired` or `cancelled` approval keeps the fields, but one that ended before a grant has none. Fixed: the docs list those cases as absent.
3. "Access ends then unless a renewal replaces the grant first" was wrong for revocation and certificate revocation. Fixed: the docs say a revocation, a renewal or a Gateway lease can end access sooner, and `state` says whether the grant is still in force.
4. `expires_at_ms` is not the effective lease deadline. Fixed: the docs call it the deadline the user approved; the value stays the grant's deadline, as the ticket asks.
5. The test tolerated 999 ms between the status deadline and the activation deadline. Fixed: it asserts exact equality.
6. No test covered an approval that expired with no grant. Fixed: the test lets a renewal's offer lapse and checks that both fields are absent.
7. The new `approve`/`status` helpers repeat the older revocation test's inline flow. Pushed back: that test fetches by the admit body and runs lease and sign steps between those calls, so moving it onto the helpers is churn outside this ticket.

**Standards, round 1**

8. The test repeats the post-and-decode chain and the renew call. Pushed back: it matches the inline style of every other test in `service.rs`.
9. The query row is a positional 7-tuple. Pushed back: it extends the handler's existing tuple; a struct for one call site adds nothing.
10. The `certificate` binding holds a digest. Fixed: renamed to `certificate_sha256`.
11. The `approve` helper takes a bare `renewal: bool`. Pushed back: two call sites, and the doc comment says what it does.
12. The local `ended` holds seconds, while another test's `ended` holds a state. Fixed: renamed to `expired_at_s`.

**Spec, round 1:** no findings. **Security, round 1:** no findings.

**Correctness, Standards, Spec and Security, round 2** (fixes since f28a87e, pinned df4be77): no findings.

**Correctness, round 3** (the two widenings, df4be77..9eb4f81)

13. The Job page compares against the approval the tab remembers, which the job's own request never gives it, so it shows nothing to compare, or the wrong approval after a renewal. Fixed: widened #12 on the owner's choice; `approvals/current` finds the job's approval (criterion 5), reviewed in round 4. The same round found `compose_demo.py --verify` still filling the removed paste box; fixed to expect `#job-approved` and `#match`.
14. The wording when no approval is tracked. Fixed: `#no-compare` says to approve the request in the Companion and run the job again.
15. The countdown trusts the browser's clock. Pushed back: it is advisory, and the page re-reads the Broker's state every 5 s.
16. A local variable shadows `show`. Fixed: renamed.
17. The page test duplicates the screenshot script's page server. Pushed back: sharing it would tie the test to a docs script CI does not run.
18. Two copies of one fingerprint comparison. Fixed: one `same` computed once.
19. The docs implied RFC 4514 order for `subject` and `issuer`. Fixed: `api.md` says encoding order, joined with ", ".

**Standards, Spec and Security, round 3:** no findings; Spec judged both added criteria met.

**Correctness, round 4** (9eb4f81..d515e6c)

20. The page looks up the current approval when it opens, not when the job ran, so a renewal in between changes what it compares. Fixed: widened #12 on the owner's choice; the Integrator pins the approval when the job's result lands (`job-approval.js`), reviewed in round 5.
21. `approvals/current` checks no permit, and answers 404 where `status` might answer 403. Pushed back: the endpoint takes the backend bearer token like `status`, and 404 for "no current approval" is what the demo and docs rely on.
22. `/api/job` fails outright when the Broker errors. Fixed: a failed lookup gives `approval: null`.
23. An unknown host answers 404 rather than an error naming the host. Pushed back: the host comes from the Integrator's own configuration, and 404 tells the caller no approval exists, which is true.
24. The lookup repeats the approval view's query. Pushed back: both call one `view`; the lookup's own query selects only the ID.
25. The lookup filtered on the caller's Integrator rather than the authenticated one. Fixed: it binds `a.integrator` and refuses a binding for another Integrator (red: `service.rs:803 left: 200 right: 404`).
26. `/api/job` awaits the job file and then the Broker, one after the other. Pushed back: the second needs the first's result to decide whether to pin.
27. The interval's updater is named `tick` like the field that holds it. Pushed back: `page.tick` holds the handle of `tick`, and the pair reads as one thing.

**Standards, Spec and Security, round 4:** no findings; Spec judged criterion 5 met.

**Correctness, round 5** (d515e6c..99dabc2, pinned 99dabc2)

28. A job result whose text equals the last one is never pinned again, so a rerun under a renewal keeps the earlier approval. Fixed: widened #12 on the owner's tick; the pin is keyed on the text and the file's mtime, reviewed in round 6.
29. A failed or absent pin falls back to the approval current at the next read, and a restart loses every pin. Pushed back: the fallback is the documented, tested behaviour (`no job, or a Broker that could not answer, leaves nothing pinned for good`), and the demo keeps all its state in memory by design.
30. The file watcher polls every second, so a read can race the pin. Pushed back: it takes a renewal approved within a second of the job's result landing; `forJob` pins at that read in any case.
31. Two concurrent `pin()` calls are not serialised. Pushed back: both store the same text with the ID the Broker returned milliseconds apart; the last write wins with the same answer.
32. No negative caching while the pinned ID is null. Pushed back: retrying the lookup on the next read is the intended behaviour, and its test asserts it.
33. No test for the Integrator-mismatch guard. Pushed back: the stranger binding in `status_reports_grant_expiry_and_certificate_once_a_grant_exists` (`service.rs:801`) covers it, and it was red with the guard removed.
34. The Integrator is enforced twice, by the guard and the query. Pushed back: the query alone answered 200 for a stranger binding (finding 25's red); the guard is what refuses it.
35. No test for an identical rerun after a renewal. Fixed: `a rerun that writes the same result again pins the approval current then`.
36. No tests for a lookup failure followed by a renewal, or for a restart. Pushed back: both are finding 29's documented fallback.

**Standards, Spec and Security, round 5:** no findings; Spec judged criterion 5 met, wanting evidence from `compose_demo.py --verify`.

**Correctness, Standards, Spec and Security, round 6** (the fix for 28 and 35, 99dabc2..81c52af, pinned 81c52af): no findings. Spec wants evidence from `compose_demo.py --verify`.

**Correctness, Standards, Spec and Security, round 7** (81c52af..17a55a6: the image left out `job-approval.js`, found by the compose run, not by a review): no findings. Spec judged criterion 5 shown by the passing compose run. Security was read in the session: the diff copies one module into the image and adds a test.

</details>

## Tracking

Epic: none
Spec: none
Ticket: #12 Return grant expiry and approved certificate in the approval status response
Flag: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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