Skip to content

feat(portal): add patch management confirmations - #269

Merged
allisonmahmood merged 2 commits into
mainfrom
portal/256-confirmation-pages
Sep 16, 2026
Merged

allisonmahmood merged 2 commits into
mainfrom
portal/256-confirmation-pages

Conversation

@allisonmahmood

Copy link
Copy Markdown
Owner

Owners and admins could reach the management links but could not complete retire, delete, restore with off sources, or reassignment in the portal.

Adds the four pages on the shared confirmation component, with dependant acknowledgements, typed-name deletion, source warnings and an active-member picker. Stale forms refuse without changing the patch; reassignment checks the expected owner under the existing row lock. Updates the product docs and glossaries.

Stacked on portal/255-portal-index-card, which is this PR's base branch. This diff contains only the confirmation-page work.

Closes #256.

Verification

  • All 34 portal socket tests, workspace typecheck and lint pass.
  • Browser exercised all four actions and a 390px layout without horizontal overflow.
  • Full suite: 898 passed, 13 failed in two untouched files. All 13 failures passed a targeted rerun without overlapping builds. A broader isolation run and the temporary browser runner's teardown timed out.
  • Standards and spec reviews completed; accepted findings fixed.

Implemented with GPT-6 Astra in Oh My Pi.

@github-actions github-actions Bot added area:server Touches the server area area:docs Touches the docs area size:l 501-1,000 changed lines labels Sep 15, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Astra review

Reviewed 92514b2 with git diff origin/portal/255-portal-index-card...HEAD, against issue #256 and its linked decisions. One pass, no subagents. Only merge blockers considered.

Standards

No blocking method or YAGNI findings. The change reuses the shared confirmation components and existing Patches lifecycle operations. The expected-owner check belongs in the existing reassignment transaction; no new service or framework is needed or introduced.

Spec

No blocking intent findings. The four confirmation flows cover the specified permissions, acknowledgement-to-force mapping, typed-name deletion, source warnings, active-member filtering and stale-owner refusal. Reassignment remains repeatable and choosing the current owner preserves the stamps. The requested product and glossary updates are present.

Verification: pnpm exec vitest run packages/portal/src/PortalPages.test.ts passed all 34 tests.

