Skip to content

Read publications from a local directory during development - #6

Merged
anth-volk merged 2 commits into
feat/immutable-run-viewerfrom
feat/local-publication-directory
Oct 14, 2026
Merged

anth-volk merged 2 commits into
feat/immutable-run-viewerfrom
feat/local-publication-directory

Conversation

@anth-volk

Copy link
Copy Markdown
Contributor

Fixes #5

Stacked on #1.

Summary

  • Add MICROCOSM_RUNS_LOCAL_DIR. It points at a folder holding Microcosm publication bundles: each is an orrery.upload.json inventory plus the files it lists, either in that folder or one subfolder down.
  • With the variable set, /api/runs/[id] and /runs/[id]/[filename] read from disk instead of Vercel Blob. Every file is checked for size, SHA-256, JSON, the Orrery parser and source references, the same checks publishing runs. Local responses are sent with Cache-Control: no-store.
  • Only files listed in the inventory are served. Anything else, such as a population H5 file in the same folder, returns 404.
  • The viewer accepts a same-origin graph URL only when it exactly matches /runs/<id>/graph.orrery.json. Every other graph URL must still be a Vercel Blob HTTPS URL.
  • Production servers refuse the setting (503 local_publications_disabled). Uploads and publishing still go to Blob.
  • Local file URLs have no trailing slash, because Next redirects paths that end in a file extension.
  • Add a README section, "Viewing local Microcosm output".

Testing

  • bun test: 34 tests pass, including new tests in tests/local.test.ts and tests/viewer.test.ts.
  • Format, lint, typecheck and production build all pass.
  • Ran the dev server against a synthetic UK build bundle (19 files). Metadata, the graph (345,358 bytes), an evidence file and the run page each returned 200, and an unlisted H5 file returned 404.

🤖 Generated with Claude Code

MICROCOSM_RUNS_LOCAL_DIR points the metadata and file routes at preserved
Microcosm publication directories instead of Blob storage, applying the same
size, digest, JSON, Orrery and source-reference checks as publication. The
viewer accepts the graph from this app's own route only for that exact path.
Only inventory-listed files are served, writes still use Blob, and a
production server refuses the setting.

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

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
microcosm-runs Ready Ready Preview Oct 14, 2026 9:14pm UTC

Request Review

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk marked this pull request as ready for review October 14, 2026 21:14
@anth-volk
anth-volk merged commit 70ee820 into feat/immutable-run-viewer Oct 14, 2026
6 checks passed

This branch was successfully deployed

1 active deployment
Preview — 628de1a5 Deployed Oct 14, 2026 by vercel[bot]
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