Skip to content

feat(serving): explain retired and deleted patch links - #271

Merged
allisonmahmood merged 2 commits into
mainfrom
portal/258-address-notice
Sep 16, 2026
Merged

allisonmahmood merged 2 commits into
mainfrom
portal/258-address-notice

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Sep 15, 2026 •

Copy link
Copy Markdown
Owner

Retired and deleted patch links gave colleagues a 404, with no explanation or way to restore the tool. They now show an app-shell notice with who took it off, when, and the recovery time left. Owners and admins can restore directly or review unavailable sources first; every colleague gets a link to the patch card.

The address, version and content URLs share the notice and private cache policy. Signed-out readers keep the login door for retained patches; foreign, disabled and reclaimed patches stay 404. Overlong portal names use the guard’s route table, and tests verify the server’s sole ownership of / and the catch-all, inherited from the base branch.

Stacked on portal/257-deactivation-pick, which provides the portal routes and shared components. This PR targets that branch, not main.

Closes #258.

Verification

  • Latest commit: f1fe3d1f0f6f55e615dd31b7402465ffe6386c1b. All eight reported checks passed.
  • Complete offline suites on Node 22 and Node 24: 80 files, 935 tests passed each.
  • Formatting, lint/typecheck, Postgres concurrency, live Clerk and CLI smoke passed in CI.
  • Local affected coverage: 103 tests across five files passed. One timeout in the local full suite's unchanged Postgres mapping test passed on an unchanged eight-test file rerun; both full CI suites passed.
  • Browser owner smoke confirmed deleted/retired Restore, the card link, historical content notices, private caching and alias redirects preserving suffix/query. Visually checked the notice and portal card. PNGs under /tmp/foreman/258/shots/: retired-notice-owner-reviewed.png, deleted-notice-owner-reviewed.png, retired-card-owner-reviewed.png.
  • Review dispositions and final evidence. No unresolved blockers.

Hit every surface

  • Wire contract: unchanged API routes and request/response bodies; API docs and shell broker need no changes.
  • CLI: no command, flag, exit-code or JSON changes; CLI docs and release-bound SDK skills unchanged.
  • Dev loop: runner and seed unchanged; global dev-loop skill now explains 404 after reclamation.
  • Vocabulary/product: Hosting and Serving glossaries and product address/lifecycle docs updated.
  • Migrations: none.
  • Company resources: reuses current-version off-source lookup; no new company-database caller, provisioning or lock changes.
  • Served pages: composes the existing app-shell components; notice/card share presentation. Accepted patch HTML policy is unchanged, so upload fixtures are unchanged.
  • Reverse states: notice offers the existing Restore path and card link, including off-source review and recovery deadline handling.
  • Repo layout: no packages added, renamed or removed.

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 commit ba274a94f4f6b85100a03bcc7e05286035446580 against origin/portal/257-deactivation-pick at 596725802695c6bb1b130355f251accdd2a46805, using git diff origin/portal/257-deactivation-pick...HEAD. Spec: #258 and its referenced routing and address-notice decisions. One pass, no subagents; merge blockers only.

Standards

No merge-blocking method or YAGNI findings against the repository, Effect-service and UI-consistency standards.

Spec

No merge-blocking intent findings. The notice, Restore choice based on the current version's sources, reader admission, cache policy and routing requirements are covered. The server already owns the root and catch-all on the supplied base; this change adds coverage rather than another registration.

Verification

All 125 tests passed across six files: ApiGuard.test.ts, Server.test.ts, Serving's Pages.test.ts and render.test.ts, and Patches' Patches.test.ts and PatchesApi.test.ts. These ran against the isolated offline fixtures, not a live instance. No source changes made.

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

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Opus review

First reviewer standing in for grok build. Two-axis review per .claude/skills/code-review, fixed point origin/portal/257-deactivation-pick (three-dot), plus the three extra passes the request asked for: intent against #258, the method, and YAGNI. Standards sources: CLAUDE.md, .agents/skills/effect-service-conventions/SKILL.md, .agents/skills/ui-consistency/SKILL.md. Spec sources: #258, with #247 §11 and §9.

Overall this is a good change. It adds a real feature while removing 29 lines from PortalPages.ts, adds no migration, no wire route, no package and no CSS, and the three structural moves it makes (one route table, findRetained/find, one guard table) are each the smallest shape that works. Nothing below blocks merge; one item wants a decision from you rather than a code change.

Standards

1. apps/server/CONTEXT.md:8-9 was not followed through. ApiGuard.ts:3 now reads "The API and portal-name guard" and classify gained portal-name-too-long (ApiGuard.ts:92, 116-119, 176), but the Hosting glossary still says API guard: "The boundary ahead of every API route: protected requests require a valid machine token before revealing malformed or unknown targets." CLAUDE.md, Hit every surface → Vocabulary and product shape: "A new or renamed concept follows through to the owning CONTEXT.md glossary". packages/serving/CONTEXT.md:47 and docs/product.md:205 were done; this one was missed. Hard, small.

2. The PR never names which Hit every surface entries applied. CLAUDE.md: "Before calling work done, walk this list and say which entries applied", restated by #247 §16: "Every ticket walks Hit every surface and names which entries applied." The Verification section lists test counts instead. Hard, procedural.

3. Duplicated Code — packages/serving/src/address-notice.ts is four copies of packages/portal/src/render.ts. Judgement call, but the largest one here:

address-notice.ts twin in render.ts
:33-35 the retired / deleted note :275-279, byte-for-byte
:36 the State fact :266-270
:23 Math.max(0, Math.ceil((purgeAt - now) / 86_400_000)) :43-44 daysLeft
:28-32, :36 restore form-vs-link, the "Review those sources" hint, "The recovery window has ended…" :224-238 restoreActions

§11 forbids the import ("Serving never imports the portal"); it does not forbid a shared home. @patchy/core already owns html.ts, the component CSS and the escaping helpers — one exported off-patch fragment there, consumed by both, keeps the copy from drifting. This is the finding I would most like addressed.

4. Divergent date rendering — address-notice.ts:17-20 uses DateTime.format(…, { day: "numeric", month: "short", year: "numeric", locale: "en-GB" }); the portal renders the same displayed format with toPartsUtc and a months table (render.ts:27-32). Two implementations of one format, and the new one is ICU/locale-dependent where its twin is not. Judgement call, folds into 3.

5. Readability — address-notice.ts:36 is a single ~950-character return with four nested ternaries; the "recovery window has ended" branch is buried mid-expression. The file it copies names its fragments. Judgement call.

6. apps/server/src/ApiGuard.ts:160-166 hand-lists three Effect.provideService calls to close PortalPages.nameTooLong's environment. RuntimeProduction.ts:28-31 already solves this in one line: yield* Effect.context<Effect.Services<typeof PortalPages.nameTooLong>>() then Effect.provideContext. Prefer the existing pattern; the hand-list has to be edited every time the portal page's requirements move. Judgement call.

7. packages/patches/src/PatchesApi.test.ts:1812 deletes the resolveName assertion where Patches.test.ts:655 and :704 invert theirs. Invert it too — "a deleted name still resolves" is now the interesting fact. Judgement call.

Clean otherwise: service file order, namespace imports, Context.Service shape, Effect.fn naming, Schema.TaggedError usage, component-class composition (every class in address-notice.ts — facts, note, note-warn, note-title, supporting-text, btn btn-primary, btn btn-quiet, actions — comes from packages/core/src/html.ts, with no page-level override, satisfying §12 and ui-consistency), the escaping test, and the patchy-dev-loop and docs/product.md follow-throughs.

Spec

Every obligation in #258 is met. Verified individually: the notice on the address, /~v/<n> and /~content/… for both states (Pages.ts:119-143, Pages.test.ts:211-247); who, when, state, days from purgeAt (address-notice.ts:14-36); form when sources are live, link when off (address-notice.ts:28-32 against Patches.ts:1483-1498, exercised at historical URLs in Pages.test.ts:281-330); the card link for every colleague; Serving asks Patches and does not import the portal (no @patchy/portal in packages/serving/package.json); the door for a signed-out reader including a formerly public patch, 404 for foreign, disabled and reclaimed (Pages.test.ts:248-278); private, no-store; / and /* in one place (Server.ts:199-221); the 414 through the guard's table (ApiGuard.ts:53-80, 254-281). Coverage is NodeHttpServer.layerTest as "Done when" required. ADR-0010 correctly untouched — its door text names wire retirement, not patch states.

Two notes, no missing requirements.

8. The signed-out reader can now enumerate addresses. This is the one item I want your call on. Pages.ts:88-91 answers 404 for an unresolvable address before admission, so an anonymous probe now separates "a retained patch lives here" (401 door) from "nothing here" (404). The branch deliberately retires the old parity guarantee: Pages.test.ts:728 was renamed from "without disclosing whether a company patch exists" to "without disclosing a retained company patch's content", and Server.test.ts:247, :356, :469 swapped their body-comparison assertions (and the comment "neither response may reveal patch existence") for 404.

I read this as spec-forced, not scope creep: a reclaimed patch is gone from the table and so is indistinguishable from a name that never existed, therefore §11's "a reclaimed patch is 404 for everyone" cannot hold while unknown names keep the door. The implementation is honest and the new behaviour is pinned by tests. But it is a product trade — company scope promises "Not the public", and address existence is now public — and nothing records it. Either (a) keep it and say so in docs/product.md § Addresses and the Serving Login door glossary entry, or (b) read "for everyone" as "every admitted reader", give signed-out readers the door for unknown and reclaimed names alike, and restore the parity tests. My recommendation is (a): the leak is small, and doors on nonexistent addresses cost a Clerk round trip per probe. Your call.

9. address-notice.ts:23-26, :36 add the past-deadline state (Restore suppressed, "The recovery window has ended. This patch can no longer be restored."), which neither §11 nor §9 describes. It is not scope creep — a deletion sits past purgeAt for up to an hour before the sweep — and it matches both Patches.restore's refusal (Patches.ts:1917-1921) and the portal card's own handling (render.ts:226-228, same sentence). Only nit: the notice prints "Gone for good in 0 days" as a heading directly above "The recovery window has ended", which reads oddly. The portal replaces the whole block instead.

Intent vs. what was built

#258 asked for two things and got both, with one caveat about credit.

The notice half is faithful and complete, down to details the ticket only gestured at — the form-vs-link choice is computed from the current version's sources even when the reader is at a historical URL (Pages.test.ts:281-330), which is the correct reading of "the current version's sources" and is a detail that was easy to get wrong.

The routing half is half-inherited. "/ and the /* catch-all registered by the server in one place" is already true on the base branch — Server.ts:199-221 came in with 3dd7bfd — so this PR's contribution there is the test (Server.test.ts:80-135), not the wiring. Fine, but the PR body reads as though it did the work.

The 414 half is genuine and better than the ticket asked. The real defect it fixes is not visible in the ticket text: Effect's router defaults to maxParamLength: 100 (node_modules/effect/dist/unstable/http/FindMyWay/internal/router.js:35), so before this change a portal name over 100 characters fell silently through to the catch-all 404 while a 33-character one got 414. Moving the bound into the guard's table makes both 414 and makes the table the single place a new portal route registers its shape. Good.

Method

What I like: the change reached for structure that already existed in three places rather than adding a parallel mechanism. PortalPages.patchRoutes is one array that both the router and the guard read, so a new route cannot leave its too-long target behind — the comment at ApiGuard.ts:49-52 says exactly this and it is true. find becoming a filter over findRetained keeps ~20 existing callers' semantics identical while giving Serving the wider read. The blast radius of the two widened queries is contained: findPatch has one caller (Patches.ts:1150) and resolveName has one non-test caller (Pages.ts:69), both of which now do their own state filtering.

Tests are the right kind: real layers, TestClock for the 30-day window, no mocks, faults injected by layer. Pages.test.ts:164-278 is dense — owner × admin × member × two states × five paths, plus door, foreign, post-purge and disabled in one it.effect — and CLAUDE.md asks for focused tests. I would split the post-purge and disabled-patch blocks out; judgement call, the assertions all earn their place.

10. The one seam this PR creates is untested. address-notice.ts:32 hand-writes <input type="hidden" name="expectedState" value="…"> and posts it to /patches/<name>/restore, whose decoder is PortalPages.ts:49 Schema.Struct({ expectedState: PatchState }). Serving must not import the portal, so this contract exists only as matching string literals in two packages, and no test crosses the boundary: Pages.test.ts mounts Serving alone, PortalPages.test.ts mounts the portal alone, and Server.test.ts — which mounts both — never mentions restore. Rename the field in the portal and the notice's only action breaks with a 422, silently, in every state the notice exists for. One test in apps/server: GET the notice, POST the form it rendered, assert the redirect. That would also cover the /patches/<name> card link. Judgement call in form, but it is the highest-value test missing.

