Repository navigation
Publish the extension host API: services, ui and testing entries, version policy - #3409
Conversation
Pragmatic Code Review: PR #3409 (closes #3315)Review Type: Initial Review Scope reviewed: Verification I re-ran:
Requirements CheckSurface
Checks that must fail when they should
Everything else unchanged
Deviations listed in the PR body: all 8 are sound.
Code Review Findings🟡 Important1. The entry list is maintained by hand. Any other file in
🟢 Suggestions2. The hand-written parser has a silent-drop path that its own doc says it does not have. The TypeScript compiler API would be smaller and exact.
3. A type change with only a minor bump is accepted, and the docs read as if it were enforced.
4.
5. Nit: the index entry's runtime export list is now asserted in two places. Every future addition must update both this hard-coded list and the surface snapshot. That test's job is to check that the alias resolves and exposes the registration API. Checked and fine (no action)
Recommendation: REQUEST CHANGESThe work is solid and well tested, and the PR is unusually candid about its gaps. The one should-fix is finding 1: the check that makes every API change deliberate does not see a new file in the aliased directory. The fix is about 5 lines. Findings 2 and 3 are at minimum doc corrections, because both docs currently over-state what the tooling guarantees. Findings 4 and 5 are optional. 🤖 Automated pragmatic-code-review (Claude Code) |
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: REQUEST CHANGES (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
Address review (round 1)All five findings addressed in 93d138b. 🟡 1. A new file in the host API directory escaped the snapshot: fixed.
🟢 2. The hand parser could silently drop declarations: fixed with the TypeScript syntax tree, as suggested.
🟢 3. Docs implied type changes were held to major: reworded.
🟢 4.
Nit 5. Duplicate runtime list: fixed. Also found while re-verifying. Three synthetic Snapshot. Re-recorded fresh at 1.0. The entries are identical; Verification: extension-api suite 41/41; Re-Review DecisionDecision: RE-REVIEW NEEDED Rationale: The parsing layer was rewritten on the TypeScript compiler API, and both the hash scope and how entries are found changed. These are non-trivial logic changes to the checks themselves. |
Pragmatic Code Review: PR #3409 (closes #3315)Review Type: Re-Review Scope: only the new commit Previous Review Summary
Verification I re-ran at
|
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review): APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
Address review (round 2)The re-review came back APPROVE with two optional nits. Both are addressed in 8a13d30. Nit A.
Nit B. Merged interfaces hashed only their last block: fixed.
No interface in the API uses merging today, so the recorded snapshot is unchanged. Verification: extension-api suite 43/43; Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: Two small, local changes to test helpers, each with its own test and mutation check. Production code is unchanged, the snapshot is unchanged, and the reviewer had already approved the logic around them. |
…sion policy (closes #3315) @nodespace/extension-api gains ExtensionLifecycle and read-through facades: databases (getters over databaseStore's state plus create, switchTo and refreshDatabaseSettings), nodes (getNode, fetchNode, createNode), collections.reload and schemas.reload, and re-exports of onDaemonReconnect, createLogger, toError, isCommandError, CommandError, DatabaseInfo and DATABASE_SETTINGS_NODE_ID. Its module doc holds the compatibility policy. New /ui (Button, Badge, Input, Card parts, Dialog namespace, focusTrap) and /testing (mockTauriCore, testing-library helpers) entries. extension-api-surface.test.ts records each entry's export names and a hash of the API's type declarations at 1.0, and fails on export *, an unversioned change, a removal with only a minor bump, a version regression, or a bump that was not re-recorded. extension-api-boundary.test.ts keeps core modules off the host API, the host API off edition-specific modules, test code behind /testing, and the fixture extension on the host API. The fixture now takes its types from the barrel. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ve entries from the directory - source-scan.ts parses with ts.createSourceFile: export lists from export declarations and modifiers, declaration text from the printer without comments, import specifiers from import/export declarations, import() calls and import types. A regex literal can no longer hide a declaration or an import. - Every .ts file in src/lib/extension-api is an entry, so a new one is recorded or fails like any other surface change. - The types hash covers the host API's own declarations and the registry declarations the API reaches, so a host-only type no longer demands a bump. - Docs say what the check enforces: a bump for any change, a major one for a removal or rename; major vs minor for a changed type is review's call. - Synthetic surfaceProblems cases use fixed versions, not the live one. - The build test no longer duplicates the snapshot's export list. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…k of a merged interface Co-Authored-By: Claude Opus 5.5 <[email protected]>
8a13d30 to
44baca1
Compare
Closes #3315
Summary
Completes the host API that extension code imports from core (ADR-082 §2.6, §7), at
EXTENSION_API_VERSION1.0, with a recorded surface snapshot and a boundary guard.@nodespace/extension-api(src/lib/extension-api/index.ts)EXTENSION_API_VERSIONand the registry types, now includingExtensionLifecycle.databases(ExtensionDatabases): read-through gettersactiveDatabaseId,activeDatabase,list,erroroverdatabaseStore's$state, so they are reactive inside a derivation. Methodscreate(name, path?),switchTo(id)andrefreshDatabaseSettings()delegate. TheDatabaseInfotype is re-exported.nodes:getNode(id)(reactivesharedNodeStoreread; documented as not pinning),fetchNode(id)andcreateNode(input)(viabackendAdapter).collections.reload()andschemas.reload(), overcollectionsData.loadCollections()andschemasData.loadSchemas().onDaemonReconnect,createLogger,toError,isCommandError,CommandError, and the provisionalDATABASE_SETTINGS_NODE_ID.@nodespace/extension-api/ui:Button,Badge,Input,Cardand its six parts,Dialogas a namespace,focusTrap.@nodespace/extension-api/testing:mockTauriCore, plusrender,screen,fireEvent,waitForandcleanupfrom@testing-library/svelte. The module doc says it is test-only, and that the rune mocks and setup files come from core'svitest.config.ts.Checks
extension-api-surface.test.ts+extension-api-surface.json: the export lists of every entry (every.tsfile insrc/lib/extension-api/, since the alias makes each one importable) and a SHA-256 over the API's type declarations, recorded at 1.0. Sources are read through the TypeScript syntax tree (typescriptis already a devDependency). It fails onexport *, on a surface change without a version change, on a removal or rename with only a minor bump, on a version that went backwards, and on a bump that was not re-recorded (it prints the command). Re-record:UPDATE_EXTENSION_API_SURFACE=1 bun run --cwd packages/desktop-app test src/tests/extension-api. Re-recording refuses a missing bump and a minor bump for a removal. Whether a changed type needs major or minor is review's call: the hash records only that a declaration changed.extension-api-boundary.test.ts: no.ts/.svelteundersrc/lib(outside the host API) orsrc/routesimports the host API by either alias or by a relative path; the host API imports no edition-specific module (needles built from fragments); only/testingreaches test code; the fixture extension reaches core only through the host API.src/tests/fixtures/test-extension/) now imports its types only from@nodespace/extension-api, so svelte-check fails on an incompatible type change.Docs: one line in
src/lib/plugins/index.ts; one sentence inCLAUDE.md.Deviations from the issue (and why)
extension-api-facades.svelte.test.ts, not.test.ts. Reactivity is checked inside a real$effect.root/$derived, which needs the Svelte compiler; core compiles runes only in*.svelte.test.ts.plugins/ui-extensions.tsandsrc/lib/extension-api/*.ts". The hash instead covers:src/lib/extension-api/*.ts, exported or not. The issue lists the entries' exports exactly, so thenodes,collectionsandschemasfacades are typed by non-exported interfaces (ExtensionNodes,ExtensionReloadable). Hashing only exported ones would letnodes.createNodebe retyped silently;Keyed<C>, which only hosts use, is excluded, so changing it doesn't demand a bump (policy: "none: anything not reachable through the API").Not hashed (gap, by the issue's scope): types re-exported from other core modules (
DatabaseInfo,CommandError, andNode/CreateNodeInputbehindnodes), plus value signatures and component props. In particular, Move Pro-owned data out of core's data model (ADR-083) #3345's planned removal of the two binding fields fromDatabaseInfowill not trip the snapshot; under the policy that is a major change, so review has to apply it. Pulling re-exported declarations into the hash is a small extension ofapiTypeDeclarations()if wanted later.Dialogmembers are recorded asDialog.<member>in theuientry list, so removing a dialog part is caught too, not only the namespace name.SettingsSlotContributionForandCollectionTreeRootsContribution(added by Add settings-section and database settings-slot extension points #3312/Add the collectionTreeRoots extension point to the sidebar collection tree #3314, after the issue's list was written).nodes.createNodetakesCreateNodeInput, not the adapter's widerCreateNodeInput | Node.shared-node-store-pin-guard.test.tsscans every non-test file forsharedNodeStore.getNode(, solib/extension-api/index.tsgets aREACHABLE_WITHOUT_PINentry with its reason: a pass-through read whose doc says it does not pin; the settings singleton it exists for is pinned centrally byrefreshDatabaseSettings(), which core runs on every load and switch.nodespace-extensions-plugin.test.tspinned the barrel's runtime keys to['EXTENSION_API_VERSION']. The list now lives only in the surface snapshot; the build test checks that the alias resolves to the registry'sEXTENSION_API_VERSION, andExtensionLifecyclewas added to its type-equality checks.Pro-boundary ratchet
bun run scripts/check-pro-boundary.tsexits 0. Delta is 0 for every marker: the new files have no hits, and--changedlists only four pre-existing lines inshared-node-store-pin-guard.test.ts, none added here. BASELINES unchanged.Tests
New:
extension-api-surface.test.ts(27),extension-api-facades.svelte.test.ts(7),extension-api-boundary.test.ts(9). Updated:nodespace-extensions-plugin.test.ts,shared-node-store-pin-guard.test.ts.Mutation checks (each applied alone, target test run, file restored; all 26 fail as expected):
index.ts, no bumpindex: extra, asks for a bump)Contributioninui-extensions.ts, no bumpreload()facade type changed, no bumptoErrorrenamed + minor bump onlyexport *inui.tssrc/lib/extension-api/extra.tsexportingfoo, no bumpadded extra: foo)Keyedmust be excluded)/\/*$/regex literal)import()ignored by the import scan.sveltefile parsed instead of its<script>blocks.tsfile in the host API directory accepted$lib/extension-api../extension-api/uiindex.tsimports the membership storeui.tsimports./testing$lib/plugins/ui-extensionsdatabases.createdropspathdatabases.errorgetter returns a stale valuedatabases.activeDatabaseread wrapped inuntracknodes.getNoderead wrapped inuntrackschemas.reloadcalls the collections loadernodes.fetchNodereads the cache instead of the daemonAlso checked by hand: with a change and no bump,
UPDATE_EXTENSION_API_SURFACE=1fails and leaves the snapshot untouched; with a minor bump, it re-records and a normal run then passes.Verification
bun run test:changed(frontend tier): passed — frontend 311 files / 5649 tests (baseline 308 / 5606), Chromium browser tier passedbun run --cwd packages/desktop-app test src/tests/extension-api: 43 passedbun run --cwd packages/desktop-app test:free-users: 9 passedbun run --cwd packages/desktop-app quality:fix: eslint clean, design tokens clean, svelte-check 0 errors / 0 warningsbun run scripts/check-pro-boundary.ts: exit 0🤖 Generated with Claude Code