Your AI Agent Followed the Procedure. Which Version? A developer working on regulated-industry AI agents describes a bitemporal, append-only schema for versioned procedures, using PostgreSQL range types and an exclusion constraint to guarantee that two revisions of the same procedure never overlap in effective dates. Retrieval is keyed to an as-of timestamp taken from the business event rather than the current time, and embeddings are stored per (procedure_id, version, chunk_no) so vector search cannot surface a superseded passage. The approach is framed as a way to satisfy audit-trail expectations under 21 CFR Part 11.10(e) and EU GMP Annex 11, which the developer says most agent backends cannot currently meet. In regulated industries, an agent answer is only defensible if you can prove which rules were in force when it ran. Draft created: 2026-12-03 | Status: Draft, pending partner review | Vertical alignment E14 : regulated-industry AI SaaS pharma/life sciences compliance, research-integrity tooling ; no Email-2/3 sequences are active this week, so aligned to the 2026-12-03 market intel instead An agent tells a quality manager that a deviation on a batch record needs escalation, citing the cleaning procedure. Six weeks later an auditor asks which revision of that procedure the agent read, and whether it was the revision in force on the day of the batch. Most teams building agents on top of controlled documents cannot answer. The vector index holds whatever was last embedded, and the answer was never tied to a version. A typical retrieval pipeline chunks documents, embeds them, and returns the top-k nearest chunks. That works for a wiki. It breaks for SOPs, work instructions and policy documents, because those are versioned, approved, and effective-dated. Revision 7 of a procedure is valid from one date to another, and a record created inside that window must be judged against revision 7 even if revision 9 exists today. Three failure modes show up repeatedly in agent backends for regulated customers: Regulators do not prescribe an architecture here, but the expectation is stable. 21 CFR Part 11.10 e calls for secure, computer-generated, time-stamped audit trails that record actions creating, modifying or deleting electronic records. EU GMP Annex 11 asks for audit trails on computerised systems in the same spirit. An agent that influences a quality decision and leaves no trace of its inputs is a gap in that trail. The pattern is consistent in lean teams that have just raised and are moving into enterprise sales. The first version of the agent ships fast, usually one or two strong backend engineers plus a framework. It works in the demo. Then the first pharma or medtech security questionnaire arrives and asks about traceability, and the team discovers that provenance was never a first-class concept in the schema. Retrofitting is expensive because the missing data cannot be backfilled. You cannot reconstruct which chunks a model saw three months ago if you never stored them. That is why this belongs in the first sprint of the data model, before the second customer. Our recommendation is to treat procedures as bitemporal, append-only data and to store the retrieval set with every run. In PostgreSQL this is a small amount of schema. CREATE EXTENSION IF NOT EXISTS btree gist; CREATE TABLE procedure version procedure id uuid NOT NULL, version int NOT NULL, content sha256 text NOT NULL, body text NOT NULL, effective tstzrange NOT NULL, -- when this revision is in force approved at timestamptz NOT NULL, -- when the approval was recorded PRIMARY KEY procedure id, version , EXCLUDE USING gist procedure id WITH =, effective WITH && ; The exclusion constraint guarantees that two revisions of the same procedure never overlap in time. The database enforces it, so no application bug can create an ambiguous answer to "what was in force on this date". Retrieval then takes an as-of timestamp, and that timestamp is the date of the business event, not now . SELECT procedure id, version, content sha256, body FROM procedure version WHERE effective @ :event time::timestamptz; Embeddings live in a table keyed by procedure id, version, chunk no . A new revision adds rows and never updates or deletes old ones. Vector search is filtered to the revision set returned above, so the retriever physically cannot surface a superseded passage for a current event, or a current one for a historical event. With pgvector this is an ordinary join or a filtered index scan, and you keep one datastore to back up, validate and explain to a customer's IT security team. Every agent run then writes one immutable row: CREATE TABLE agent run run id uuid PRIMARY KEY, started at timestamptz NOT NULL, event time timestamptz NOT NULL, model id text NOT NULL, -- exact model identifier as returned by the provider prompt version text NOT NULL, retrieved jsonb NOT NULL, -- {procedure id, version, chunk no, sha256} output jsonb NOT NULL ; REVOKE UPDATE, DELETE ON agent run FROM app role; Three details matter. Store the content hash next to the version number, so a later edit to a row is detectable. Store the model identifier and prompt version, because a provider-side model update changes behavior even when your documents did not change. Revoke update and delete at the database level and add a trigger that rejects them for the table owner role used in migrations, rather than relying on code review. Add one integration test that replays the audit scenario. Create revision 1, run the agent, publish revision 2, run the agent for a historical event date, and assert that each run's retrieved field points at the right revision. Then pick any run id and assert you can reconstruct the exact prompt input from stored data alone. If that test passes, a customer questionnaire on traceability becomes a screenshot of a query instead of a two-week engineering project. Two cautions. First, an exact replay of model output is not guaranteed even at temperature zero, so what you can promise is reconstruction of inputs and a complete record of what the model returned, not bit-identical regeneration. Say that clearly in customer documentation. Second, this design gives you traceability, not validation. A computerised system in a GxP setting still needs its own validation approach agreed with the customer's quality team. tstzrange , and never update embeddings in place. SifrVentures https://sifrventures.com builds dedicated engineering teams for tech companies. Based in Berlin. Learn how we work https://sifrventures.com/how-we-work | Read more on our blog https://sifrventures.com/blog