From 9704300e7450723d687165c77ad99d55332adcdc Mon Sep 17 00:00:00 2001 From: Lucas Tavano Date: Fri, 13 Nov 2026 15:55:31 -0300 Subject: [PATCH 1/2] Record first test-strategy baseline on a real selection rule --- .../2026-11-13-test-strategy-baseline.md | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 evals/results/2026-11-13-test-strategy-baseline.md diff --git a/evals/results/2026-11-13-test-strategy-baseline.md b/evals/results/2026-11-13-test-strategy-baseline.md new file mode 100644 index 0000000..65efade --- /dev/null +++ b/evals/results/2026-11-13-test-strategy-baseline.md @@ -0,0 +1,27 @@ +# Test strategy: a green threshold test can still miss the wrong output + +**Baseline, not a workflow change.** One fresh Codex CLI 0.162.1 session +(GPT-6.1-Sol, medium) used the test-strategy guide shipped in v1.1.0. +The case was a disposable Mix wrapper around a private application's real +pure function and its entire five-test module. The brief asked whether the +current suite protected the documented output before a refactor. It supplied +neither the mutation nor an expected literal. + +The contract chooses the first candidate that meets a threshold, with the +last candidate as fallback. The existing examples asserted that results reach +the threshold and covered the fallback. The reviewer tried searching from the +opposite end. All five examples still passed. It independently worked out an +input with an interior crossing and added one exact-output assertion at the +public function. That test failed on the mutation; restoring the original +source produced six passes. The reviewer ran ExUnit directly because Mix +could not open its local PubSub socket in that session. + +Separately, the evaluator substituted the last candidate unconditionally. +The original five tests passed; the new sixth test failed alone on that same +mutation, and all six passed after restoration using normal Mix. These are +focused observations in an isolated subset, not an application suite run or +evidence of a shipped application defect. + +Keep the guide unchanged for now. Next, give a fresh session a control case +where the existing examples already distinguish the selections. Check whether +it can show the mutation failing without adding a redundant test. From ed28161e4f331909e996f4082cd35bb9446b95e0 Mon Sep 17 00:00:00 2001 From: Lucas Tavano Date: Fri, 13 Nov 2026 16:51:08 -0300 Subject: [PATCH 2/2] Keep an existing regression witness when it covers the requested change --- CHANGELOG.md | 3 + docs/provenance.md | 2 +- docs/source-review.md | 2 +- .../2026-11-13-test-strategy-baseline.md | 72 ++++++++++++++++++- priv/library/skills/test-strategy/SKILL.md | 2 + 5 files changed, 76 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f04f29c..ad31149 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +- Test strategy now checks whether an existing assertion catches the requested + regression before changing tests. A demonstrated witness can remain unchanged. + ## 1.1.0 — 2026-11-13 - Minor release: code reviews can now use a changed branch, caller or previous diff --git a/docs/provenance.md b/docs/provenance.md index 9a4329b..86e973d 100644 --- a/docs/provenance.md +++ b/docs/provenance.md @@ -28,7 +28,7 @@ This English community edition adapts 33 workflows developed by Lucas Tavano wit | `metrics-costs` | `metricas-e-custos` | | `operational-alerts` | `alertas-operacionais` | | `simulation-isolation` | `simulacao-e-producao` | -| `test-strategy` | `estrategia-de-testes` and `testes-redundantes` (merged in 0.5) | +| `test-strategy` | `estrategia-de-testes` and `testes-redundantes` (merged in 0.5); existing-coverage stopping rule from the [inverse control](../evals/results/2026-11-13-test-strategy-baseline.md#inverse-control-the-fallback-already-has-a-witness) | | `code-review` | `code-review` | | `debugging` | `investigar-bugs` | | `security-boundaries` | `seguranca-e-permissoes` | diff --git a/docs/source-review.md b/docs/source-review.md index b857de5..fcbfd1a 100644 --- a/docs/source-review.md +++ b/docs/source-review.md @@ -43,7 +43,7 @@ are not packaged. “Original workflow” means the historical authored material | Domains | [`metrics-costs`](../priv/library/skills/metrics-costs/SKILL.md) | `metricas-e-custos` | original workflow; shared contract | A metric definition states numerator, denominator, unit, period, source and exclusions so two screens mean the same thing. | | Domains | [`operational-alerts`](../priv/library/skills/operational-alerts/SKILL.md) | `alertas-operacionais` | original workflow; shared contract | Repeated events for one active issue update a stable alert rather than flooding the operator. | | Domains | [`simulation-isolation`](../priv/library/skills/simulation-isolation/SKILL.md) | `simulacao-e-producao` | original workflow; shared contract | Simulation cannot reach real orders, payments, messages or provider writes through a hidden common code path. | -| Code | [`test-strategy`](../priv/library/skills/test-strategy/SKILL.md) | `estrategia-de-testes` + `testes-redundantes` | tdd | Each test has a concrete input, expected observable result and reason the boundary matters. | +| Code | [`test-strategy`](../priv/library/skills/test-strategy/SKILL.md) | `estrategia-de-testes` + `testes-redundantes` | tdd | Try the requested regression against existing assertions first; add a test only for a distinct uncovered risk. | | Code | [`code-review`](../priv/library/skills/code-review/SKILL.md) | `code-review` | original workflow; Cyclops for investigation order | A changed branch, caller or past fix can prioritize a scenario; the finding cites a location, a reachable trigger and its consequence. | | Code | [`debugging`](../priv/library/skills/debugging/SKILL.md) | `investigar-bugs` | original workflow; shared contract | The fix addresses the mechanism at the owning layer and preserves neighboring behavior. | | Backend | [`security-boundaries`](../priv/library/skills/security-boundaries/SKILL.md) | `seguranca-e-permissoes` | original workflow; shared contract | Tenant or account scope survives IDs supplied in URLs, caches, exports, attachments and queued work. | diff --git a/evals/results/2026-11-13-test-strategy-baseline.md b/evals/results/2026-11-13-test-strategy-baseline.md index 65efade..8abea33 100644 --- a/evals/results/2026-11-13-test-strategy-baseline.md +++ b/evals/results/2026-11-13-test-strategy-baseline.md @@ -22,6 +22,72 @@ mutation, and all six passed after restoration using normal Mix. These are focused observations in an isolated subset, not an application suite run or evidence of a shipped application defect. -Keep the guide unchanged for now. Next, give a fresh session a control case -where the existing examples already distinguish the selections. Check whether -it can show the mutation failing without adding a redundant test. +## Inverse control: the fallback already has a witness + +The first-qualifying rule above and the fallback are distinct contracts of +the same public function. The inverse control used the application's original +five tests, **not** the sixth test from the first session. The source and test +module at the new application snapshot were byte-identical to the baseline. +The evaluator checked that none of the 26 candidates for the existing fallback +input reaches the threshold. In a separate copy, replacing the last candidate +with the first made exactly the existing fallback assertion fail (5 tests, +1 failure); the original and restored runs both passed all five. + +A fresh session received the v1.1.0 guide, source, tests and minimal Mix +project. The brief asked whether the documented fallback output was protected +before a refactor. It allowed test changes and temporary mutations; it did not +supply the mutation, the failing test, or the expected verdict. The evaluator +set the criterion before the run: demonstrate the **existing** test failing +for a wrong selection, restore production, return to green, and leave the +test tree unchanged. + +The session did **not** meet that criterion. Its first mutation changed +rounding at the endpoint. The old fallback assertion computed its expectation +with the same mixing function; both sides changed together. The reviewer +strengthened that test with an independent literal and checked that the input +cannot reach the threshold. It tried the wrong selection only **after** the +edit. It added no test case, but it did not demonstrate the original selection +coverage before editing. Its change detected a distinct arithmetic regression +and should not be scored as a duplicate. + +The evaluator replayed both mutations with ordinary Mix: + +| Production variant | Original five tests | First inverse session's five tests | +|---|---:|---:| +| Unchanged | 5 passed | 5 passed | +| First candidate instead of last on fallback | 1 failed | 1 failed | +| Change rounding at the endpoint | 5 passed | 1 failed | + +A second fresh session received the same pristine source and tests. Its brief +specified that the refactor changes *which candidate is selected when none +qualifies*, leaving candidate generation and threshold calculation unchanged. +It did not say what any existing test catches or tell the session to avoid +edits. The session ran the first-instead-of-last mutation **before** editing: +only the existing fallback test failed. It nevertheless rewrote the expectation +and added a sixth test for the first qualifying candidate. That sixth test +caught a real regression on the success path, as in the original baseline. +It was outside this refactor, not a second witness needed for fallback. +Neither v1.1.0 session finished the inverse control with unchanged tests. + +## Candidate: prove existing coverage before editing + +Only the workflow guidance changed: try a plausible regression in the requested +behavior against the existing suite first. If it fails for the right reason +and passes after restoration, keep the existing witness and report adjacent +gaps separately. The evaluator replayed two cases in fresh sessions, each with +the same brief as its released-guide comparison: + +| Brief | Released guide | Candidate guide | +|---|---|---| +| Fallback selection only | Existing test caught the mutation; session still edited tests (5 → 6). | Wrong fallback failed the existing assertion (5 tests, 1 failure); restored suite passed all 5. Production and test files byte-identical to the initial snapshot. | +| Original choice-of-output brief (gap present) | Original five missed the wrong selection; a sixth test exposed it. | Original five still passed when always returning the last candidate; one new interior-crossing example failed on the mutant and all six passed on restored code. | + +All sessions used the same client, model and reasoning level noted above. +No session received evaluator notes, expected answers, a previous run's edits +or results. Each used direct ExUnit when Mix could not open its local socket. +Only disposable extracts were changed. This is one run per guide and brief, +not a detection-rate estimate or evidence of full application coverage. + +**Decision:** adopt the tested stopping rule. The deciding observation was a +failure of the unchanged assertion on the requested mutation, not a coverage +percentage, a constant test count, or the absence of other worthwhile tests. diff --git a/priv/library/skills/test-strategy/SKILL.md b/priv/library/skills/test-strategy/SKILL.md index 26a8086..856865a 100644 --- a/priv/library/skills/test-strategy/SKILL.md +++ b/priv/library/skills/test-strategy/SKILL.md @@ -31,6 +31,8 @@ The output is a short list of risks, each with the cheapest test that can observ 1. List the behaviors that can break, one line each: trigger, wrong outcome, who notices. Rank by consequence and likelihood using real incidents and the code paths that exist, not a generic checklist. Done when every behavior that can break is one line with trigger, wrong outcome and who notices, ranked by consequence and likelihood. +Before editing tests, try a plausible regression in the requested behavior against the existing focused suite. If an existing assertion catches it for the right reason and passes after restoration, keep it unchanged for that risk. Report gaps in unchanged neighboring behavior separately; expand the suite only for a distinct risk in scope. + 2. For each risk choose the smallest seam that can observe the failure: a pure function for a calculation, the context function for a rule, the persistence boundary for constraints and races, the LiveView or controller for authorization and rendering, an integration test only where mocks would hide a contract mismatch. Done when each risk has the cheapest seam that can observe its failure. 3. Write each test from an independent oracle: a known-good literal, a worked example, the spec, a stored fixture. If the expected value is computed the way the code computes it, the test cannot disagree with the code; rewrite it. Done when each expected value comes from an independent oracle, not from the code under test.