Test Oracle Independence
ASecurityUse when you are about to write tests for code that already exists, especially code you or another agent just wrote and that is sitting in your context. A test is an oracle only if it is independent of the code it checks: tests written with a faulty implementation in view repeat the fault in their assertions, so code and tests agree and are both wrong. Take every expected value from the specification (requirement, acceptance criteria, docstring contract, domain invariant), never from what the...
- 72 stars
- 0 votes
- 0 copies
- 1 view
- Added November 28, 2026
Works with
Security analysis
100/100Pro scans all 2 files and shows the line behind each finding
npx -y skills add Tibsfox/gsd-skill-creator --skill test-oracle-independence --agent claude-codeAre you the author of Test Oracle Independence?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tibsfox-test-oracle-independence)---
name: test-oracle-independence
description: >
Use when you are about to write tests for code that already exists,
especially code you or another agent just wrote and that is sitting in your
context. A test is an oracle only if it is independent of the code it
checks: tests written with a faulty implementation in view
repeat the fault in their assertions, so code and tests agree and are both
wrong. Take every expected value from the specification (requirement,
acceptance criteria, docstring contract, domain invariant), never from what
the code currently returns; if no specification exists, write one first;
label any test that pins current behaviour as a characterization test.
Distinct from test-generator (test structure and naming) and
execution-grounded-selection (choosing among candidates by running them).
Backed by arxiv 2607.05139 and arxiv 2607.22883. Triggers on writing tests
after the implementation and on reviewing agent-written tests.
description-frequency: on-demand
user-invocable: true
version: 1.0.0
format: 2025-10-02
triggers:
- "add tests for code that is already written"
- "the implementation is in context while I write its tests"
- "where did this expected value come from"
updated: 2026-11-27
status: ACTIVE
source: arxiv 2607.05139, arxiv 2607.22883 (generated-test oracle independence)
---
# Test Oracle Independence
A provenance check on expected values. It runs when tests are written *after*
the code they check. It asks one question of every assertion — where did the
expected value come from? — and accepts only answers that do not pass through
the implementation under test.
## Why
A test earns the name oracle by being able to disagree with the code. Two 2026
studies measured what happens when a model writes tests with the implementation
in its context. In the first (arxiv 2607.05139), tests generated after faulty
code reached 14% fault-detection effectiveness, against 25% for tests
generated independently of that code. In the second (arxiv 2607.22883), buggy code in the
prompt increased the tests that assert the incorrect behaviour and suppressed
the bug-finding ones; replacing the code in the prompt with a specification
docstring reduced the misguided tests and increased the effective ones.
In this repository the house pattern is TDD RED-GREEN, where the test exists
before the code and independence comes for free. The exposure is everything
that runs the other way round: `gsd:add-tests` on a completed phase,
`gsd-nyquist-auditor` filling validation gaps, a fixer that adds a regression
test beside its own patch, or a plain "add tests for this function". In each of
those the body is in context when the assertions are written.
## Data classes touched
Reads project-internal source, plans and requirements; writes test files. No
sensitive class is read or surfaced. One boundary rule: in gate-enforced test
files (`.college/tests/safety-critical.test.ts`, hook tests under
`.claude/hooks/`, the audit tests that guard `src/` chokepoints) an existing
assertion is never weakened or re-derived from current behaviour without the
user's say.
## How
1. **Classify the order.** Tests written before the implementation exists (RED
first) are independent by construction: go to step 6. Tests written after
it: continue.
2. **Name the specification source** for the unit, in this order of preference:
acceptance criteria in the phase `PLAN.md`, `REQUIREMENTS.md` or UAT list;
the issue or user request; a public contract (type signature plus docstring)
written before the body or by someone else; a domain invariant (a
mathematical identity, a protocol or file-format specification, a round-trip
property).
3. **If there is none, write one before any test.** State the input domain,
output contract, error cases and invariants as a docstring-level
specification, from the requirement and the signature. Do not paraphrase the
body. For public API, show the specification to the user or the plan owner.
4. **Derive expected values from that source only.**
- Do not run the code to learn what to assert.
- Do not copy constants, regexes or branch conditions out of the body.
- Compute expected values by an independent route: by hand, from a reference
formula, from a second method, or from a published example.
- For the strongest separation, delegate test writing to a subagent whose
brief holds the specification and the public signature and does not hold
the body.
5. **Label what is not independent.** A test whose expected value came from
running the code is a *characterization test*. It is legitimate as a
refactoring guard. Name it so (`describe('characterization: …')`) and never
count it as evidence that the behaviour is correct.
6. **See each test fail once.** A test never seen red has not shown it can find
a bug. Run it against a stub, against the pre-fix commit, or against a
one-line mutant. When mutating, copy the file to a scratch directory first
and restore from that copy; never `git checkout` a file that has
uncommitted work.
7. **On disagreement, do not edit the test toward the code.** A
specification-derived test that fails is a finding: the code is wrong, or
the specification is. Take it to whoever owns the specification. Code and
tests agreeing after you changed the test is not a resolution.
### Robustness rule
Judge by provenance, not by outcome. "All new tests pass on the first run" is
the expected result both when the code is right and when the tests were shaped
by the code, so on its own it carries no information. The check is whether you
can name, for each expected value, a source that is not the body.
## Confidence / failure model
This skill wraps an **LLM judgment** (which text counts as the specification,
and whether an expected value was derived independently), not a decidable
check. It lowers the rate of fault-replicating tests; it does not remove it,
and a specification can itself be wrong. Fail-closed defaults: (a) an expected
value whose provenance you cannot name is treated as characterization and
labelled; (b) a conflict between a specification-derived test and the code is
escalated, never settled by rewriting the assertion; (c) in the gate-enforced
files listed above, nothing is weakened without the user.
## When to skip
- RED-first TDD, where the test predates the implementation.
- The user asked for golden or snapshot tests to pin behaviour before a
refactor: write them, and label them characterization.
- Throwaway tests in a spike that will be deleted with it.
## Integration
- **test-generator** — owns structure, naming and categories of tests. This
skill adds the one thing it does not cover: where expected values may come
from. Use both.
- **execution-grounded-selection** — runs candidates and clusters them by
behaviour. Inputs may be generated from the candidates; expected outputs may
not, for the reason above.
- **gsd:add-tests / gsd-nyquist-auditor** — after-the-fact test generation;
apply steps 2 to 5 to each generated test.
- **code-review** — one extra review question for agent-written tests: "which
source does this expected value come from?"
- **goal-ambiguity-gate** — if the specification in step 2 admits two readings,
resolve that first; a test cannot be independent of an ambiguity.
Files in this skill
- SKILL.md
- triggering.test.md
Attribution
Related skills
View all in ai-agents →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.