Skip to content

feat(hub): export public share links to the isolated reader - #448

Draft
weastler wants to merge 5 commits into
build/hub/newfrom
weastler-hub-public-share-export-ui
Draft

weastler wants to merge 5 commits into
build/hub/newfrom
weastler-hub-public-share-export-ui

Conversation

@weastler

@weastler weastler commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 3611d50d04d3a319d9ab8dba31397f23c03bf9fa

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ All 57 CI checks pass on this revision, including Hub unit, database, controls and extension tests on both Node versions.
↑ 13 domain and 2 route database tests cover copy order, eligibility, retries, revocation, passwords, overtaken writes, recovery, cleanup and legacy isolation.
↑ Local integrated run: Hub exported a real Vite-built proto/* Build and the #438 reader served entry, assets, deep links and password links; revoking one link left the other working.
↑ An independent review's three findings were fixed and covered by tests.
↓ Real Azure Blob permissions and managed identity are untested until PR 3.
↓ Rendered browser playback through the reader was not checked; only HTTP-level checks ran.

Why

ADR 0003 moves public sharing to an isolated read-only reader, which #438 added. Hub still had no way to give that reader anything to serve. This PR lets Hub copy a shared Build into the public export storage, turn the copy on and off, and show the result on the existing Share links page.

What changes

When HUB_PUBLIC_SHARE_ENABLED=true, every new hosted share link is an export: Hub copies the Build's stored files into its own folder in the export container and gives out https://<public-origin>/s/<shareId>. There is still no API between Hub and the reader. Hub writes with its own managed identity, and the reader only reads.

flowchart LR
  user["Hub user"] -- "create, revoke, change password" --> api["Hub API"]
  api --> db[("share_links: state, password hash, revision")]
  api -- "enqueue" --> worker["On-demand worker"]
  worker -- "reads dist files" --> private[("Build artifact storage")]
  worker -- "files, then manifest, then policy" --> exports[("Export container")]
  api -- "revoked or new policy" --> exports
  sweep["Scheduled recovery and cleanup"] --> exports
  reader["Public reader (#438)"] -- "reads" --> exports
  viewer["Link viewer"] --> reader
Loading
  • Eligible Builds only. A link can share only a Build that Hub's private prototype service already serves, because its files were built for that exact path. Other Builds show "This Build can't be shared publicly".
  • One copy per link. The worker writes each file once, then manifest.json, then policy.json last, so a link is never live half-copied. A retry finishes an interrupted copy, and a different object at the same name fails the export. Two links to one Build are two independent copies.
  • States on the page. Each export link shows Preparing, ready, Updating, Failed or Revoking. The page also has an optional password field when creating a link, and a Password control to replace or remove it.
  • Passwords. These are optional and need at least 8 characters. Hub stores and exports only the scrypt hash. Each change rewrites the policy and ends existing password sessions.
  • Revocation. Revoking a link overwrites its policy during the request. If that write fails, the link shows Revoking and the worker keeps retrying. A minute-by-minute recovery job also catches links revoked in bulk, and links whose branch was deleted, became the default branch, or lost its repository. An hourly cleanup deletes copied files of revoked, failed or expired links, but keeps the Hub records. Expiry can't be extended.
  • Settings. Hub refuses a partial configuration. It also refuses to start while its own hostname is a generated azurecontainerapps.io one, or on the same site as the public origin. The exception is HUB_PUBLIC_SHARE_ALLOW_SHARED_SITE=true, which logs a warning and is meant for non-production installations only.
  • Legacy links. Existing ShareLink rows stay on the legacy backend. Hub doesn't copy, convert or redirect them, and the reader never serves them. A database check keeps export data off legacy rows.

hub/docs/share-links.md now documents the export contract, states and jobs. The reader guide no longer says Hub doesn't write exports.

Needed from PR 3: set the five HUB_PUBLIC_SHARE_* settings on Hub's API and both workers, and give their identities create, overwrite, read and delete access on the export container. To keep sharing off, leave every HUB_PUBLIC_SHARE_* setting unset or set HUB_PUBLIC_SHARE_ENABLED=false. Hub refuses the other settings without an explicit HUB_PUBLIC_SHARE_ENABLED.

Known verification gaps:

  • The Azure Blob adapter is covered with a mocked SDK because the repository has no Blob emulator.
  • The integrated check used a filesystem export directory over HTTP with forwarded HTTPS headers. Browser playback through local TLS couldn't be rendered here: the browser canvas rejects a self-signed certificate, and the Playwright fallback has no Chrome installed.
  • The Prototype canvas share dialog still uses its own legacy share API and doesn't get exports yet.

Storybook screenshots

Captured from the candidate's static Storybook build in headless Chromium. Narrow captures are omitted because the page's 390 px clipping is unchanged from the base.

Hub/Pages/Share Links

Hub/Pages/Share Links / Public Exports, light theme, 1280 px wide

Hub/Pages/Share Links / Public Exports, light, 1280 px

Hub/Pages/Share Links / Public Exports, dark theme, 1280 px wide

Hub/Pages/Share Links / Public Exports, dark, 1280 px

Hub/Pages/Share Links / Build Cannot Be Shared, light theme, 1280 px wide

Hub/Pages/Share Links / Build Cannot Be Shared, light, 1280 px

Hub/Pages/Share Links / Build Cannot Be Shared, dark theme, 1280 px wide

Hub/Pages/Share Links / Build Cannot Be Shared, dark, 1280 px

Hub/Features/Share Links/Form

Hub/Features/Share Links/Form / With Password, light theme, 1100 px wide

Hub/Features/Share Links/Form / With Password, light, 1100 px

Hub/Features/Share Links/Form / With Password, dark theme, 1100 px wide

Hub/Features/Share Links/Form / With Password, dark, 1100 px

Hub/Features/Share Links/Item

Hub/Features/Share Links/Item / Public Copy Preparing, light theme, 900 px wide

Hub/Features/Share Links/Item / Public Copy Preparing, light, 900 px

Hub/Features/Share Links/Item / Public Copy Preparing, dark theme, 900 px wide

Hub/Features/Share Links/Item / Public Copy Preparing, dark, 900 px

Hub/Features/Share Links/Item / Password Protected (password control opened by the story), light theme, 900 px wide

Hub/Features/Share Links/Item / Password Protected (password control opened by the story), light, 900 px

Hub/Features/Share Links/Item / Password Protected (password control opened by the story), dark theme, 900 px wide

Hub/Features/Share Links/Item / Password Protected (password control opened by the story), dark, 900 px

Hub/Features/Share Links/Item / Revoking, light theme, 900 px wide

Hub/Features/Share Links/Item / Revoking, light, 900 px

Hub/Features/Share Links/Item / Revoking, dark theme, 900 px wide

Hub/Features/Share Links/Item / Revoking, dark, 900 px

Hub/Features/Share Links/Row

Hub/Features/Share Links/Row / Preparing, light theme, 900 px wide

Hub/Features/Share Links/Row / Preparing, light, 900 px

Hub/Features/Share Links/Row / Preparing, dark theme, 900 px wide

Hub/Features/Share Links/Row / Preparing, dark, 900 px

Hub/Features/Share Links/Row / Updating, light theme, 900 px wide

Hub/Features/Share Links/Row / Updating, light, 900 px

Hub/Features/Share Links/Row / Updating, dark theme, 900 px wide

Hub/Features/Share Links/Row / Updating, dark, 900 px

Hub/Features/Share Links/Row / Expired (changed: muted status text), light theme, 900 px wide

Hub/Features/Share Links/Row / Expired (changed: muted status text), light, 900 px

Hub/Features/Share Links/Row / Expired (changed: muted status text), dark theme, 900 px wide

Hub/Features/Share Links/Row / Expired (changed: muted status text), dark, 900 px

Prototype canvas/Share links page

Prototype canvas/Share links page / Expired Link (changed indirectly through the shared row: muted status text), light theme, 900 px wide

Prototype canvas/Share links page / Expired Link (changed indirectly through the shared row: muted status text), light, 900 px

Prototype canvas/Share links page / Expired Link (changed indirectly through the shared row: muted status text), dark theme, 900 px wide

Prototype canvas/Share links page / Expired Link (changed indirectly through the shared row: muted status text), dark, 900 px

weastler and others added 4 commits November 30, 2026 19:18
Hub copies eligible Builds into public export storage, writes and revokes
their policies, supports optional link passwords, and shows export status
on the Share links page. Legacy share links stay on their backend.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ests

Recovery now revokes export links whose branch was deleted, whose prototype
became a replica, or whose repository was removed, and a copy refuses those
prototypes. A retry keeps the manifest an earlier attempt wrote when only
its start page changed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI adaptive review requested due to automatic review settings December 1, 2026 03:33
The share-links components bundled into the canvas extension changed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical publication races, recovery gaps, and cleanup flaws can leave links accessible under stale access rules and exported files undeleted, while password badges can falsely indicate protection.

8 open issues
2 files not reviewed
  • .github/extensions/replica-prototype/assets/renderer.css: Generated file
  • .github/extensions/replica-prototype/assets/renderer.js: Generated file
What changed in this PR

Connects Hub’s Share links flow to the isolated reader introduced in #438. When enabled, Hub exports eligible Builds to separate storage and issues reader URLs while preserving legacy links.

Changes:

  • Adds export storage, lifecycle records, password policies, revocation, recovery, and cleanup jobs.
  • Extends the Share links page with export status, eligibility feedback, and password controls.
  • Adds configuration checks, automated coverage, stories, and operating documentation.
File Description
hub/​test/​public-share-export-storage/​index.ts Adds an in-memory export storage fixture.
hub/​test/​database/​public-share-export-migration/​index.db.test.ts Tests legacy-link migration behavior.
hub/​server/​workers/​recover-public-share-exports/​index.ts Connects scheduled recovery to the queue.
hub/​server/​workers/​index.ts Validates worker export configuration.
hub/​server/​workers/​index.test.ts Tests partial-configuration rejection.
hub/​server/​workers/​export-public-share/​index.ts Runs individual export jobs.
hub/​server/​workers/​delete-public-share-exports/​index.ts Runs scheduled export cleanup.
hub/​server/​workers/​create-public-share-export-dependencies/​index.ts Assembles worker export dependencies.
hub/​server/​workers/​configuration.ts Registers export processors and schedules.
hub/​server/​workers/​configuration.test.ts Tests queue placement and schedules.
hub/​server/​utils/​run-in-batches/​index.ts Adds bounded parallel processing.
hub/​server/​routes/​index.ts Registers password-change requests.
hub/​server/​routes/​build-preview/​share-authorize/​get/​index.test.ts Updates sharing service mocks.
hub/​server/​routes/​api/​security-audits/​present-security-audit/​index.ts Presents password-change audit actors.
hub/​server/​routes/​api/​public-sharing/​respond-public-sharing-error/​index.ts Maps invalid-password errors.
hub/​server/​routes/​api/​public-sharing/​public/​get/​index.ts Requires a legacy preview origin.
hub/​server/​routes/​api/​public-sharing/​public-share-exports.db.test.ts Tests export routes and permissions.
hub/​server/​routes/​api/​public-sharing/​public-preview/​get/​index.ts Guards legacy preview redirects.
hub/​server/​routes/​api/​public-sharing/​present-share-link-export/​index.ts Presents export URLs and status.
hub/​server/​routes/​api/​public-sharing/​links/​post/​index.ts Accepts optional creation passwords.
hub/​server/​routes/​api/​public-sharing/​links/​patch/​index.ts Adds password replacement and removal.
hub/​server/​routes/​api/​public-sharing/​links/​get/​index.ts Returns export status and eligibility.
hub/​server/​routes/​api/​public-sharing/​links/​delete/​index.ts Reports pending public revocation.
hub/​server/​routes/​api/​public-sharing/​index.test.ts Updates sharing route mocks.
hub/​server/​routes/​api/​public-sharing/​create-public-sharing-route-dependencies/​index.ts Composes hosted export services.
hub/​server/​repositories/​security-audits/​record-repository-audit/​index.ts Adds the password-change audit action.
hub/​server/​repositories/​public-sharing/​update-share-link-password/​index.ts Saves hashes and advances policy revisions.
hub/​server/​repositories/​public-sharing/​update-share-link-expirations/​index.ts Tracks shortened export deadlines.
hub/​server/​repositories/​public-sharing/​update-share-link-expirations/​index.db.test.ts Updates deadline test inputs.
hub/​server/​repositories/​public-sharing/​start-revoking-share-links/​index.ts Marks exports for policy revocation.
hub/​server/​repositories/​public-sharing/​revoke-retired-export-links/​index.ts Revokes links whose targets become ineligible.
hub/​server/​repositories/​public-sharing/​mark-public-share-policy-written/​index.ts Confirms published policy revisions.
hub/​server/​repositories/​public-sharing/​mark-public-share-files-deleted/​index.ts Records completed cleanup.
hub/​server/​repositories/​public-sharing/​mark-public-share-export-failed/​index.ts Records permanent export failures.
hub/​server/​repositories/​public-sharing/​list-share-links/​index.ts Keeps unfinished revocations visible.
hub/​server/​repositories/​public-sharing/​list-share-link-expirations/​index.ts Includes backend information for expiry updates.
hub/​server/​repositories/​public-sharing/​list-public-share-export-work/​index.ts Selects unfinished export work.
hub/​server/​repositories/​public-sharing/​list-expired-public-share-exports/​index.ts Selects cleanup candidates.
hub/​server/​repositories/​public-sharing/​find-shareable-build/​index.ts Includes identifiers needed for eligibility.
hub/​server/​repositories/​public-sharing/​find-public-share-export/​index.ts Reads export records and source metadata.
hub/​server/​repositories/​public-sharing/​fail-stale-public-share-exports/​index.ts Times out pending exports.
hub/​server/​repositories/​public-sharing/​create-share-link/​index.ts Creates export-backed share records.
hub/​server/​integrations/​azure-blob/​create-public-share-export-storage/​types.ts Defines the export storage contract.
hub/​server/​integrations/​azure-blob/​create-public-share-export-storage/​index.ts Implements managed-identity Blob operations.
hub/​server/​integrations/​azure-blob/​create-public-share-export-storage/​index.test.ts Tests storage behavior with SDK mocks.
hub/​server/​index.ts Composes and validates API export settings.
hub/​server/​index.test.ts Tests generated-hostname restrictions.
hub/​server/​domains/​public-sharing/​types.ts Extends sharing contracts for exports.
hub/​server/​domains/​public-sharing/​synchronize-public-share-export/​index.ts Coordinates copying and policy publication.
hub/​server/​domains/​public-sharing/​recover-public-share-exports/​index.ts Recovers unfinished exports and revocations.
hub/​server/​domains/​public-sharing/​read-public-share-source/​index.ts Reads and verifies source artifact bytes.
hub/​server/​domains/​public-sharing/​read-public-share-export-settings/​index.ts Validates opt-in, storage, and site isolation.
hub/​server/​domains/​public-sharing/​read-public-share-export-settings/​index.test.ts Tests export configuration rules.
hub/​server/​domains/​public-sharing/​publish-public-share-policy/​index.ts Publishes activation and access policies.
hub/​server/​domains/​public-sharing/​public-share-exports.db.test.ts Covers export lifecycle and legacy isolation.
hub/​server/​domains/​public-sharing/​jobs/​recover-public-share-exports.ts Defines the recovery job.
hub/​server/​domains/​public-sharing/​jobs/​export-public-share.ts Defines export retries and payloads.
hub/​server/​domains/​public-sharing/​jobs/​delete-public-share-exports.ts Defines the cleanup job.
hub/​server/​domains/​public-sharing/​is-public-share-eligible/​index.ts Checks private-preview eligibility.
hub/​server/​domains/​public-sharing/​errors.ts Adds password and export failure types.
hub/​server/​domains/​public-sharing/​enqueue-public-share-export/​index.ts Enqueues recoverable work with stable IDs.
hub/​server/​domains/​public-sharing/​delete-public-share-export-files/​index.ts Deletes ended exports’ stored objects.
hub/​server/​domains/​public-sharing/​create-public-sharing-service/​index.ts Adds export creation and access management.
hub/​server/​domains/​public-sharing/​copy-public-share-files/​index.ts Copies immutable files and manifests.
hub/​server/​create-app/​index.test.ts Updates application sharing mocks.
hub/​schema/​share-link.prisma Adds export lifecycle and policy fields.
hub/​schema/​share-link-export-state.enum.prisma Defines export states.
hub/​schema/​share-link-backend.enum.prisma Distinguishes legacy and export links.
hub/​schema/​migrations/​20261221120000_public_share_exports/​migration.sql Adds export columns, constraints, and index.
hub/​docs/​share-links.md Documents configuration and export lifecycle.
hub/​docs/​public-share-reader.md Documents Hub’s writer integration.
hub/​docs/​background-jobs.md Describes export queues and schedules.
hub/​docs/​architecture.md Includes export storage and workers.
hub/​client/​pages/​share-links-index-page/​types.ts Adds password and eligibility page props.
hub/​client/​pages/​share-links-index-page/​stories.tsx Adds export and ineligible-Build stories.
hub/​client/​pages/​share-links-index-page/​index.tsx Displays eligibility feedback and password controls.
hub/​client/​features/​share-links-form/​types.ts Adds optional password field labels.
hub/​client/​features/​share-links-form/​styles.css Accommodates the password field.
hub/​client/​features/​share-links-form/​stories.tsx Adds a password-enabled form story.
hub/​client/​features/​share-links-form/​index.tsx Renders the creation password input.
hub/​client/​features/​share-link-row/​types.ts Adds status and protection labels.
hub/​client/​features/​share-link-row/​styles.css Styles link status messages.
hub/​client/​features/​share-link-row/​stories.tsx Adds Preparing and Updating stories.
hub/​client/​features/​share-link-row/​index.tsx Displays export status and protection labels.
hub/​client/​features/​share-link-item/​types.ts Defines password-management and availability props.
hub/​client/​features/​share-link-item/​styles.css Styles password management.
hub/​client/​features/​share-link-item/​stories.tsx Adds export-state and password stories.
hub/​client/​features/​share-link-item/​index.tsx Adds password forms and state-aware actions.
hub/​client/​application/​hub/​view-models/​product-share-links-data/​index.ts Maps export responses to page states.
hub/​client/​application/​hub/​routes/​product-share-links/​index.tsx Submits creation and password changes.
hub/​client/​application/​hub/​routes/​expanded-flows.test.tsx Tests export creation and eligibility feedback.
hub/​client/​application/​hub/​product-contracts/​index.ts Extends request and response schemas.
hub/​.env.example Lists optional export settings.

Review effort: Max (adaptive)

...(hasUrl && (status === "ready" || status === "pending")
? { password: { hasPassword, path: passwordPath } }
: {}),
protectedLabel: hasPassword ? "Password protected" : undefined,
try {
return (await readPublicShareSource(artifacts, link)).map(({ sha256 }) => sha256)
} catch (error) {
if (error instanceof PublicShareExportError && error.permanent) return []
Comment on lines +54 to +58
const links = await listExpiredPublicShareExports(
database,
new Date(now.getTime() - settleTime),
batchSize,
)
Comment on lines +41 to +45
const written = await storage.replace(
key,
Buffer.from(JSON.stringify(policy)),
"application/json",
)
Comment on lines +24 to +25
const work = await listPublicShareExportWork(database, now, batchSize)
if (work.length > 0) await enqueue(work.map(({ id }) => id))
Comment on lines +30 to +31
// Expiry is enforced by the policy's deadline; cleanup deletes the files later.
if (!revoked && (link.exportState === "failed" || link.expiresAt <= new Date())) return
filesDeletedAt: null,
createdAt: { lte: createdBefore },
},
data: { exportState: "failed" },
Comment on lines +28 to +31
const live = hasUrl && (status === "ready" || status === "updating")
return {
...(statusLabel ? { statusLabel } : {}),
...(live ? {} : { unavailable: true }),
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.

2 participants