v5: Hermes-inspired learning loop (auto skill sedimentation)#3
Merged
Conversation
Introduces opt-in v5 runtime that persists per-civilization skills across matches, inspired by NousResearch/hermes-agent's autonomous skill creation and agent-curated memory patterns. - engine/v5/civ-memory.mjs — isolated HOME per regime at ~/.civagent/envs/<region>-<id>/, seeded with regime identity, symlinks learned skills from regimes/<civ>/skills/ - engine/v5/skill-sediment.mjs — post-match pipeline: codex extracts governance patterns from transcript → gemini audits → write skill .md. Includes prompt-injection guard and provenance banner. - engine/v5/run-v5.mjs — new entry: HOME override + stdout transcript capture to ~/.civagent/transcripts/, triggers sediment on exit - bin/civagent — adds --v5 flag on run, plus skills/match-log subcommands - docs/V5-DESIGN.md — full design with MVP scope (tang/qin/athens/rome) - ~/.claude/teams/civagent-v5/config.json — Agent Team with team-lead judge + 4 civ-agents (backend metadata routes to cn:/gemini:/codex: dispatch agents; native model IDs kept valid) v4 behavior preserved — v5 is opt-in via --v5 flag.
…tion guards
- engine/v5/civ-memory.mjs: add validateRegime() regex guard vs path traversal;
handle pre-existing non-symlink destinations with warning instead of silent skip
- engine/v5/run-v5.mjs: override XDG_{CONFIG,DATA,CACHE}_HOME too, so any CC
build that reads XDG paths independently of HOME also gets isolated
- engine/v5/skill-sediment.mjs: strip ANSI escapes and unwrap JSONL chunks
before feeding codex (was wasting tokens + confusing extractor); require
codex/gemini binaries via explicit hasBinary() check
- bin/civagent: fix Python shell injection in cmd_skills (f was interpolated
into a Python string literal; now passed via sys.argv)
Gemini auditor often emits a chain-of-thought block before the final APPROVE/REJECT verdict. Strict startsWith() rejected valid approvals. Now checks the last non-empty line instead.
- civ-memory.mjs: re-seed CLAUDE.md when SOUL.md or IDENTITY.md is newer (was frozen on first run, blocking regime identity edits) - skill-sediment.mjs: append matchId suffix to skill filenames so two matches on the same day with similar topics don't overwrite - skill-sediment.mjs: clarify AUDIT_PROMPT — auditor has no transcript access and should only validate skill shape, not hallucinate verification - docs/V5-DESIGN.md: document design limitations Kimi raised (regime-to-agent compression, time-dimension omission, seed semantics)
5 tasks
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.
Summary
Adds an opt-in v5 learning loop to CivAgent, inspired by NousResearch/hermes-agent's autonomous skill creation and agent-curated memory. v4 was stateless per run; v5 persists per-civilization governance patterns across matches.
What's new
~/.civagent/envs/<region>-<id>/HOME with its own.claude/subtree, so learned skills don't cross-contaminate between civilizations. Re-seeds CLAUDE.md when SOUL.md/IDENTITY.md changes.regimes/<civ>/skills/learned-<date>-<topic>-<matchId>.md. Includes prompt-injection guard, provenance banner, ANSI/JSONL cleaning.--v5opt-in flag onrun, plusskills <regime>andmatch-logsubcommands.Compatibility
v5 is fully opt-in via
--v5. Without the flag, v4 behavior is unchanged.Review trail
Three independent AI reviews on the same diff:
All actionable findings fixed across 4 commits.
Test plan
node -con all 3 engine/v5 filesbash -n bin/civagentcivagent run --v5match (requires tester with stable CC auth in isolated HOME)Risks
codex+geminibinaries in PATH; v5 degrades gracefully with a warning if either is missing.claudespawned in isolated HOME will need credentials on first run per civ (one-time OAuth per isolated environment).