Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,29 @@ It loads published graph JSON directly from Vercel Blob, verifies its digest,
and keeps selection/filter state in linkable URL fragments. It does not embed
generated HTML or accept population datasets.

The provider's `/browser` package owns bounded document downloads, metadata and
digest validation, and Orrery parsing. Its `/server` package reads completed
publication records and resolves only listed evidence through this app's storage
adapter. The app retains Next routes, the React component, URL state, collector
authorization, immutable writes and Vercel Blob credentials. It does not start a
Python service or move the calibration dashboard's telemetry.

## Provider package

The app depends on one exact npm release of
`@policyengine/microcosm-provider-orrery`, which PolicyEngine/microcosm-emitter
publishes automatically on every merge to its `main`. The package contains
compiled JavaScript and declarations, so the app needs no transpilation or
resolver override for it. To adopt a new release, change the exact version,
regenerate `bun.lock` and rerun every check below.

No new environment variables, secrets, stores or endpoints are introduced by this
migration. Existing provisioning remains unchanged. Provider contract and browser
reader tests live in the provider repository; this app retains its own HTTP,
write-service, authorization, URL-state and provisioning tests using synthetic
data and in-memory storage. Neither repository adds a test of a Microcosm build
against the runs app.

## Publication API

1. POST a version-1 file inventory to `/api/uploads/` with a short-lived collector
Expand Down
2 changes: 1 addition & 1 deletion app/runs/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { publicationId } from "@/lib/contract";
import { publicationId } from "@policyengine/microcosm-provider-orrery/contract";
import RunViewer from "@/components/RunViewer";
import { notFound } from "next/navigation";
export default async function Page({
Expand Down
3 changes: 3 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions changelog.d/provider-graph-readers.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Read and validate graph publications with the `@policyengine/microcosm-provider-orrery` package (0.2.1) instead of a copy of its contract and readers in this app. The viewer, routes and publication behaviour are unchanged.
2 changes: 1 addition & 1 deletion components/RunViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type GraphDocument,
} from "@axiom-foundation/orrery";
import { Orrery } from "@axiom-foundation/orrery/react";
import { loadDocument } from "@/lib/viewer";
import { loadDocument } from "@policyengine/microcosm-provider-orrery/browser";

function subscribe(callback: () => void) {
window.addEventListener("hashchange", callback);
Expand Down
6 changes: 5 additions & 1 deletion lib/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { ApiError, inventoryDigest, type Inventory } from "./contract";
import {
ApiError,
type Inventory,
} from "@policyengine/microcosm-provider-orrery/contract";
import { inventoryDigest } from "@policyengine/microcosm-provider-orrery/server";
import type { Fetcher } from "./net";

export const PRODUCTION_COLLECTOR_ORIGIN =
Expand Down
115 changes: 0 additions & 115 deletions lib/contract.ts

This file was deleted.

5 changes: 4 additions & 1 deletion lib/http.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { ApiError, inventory } from "./contract";
import {
ApiError,
inventory,
} from "@policyengine/microcosm-provider-orrery/contract";
import { authorize } from "./auth";
import { createService } from "./service";
import { blobStorage, type Storage } from "./storage";
Expand Down
20 changes: 8 additions & 12 deletions lib/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import { parseGraphDocument } from "@axiom-foundation/orrery";
import {
ApiError,
inventory,
type Inventory,
type Publication,
} from "@policyengine/microcosm-provider-orrery/contract";
import {
inventoryDigest,
objectPath,
publicationPath,
publicationId,
sha256,
type Inventory,
type Publication,
} from "./contract";
} from "@policyengine/microcosm-provider-orrery/server";
import type { Storage } from "./storage";
import { createPublicationReader } from "@policyengine/microcosm-provider-orrery/server";

const encode = (value: unknown) =>
new TextEncoder().encode(JSON.stringify(value));
Expand All @@ -35,10 +37,7 @@ export function checkSources(value: unknown, names: Set<string>): void {
}
}
export function createService(storage: Storage, subject: string) {
async function read(id: string): Promise<Publication | null> {
const object = await storage.read(publicationPath(id), 256 * 1024);
return object ? (decode(object.bytes) as Publication) : null;
}
const { read, evidence } = createPublicationReader(storage);
async function reserve(value: Inventory) {
if (!subject) throw new ApiError(401, "unauthorized");
const claim = { subject, inventory_sha256: inventoryDigest(value) };
Expand Down Expand Up @@ -132,9 +131,6 @@ export function createService(storage: Storage, subject: string) {
throw new ApiError(409, "publication_conflict");
return winner;
},
async evidence(id: string, name: string) {
const published = await read(publicationId(id));
return published?.files.find((f) => f.name === name)?.url ?? null;
},
evidence,
};
}
2 changes: 1 addition & 1 deletion lib/storage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { get, put, issueSignedToken, presignUrl } from "@vercel/blob";
import { ApiError } from "./contract";
import { ApiError } from "@policyengine/microcosm-provider-orrery/contract";

export interface Storage {
read(
Expand Down
73 changes: 0 additions & 73 deletions lib/viewer.ts

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"dependencies": {
"@axiom-foundation/orrery": "0.6.1",
"@policyengine/microcosm-provider-orrery": "0.2.1",
"@policyengine/ui-kit": "^0.4.0",
"@vercel/blob": "^2.8.1",
"next": "^16.2.6",
Expand Down
6 changes: 5 additions & 1 deletion scripts/qualify.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// Explicit, non-visual deployment qualification. Never imports Microcosm code.
import { randomUUID } from "node:crypto";
import { parseGraphDocument } from "@axiom-foundation/orrery";
import { inventory, inventoryDigest, sha256 } from "../lib/contract";
import { inventory } from "@policyengine/microcosm-provider-orrery/contract";
import {
inventoryDigest,
sha256,
} from "@policyengine/microcosm-provider-orrery/server";
import { createService } from "../lib/service";
import { blobStorage } from "../lib/storage";

Expand Down
3 changes: 2 additions & 1 deletion tests/auth.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect, test } from "bun:test";
import { authorize, collectorOrigin } from "../lib/auth";
import type { Fetcher } from "../lib/net";
import { inventory, inventoryDigest } from "../lib/contract";
import { inventory } from "@policyengine/microcosm-provider-orrery/contract";
import { inventoryDigest } from "@policyengine/microcosm-provider-orrery/server";
const value = inventory({
version: 1,
publication_id: "standalone",
Expand Down
Loading
Loading