feat(plan): describe a compiled plan as JSON - #46
Merged
Conversation
The framework already knows exactly what an extension registers -- that is what compiling declarations before running them is for -- but an `ApplicationPlan` holds factories, handlers and token objects, so the answer was locked inside it. `describePlan` projects it: module ids, service tokens and the edges between them, command ids and titles, settings keys and defaults, storage versions, watcher globs, view ids. Nothing callable and nothing opaque crosses the boundary, so the result is safe to stringify, commit and diff. It is deterministic and in declaration order, which is what makes a diff mean something: a change in the file is a change in what the extension registers. That is the review question `git diff` on a large module rarely answers directly, and it is the same document a manifest cross-check or a dependency diagram needs. Ownership is recovered by identity rather than by field, because settings, storage, secrets and UI items carry no module id of their own: the plan's flat lists hold the very objects the modules hold. The tokens the Application registers itself are now named once, in `FRAMEWORK_SERVICES`, because preflight and this projection need the same list -- preflight so a module injecting `Notifications` is not reported as depending on nothing, and the description so a reader of the graph can tell which tokens need no declaration. Secret keys appear; a declared key is metadata the extension's own source states in the clear, and a value does not exist at plan time. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Aug 29, 2026
Merged
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.
Summary
The framework knows exactly what an extension registers — compiling declarations before running them is the whole design — but that knowledge was locked inside an
ApplicationPlan, which holds factories, handlers and token objects and cannot be printed, diffed or serialized.describePlan(plan)projects it to JSON:Module ids and host requirements, service tokens with their lifetimes and dependency edges, command ids and titles, settings keys and defaults, storage versions and migrations, watcher globs, view ids, raw registration ids — and nothing callable.
Why it is worth having
git diffon a large module shows that a file changed; this shows that the extension now registers a command it did not, or that a service gained a dependency. The output is deterministic and in declaration order, so committing it makes topology changes visible next to code changes.package.jsoncross-check needs (ids, types, defaults, scopes) and what a dependency diagram needs (tokens and edges).defineModulecall.Boundaries
Notes
The tokens the Application registers itself are now named once as
FRAMEWORK_SERVICES, because preflight and this projection need the same list — preflight so a module injectingNotificationsis not reported as depending on nothing, and the description so a reader of the graph can tell which tokens need no declaration.Ownership is recovered by object identity rather than by reading a field: settings, storage, secrets and UI items carry no module id of their own, and the plan's flat lists hold the very objects the modules hold.
Verification
Additive; no existing type or signature changes.
npm run quality(1056 tests) andnpm run verify:packagepass.Fourteen new tests cover determinism, JSON round-tripping, the no-functions boundary, every declaration kind, both glob spellings, migration versions sorted independently of declaration order, and module attribution for the declarations that do not name their own module.
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