P1b: RegimeBrowser 治理结构拓扑图可视化 - #19
Merged
Merged
Conversation
…etrics, CLI
P1: make governance topology a first-class, computable artifact.
- schemas/regime-topology.schema.json: { schema_version, regime, mode,
nodes[], edges[] }. nodes carry { id, label, functional_role } with the
compiler's 9-role vocabulary (coordinator/engineering/review/research/
data/devops/content/legal/management); edges carry { from, to, kind }
with kind in command (instructions/reporting) / review (checks) /
info (sharing) / veto (rejection).
- engine/topology/validate.mjs: zero-dependency hand-written schema
validation + cross-checks: mode must match metadata orchestrationPattern
(alias-normalized), and node ids must equal the IDENTITY.md role mapping
table exactly (no invented or omitted roles).
- engine/topology/metrics.mjs: node/edge counts, density, command-chain
depth (longest simple command path, cycle-safe), in-degree centrality,
and checks-cycle count (elementary cycles containing a review/veto edge).
- bin/civagent: new 'civagent topology validate|metrics <regime>'
subcommand; 'civagent doctor' now validates every regime that has a
topology.json (regimes without one are skipped silently).
- package.json lint:syntax covers the two new engine files.
regime-to-cc.mjs is untouched: topology.json is a sidecar this iteration.
One hand-written topology.json per orchestration mode, each derived from the regime's own IDENTITY.md (role mapping table, org chart, decision flow) — no invented roles or flows: - china/tang (checks-and-balances): zhongshu-sheren hub, dispatch/report spokes to the six ministries - china/qin (centralized): emperor → three excellencies → ministers, yushi-censor review edges over all officials - global/athens (democratic): boule proposals → ekklesia vote → execution, dikasterion post-hoc review - china/ming (dual-track): shoufu/silijian 票拟-批红 veto cycle + six ministries fan-out - china/zhou (federation): tianzi → zhuhou → qingdafu layered enfeoffment, xingren liaison info edges - china/shang (theocratic): da-wang hub with divination chain da-wu → zhen-ren test/topology.test.mjs (18 cases): schema positive/negative, IDENTITY cross-check (missing/extra roles), hand-computed metrics on small graphs, real-regime metric invariants, CLI smoke (validate/metrics exit codes).
- API: new read-only GET /api/regimes/:region/:id/topology in the vite dev-server middleware. Path safety reuses the existing safeResolve pattern (400 on bad segments, 404 when a regime has no topology.json, 422 when the file fails validation). The handler imports the engine's validate.mjs/metrics.mjs directly, so UI and CLI share one source of truth for validation and graph metrics. - Types: RegimeTopology / TopologyNode / TopologyEdge / TopologyMetrics / TopologyResponse added to frontend types (mirror schemas/regime-topology). - New TopologyGraph component (4th RegimeBrowser tab 'Topology'): self-drawn SVG layered layout — Kahn layering over command edges with cycle-breaking (largest out−in surplus) + any-kind fallback for liaison nodes + two barycenter sweeps for sibling ordering. Edge styles: command solid cyan, review dashed gold, veto dashed crimson, info dotted gray; arrowheads per kind. Node hover/click pins a detail strip (role badge, id, edge list); edge hover shows the provenance note. Metrics chips (nodes/edges/density/depth/checks) in the panel header. Regimes without topology.json get a graceful '尚未类型化' placeholder. - Zero new runtime dependencies; no graph library.
LeoLin990405
added a commit
that referenced
this pull request
Jul 29, 2026
Reconciles the two diverged lines: this branch's v6 hardening (constitutional mechanism engine, Express API server, history-db episodic memory, i18n sweep, regime audit) with main's P1-P6 features (topology graphs, BT stats pipeline, skill supply-chain gate, ablation variants, hill-climbing loop, T3 deterministic scoring, anchored blind-judge rubric). Key resolutions: - tournament.mjs: main's anchored-rubric blind judge + T3 grading kept as the successor; branch's history-db recording, spawn-error handler, and markdown --task-file support grafted on top (.json → T3 spec, else plain text) - run-v5.mjs: mechanism engine + UTF-8-safe line decoding kept, with main's withPermissionMode() and per-turn actor attribution folded in - skill-sediment.mjs: main's writeSkillFile (frontmatter pinning + content hash) extended with the branch's random filename suffix + atomic tmp+rename - API home is the Express server (vite middleware dropped); main-only endpoints ported as server/routes/stats.mjs and /api/regimes/:r/:id/topology - App.tsx keeps the v6 glassmorphism shell; RankingsPanel mounted as a new tab - china/tang keeps the audited 9-agent 三省 structure; topology.json rewritten to match and topology tests updated accordingly - events schema: union of mechanism event types and the v2 OTel envelope ci: 213 tests green, 57 regimes validated, frontend tsc/lint/build clean
3 tasks
LeoLin990405
pushed a commit
that referenced
this pull request
Aug 6, 2026
- wanikua#37: Replace static AUTH_TOKEN with dynamic getAuthToken() to fix 401 after login - #29: Change silijian agent id from 'main' to 'silijian' to avoid conflicts - #19: Remove deprecated fields (runTimeoutSeconds, maxConcurrent), fix api field, add troubleshooting - #20: Add --with-gui / --no-gui flag for optional Dashboard installation - #31: Add comments recommending openclaw CLI over direct config editing - #26: Add docs/windows-wsl.md for WSL2 setup guide - #25/#17: Add hanlinyuan (翰林院) agent as optional configuration
LeoLin990405
added a commit
that referenced
this pull request
Aug 6, 2026
* feat(topology): explicit regime-as-graph layer — schema, validator, metrics, CLI
P1: make governance topology a first-class, computable artifact.
- schemas/regime-topology.schema.json: { schema_version, regime, mode,
nodes[], edges[] }. nodes carry { id, label, functional_role } with the
compiler's 9-role vocabulary (coordinator/engineering/review/research/
data/devops/content/legal/management); edges carry { from, to, kind }
with kind in command (instructions/reporting) / review (checks) /
info (sharing) / veto (rejection).
- engine/topology/validate.mjs: zero-dependency hand-written schema
validation + cross-checks: mode must match metadata orchestrationPattern
(alias-normalized), and node ids must equal the IDENTITY.md role mapping
table exactly (no invented or omitted roles).
- engine/topology/metrics.mjs: node/edge counts, density, command-chain
depth (longest simple command path, cycle-safe), in-degree centrality,
and checks-cycle count (elementary cycles containing a review/veto edge).
- bin/civagent: new 'civagent topology validate|metrics <regime>'
subcommand; 'civagent doctor' now validates every regime that has a
topology.json (regimes without one are skipped silently).
- package.json lint:syntax covers the two new engine files.
regime-to-cc.mjs is untouched: topology.json is a sidecar this iteration.
* feat(topology): 6 representative regime topologies + test suite
One hand-written topology.json per orchestration mode, each derived from
the regime's own IDENTITY.md (role mapping table, org chart, decision
flow) — no invented roles or flows:
- china/tang (checks-and-balances): zhongshu-sheren hub, dispatch/report
spokes to the six ministries
- china/qin (centralized): emperor → three excellencies → ministers,
yushi-censor review edges over all officials
- global/athens (democratic): boule proposals → ekklesia vote → execution,
dikasterion post-hoc review
- china/ming (dual-track): shoufu/silijian 票拟-批红 veto cycle + six
ministries fan-out
- china/zhou (federation): tianzi → zhuhou → qingdafu layered enfeoffment,
xingren liaison info edges
- china/shang (theocratic): da-wang hub with divination chain
da-wu → zhen-ren
test/topology.test.mjs (18 cases): schema positive/negative, IDENTITY
cross-check (missing/extra roles), hand-computed metrics on small graphs,
real-regime metric invariants, CLI smoke (validate/metrics exit codes).
* feat(frontend): governance topology visualization in RegimeBrowser
- API: new read-only GET /api/regimes/:region/:id/topology in the vite
dev-server middleware. Path safety reuses the existing safeResolve
pattern (400 on bad segments, 404 when a regime has no topology.json,
422 when the file fails validation). The handler imports the engine's
validate.mjs/metrics.mjs directly, so UI and CLI share one source of
truth for validation and graph metrics.
- Types: RegimeTopology / TopologyNode / TopologyEdge / TopologyMetrics /
TopologyResponse added to frontend types (mirror schemas/regime-topology).
- New TopologyGraph component (4th RegimeBrowser tab 'Topology'):
self-drawn SVG layered layout — Kahn layering over command edges with
cycle-breaking (largest out−in surplus) + any-kind fallback for liaison
nodes + two barycenter sweeps for sibling ordering. Edge styles:
command solid cyan, review dashed gold, veto dashed crimson, info
dotted gray; arrowheads per kind. Node hover/click pins a detail strip
(role badge, id, edge list); edge hover shows the provenance note.
Metrics chips (nodes/edges/density/depth/checks) in the panel header.
Regimes without topology.json get a graceful '尚未类型化' placeholder.
- Zero new runtime dependencies; no graph library.
LeoLin990405
added a commit
that referenced
this pull request
Aug 6, 2026
Reconciles the two diverged lines: this branch's v6 hardening (constitutional mechanism engine, Express API server, history-db episodic memory, i18n sweep, regime audit) with main's P1-P6 features (topology graphs, BT stats pipeline, skill supply-chain gate, ablation variants, hill-climbing loop, T3 deterministic scoring, anchored blind-judge rubric). Key resolutions: - tournament.mjs: main's anchored-rubric blind judge + T3 grading kept as the successor; branch's history-db recording, spawn-error handler, and markdown --task-file support grafted on top (.json → T3 spec, else plain text) - run-v5.mjs: mechanism engine + UTF-8-safe line decoding kept, with main's withPermissionMode() and per-turn actor attribution folded in - skill-sediment.mjs: main's writeSkillFile (frontmatter pinning + content hash) extended with the branch's random filename suffix + atomic tmp+rename - API home is the Express server (vite middleware dropped); main-only endpoints ported as server/routes/stats.mjs and /api/regimes/:r/:id/topology - App.tsx keeps the v6 glassmorphism shell; RankingsPanel mounted as a new tab - china/tang keeps the audited 9-agent 三省 structure; topology.json rewritten to match and topology tests updated accordingly - events schema: union of mechanism event types and the v2 OTel envelope ci: 213 tests green, 57 regimes validated, frontend tsc/lint/build clean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
P1b: RegimeBrowser 治理结构拓扑图可视化
基于 #18(政体拓扑类型化),把 topology.json 可视化进前端。Base 设为 feature/p1-regime-topology,#18 合并后本 PR 会自动 retarget 到 main。
改动
GET /api/regimes/:region/:id/topology(dev server 只读端点):safeResolve 路径校验 → 400;无文件 → 404;校验失败 → 422 带 details;成功 → 200{topology, metrics},metrics 由引擎computeMetrics服务端计算(UI 与 CLI 同一真源)TopologyGraph.tsx(477 行新组件):自绘 SVG 分层布局,零新增依赖note出处标注RegimeBrowser新增 "Topology" 标签页(与 Org Chart 共享选中态)验证
npm run build(含 tsc -b)通过;根目录npm test97 pass / 0 fail;lint 通过待决策