Skip to content

R6: regime editing API + online editor + second-pass historical revision - #31

Merged
LeoLin990405 merged 7 commits into
mainfrom
r6/integration
Aug 3, 2026
Merged

LeoLin990405 merged 7 commits into
mainfrom
r6/integration

Conversation

@LeoLin990405

Copy link
Copy Markdown
Owner

Round 6, built in parallel by three workers in isolated worktrees. 321 backend + 20 frontend tests green; five-machine home-cluster CI green at bcaba56 (including a Node 26 / macOS arm64 runner).

What's here

PUT /api/regimes/:region/:id — edits metadata.json / IDENTITY.md / SOUL.md behind a validation chain that must pass in full before any byte lands: id whitelist + safeResolve paths, regime must already exist (edits only), metadata must parse, the IDENTITY role table must compile to ≥1 agent, agentCount is resynced to the compiled count, topology validation runs when topology.json exists. Temp-file + rename with rollback, so multi-file updates are all-or-nothing; the regime cache is invalidated on success.

Editor tab — live agent-count preview while editing the IDENTITY table; at zero it disables save and explains why, since a prose rewrite is exactly what silently bricks a regime. Server rejections surface the error and every finding verbatim. SkillLibrary gains a read-only staged-skill list; approval stays on the CLI (no endpoint yet) with the button disabled rather than faked.

Historical revision, 10 regimes — periodization and anachronism fixes (Han Confucian orthodoxy dated to Emperor Wu with the early Western Han marked Huang-Lao; the Qing Grand Council dated to 1729; Shang ranks replaced with attested Shang titles rather than Zhou feudal grades), attribution fixes (the Cao Cao hero speech marked as a novel; "L'État, c'est moi" flagged apocryphal), and an office-power correction for Athens. Seven further doubts are recorded in the report rather than silently rewritten. IDENTITY.md and topology.json untouched, so agentCount is unaffected.

Bug found during integration

The write API computed the resynced agentCount and returned it, but only persisted it when the caller also sent a metadata payload — so editing just the IDENTITY table answered 200 {agentCount: 3} while metadata.json kept saying 2, which would fail validate:regimes on the next run. The existing test always sent metadata, which is why it passed. Fixed, with cases that edit IDENTITY alone and assert the on-disk value; reverting the fix turns exactly that case red.

Test plan

  • npm run ci — 321 backend, 57 regimes, 20 frontend
  • Home-cluster CI on five workers, all bound to bcaba56
  • Manual probe: prose IDENTITY rejected with both files byte-identical on disk; traversal and unknown-regime rejected; agentCount synced on an IDENTITY-only edit

Follows the 2026-06 audit. Periodization and anachronism fixes: Han Confucian
orthodoxy dated to Emperor Wu with the early Western Han marked as Huang-Lao
Daoist; the Qing Grand Council dated to 1729 with the Deliberative Council and
Grand Secretariat named for the period before it; Shang ranks replaced with
attested Shang titles instead of Zhou feudal grades, and coordination moved off
the Zhou-era Qingshi Liao; Sui quantifies the division it ended.

Attribution fixes: the Cao Cao hero speech marked as Sanguo Yanyi, a novel, not
a historical source; L%27Etat c%27est moi flagged as apocryphal in both the
Louis XIV soul file and the metadata system field. Office-power correction for
Athens: the Strategia was the powerful classical office while the Archonship had
become largely ceremonial and allotted.

Seven further doubts are recorded in the report rather than silently rewritten
- among them the Qin Nine Ministers as a Han-era reconstruction and the Manchu
or Han temperament framing in the Qing soul file. IDENTITY.md and topology.json
were deliberately untouched, so agentCount is unaffected; all 57 regimes still
pass validate:regimes.
Edits metadata.json / IDENTITY.md / SOUL.md behind a validation chain that must
pass in full before a single byte lands: id whitelist + safeResolve paths, the
regime must already exist (edits only, no create/delete), metadata must parse,
the IDENTITY role table must compile to >= 1 agent (AGENTS.md rule 2 — a prose
rewrite silently yields 0 agents and bricks the regime), metadata.agentCount is
resynced to the compiled count (rule 3), and topology validation must pass when
topology.json exists. Writes go through temp file + rename with rollback, so a
multi-file update is all-or-nothing. The regime cache is invalidated on success.

Fixed during integration: the resynced agentCount was computed and returned but
only persisted when the caller also sent a metadata payload — so editing just
the IDENTITY table answered 200 with agentCount 3 while metadata.json kept
saying 2, which would fail validate:regimes on the next run. metadata.json is
now rewritten whenever the count drifts. The existing test always sent metadata,
which is why it passed; added cases that edit IDENTITY alone and assert the
on-disk value, plus one asserting no gratuitous metadata rewrite.
Editor tab edits metadata.json / IDENTITY.md / SOUL.md for the selected regime
through PUT /api/regimes/:region/:id. The IDENTITY box parses the role table as
you type and shows how many agents it would compile to; at zero it turns red and
disables save with an explanation, since a prose rewrite is what silently bricks
a regime (AGENTS.md rule 2). That preview is convenience only — the server
validation is still authoritative, and when it rejects, the error string and
every finding are surfaced verbatim rather than summarized.