Summary: Standards 0 blocking findings; Spec 0 blocking findings. No merge blocker on either axis.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Code review (PR 269 vs #256)

Two-axis review against origin/portal/255-portal-index-card (573a862...92514b2), plus method, YAGNI, and surface checks. Spec source is #256 (parent #247 §9 / §4).

Standards

No Effect service findings. Patches.reassign's optional expectedOwnerUserId matches existing expected-* preconditions; StaleAction was already on LifecycleError. Portal acquires Patches.Patches / Users.Users from the environment and uses Effect.catchTags.

No hard UI-consistency findings. Confirmation pages go through pageResponse (app shell), compose confirmation-form|consequence|list|acknowledgement|actions plus shared field* / btn* classes, and add no page CSS.

Judgement — .agents/skills/ui-consistency/SKILL.md (supporting text vs field-hint): every reassign radio repeats the same policy as a field-hint (packages/portal/src/render.ts ~430). That copy is page-level guidance (supporting-text); confirmation-consequence already states the act. Drop the per-row hints or use one supporting line.

Judgement — same spec (field associations): owner radios live in ul.confirmation-list with aria-label, not role="radiogroup" as scopeForm does. Native name="user" still groups them.

Judgement smells

  • Mysterious Name — local query is the serialized query string, shadowing input.query (the member filter) in render.ts ~358–362.
  • Duplicated Code — retire and live-delete both splice confirmationDependants(groups) plus the same ack sentence (render.ts 375–376 and 386–389).
  • Data Clumps — renderConfirmation takes one optional bag (members, query, submittedName, nameError, selectedOwnerId, acknowledged) for four different pages rather than a union on action. YAGNI can leave it.

Repeated action switches (render vs post) are the same shape; repo YAGNI overrides extracting a strategy table.

Spec

The four confirmation routes, ack→force mapping, ticket-8 stale 409s, and glossary/product-section surfaces are in place. Tests cover owner/admin/member, dependants on/off, delete-from-retired, restore redirect vs off-source list, reassign deactivated/stale owner, and ack=1 vs ack=on.

(a) Missing or partial

Typed-name copy is only partial. Spec: a typed-name miss redisplays with "Type name to confirm. Nothing was done." PortalPages.ts interpolates the raw name as a field-error (Type exact-delete-name to confirm…) with no <code> (dependant lines on the same pages use <code>). Test keeps a mismatched typed delete name escaped only checks 422, escaped value, and aria-invalid — not that sentence.

(b) Scope creep

GET of an inapplicable confirmation is 409 on the card, not the page. Spec: each GET (the page) and POST (the act). render() maps GET /retire when not live, /delete when deleted, and /restore when live to the card plus This action is not available. Ticket 8’s 409 rule is for stale POSTs. Test refuses a stale retire/delete confirmation also asserts GET /retire after retire → 409 card.

Reassign POST keeps q on the form action. Spec asked only for a plain GET filter.

(c) Implemented but wrong

Invalid reassign target + preserved filter can 409 with an empty picker. Spec: the POST re-checks the target is an active member of the company (else 409 with the picker). After deactivating Alex, POST user=Alex with q=Alex returns 409 and no radios (No active members match this filter). Test filters reassignment to active company members… expects that. Active members stay hidden until the filter is cleared, so the 409 does not present a choosable owner.

Smallest fix: keep q on the GET filter form only; do not copy it onto the POST action. Then an InvalidOwner 409 redisplays the full active picker.

Method

Verdict: method is sound. Seams match the existing expected-* / CLI-omit / ack-as-force pattern. The mess is render() control flow, not the model.

Confirmation chrome is shared (back, h1, consequence, submit/cancel), so one shell is right. The switch-with-lets at render.ts 365–437 is the god: reassign is a GET picker with no ack, stuffed in with retire/delete/restore. Four field builders plus confirmationShell({verb, consequence, fields}) would match the card-act shape without four separate pages.

render() (PortalPages.ts 97–211) now owns index, card, versions, confirmation, 403, 409, and the restore-303, by mutating options and clearing action. A confirmationGet that returns render(name, {status, notice}) on refusal would be the dedicated response.

redisplay vs stale() is the correct split. StaleAction / WrongState belong on the card (ticket 8, product.md). HasDependants / SourcesOff / InvalidOwner belong on the confirmation with a recomputed list.

expectedOwnerUserId?: is the right smallest lock check: same optional-precondition seam as restore/rollback/describe, evaluated inside sql.withTransaction after manageable. Portal-check-then-call is TOCTOU. Making it required would churn CLI callers for no gain.

Users.list on reassign GET only, then client-side q + active-only, is the smallest addition. Typed name stays in the portal; force stays in Patches. Correct boundary.

<title> is still just the patch name on confirmation pages (PortalPages.ts 203). Versions already suffixes " versions". Tabs then match the card while the h1 is Retire {name}?.

YAGNI

Mostly. One shared confirmation component is what #256 asked for. Optional expectedOwnerUserId is not speculative. The GET filter is spec. Reclaim date uses Patches.RECOVERY_WINDOW instead of a second “30”. Disabled empty submit is one attribute, not a framework.

The ...(options.notice === undefined ? {} : { notice }) dance, copied four more times into renderConfirmation, is ritual: renderConfirmation already treats omitted and undefined the same. Pass notice: options.notice.

Tests (~+620) mostly map to Done-when. The restore case cartesian-products 2 states × 2 viewers × GET+POST over the same HTML cluster; one HTML blob per state would do.

Surfaces (hit every surface)

Applied: no wire/CLI/API.md change needed (reassign is portal-only). Reverse states are there (repeatable reassign, Restore on the card, Cancel, live-source restore 303s to the card). Portal/Patches glossaries and the later docs/product.md sections moved confirmation pages to built.

Misses:

  • CONTEXT-MAP.md still says “Destructive confirmation pages and deactivation/reactivation pick pages remain future work.” Confirmations are built; pick pages are not.
  • docs/product.md Built today lede still lists “destructive portal confirmations” among the things that are not built, which now contradicts the portal/lifecycle/admin sections this PR updated.

Issue 256 named those glossary/product surfaces; it did not name CONTEXT-MAP.md or the lede. Both still tell the next agent the pages do not exist.

Tests vs Done-when

Owner/admin/member, ±dependants, delete-from-retired clock, restore redirect vs list, reassign deactivated/stale/no-op, ack=1 vs ack=on are covered.

Weak spots, not missing pages: 403s are status-only (no adminRequired vs forbidden copy); typed-name 422 does not assert the specified sentence; live delete GET does not assert the reclaim date; this diff adds no Patches.test.ts case for expectedOwnerUserId (portal stale-owner test covers the seam sequentially, not under a lock race).

Summary

  • Standards: 0 hard violations; 2 UI judgements (per-row field-hint, missing radiogroup); 3 smell judgements. Worst: reassign per-row policy copy using field-hint.
  • Spec: 1 partial (typed-name copy), 2 scope (GET-unavailable → card; q on POST), 1 wrong. Worst: InvalidOwner 409 with q preserved can render an empty picker instead of the active-member picker.

@allisonmahmood

allisonmahmood commented Sep 15, 2026 •

Copy link
Copy Markdown
Owner Author

Addressed the reviews in 9438a39. Read both conversation reviews, the Reviews tab and the inline-comment API. There were no review bodies or inline findings.

Fixed

  • Invalid-owner recovery and q on POST. Reassignment forms no longer copy the GET member filter onto their POST action. The server ignores q on POSTs too, so older forms cannot preserve a filter that hides every eligible owner. A rejected deactivated, foreign-company or missing target now returns the full active-member picker. Updated the existing socket regression to require eligible choices and prove a subsequent reassignment succeeds.
  • Radio-group semantics. Added a named radiogroup around the existing list, preserving list semantics, native radios and their associated consequence hints.
  • Confirmation document titles. Titles now distinguish the action from the patch card.
  • Local query ambiguity and optional-field spreads. Reused cardPath for the POST URL, removing the second serialized query variable and unnecessary URL construction. Passed the confirmation renderer's optional values directly; the project does not enable exactOptionalPropertyTypes.
  • Stale product descriptions. Corrected both the Portal entry in CONTEXT-MAP.md and the docs/product.md Built today introduction. Confirmation pages are built; deactivation/reactivation pick pages remain future work.

Kept as is

  • Typed-name copy. The response already says Type <patch name> to confirm. Nothing was done. The browser confirmed that exact sentence, status 422 and preservation of the incorrect input. The spec's Markdown backticks do not establish an HTML <code> requirement, so no markup or wording-only assertion was added.
  • Per-member field-hint consequences. Issue feat(portal): the confirmation pages: retire, delete, restore, reassign #256 explicitly asks for the named member's consequence. Each hint describes that radio's selection and is linked with aria-describedby; it is not unassociated page-level guidance.
  • Unavailable GET actions returning the current card with 409. These prevent offering retire on an off patch, delete on an already deleted patch, or restore on a live patch. They match the state applicability in Portal: finding and managing patches in the deployed stage #247 §3. GET restore with live sources still redirects to the card as required; stale POSTs retain their separate actor-aware 409 behavior.
  • Shared renderer, small duplicated acknowledgement expressions and optional input bag. No behavioral defect was identified. Splitting four field builders, a new shell helper and a dedicated GET handler, or introducing a union/strategy layer, would add refactoring to this fix without changing the contract.
  • Existing role/state test coverage. Owner/admin and retired/deleted combinations exercise distinct permissions and lifecycle states. I did not add wording-only tests, duplicate the HTTP seam in renderer tests, or add a separate lock-race test solely for coverage. The expected-owner check remains inside the existing transaction after FOR UPDATE OF patches; active-target validation still holds FOR SHARE, and the stale-owner/no-op socket cases remain in place.

Verification

  • All 34 portal socket tests pass. The updated picker regression failed before the fix and passes afterward.
  • Workspace pnpm typecheck and pnpm lint pass.
  • Chromium exercised filtering, selection, deactivation before submission, rejection with both remaining active owners, and successful reassignment to Sam. The accessibility tree exposes New owner as a radio group. Reassignment at 390px has no horizontal overflow; delete mismatch remains 422 with the submitted text retained.
  • The disposable browser scenario's final ownership assertion passed. Its test runner reported an interruption during suite teardown; the runner and temporary files have been removed. This was not a clean runner exit.
  • Final local pnpm test: 910 passed, one 5-second timeout in the untouched packages/integrations/src/postgres/Operations.test.ts. Rerunning that entire suite in isolation passed all 8 tests. No timeout or test suppression was added.
  • All eight checks pass on the latest commit 9438a3967dbba43bda50e6050ee3077a96b16505: test (22), test (24), lint including typecheck and formatting, postgres-concurrency, clerk-live, cli-smoke, dependency-review, and label. CI run.
  • GitHub reports MERGEABLE and CLEAN. The stack base has no required-check or protection rules, so there are no additional required checks beyond the configured checks above. No newer review findings or unresolved blockers remain.

No API/CLI contract, migration, company-resource protocol or deactivation-flow change was needed. The PR remains stacked on portal/255-portal-index-card; no merge has been performed.

@allisonmahmood
allisonmahmood force-pushed the portal/255-portal-index-card branch from 573a862 to cd44643 Compare September 16, 2026 16:00
@allisonmahmood
allisonmahmood force-pushed the portal/256-confirmation-pages branch from 9438a39 to 0947073 Compare September 16, 2026 16:00
@allisonmahmood
allisonmahmood force-pushed the portal/255-portal-index-card branch from cd44643 to a8e2b71 Compare September 16, 2026 17:09
Base automatically changed from portal/255-portal-index-card to main September 16, 2026 17:16
Implement #256 with retire, delete, restore and admin reassignment confirmations. Check expected ownership under the patch row lock and preserve stale-action refusals.
@allisonmahmood
allisonmahmood force-pushed the portal/256-confirmation-pages branch from 0947073 to 30898ba Compare September 16, 2026 17:16
@allisonmahmood
allisonmahmood merged commit 89efe91 into main Sep 16, 2026
20 of 22 checks passed
@allisonmahmood
allisonmahmood deleted the portal/256-confirmation-pages branch September 16, 2026 17:54
allisonmahmood added a commit that referenced this pull request Sep 16, 2026
Deactivating a user left admins to retire their patches separately,
without seeing which tools would break. Reactivation had the same gap
for restoring patches.

Company now links to pick pages where admins can keep the patches as
they are, select some, or act on all. Confirmations recompute breakage
for the exact selection, including off-source warnings on restore. User
access changes and selected patch changes commit together or all roll
back. Last-active-admin, company-scoping and same-origin checks remain
in place.

Stacked on #269 (`portal/256-confirmation-pages`). This PR targets that
branch, not `main`.

Closes #257.

## Verification
- `pnpm test --maxWorkers=2`: 925 tests passed across 80 files.
- `pnpm typecheck` and `pnpm lint` passed.
- Browser-verified desktop and mobile selection, confirmation,
deactivation and reactivation flows.
- Standards and specification reviews completed with no blocking
findings.

Implemented with GPT-6 Astra in Oh My Pi.
allisonmahmood added a commit that referenced this pull request Sep 16, 2026
Server configuration tests intermittently exceed their 10-second
subprocess timeout under Node 24 CI load, failing with `expected null to
be 1` before configuration validation finishes. This hit PR #269 twice
in a row.

Raise the subprocess cap to 60 seconds and the Vitest deadline to 75
seconds. A null exit status now reports the signal and configured
timeout. Configuration and credential-safety assertions are unchanged.

This PR is stacked directly on `main` and targets `main`; the branch is
up to date with the latest `origin/main`.

Validation passed:
- `pnpm lint`
- `pnpm typecheck`
- `pnpm exec vitest run apps/server/src/start.test.ts` (9 tests)
- `pnpm test` (899 tests across 80 files)
- Forced-timeout smoke covering all nine diagnostic paths

Standards and spec reviews found no issues.

Implemented with OpenAI GPT-6 Astra in the Oh My Pi coding harness.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs Touches the docs area area:server Touches the server area size:l 501-1,000 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(portal): the confirmation pages: retire, delete, restore, reassign

1 participant