Skip to content

fix(spaces): report the config only, not a per-space audit - #192

Merged
mindsocket merged 1 commit into
mainfrom
fix/spaces-config-only
Oct 27, 2026
Merged

mindsocket merged 1 commit into
mainfrom
fix/spaces-config-only

Conversation

@mindsocket

Copy link
Copy Markdown
Owner

Problem

A space whose path is a URL (a parser plugin that reads remote pages) switched the Claude Code SessionStart hooks off for the whole config, with E_SPACE_PATH_MISSING.

  • measured: sctx spaces --json on a config with one URL-path space returned E_SPACE_PATH_MISSING as its only problem (src/config/health.ts:81 ran existsSync(space.path) for every space), and preflight treats any error problem as "hooks inactive" (plugin/scripts/preflight.ts:61).
  • sctx spaces was the only caller of checkConfig, so a listing command also ran a per-space audit, and loaded the config twice in text mode (once in checkConfig, once in listSpaces).

Change

  • sctx spaces loads 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: what path means belongs to the plugin that reads it, and a schema is checked when it is loaded. --json keeps its shape, so the plugin's preflight is unchanged. Exit 1 only on an error-severity config problem.
  • checkConfig becomes inspectConfig (internal, not exported from api.ts) and returns the loaded config alongside the report. E_NO_SPACES is no longer reported; preflight already says nothing for zero spaces.
  • Hooks: validateSpace throws when sctx validate produced 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 as E_HOOK_FAILED with the first stderr line.

Why the hook change: the startup schema check used to catch a broken schema before any hook ran.

  • measured: sctx validate <space> --json with an unparsable schema exits 1 with empty stdout and one E_SCHEMA_INVALID line on stderr, and validateSpace returned {} for empty stdout, i.e. "clean".

Without the change, dropping the startup check would have made that failure silent.

Not in this PR

  • A sctx doctor that audits spaces and schemas, delegating to the schema loader and to plugins for path validity (see Add sctx doctor #176).
  • sctx spaces add still 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.
  • Full suite: 940 pass, 15 skip, 0 fail; tsc and biome clean.

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.
@mindsocket mindsocket mentioned this pull request Oct 27, 2026
@mindsocket
mindsocket marked this pull request as ready for review October 27, 2026 13:24
@claude

claude Bot commented Oct 27, 2026

Copy link
Copy Markdown

Code review

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

@mindsocket
mindsocket merged commit 99bc1ac into main Oct 27, 2026
3 checks passed
@mindsocket
mindsocket deleted the fix/spaces-config-only branch October 27, 2026 13:26
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