11. Pages.ts:120 — if (HttpServerResponse.isHttpServerResponse(admission)) return admission; is unreachable: state !== "live" forces isPublic false, so :99-107 already returned the door. TypeScript needs some narrowing here, but this copy is weaker than its live twin — it drops withCookies(…, cookies) and patchUrlHeaders. Narrow once above the branch (bind the viewer) rather than repeating a second, divergent guard. Judgement call.

12. Pages.ts:42-49 is now stale. "On every address and content answer, the 404 included: a patch URL is never indexed or handed on as a referrer, whether or not it currently serves" — the notice sets x-robots-tag but takes pageResponse's referrer-policy: same-origin rather than no-referrer (asserted at Pages.test.ts:227). The choice is right, since the restore form needs a same-origin referrer, but CLAUDE.md asks that comments stay in sync; amend the sentence to name the notice's exception.

YAGNI and beauty

Nothing here is built for a future #258 did not ask for. No new migration, no new wire route, no new package, no new component or CSS rule, no configuration, no abstraction with one caller. addressNotice returns exactly the three fields the page renders and no more; patchRoutes carries only what both consumers need. The net effect on PortalPages.ts is −29 lines while gaining the guard's table. That is the shape the repo asks for.

Two places where it is less beautiful than it should be, both already above: the four-way copy of the portal's off-card copy and arithmetic (finding 3), and the 950-character single-expression render (finding 5). Neither is over-building — they are under-factoring, and they are the parts most likely to drift out of sync with the card they were copied from.

One smaller cost: Patches.addressNotice re-reads the patch (Patches.ts:1487) that servePatch already holds in served.value.patch, and re-checks the company that Pages.ts:106 has already enforced, so the notice path runs five queries where three would do. Defensible — the service method should be safe called on its own — but worth naming.

Summary

  • Standards: 7 findings, 2 hard (apps/server/CONTEXT.md glossary; the Hit every surface walk missing from the PR body), 5 judgement calls. Worst: the four-copy duplication of the portal's off-card copy and logic in address-notice.ts.
  • Spec: 0 missing requirements, 2 notes. Worst: the anonymous address-existence oracle at Pages.ts:88-91 — I believe §11 forces it, but it is an undocumented product trade and wants your explicit yes.
  • Method / YAGNI: 3 findings. Worst: the expectedState contract between address-notice.ts:32 and PortalPages.ts:49 crosses a package boundary with no test on either side of it.

Reviewed with Claude Opus 5 (1M context) in Claude Code.

@github-actions github-actions Bot added area:ci CI, shared testing infrastructure, development scripts and tooling area:core Touches the core area labels Sep 15, 2026
@allisonmahmood

allisonmahmood commented Sep 15, 2026 •

Copy link
Copy Markdown
Owner Author

Reviewed both conversation reviews, the Reviews tab and inline review comments. The Reviews tab and inline comments were empty. Fixes are in f1fe3d1.

Fixed

  • Finding 1. Updated the Hosting glossary to include portal-name guarding and its separate admission/rate-limit behavior.
  • Finding 2. Added the full Hit every surface walk to the PR description, including the intentionally unchanged entries.
  • Finding 3. Moved the shared state fact, lifecycle note, countdown, Restore control/hints and recovery-ended message into Core's patch-presentation.ts. Portal and Serving both consume it; Serving still does not import Portal.
  • Finding 4. Both pages now use the same explicit UTC date formatter. The previous notice rendered "1 Sept 2026" while the portal rendered "1 Sep 2026"; the shared formatter and UTC rollover regression remove that drift. Core uses the existing catalog-pinned Effect DateTime API, without a diagnostic suppression or new dependency version.
  • Finding 5. Split the address notice into named fragments instead of the nested single-expression template.
  • Finding 10. Added a real-socket server regression that publishes, retires/deletes, extracts the actual rendered form action and hidden controls, submits them, follows the 303 to the card, follows Open and reads the restored document. It does not hardcode expectedState. Its separate server/database fixture avoids spending the other tests' publish-rate budget.
  • Finding 11. Moved notice rendering inside the already-narrowed admission branch and removed the redundant response return. Alias redirects still follow admission and preserve the suffix/query.
  • Finding 12. Corrected the header comment to name the notice's same-origin referrer-policy exception, which permits the browser Restore POST.

