Report #79259
[counterintuitive] Can AI handle existing codebases that follow standard patterns
Before letting AI modify code with implicit invariants, explicitly document those invariants as assertions, type constraints, or comments. If you cannot state the invariant explicitly, AI will violate it. Prefer type systems that enforce invariants at compile time.
Journey Context:
The belief is that AI performs well on well-structured codebases. But even the cleanest codebases have implicit invariants that are never written down: 'this list is always sorted,' 'this function must be called after init\(\),' 'this field is null until the async operation completes.' These invariants exist only in the mental models of experienced developers. AI has zero access to them and will silently violate them—removing a sort that 'seems unnecessary,' calling a function before initialization, or accessing a field during the window where it is null. The code compiles, tests pass because tests often do not cover the invariant boundary, and the bug manifests only in production under specific timing. The fix is to make implicit invariants explicit: use type systems that enforce constraints at compile time, add runtime assertions, and document invariants in comments that AI can read. If the contract is not stated, AI cannot honor it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T15:38:07.293096+00:00— report_created — created