0 FAIL, 12 Contradictions: How My Agent Memory System Lied to Me
A green check is not the truth. The liar was my verifier.
Every number in this post points at a file or a command output in the repository. If it is not there, it is not here.
Note: the "12 contradictions" in the title belong to a different project — a learning project I audited. AHP's own cold reads found 8 / 3 / 5. Both teach the same lesson, so they are told together.
1. A green dashboard
Let me be concrete about what I built, otherwise the "gotcha" later lands soft.
I built a repo-local handoff protocol for AI coding agents, AHP (Agent Handoff Protocol) — a machine-checkable handoff protocol. It does not try to remember more. It answers one question: is the current state trustworthy, and can the next session pick it up?
Four files:
| File | Owns |
|---|---|
AGENTS.md |
Agent entry point, boundaries, handoff contract |
INDEX.md |
A file map — and no dynamic state |
PROJECT.md |
Long-term decisions + a derived status block |
HANDOFF.md |
Current work unit, exact pause point, next action, acceptance |
Plus a status machine: PAUSED → ACTIVE → PAUSED / BLOCKED / COMPLETE / MONITORING. ACTIVE requires a future lease; PAUSED and COMPLETE must not keep an owner, a session, or a lease residue (SPEC.md §3).
Then twelve read-only gates, run in one command:
PASS CORE_FILES core files present
PASS HANDOFF_SCHEMA frontmatter is valid
PASS HANDOFF_TIME timestamps are ordered
PASS LEASE PAUSED has no residual lease
PASS VERIFY_COMMAND verification command recorded
PASS HANDOFF_BODY 8 sections and next action are present
PASS HANDOFF_FRESH sections 4-6 are fresh (0 days)
PASS INDEX_MAP INDEX is a map and its links resolve
PASS PROJECT_SYNC derived status matches HANDOFF
PASS MEMORY_LINKS memory index and links are closed
PASS SECRETS no high-confidence secret pattern found
PASS GIT_STATE tree clean; timestamp matches the commit
[ahp] 0 FAIL / 0 WARN / 12 PASS / 0 SKIP
One number matters more than the others: fail-open gates are forbidden. Every gate needs a negative fixture that must turn red; a check with no failing fixture is a claim, not a check. At v0.1.0 the suite was 22 tests: 15 negative "must turn red" fixtures (one per gate), 6 CLI/scaffold tests, and 1 positive "a valid project should pass everything". npm test → 22/22. It is 27 tests (19 negative fixtures) now, after the SECRETS gate grew a docs/ scan — the numbers moved, the method did not.
That is where I thought the story ended.
Then I ran a cold read: a zero-context session that only got the four core files, and had to answer five questions — what is the current work unit and status, what is the exact next action, what was the last verification command and its result, what are the top three risks, and which statements in the four files contradict each other.
It found 12 contradictions.
The gates were 0 FAIL.
2. What the gates could not see
First, whose "12" this is: it belongs to another project — a learning project whose gates were all green while a zero-context reader found 12 contradictions in its four core files (docs/case-studies.md, case 8):
-
current_filenamed one file while §3 of the same document said "no file is being edited"; - the acceptance criteria lived in two files — three items in one, four in the other;
- the project documented three different verification command sets;
- the long-term summary's "last updated" header was four days older than its own newest entry;
-
INDEX.mdsaid "map and status" in one line and "map only" in another; - the status was
ACTIVEwith a lease that had expired 34 minutes earlier; - the recorded "last verification command" was a lifecycle command (
ahp pause), not a verification.
The production project I audited was bigger: 70+ memory files, 279 wiki links, a 211 KB HANDOFF.md, a 185 KB long-term summary, 5 derived mirrors. It had the same disease: §1 said the work unit was accepted and pushed, while §2, §5 and the frontmatter still said "in progress, uncommitted files" — with a clean tree and the commit already on the remote. All gates green; the cold read found it.
Lesson one: structural checks are necessary but not sufficient. Eight sections can coexist with a contradiction. I wrote that into the protocol itself (docs/limits.md §2: "the worst failure is not a red gate — it is a green gate over a contradictory handoff").
What about my own repo? Same rules: zero context, four files only, one contradiction at a time.
-
v1: eight issues. A stale warning about the repo living inside a larger workspace git repo; an acceptance criterion that omitted the cold read; four different orderings of "test → cold read → commit/tag → article" across
PROJECT.mdandHANDOFF.md; alast_verified_commandthat recorded onlyahp checkwhen the real verification also rannpm test; a vague "finish the docs" when the docs were already written; and a missing statement thatPROJECT.md's status block is derived. - v2: three issues. Release sequencing (requiring a clean tree before committing) and local-vs-remote tag ambiguity; and where the next work unit is opened.
- v3: five more, smaller and semantic.
Eight, three, five — every single one was a documentation issue. The code was fine. The handoff was not.
That is exactly the failure AHP exists to catch, and it also showed that a cold read is not a one-off: it iterates, and every round produces something.
Where those contradictions ended up
The value of a cold read is not the discovery — it is that the same thing cannot happen twice. Every one of the 12 became either a gate assertion or a written "accepted, not fixed".
Three became gates, because the wording of the problem and the wording of the check are nearly identical:
| Contradiction found | Gate | What the gate actually checks |
|---|---|---|
current_file contradicts §3 |
HANDOFF_BODY |
if §3 says "none", current_file must be "none" |
Status is ACTIVE but the lease expired |
LEASE |
ACTIVE requires a future lease_until; PAUSED/COMPLETE must not keep residues |
| The last verification command is a lifecycle command | VERIFY_COMMAND |
last_verified_command cannot be ahp start/ahp pause-style |
The rest did not become gates, not because they matter less, but because none of them can be machine-checked reliably:
| Contradiction found | Why no machine can check it |
|---|---|
| Three different verification command sets |
VERIFY_COMMAND inspects one field; it cannot see three documents each describing their own |
| Acceptance criteria split across two files, with different counts |
HANDOFF_BODY requires a numbered action in §4 and a non-empty next_action; it does not count acceptance items |
| The summary's "last updated" header predates its own newest entry |
HANDOFF_FRESH measures the age of dates in §4–§6 (threshold: 21 days); it does not compare a header against an entry |
INDEX.md says "map and status" in one line and "map only" in another |
INDEX_MAP matches dynamic state rows; it does not recognise two different paraphrases of a policy |
Those four became written acceptances instead of gates. A gate cobbled together to fit a case manufactures false greens — the one thing this whole design exists to prevent.
3. Worse: the verifier itself lies
The contradictions above were at least catchable by a cold read. The failures that actually scared me were of another kind: my negative tests told me a gate was broken, when my tests were the broken part.
Four real cases. All of them are in docs/lessons-from-production.md §3 and docs/case-studies.md.
3.1 The fixture was not past the threshold, so "red" was fake
The freshness gate fails above 21 days (the threshold comes from freshness.handoffDays in ahp.config.json). My negative fixture built a 20-day-old HANDOFF.md.
20 < 21, so the gate correctly emitted a WARN, not a FAIL. My test expected FAIL, so it could not turn red.
It looked like a broken gate. It was a bad fixture. Two fixes: push the fixture clearly past the threshold (40 days), or stop asserting the human-readable sentence.
3.2 The gate read the real repository, not the fixture
This one was worse. The fixture was written into a temp directory, but the git status and git log calls ran against the real project. The real repository was dirty at that moment, so the gate skipped itself and reported success.
The test said "not red". The gate logic was perfectly correct.
Fix: the test creates a temp git repo, passes the root explicitly, and every git command uses that root. Isolation is part of the test, not a convenience.
3.3 The assertion tested the message, not the gate
The gate printed 21 days; the test looked for 20 days. The test failed while the gate worked.
The reverse is worse: change the message and the test silently passes, so the gate is never exercised again — it becomes a decoration that can never fail.
Fix: assert the gate ID and status (LEASE / FAIL), use a regex for numeric details, and assert the exit code too.
3.4 A command named --check that wrote files
This one deserves its own paragraph.
A backup script took --check as an argument. Its behaviour: copy the source into the backup first, then enter the comparison branch, then report the resulting git differences. Result: it reported "10 differences" and left 10 files modified in the backup repository.
A check that writes is not a check. It is a migration wearing a misleading flag.
Fix: compare first, write only behind an explicit non-check flag, and verify git status before and after every --check.
AHP carries the same rule: gates must be read-only, and sync is the only thing that writes.
4. What I changed
Five moves, each of them turning a discovery into "this cannot happen again".
1. One current-state source. Dynamic state lives in HANDOFF.md and nowhere else. INDEX.md is a map, so the INDEX_MAP gate checks that it has not grown a status board. Long-term decisions live in PROJECT.md. The same fact is not allowed three homes.
2. Derive, do not duplicate. The status block at the top of PROJECT.md is generated from HANDOFF.md by ahp sync, not written by hand. Hand-written means it will drift, so ahp sync --check exists to catch the drift. Fields a tool can generate should not be maintained by discipline.
3. Negative tests are the product. Twelve gates, each with a fixture that must turn red. The cost is that I had to write 15 negative fixtures at v0.1.0 (19 now); the payoff is that every gate is still alive.
4. Isolated git fixtures. See 3.2.
5. The cold read is part of the protocol. A cold read is not "read the README and summarise it" — it is a zero-context session answering five specific questions. And every contradiction it finds must become either a gate assertion or a written acceptance. "Read it and forget it" is forbidden.
One more rule, borrowed verbatim from an external audit: every finding becomes either a gate/test or a written accepted risk, with a reason and a trigger for re-evaluation. It is the rule that stops "I know about this problem" from dying in a chat log.
5. What this does not fix (and what I will not claim)
It is easy to read the above as "install this and your memory system is safe". It is not. Stating the limits matters more than stating the wins.
-
Green is not true. The gates can see that a file exists, that the frontmatter is well-formed, that timestamps are ordered, that the lease has not expired, that the derived block has not drifted, that the index has not turned into a status board, and that no obvious key is committed. They cannot see whether
next_actionis the right next action, whether the recorded verification actually ran, whether two files contradict each other in prose, whether a remembered fact is still true in the world, whether aCOMPLETEunit was actually accepted by a human, or whether the agent respected its boundaries. The worst failure is not a red gate — it is a green gate over a contradictory handoff. -
Two models agreeing is not evidence. My workflow is one writer plus one independent reviewer: the reviewer is read-only, returns findings with
file:lineand evidence, and the primary adjudicates each one — fix it, turn it into a test/gate, or accept it in writing with a reason. The reviewer cannot merge. Tests and code always beat model consensus. Two models can also agree and both be wrong in the same way. - AHP is not a memory system. It does not replace Mem0 / Letta / Zep, does not do vector retrieval, does not do long-term memory extraction. It is four files, one status machine, a set of read-only checks, and one cold read.
- AHP is not an access-control system. A lease is a soft lock, not authentication. It prevents accidents and low-grade concurrency, not malice.
- AHP is not a security guarantee, and it is not an attack tool. It touches no live target and does not "hack things automatically". It just makes the handoff state harder to fool the next person.
One more thing I deliberately keep in the docs: docs/limits.md is not fine print at the bottom of a README. It is part of the protocol. A guarantee you cannot back is a disclaimer, and disclaimers are a form of dishonesty.
6. Try it yourself
You do not have to take my word. Use my repo as the target:
git clone https://github.com/cheah505-cyber/agent-handoff-protocol.git
cd agent-handoff-protocol
npm test # 22 tests at v0.1.0; 27 now
node bin/ahp.mjs check # 12 gates
node bin/ahp.mjs init /tmp/demo && cd /tmp/demo
# now deliberately change HANDOFF.md's last_verified_command to "ahp pause"
# run check again and watch VERIFY_COMMAND turn red
Go further: stale the derived status block in PROJECT.md, run node bin/ahp.mjs sync --check and it fails; run node bin/ahp.mjs sync and it is repaired.
If you want to run the same checks against your own agent memory, I wrote them up as a practical, authorized-assessment checklist: docs/memory-security-checklist.en.md. Thirteen items, each with what to inspect, why it matters, what evidence to collect, and what counts as pass versus must-fix. It covers the memory inventory, poisoning, stale facts, hook injection, cross-agent trust, fail-open gates, checks that write, secrets, template supply chain, authorization scope, and report/retest.
Repo: https://github.com/cheah505-cyber/agent-handoff-protocol
Checklist: https://github.com/cheah505-cyber/agent-handoff-protocol/blob/master/docs/memory-security-checklist.en.md
The checklist is free and lives in the repository. If you want the packaged version (team rollout checklist + cold-read question card), leave an email and I will send it when it exists.
It is not an "automated scanner". It is a 2–5 day manual assessment process — use it only on systems you are authorized to assess.
7. One sentence
If this post leaves you with a single line, let it be this:
A handoff system is not a memory system; it is a truth-maintenance system.
The moment its checks stop being able to fail, it becomes another source of drift.
And the cheapest place to start is not a tool. It is this: the next time you hand off, let someone with no context read your state files. Whatever they cannot reconstruct is where your system is currently lying to you.
Appendix: where every number comes from
| Number | Source |
|---|---|
| 12 gates, 0 FAIL |
node bin/ahp.mjs check; gate list in SPEC.md §6 |
| 22 tests at v0.1.0 (15 negative, 6 CLI, 1 positive); 27 now | npm test |
| 12 contradictions in the learning project |
docs/case-studies.md case 8 |
| Cold reads 8 / 3 / 5 on AHP itself |
docs/lessons-from-production.md §3.7; HANDOFF.md §1 |
| Production project: 70+ files, 279 links, 211 KB, 185 KB, 5 mirrors |
docs/lessons-from-production.md, preamble |
| 21-day threshold / 40-day fixture |
ahp.config.json; docs/limits.md §3.1 |
| 20-day fixture |
docs/lessons-from-production.md §3.4; docs/case-studies.md case 3 |
--check left 10 files modified |
docs/lessons-from-production.md §3.5; docs/case-studies.md case 5 |
| Lease expired 34 minutes earlier |
docs/case-studies.md case 6 |
| 5 derived mirrors |
docs/lessons-from-production.md §6 |
| The five cold-read questions |
docs/limits.md §6; AGENTS.md handoff contract |
License: MIT. The protocol and the CLI are open source.
Top comments (16)
A green gate over a contradictory handoff is a punch list where every box is checked and the door still doesn't close. Each check was true, and none of them asked whether the pieces agree with each other. The cold read is the walkthrough by someone who wasn't on the job, and that's the inspection that catches two sheets saying different things. Requiring a failing fixture for every gate is a good rule on its own. At ML Systems we want the same test for a handoff note: can someone with no context pick it up and say what's next.
The punch-list image is the sharpest version of this I have seen: every box ticked, and the door still shut.
Your one-question test is the right cheap version, and I would keep it — "can someone with no context pick it up and say what's next" is the cheapest probe there is, and it catches most of what a punch list misses.
One caveat, taken straight from the failure mode you named: "say what's next" can be answered confidently and still be wrong. A note can be internally consistent and stale, or consistent with itself and inconsistent with the repo it describes. So I would add two things to the one question:
Then the test becomes: the fresh reader writes the next three steps, and every step must be traceable to a specific file rather than inferred. Any step they had to guess is a failed handoff — not a failed reader.
One asymmetry worth naming: gates are cheap and repeatable, a cold read is expensive and human. That is why I run the read when the handoff changes hands rather than per commit, and why I still keep the twelve gates underneath — they do the part a human should not have to do.
And the closest thing to a failing fixture for a prose note is a disconfirming question: ask the fresh reader something the note claims, and see whether they can answer it from the note alone rather than from your head. If they have to come back to you, that note is the gate that did not turn red.
"What would you redo by mistake?" is the better question, and I'm taking it. On a job that's how a bad handoff shows up: the new crew redoes something that was already done, or builds over something that wasn't. Making every next step trace to a file, and calling a guessed step a failed handoff and not a failed reader, puts the blame in the right place. Running the cold read when the work changes hands, not on every commit, is how inspections get scheduled too.
That distinction is the one I under-weighted: rework is visible, but building on a step that never happened is silent until the foundation is covered. The protocol's only defence against the second is traceability —
next_action_fileandnext_action_anchorforce the next action to point at a line, andVERIFY_COMMANDrefuses a lifecycle command (pause,complete) as the last verification, because "I paused" is not evidence that anything ran.Your scheduling point matches how the two checks differ in cost.
checkis cheap and runs at every pause; the cold read is expensive and runs when the unit changes hands. Running the cold read per commit would train people to skim it, which is the alarm-fatigue failuredocs/limits.mdwarns about.And "a guessed step is a failed handoff, not a failed reader" is already in
docs/limits.md§7, credited to your earlier comment. It is the sentence I would keep if the rest were cut."The liar was my verifier" is the line I'll remember. A checker that only checks a handoff's shape will happily pass a handoff that is wrong. How did you run the cold reads: a fresh session with nothing but the four files?
Fresh session, four files, no chat history — that was the setup. v1/v2/v3 were three separate fresh contexts, each asked the same five questions: current unit and status; the exact next action and what a new session would redo by mistake; the last verification command and its result; the top three risks; and which statements in the four files contradict each other.
The part that made it useful was comparing the answers with the live repository by hand. A cold read that only summarizes the project passes; one that names a next action you can see is wrong is the one that pays. v1 found 8 documentation problems, v2 found 3 sequencing/ambiguity ones (validation order on a clean tree, local vs remote tag, where the next unit gets opened), v3 found 5 more. The final pass found none.
If I had to keep one question it would be "what would be redone by mistake?" — it catches work that is finished but unmarked, which a status line never shows.
This landed for me because the failure mode is so familiar: the checks pass, so you stop looking. The cold read idea is the part I'll actually steal — a zero-context session answering five questions about state files is cheap, and it found things twelve green gates missed. The 3.2 case stuck with me too: fixtures written to a temp dir while the git commands ran against the real repo, so the gate skipped itself and reported success. That's the kind of bug that makes you distrust your own suite. How often do you run the cold read in practice — at every handoff, or only before releases?
Thanks — the 3.2 case is the one that made me distrust my own suite: the gate was correct, the test was the liar.
On cadence: the cheap answer is "whenever the handoff is about to change hands", which in practice means before a pause and before a release. This repo's cold reads were three passes before v0.1 (8 / 3 / 5 issues), because that is when the four files were being rewritten anyway. The backstop for "you forgot" is the freshness gate — HANDOFF §4–§6 must carry a date within 21 days, so a stale handoff fails structurally even if nobody reads it.
What I would not claim: a schedule catches the semantic problems. It catches the ones that are visible when someone with no context tries to reconstruct the state — which is exactly the class the gates cannot see.
The distinction between structural checks and a "truth-maintenance system" nails why handoffs quietly rot—eight required sections can all pass schema validation while contradicting each other in prose.
Two things stand out from the cases you audited:
ahp pauseaslast_verified_commandand letting an expiredACTIVElease sit 34 minutes pastlease_untilare both state-transition bugs disguised as valid metadata. TreatingVERIFY_COMMANDwith an explicit verb denylist/allowlist and auto-transitioning expired leases into an explicitSTALE/EXPIREDstate keeps the next session from trusting a dead lock.Also appreciated §3.2 (fixtures running
gitagainst the real repo instead of an isolated temp root)—silent false greens in the verifier itself are much harder to spot than a failing gate.Both of those are the right things to pull out.
On
last_verified_command: a denylist is the weakest form of that check, because it only knows the verbs someone already got wrong. The property I actually want is "this command could have failed in the state we just declared" —ahp pausecan't, a test can. So the field has to point at a command that exits non-zero for the wrong state, and the only way to know that is to have run it against that state. Same rule as the rest of the suite: a verification command with no failing case is a declaration.On expired leases: I would rather compute EXPIRED than store it. Adding it to the status enum lets a writer claim it, and the claim is what we are trying to stop trusting.
lease_untilis already the fact; "expired" is a derived read, so the reader's gate should fail, and the next session should treat a failed lease as EXPIRED no matter what the file says. A stored state would be a second source for the same fact — the exact bug the comment below yours describes.The cross-harness point is the one I under-sold. A fresh context in the same client inherits the same tooling assumptions; a different harness is a stronger test. My three cold reads before v0.1 (8 / 3 / 5 issues) all ran in the same setup — that is a weakness in my evidence, not a feature of the method.
Several of your twelve have the shape of a bug class I counted in August: eleven bugs in two days with no broken code, only a second source for the same fact. An onboarding tour kept its own list of pages next to the menu, 7 against 14. A tool count was written in ten files. Each copy was right on the day it was written. A cold read finds the ones already there. What stops the next one is giving each fact one owner, and making the other places read from it or fail a check when they don't match.
Eleven bugs in two days with no broken code is the pattern exactly: a duplicated fact is not a documentation problem, it is a second owner.
Your two examples are the two shapes it takes. The tour list against the menu (7 vs 14) is a copy somebody maintained; the tool count in ten files is a copy nobody maintained. Both were true the day they were written, which is why review did not catch them, and why "remember to update both" never holds for long.
What I would add: "make the other places read from it" needs a mechanism, or the drift just moves into the mechanism. Two that survive. Derive the copy on every write — in this repo the PROJECT status block is generated, and a gate fails when it does not match the source. Or delete the copy and make the reader resolve it. A check that compares two copies only works if the check must turn red; otherwise you have added a third copy of the same fact, and the check is the one nobody maintains.
One caveat from this week: a count in published prose has no single owner. Markdown has no include, so "the suite has 27 tests" is a hand-written copy of a fact that moves. Mine drifted twice. The honest fix is not a check — it is to stop quoting numbers that move, or to label them "as of ".
Your last sentence is the whole design: one owner, the rest read or fail.
On 'Markdown has no include': the nearest thing I've found is to stop writing the fact in prose at all. The moving value lives in one file's frontmatter, every other file links to that file instead of restating it, and a check fails when a second file carries the same field. That would have caught your acceptance criteria living in two files with different counts. It does nothing for two paraphrases of one policy, which is where your cold read still earns its place. (I work on iwe, an open-source CLI that queries markdown frontmatter and links that way.)
That is a stronger version of "make the other places read from it": it turns a duplicate into something a check can see. AHP does it in one place already — the status block in
PROJECT.mdis derived fromHANDOFF.md's frontmatter byahp sync, andPROJECT_SYNCfails when the block differs, so the acceptance text is not restated by hand.INDEX_MAPalso forbids dynamic state in the index.What it does not do is scan for a field that reappears in a second file. In your shape that is cheap: parse the frontmatter of the four files, fail when a key outside an allowlist appears twice. I have written it down as a v0.2 candidate next to the superseded-by check another reader proposed.
The paraphrase case is the one I would not try to gate. Two sentences can carry one policy with no shared tokens, and a check that guesses would produce exactly the false confidence the article is about. That stays with the cold read.
iwe sounds like the right layer for the mechanical half.
Every gate needs a negative fixture that must turn red. I've been building the same thing at a much smaller scale, and I hit a wall your fixtures can't reach.
I keep people's exact words on one page: eighteen short lines, each printed the way it was said, each with the speaker's written yes and the message id it came from. That's a provenance chain, not a check. There is no second copy, so there is no fixture. You can't build a test that turns red for a sentence nobody ever wrote down.
The only failing test a person's line can have is that person saying "no, that isn't what I said." Which makes the checker and the subject the same body. By your rule, that's a claim.
So, a real open question: is the read-back the floor for unrecorded speech, or is there a way to make the check independent of the speaker who gave the line? (The page, if the shape helps: pub-a941bfd863a24f91a60e6c4979c18a... )
This is the best version of the question, and I don't think there is a clever way around it. Two different things are being checked, and only one of them can have a fixture.
Integrity of the record is testable. If the line was written down with a consent and a message id, hash the exact words at consent time and fail when the stored copy diverges by one character. That is a real negative fixture: mutate a quote, the check must turn red. It proves the record is unchanged since it was attested — nothing more.
Truth of the quote has no independent fixture once there is no recording and no second witness. Read-back is the floor, and yes, that makes the checker and the subject the same body. The honest move is not to invent a test — it is to refuse to call it verified: mark those lines "attested, not verified" and never let a gate report them green. That is the CANNOT VERIFY state in my checklist; the failure mode is pretending a re-confirmation is evidence.
If the stakes justify it, the only thing that adds independence is another party: a second reader at consent time, or the speaker's own later revocation recorded as a new dated fact. Both are weaker than a recording, and both are honest about being weaker.
So: read-back is the floor for unrecorded speech. What you can still make machine-checkable is that nobody edited the floor afterwards.