Skip to content

refactor!: let domains bring their own flags, and their own words - #32

Merged
osolmaz merged 1 commit into
mainfrom
refactor/lean-core
Oct 28, 2026
Merged

osolmaz merged 1 commit into
mainfrom
refactor/lean-core

Conversation

@osolmaz

@osolmaz osolmaz commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Summary

switch's run and replay still 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.

  • Domain flags. HarnessDomain gets flags, a list such as { flag: "--judge <file>", description }. commandLine adds every domain's flags to run and replay, and setup gets the values of its own flags by name. --definition and DefinitionError go. The Definition record in run.json stays.
  • Examples. legal-judge declares --judge <file> in legalJudgeDomain, in setup.ts. Chess declares none, and chessSetup() takes nothing.
  • Word lists. Each example has a domain-words.txt, one word a line. tests/no-domain.test.ts reads 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 matched sans-serif.
  • Docs. The README, 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.
  • A new test: a domain's flags appear on run and replay once each, and setup gets the values of its own flags and nothing else.
  • legal-judge run --help lists --judge <file>, and chess run --help has no definition flag.

Risks

A command line or script that passes --definition to legal-judge must pass --judge now.

  • A domain flag must take a value. A flag without one gives setup no value.

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.
@osolmaz
osolmaz merged commit 1a079d3 into main Oct 28, 2026
1 check passed
@osolmaz
osolmaz deleted the refactor/lean-core branch October 28, 2026 07:11
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