Repository navigation
feat: add the wikirace example, the race from TypeSafe's Jev demo - #36
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
src/wiki.tsreads 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.src/race.tskeeps 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..gitignorelets these three public pairs of titles in, as it does chess's cases.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.Risks
The example depends on Wikipedia's live HTML and API.