From 8d3c15b6bbb2ffcc4d179ba974dc9df14fd14c3a Mon Sep 17 00:00:00 2001 From: Lucas Tavano Date: Sat, 14 Nov 2026 07:37:42 -0300 Subject: [PATCH] Trace policy vocabulary and preserve functional observation points --- .github/workflows/ci.yml | 5 + CHANGELOG.md | 7 + docs/provenance.md | 7 + docs/source-review.md | 4 +- evals/README.md | 6 +- evals/fixtures/concept-review/README.md | 13 ++ .../concept-review/architecture/control.ex | 12 ++ .../concept-review/architecture/control.txt | 18 +++ .../concept-review/architecture/oracle.txt | 4 + .../concept-review/architecture/positive.ex | 14 ++ .../concept-review/architecture/positive.txt | 20 +++ .../concept-review/architecture/reviews.json | 122 ++++++++++++++++++ .../concept-review/architecture/verify.exs | 22 ++++ .../concept-review/clarity/body.prompt | 16 +++ .../fixtures/concept-review/clarity/check.exs | 50 +++++++ .../concept-review/clarity/guard.prompt | 15 +++ .../fixtures/concept-review/clarity/rubric.md | 1 + .../concept-review/functional/brief.txt | 1 + .../concept-review/functional/holdout.exs | 37 ++++++ .../concept-review/functional/inverse.ex | 9 ++ .../concept-review/functional/oracle.txt | 1 + .../concept-review/functional/replay.py | 16 +++ .../concept-review/functional/support.ex | 10 ++ .../concept-review/functional/target.ex | 8 ++ evals/results/2026-11-14-concepts.md | 64 +++++++++ .../skills/architecture-review/SKILL.md | 1 + .../skills/functional-refactoring/SKILL.md | 10 +- scripts/check_library.py | 3 +- scripts/eval_matrix.py | 21 ++- 29 files changed, 504 insertions(+), 13 deletions(-) create mode 100644 evals/fixtures/concept-review/README.md create mode 100644 evals/fixtures/concept-review/architecture/control.ex create mode 100644 evals/fixtures/concept-review/architecture/control.txt create mode 100644 evals/fixtures/concept-review/architecture/oracle.txt create mode 100644 evals/fixtures/concept-review/architecture/positive.ex create mode 100644 evals/fixtures/concept-review/architecture/positive.txt create mode 100644 evals/fixtures/concept-review/architecture/reviews.json create mode 100644 evals/fixtures/concept-review/architecture/verify.exs create mode 100644 evals/fixtures/concept-review/clarity/body.prompt create mode 100644 evals/fixtures/concept-review/clarity/check.exs create mode 100644 evals/fixtures/concept-review/clarity/guard.prompt create mode 100644 evals/fixtures/concept-review/clarity/rubric.md create mode 100644 evals/fixtures/concept-review/functional/brief.txt create mode 100644 evals/fixtures/concept-review/functional/holdout.exs create mode 100644 evals/fixtures/concept-review/functional/inverse.ex create mode 100644 evals/fixtures/concept-review/functional/oracle.txt create mode 100644 evals/fixtures/concept-review/functional/replay.py create mode 100644 evals/fixtures/concept-review/functional/support.ex create mode 100644 evals/fixtures/concept-review/functional/target.ex create mode 100644 evals/results/2026-11-14-concepts.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e10fef4..8ffa632 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,11 @@ jobs: otp-version: ${{ matrix.otp }} - run: mix check - run: python3 scripts/check_library.py + - name: Replay the three concept counterexamples without a model + run: | + elixir evals/fixtures/concept-review/architecture/verify.exs + python3 evals/fixtures/concept-review/functional/replay.py + elixir evals/fixtures/concept-review/clarity/check.exs - run: python3 -m pip install --user pyflakes==4.1.0 - run: python3 -m pyflakes scripts/ - run: python3 scripts/smoke_install.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 720caab..6abe46b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## Unreleased + +- Architecture reviews now check whether a policy knows an adapter’s fields + or units even when the call graph is acyclic. Functional refactoring now + distinguishes functions from the data they transform and preserves when a + deferred read happens. No workflow IDs or installer behavior changed. + ## 1.2.1 — 2026-11-14 - Patch release: English, Portuguese and agent installation guides distinguish diff --git a/docs/provenance.md b/docs/provenance.md index 5049cff..59a4630 100644 --- a/docs/provenance.md +++ b/docs/provenance.md @@ -174,3 +174,10 @@ reference in the same way: no passage was consulted for wording or reproduced. The [catalog field round](https://github.com/sallaumen/elixir-agent-kit/blob/c2ff7e5be2a08fdfab757d101e95036069634396/evals/results/2026-11-13-catalog-field-round.md) records original, application-derived experiments behind the 2026-11-13 workflow corrections. The application snapshots and the evaluator's answers are not installed as client instructions. The [class handover holdout](https://github.com/sallaumen/elixir-agent-kit/blob/c2ff7e5be2a08fdfab757d101e95036069634396/evals/results/2026-11-13-ui-identity-handover.md) supports the additional UI identity decision points. The installed text is the general candidate tested across screens; no application rule or fixture is shipped. + +The subsequent concept review compared executable Elixir counterexamples with +the actions/calculations/data distinction in [Eric Normand’s overview](https://ericnormand.me/grokking-simplicity), +the discussion of boundary data in [Robert C. Martin’s architecture essay](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html), +and Elixir’s [guard semantics](https://hexdocs.pm/elixir/1.15.5/patterns-and-guards.html#errors-in-guards). +The two guide corrections are original applications of those ideas. No new +framework, mandatory layer or workflow was introduced. diff --git a/docs/source-review.md b/docs/source-review.md index 444854c..b735e22 100644 --- a/docs/source-review.md +++ b/docs/source-review.md @@ -14,7 +14,7 @@ are not packaged. “Original workflow” means the historical authored material | Area | Public workflow | Original ID | Additional review lens | Most important quality boundary | |---|---|---|---|---| | Delivery | [`delivery-coordination`](../priv/library/skills/delivery-coordination/SKILL.md) | `coordenar-entregas` | original workflow; shared contract | Each work item has an owner, objective, affected paths, integration condition and handoff evidence. | -| Code | [`architecture-review`](../priv/library/skills/architecture-review/SKILL.md) | `revisar-arquitetura` | elixir-antipatterns | Each finding names the owner of the behavior, the dependency crossing it and the consequence for a real use case. | +| Code | [`architecture-review`](../priv/library/skills/architecture-review/SKILL.md) | `revisar-arquitetura` | elixir-antipatterns | Trace who calls whom and who owns the fields, units and results crossing the boundary; name the consequence for a real use case. | | Code | [`abstraction-layers`](../priv/library/skills/abstraction-layers/SKILL.md) | `stratified-design` | elixir-antipatterns | A reader can follow the business intent without chasing a chain of one-line wrappers or decoding transport mechanics. | | Code | [`module-design`](../priv/library/skills/module-design/SKILL.md) | `organizar-modulos` | elixir-antipatterns | Each public module name predicts its responsibility, and exported operations form a coherent promise to consumers. | | Code | [`code-consolidation`](../priv/library/skills/code-consolidation/SKILL.md) | `consolidar-codigo` | elixir-antipatterns | The resulting API names the common concept and leaves meaningful differences visible at call sites. | @@ -31,7 +31,7 @@ are not packaged. “Original workflow” means the historical authored material | Code | [`performance`](../priv/library/skills/performance/SKILL.md) | `performance` | original workflow; shared contract | Before/after measurements use comparable inputs, warmup, configuration and statistical summary. | | Code | [`process-lifecycle`](../priv/library/skills/process-lifecycle/SKILL.md) | none (new in 0.5) | shared contract; Elixir context | Every process has a stated reason, an owner of its state and a rebuild path after restart; duplicates and bursts are bounded. | | Code | [`house-patterns`](../priv/library/skills/house-patterns/SKILL.md) | none (new in 0.7) | shared contract; Elixir context; a consuming application's conventions, generalized | Every conformed site has a public-seam test that passed before and after its own step, and every remaining deviation has a written reason. | -| Code | [`functional-refactoring`](../priv/library/skills/functional-refactoring/SKILL.md) | none (new in 0.8) | shared contract; Elixir context; *Grokking Simplicity* concepts (Eric Normand), concept only | Every extracted decision is tested with plain values and no stub, and the effect inventory is identical before and after. | +| Code | [`functional-refactoring`](../priv/library/skills/functional-refactoring/SKILL.md) | none (new in 0.8) | shared contract; Elixir context; *Grokking Simplicity* concepts (Eric Normand), concept only | Every extracted decision is tested with plain values and no stub, and callers observe effects at the original time and in the original process. | | Code | [`readable-code`](../priv/library/skills/readable-code/SKILL.md) | none (new in 0.8) | shared contract; Elixir context; *Clean Code* concepts (Robert C. Martin), concept only | Tests, effects and public names are unchanged and no new lint finding appears, while every obstacle in the reading notes is resolved or handed off. | | Code | [`async-state`](../priv/library/skills/async-state/SKILL.md) | `estados-assincronos` | original workflow; shared contract | The UI and API can reconcile after reconnect or reload using persisted identifiers and a current-state read; commands tied to a rendered result retain their gesture and confirmation requirements. | | Domains | [`ai-orchestration`](../priv/library/skills/ai-orchestration/SKILL.md) | `orquestracao-ias` | original workflow; shared contract | Acquisition, release, timeout, cancellation and crash recovery keep capacity counters consistent. | diff --git a/evals/README.md b/evals/README.md index 95028cb..5789a79 100644 --- a/evals/README.md +++ b/evals/README.md @@ -40,10 +40,14 @@ cell. A live round fills that matrix with observed runs: the `.tsv` with a short Markdown summary beside it. `scripts/check_library.py` validates every committed `.tsv`, so a malformed row -fails CI. Runs are manual and paid; nothing here calls a model. +fails CI. Within one client, model and kit revision, a run ID identifies one +execution across input files. Give an independent repeat a new run ID; copying a +transcript into another file must not increase the reported sample size. Runs are manual and paid; nothing here calls a model. ## Case notes +The [concept review](results/2026-11-14-concepts.md) separates live routing and guided comparisons from offline counterexamples for architecture, functional refactoring and readable code. + The [catalog field round](results/2026-11-13-catalog-field-round.md) maps all 38 workflows to their paired evidence and records the release decision. diff --git a/evals/fixtures/concept-review/README.md b/evals/fixtures/concept-review/README.md new file mode 100644 index 0000000..3deb386 --- /dev/null +++ b/evals/fixtures/concept-review/README.md @@ -0,0 +1,13 @@ +# Three counterexamples for workflow reviews + +Run from the repository root with Elixir on PATH. These original examples use +fictional data and the standard library. They are evaluator material, excluded +from the package. They replay application behavior, not the model sessions. + +| Command | What failure would distinguish the alternatives? | +|---|---| +| `python3 evals/fixtures/concept-review/functional/replay.py` | Compares per-element preference reads with a snapshot. Construction, partial consumption, repeated consumption and moving to another process distinguish the two contracts. Each original passes its own four checks and fails the opposite contract. | +| `elixir evals/fixtures/concept-review/architecture/verify.exs` | With the same public commands and dependency directions, the mixed-unit implementation wrongly labels 5,399 seconds long; the control preserves the 5,400-second cutoff. The verifier checks the exact mismatch list. | +| `elixir evals/fixtures/concept-review/clarity/check.exs` | A tuple operation in the body can raise where the same operation in a guard falls through. Matching ordinary inputs is insufficient: malformed data and overlapping clauses distinguish the contracts. | + +For the live comparison, rubric and interpretation see the [concept review](../../results/2026-11-14-concepts.md). diff --git a/evals/fixtures/concept-review/architecture/control.ex b/evals/fixtures/concept-review/architecture/control.ex new file mode 100644 index 0000000..c34e5e0 --- /dev/null +++ b/evals/fixtures/concept-review/architecture/control.ex @@ -0,0 +1,12 @@ +defmodule Studio.Legacy do + def preview(%{"minutes" => n}), do: Studio.Schedule.classify(n * 60) +end + +defmodule Studio.Mixer do + def preview(%{"time" => n}), do: Studio.Schedule.classify(n) +end + +defmodule Studio.Schedule do + def classify(seconds) when is_integer(seconds) and seconds >= 5400, do: :long + def classify(seconds) when is_integer(seconds), do: :standard +end diff --git a/evals/fixtures/concept-review/architecture/control.txt b/evals/fixtures/concept-review/architecture/control.txt new file mode 100644 index 0000000..4434c05 --- /dev/null +++ b/evals/fixtures/concept-review/architecture/control.txt @@ -0,0 +1,18 @@ +Review this proposed rehearsal-scheduling change as a maintainer. Would you ship it as written? Give the smallest correction if any, who owns it, and what evidence would settle the decision. Keep the existing commands and their outputs compatible. Use only the supplied material; do not edit files or call tools. Up to 320 words. +Studio has one Mix app, no library dependencies. Both batch preview commands must classify a rehearsal of at least 90 minutes as :long, otherwise :standard. Both formats are in use concurrently. Inputs to these commands have already passed integer and range validation. Public command examples from the partner fixtures: + Studio.Legacy.preview(%{"minutes" => 90}) # :long + Studio.Mixer.preview(%{"time" => 5400}) # :long + Studio.Mixer.preview(%{"time" => 5399}) # :standard +CI ran a smoke check for legacy 90 and mixer 5400, and a file dependency cycle check. All three passed. Here is the entire code for the two entry paths, one module per file. +defmodule Studio.Legacy do + def preview(%{"minutes" => n}), do: Studio.Schedule.classify(n * 60) +end + +defmodule Studio.Mixer do + def preview(%{"time" => n}), do: Studio.Schedule.classify(n) +end + +defmodule Studio.Schedule do + def classify(seconds) when is_integer(seconds) and seconds >= 5400, do: :long + def classify(seconds) when is_integer(seconds), do: :standard +end diff --git a/evals/fixtures/concept-review/architecture/oracle.txt b/evals/fixtures/concept-review/architecture/oracle.txt new file mode 100644 index 0000000..5bce484 --- /dev/null +++ b/evals/fixtures/concept-review/architecture/oracle.txt @@ -0,0 +1,4 @@ +Fixed before any model calls. Score answers separately by case. Award each binary criterion from explicit evidence, never by similar vocabulary alone. +Positive P1 Reject as written and identify incorrect classification for an actual subthreshold seconds value due to rounding (a valid witness is 5399). P2 Identify an ownership problem distinct from arithmetic: Schedule's decision understands the two import-specific shape conventions even though both command modules call Schedule; absence of cycles does not resolve this. Explicit pair of shape/meaning ownership and one-way calls or absence of cycle needed. P3 Place wire shape/unit handling at each input edge (convert legacy minutes to exact elapsed seconds and forward mixer seconds unchanged) while retaining one shared 5400-second threshold, compatible command results. P4 Propose regression evidence exercising both public paths at/around the cutoff, including near-below for Mixer, and a direct check of the single rule with its own seconds value independent of raw fields. P5 Do not require a new callback/behaviour, intermediate struct, process, umbrella or other infrastructure. +Control N1 Explicitly accept current implementation with no structural code change needed. N2 Correctly describe two input translations and shared policy with one canonical unit. N3 Identify smoke coverage gap with a concrete 5399-second mixer regression and a legacy comparison (89/90 acceptable). N4 No new abstractions, processes, umbrella or structural migration suggested as necessary. +Primary test of architecture specificity: both candidate replicates must achieve P2 + P3 AND N1 + N4; candidate must add at least one P2 success over baseline to warrant shipping this guide; no additional control regression. All criteria are binary; split technical probe from live helper/adherence claims. Judge material and anonymised replies only. Two replies per case per arm, model gpt-6.1-sol medium. Synthetic, assisted workflow (routing/discovery excluded); no inference about other projects or clients. No post-hoc edits. diff --git a/evals/fixtures/concept-review/architecture/positive.ex b/evals/fixtures/concept-review/architecture/positive.ex new file mode 100644 index 0000000..cade6f4 --- /dev/null +++ b/evals/fixtures/concept-review/architecture/positive.ex @@ -0,0 +1,14 @@ +defmodule Studio.Legacy do + def preview(row), do: Studio.Schedule.classify(row) +end + +defmodule Studio.Mixer do + def preview(row), do: Studio.Schedule.classify(row) +end + +defmodule Studio.Schedule do + def classify(%{"minutes" => n}), do: classify_length(n * 60) + def classify(%{"time" => n}), do: classify_length(round(n / 60) * 60) + defp classify_length(seconds) when seconds >= 5400, do: :long + defp classify_length(_seconds), do: :standard +end diff --git a/evals/fixtures/concept-review/architecture/positive.txt b/evals/fixtures/concept-review/architecture/positive.txt new file mode 100644 index 0000000..dd9c9ae --- /dev/null +++ b/evals/fixtures/concept-review/architecture/positive.txt @@ -0,0 +1,20 @@ +Review this proposed rehearsal-scheduling change as a maintainer. Would you ship it as written? Give the smallest correction if any, who owns it, and what evidence would settle the decision. Keep the existing commands and their outputs compatible. Use only the supplied material; do not edit files or call tools. Up to 320 words. +Studio has one Mix app, no library dependencies. Both batch preview commands must classify a rehearsal of at least 90 minutes as :long, otherwise :standard. Both formats are in use concurrently. Inputs to these commands have already passed integer and range validation. Public command examples from the partner fixtures: + Studio.Legacy.preview(%{"minutes" => 90}) # :long + Studio.Mixer.preview(%{"time" => 5400}) # :long + Studio.Mixer.preview(%{"time" => 5399}) # :standard +CI ran a smoke check for legacy 90 and mixer 5400, and a file dependency cycle check. All three passed. Here is the entire code for the two entry paths, one module per file. +defmodule Studio.Legacy do + def preview(row), do: Studio.Schedule.classify(row) +end + +defmodule Studio.Mixer do + def preview(row), do: Studio.Schedule.classify(row) +end + +defmodule Studio.Schedule do + def classify(%{"minutes" => n}), do: classify_length(n * 60) + def classify(%{"time" => n}), do: classify_length(round(n / 60) * 60) + defp classify_length(seconds) when seconds >= 5400, do: :long + defp classify_length(_seconds), do: :standard +end diff --git a/evals/fixtures/concept-review/architecture/reviews.json b/evals/fixtures/concept-review/architecture/reviews.json new file mode 100644 index 0000000..61f9952 --- /dev/null +++ b/evals/fixtures/concept-review/architecture/reviews.json @@ -0,0 +1,122 @@ +{ + "pinned_tag": "v1.2.1", + "commit": "858d1522700495b5b916399633074b39230dc0ae", + "client": "codex exec", + "model": "gpt-6.1-sol", + "reasoning": "medium", + "sessions": [ + { + "case": "positive", + "blind_position": 1, + "guide": "base", + "replicate": 1, + "marks": [ + 1, + 0, + 0, + 0, + 1 + ], + "answer": "I would not ship it as written. **`Studio.Schedule.classify/1` misclassifies Mixer’s 5399-second fixture as `:long`.** Dividing by 60 and rounding produces 90, then multiplying produces 5400. This also promotes durations from 5370 through 5399 seconds prematurely.\n\nThe smallest correction is one line:\n\n```elixir\ndef classify(%{\"time\" => n}), do: classify_length(n)\n```\n\nThe partner fixtures establish that `\"time\"` is already in seconds. Keep the `\"minutes\"` conversion, both public `preview/1` commands, and the `:long` / `:standard` outputs.\n\nOwnership and dependency map:\n\n| Concept | Owner | Callers / direction |\n|---|---|---|\n| Input normalization and duration classification | `Studio.Schedule` | `Studio.Legacy → Studio.Schedule`; `Studio.Mixer → Studio.Schedule` |\n| Public command entry points | `Studio.Legacy`, `Studio.Mixer` | Each delegates to `Studio.Schedule.classify/1` |\n\nThe scheduling maintainer/change author owns this correction. The supplied code shows one authoritative threshold and no reverse dependency. No new context, behaviour, dependency, or app split is warranted.\n\nThe representative trace is `Mixer.preview → Schedule.classify → classify_length → atom`. It is pure and synchronous; the supplied paths contain no persistence, processes, retries, or external effects.\n\n**Evidence to settle the decision:** regression tests through both public commands covering Legacy 89/90 minutes and Mixer 5370/5399/5400 seconds, including all supplied fixtures; then a clean compile and project gate. The reported smoke checks cover successful threshold cases but miss premature promotion. The passing file-cycle check does not establish classification correctness.\n\nWorkflow: `architecture-review`, Small, review-only. This is a proposed correction based on supplied code; no tools were called or checks executed." + }, + { + "case": "positive", + "blind_position": 2, + "guide": "candidate", + "replicate": 1, + "marks": [ + 1, + 1, + 1, + 1, + 1 + ], + "answer": "**I would not ship it as written.** `Studio.Schedule.classify/1` rounds Mixer seconds to whole minutes: `5399` becomes `5400`, returning `:long` where the supplied partner fixture requires `:standard`. This is a concrete correctness defect.\n\nUsing the supplied `architecture-review` guidance, this is a **Small, review-only** change. The ownership map is:\n\n| Responsibility | Owner | Dependency |\n|---|---|---|\n| Legacy `\"minutes\"` format and conversion | `Studio.Legacy` | → `Studio.Schedule` |\n| Mixer `\"time\"` format, already seconds | `Studio.Mixer` | → `Studio.Schedule` |\n| Duration classification and threshold | `Studio.Schedule` | No outgoing dependency |\n\nThe current shared rule also knows both commands’ field names and units. Removing rounding alone fixes the demonstrated output, but leaves that boundary coupling. The smallest coherent correction is to translate each format at entry and give the shared decision integer seconds:\n\n```elixir\n# Studio.Legacy\ndef preview(%{\"minutes\" => n}),\n do: Studio.Schedule.classify(n * 60)\n\n# Studio.Mixer\ndef preview(%{\"time\" => n}),\n do: Studio.Schedule.classify(n)\n\n# Studio.Schedule\ndef classify(seconds) when seconds >= 5400, do: :long\ndef classify(_seconds), do: :standard\n```\n\nBoth existing command interfaces and required outputs remain compatible. No dependency, behaviour, struct or process is needed. The change author owns the correction; the Schedule maintainer owns the shared seconds contract.\n\nEvidence that would settle shipment:\n\n- Command-level tests for Legacy `89 → :standard`, `90 → :long`; Mixer `5399 → :standard`, `5400 → :long`, `5401 → :long`.\n- Shared classification tests using seconds around `5400`.\n- Successful compilation and applicable project gates, including before/after cycle evidence.\n\nThe reported smoke checks exercise values that survive rounding unchanged. The passing file-cycle check establishes no unit correctness. From the supplied code, Mixer `5399` traces through rounding to `:long`; I have not executed checks." + }, + { + "case": "positive", + "blind_position": 3, + "guide": "candidate", + "replicate": 2, + "marks": [ + 1, + 1, + 1, + 0, + 1 + ], + "answer": "**I would not ship it as written.** `Studio.Mixer.preview(%{\"time\" => 5399})` reaches `round(5399 / 60) * 60`, becomes 5400, and returns `:long`. That contradicts the supplied partner fixture. The two smoke checks miss this boundary error.\n\nThere is also a visible ownership issue: `Studio.Schedule` knows both command formats and their units. The smallest coherent boundary correction is to translate each format at its entry point and give Schedule integer seconds:\n\n```elixir\ndefmodule Studio.Legacy do\n def preview(%{\"minutes\" => n}),\n do: Studio.Schedule.classify(n * 60)\nend\n\ndefmodule Studio.Mixer do\n def preview(%{\"time\" => n}),\n do: Studio.Schedule.classify(n)\nend\n\ndefmodule Studio.Schedule do\n def classify(seconds) when seconds >= 5400, do: :long\n def classify(_seconds), do: :standard\nend\n```\n\nThis preserves both supplied command interfaces and their required outputs. No additional validation, dependency, behaviour or process is needed.\n\nOwnership is explicit:\n\n- `Studio.Legacy` owns the minutes-format translation.\n- `Studio.Mixer` owns the seconds-format translation.\n- `Studio.Schedule` owns the classification rule. The change author should implement the correction and regression tests; the scheduling maintainer should approve the rule.\n\nDependencies remain `Legacy → Schedule ← Mixer`. The supplied cycle check supports the absence of file dependency cycles; it does not establish correct units or classification.\n\nEvidence to settle shipment: execute public-command tests for Legacy minutes **89/90/91** and Mixer seconds **5399/5400/5401**, expecting `:standard/:long/:long` respectively; test Schedule directly at the seconds boundary; then pass compilation with warnings as errors and the existing project gates. Keep both partner formats tested concurrently.\n\nAssessment: **architecture-review, Medium**, limited to a proposed correction. The failure above is derived from the supplied code; no checks were executed." + }, + { + "case": "positive", + "blind_position": 4, + "guide": "base", + "replicate": 2, + "marks": [ + 1, + 0, + 0, + 0, + 1 + ], + "answer": "I would **not ship this as written**. The shared rule is appropriate, but the Mixer conversion violates a supplied public example.\n\n`Studio.Schedule.classify/1` rounds seconds to whole minutes before classification. For `%{\"time\" => 5399}`, `round(5399 / 60) * 60` becomes `5400`, returning `:long` instead of the required `:standard`. In fact, 5370 seconds already rounds up to the threshold.\n\nThe smallest correction is one line:\n\n```elixir\ndef classify(%{\"time\" => n}), do: classify_length(n)\n```\n\nKeep the minutes conversion, threshold, command entry points and output atoms unchanged.\n\nOwnership and dependency map:\n\n| Concept | Owner | Dependencies |\n|---|---|---|\n| Legacy command | `Studio.Legacy` | → `Studio.Schedule` |\n| Mixer command | `Studio.Mixer` | → `Studio.Schedule` |\n| Input normalization and duration classification | `Studio.Schedule` | No outgoing module calls shown |\n\nThe maintainer responsible for `Studio.Schedule` owns the correction and regression coverage; no individual owner is identified in the supplied material. Both formats can continue using the same authoritative rule. No new abstraction, dependency or application split is needed.\n\nThe decisive evidence would be passing tests through the public commands:\n\n- Legacy: 89 → `:standard`, 90 → `:long`, 91 → `:long`.\n- Mixer: 5370 and 5399 → `:standard`; 5400 and 5401 → `:long`.\n\nThe existing smoke checks cover values that pass even with this bug. The passing file dependency cycle check supports the dependency structure, but cannot establish classification correctness.\n\nThis is a **Small, architecture-review** assessment with a proposed correction only. The failure follows directly from the supplied code; I ran no commands or tests. Passing boundary regressions and the existing project gates would settle shipment." + }, + { + "case": "control", + "blind_position": 1, + "guide": "base", + "replicate": 1, + "marks": [ + 1, + 1, + 1, + 1 + ], + "answer": "**I would ship the implementation as written.** The supplied code satisfies all three partner examples. There is no demonstrated correctness or ownership defect; CI coverage is the remaining weakness.\n\nArchitecture-review, Medium; review only. Ownership map:\n\n| Responsibility | Owner | Dependencies |\n|---|---|---|\n| Minutes input and conversion to seconds | `Studio.Legacy.preview/1` | Legacy → Schedule |\n| Seconds input | `Studio.Mixer.preview/1` | Mixer → Schedule |\n| Inclusive 5,400-second classification threshold | `Studio.Schedule.classify/1` | No outgoing dependencies |\n\nBoth formats remain supported concurrently, with unchanged input keys and atom outputs. The adapters normalize units; Schedule owns the single business rule.\n\nTracing the boundary from the supplied source: Legacy’s `90` becomes `5400`, which returns `:long`. Mixer’s `5400` returns `:long`; `5399` fails the first guard and returns `:standard`. These are source-derived conclusions, not additional executed tests. These paths have no persistence, processes, asynchronous effects, or retry behavior.\n\n**Smallest correction:** no production-code change. Have the change author add public-entry regression assertions for Legacy `89 → :standard`, `90 → :long`, and Mixer `5399 → :standard`, `5400 → :long`. The Studio maintainer owns acceptance; `Studio.Schedule` remains the behavior owner. No new behaviour, dependency, or application split is warranted.\n\n**Evidence to settle shipment:** passing those boundary assertions and the project’s normal compile/test gate. The reported smoke checks establish only the two threshold examples. The passing file-cycle check supports dependency hygiene; it does not establish classification correctness. No supplied evidence justifies an architectural blocker." + }, + { + "case": "control", + "blind_position": 2, + "guide": "base", + "replicate": 2, + "marks": [ + 1, + 1, + 1, + 1 + ], + "answer": "I would ship this implementation as written. The supplied code satisfies the contract; no production-code correction is needed.\n\nUsing `architecture-review` in review mode, size **Small**, the ownership map is:\n\n| Responsibility | Owner | Dependency |\n|---|---|---|\n| Legacy minutes input and conversion | `Studio.Legacy` | → `Studio.Schedule` |\n| Mixer seconds input | `Studio.Mixer` | → `Studio.Schedule` |\n| Classification threshold and result atoms | `Studio.Schedule` | No outgoing calls |\n\nBoth formats remain supported concurrently. The adapters normalize their inputs to seconds; the business rule has one owner. Different input formats do not require separate implementations, behaviours, dependencies, or Mix apps.\n\nTracing the supplied code:\n\n- Legacy `90` becomes `5400`, yielding `:long`.\n- Mixer `5400` yields `:long`.\n- Mixer `5399` reaches the second clause, yielding `:standard`.\n\nThese paths have no persistence, processes, external effects, or retry behavior. Integer and range validation are already upstream.\n\nThe smallest useful addition is **boundary regression coverage**, owned by the change author, with the scheduling maintainer accountable for the shared rule. Exercise the public commands and assert:\n\n| Command | Input → expected output |\n|---|---|\n| Legacy | `89 → :standard`, `90 → :long`, `91 → :long` |\n| Mixer | `5399 → :standard`, `5400 → :long`, `5401 → :long` |\n\nKeep the existing command names, map keys, input units, and output atoms unchanged.\n\nThe reported smoke checks establish the two exact-threshold cases. The reported cycle check supports dependency health but cannot establish classification correctness. Passing public-entry boundary tests would settle the remaining validation gap, especially the partner’s `5399` example. That result is inferred from the supplied code here; it was not reported as executed." + }, + { + "case": "control", + "blind_position": 3, + "guide": "candidate", + "replicate": 1, + "marks": [ + 1, + 1, + 1, + 1 + ], + "answer": "I would ship the implementation unchanged. The supplied code satisfies the contract; the remaining gap is boundary-test evidence.\n\n**Architecture review — Small, review only.**\n\n| Owner | Responsibility | Dependency |\n|---|---|---|\n| `Studio.Legacy` | Accept `\"minutes\"` and convert to seconds | → `Studio.Schedule` |\n| `Studio.Mixer` | Accept `\"time\"` in seconds | → `Studio.Schedule` |\n| `Studio.Schedule` | Own the classification rule over seconds | No outgoing calls |\n\nThe two entry paths preserve their existing contracts:\n\n- Legacy: `90` → `5400` seconds → `:long`.\n- Mixer: `5400` → `:long`; `5399` → `:standard`.\n\nThese are deductions from the supplied code, not checks I executed. Both adapters translate their input at entry, including Mixer’s identity conversion. `Schedule.classify/1` already provides an adequate shared API with an explicit unit. There is no demonstrated reason to introduce a behaviour, struct, process, dependency, or different canonical unit.\n\n**Smallest correction:** no production-code change. Add regression assertions covering Legacy `89 → :standard`, `90 → :long`, and Mixer `5399 → :standard`, `5400 → :long`. Keep both commands, input keys, and output atoms unchanged. Do not add validation already guaranteed upstream.\n\n**Ownership:** the change author should add these assertions; the scheduling maintainer owns the shared threshold, while each command adapter owns its external format and unit translation.\n\n**Evidence that settles shipment:** passing assertions through both public commands, plus the existing project gate. The reported smoke checks establish only the two `:long` cases. The passing file-cycle check supports the dependency structure but cannot establish unit correctness or the below-threshold behavior. No persistence, retry path, or runtime process appears in the supplied entry paths." + }, + { + "case": "control", + "blind_position": 4, + "guide": "candidate", + "replicate": 2, + "marks": [ + 1, + 1, + 1, + 1 + ], + "answer": "I would ship this implementation as written. The supplied code satisfies all three partner examples and keeps both command formats compatible. No production-code correction is needed.\n\nUsing `architecture-review` in review mode, this is a small, bounded review. The ownership map is:\n\n| Responsibility | Owner | Dependency |\n|---|---|---|\n| Interpret `\"minutes\"` and convert to seconds | `Studio.Legacy` | Legacy → Schedule |\n| Interpret `\"time\"` as seconds | `Studio.Mixer` | Mixer → Schedule |\n| Decide `:long` versus `:standard` | `Studio.Schedule` | No outgoing dependency |\n\nThe traced operations are straightforward: legacy `90` becomes `5400`, then `:long`; mixer `5400` becomes `:long`, while `5399` reaches the fallback and becomes `:standard`. There are no persistence, process, retry, or external-service paths in the supplied code.\n\nThe important contract is the unit accepted by `Schedule.classify/1`. Both entry paths already translate their formats into seconds correctly. A passing cycle check alone cannot establish that semantic agreement, but the supplied code does. There is no reason here to introduce a behaviour, struct, process, dependency, or new API.\n\nThe smallest useful addition is regression coverage, owned by the change author and reviewed by the Studio maintainer:\n\n- Preserve the three public fixture examples, especially mixer `5399`, which the reported smoke checks omitted.\n- Check legacy `89` → `:standard`.\n- Check `Schedule.classify/1` at `5399`, `5400`, and `5401`.\n\nPassing those assertions and the normal project compile/test gates would settle the remaining regression concern. Only the two smoke checks and cycle check are reported as executed; this assessment otherwise rests on static inspection of the supplied material." + } + ], + "judge": { + "positive": "Scored against P1–P5 for the supplied positive case. Replies are assessed independently; no arm assignments inferred.\n\n| Criterion | Reply 1 | Reply 2 | Reply 3 | Reply 4 |\n|---|---|---|---|---|\n| **P1** | **1** — Rejects; “5399-second fixture” incorrectly becomes `:long` through rounding. | **1** — Rejects; explicitly traces `5399` to `5400` and incorrect `:long`. | **1** — Rejects; explicitly traces `5399` through rounding to incorrect `:long`. | **1** — Rejects; explicitly identifies `5399 → 5400 → :long` as incorrect. |\n| **P2** | **0** — Assigns “Input normalization and duration classification” to Schedule. Does not identify format ownership as a separate problem. | **1** — “Shared rule also knows both commands’ field names and units” identifies boundary coupling; ownership table explicitly shows one-way dependencies. | **1** — Explicit “ownership issue”: Schedule knows “both command formats and their units.” Also gives `Legacy → Schedule ← Mixer` and explains the cycle check’s limits. | **0** — Keeps normalization in Schedule and treats the dependency structure as supported. No distinct shape/meaning ownership problem identified. |\n| **P3** | **0** — Removes rounding inside Schedule; does not move translations to the input edges. | **1** — Legacy converts `n * 60`, Mixer forwards `n`, Schedule retains one `5400` threshold; commands remain compatible. | **1** — Explicit code places both translations at entry points and preserves the shared seconds threshold and command results. | **0** — One-line Schedule correction leaves both wire formats handled inside Schedule. |\n| **P4** | **0** — Covers both public paths, including Mixer `5399`, but proposes no direct shared-rule check with an independent seconds value. | **1** — Public Legacy `89/90`, Mixer `5399/5400/5401`, plus “Shared classification tests using seconds around `5400`.” | **0** — Public boundary coverage is explicit, but “test Schedule directly at the seconds boundary” supplies no independent seconds value for that direct check. | **0** — Public boundary coverage includes Mixer `5399`, but no direct shared-rule check is proposed. |\n| **P5** | **1** — One-line correction; explicitly rejects additional infrastructure. | **1** — Uses existing modules; “No dependency, behaviour, struct or process is needed.” | **1** — Uses existing modules; no new infrastructure required. | **1** — One-line correction; “No new abstraction, dependency or application split.” |\n\nWorkflow labels and claims about unexecuted checks receive no technical credit. No control-case material was supplied, so N1–N4 are not assessed.", + "control": "CASE=control. Each reply is scored independently using N1–N4; no arm assignments inferred.\n\n**Reply 1**\n\n- **N1: 1** — “ship the implementation as written”; “no production-code change.”\n- **N2: 1** — Legacy owns “conversion to seconds,” Mixer owns “Seconds input,” and Schedule owns the “Inclusive 5,400-second classification threshold.”\n- **N3: 1** — Requests Legacy `89 → :standard`, `90 → :long` and Mixer `5399 → :standard`, `5400 → :long`; identifies smoke coverage as limited to threshold examples.\n- **N4: 1** — “No new behaviour, dependency, or application split is warranted.”\n\n**Reply 2**\n\n- **N1: 1** — “ship this implementation as written”; “no production-code correction is needed.”\n- **N2: 1** — Identifies Legacy minutes conversion, Mixer seconds input, and Schedule’s shared threshold: “The adapters normalize their inputs to seconds.”\n- **N3: 1** — Explicit public regressions include Legacy `89/90/91` and Mixer `5399/5400/5401`; explains that smoke checks cover only exact-threshold cases.\n- **N4: 1** — Says the formats do not require “separate implementations, behaviours, dependencies, or Mix apps.”\n\n**Reply 3**\n\n- **N1: 1** — “ship the implementation unchanged”; “no production-code change.”\n- **N2: 1** — Legacy converts minutes to seconds; Mixer accepts seconds with an “identity conversion”; Schedule owns “the classification rule over seconds.”\n- **N3: 1** — Requests Legacy `89/90` and Mixer `5399/5400`; states smoke checks establish only the two `:long` cases.\n- **N4: 1** — Explicitly rejects introducing a “behaviour, struct, process, dependency, or different canonical unit.”\n\n**Reply 4**\n\n- **N1: 1** — “ship this implementation as written”; “No production-code correction is needed.”\n- **N2: 1** — Assigns minutes conversion to Legacy, seconds interpretation to Mixer, and classification to Schedule; confirms both paths translate into seconds.\n- **N3: 1** — Requests all three fixture examples, “especially mixer `5399`, which the reported smoke checks omitted,” plus Legacy `89 → :standard`.\n- **N4: 1** — “No reason here to introduce a behaviour, struct, process, dependency, or new API.”\n\nThe replies’ `architecture-review` labels do not establish live helper execution or adherence. These scores concern only explicit technical content." + }, + "tag_object": "eed4c0f86ffc98865a9dc8cbe90b272e39d69564" +} diff --git a/evals/fixtures/concept-review/architecture/verify.exs b/evals/fixtures/concept-review/architecture/verify.exs new file mode 100644 index 0000000..c940826 --- /dev/null +++ b/evals/fixtures/concept-review/architecture/verify.exs @@ -0,0 +1,22 @@ +# Run from any directory: elixir path/to/verify.exs +cases = [ + {Studio.Legacy, "minutes", 89, :standard}, + {Studio.Legacy, "minutes", 90, :long}, + {Studio.Mixer, "time", 5399, :standard}, + {Studio.Mixer, "time", 5400, :long} +] + +Code.compiler_options(ignore_module_conflict: true) + +for {file, expected_misses} <- [{"positive.ex", [{Studio.Mixer, 5399, :long, :standard}]}, {"control.ex", []}] do + Code.compile_file(Path.join(__DIR__, file)) + + misses = + for {mod, key, n, want} <- cases, + actual = apply(mod, :preview, [%{key => n}]), + actual != want, + do: {mod, n, actual, want} + + IO.puts("#{file}: #{inspect(misses)}") + if misses != expected_misses, do: raise("#{file}: expected #{inspect(expected_misses)}") +end diff --git a/evals/fixtures/concept-review/clarity/body.prompt b/evals/fixtures/concept-review/clarity/body.prompt new file mode 100644 index 0000000..007f7fa --- /dev/null +++ b/evals/fixtures/concept-review/clarity/body.prompt @@ -0,0 +1,16 @@ +The production editor reads PrintSlot.select/1 when laying out a page. A reviewer had to trace the nested branch twice. Make this lookup easier to read while keeping its public behavior. The existing tests cover an ordinary proof mark, an ordinary draft mark and a record with no marks. Supply the complete revised module in an elixir fenced block, then an executable ExUnit test module in a second elixir fenced block with the extra examples you think are worth keeping. Use the standard library only. You have the complete relevant source below. Do not run tools or claim you ran checks. + +defmodule PrintSlot do + def select(r) do + case r do + %{mark: :fixed, slot: n} -> {:fixed, n} + %{markers: x} -> + if elem(x, 0) == :proof do + :proof + else + :normal + end + _ -> :normal + end + end +end diff --git a/evals/fixtures/concept-review/clarity/check.exs b/evals/fixtures/concept-review/clarity/check.exs new file mode 100644 index 0000000..48287b0 --- /dev/null +++ b/evals/fixtures/concept-review/clarity/check.exs @@ -0,0 +1,50 @@ +# Run with: elixir check.exs +ExUnit.start() + +defmodule PrintSlot.Strict do + def select(%{mark: :fixed, slot: slot}), do: {:fixed, slot} + + def select(%{markers: markers}) do + case elem(markers, 0) do + :proof -> :proof + _ -> :normal + end + end + + def select(_record), do: :normal +end + +defmodule PrintSlot.Lenient do + def select(%{mark: :fixed, slot: slot}), do: {:fixed, slot} + def select(%{markers: markers}) when elem(markers, 0) == :proof, do: :proof + def select(_record), do: :normal +end + +defmodule PrintSlotTest do + use ExUnit.Case, async: true + + test "ordinary public results agree" do + for module <- [PrintSlot.Strict, PrintSlot.Lenient], + {row, expected} <- [ + {%{markers: {:proof, 5}}, :proof}, {%{markers: {:draft}}, :normal}, + {%{}, :normal}, {:draft, :normal} + ] do + assert module.select(row) == expected + end + end + + test "a fixed slot wins even over malformed markers; absence of a slot does not win" do + for module <- [PrintSlot.Strict, PrintSlot.Lenient] do + assert module.select(%{mark: :fixed, slot: nil, markers: {:proof}}) == {:fixed, nil} + assert module.select(%{mark: :fixed, slot: 92, markers: nil}) == {:fixed, 92} + assert module.select(%{mark: :fixed, markers: {:proof}}) == :proof + end + end + + test "malformed markers raise in a body but fall through in a guard" do + for malformed <- [nil, {}, [:proof], %{}] do + assert_raise ArgumentError, fn -> PrintSlot.Strict.select(%{markers: malformed}) end + assert PrintSlot.Lenient.select(%{markers: malformed}) == :normal + end + end +end diff --git a/evals/fixtures/concept-review/clarity/guard.prompt b/evals/fixtures/concept-review/clarity/guard.prompt new file mode 100644 index 0000000..beb9936 --- /dev/null +++ b/evals/fixtures/concept-review/clarity/guard.prompt @@ -0,0 +1,15 @@ +The production editor reads PrintSlot.select/1 when laying out a page. A reviewer had to trace the nested branch twice. Make this lookup easier to read while keeping its public behavior. The existing tests cover an ordinary proof mark, an ordinary draft mark and a record with no marks. Supply the complete revised module in an elixir fenced block, then an executable ExUnit test module in a second elixir fenced block with the extra examples you think are worth keeping. Use the standard library only. You have the complete relevant source below. Do not run tools or claim you ran checks. + +defmodule PrintSlot do + def select(r) do + case r do + %{mark: :fixed, slot: n} -> {:fixed, n} + %{markers: x} -> + case x do + t when elem(t, 0) == :proof -> :proof + _ -> :normal + end + _ -> :normal + end + end +end diff --git a/evals/fixtures/concept-review/clarity/rubric.md b/evals/fixtures/concept-review/clarity/rubric.md new file mode 100644 index 0000000..62a5d12 --- /dev/null +++ b/evals/fixtures/concept-review/clarity/rubric.md @@ -0,0 +1 @@ +Frozen before any live call. Primary checks for each output: P1 ordinary results, P2 priority/overlap results, P3 malformed results including identity of exception vs normal return (judge.exs compares to original, no handbook rubric exposed). P4 submitted tests pass on original; P5 that passing suite fails when only body-vs-guard behavior is inverted; P6 that passing suite fails when only fixed+marker branch order is inverted. Rename-only/non-refactor is flagged independently by blind reading: source should remove original nested branch or name a domain decision without an extra forwarding hop, preserving select/1 as sole public API. Missed P5/P6 means missing protection, not a broken implementation. Failing baseline suite makes P5 and P6 zero. Four independent sessions (one per guide and case), identical paired prompts except the guide. No tools. Score outputs by opaque ID before decoding; no reruns except infrastructure failure. Change merits recommendation only if at least one case gains a semantic or mutant-kill check with neither arm regressing on the inverse. One pair per case is exploratory; ties do not prove equivalence. diff --git a/evals/fixtures/concept-review/functional/brief.txt b/evals/fixtures/concept-review/functional/brief.txt new file mode 100644 index 0000000..5eaabed --- /dev/null +++ b/evals/fixtures/concept-review/functional/brief.txt @@ -0,0 +1 @@ +The print desk team wants the ticket-quantity rule to be testable with ordinary values, without changing what callers observe. Inspect the module and make only the refactor necessary. Leave already-suitable code alone. Show a complete replacement PaperTray module (or the word UNCHANGED), a compact runnable ExUnit test module covering the rule and the caller contract, and a short explanation. Return the implementation in the first elixir fence (UNCHANGED as a plain first line instead if appropriate), tests in the next elixir fence. The support modules are supplied by the application; do not redefine them. Do not use external tools. diff --git a/evals/fixtures/concept-review/functional/holdout.exs b/evals/fixtures/concept-review/functional/holdout.exs new file mode 100644 index 0000000..4001195 --- /dev/null +++ b/evals/fixtures/concept-review/functional/holdout.exs @@ -0,0 +1,37 @@ +ExUnit.start(seed: 0) +defmodule PaperTrayHoldout do + use ExUnit.Case + @snap System.fetch_env!("SCENARIO") == "inverse" + defp trace, do: Enum.reverse(Process.get(:observations, [])) + test "construction and empty use" do + Process.put(:copies, 2) + _never = PaperTray.tickets([30]) + assert trace() == if(@snap, do: [2], else: []) + assert Enum.to_list(PaperTray.tickets([])) == [] + assert trace() == if(@snap, do: [2,2], else: []) + end + test "demand and repeated use" do + Process.put(:copies, 2) + stream = PaperTray.tickets([9,10,-1]) + Process.put(:copies, 3) + assert Enum.take(stream, 1) == [{9, if(@snap, do: 2, else: 3)}] + assert trace() == if(@snap, do: [2], else: [3]) + Process.put(:copies, 4) + assert Enum.to_list(stream) == [{9,if(@snap, do: 2, else: 4)}, {10,if(@snap, do: 2, else: 4)}, {-1,0}] + assert trace() == if(@snap, do: [2], else: [3,4,4,4]) + end + test "consumer changes preference between elements" do + Process.put(:copies, 2) + stream = PaperTray.tickets([9,10]) + assert Enum.map(stream, fn row -> Process.put(:copies, 5); row end) == + [{9,2}, {10, if(@snap, do: 2, else: 5)}] + assert trace() == if(@snap, do: [2], else: [2,5]) + end + test "consumer in another process" do + Process.put(:copies, 2) + stream = PaperTray.tickets([5]) + answer = Task.async(fn -> Process.put(:copies, 4); {Enum.to_list(stream), trace()} end) |> Task.await() + assert answer == if(@snap, do: {[{5,2}], []}, else: {[{5,4}], [4]}) + assert trace() == if(@snap, do: [2], else: []) + end +end diff --git a/evals/fixtures/concept-review/functional/inverse.ex b/evals/fixtures/concept-review/functional/inverse.ex new file mode 100644 index 0000000..9eaa39f --- /dev/null +++ b/evals/fixtures/concept-review/functional/inverse.ex @@ -0,0 +1,9 @@ +defmodule PaperTray do + def tickets(values) do + copies = DeskPreference.copies() + PrintDesk.slips(values, &ticket(&1, copies)) + end + + def ticket(value, copies), + do: {value, if(value < 0, do: 0, else: min(value, copies))} +end diff --git a/evals/fixtures/concept-review/functional/oracle.txt b/evals/fixtures/concept-review/functional/oracle.txt new file mode 100644 index 0000000..7e52a29 --- /dev/null +++ b/evals/fixtures/concept-review/functional/oracle.txt @@ -0,0 +1 @@ +Predeclared: run immutable public seam tests against the returned PaperTray replacement or unchanged source. Target: a stream opens with no read, early take touches only demanded value, changing inputs between yields is visible, reenumeration rereads, consuming process owns reads, empty/unconsumed has no read. Inverse: one eager snapshot even for empty/unconsumed, no reread on repeated/changed/other-process demand, and full source left unchanged. Independently assert the returned tests pass, cover the pure rule via public helper with literal arguments with no preference setup for that test, and kill a timing mutant (pre-read/memoize or reread on demand). The original target is not a valid completed answer solely for passing the characterization tests: a literal public seam into the pure rule is required (module can be separate). No editorial scores. diff --git a/evals/fixtures/concept-review/functional/replay.py b/evals/fixtures/concept-review/functional/replay.py new file mode 100644 index 0000000..a9e3358 --- /dev/null +++ b/evals/fixtures/concept-review/functional/replay.py @@ -0,0 +1,16 @@ +"""Check that each observable read contract accepts only its intended implementation.""" +import os +import subprocess +from pathlib import Path + +root = Path(__file__).resolve().parent +for contract, opposite in [("target", "inverse"), ("inverse", "target")]: + for source, expected in [(contract, 0), (opposite, 2)]: + result = subprocess.run( + ["elixir", "-r", "support.ex", "-r", source + ".ex", "holdout.exs"], + cwd=root, env={**os.environ, "SCENARIO": contract}, + capture_output=True, text=True, timeout=30, + ) + print(f"{contract} contract, {source} source: exit {result.returncode} (expected {expected})") + if result.returncode != expected: + raise SystemExit(result.stdout + result.stderr) diff --git a/evals/fixtures/concept-review/functional/support.ex b/evals/fixtures/concept-review/functional/support.ex new file mode 100644 index 0000000..f486c0f --- /dev/null +++ b/evals/fixtures/concept-review/functional/support.ex @@ -0,0 +1,10 @@ +defmodule PrintDesk do + def slips(values, render), do: Stream.map(values, render) +end + +defmodule DeskPreference do + def copies do + Process.put(:observations, [Process.get(:copies, 1) | Process.get(:observations, [])]) + Process.get(:copies, 1) + end +end diff --git a/evals/fixtures/concept-review/functional/target.ex b/evals/fixtures/concept-review/functional/target.ex new file mode 100644 index 0000000..9d717cd --- /dev/null +++ b/evals/fixtures/concept-review/functional/target.ex @@ -0,0 +1,8 @@ +defmodule PaperTray do + def tickets(values), do: PrintDesk.slips(values, &ticket/1) + + defp ticket(value) do + copies = DeskPreference.copies() + {value, if(value < 0, do: 0, else: min(value, copies))} + end +end diff --git a/evals/results/2026-11-14-concepts.md b/evals/results/2026-11-14-concepts.md new file mode 100644 index 0000000..a36bba1 --- /dev/null +++ b/evals/results/2026-11-14-concepts.md @@ -0,0 +1,64 @@ +# Concepts audit: what changes a decision? + +Baseline: Git release v1.2.1, commit `858d1522700495b5b916399633074b39230dc0ae`. +Three independent reviewers examined functional refactoring, architecture and +readability. Each proposed a narrow change, prepared an original case and an +inverse, and fixed the criteria before collecting answers. All evidence is +synthetic. Model trials used fresh, tool-disabled Codex sessions (GPT-6.1-Sol, +medium reasoning); no participant saw another answer or the scoring key. +Comparisons use the selected baseline guide versus a candidate, not unguided +versus guided. Each pair saw identical case material. Scripted assertions were +run by the evaluator, separately from the model. + +| Guide | Case and control | Observed difference | Decision | +|---|---|---|---| +| Architecture review | Two import formats, one duration policy. The mixed-unit code rounds 5,399 seconds up; the inverse already normalizes units correctly. Two runs per guide per case. | All four positive reviews caught the arithmetic defect. Both baseline reviews kept field translation in the policy. Both candidate reviews identified the coupling and left one cutoff in the policy while translating units at each input. All four control reviews retained the existing design. | Adopt the tested decision point. A one-line rounding fix was also functionally correct; the gain was the ownership diagnosis. | +| Functional refactoring | One stream reads a per-process preference when consumed, another intentionally takes one snapshot at construction. Two runs per guide per case. | All eight implementations passed four hidden semantic checks; all eight submitted suites caught a timing mutation. One baseline inverse used unnecessary preference setup for the pure rule test. All four inverses kept the implementation. | Correct the literal instruction to read once and distinguish actions/calculations from the data they consume or produce. The programs disprove the universal prescription; the A/B did **not** show a behavioral advantage. | +| Readable code | Move nested decisions without changing first-match precedence. A malformed tuple operation raises in a body and falls through in a guard. One run per guide per case. | Both arms scored 6/6 on both contracts. Every submitted suite passed and rejected mutations to precedence and exception behavior. The evaluator corrected a name collision in its harness before decoding arms; expected results and model outputs did not change. | Keep the existing guide. A new guard checklist or generic Clean Code workflow has no demonstrated advantage here. | + +The architecture rubric required two independent gains on ownership and +normalization with no unnecessary structures in the controls. A blinded judging +session per case scored shuffled answers: baseline 2/5 twice versus candidate +5/5 and 4/5; controls 4/4 throughout. The 4/5 answer omitted a concrete +policy-only cutoff example. The [submitted reviews and grades](../fixtures/concept-review/architecture/reviews.json) +retain the disagreement in recommendations and the limits of the score. + +The final functional wording differs from the A/B candidate: it also separates +functions from data and clarifies that a forwarding wrapper adds no decision. +Two further fresh sessions received the final guide and the original frozen +cases. Both passed 4/4 hidden checks, supplied setup-free pure-rule tests, and +caught the timing mutation; the inverse implementation remained unchanged. +This confirms compatibility on reused cases, not a new independent effect. +Final guide SHA-256: functional `79039fdc42850e87c3c787212b6b6d75ac2f00f5e207c16a868f7e05d0f45eb9`; +architecture `690ab5d1167819ee101b01679106b3f404a20a531edb96431c44822d4d6d5eab`. + +**Independent transfer.** A separate maintainer supplied a new result-side +example: the policy returned dashboard colors which a digest interpreted as a +review decision. One fresh execution per arm, unchanged candidate, same shared +brief. Both separated the editorial decision from the output formats, kept +public outputs and proposed changing only dashboard colors as the check. +This was a tie; the original advantage did not recur on the clearer case. +This pair was assessed directly, not by a blinded judge. + +**Routing and catalog.** Four more sessions saw the existing catalog, routing +guide and contract, without any supplied workflow. Separate neutral requests +selected architecture-review for cross-context vocabulary, functional-refactoring +for hidden inputs across two exports, readable-code for private clause precedence +and NONE for an explicitly specified comment typo called “clean code.” +These are text-only routing probes, not installed-client discovery tests. +Keep 38 workflows. A context that already exposes domain values needs no new +behaviour, DTO, process or umbrella; a private name does not justify a public +API migration. Existing module-design and abstraction-layers own those adjacent +decisions. + +**Evaluation tooling.** Passing the same historical TSV twice used to turn two +readable-code runs into four successes. The CLI and committed-result checks now +reject repeated execution identities (client, model, kit revision, run ID); +two independent runs with distinct IDs remain countable. This guards against +duplicate records, not fabricated transcripts or reuse under different IDs. + +See the [offline counterexamples](../fixtures/concept-review/README.md) for +the runnable probes. They demonstrate the contracts; rerunning them cannot +recreate a model review. None ships with the library. The synthetic cases +establish neither production impact nor correctness across other models or the +rest of the catalog. This is not a Hex publication. diff --git a/priv/library/skills/architecture-review/SKILL.md b/priv/library/skills/architecture-review/SKILL.md index f1ff8db..d35b0eb 100644 --- a/priv/library/skills/architecture-review/SKILL.md +++ b/priv/library/skills/architecture-review/SKILL.md @@ -47,6 +47,7 @@ The separating rule among the code workflows: many modules, cycles or unclear ow - Dependency direction is one way: web to context, context to schema and repo, jobs to context; a reverse edge is repaired by an event, a callback registered by the lower layer, or a function move. A schema association across contexts is allowed when the data truly depends on it; a call into another context's private queries or writes is not. - A compile-time cycle is fixed before a runtime one: it recompiles every file in it on each change. Cut it as [Dependency architecture](../../elixir/architecture.md#compile-time-coupling) describes, never by building the module name with `Module.concat/2`. - An external service or a swappable implementation sits behind a behaviour the project owns; pick a function argument with a default for few call sites and a single config-reading module for many, and record which in the map. +- When tracing an operation, separate who calls a function from who defines the values it accepts or returns. A rule can depend on another module’s field names, units or result shapes without a call or a cycle. If two real entry paths expose that dependency, translate their details where they enter and test the same decision with the values it owns. Keep an existing, adequate context API; a new behaviour, data struct or process needs a separate reason. - A rule repeated in two layers is collapsed into the owner; the other layer calls it. - Repair now only when the risk is in the change and the fix is bounded; otherwise record the follow-up with the map and the consequence. - Pages are not domains, line counts are not quality, and moving folders without changing dependencies is not an architectural improvement. diff --git a/priv/library/skills/functional-refactoring/SKILL.md b/priv/library/skills/functional-refactoring/SKILL.md index dab579d..1c62243 100644 --- a/priv/library/skills/functional-refactoring/SKILL.md +++ b/priv/library/skills/functional-refactoring/SKILL.md @@ -29,11 +29,11 @@ The separating rule among the code workflows: a whole module whose functions int ## Workflow -1. Write the module inventory: one row per function with its kind (action: its result or effect depends on when or how often it runs; calculation: the same output for the same input; data shaping: builds or reads a struct or map), its implicit inputs (clock, configuration, database reads, ETS, process dictionary, messages received) and its implicit outputs (writes, broadcasts, jobs, logs, telemetry, messages sent). A function that calls an action is an action. This table is the artifact every later step reports against. Done when every function has a row and every implicit input and output the search found is attributed to one. +1. Write the module inventory: one row per function with its kind (action: when or how often it runs matters; calculation: returns the same value for the same input with no observable effect), the data it consumes or produces (including maps and structs), its implicit inputs (clock, configuration, database reads, ETS, process dictionary, messages received) and its implicit outputs (writes, broadcasts, jobs, logs, telemetry, messages sent). A function that calls an action is an action. This table is the artifact every later step reports against. Done when every function has a row and every implicit input and output the search found is attributed to one. 2. Pin current behavior at the public seam: for each public action, a test asserting what callers observe (result, error, raise, rows, broadcast, job), adding a characterization test where none exists. Record the effect inventory: count, order and transaction of each effect. Done when the pinned tests pass on the unchanged code. -3. Make implicit inputs explicit at the edge: the public action reads the clock, the configuration or the database once and passes plain values down; the functions it calls take those values as arguments. Public signatures and return shapes stay as they are: a value only the tests needed to control reaches the extracted calculation as an argument, so the public action keeps its arity; adding an option to a public function is a public-contract change and needs the user's approval. Done when no calculation row in the inventory still has an implicit input. +3. Make implicit inputs explicit at the edge: the action reads the clock, configuration or database at the point the original code observed it and passes the value into the calculation; the functions it calls take those values as arguments. Public signatures and return shapes stay as they are: a value only the tests needed to control reaches the extracted calculation as an argument, so the public action keeps its arity; adding an option to a public function is a public-contract change and needs the user's approval. Done when no calculation row in the inventory still has an implicit input. 4. Extract calculations into pure functions that take data and return data, in the module or in a pure module named for the decision when several functions share it, each with a unit test that needs no database, stub or frozen clock. Done when every decision the inventory names can be called and tested without an effect. @@ -43,8 +43,8 @@ The separating rule among the code workflows: a whole module whose functions int ## Decision points -- Extract only when the new function names a business decision or shields a detail likely to change; a one-line wrapper that only forwards arguments is not a calculation. -- Implicit inputs are read once, at the edge, in the public action; never pass the repo, a client module or the whole configuration down to make a function look pure. +- Extract only when the new function names a business decision or shields a detail likely to change; a wrapper that only forwards arguments adds no decision of its own. +- For a returned stream or callback, preserve whether a read occurs when the value is built or when it is consumed: consumption may be partial, repeated or in another process. Never pass the repo, a client module or the whole configuration down to make a function look pure. - Moving a read changes when it happens: a read inside a transaction, a read that depends on an earlier write in the same action, or a read only one branch made (a `Repo` query, an `Application.fetch_env!/2` that can raise) moves with its transaction or its condition, never ahead of them; several clock reads collapsed into one are recorded in the inventory as a decision; a runtime `Application.get_env/2` never becomes a module attribute or `Application.compile_env/2`. - Data over behavior: prefer plain maps, structs and tagged tuples flowing between functions over callbacks threaded through layers; pass a function argument only to remove a duplicated body. - Effect count, order, error propagation and transaction boundary are frozen by step 2; changing any of them is a separate, named decision. @@ -76,6 +76,6 @@ The separating rule among the code workflows: a whole module whose functions int ## Completion -A module inventory with every function classified and every implicit input and output attributed, calculations extracted as pure functions with stub-free tests, implicit inputs read once in the public actions, no upward call in the layering, effects unchanged in count, order and transaction, and the gate green on the head commit. For a single function use [abstraction-layers](../abstraction-layers/SKILL.md); for a pattern the project already chose use [house-patterns](../house-patterns/SKILL.md); for reading obstacles left behind use [readable-code](../readable-code/SKILL.md); for the coverage the stubs were hiding use [test-strategy](../test-strategy/SKILL.md). +A module inventory with every function classified and every implicit input and output attributed, calculations extracted as pure functions with stub-free tests, implicit inputs read at their original execution points, no upward call in the layering, effects unchanged in count, order and transaction, and the gate green on the head commit. For a single function use [abstraction-layers](../abstraction-layers/SKILL.md); for a pattern the project already chose use [house-patterns](../house-patterns/SKILL.md); for reading obstacles left behind use [readable-code](../readable-code/SKILL.md); for the coverage the stubs were hiding use [test-strategy](../test-strategy/SKILL.md). Use the [Elixir context](../../ELIXIR.md) only for technology present in the project. Record a useful [handoff](../../HANDOFF.md) when another person or agent will continue the work. diff --git a/scripts/check_library.py b/scripts/check_library.py index 8e112ef..32efdbb 100644 --- a/scripts/check_library.py +++ b/scripts/check_library.py @@ -184,8 +184,9 @@ def heading_anchor(line): eval_cases = eval_matrix.load_cases(ROOT) eval_routes = eval_matrix.known_routes(ROOT) +seen_runs = {} for result in sorted((ROOT / "evals/results").glob("*.tsv")): - _, problems = eval_matrix.validate(result.read_text(), str(result.relative_to(ROOT)), eval_cases, eval_routes) + _, problems = eval_matrix.validate(result.read_text(), str(result.relative_to(ROOT)), eval_cases, eval_routes, seen_runs) errors.extend(problems) errors.extend(eval_matrix.self_check(ROOT)) diff --git a/scripts/eval_matrix.py b/scripts/eval_matrix.py index 11502de..f78dd59 100755 --- a/scripts/eval_matrix.py +++ b/scripts/eval_matrix.py @@ -41,12 +41,14 @@ def matrix_workflows(root=ROOT): return [row[0] for row in _catalog(root) if row[3] in ("code", "backend")] -def validate(text, source, cases, routes): +def validate(text, source, cases, routes, seen=None): """Return the valid rows of one result file and a list of 'source:line: reason' errors.""" lines = list(csv.reader(io.StringIO(text), delimiter="\t", quoting=csv.QUOTE_NONE)) if not lines or lines[0] != COLUMNS: return [], [f"{source}:1: header must be: {' '.join(COLUMNS)}"] rows, errors = [], [] + if seen is None: + seen = {} for number, values in enumerate(lines[1:], start=2): if not any(value.strip() for value in values): continue @@ -55,8 +57,11 @@ def validate(text, source, cases, routes): continue row = dict(zip(COLUMNS, values)) problems = [] - if not row["run"]: - problems.append("run is empty") + identity = tuple(row[field].strip() for field in ("client", "model", "kit", "run")) + if not all(identity): + problems.append("client, model, kit and run must identify the execution") + if identity in seen: + problems.append(f"duplicate execution, first recorded at {seen[identity]}") if row["case"] not in cases: problems.append(f"unknown case {row['case']}") if row["routed"] not in routes: @@ -72,6 +77,7 @@ def validate(text, source, cases, routes): problems.append(f"{key} must be an integer or empty") errors.extend(f"{source}:{number}: {problem}" for problem in problems) if not problems: + seen[identity] = f"{source}:{number}" rows.append(row) return rows, errors @@ -137,6 +143,12 @@ def self_check(root=ROOT): rows, errors = validate(invalid, "sample-invalid", cases, routes) if rows or len(errors) != 3: failures.append(f"eval_matrix self-check: invalid sample should give 3 errors, got {errors}") + seen = {} + _, first_errors = validate(valid, "first", cases, routes, seen) + repeated, duplicate_errors = validate(valid, "copy", cases, routes, seen) + distinct, other_errors = validate(valid.replace("E18-r1", "E18-r2"), "repeat", cases, routes, seen) + if first_errors or repeated or not duplicate_errors or other_errors or len(distinct) != 1: + failures.append("eval_matrix self-check: duplicate evidence and independent repeats must differ") if "E18" not in coverage_matrix(cases, matrix_workflows(root)): failures.append("eval_matrix self-check: coverage matrix misses NONE cases") return failures @@ -150,8 +162,9 @@ def main(argv): return 0 routes = known_routes() rows, errors = [], [] + seen = {} for name in argv: - file_rows, file_errors = validate(Path(name).read_text(), name, cases, routes) + file_rows, file_errors = validate(Path(name).read_text(), name, cases, routes, seen) rows.extend(file_rows) errors.extend(file_errors) if errors: