$ fssg build --deterministic --validate |

AI-Generated Code Must Earn Its Place

Logs

AI can produce code faster than a system can learn whether that code deserves to exist.

That asymmetry bothers me more than the usual argument about hallucinations. A wrong line often fails quickly. A plausible abstraction, fallback, adapter, or helper can pass review, enter the repository, and remain there for years. It works. It has tests. Nobody remembers the temporary assumption that created it. The generated code stops looking generated and becomes architecture.

I do not want to measure an AI coding system only by how much useful code it can add. I want to know whether it can help the codebase become smaller after the uncertainty is gone.

Generation has a low entry price and a high carrying cost

An agent can create a compatibility layer in seconds. The organization then pays for that layer every time someone reads the call graph, changes an interface, audits permissions, updates a dependency, or investigates a failure.

The cost is not the number of lines. A five-line branch can preserve an obsolete state of the world. A thousand-line generated module may be justified if it owns a real boundary. What matters is the number of assumptions the system must continue carrying.

This is why “the patch passes” is too weak as a completion condition. It proves that the new path is acceptable now. It does not prove that every path introduced during exploration should become permanent.

My preferred unit is a retention test. Any generated structure that survives the task should answer three questions:

Test Question Failure signal
Dependency What current behavior depends on this code? No named consumer or invariant
Evidence What proves the structure is still needed? Only “it might be useful later”
Removal trigger What observable change makes deletion safe? No condition can ever retire it

This is not a demand to document every line. It is a filter for things with carrying cost: adapters, feature flags, retry branches, compatibility readers, duplicated implementations, temporary migrations, and abstractions created to make one agent task easier.

Temporary code needs a second contract

We already know how to describe what code must do. We are much worse at describing why it may continue to exist.

A behavioral contract might say:

compatibility_reader:
  accepts: [v1, v2]
  emits: v2

The retention contract adds the missing half:

retention:
  dependency: "clients still sending v1 payloads"
  evidence: "v1_seen_30d > 0"
  removal_trigger: "v1_seen_30d == 0 for 60 days"
  protected_invariants:
    - "historical payloads remain readable"

The numbers here are illustrative, not a universal policy. The important move is turning “temporary” from prose into a testable state transition.

Without that transition, temporary code is permanent code with an optimistic comment.

This also changes the role of review. The reviewer does not have to predict the future. They only need to verify that the dependency is real, the evidence can be observed, and deletion has a boundary. If the trigger never arrives, the code stays for an explicit reason. If it does arrive, removal becomes planned engineering work rather than archaeology.

The Shrink phase should challenge survival, not reward deletion

IOSM is ordered as Improve → Optimize → Shrink → Modularize. I see the Shrink phase as more than compression after implementation. It is the point where every structure added under uncertainty must justify its survival.

That does not mean maximizing negative lines of code. Bill Atkinson’s famous -2000 weekly report survives because it mocked a bad productivity metric, not because deletion is automatically valuable. The underlying QuickDraw rewrite was reported as both smaller and faster. The outcome mattered; the negative count merely exposed that addition and progress are not synonyms.

Unsafe deletion is still unsafe. Removing an observability check, a migration reader, or a permission boundary can make a diff look elegant while making the system less legible or less correct. A retention test therefore protects invariants before it asks for subtraction.

The sequence I want is:

name the dependency
→ locate current evidence
→ define the removal trigger
→ protect invariants
→ delete or keep
→ record why

This connects naturally to treating every change as a hypothesis. Addition proposes that a structure will improve the system. Retention asks a later, different question: does current evidence still support paying for it?

AI should produce candidates, not sediment

Generated code often appears during search. An agent tries one parser shape, introduces an adapter, keeps an old route as fallback, and then converges on a working solution. That exploration is useful. The mistake is treating every artifact of the search path as part of the destination.

I separate three states:

  1. Candidate — useful for exploration; no promise of permanence.
  2. Retained — has a named dependency, evidence, and a protected boundary.
  3. Retired — its removal trigger passed and the relevant invariants were rechecked.

This small lifecycle makes code review more honest. “Keep both implementations for safety” is no longer a free decision. Which consumer requires both? What signal demonstrates that requirement? When can one path disappear?

It also prevents a familiar form of AI technical debt: the repository grows because generation is cheap, while simplification remains a human-only responsibility. If an agent can add a compatibility branch, it can also draft the telemetry query, removal condition, affected-invariant list, and cleanup task. The model does not get authority to delete blindly. It does get responsibility for making future deletion possible.

That distinction matters. I want AI to lower the cost of understanding a change, not only the cost of producing one.

The final artifact is a smaller obligation set

A successful engineering cycle is not the one with the largest diff. It is the one that improves behavior while leaving the fewest unjustified obligations behind.

Sometimes that means adding substantial code. Sometimes it means preserving an old path because the evidence says real consumers still need it. Sometimes it means deleting the scaffolding that helped an agent reach the answer. The retention test does not prefer subtraction; it prefers explicit reasons.

I already treat decision residue as useful evidence rather than noise. Code needs the complementary discipline: preserve the reason, but do not preserve every implementation that once expressed it.

AI makes creation abundant. Engineering must make survival selective.

Sources

FACET AI CLI Terminal
facet@ai:~$