Run Core locally
Run the local ziteox-core Worker, migrate D1, and exercise the connector with @ziteox/core-client.
Run Core locally
Local-only Worker (apps/core). Nothing is deployed. No wrangler login / wrangler deploy without an explicit go-ahead.
Prerequisites
- Node 22+ (type-stripping for
@ziteox/core-clientsource) and pnpm - Repo dependencies installed (
pnpm installat the monorepo root) - Optional: free local port 8787 (override with
CORE_E2E_PORTfor the e2e script)
Keys, migrate, seed, dev
From the monorepo root:
pnpm --filter @ziteox/core-worker dev:keys
pnpm --filter @ziteox/core-worker db:migrate
pnpm --filter @ziteox/core-worker devdev:keyswritesapps/core/.dev.varsandapps/core/.dev-admin-key.json(gitignored). Pass--forceto rotate.db:migrateapplies D1 migrations locally (ziteox-core-local), then runs the local-only seed (seed/dev_seed.sqlviadb:seed). Migrations themselves are schema-only;migrations/0002_dev_seed.sqlis a no-op kept for history.db:seedalone re-appliesseed/dev_seed.sql(idempotentINSERT OR IGNORE). It refuses--remote/--env production. Never apply the seed to a remote database.devstartswrangler dev --local --port 8787.
The seed creates local staff roles (dev-admin / dev-operator) and mock GitHub rows used by file/publish flows. Without it, admin assertions and mock file reads will fail.
Health check:
curl -s http://127.0.0.1:8787/healthzEnd-to-end script
Resets a dedicated persist dir (apps/core/.wrangler/e2e), migrates, starts the Worker, runs the full connector matrix via @ziteox/core-client, then always stops the child process:
pnpm core:e2eExit 0 only if every step passes. Tokens are printed redacted as zxcore_…<last4>.
Curl examples
Data plane (replace the Bearer value; never commit real tokens):
curl -s http://127.0.0.1:8787/v1/whoami \
-H "Authorization: Bearer zxcore_…"curl -s "http://127.0.0.1:8787/v1/files?path=packages/ui/package.json" \
-H "Authorization: Bearer zxcore_…"Management plane needs an Ed25519 assertion (X-Ziteox-Assertion or Bearer JWS). Prefer the client snippet below rather than hand-rolling JWS in the shell.
Client snippet
import { createCoreClient, createCoreAdminClient } from "@ziteox/core-client";
import { createEd25519AssertionSigner } from "@ziteox/core-client/admin-signer";
import { readFileSync } from "node:fs";
const baseUrl = "http://127.0.0.1:8787";
const adminKey = JSON.parse(
readFileSync("apps/core/.dev-admin-key.json", "utf8"),
);
const signAssertion = createEd25519AssertionSigner({
kid: adminKey.kid,
privateKey: adminKey.privateKey,
sub: "dev-admin",
iss: "http://localhost:3000",
});
const admin = createCoreAdminClient({ baseUrl, signAssertion });
const project = await admin.createProject({
key: "demo",
label: "Demo",
owner_user_id: "dev-admin",
allowed_scopes: ["read:packages/ui/**", "read:secrets/**"],
});
const { token } = await admin.issueToken({
project_key: project.key,
scopes: ["read:packages/ui/**"],
environment: "development",
});
const core = createCoreClient({
baseUrl,
token,
environment: "development", // optional X-Ziteox-Environment
});
console.log(await core.whoami()); // includes environment / environment_id
console.log(await core.getFile("packages/ui/package.json"));Tokens and vault secrets are environment-scoped (development | staging | production). See Admin portal integration for allowed_environments, rotate rules, and X-Ziteox-Environment.
Import the signer from @ziteox/core-client/admin-signer so browser bundles do not pull Node signing helpers.
Mocked vs real
| Piece | Local v1 |
|---|---|
| Worker + HTTP API | Real (Miniflare / wrangler dev --local) |
| Registry / vault / audit | Real schema on local D1 (tables mirror forge_core.* names from the design) |
| GitHub | Mock adapter + App stub (GITHUB_MODE=mock); files/branches/PRs in D1 |
| Admin assertions | Real Ed25519 verify; public keys pinned in .dev.vars; private key only in .dev-admin-key.json |
| Deploy / Cloudflare account | Not used — nothing is published |
Defaults chosen for this local slice (TTL, overlap, roles, envelope crypto, etc.) are listed under Local v1 defaults chosen and still await Laki on the open questions.