Kept, with reasons

  • Finding 6. Kept explicit Session/Companies/Users acquisition. The Effect service spec requires production construction to acquire dependencies with yield* Service; RuntimeProduction's entrypoint context capture does not override that service convention. Missing requirements still fail typecheck.
  • Finding 7. Kept the deleted-name lookup assertion out of PatchesApi.test.ts. Patches.test.ts covers retained-name resolution; the API test checks the consumer-visible 409 name_taken after deletion and restoration of the same name. Repeating the internal lookup there would not test another API contract.
  • Finding 8. Kept the specified signed-out 401 for retained addresses versus 404 for missing/disabled/reclaimed addresses. Reclamation leaves no row or name, so reclaimed and never-created addresses are indistinguishable. Documented the resulting address-existence disclosure in product Addresses and Serving's Login door glossary. Content remains protected.
  • Finding 9. Kept the decided countdown and expired-recovery behavior. Contrary to the review's comparison, the portal also retains the zero-day lifecycle note; only its Restore action block becomes the recovery-ended message. Both pages now share that presentation, and the deadline test verifies the source-review Restore link and hint disappear.

The existing lifecycle admission matrix stays together because it exercises one patch's retained-to-reclaimed transition across readers and URL forms. The new cross-package form scenario is isolated. The repeated Patches lookup/authorization check stays because addressNotice must enforce its own company, disabled-state and Openability checks rather than trust an earlier caller read. The PR description now explicitly credits the base branch for root/catch-all ownership; this PR adds routing coverage, not that wiring.

Verification

  • Typecheck and lint passed. After isolating the new server fixture, the server typecheck/lint and all 103 focused tests across five files passed.
  • Chromium, offline owner session: deleted and retired Restore buttons reached the live card; the card link worked; an old retired name returned 308 while preserving /~v/1 and its query; current and historical content notices returned 200 with private, no-store, same-origin referrers and no iframe.
  • Visually checked PNGs: /tmp/foreman/258/shots/retired-notice-owner-reviewed.png, deleted-notice-owner-reviewed.png and retired-card-owner-reviewed.png. The disposable instance is stopped and session/CLI fixtures removed.
  • Final CI on f1fe3d1: all eight checks passed. Both Node 22 and Node 24 passed all 935 tests across 80 files. Lint, including formatting and typecheck, Postgres concurrency, live Clerk, CLI smoke, dependency review and labels also passed.
  • Local formatting passed. The local full suite had 934 passes and one five-second timeout in the unchanged Postgres mapping test. Rerunning that entire file unchanged passed all eight tests; both complete CI suites then passed without retries or timeout changes.
  • The stacked base has no configured required-check or review rules. All reported checks are green, GitHub reports MERGEABLE/CLEAN, and no new or edited reviewer feedback, inline comments or reviews arrived after the push. No unresolved blockers; ready to merge into portal/257-deactivation-pick. Not merged.

@allisonmahmood
allisonmahmood force-pushed the portal/257-deactivation-pick branch from 5967258 to fdc8c65 Compare September 16, 2026 16:00
@allisonmahmood
allisonmahmood force-pushed the portal/258-address-notice branch from f1fe3d1 to 719d695 Compare September 16, 2026 16:00
@allisonmahmood
allisonmahmood force-pushed the portal/257-deactivation-pick branch from fdc8c65 to 06ba077 Compare September 16, 2026 17:54
Base automatically changed from portal/257-deactivation-pick to main September 16, 2026 18:02
@allisonmahmood
allisonmahmood force-pushed the portal/258-address-notice branch from 719d695 to c0163e1 Compare September 16, 2026 18:09
@allisonmahmood
allisonmahmood merged commit 5587da3 into main Sep 16, 2026
8 checks passed
@allisonmahmood
allisonmahmood deleted the portal/258-address-notice branch September 16, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:core Touches the core area 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(serving): the address notice for retired and deleted patches; one owner for / and the catch-all

1 participant