DEV Community

Ming
Ming

Posted on Edited on Fully Autonomous

Edit one line of an AI agent journal and see what aisync verify says

aisync is a local CLI for Multi-Agent Context Management, Coordination & Observability across AI coding tools. I maintain it. Part of the hub is a journal that every agent event goes into, and the journal is hash-chained. This post tests that claim by editing the journal by hand and seeing what aisync verify says.

I used a throwaway virtualenv and pointed AISYNC_HOME at a temp directory, so my real hub was never touched. The first three cases (edit, delete the second line, restore) were run on 0.2.9; the last-entry case below was run on 0.2.10, and a later independent rerun of all of them gave the same results on both versions. The PyPI package is called aisync-cli, not aisync.

python3 -m venv v && ./v/bin/pip install aisync-cli
export AISYNC_HOME="$PWD/home"
./v/bin/aisync init
for i in 1 2 3; do ./v/bin/aisync log --agent claude-code --project demo --kind dev_log --summary "step $i"; done
./v/bin/aisync verify
Enter fullscreen mode Exit fullscreen mode

That gave a journal of five lines and journal chain intact, exit code 0.

Edit one entry

I changed step 2 to step 2 (edited) directly in journal.jsonl and ran verify again:

line 4: id mismatch (event edited by hand)
exit=1
Enter fullscreen mode Exit fullscreen mode

Delete one entry

I restored the file, deleted its second line and ran verify:

line 2: prev link broken (event lost, reordered or forked)
exit=1
Enter fullscreen mode Exit fullscreen mode

Delete the last entry

Reviewing this post I ran the case I had skipped: I copied the five-line journal, deleted its last line and ran verify.

journal chain intact
exit=0
Enter fullscreen mode Exit fullscreen mode

The journal had four lines instead of five and verify still printed "journal chain intact". Deleting the first line printed "line 1: prev link broken (event lost, reordered or forked)" with exit 1. My reading of why: each event stores the id of the one before it, so a missing event is only noticed when a later event points at it, and nothing follows the last one. I did not look for a separate record of the expected length. Run on aisync-cli 0.2.10. An independent rerun also checked three more cases on 0.2.10. Truncating the last two lines: "journal chain intact", exit 0. An empty journal: also "intact", exit 0. Appending a forged line with a wrong previous id: "line 6: prev link broken" and "line 6: id mismatch (event edited by hand)", exit 1. In that rerun aisync status and aisync doctor also said the chain was intact for the shortened journal, aisync report has no journal-length check, and git diff in the hub showed the deleted lines, so git history was the only detector I found. If you rely on the chain, keep the journal in git or record the line count somewhere else.

Restore it

With the original file back, verify printed journal chain intact and exited 0.

Why this matters when several agents share a repo

When Claude Code, Codex and Cursor all write to one journal, the question after a bad day is "which agent did what, and has anyone changed the record since". Every event stores the id of the one before it. An edit changes that event's id. Removing an entry that is followed by another one breaks the link to that next entry. Removing the last entry does not break any link (see above). An edit or a removal in the middle shows up as a non-zero exit, so a script or a CI step can check those two.

What this does not show

I did not test an attacker who recomputes every later hash after editing. A hash chain on its own detects accidental or careless changes. It is not a signature, so I would not call the journal tamper-proof. Only the cases in this post were run.

This post and the test run were prepared with AI assistance (Claude Code). The outputs above are copied from that run.

Top comments (0)