Skip to content

validateSpace and validateFile derive the judge and rule filter - #201

Merged
mindsocket merged 4 commits into
mainfrom
refactor/validate-derives-judge
Nov 4, 2026
Merged

mindsocket merged 4 commits into
mainfrom
refactor/validate-derives-judge

Conversation

@mindsocket

Copy link
Copy Markdown
Owner

Library callers had to reproduce the CLI's flag-to-judge step (judgeForRun, parseRuleFilter) to get what sctx validate --semantic --rule-filter does. Those internal helpers did the work in the command; now validateSpace, validateFile and validateResolvedFile take semantic?: boolean | string and ruleFilter?: string[] (the CLI's values) and build the judge and parsed filter themselves, before reading the space so a bad provider config fails early.

Breaking (pre-1.0): the judge and parsed ruleFilter options are gone from the public options. api.ts does not grow.

Tests that supply their own FakeJudgeProvider call validateNodes and validateResolvedFileWith (exported from validate.ts, not api.ts) through tests/helpers/validate-run.ts.

Motivated by the map-views export command, which should pass validation options through faithfully (map-views#22).

…lter

semantic and ruleFilter (the CLI's values) are now options of validateSpace,
validateFile and validateResolvedFile; the judge and parsed filter are built
inside. Library callers no longer reproduce the CLI's flag-to-judge step.

Tests that need their own FakeJudgeProvider use validateNodes and
validateResolvedFileWith through tests/helpers/validate-run.ts.
@claude

claude Bot commented Nov 4, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

JudgeConfigError becomes SctxError with code E_MODEL_PROVIDER_INVALID, so the
CLI's top-level handler reports it like other configuration errors and the
validate-specific wrapper goes. SctxError and SctxErrorCode are exported from
structured-context/api so library callers can recognise these failures.
Comment thread src/api.ts
export { loadConfig, resolveConfigPath, resolveSchema, resolveSchemaPath, setConfigPath } from './config';
export { addSpace } from './config/write';
export { LOCAL_CONFIG_FILE, PLUGIN_PREFIX } from './constants';
export { SctxError, type SctxErrorCode } from './errors';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds SctxError and SctxErrorCode to the public API, which breaks a rule in CLAUDE.md: "Do not add exports to src/api.ts ... without the maintainer's explicit agreement on that specific surface... If a change seems to need a new export, stop and propose it, with the consumer that needs it." The PR description also says "api.ts does not grow", which this line contradicts.

SctxErrorCode is a separate export from SctxError, so agreeing to one doesn't cover the other. Remove this line, or get the maintainer's agreement on it first. Library callers can still detect the new error by checking err.code === 'E_MODEL_PROVIDER_INVALID'.

@mindsocket
mindsocket merged commit 65ebd81 into main Nov 4, 2026
2 checks passed
@mindsocket
mindsocket deleted the refactor/validate-derives-judge branch November 4, 2026 12:48
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