Wenyan is monorepo implementing the Wenyan runtime architecture.
If you want to understand the architectural rationale and design principles behind Wenyan, start with the genesis docs:
genesis/wenyan.md- architectural genesis and modelgenesis/criteria-of-completeness.md- completion criteria and invariantsgenesis/out-of-scope.md- explicit non-goals and boundariessequence-graph.md- end-to-end sequencing graph of the Wenyan flow
packages/server(@andrey-kokoev/wenyan-server) - Cloudflare Hono serverpackages/shared(@andrey-kokoev/wenyan-shared) - compatibility/shared facadepackages/core(@andrey-kokoev/wenyan-core) - schemas, envelope types, state transitions, bootstrap/law schemaspackages/actor(@andrey-kokoev/wenyan-actor) - law-driven actor permission helperspackages/seal(@andrey-kokoev/wenyan-seal) - seal chain primitives and verificationpackages/archive(@andrey-kokoev/wenyan-archive) - append-only archive repository API + law/genre lookuppackages/pipeline(@andrey-kokoev/wenyan-pipeline) - Caoni/Shenfu/Pizhun stages + law resolverpackages/gateway(@andrey-kokoev/wenyan-gateway) - gateway routes and Tongzheng Si input filterpackages/channel(@andrey-kokoev/wenyan-channel) - reliable local broadcast channelpackages/gossip(@andrey-kokoev/wenyan-gossip) - SWIM/Plumtree-style consort gossip primitivespackages/crdt(@andrey-kokoev/wenyan-crdt) - CRDT reconciliation for legislative conflictspackages/consensus(@andrey-kokoev/wenyan-consensus) - PBFT lifecycle for constitutional consensuspackages/bridge(@andrey-kokoev/wenyan-bridge) - foreign protocol bridge runtime (standalone Node)packages/imperial-works(@andrey-kokoev/wenyan-imperial-works) - role hierarchy, emergency routing, and construction anomaly rulespackages/mobile-foreman(@andrey-kokoev/wenyan-mobile-foreman) - PWA offline foreman queue and sync primitivespackages/benchmark(@andrey-kokoev/wenyan-benchmark) - deterministic toy/stress benchmark harnesspackages/genesis(@andrey-kokoev/wenyan-genesis) - explicit genesis bootstrap (createEmptyOffice,applyGenesis)packages/cli(@andrey-kokoev/wenyan-cli) -wenyanCLI for--init,draft,submit,status,query,stream,imperialworks,mobile syncpackages/tests- shared fixtures used by server tests
sqliteadapter (local Dang'an)cloudflareadapter (D1-backed Dang'an)
- Runtime law/config for admission/appointment/classification/routing/protocol/regulation is resolved from archived
genre: "edict"documents. - Genre schema registry is archived as sealed
genre: "ti_definition"documents. - Static filesystem config is bootstrap-only (
wenyan.toml): archive engine/path, genesis identity/key, gateway bind, and optional law cache tuning. - Runtime is strict fail-closed: missing/ambiguous/invalid law and undefined genres are rejected.
POST /api/wenyan/messages(enqueue-only, returns202 Accepted)GET /api/wenyan/messages/:idGET /api/wenyan/messages?state=...GET /api/wenyan/stream(SSE)GET /api/wenyan/stream/replay?since=...(JSON polling replay)GET /api/wenyan/mesh/statusPOST /api/wenyan/mesh/joinPOST /api/wenyan/mesh/syncGET /api/wenyan/mesh/merkle-root
Read endpoints enforce JWT actor authentication when access_control law requires it. Header spoofing via x-wenyan-actor-* is disabled by default.
Bridge runtime (standalone):
wenyan bridge run [--config wenyan.toml]wenyan bridge status [--config wenyan.toml]wenyan bridge sync --adapter <id> [--config wenyan.toml]wenyan bridge dry-run --adapter <id> --file payload.json [--config wenyan.toml]
wenyan.tomlwenyan.toml.example
Minimal shape:
[archive]
engine = "sqlite"
path = "./wenyan.dang'an"
[genesis]
node_id = "11111111-1111-4111-8111-111111111111"
genesis_key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
[gateway.listen]
host = "127.0.0.1"
port = 8787
[auth]
jwt_issuer = "wenyan.local"
jwt_audience = "wenyan-gateway"
jwt_alg = "HS256"
jwt_secret = "change-this-secret"
allow_header_actor = false
[law]
mode = "strict"
[distributed]
mode = "single"
node_id = "node-a"
bind_gossip = "127.0.0.1:7946"
seeds = []
fanout = 3
suspicion_timeout_ms = 5000
[consensus]
kind = "none"
replica_set = []
constitutional_threshold = 3
view_change_timeout_ms = 5000
allow_single_replica = false
[bridge]
enabled = false
mode = "standalone"
[bridge.sync]
mode = "hybrid"
poll_interval_ms = 1000
batch_size = 100pnpm installpnpm dev(server local on8787)pnpm dev:remote(remote Worker preview)pnpm dev:server:local(server only, local wrangler)pnpm dev:server:remote(server only, remote wrangler)pnpm typecheckpnpm testpnpm buildpnpm security:auditpnpm security:fuzzpnpm sbom:generatepnpm docs:apipnpm benchmark:toy:checkpnpm benchmark:stresswenyan --join gossip://seed:7946wenyan sync --peer gossip://seed:7946wenyan mesh statuswenyan bridge run --config wenyan.tomlwenyan imperialworks init|status|ceremony --workers <n> --days <n>wenyan imperialworks emergency --site <id> --severity <level>wenyan mobile sync --node <minister-node>
Authenticate npm for the @andrey-kokoev scope:
export GITHUB_TOKEN=YOUR_GITHUB_TOKEN
cat > ~/.npmrc <<'EOF'
@andrey-kokoev:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
EOFInstall packages:
npm install @andrey-kokoev/wenyan-core @andrey-kokoev/wenyan-cli @andrey-kokoev/wenyan-gatewayInstall public npmjs packages:
npm install @wenyan2/wenyan-core @wenyan2/wenyan-cli @wenyan2/wenyan-gatewayPublished packages in v1.x (both registries, different scopes):
@andrey-kokoev/wenyan-core@andrey-kokoev/wenyan-actor@andrey-kokoev/wenyan-seal@andrey-kokoev/wenyan-archive@andrey-kokoev/wenyan-pipeline@andrey-kokoev/wenyan-gateway@andrey-kokoev/wenyan-channel@andrey-kokoev/wenyan-gossip@andrey-kokoev/wenyan-crdt@andrey-kokoev/wenyan-consensus@andrey-kokoev/wenyan-bridge@andrey-kokoev/wenyan-genesis@andrey-kokoev/wenyan-cli@wenyan2/wenyan-core@wenyan2/wenyan-actor@wenyan2/wenyan-seal@wenyan2/wenyan-archive@wenyan2/wenyan-pipeline@wenyan2/wenyan-gateway@wenyan2/wenyan-channel@wenyan2/wenyan-gossip@wenyan2/wenyan-crdt@wenyan2/wenyan-consensus@wenyan2/wenyan-bridge@wenyan2/wenyan-genesis@wenyan2/wenyan-cli
- Bump versions as needed in workspace package manifests.
- Push changes to
main. - Create and push tag:
vX.Y.Z. - Verify deploy docs are current:
docs/deploy/quickstart.mddocs/deploy/production.mddocs/deploy/enterprise.md
- Verify release validation commands pass locally (
pnpm -r typecheck,pnpm -r test,pnpm -r build,pnpm security:audit,pnpm benchmark:toy:check). - Publish to GitHub Packages:
pnpm publish:github(orpnpm publish:github:dry-run). - Publish npmjs mirror scope:
pnpm publish:npmjs(orpnpm publish:npmjs:dry-run). - Confirm packages appear in GitHub repository Packages section and npmjs for
@wenyan2.