Repository navigation
refactor!: let domains bring their own flags, and their own words - #32
Merged
Merged
Conversation
run and replay lose --definition <file>, which existed for legal-judge's judge files, and DefinitionError goes with it. A HarnessDomain can declare flags of its own, which both commands take, and its setup gets their values by name. legal-judge declares --judge <file>; chess declares none, and its setup takes nothing. Each example lists its words in domain-words.txt. The word test reads every example's list in place of a list of its own, and fails when an example has none, so a new example is covered.
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
switch's
runandreplaystill had a--definition <file>flag that existed only for legal-judge's judge files, and the word check that keeps domains out of switch had its own fixed list of words.This change lets each domain bring its own command-line flags, so switch's commands name no domain's input, and lets each example list its own words, so a new example is checked too.
Both points come from the earlier review of switch's code, which called them out and which #30 and #31 left open.
What Changed
switch's commands now take only their own flags, plus the flags that each domain declares.
The word check reads its words from the examples.
HarnessDomaingetsflags, a list such as{ flag: "--judge <file>", description }.commandLineadds every domain's flags torunandreplay, andsetupgets the values of its own flags by name.--definitionandDefinitionErrorgo. TheDefinitionrecord inrun.jsonstays.--judge <file>inlegalJudgeDomain, insetup.ts. Chess declares none, andchessSetup()takes nothing.domain-words.txt, one word a line.tests/no-domain.test.tsreads every example's list and fails when an example has none. The lists leave out words that are too common, such as check, square and san, which matchedsans-serif.AGENTS.md, the legal-judge README and the plan describe the flags and the word lists.Testing
I ran every check of switch, the viewer and both examples, and the help of both harnesses.
pnpm check: format, lint, typecheck, coverage, DRY and Slophammer with no findings. 47 tests in switch, 32 in the viewer, 74 in chess and 45 in legal-judge.runandreplayonce each, andsetupgets the values of its own flags and nothing else.legal-judge run --helplists--judge <file>, andchess run --helphas no definition flag.Risks
A command line or script that passes
--definitionto legal-judge must pass--judgenow.setupno value.