AI Code Governance

How to Find AI-Written Code in Your Repos Without an AI Detector

Detectors guess at code. Attribution reads the record. Find AI-written code in your repos from merge and review history. Connect your estate free.

GR
Gil Rachlin
Diwo Team
November 9, 20266 min read
How to Find AI-Written Code in Your Repos Without an AI Detector

A detector guesses what the code looks like. Governance needs a record of how the change was made. Here's how to get the record.

This post is part of our AI Code Governance series. Start with the pillar: AI Code Governance: A 2026 Field Guide.

The CISO asks a plain question: what share of last quarter's merges did AI write? An engineering lead pastes a pull request into an AI-code detector and reads out the score. Sixty-two percent likely AI-generated.

She pastes the next one, from the same author in the same week. Thirty-one percent. (Both scores are illustrations, not measurements.) Nobody puts a probability in front of a board and calls it an answer.

What does it mean to detect AI-written code?

Two different things hide behind the phrase. One is classification: a model reads the code and estimates how likely a machine wrote it. The other is attribution: you read the record of the change and see which tool or agent produced it.

Search results for "detect AI-generated code" are mostly the first kind. Governance needs the second. A classifier gives you an opinion about text. Attribution gives you a fact about a change.

Cycode's 2026 survey of more than 400 CISOs found that 100% of enterprises have AI-generated code in production and 81% of security teams can't see it. The gap is visibility, not a shortage of opinions.

Why classifiers fail the audit test

A classifier can work as a hint. It is a poor basis for a decision, for three reasons:

• It can't be reproduced. Run it on another day, or after a small edit, and the score moves. An auditor can't re-perform it. • It can't be sealed. A probability isn't an observed fact, so there is nothing to freeze into a record that holds up later. • It can't name an owner. It says "likely AI". It doesn't say which agent, under whose account, approved by whom.

Reading every change by hand doesn't fix this either. Nobody watches the building.

Consider what happens when a developer reformats a function an agent wrote. The text changes, so the score changes. The history of the change does not. The tool that opened the pull request is still named in the record, and so is the person who did, or didn't, approve it. Not a guess about style. A fact about origin.

A score tells you what the code resembles. It never tells you who decided it could ship.

Where the facts already live

Your estate records more about authorship than most teams realize. You don't need to read the code to find it:

• Commit metadata. Co-author trailers, bot identities and tool-generated messages often name the tool that wrote the change. • Pull request history. Who opened it, who approved it, and whether anyone did before the merge. • Agent settings files. The agent's own configuration in the repo shows whether auto-approve is on and what it was allowed to run. • Runtime signals. What an agent actually did in production, tied back to the merge that shipped it.

Each is a machine-written value, read as it is. "This pull request merged with no recorded reviewer" is an observed fact. Nobody has to guess.

In a real 52-repo engineering org, the first Provenance connection surfaced 25 AI-authored pull requests merged with zero recorded human review. No classifier was involved. The record said so.

That finding didn't need a model's opinion about any line of code. It needed the merge history, read once and joined to the review record. Not a new gate for engineers, a question put to history they had already written. It also works backward: the same read covers last quarter, not only next week.

Know where attribution stops

Attribution has an honest limit, and a governance record should state it. If a developer pastes code from a chat window and strips every trace, no record says an AI wrote it. No tool, Provenance included, promises to catch deliberately laundered code.

What you can do is mark the limit. Repositories with no readable signal are blind spots, and a blind spot should hold your score down, not count as clean. The lower number is the honest one.

The absence of a trace is not evidence of human authorship.

That is the difference between detection and governance. Detection tries to be right about every line. Governance is clear about what it saw, what it didn't, and who decided.

What to do this quarter

Four steps, none of which needs a new tool or a change to how engineers work:

  1. Pull the trailers. Search a quarter of merged history for co-author trailers and bot accounts, and list which tools appear. That is your first honest count of AI-authored changes.

  2. Join it to review. For each flagged change, record whether a named human approved before the merge. Count the empty ones.

  3. Mark your blind spots. List the repositories where no signal exists, such as squashed history or shared accounts. Treat them as unknown, not safe.

  4. Write the rule. "AI-authored changes to sensitive repositories need a recorded human approval." Put it in your control matrix, and check it continuously instead of once a year.

An afternoon of this gives you a number with names attached. It also shows how much of the answer a classifier would have guessed.

Where Provenance fits

Diwo Provenance is the governance layer above the scanners you already run. It is not a scanner and not an AI detector. It reads signals your estate already emits (merge and review history, the agents' own settings files), attributes changes to the tools that wrote them, and weights them by how critical each repository is. It turns the result into decisions (fix, waive, accept) with a named owner, and seals the evidence for boards and auditors. It reads code signals, never your source. A coach, not a blocker.

Seeing your own estate takes about 15 minutes, free and read-only: Connect your estate free at https://provenance.diwo.ai/provenance/signup

Detection guesses at the code. Provenance records the decision.

Related reading

• AI Code Governance: A 2026 Field Guide: the pillar and the full operating model. • Who's Accountable When AI Writes the Code? • Your AI Agent Has Your Production Keys: Here's How to Find Out • What is AI code governance?

Frequently Asked Questions

Can you reliably detect AI-generated code?

Not from the text alone. Classifiers return probabilities that shift between runs. Reading the change record gives observed facts, with blind spots marked wherever no signal exists.

Do I need to give a governance tool access to my source code?

No. Provenance reads signals such as commit metadata, review history and agent settings. It is read-only, works retroactively from history already in your repositories and never needs your source.

What about code someone pasted from a chat window?

If every trace is removed, no record can show it. Provenance marks those repositories as blind spots and holds the score down instead of counting them as clean.

See it in action Your scanners detect. Provenance decides. Book a working demo →

TagsAI code governancedetect AI-generated codeAI code attributionAI-written codeAI code detectoraudit
See it in action
See a decision made on your data?