Skip to content

feat: add the wikirace example, the race from TypeSafe's Jev demo - #36

Merged
osolmaz merged 1 commit into
mainfrom
feat/wikirace
Oct 28, 2026
Merged

osolmaz merged 1 commit into
mainfrom
feat/wikirace

Conversation

@osolmaz

@osolmaz osolmaz commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Summary

TypeSafe introduced Jev with a WikiRace demo: the model starts at one Wikipedia article and must reach another by following only the links on the pages it visits.
switch now has that race as a third example harness, examples/wikirace, next to chess and rubric-judge.
It reads Wikipedia's API, shows long articles in two stages because Jev takes at most 255 answers per question, and replays a race from its trace without the network.
In a test run Jev reached 2 of 3 targets, for example DNA to Manipuri pony in 6 hops.

What Changed

The example is a package of its own, built like the chess example, with a domain, a viewer part, three cases and tests.
Nothing in switch itself changes.

  • Wikipedia. src/wiki.ts reads an article's HTML from the API, after redirects, and keeps its links to other articles by top-level section. It leaves out files, categories, help pages and the like, disambiguation pages, and the sections that list sources. It names itself with a User-Agent, as Wikipedia asks.
  • The race. src/race.ts keeps the target, the path and the current article's links in the state, so a replay needs no page. The choices are the article's links in its order, without the articles visited before. An article with more than 200 links shows its lead's links and its other sections, and a section opens to its links. The target has no choices, so the race ends there.
  • The view shows the target and its first sentences, the current article, the path, what the step shows and what the last step did. The stop text is "Give up and lose the race": with a softer text Jev used stop as "none of these fits" and gave up at the start.
  • The outcome is reached, gave up or unfinished, with the hops and the path. A viewer part draws the trail of articles toward the target.
  • Cases. Baseball to Sun, DNA to Manipuri Pony, and Rubber duck to Moon. .gitignore lets these three public pairs of titles in, as it does chess's cases.
  • Repository. The README, CI and the Slophammer boundaries list the example.

Testing

I ran every check, and three races with Jev on live Wikipedia.

  • pnpm check: format, lint, typecheck, coverage, DRY and Slophammer with no findings. 68 tests in switch, 35 in the viewer, 74 in chess, 46 in rubric-judge and 18 in wikirace, at 100% of wikirace's lines.
  • The tests use a fake wiki and the fake decider: the HTML reader, the API calls and their errors, the choices of short and long articles, a whole race, a replay that reads no page, the harness, and the viewer part.
  • Jev, three runs of three races: DNA → Animal → Equestrianism → Horse → Pony → List of horse breeds → Manipuri pony, and Rubber duck → NASA → Solar System → Moon. From Baseball, Jev gave up after 4 hops at Human body, whose links lead nowhere near the Sun. Each request held 2,000 to 4,000 input tokens; all the runs together cost under one cent at TypeSafe's published price.
  • I looked at a race's page in headless Chrome.

Risks

The example depends on Wikipedia's live HTML and API.

  • A change to Wikipedia's HTML could change which links the reader finds; the trace keeps what a run saw, so replays stay exact.
  • Races are not repeatable run to run, because articles change.

The model starts at one Wikipedia article and must reach a target article by following only the links on the pages
it visits. The example reads English Wikipedia through its API, keeps each article's links by section in the state,
and shows an article with more than 200 links as its lead's links and its other sections, which open to their links,
since Jev takes at most 255 answers in one question. A replay reads no page.

- `src/wiki.ts` reads an article's links, without files, categories, disambiguation pages and source sections.
- `src/race.ts` has the state machine, the view, which shows the target's first sentences, and the outcome: reached,
  gave up or unfinished, with the hops and the path.
- A viewer part draws the trail of articles toward the target.
- Three cases from TypeSafe's demo and launch: Baseball to Sun, DNA to Manipuri Pony, and Rubber duck to Moon.
- The tests use a fake wiki and the fake decider. The README, CI and the Slophammer boundaries list the example.
@osolmaz
osolmaz merged commit 634a2d9 into main Oct 28, 2026
1 check passed
@osolmaz
osolmaz deleted the feat/wikirace branch October 28, 2026 16:28
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