Dev.to AI ๐Ÿค– Ai ๐Ÿ‘ 0 ๐Ÿ“– 7 min read

AI Audit Evidence, Part 11: Written Down Is Not the Same as Enforced

AI Audit Evidence, Part 11: Written Down Is Not the Same as Enforced We build a runtime that lets AI agents take real write actions inside enterprise systems: create a record, send a call to another service. Every acti

AI Audit Evidence, Part 11: Written Down Is Not the Same as Enforced

AI Audit Evidence, Part 11: Written Down Is Not the Same as Enforced

We build a runtime that lets AI agents take real write actions inside enterprise systems: create a record, send a call to another service. Every action carries permissions, approvals, and a record someone can review afterwards.

The earlier pieces in this series asked what a record can prove. This one asks a question one step earlier: what makes a sentence in a contract actually count?

The short answer: writing it down is a description; only something that can turn the build red is a constraint. Between the two lie four layers, and each one was pulled out by a reader.

1. He asked about the form, not the content

A reader followed this thread for several rounds. At one of them he asked:

Does the contract now name the skip-fails behaviour as a requirement, or does it describe the test and leave the enforcement implied?

He was not questioning whether the thing should be done. He was asking whether the contract wrote it as a requirement or only as a status report.

That question stopped us, because the answer was embarrassing. Our contract said:

A run that would skip it is a failure.

It reads firmly, but it is a declarative sentence: it states a fact โ€” if someone skips it, that is a failure. It does not say must. It imposes nothing on any later edit.

2. A declarative sentence is true only on the day it is written

The problem with a declarative sentence is not that it is wrong. It is that it correctly describes only the day it was written.

At that time the same section still called the concurrency test "a guard to add when such a deployment exists". The test already existed. The contract lagged the code by one line, and a reader meeting it first would think the test was not built yet.

Two things changed. One restored the fact the contract had lagged โ€” the test is built, so it now says to extend it, not to write it. The other mattered more, and it changed not the fact but the mood:

  • a run that would skip it must fail;
  • a lane that passes without running does not satisfy this section;
  • a green lane may be read only as "the property was exercised".

The rule that came out of that round: anything a reader might rely on cannot be written as a status report. A status report rots with the implementation, and it rots silently.

3. A requirement belongs where it can go red

With the wording fixed, the reader asked the next question:

is 'a run that would skip must fail' enforced by the workflow itself, or written in the contract?

Another cut straight to the bone. A "must" in prose rots exactly the way a "is" does.

We checked the CI. The flag lived in the environment of one test step. Anyone deleting that line would make the suite skip and the lane go green โ€” on a requirement we had just written as "must". He had described that rot line for line.

The fix was two minimal moves:

  1. the flag moved from step-level env to job-level env (PG_SNAPSHOT_REQUIRED: '1');
  2. a step before the suite reads the same variable and exits non-zero when it is missing:
- name: the snapshot case must not skip
  run: |
    if [ "$PG_SNAPSHOT_REQUIRED" != "1" ]; then
      echo "::error::PG_SNAPSHOT_REQUIRED is not 1 - the snapshot case would skip and report green"
      exit 1
    fi

Now the cheapest accident โ€” deleting the flag โ€” breaks the job instead of quietly falsifying a claim.

4. A guard cannot live in the file it guards

After that step I felt settled. The reader did not let us stay settled for long:

The remaining gap is honest too: the guard and the thing it guards live in the same file, so a careless delete takes both.

Right. The flag and its self-check both sat inside migration-consistency-postgres. One careless edit could remove both without that job turning red โ€” it would simply stop checking itself.

He asked whether there was a CODEOWNERS file, or a required reviewer on workflow changes. The answer was no to both. There is no CODEOWNERS anywhere in the repo; branch protection is a server-side setting invisible from the checkout; and on a single-maintainer repository "a required review" is not something the owner can satisfy โ€” GitHub will not let someone approve their own change. Adding a file that looks like protection and blocks nothing would be worse than adding none.

What can actually go red is a different job that reads the file from outside:

workflow-invariants:
  steps:
    - uses: actions/checkout@v5
    - name: the snapshot lane keeps its flag and its self-check
      run: |
        set -eu
        f=".github/workflows/ci.yml"
        grep -q "PG_SNAPSHOT_REQUIRED: '1'" "$f" || { echo "::error::the snapshot flag is missing from $f"; exit 1; }
        grep -q "the snapshot case must not skip" "$f" || { echo "::error::the snapshot self-check step is missing from $f"; exit 1; }

Delete either line from the job above, and workflow-invariants fails.

5. The recursion ends at a person

But delete workflow-invariants itself, and nothing catches it.

That is the last answer of this round, and the reader gave us the words:

The recursion point is the real lesson: at some layer the check has to be a human reading a diff.

We wrote that into the contract: a human reviewing the diff is not an optional fallback, it is the final layer of the chain. And the person needs a standard to compare against, not improvisation โ€” the "must fail" line is in the contract, and the workflow points at it. A diff that removes the guard does not just look careless; it contradicts a written requirement.

The same reader also asked whether the contract is hand-written or generated from the code it governs.

Hand-written, and the sentences that matter cannot be otherwise. What can be pinned is pinned: protocol vectors live in the contract repo, byte-hashed and replayed by tests; a release gate refuses to let a release claim a capability with no implementer; a compatibility check resolves what the pinned submodule actually holds instead of trusting the table that names it. Those mismatches turn the build red.

What remains is prose: no generator, no monitor, and the detector is the person reading it. The two fixes this round โ€” the isolation assumption and the workflow self-guard โ€” were both pulled out by a reader, which is exactly the proof: for these sentences, the last detector really is a person.

An open question

Every layer of this chain moves the check earlier and makes the failure louder. The last layer is still a person.

So: if the last layer is always a person reading a diff, is the sentence in the contract constraining the code, or constraining the person who reads it?

The two answers lead to different maintenance. The first requires the sentence to change with the code. The second requires it to stop a person. We currently write for the second โ€” as an obligation, checked by a human โ€” but I am not sure that is the right one.

Appendix: three things this thread did not build

Three branches of the same thread are still open. They share a status: registered, not implemented.

  1. The idempotency key is enforced by the target. We mint an Idempotency-Key per logical call, but our own replay guard only fires when an effect row was recorded. A not_executed leaves no effect row, so the same call in the same conversation can be sent again; the target's dedupe is the only thing standing between the retry and a second write.
  2. The receipt has no first-party producer. A target may declare basis=receipt, and we record the kind. But none of our own endpoints accepts Idempotency-Key, so KeelBase as a target keeps no record of what it accepted. The declaration slot exists (ToolCapabilityDeclarations.dedup, three-valued) and has no consumer.
  3. basis does not reach the export. The read surfaces carry it (the claim list, the lookup history, the console); the six-column export has no column for it. The field exists so a reader can tell "not there now" from "never accepted" โ€” and the export flattens it back into one word.

All three are registered as remediation items (R-9 / R-10 / R-11), not planned deliverables. They are listed here because this piece is about writing down not counting โ€” and that applies to us too.

The implementation described here comes from the open-source project KeelBase:

Drafted with an AI assistant. The system, the positions and the mistakes are mine.

๐Ÿ“ฐ Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.