Skip to content
Codex · разработка · контроль качества · тестирование

Quality Control with Codex Starts With the Change, Not the Code

Why code, tests, and an agent's report can confirm one mistaken interpretation of a task, and how to verify behaviour before acceptance.

Quality Control with Codex Starts With the Change, Not the Code

A Codex task can end with an impressive cluster of green signals. The implementation is complete. New tests pass. The agent reviews its own changes and reports that the requirements are met. Each signal is useful. Together, though, they may still answer only one question: is the result consistent with the agent's reading of the task?

When that reading is wrong, the implementation, newly written tests, and the completion assessment can still agree. They share the same starting assumption, so consistency between them does not necessarily show that the team received the behavior it intended.

Our position is that quality control with Codex should be organized around a verifiable change, not around the generated code itself. A verifiable change is a self-contained unit of behavior with a visible outcome, explicit boundaries, named decisions that must not be made silently, and a check capable of rejecting at least one plausible wrong result.

This model combines established practices rather than presenting an official Codex framework. OpenAI recommends giving substantial tasks a clear goal, relevant context, constraints, and completion requirements, and using planning or clarification when the work is ambiguous (Codex best practices, Prompting). General engineering guidance reaches a compatible conclusion from another direction: small, self-contained changes are generally easier to understand, review thoroughly, and revert (Google Engineering Practices). The practical question is how to turn those ideas into a process that defines behavior, contains execution, and supplies concrete evidence for acceptance.

Three green signals can share one assumption

One possible Codex workflow is that the agent interprets the request, chooses an implementation, writes and runs tests, and summarizes the result. This sequence does not describe every task. It shows how several artifacts can emerge from one chain of reasoning.

Agent-written tests and self-review can still be useful. Their usefulness does not establish that they provide an interpretation independent of the implementation. If the initial reading is mistaken, all three artifacts may encode it without exposing the difference between the implemented result and the result the team wanted.

Three green signals after a task is complete: code written, tests passing, report ready

A useful check therefore needs some power to falsify the implementation. It should answer more than "does this code behave as its author expected?" It should distinguish the intended product result from another result that the codebase, task wording, or agent could plausibly permit.

That criterion can originate in an existing contract, a reliable pre-existing test, an acceptance example approved before implementation, or a separate review against the stated behavior. It does not always require a human reviewer. What matters is that the criterion does not merely appear downstream of the same unexamined assumption.

A hypothetical change, made verifiable

To keep the mechanism concrete, consider a hypothetical scenario.

A workspace contains an owner, an ordinary member, and a document created by that member. The owner needs to remove the member. The product decision has already been made: the removed member loses access, the document stays in the workspace, and ownership of that document transfers to the workspace owner.

A short request such as "implement member removal" does not contain those decisions. Depending on the existing schema and code, deleting a membership could cascade into deleting the document. Another implementation could preserve the document while leaving the removed member as its owner. Both results conflict with the intended behavior, even if the API returns success.

A test that checks only the response status would not detect either error. A behavioral check needs to inspect the state after removal:

  • the membership no longer grants the removed member access;
  • the document still exists;
  • the workspace owner is now recorded as the document owner.

Those postconditions turn the request into a verifiable change. They describe observable domain behavior rather than prescribing an internal sequence of calls. In behavior-driven development, concrete examples help build shared understanding, while good scenarios describe domain behavior rather than an internal implementation sequence (Cucumber on BDD, Writing better Gherkin). This is especially useful when several interpretations or consequential exceptions are plausible.

The example also reveals four control points. Each has a different positive function: repository rules provide a stable execution baseline, expected behavior defines the semantic target, execution boundaries contain operational scope, and completion evidence tests the result.

1. Put stable repository rules in the repository

Repository-level instructions provide a common baseline for work across tasks. They can cover required commands, architectural boundaries, the location of authorization checks, naming conventions, and prohibited operations. OpenAI documents AGENTS.md as a way to provide persistent instructions. Codex combines applicable instructions from broader to more specific directory scopes, with more local instructions taking precedence when they conflict (Custom instructions with AGENTS.md).

In the hypothetical workspace, repository rules might tell Codex where access checks belong, which test command to run, and that a schema migration requires explicit approval. A skill can package a repeatable procedure, such as a migration or review workflow (Build skills).

These two mechanisms make different kinds of knowledge available during execution: one records stable repository instructions, while the other packages a procedure. The member-removal task still needs to supply the changing product decision about document retention and ownership. With that separation, repository rules guide how the change is made, while the task states what the change must accomplish.

2. Define expected behavior before implementation

Expected behavior gives both Codex and reviewers a semantic target. The task should state what changes, what must remain true, and which plausible outcomes are unacceptable. For the hypothetical removal flow, the three postconditions above do more work than a long description of classes, handlers, or database calls.

Checking the change boundaries before writing code

This is also the right place to identify decisions Codex must not make silently. If the current ownership model cannot represent the transfer, should the task introduce a migration, stop for clarification, or use an existing service? If removing a member touches records outside the stated scope, may those records change? The team does not need to predict every line of code, but it does need to own consequential product and data decisions.

Tests written by Codex can encode the approved criterion and exercise the resulting implementation. Their value comes from checking the stated postconditions. Reviewing those tests against the behavior defined before coding helps reveal whether they actually distinguish document retention and ownership transfer from the plausible wrong results.

3. Bound execution and define when to stop

Execution boundaries turn a broad feature request into a change that can be inspected as one unit. In this scenario, the unit is not "improve workspace administration." It is the member-removal behavior and the required ownership transition.

Codex can work toward that result in visible steps: inspect the relevant contracts, state a plan, add or adjust the focused behavioral check, implement the change, and run the required verification. The exact sequence can vary with the repository. Keeping each step tied to the same bounded outcome makes scope expansion visible.

Stop conditions create an escalation point before ambiguity becomes a consequential action. Codex should pause, for example, if the ownership transfer conflicts with the data model, requires an unapproved migration, or expands into records whose behavior the task does not define. At that point, continuing would settle a product or data decision that the team has not delegated.

Once the team has defined where the task may act, operational controls can enforce parts of that boundary. Parallel work in one checkout can allow file changes from separate tasks to interfere. Worktrees provide separate working directories that can isolate file changes across parallel tasks (Git worktrees). If an action would reach outside the permitted environment or requires explicit authorization, sandbox and approval policies can constrain what the agent may access or execute (Agent approvals and security).

The causal link is specific: worktrees address interference between file changes, while sandboxing and approvals address access and action boundaries. These controls can reduce operational interference or unauthorized action. The behavioral postconditions serve another function: they establish what the permitted change is supposed to do.

4. Require evidence that can reject the wrong result

Completion evidence makes each claimed outcome inspectable. In the hypothetical change, a reasonable evidence set could include the existing test suite for regressions, a focused behavioral test for the three postconditions, inspection of that test for false positives, and review of the code for authorization, data integrity, design, and unintended scope.

Comparing expected behaviour with a plausible but wrong result

That review should cover more than the final test status. Google's guidance includes functionality, design, complexity, tests, naming, documentation, and context-specific concerns; tests are themselves part of the material to review (What to look for in a code review). Each dimension can expose a different weakness in an otherwise plausible change.

Codex can review a branch, uncommitted changes, a commit, or changes against stated criteria (Codex code review). Such a review contributes evidence by comparing the change with explicit criteria. It should not be treated as an independent guarantee of intended product behavior.

The completion report should then map claims to evidence. "Implemented member removal" is weak. "The removed member cannot access the workspace; the document remains; its owner is now the workspace owner; the focused test asserts all three; the broader suite passes; no schema change was made" is inspectable. A reviewer can challenge each statement without reconstructing the whole task from the code change.

Independent evidence does not mean every check must be performed by a human. A pre-existing contract can supply the criterion while Codex executes the test. A person can approve the behavior and an automated check can enforce it. A separate reviewer can compare the change with those criteria. The required degree of separation depends on the risk, but asking the same agent to confirm an interpretation it introduced does not create that separation by itself.

The team still decides when the evidence is enough

Codex can automate parts of implementation, testing, and review. That does not establish a universal reduction in total engineering effort. Depending on the task, effort may move into defining behavior, reviewing evidence, resolving ambiguity, or handling exceptions.

The team remains responsible for deciding the intended behavior, identifying choices that require escalation, selecting adequate evidence, and accepting the remaining risk. Codex can perform work inside those decisions, but it cannot infer which unstated product outcome the team would approve.

This is ordinary engineering discipline, not a claim that agents need a unique bureaucracy. Human engineers also infer missing requirements. The mechanism matters here because an assumption can become a finished-looking change with code, tests, and a confident summary attached.

The controls should match the cost of being wrong. A concise request may be sufficient when the change is local and reversible, its behavior is already constrained by reliable code, contracts, and tests, and no unresolved product decision remains. More ceremony would add little in that case.

A change involving data ownership, permissions, payments, or an external system deserves clearer postconditions, explicit stop points, and evidence aimed at its plausible failure modes. Hard-to-reverse changes justify more scrutiny than edits that can be inspected and undone cheaply.

More stop conditions can slow execution. Sometimes that is the correct trade. The goal is not to maximize checkpoints. It is to place them where an unresolved decision or costly effect would otherwise pass unnoticed.

A practical checklist

Before giving Codex the task:

  • Can we state the observable result without describing the implementation?
  • What must remain true after the change?
  • Which plausible wrong result must a check reject?
  • Which decisions may Codex make, and which require clarification?
  • Are stable repository rules separated from task-specific product choices?
  • Is the scope small enough to review and, where possible, revert as one unit?

While Codex works:

  • Are intermediate steps tied to the same behavioral outcome?
  • Are stop conditions explicit before migrations, broader data effects, or other consequential actions?
  • For parallel work, would separate worktrees prevent file changes from interfering?
  • Do sandbox and approval settings match the access and actions permitted by the task?

Before accepting the result:

  • Do the checks assert behavior rather than only successful execution?
  • Have the tests been inspected against the approved postconditions?
  • Has the code been reviewed for design and risk beyond the green test run?
  • Does the completion report point to evidence for each claimed outcome?
  • Is the rigor proportional to the cost of failure and the difficulty of reversal?

The checklist is intentionally conditional. Not every task needs every control at maximum strength. Every accepted task does need a defensible answer to the same basic question: what evidence would tell us that this plausible implementation is the wrong one?

Several green signals can be reassuring while still sharing one interpretation. Quality control becomes stronger when the team defines the change before the code, keeps execution within visible boundaries, and asks for evidence that can disagree with the implementation. Codex is then not accepted because it produced code, tests, and a review. The change is accepted because those artifacts support a behavioral claim that was defined independently enough to be challenged.

Want to understand what is slowing your product down?

In a free 30-minute express review we name the likely causes and the next technical step.

Book an express review