Skip to content

feat(preflight): report each problem as data, with a stable code - #47

Merged
kkdev92 merged 1 commit into
mainfrom
feat/preflight-problems-4.1.0
Aug 29, 2026
Merged

feat(preflight): report each problem as data, with a stable code#47
kkdev92 merged 1 commit into
mainfrom
feat/preflight-problems-4.1.0

Conversation

@kkdev92

@kkdev92 kkdev92 commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Summary

Preflight throws before VS Code is touched and reports every problem it found. Until now it reported them as sentences only, so a test asserting "this plan has a captive dependency" matched prose, and a script reading the error had nothing to branch on.

PreflightError.problems now carries each finding as data:

try {
  defineExtension({ name: 'Sample', modules });
} catch (error) {
  if (error instanceof PreflightError) {
    for (const problem of error.problems) {
      // { code: 'SERVICE_CAPTIVE_DEPENDENCY', subject: 'projects.repository',
      //   moduleId: 'projects', path: ['projects.repository', 'core.clock'], message: '…' }
    }
  }
}

What was being lost

The information existed and was dropped at the throw. The service-graph validator reports a code, the token it is about and the dependency path it walked; runtime preflight reports a code and the module. Both were reduced to message on the way out. compileApplication's own checks — duplicate ids, a handler conflict, a hosted service with no lifecycle, syncable on a workspace-scoped key — were built as sentences from the start.

Each check now produces a PreflightProblem with a stable code. The graph validator's codes join the same vocabulary (SERVICE_DUPLICATE, SERVICE_MISSING_DEPENDENCY, SERVICE_CIRCULAR_DEPENDENCY, SERVICE_CAPTIVE_DEPENDENCY) so a reader of problems sees one. The full list is on compileApplication's documentation; the runtime codes are on RuntimeIssue.

Compatibility

Additive. issues remains the list of messages in the same order, and the error's own message is the same text as before, so nothing changes for anyone reading the console or matching on message.

PreflightError is now exported from the root. It is the error consumers already receive; exporting it means instanceof instead of comparing error.name.

Two JSDoc examples that showed the old constructor were updated with it.

Verification

npm run quality (1043 tests) and npm run verify:package pass. New assertions pin the code, subject and module of every finding kind, the dependency path on a graph problem, the runtime code surviving activation failure, and issues equalling problems reduced to messages.

A published extension built on this package was run against this build with its own sources untouched: type-check, lint and 271 tests pass.

🤖 Generated with Claude Code

`PreflightError` carried its findings as a list of sentences. A test that
wanted to assert "this plan has a captive dependency" had to match prose, and
a script reading the error had nothing to branch on. The information was there
and being thrown away: the service-graph validator reports a code, a token and
the dependency path, and runtime preflight reports a code and a module -- both
were reduced to their messages at the throw.

`problems` keeps them: `{ code, message, subject, moduleId, path }` for every
finding, in the order found. `compileApplication` names each of its own checks
the same way -- `COMMAND_HANDLER_CONFLICT`, `STORAGE_SYNCABLE_WORKSPACE`,
`HOSTED_SERVICE_EMPTY` and so on -- and the graph validator's codes join that
vocabulary rather than keeping their own. `issues` is unchanged as the list of
messages, and the error's own message is the same text as before.

`PreflightError` is exported from the root. It is the error a consumer already
receives from `defineExtension` at import time and from `activate` when the
host fails a requirement; exporting it means `instanceof` instead of comparing
`name`.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kkdev92
kkdev92 force-pushed the feat/preflight-problems-4.1.0 branch from 2b6e038 to 5d12e21 Compare August 29, 2026 14:01
@kkdev92
kkdev92 merged commit 3538c9e into main Aug 29, 2026
10 checks passed
@kkdev92 kkdev92 mentioned this pull request Aug 29, 2026
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