Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

MCP: a race's regression test and report count a page line the page shows elsewhere too (the test stayed red after the fix) - #321

Open
MeharPro wants to merge 2 commits into
mainfrom
fix/explain-test-assertion
Open

MeharPro wants to merge 2 commits into
mainfrom
fix/explain-test-assertion

Conversation

@MeharPro

@MeharPro MeharPro commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What was wrong

genclass_explain turns a race found by genclass_explore into a Playwright regression test. On the Tiny Shop
(docs/evidence/e2e-walkthrough/app) that test could not go green: it stayed red after the race was fixed.

Typing "react" fast lets an older /api/search answer land last. Explore reports it correctly: under seed 2 the page
shows "Reading lamp" and "Real wood desk". Explore compares page lines as counts, and the shop always lists a product
card named "Reading lamp" outside the results, so that line is on the page once with responses in request order and
twice in the failing order. The finding's evidence says so (textCounts: "Reading lamp": { baseline: 1, run: 2 },
"Real wood desk": { baseline: 0, run: 1 }), and the replay verdict has used those counts since 0.2.0.

The test generator did not (packages/mcp/src/testgen.ts, the loop over textOnlyRun). It wrote

expect(snap.text, "the page does not show what only the failing order showed").not.toContain("Reading lamp");

which the product card alone fails, on the fixed shop too.

What changed

testgen.ts reads textCounts:

  • a line both orders show (one of them more often) is asserted by how many times the page shows it: no more often
    than with responses in request order for a line of the failing run, and no less often for a line of the baseline
    (there, toContain passed on the bug);
  • a line one side never shows keeps not.toContain / toContain, and so does a finding stored without counts, so
    those tests are generated byte for byte as before;
  • counts enter the generated file only as whole numbers (the evidence can come from a state file).

For the shop's finding the test now ends with

const shows = (line: string) => (snap.text ?? []).filter((l: string) => l === line).length;
expect(shows("Reading lamp"), "the page shows this line elsewhere too: 1 time with responses in request order, 2 in the failing order").toBeLessThanOrEqual(1);
expect(snap.text, "the page does not show what only the failing order showed").not.toContain("Real wood desk");

The title and the report (second commit)

For the same reason the finding and the explore report said something untrue: it shows "Reading lamp", which the baseline does not, and "Reading lamp" under "page text only in this run", while the baseline shows that line once.

  • nameDifference() (the finding's title and the report's RACE line) names a line the other side never shows before
    a line both sides show. The shop's finding now reads under "seed 2" it shows "Real wood desk", which the baseline does not. When every differing line is on both pages it says the counts: it shows "Reading lamp" 2 times, 1 in the baseline.
  • The report's lists and genclass_explain's evidence add the counts to such a line:
    page text only in this run: "Reading lamp" (2 times in this run, 1 in the baseline), "Real wood desk".
  • A diff or finding kept without counts reads as before.

Only packages/mcp/ and two paragraphs of docs/runtime/AGENT.md (5.1 the report, 5.3 the generator) changed. No
new dependency, no model-visible text, nothing in the runtime.

Checks

  • npm run typecheck -w @genclass/mcp && npm run build -w @genclass/mcp && (cd packages/mcp && npx vitest run): green,
    343 tests.

  • New unit tests in packages/mcp/test/testgen.test.ts ("a race test counts a page line the page shows elsewhere
    too"). They build the shop's finding through the store and run the generated assertions on page lines: on the fixed
    page (the card still there) they pass, on the failing order's page they fail. Two of the three fail on main
    (expected 'fails' to be 'passes' for the fixed page; expected 'passes' to be 'fails' for the reverse direction).

  • New tests for the wording in test/compare.test.ts (the name) and test/mcp.test.ts (the report and
    genclass_explain through the tools); both fail on the first commit.

  • The real flow, once, in headless Chrome, on a copy of the rehearsal's shop (the walkthrough's shop with
    @genclass/runtime 0.3.0-beta.11 from npm) and this branch's built server: explore (2 baselines, 3 seeded orders)
    → RACE 2 of 3 → genclass_explain → the test, run with npx playwright test. The same finding also went through
    main's generator for comparison.

    this branch's test main's test
    broken shop failed (Expected: <= 1, Received: 2 on "Reading lamp") failed
    fixed shop (answers to older queries dropped) passed failed (not.toContain("Reading lamp"))

    On the fixed shop genclass_replay says "not reproduced", and a new explore finds no race.

  • The steps of packages/mcp/test/e2e/race.e2e.mjs (both packages built): ok, with testOnBuggy: failed,
    testOnFixed: passed, exploreFixed: no race. Its generated assertions are the same as before (its page shows no
    result line anywhere else).

Not run, and why

  • race.e2e.mjs as committed: Playwright's own Chromium is not installed on this machine, so I ran a scratch copy
    that differs only in launching the installed Chrome (channel: "chrome") and closing its browser while the spec
    runs. The mcp.yml workflow runs the committed script in Chromium on this pull request.
  • The runtime's vitest steps, the install suite, the model suites: nothing outside packages/mcp/ and one doc
    paragraph changed.

Left for the owner

  • No version bump and no tag: a release (mcp-v*) is the owner's call. The changelog entries are under "Unreleased".

🤖 Generated with Claude Code

MeharPro and others added 2 commits December 3, 2026 20:49
…here too

genclass_explain wrote a Playwright test that could not go green. On the Tiny
Shop (docs/evidence/e2e-walkthrough/app) typing "react" fast lets an older
/api/search answer land last, and explore reports it: under seed 2 the page
shows "Reading lamp" and "Real wood desk". Explore compares page lines as
counts: the shop always lists a product card "Reading lamp", so that line is
there once with responses in request order and twice in the failing order
(the finding's evidence says so: textCounts 1 and 2). The generator ignored
the counts and wrote `expect(snap.text).not.toContain("Reading lamp")`, which
the card alone fails, so the test stayed red after the fix.

testgen.ts now reads textCounts, as the replay verdict already does: a line
both orders show is asserted by how many times the page shows it (no more
often than with responses in request order; for a line the failing order
showed less often, no less often, where presence passed on the bug). A line
one side never shows, and a finding stored without counts, keep the presence
assertion, so those tests are generated byte for byte as before. Counts enter
the file only as whole numbers.

Tests: the shop's case through the store (the generated assertions run on the
fixed page's lines and on the failing order's), the reverse direction, and
counts from a state file.

No version bump: a release is the owner's call.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…e it shows

The finding from the Tiny Shop read `it shows "Reading lamp", which the
baseline does not`, and the report listed "Reading lamp" under "page text only
in this run", while the baseline shows that line once (the product card): page
lines are compared as counts, 1 in request order and 2 in the failing order.

- nameDifference() (the finding's title and the report's RACE line) names a
  line the other side never shows before a line both sides show, so the shop's
  finding says `it shows "Real wood desk", which the baseline does not`; when
  every line is on both pages it says the counts: `it shows "Reading lamp"
  2 times, 1 in the baseline`.
- The report's lists and genclass_explain's evidence add the counts to such a
  line: `"Reading lamp" (2 times in this run, 1 in the baseline)`.
- compare.ts onBothSides() reads textCounts for the title, the report and the
  test generator (whole numbers only); the generated message says "1 time".

A diff or finding kept without counts reads as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@MeharPro MeharPro changed the title MCP: a race's regression test counts a page line the page shows elsewhere too (it stayed red after the fix) MCP: a race's regression test and report count a page line the page shows elsewhere too (the test stayed red after the fix) Dec 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant