DEV Community

Dakota Wu
Dakota Wu

Posted on

Provenance Records for AI-Proposed Refactor Diffs

An illustrative scenario: a four-person team merges an agent-proposed refactor of a messy module, tests pass, and the diff ships. Six weeks later nobody can say which inputs, model version, or approver produced it.

Characterization tests prove behavior held; they do not record who decided, or against what. W3C PROV-DM supplies a usable vocabulary here: an activity uses input entities, generates output entities, and an association names the responsible agent (https://www.w3.org/TR/prov-dm/). That same specification is explicit that lineage does not certify output correctness, so keep the boundary visible or the record becomes false assurance.

Steps

  1. Hash the inputs: base commit SHA, test-suite revision, and the exact task text handed to the agent.
  2. Name the activity and the agent: run id, UTC timestamp, pinned model identifier, prompt revision, and the human who launched the run.
  3. Record attempts and potential side effects, not only the final diff. Retries add load to an already overloaded dependency, and backoff with jitter spaces attempts without proving an earlier call had no side effects (https://aws.amazon.com/builders-library/timeouts-retries-and-backoff-with-jitter/). List every attempt and any external write it could have caused.
  4. Attach approval as a separate field, because lineage and sign-off are two distinct claims.
# Illustrative schema only; never executed as shown.
activity: refactor-run-4412
used: [base_commit:9f3c1a, tests_rev:2b7e]
agent: {model: pinned-version, prompt_rev: 7, operator: dwu}
generated: diff_sha256:1ac9f0
attempts: [{n: 1, retried: false}]
approved_by: reviewer-id
Enter fullscreen mode Exit fullscreen mode

Test

Pick one merged AI-proposed change from the last quarter and reconstruct it without asking the author. Expect to identify the base commit, the agent configuration, and the approver within a few minutes. If you can produce the diff but not the approver, the record is lineage-only: add the approval field before scaling the practice. If attempts appear without a side-effect note, do not assume idempotency; verify the external write directly instead.

Limits

Skip this for throwaway spikes and local experiments that never merge. Skip it as well when a diff is regenerated deterministically from already reviewed source, where the generator itself becomes the reproducible artifact.

This article was created with AI assistance.

Top comments (0)