When an AI agent or clinical scribe writes to a database, developers assume that receiving an HTTP 200 OK or rows_affected: 1 means the physical database state matches what the agent authorized.
It does not. In our benchmarks across PostgreSQL 18.6 and FHIR R4 stores, application-layer responses frequently diverge from physical disk commits.
Under HIPAA and India DPDP 2023, storing raw patient notes in audit logs is a breach hazard. How SHA-256 digests and RFC 9943 SCITT structures solve this.
The empirical setup
We configured an isolated environment with a PostgreSQL 18.6 instance and an open FHIR store. A simulated autonomous agent was given scoped permissions to execute record updates.
Deedglass was attached as an out-of-band physical storage witness using PostgreSQL logical decoding (pglogrepl consuming the Write-Ahead Log) and a direct FHIR read-back verifier.
Code A settings file: the rules a tool reads before it acts.
# Deedglass evaluation rule
- id: check-record-integrity
match: { tool: "postgres.execute" }
when: >-
sql.kind == "update" && sql.tables == ["patient_records"]
&& !sql.unbounded_write
approval:
required: 1
roles: ["attending_physician"]
Deedglass
A sealed record you can check offline
Record 1043
- What ran
- Medication order, Bed 12
- Approved by
- Dr. N. Shah
- Check
- Matches
- Time
- 09:12
- The request
- Not keptA fingerprint only: 77d2…c41a
Each record is linked to the one before
- Record 1041
- Record 1042
- Record 1043
The observed divergence
The agent executed what appeared to be a single-field mutation. The HTTP layer immediately responded:
Code Data in JSON, the format software uses to pass records and settings.
{
"status": 200,
"message": "Resource successfully updated",
"rows_affected": 1
}
However, inspecting the PostgreSQL Write-Ahead Log (WAL) revealed a completely different story:
- An unindexed foreign key trigger fired asynchronously.
- A cascading constraint modified auxiliary clinical attributes.
- The actual rows mutated on disk exceeded the authorized parameter boundary.
The agent’s self-report claimed success on one row. The database transaction log recorded a multi-row divergence.
Why gateways cannot see this
Pre-execution gateways (such as API proxies or MCP network filters) intercept the call before it reaches the database. They can parse the SQL abstract syntax tree (AST), but they terminate at the socket layer.
They have zero visibility into:
- Asynchronous database triggers (
AFTER UPDATE) - Cascade foreign key rules (
ON DELETE CASCADE) - Storage engine lock aborts and partial rollbacks
- Physical write serialization conflicts
A pre-call gateway answers only one question: “MAY this request be sent to the socket?” It cannot tell you what the storage engine actually committed to disk.
The generic fix without any vendor
You do not need Deedglass to begin fixing this today. Any engineering team can improve their write integrity using native database primitives:
- Strict Statement Timeouts: Enforce
SET statement_timeout = '2s'on all agent database sessions. - Postgres RLS (Row-Level Security): Lock down tables so agent credentials cannot access rows outside their immediate operational scope.
- Transaction Isolation: Run agent writes under
SERIALIZABLEisolation if concurrent writes touch related records. - Trigger Auditing: Audit all legacy triggers to ensure they do not silently alter sibling tables during automated updates.
What this doesn’t catch
Honesty about technical boundaries is essential:
- Logical decoding verifies committed rows on disk; it does not evaluate the clinical wisdom or medical accuracy of a note written by a human doctor.
- If an agent writes garbage text into a text field, and that write was fully authorized by an attending physician, Deedglass reports
Matchesbecause the committed bytes match the authorized change. - Deedglass is strictly administrative and data-integrity infrastructure. It operates under a strict Non-SaMD (Software as a Medical Device) boundary and never provides clinical diagnosis.
How to reproduce it in 10 seconds
You can run this exact test against a local throwaway container:
Code Commands typed in a terminal. The text around it says what happens.
https://deedglass.com/spec/agent-action-provenance
The test runner will simulate an agent update, capture the WAL diff, and show you the exact discrepancy between what the tool reported and what the storage engine committed.
Written with AI assistance and checked against our claims register.