This repository was archived by the owner on Sep 5, 2026. It is now read-only.
feat: cogmem trust --rotate for safe key rotation - #12
Merged
Conversation
Changing the agent key previously meant manually deleting trust.json, and the pin would have bricked verification of all history signed by the old key. Add an explicit operator command that re-anchors to the current key while retaining prior DIDs (so historical log/credentials still verify), archives the old anchor, and is idempotent. doctor and 'cogmem trust' now warn on a key/anchor mismatch. A vault-content attacker cannot run it, so the security property holds. Tests prove history survives rotation and a foreign key is still rejected.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Automates the key-rotation path so it no longer means manually deleting
trust.json— and fixes a latent bug in the issuer pin while doing so.The bug this also fixes
The TOFU pin (PR #11) trusted exactly one DID. Rotating the agent key would have bricked verification of all history: every past log entry and credential was signed by the old DID, which the pin would now reject as untrusted.
Design
cogmem trust --rotateis an explicit operator action — the only supported way to change the trusted identity, so a vault-content attacker (who can't run it) still can't re-root trust. It:priorset so history signed by the retired key still verifies,trust.json.prev,cogmem trust(no flag) shows the trusted + retired DIDs and warns on a key/anchor mismatch;cogmem doctorwarns too.What I did NOT do
No silent auto-re-pin on detected key change — that is the attack the pin defends against. Rotation stays deliberate.
Tests (38 provenance, +3)
test_rotation_preserves_history_and_accepts_new_key— old entry still verifies after rotation, new-key entry verifies too.test_rotation_idempotent_when_key_unchangedtest_rotation_still_rejects_foreign_key— a never-trusted key is still rejected post-rotation.End-to-end CLI flow (establish → mismatch warning → rotate → clean → idempotent) verified against a temp home. THREAT-MODEL §4.3 updated.