Repository navigation
fix(spaces): report the config only, not a per-space audit - #192
Merged
Merged
Conversation
sctx spaces ran a per-space audit that assumed every path is a local file, so a space whose path is a URL turned the SessionStart hooks off for the whole config. spaces now loads the config once and reports config-level problems only. checkConfig becomes inspectConfig, which no longer looks at spaces. Hooks no longer treat a validate run that produced no output (for example a schema that fails to load) as clean: validateSpace throws, so the hook reports it once as E_HOOK_FAILED.
Open
mindsocket
marked this pull request as ready for review
October 27, 2026 13:24
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
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.
Problem
A space whose
pathis a URL (a parser plugin that reads remote pages) switched the Claude CodeSessionStarthooks off for the whole config, withE_SPACE_PATH_MISSING.sctx spaces --jsonon a config with one URL-path space returnedE_SPACE_PATH_MISSINGas its only problem (src/config/health.ts:81ranexistsSync(space.path)for every space), and preflight treats anyerrorproblem as "hooks inactive" (plugin/scripts/preflight.ts:61).sctx spaceswas the only caller ofcheckConfig, so a listing command also ran a per-space audit, and loaded the config twice in text mode (once incheckConfig, once inlistSpaces).Change
sctx spacesloads the config once and reports config-level problems only (E_CONFIG_NOT_FOUND,E_CONFIG_INVALID,E_INCLUDE_NOT_FOUND). It no longer checks a space's path or schema: whatpathmeans belongs to the plugin that reads it, and a schema is checked when it is loaded.--jsonkeeps its shape, so the plugin's preflight is unchanged. Exit 1 only on an error-severity config problem.checkConfigbecomesinspectConfig(internal, not exported fromapi.ts) and returns the loaded config alongside the report.E_NO_SPACESis no longer reported; preflight already says nothing for zero spaces.validateSpacethrows whensctx validateproduced no output (for example a schema that fails to load) instead of treating the space as clean. The hook's existing wrapper reports it once per session asE_HOOK_FAILEDwith the first stderr line.Why the hook change: the startup schema check used to catch a broken schema before any hook ran.
sctx validate <space> --jsonwith an unparsable schema exits 1 with empty stdout and oneE_SCHEMA_INVALIDline on stderr, andvalidateSpacereturned{}for empty stdout, i.e. "clean".Without the change, dropping the startup check would have made that failure silent.
Not in this PR
sctx doctorthat audits spaces and schemas, delegating to the schema loader and to plugins for path validity (see Addsctx doctor#176).sctx spaces addstill requires a space path to exist (src/config/write.ts), which has the same file-path assumption.Tests
tests/config/health.test.ts: config-level reports; URL, missing-path, missing-schema and bad-schema spaces produce no problems.tests/commands/spaces-config-only.test.ts: the CLI lists those spaces with exit 0 and still exits 1 on an invalid config.hook-test/unit/preflight.test.ts: a URL-path space does not switch hooks off; a schema that does not load makes the prompt hook fail with the reason and records no baseline.tscandbiomeclean.