Skip to content
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,20 @@ gates close.

The Calibration Worker demo in [`wrangler.jsonc`](./wrangler.jsonc) and
[`src/worker/calibration-demo.mjs`](./src/worker/calibration-demo.mjs) exposes a
read-only public evidence surface for issue #15. It is configured with live
Calibration evidence for registry object `1`, provider/dataset/piece
`4`/`12524`/`34`, and a committed registry finalization. The deployed demo is
available at `https://foc-platform-calibration-demo.snissn.workers.dev`. Run
read-only public admin dashboard and evidence surface. `/` and `/admin` render
the dashboard; `/api/admin/overview`, `/api/admin/files`,
`/api/admin/accounts`, `/api/admin/datasets`, `/api/admin/coordinators`, and
`/api/admin/reconciliation` expose JSON rows backed by direct registry
count/list/detail reads. Overview uses bounded contract count reads; table
routes expose page metadata with `cursor` or `offset`, and filters are
page-scoped to keep Worker requests bounded. The committed demo config still points at live Calibration
evidence for registry object `1`, provider/dataset/piece `4`/`12524`/`34`, and
a committed registry finalization; issue #33 owns publishing updated public
evidence for the direct pagination ABI. Until that registry/runtime evidence
matches the current artifact hash, the dashboard defaults to skipped read-only
API responses instead of live dashboard reads; use `?live=true` only against an
upgraded pagination-capable registry. The deployed demo is available at
`https://foc-platform-calibration-demo.snissn.workers.dev`. Run
`pnpm worker:dev` for a local Worker and `pnpm worker:dry-run` to validate the
deploy bundle. The Worker must not receive private keys or session keys;
privileged FOC upload and registry transaction submission stay in the local
Expand Down
51 changes: 40 additions & 11 deletions docs/calibration-worker-demo.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Calibration Worker Demo

Issue #15 exposes the Calibration demo through a Cloudflare Worker. The Worker
is intentionally read-only: it serves public evidence, links to generated
Token Host wrapper metadata, and can read the deployed registry through a
public Calibration RPC. It must not upload files, pay FOC, withdraw funds, or
Issue #15 exposes the Calibration demo through a Cloudflare Worker. Issue #32
turns the Worker first screen into a read-only admin dashboard for the
configured `FocPlatformRegistry`: it serves public evidence, reads dashboard
rows through direct registry list/detail views, and links to generated Token
Host wrapper metadata. It must not upload files, pay FOC, withdraw funds, or
submit registry transactions.

## Worker Commands
Expand All @@ -20,6 +21,14 @@ Check the public endpoints:
curl http://127.0.0.1:8787/api/health
curl http://127.0.0.1:8787/api/demo/evidence
curl http://127.0.0.1:8787/api/demo/registry
curl http://127.0.0.1:8787/api/admin/overview
curl http://127.0.0.1:8787/api/admin/files?limit=10
curl 'http://127.0.0.1:8787/api/admin/files?limit=10&cursor=1'
curl http://127.0.0.1:8787/api/admin/accounts?limit=10
curl 'http://127.0.0.1:8787/api/admin/accounts?limit=10&offset=10'
curl http://127.0.0.1:8787/api/admin/datasets?limit=10
curl http://127.0.0.1:8787/api/admin/coordinators?limit=10
curl http://127.0.0.1:8787/api/admin/reconciliation?limit=10
```

Current deployed Worker:
Expand Down Expand Up @@ -47,21 +56,41 @@ documented in
[`docs/production-hardening-runbook.md`](./production-hardening-runbook.md).

The current deployed Worker and registry evidence predate the direct pagination
ABI. They prove the read-only Worker demo and one configured object against the
then-deployed registry, but they do not prove `listStorageObjectIds`,
`listAccountIds`, `listDatasetKeys`, `readBatch`, or the direct-onchain admin
dashboard path. Issue #33 must publish updated evidence from a registry build
that includes the pagination ABI before the dashboard stack can claim
end-to-end direct-read proof.
ABI. The Worker code now has direct-onchain dashboard routes, but the deployed
public evidence still points at the earlier registry. For that configuration,
the dashboard defaults to skipped read-only API responses instead of attempting
live dashboard reads against missing count/list methods. `?live=true` should be
used only with a registry whose runtime hash matches the current pagination ABI.
Issue #33 must publish updated evidence from a registry build that includes the
pagination ABI before the dashboard stack can claim end-to-end public
Calibration direct-read proof.

## Public Endpoints

| Route | Purpose |
| --- | --- |
| `/` | Operator-facing HTML demo surface. |
| `/` | Operator-facing admin dashboard HTML surface. |
| `/admin` | Explicit admin dashboard alias. |
| `/api/health` | Worker health and authority boundary. |
| `/api/demo/evidence` | Static public demo configuration assembled from Worker vars. |
| `/api/demo/registry` | Public registry reads for owner, next object id, and configured object/usage/receipt state. |
| `/api/admin/overview` | Bounded dashboard metrics and source metadata from direct registry count reads. |
| `/api/admin/files` | Paginated object/file rows with status, account, provider, dataset, coordinator, and text filters. Uses `cursor` for next-page reads; cross-surface reconciliation remains in `/api/admin/reconciliation`. |
| `/api/admin/accounts` | Paginated account usage rows from registry account list/detail reads. |
| `/api/admin/datasets` | Paginated dataset/provider rows from registry dataset key/detail reads. |
| `/api/admin/coordinators` | Coordinator policy and relayer rows from registry list/detail reads. |
| `/api/admin/reconciliation` | Page-scoped reconciliation warnings and evidence boundaries for the current object cursor page. Cross-surface account, dataset, and coordinator-policy checks are declared as omitted instead of scanning the whole registry from one Worker request. |

The table endpoints accept `limit` up to the registry max list limit. Files use
the object-id cursor returned as `pagination.nextCursorIdExclusive`;
reconciliation uses the same object cursor for page-scoped checks. Accounts,
datasets, and coordinators use the returned `pagination.nextOffset`. Filters
and text search apply to the returned page so the Worker keeps each request
bounded instead of scanning the full registry for a global search.

Append `?live=false` to any dashboard or registry endpoint when you need a
route-level smoke check without making public RPC calls. Unknown dashboard
routes still return `404`.

## Local Evidence Generation Boundary

Expand Down
6 changes: 2 additions & 4 deletions src/registry/read-model.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { readFileSync } from "node:fs";
import { decodeEventLog, encodeFunctionData } from "viem";
import registryArtifactJson from "../../artifacts/contracts/FocPlatformRegistry.json" with { type: "json" };

const artifactUrl = new URL("../../artifacts/contracts/FocPlatformRegistry.json", import.meta.url);

export const registryArtifact = JSON.parse(readFileSync(artifactUrl, "utf8"));
export const registryArtifact = registryArtifactJson;
export const registryAbi = registryArtifact.abi;

const FINALIZATION_STATUS = ["Committed", "Partial", "Failed"];
Expand Down
Loading
Loading