SkillLibrary gains a Pending-approval section listing staged skills. Approval
itself stays on the CLI this round because no approval endpoint exists yet; the
button is disabled and says so instead of pretending to work.

Six vitest cases cover the zero-agent lockout, findings rendering, agentCount
refresh on success, and inline JSON syntax errors; the fetch mocks mirror the
real { id, metadata } envelope.
main's list gained the R7-R12 modules (skill-outcome, history-db,
history-retriever); r6 added server/services/regime-write.mjs. The conflict was
resolved by keeping main's list and inserting r6's entry, so neither side loses
a syntax check.

Note: `git merge-tree` reported zero conflict markers for this pair while the
real merge conflicted on package.json — the newer merge-tree output format does
not emit the markers that check grepped for. A conflict probe that returns a
clean wrong answer is worse than no probe.

CI on the merged tree: 519 backend + 25 frontend + 57 regimes + smoke.
@LeoLin990405
LeoLin990405 merged commit d5bcebb into main Aug 3, 2026
3 checks passed
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 pushed a commit that referenced this pull request Aug 6, 2026
LeoLin990405 added a commit that referenced this pull request Aug 6, 2026
…ion (#31)

* content: second-pass historical revision across 10 regimes

Follows the 2026-06 audit. Periodization and anachronism fixes: Han Confucian
orthodoxy dated to Emperor Wu with the early Western Han marked as Huang-Lao
Daoist; the Qing Grand Council dated to 1729 with the Deliberative Council and
Grand Secretariat named for the period before it; Shang ranks replaced with
attested Shang titles instead of Zhou feudal grades, and coordination moved off
the Zhou-era Qingshi Liao; Sui quantifies the division it ended.

Attribution fixes: the Cao Cao hero speech marked as Sanguo Yanyi, a novel, not
a historical source; L%27Etat c%27est moi flagged as apocryphal in both the
Louis XIV soul file and the metadata system field. Office-power correction for
Athens: the Strategia was the powerful classical office while the Archonship had
become largely ceremonial and allotted.

Seven further doubts are recorded in the report rather than silently rewritten
- among them the Qin Nine Ministers as a Han-era reconstruction and the Manchu
or Han temperament framing in the Qing soul file. IDENTITY.md and topology.json
were deliberately untouched, so agentCount is unaffected; all 57 regimes still
pass validate:regimes.

* feat(server): PUT /api/regimes/:region/:id — validated regime editing

Edits metadata.json / IDENTITY.md / SOUL.md behind a validation chain that must
pass in full before a single byte lands: id whitelist + safeResolve paths, the
regime must already exist (edits only, no create/delete), metadata must parse,
the IDENTITY role table must compile to >= 1 agent (AGENTS.md rule 2 — a prose
rewrite silently yields 0 agents and bricks the regime), metadata.agentCount is
resynced to the compiled count (rule 3), and topology validation must pass when
topology.json exists. Writes go through temp file + rename with rollback, so a
multi-file update is all-or-nothing. The regime cache is invalidated on success.

Fixed during integration: the resynced agentCount was computed and returned but
only persisted when the caller also sent a metadata payload — so editing just
the IDENTITY table answered 200 with agentCount 3 while metadata.json kept
saying 2, which would fail validate:regimes on the next run. metadata.json is
now rewritten whenever the count drifts. The existing test always sent metadata,
which is why it passed; added cases that edit IDENTITY alone and assert the
on-disk value, plus one asserting no gratuitous metadata rewrite.

* feat(frontend): regime editor tab and a read-only staged-skill view

Editor tab edits metadata.json / IDENTITY.md / SOUL.md for the selected regime
through PUT /api/regimes/:region/:id. The IDENTITY box parses the role table as
you type and shows how many agents it would compile to; at zero it turns red and
disables save with an explanation, since a prose rewrite is what silently bricks
a regime (AGENTS.md rule 2). That preview is convenience only — the server
validation is still authoritative, and when it rejects, the error string and
every finding are surfaced verbatim rather than summarized.

SkillLibrary gains a Pending-approval section listing staged skills. Approval
itself stays on the CLI this round because no approval endpoint exists yet; the
button is disabled and says so instead of pretending to work.

Six vitest cases cover the zero-agent lockout, findings rendering, agentCount
refresh on success, and inline JSON syntax errors; the fetch mocks mirror the
real { id, metadata } envelope.

* build: cover regime-write.mjs in lint:syntax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant