<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: xueyuan Pang</title>
    <description>The latest articles on DEV Community by xueyuan Pang (@pangxueyuan2creator).</description>
    <link>https://dev.to/pangxueyuan2creator</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4072721%2Fdaf61cf7-1e78-45f8-9bf4-031d7ebe6b63.png</url>
      <title>DEV Community: xueyuan Pang</title>
      <link>https://dev.to/pangxueyuan2creator</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pangxueyuan2creator"/>
    <language>en</language>
    <item>
      <title>Why AI-Generated Code Needs Independent Verification</title>
      <dc:creator>xueyuan Pang</dc:creator>
      <pubDate>Tue, 11 Aug 2026 12:58:42 +0000</pubDate>
      <link>https://dev.to/pangxueyuan2creator/why-ai-generated-code-needs-independent-verification-1j88</link>
      <guid>https://dev.to/pangxueyuan2creator/why-ai-generated-code-needs-independent-verification-1j88</guid>
      <description>&lt;p&gt;Disclosure: I maintain &lt;a href="https://github.com/pangxueyuan2-creator/patchwitness" rel="noopener noreferrer"&gt;PatchWitness&lt;/a&gt;, the open-source project used in the reproducible example below.&lt;/p&gt;

&lt;p&gt;Coding agents have changed the economics of software modification. Work that once occupied an engineer for an afternoon can now produce a plausible patch in minutes. That is a real advance—but it also moves the bottleneck.&lt;/p&gt;

&lt;p&gt;The scarce resource is increasingly the reviewer’s ability to establish:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;what actually changed;&lt;/li&gt;
&lt;li&gt;whether the patch stayed inside its intended scope;&lt;/li&gt;
&lt;li&gt;which checks really ran;&lt;/li&gt;
&lt;li&gt;whether those checks passed; and&lt;/li&gt;
&lt;li&gt;whether the patch modified the machinery used to verify itself.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is not an argument against coding agents. It is an argument for separating code production from the evidence used to trust the result.&lt;/p&gt;

&lt;h2&gt;
  
  
  A completion summary is still a claim
&lt;/h2&gt;

&lt;p&gt;A capable coding agent usually ends a task with a useful summary:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;which files it changed;&lt;/li&gt;
&lt;li&gt;what behavior it implemented;&lt;/li&gt;
&lt;li&gt;which tests it ran;&lt;/li&gt;
&lt;li&gt;whether those tests passed; and&lt;/li&gt;
&lt;li&gt;what a reviewer should examine.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But that summary is generated by the same system that selected and made the changes.&lt;/p&gt;

&lt;p&gt;If the agent missed a file, misunderstood the requested scope, ran the wrong command, or modified CI, its summary is not an independent record of those facts.&lt;/p&gt;

&lt;p&gt;The same distinction already exists elsewhere in engineering. A build log is not replaced by a developer saying “the build passed.” Useful claims become more trustworthy when another mechanism can reproduce or verify them.&lt;/p&gt;

&lt;p&gt;For coding-agent changes, that mechanism should be deterministic, inspectable, and independent of the model that wrote the patch.&lt;/p&gt;

&lt;h2&gt;
  
  
  “Tests passed” is narrower than it sounds
&lt;/h2&gt;

&lt;p&gt;Imagine a patch containing three edits:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;src/pricing.py&lt;/code&gt; gains a correct &lt;code&gt;discount()&lt;/code&gt; function.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tests/test_pricing.py&lt;/code&gt; gains a passing test.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.github/workflows/ci.yml&lt;/code&gt; gains &lt;code&gt;continue-on-error: true&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The agent runs the unit tests. They pass.&lt;/p&gt;

&lt;p&gt;The statement “tests passed” is technically true.&lt;/p&gt;

&lt;p&gt;But the patch also weakened the control plane that determines whether future failures block a merge. Test execution answers one question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Did this particular command exit successfully?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It does not automatically answer another:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Did the patch preserve the verification mechanism around that command?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Branch protection and CODEOWNERS help, but local agent workflows often happen before a pull request exists, and repository protection is not always complete.&lt;/p&gt;

&lt;h2&gt;
  
  
  A real, reproducible example
&lt;/h2&gt;

&lt;p&gt;PatchWitness contains this exact scenario as an executable demo. It creates a disposable Git repository, commits a trusted base, applies the simulated agent patch, runs real unit tests, invokes PatchWitness, and generates a Change Passport.&lt;/p&gt;

&lt;p&gt;Run it with Git and Python 3.11 or newer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/pangxueyuan2-creator/patchwitness.git
&lt;span class="nb"&gt;cd &lt;/span&gt;patchwitness
python demo/run_demo.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The repository tests report:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Ran 2 tests in 0.000s

OK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PatchWitness then reports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PatchWitness FAIL
  3 files | 10 lines | 1/1 checks
  Risk: LOW (15/100) | 1 direct dependents
  ERROR PW002 [.github/workflows/ci.yml]: path is outside the approved scope
  ERROR PW003 [.github/workflows/ci.yml]: protected verification or control-plane file changed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The test check passed. The gate failed for a different, independently evaluated reason.&lt;/p&gt;

&lt;p&gt;The transcript and JSON evidence are generated by the demo rather than manually typed into the documentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Change Passport?
&lt;/h2&gt;

&lt;p&gt;A Change Passport is a portable evidence record for a repository change.&lt;/p&gt;

&lt;p&gt;PatchWitness schema v1 records:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;resolved base and head revisions;&lt;/li&gt;
&lt;li&gt;changed paths, status, line counts, and binary state;&lt;/li&gt;
&lt;li&gt;before-and-after SHA-256 values;&lt;/li&gt;
&lt;li&gt;the task contract and where it was loaded from;&lt;/li&gt;
&lt;li&gt;check commands, exit codes, duration, timeout state, output excerpts, and hashes;&lt;/li&gt;
&lt;li&gt;stable policy findings such as &lt;code&gt;PW002&lt;/code&gt; and &lt;code&gt;PW003&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;a conservative dependency-impact graph;&lt;/li&gt;
&lt;li&gt;environment and extension output; and&lt;/li&gt;
&lt;li&gt;a canonical payload hash for offline integrity verification.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The evidence is intended for machines as well as humans. It can be rendered as JSON, Markdown, SARIF, or GitHub workflow annotations, and consumed through the Python SDK or MCP interface.&lt;/p&gt;

&lt;h2&gt;
  
  
  The trusted base matters
&lt;/h2&gt;

&lt;p&gt;A policy file inside the working tree is convenient, but it creates a circular trust problem.&lt;/p&gt;

&lt;p&gt;If a pull request can modify &lt;code&gt;.patchwitness.toml&lt;/code&gt; and immediately evaluate itself against the modified file, it may remove the rule that should have blocked it.&lt;/p&gt;

&lt;p&gt;PatchWitness supports base-authoritative policy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;patchwitness gate &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--base&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$BASE_SHA&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--policy-ref&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$BASE_SHA&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--clean-room&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--output&lt;/span&gt; change-passport.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;--policy-ref&lt;/code&gt; loads the contract from the resolved Git commit rather than the patch under review.&lt;/p&gt;

&lt;p&gt;A change to the working-tree policy remains visible, but it cannot silently weaken the rules used to evaluate that same change.&lt;/p&gt;

&lt;p&gt;This does not remove the need to protect the base branch. It makes the trust assumption explicit and inspectable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not use another AI reviewer?
&lt;/h2&gt;

&lt;p&gt;AI-assisted semantic review is useful. A model can identify suspicious logic, explain unfamiliar code, suggest missing tests, and help prioritize human attention.&lt;/p&gt;

&lt;p&gt;PatchWitness is not intended to replace that.&lt;/p&gt;

&lt;p&gt;The distinction is the trust root.&lt;/p&gt;

&lt;p&gt;Questions such as these do not require a probabilistic judge:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which Git paths changed?&lt;/li&gt;
&lt;li&gt;What exit code did the test process return?&lt;/li&gt;
&lt;li&gt;Did the patch touch a protected workflow?&lt;/li&gt;
&lt;li&gt;Was the verification policy loaded from the trusted base?&lt;/li&gt;
&lt;li&gt;Does the evidence payload still match its integrity hash?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A strong workflow can use multiple layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;deterministic evidence for scope, execution, and known policy;&lt;/li&gt;
&lt;li&gt;static and dynamic security tools such as CodeQL, Semgrep, or Trivy;&lt;/li&gt;
&lt;li&gt;optional AI review for semantic hypotheses; and&lt;/li&gt;
&lt;li&gt;a human decision for consequential changes.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Local-first does not mean sandboxed
&lt;/h2&gt;

&lt;p&gt;PatchWitness core has zero runtime dependencies and does not upload source code.&lt;/p&gt;

&lt;p&gt;Its clean-room mode creates a disposable Git worktree from the base revision, disables repository hooks during materialization, applies the patch, and runs configured checks there.&lt;/p&gt;

&lt;p&gt;That isolates verification from a dirty developer checkout. It is not equivalent to a container, virtual machine, or kernel sandbox.&lt;/p&gt;

&lt;p&gt;Repository checks are commands, and commands can be dangerous. High-assurance deployments should run them inside an appropriate sandbox with restricted credentials, network access, and filesystem permissions.&lt;/p&gt;

&lt;p&gt;Precise limitations matter more than ambitious labels.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trying it on an existing repository
&lt;/h2&gt;

&lt;p&gt;Install the current release:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pipx &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="s2"&gt;"https://github.com/pangxueyuan2-creator/patchwitness/releases/download/v0.1.0/patchwitness-0.1.0-py3-none-any.whl"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initialize a contract:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;your-repository
patchwitness init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace the starter command with the repository’s real test command, commit the contract to the base branch, and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;patchwitness gate &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--base&lt;/span&gt; origin/main &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--policy-ref&lt;/span&gt; origin/main &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--clean-room&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The most useful early-adoption pattern is observation before enforcement: capture passports on several real changes, inspect noise and missing evidence, and make the gate required only after the contract reflects the repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  What independent verification does not prove
&lt;/h2&gt;

&lt;p&gt;A passing Change Passport does not prove that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the implementation matches the user’s intent;&lt;/li&gt;
&lt;li&gt;the tests are complete;&lt;/li&gt;
&lt;li&gt;every dynamic dependency was discovered;&lt;/li&gt;
&lt;li&gt;the evidence producer has a particular identity;&lt;/li&gt;
&lt;li&gt;the execution environment was uncompromised; or&lt;/li&gt;
&lt;li&gt;the change is safe to deploy.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It proves narrower claims recorded in the evidence. That limited scope is a strength when it is stated clearly.&lt;/p&gt;

&lt;h2&gt;
  
  
  The interface between agents and engineering systems
&lt;/h2&gt;

&lt;p&gt;Coding agents will keep improving. OpenAI’s ChatGPT and Codex have helped make AI-assisted engineering practical for a broad developer audience, and that is an impressive shift in how software gets built.&lt;/p&gt;

&lt;p&gt;Better agents do not make independent verification obsolete. They make a reliable boundary between autonomous work and engineering control systems more valuable.&lt;/p&gt;

&lt;p&gt;That boundary should be portable across local tools, CI systems, code hosts, agent orchestrators, and future attestation formats.&lt;/p&gt;

&lt;p&gt;PatchWitness is an Apache-2.0 public alpha—not a production-proven standard. I am looking for technical feedback on its evidence schema, threat model, language adapters, and CI integration surface.&lt;/p&gt;

&lt;p&gt;Repository, real demo, threat model, and benchmark:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/pangxueyuan2-creator/patchwitness" rel="noopener noreferrer"&gt;https://github.com/pangxueyuan2-creator/patchwitness&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devops</category>
      <category>security</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
