---
description: "Operationalizes codification by extracting deterministic verifiers from observed stochastic behavior — the mechanism that converts blurry-zone components into calculators"
type: types/note.md
traits: [has-external-sources, title-as-claim]
tags: [learning-theory, constraining, continual-learning, self-improving-systems]
---

# Spec mining is codification's operational mechanism

[Codification](./definitions/codification.md) says knowledge hardens into repo artifacts — tests, specs, conventions. But where do those artifacts come from? One answer: you mine them from observed behavior.

## The pattern

1. Watch the system do tasks (or watch humans do tasks the system will do).
2. Identify repeated micro-actions: parsing dates, normalising names, mapping intents to actions, detecting escalation triggers.
3. Extract those regularities into deterministic artifacts: functions, schema rules, unit tests, checkers.
4. Re-run with these constraints in place. The system becomes more reliable without weight updates.

This is codification as compilation: the system mines stochastic regularities and codifies them into deterministic code. The output is an [inspectable artifact](./inspectable-artifact-not-supervision-defeats-the-blackbox-problem.md) — reviewable, testable, revertable artifacts rather than opaque weight updates. Inspectability is what makes mined specs falsifiable: you can test them under distribution shift and relax them back if they break.

The same pattern appears at the methodology level: the [maturation trajectory from instruction to script](./methodology-enforcement-is-constraining.md) is spec mining applied to methodology rather than system behavior. The codification trigger ("a pattern has emerged from repeated execution") is the same observation step.

## What a mined rule lets us test

Mining a recurring pattern gives a verifier a specific property to check. It does not show that the pattern caused earlier successes or should be required next time: [meeting a requirement does not establish that it serves the objective](./exact-implementation-does-not-validate-a-requirement.md).

This connects to the [oracle strength spectrum](./oracle-strength-spectrum.md): spec mining moves components from soft/delayed oracle toward hard oracle. A pattern that was only checkable by "does the output look right?" becomes checkable by "does this match the extracted rule?" Each mined spec is also a new oracle that [error correction can amplify through decorrelated checks](./error-correction-works-above-chance-oracles-with-decorrelated-checks.md) — the progression is: mine a spec (create an oracle with TPR > FPR), then amplify through decorrelated repetition. This design philosophy — out-evaluate, not out-implement — is what the [cybernetics thread](https://x.com/odysseus0z/status/2030416758138634583) calls "externalizing system-specific judgment."

## Concrete workflow

For an agentic system:
1. Cluster failure modes from production logs.
2. For the top clusters, ask: is there a deterministic rule that would have caught this?
3. If yes → write a verifier or deterministic helper (codify).
4. If no → the failure mode stays in the learned regime, but you now have a regression test (partial codification).
5. Repeat. The calculator surface grows monotonically.

The Codex team's report on runtime engineering ([Lopopolo, 2026](https://openai.com/index/harness-engineering/)) documents this workflow at production scale. Early on, 20% of engineering time (Fridays) went to manually cleaning "AI slop" — observing failure patterns. The team then codified those observations into structural tests and linter rules whose error messages teach the fix, and finally automated the observation step itself with background cleanup agents that scan for drift and open refactoring PRs. The progression — manual observation, extracted rules, automated monitoring — is the spec mining loop completing.

## Risks

- A recurring behavior can be incidental to success. A check that reproduces it faithfully can therefore reject useful alternatives.
- Test the rule on cases where matching the pattern and achieving the objective can come apart. [Brittleness under changed inputs](./operational-signals-that-a-component-is-a-relaxing-candidate.md) is a reason to investigate, not proof that the rule should be removed.

## Open questions

- What's the right threshold for codifying a mined pattern? Too early and you lock in a proxy theory; too late and you miss easy reliability wins.
- Can spec mining be automated? LLMs could propose candidate rules from failure clusters, then validation suites confirm or reject them. The [automating KB learning](./questions/what-gaps-remain-in-our-learning-loop.md) note explores a related version: the "boiling cauldron" mutations (extract, relink, synthesise) are spec mining applied to knowledge structure rather than system behavior.

---

Sources:
- Lopopolo (2026). [Harness engineering: leveraging Codex in an agent-first world](https://openai.com/index/harness-engineering/) — production-scale spec mining: manual failure observation → structural tests → automated cleanup agents.

Relevant Notes:

- [Deployed systems can learn from feedback with fixed model weights](./deployed-systems-can-learn-from-feedback-with-fixed-model-weights.md) — foundation: codification says knowledge hardens into repo artifacts; spec mining is the mechanism that produces those artifacts from observed behavior
- [Exact implementation does not validate a requirement against its objective](./exact-implementation-does-not-validate-a-requirement.md) — grounds: local conformance and fitness for purpose need different checks.
- [oracle-strength-spectrum](./oracle-strength-spectrum.md) — mechanism: spec mining moves components from soft/delayed oracle toward hard oracle; each mined spec is a new verification target
- [error-correction-works-above-chance-oracles-with-decorrelated-checks](./error-correction-works-above-chance-oracles-with-decorrelated-checks.md) — amplification: mined specs create oracles with TPR > FPR that error correction can then boost through decorrelated repetition
- [evaluation-automation-is-phase-gated-by-comprehension](./evaluation-automation-is-phase-gated-by-comprehension.md) — exemplifies: evaluation tuning requires manual failure analysis and judge calibration before optimization loops can safely amplify
- [operational-signals-that-a-component-is-a-relaxing-candidate](./operational-signals-that-a-component-is-a-relaxing-candidate.md) — risk mitigation: relaxing signals detect when a mined spec encodes an accidental regularity rather than a genuine spec
- [methodology-enforcement-is-constraining](./methodology-enforcement-is-constraining.md) — parallels: the maturation trajectory (instruction → script) is spec mining applied to methodology rather than system behavior
- [inspectable-artifact-not-supervision-defeats-the-blackbox-problem](./inspectable-artifact-not-supervision-defeats-the-blackbox-problem.md) — enables: mined specs produce inspectable, testable, revertable artifacts — inspectability is what makes them falsifiable
- [legal-drafting-solves-the-same-problem-as-context-engineering](./legal-drafting-solves-the-same-problem-as-context-engineering.md) — parallels: case law constraining (courts converging on one reading of a statute) is spec mining in a legal medium
- [specification strategy should follow where understanding lives](./specification-strategy-should-follow-where-understanding-lives.md) — situates: spec mining is the late-phase strategy for rules that only become legible after repeated execution
