Skip to content

Add the virtual:nodespace-extensions build entry and the extension-api alias - #3395

Merged
mstomar125 merged 4 commits into
mainfrom
issue-3311-extensions-build-entry
Sep 30, 2026
Merged

mstomar125 merged 4 commits into
mainfrom
issue-3311-extensions-build-entry

Conversation

@mstomar125

@mstomar125 mstomar125 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3311

What

A build can now inject extensions without core importing them (ADR-082 §2.1).

  • virtual:nodespace-extensions default-exports [] in core. With NODESPACE_EXTENSIONS=<module path> set it re-exports that module's default export instead. Unset, nothing changes.
  • src/routes/+layout.svelte imports it and calls registerExtensions(extensions) at the top of the script body, so contributions exist before AppShell renders.
  • The injected entry is supported in every tool that reads it: Tailwind scans its directory, Vite's dev server may serve it (server.fs.allow), Vitest picks up its *.test.ts files under core's setup, and svelte / @tauri-apps/api resolve from core's node_modules (resolve.dedupe).
  • @nodespace/extension-api is an alias for src/lib/extension-api/ (new; it re-exports the extension and contribution types, including the settings-section and settings-slot types, and EXTENSION_API_VERSION; the rest is a later issue). kit.alias covers SvelteKit and svelte-check; the unit and e2e Vitest tiers get a direct alias because they do not use sveltekit().
  • Core's release workflow now fails both Tauri build jobs, before the build, when NODESPACE_EXTENSIONS is present.

The transitional import './pro-plugin' is untouched.

Files

  • New: vite-plugins/nodespace-extensions-entry.js (env parsing + glob helpers), vite-plugins/nodespace-extensions.js (the plugin), src/lib/extension-api/index.ts, src/tests/build/{nodespace-extensions-plugin,virtual-extensions-module}.test.ts, src/tests/fixtures/sample-extension-entry.ts, scripts/release-workflow-extensions-guard.test.ts.
  • Wired: vite.config.js, svelte.config.js, tailwind.config.js, vitest.{config,browser,webkit,e2e}.config.ts, src/vite-env.d.ts, src/routes/+layout.svelte, .github/workflows/release.yml, CLAUDE.md (one sentence), .gitignore.
  • scripts/check-pro-boundary.ts is not touched.

ui-extensions.ts is not touched; the barrel re-exports what already exists there.

Deviations from the issue

  • extensionTestGlobs(entry) takes no root, and it escapes glob syntax in the directory (ext (1) would otherwise be read as a pattern and find no tests). extensionContentGlobs deliberately does not: Tailwind 3 escapes the base directory itself and turns a backslash escape into a path separator, so escaping there makes it match nothing (verified both ways with a directory named oot (1), against the real Vitest scanner and a real build). The issue left absolute-vs-root-relative to the acceptance check; an absolute glob works under Vitest 3.2.7 (recorded below), so a root parameter would be dead.
  • resolveExtensionsEntry also rejects a directory, not only a missing path (statSync().isFile()): a directory would resolve to its index in Vite but make dirname(entry) the parent, so Tailwind and Vitest would scan the wrong tree.
  • The Vite-server test passes hmr: false, watch: null and logLevel: 'silent' so a server per test never binds the HMR socket or leaks a watcher.
  • .gitignore: the root build/ rule hid the mandated src/tests/build/ directory, so that directory is un-ignored (the app's real build/ output stays ignored).
  • The guard test parses release.yml with Bun.YAML.parse (no new dependency). Besides the structural asserts in the issue, it extracts the guard's script and runs it under bash with the variable set, empty and unset, and asserts no other step's script mentions the variable.
  • The dev-server check ran vite dev on a private port with the same variable rather than the full dev:tauri (which needs the Tauri shell and a sidecar build on a shared machine); the vite config, plugin and layout are the same code path. See below.

Ratchet

bun run scripts/check-pro-boundary.ts exits 0 and --changed reports 0 hits in every file this PR touches. This PR adds and removes no marker and does not edit BASELINES (the ratchet's notices about counts below their ceilings come from other merged changes; the issue's "BASELINES equal the printed counts" criterion is intentionally not applied, per the standing rule that ceilings are tightened elsewhere).

Verification (acceptance criteria)

Resolution

  • Unset: bun run --cwd packages/desktop-app build succeeds, no "injecting" line, virtual module is export default []; (checked on the dev server too).
  • NODESPACE_EXTENSIONS=src/tests/fixtures/sample-extension-entry.ts ... build succeeds; the fixture's sample-extension id is in the emitted chunk.
  • NODESPACE_EXTENSIONS=does-not-exist.ts ... build exits 1: NODESPACE_EXTENSIONS does not name an existing file: <abs>/packages/desktop-app/does-not-exist.ts.

Out-of-tree entry (temporary directory outside the repo; index.ts imports a type from @nodespace/extension-api, imports svelte and @tauri-apps/api/core, and lazily loads oot.svelte, which uses $state and the class w-[1337px] that core does not use)

  • Build: succeeds; .w-\[1337px\]{width:1337px} is in build/_app/immutable/assets/0.*.css.
  • Tests: NODESPACE_EXTENSIONS=<tmp>/index.ts bunx vitest run <tmp> runs <tmp>/sample.test.ts under core's config (2 passed): it resolves @nodespace/extension-api and @tauri-apps/api/core and mounts a $state component. Without the variable: "No test files found".
  • Dev server: vite dev with the same variable serves /@fs/<tmp>/index.ts and /@fs/<tmp>/oot.svelte (HTTP 200) while /@fs/etc/hosts stays 403; driven in Chromium, the app shell renders the injected component in app-shell-overlay, clicking it goes oot 0 -> oot 1, and its computed width is 1337px (Tailwind reached the out-of-tree file in dev too). Without the variable the same page has no injected element and the virtual module is export default [];. The console errors in both runs are only the missing daemon (ERR_CONNECTION_REFUSED).

Checks

  • svelte-check: 0 errors, 2453 files; it resolves virtual:nodespace-extensions and @nodespace/extension-api.
  • quality:fix (desktop-app) and quality:scripts:fix clean.
  • bun run test:changed passes on the final tree: skill installer tsc, frontend (Happy-DOM), scripts, skill, browser and rust:test (release.yml is an unrecognized path for the gate scope, so it reaches every tier).

Tests and mutation results

Each new test was mutated by reverting or breaking the behavior it guards; every mutation below failed the named test.

src/tests/build/nodespace-extensions-plugin.test.ts (26) and virtual-extensions-module.test.ts (3):

  • dedupe removed / @tauri-apps/api dropped: the config test and the out-of-tree Vite-server test fail.
  • fs.allow without the workspace root / without the entry directory / also set for an in-root entry: the three config tests fail.
  • resolveId claiming every id / without the NUL prefix, load not checking the id / unquoted / not normalized / export * instead of default / wrong empty value: the resolveId and load tests (and the server tests) fail.
  • configResolved logging every time / logging without an entry, enforce: 'pre' removed: fail.
  • entry: a missing path not throwing, error omitting the variable, error omitting the path, blank not null, relative path not resolved against the root, a directory accepted, empty content globs, wrong test glob: fail.
  • kit.alias removed, unit-tier alias removed, layout call removed, layout call moved inside onMount, barrel changed to export *: fail.
  • each character removed from the glob-escape class (( ) [ ] { } * ? ! + @ | and backslash), the test glob left unescaped, the content glob escaped: fail (the last one also drops the class from a real build with a directory named oot (1)).
  • a settings or contribution type dropped from the barrel: the compile-time type-equality test fails svelte-check.

scripts/release-workflow-extensions-guard.test.ts (10): guard removed from either job, continue-on-error added to the guard, guard exiting 0, guard testing a different variable, guard using -n (misses an empty value), guard moved after the build, shell: bash removed, an if: added, the variable set at workflow / job / step level, and a step exporting it through GITHUB_ENV: each fails.

Config wiring (not unit-testable, mutated against the out-of-tree probes): dropping the Tailwind globs removes the class from the built CSS; dropping extensionTestGlobs from include gives "No test files found"; dropping the entry directory from fs.allow turns the dev-server request into 403; removing the plugin or the alias from the e2e config makes a probe import fail to resolve (probe removed); removing the vite-env.d.ts declaration or kit.alias makes svelte-check fail.

Notes for the reviewer

  • The ambient declaration in vite-env.d.ts type-imports @nodespace/extension-api, so it only resolves after svelte-kit sync writes kit.alias into the generated tsconfig (the sync step of build and the postinstall do that).
  • injecting extensions from ... prints once per Vite config resolve, and SvelteKit resolves the config several times per build, so it can appear more than once in a build log.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Pragmatic code review (initial)

Review Type: Initial Review (no prior reviews or comments on this PR; whole diff origin/main...HEAD, one commit e095d3b6)

Summary

Clean, tightly scoped implementation of the ADR-082 §2.1 seam. With NODESPACE_EXTENSIONS unset every wiring is inert: the plugin contributes only resolve.dedupe (no fs.allow), the globs are [], and the virtual module is export default [];. The plugin and helpers are small, the JSDoc/comments explain the "why", the twin browser/webkit configs stay in lockstep, and the tests are mutation-minded. Nothing blocks merge. Two low-severity suggestions below, both verified.

Checks I ran (read-only, NODESPACE_EXTENSIONS unset):

  • bun run --cwd packages/desktop-app test src/tests/build: 2 files, 25 tests passed.
  • bun test scripts/release-workflow-extensions-guard.test.ts: 10 passed.
  • bun run scripts/check-pro-boundary.ts: exit 0, "Every Pro-boundary count equals its baseline" (cloudSyncHooks 0/0, proWording 280/280, all others equal).
  • bun run scripts/check-pro-boundary.ts --changed: 0 hits in every marker for the changed files.
  • Grep of the added lines: no #NNNN issue references, no console.*, no lint suppression, no any, no Pro/tenant/Supabase/nodespace-sync wording added.
  • git check-ignore: src/tests/build/ is no longer ignored; the app's packages/desktop-app/build/ output and any nested build/ still are.
  • I did not run the Rust or full build/browser tiers (shared machine); I am relying on the PR's recorded build, out-of-tree and dev-server results for those.

Requirements Check (issue #3311)

Scope

  • ✅ 1. Entry helpers (nodespace-extensions-entry.js): plain ESM, only node:fs/node:path; blank -> null, relative resolves against root, absolute kept, missing throws naming the variable and absolute path. 📝 Deviations are sound: extensionTestGlobs(entry) has no root (I confirmed absolute globs match under tinyglobby and fast-glob from a different cwd); a directory is also rejected (correct, dirname(entry) would otherwise be the parent).
  • ✅ 2. Plugin (nodespace-extensions.js): name, enforce: 'pre', config() always dedupes svelte and @tauri-apps/api, fs.allow = [searchForWorkspaceRoot(root), dirname(entry)] only when the entry is outside root (isOutside handles .., ..\, and cross-drive absolute relative() results), resolveId claims only the exact id with a NUL prefix, load gives export default []; or a JSON-quoted normalizePath(entry) re-export, configResolved logs once per plugin instance through config.logger.info.
  • ✅ 3. Wiring: vite.config.js, svelte.config.js (kit.alias), tailwind.config.js (content globs appended after core's), vitest.config.ts (plugin after injectRuneMocks(), direct alias, test.include extended), browser/webkit (plugin added, include unchanged, blocks identical so the lockstep-twin rule holds), e2e (plugin + alias). vite-env.d.ts declaration with doc comment. Unset behaviour unchanged in all five.
  • ✅ 4. src/lib/extension-api/index.ts: explicit export list, no export *, module doc as specified.
  • ✅ 5. +layout.svelte: static import after the CSS imports, registerExtensions(extensions) at the top of the script body, before let isInitialized, with the timing comment. registerExtensions never throws and treats the identical object as a no-op, so the transitional double registration is safe.
  • ✅ 6. Release guard: step present before "Build Tauri app" in both build-tauri-macos-arm and build-tauri, shell: bash, no if, printenv semantics (set-but-empty also fails). No other job in release.yml builds the frontend (build-pkg-macos consumes artifacts, build-headless builds the daemon/CLI). Guard test present and behavioural (extracts the script and runs it under bash -eo pipefail with set/empty/unset).
  • ✅ 7. CLAUDE.md: one sentence added, as specified. 📝 There is no "frontend section", so it landed under "Component Architecture"; fine.
  • ✅ 8. Ratchet: BASELINES equals the printed counts. 📝 cloudSyncHooks 4 -> 0 and proWording 281 -> 280 are legitimate tightenings: this PR adds and removes no marker (--changed shows 0 hits), so main already sat at those counts.

Acceptance criteria

  • ✅ Unset: virtual module is export default [];; build success and "app unchanged" rest on the PR's recorded run (config-level analysis agrees).
  • ✅ Fixture entry builds; ✅ missing path fails naming the variable and the absolute path (unit-tested as well as recorded).
  • ✅ Out-of-tree build / tests / dev server: recorded in the PR body with concrete evidence (.w-\[1337px\] in emitted CSS, <tmp>/sample.test.ts under core's config, /@fs/ 200 vs /etc/hosts 403). Config wiring for these is consistent with what the code does. 📝 Dev-server check used vite dev rather than dev:tauri; acceptable, same config path.
  • ✅ svelte-check resolves both modules (recorded: 0 errors; the ambient declaration relies on kit.alias -> generated tsconfig, which sync writes).
  • ✅ Guard in both jobs and test:scripts passes (confirmed, 10/10).
  • ✅ Boundary ratchet exits 0 with baselines equal to counts (confirmed).
  • 📝 test:changed / quality:fix / boot in dev:tauri: not re-run by me; the PR notes the test:changed result is in a comment.

No contradictions with the issue text beyond the deviations the PR already explains.

Findings

No 🔴 or 🟡 findings.

🟢 Suggestion: glob metacharacters in the entry directory are not escaped (silent miss)

📁 packages/desktop-app/vite-plugins/nodespace-extensions-entry.js:54-68

extensionContentGlobs and extensionTestGlobs interpolate toPosix(dirname(entry)) straight into a glob. A directory containing (, ), [, {, !, etc. is then parsed as glob syntax. I verified with the Vitest 3.2.7 scanner (tinyglobby) and with fast-glob (Tailwind v3) that an entry under .../ext (1)/src/ yields 0 files for **/*.test.ts, while the same tree without the parentheses yields 1. The failure is silent: Tailwind purges the extension's classes and Vitest reports "No test files found". It bites on a checkout path like Program Files (x86), Downloads/foo (1), or a bracketed workspace folder; unlikely in CI, plausible on a dev machine.

Escaping the posix dirname fixes it (verified for both engines):

const escapeGlob = (p) => p.replace(/[()[\]{}*?!+@|\\]/g, '\\$&');
// `${escapeGlob(toPosix(dirname(entry)))}/**/*.test.ts`

Keep it inside this file (plain JS, no imports beyond Node), and extend the scan the entry directory ... test with one path containing (1) so the escape cannot regress. Principle: never interpolate an unescaped filesystem path into a pattern language. Fine to take as a follow-up rather than block on it.

🟢 Suggestion: the guard test can be defeated by continue-on-error, and only detects tauri-action jobs

📁 scripts/release-workflow-extensions-guard.test.ts:45-48, 76-81

  • the guard runs under bash and is never skipped asserts shell and the absence of if, but not continue-on-error. A guard step with continue-on-error: true still "fails" in the behavioural test yet no longer stops the job. Add expect(guard?.["continue-on-error"]).toBeUndefined() (cheap, matches the intent of "never skipped").
  • tauriBuildJobs() selects jobs by uses: tauri-apps/tauri-action@. A future job that builds the GUI with a run: step (bunx tauri build, bun run tauri:build, bun run build) would not be covered; only the hard-coded two-job-names assertion would catch a new tauri-action job. Consider also matching run steps that call tauri build / tauri:build so the guard requirement follows the build, not the action. Optional.

Notes (no action needed)

  • Nit: the barrel test pins Object.keys(api) to exactly ['EXTENSION_API_VERSION'] (nodespace-extensions-plugin.test.ts, "resolves @nodespace/extension-api ..."). That is the intended "explicit list, no export *" pin, but the follow-up that completes the barrel will have to update it; a one-line comment saying so would save that author a moment.
  • For the downstream pin-bump: postinstall runs svelte-kit sync, which loads vite.config.js, so a NODESPACE_EXTENSIONS that is set but points at a file that does not exist yet fails bun install itself (with the clear message). The entry must exist before install, or the variable must be set only for the build step. Consistent with the specified "missing file throws" behaviour, worth remembering when nodespace-sync sets it.
  • fs.allow covers only dirname(entry), per the issue. An extension whose imports reach outside its entry directory will build fine but get 403s in the dev server; that is a consequence of the spec, not a defect here.

Test quality

Good. The new tests fail on regression of the behaviour they name: dedupe, fs.allow (three separate cases including the in-root negative), NUL-prefix and exact-id resolveId, quoted/normalized load, once-only logging, the layout source assertions (the 2-space top-level regex rejects a call nested in onMount), and the real-Vite ssrLoadModule tests (the out-of-tree case only passes because of dedupe, since a temp dir has no node_modules). The guard test's behavioural run makes it robust against the printenv variable being subtly changed. The only cross-platform limit is that Windows backslash normalization cannot be observed on macOS; the test comment says so honestly. Bun.YAML is safe given engines.bun >= 1.3.0 (CI pins 1.3.11).

Recommendation

APPROVE — no blocking issues; the two suggestions are optional follow-ups. Per project workflow, run /address-review next.

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review: APPROVE (posted as a comment - GitHub blocks self-approval). Full findings in the review comment above.

@mstomar125
mstomar125 force-pushed the issue-3311-extensions-build-entry branch 2 times, most recently from e095d3b to 0a7c490 Compare September 30, 2026 12:20
@mstomar125

Copy link
Copy Markdown
Contributor Author

Address review (round 1)

The initial review was APPROVE with two optional suggestions and one nit. Commit eb99cd74 addresses them; 0a7c4909 and the amended first commit carry two coordinator-directed changes (below).

Addressed

  • Glob metacharacters in the entry directory (suggestion). Fixed for the Vitest test glob only, and the suggested fix would have broken the other consumer, so it is not applied to the content glob.
    • extensionTestGlobs now escapes glob syntax in the directory. Checked against the real scanner with a directory literally named oot (1): without the escape "No test files found", with it both probe tests run.
    • extensionContentGlobs stays unescaped on purpose. Tailwind 3 splits a glob into its base directory and the rest, escapes the base itself (fast-glob's escapePath), and runs its base through normalize-path, which turns a backslash escape into a path separator. Replaying Tailwind's own parseCandidateFiles for oot (1): unescaped resolves to .../oot \(1\)/**/*.js and matches all three files; pre-escaped resolves to .../oot /\(1/\)/**/*.js and matches none. A real build confirms it: class present in the emitted CSS unescaped, absent when the content glob is escaped.
    • Tests: one asserts the escaped test glob for /work/ext (1)/[team]/{a,b}/..., one pins the content glob unescaped. Mutations: escaping the content glob fails its test and drops the class from the build; unescaping the test glob fails its test and Vitest finds no tests.
  • continue-on-error on the guard (suggestion). The guard test now asserts the guard step has no continue-on-error (mutation: adding it to the macOS guard fails the test).
  • Barrel pin comment (nit). Added a one-line note to update the runtime-export list when the barrel gains one.

Skipped

  • Detecting build jobs by run: tauri build as well as by tauri-action. The issue scopes the guard to jobs that use tauri-apps/tauri-action, and the hard-coded two-job assertion already fails when a new tauri-action job appears. Revisit if a build job that invokes tauri build directly is ever added.

Acknowledged, no change

  • postinstall runs svelte-kit sync, which loads vite.config.js, so a variable pointing at a missing file fails bun install itself. That is the specified "missing file throws" behaviour; whoever sets the variable must set it after the entry exists or only for the build step.
  • fs.allow covers only the entry's directory, as specified.

Other changes since the review

  • Settings types re-exported (coordinator request, after Add settings-section and database settings-slot extension points #3392 merged): SettingsSectionContribution, SettingsSlot, SettingsSlotContribution and SettingsSlotContributionFor are now in the barrel, with a compile-time test (checked by svelte-check) that every re-exported contribution type equals the host's. Mutations: dropping SettingsSlot or SettingsSlotContributionFor from the barrel fails svelte-check.
  • BASELINES edits dropped (coordinator's standing rule: ceilings are not lowered here). The PR no longer touches scripts/check-pro-boundary.ts; the ratchet exits 0, --changed shows 0 hits, and the notices about counts below their ceilings come from other merged changes.
  • Rebased onto origin/main including Add settings-section and database settings-slot extension points #3392.

bun run test:changed on this state: frontend, scripts, skill and browser tiers pass; Rust tier result below once it finishes.

Re-Review Decision

Decision: RE-REVIEW NEEDED

Rationale: new logic (the glob escape and its Tailwind/Vitest asymmetry) and new type re-exports were added in response to feedback and a coordinator request.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Pragmatic code review (re-review)

Review Type: Re-Review (initial review and the address-review comment exist; scope is 903a8c81 (amended), eb99cd74, 0a7c4909 on top of 9d93d249)

Previous Review Summary

  • Previous actionable recommendations: 4 (glob escape, continue-on-error assertion, detect run: build jobs, barrel-pin comment)
  • Addressed: 3 (glob escape, continue-on-error, barrel comment)
  • Not addressed: 0 (1 deliberately skipped, justified below)
  • New issues found: 0 blocking; 2 optional 🟢 notes

Checks I ran (read-only, NODESPACE_EXTENSIONS unset, no Rust, no full suite):

  • bun run --cwd packages/desktop-app test src/tests/build: 2 files, 28 tests passed.
  • bun test scripts/release-workflow-extensions-guard.test.ts: 10 passed.
  • bun run --cwd packages/desktop-app quality:check (eslint + design tokens + svelte-check): 0 errors, 0 warnings across 2463 files, so the new expectTypeOf block type-checks.
  • git diff origin/main...HEAD -- scripts/check-pro-boundary.ts: empty. bun run scripts/check-pro-boundary.ts: exit 0 ("No count is above its baseline"; five markers below their ceilings, all from other merged changes). --changed: exit 0, 0 hits in every marker.
  • Added lines (776) grepped: no #NNNN references, no Pro/tenant/Supabase/nodespace-sync/cloud wording, no lint suppression, console.* or any.

Previous feedback, item by item

1. Glob metacharacters in the entry directory: ✅ addressed, and the asymmetry is correct.
I verified the Tailwind claim independently in node_modules/tailwindcss 3.4.19 (lib/lib/content.js, util/parseGlob.js) by replaying parseCandidateFiles + fast-glob 3.3.3 against real directories under the scratchpad:

  • parseCandidateFiles runs files.map(normalizePath) on the whole glob first (so a pre-escaped \( becomes /( before anything else), then parseGlob (glob-parent) splits base/rest, then resolveGlobPattern runs normalizePath on the base again and applies fastGlob.escapePath itself. The comment's reason is accurate (and slightly understated: the separator conversion happens before the split).
  • Dir x (1)/src: unescaped glob resolves to .../x \(1\)/src/**/*.js and matches 3/3 files; pre-escaped resolves to .../x /\(1/\)/src/**/*.js and matches 0. Same for Program Files (x86), p (1). So escaping the content glob would have broken the real consumer, exactly as claimed.
  • Vitest 3.2.7 globs include with tinyglobby 0.2.17 (cli-api...js:7193, dot: true, expandDirectories: false, cwd = app dir). Replayed with 25 directory names, raw vs escapeGlob: escaped matched exactly 1 file for every name; raw missed (0) or mis-matched (d!(x) gave 2) for (paren, x (1), Program Files (x86), c{1,2}, e+(x), f@(x), m|x, n\x, o(a|b). So the Vitest side does need the escape, and the regex [()[\]{}*?!+@|\\] covers every case I tried. Since toPosix runs first, no backslash separators reach the escape on Windows; the Windows case itself is not observable here.
  • Doc comments: escapeGlob and the content-glob comment are accurate and explain the "why" (see note 🟢 B for one residual).
  • Tests: extensionTestGlobs escape test pins the exact string for /work/ext (1)/[team]/{a,b}/index.ts, so removing the escape, or dropping any of ( ) [ ] { } from the class, fails it. The content-glob test pins the unescaped string, so adding an escape there fails it. Each half is guarded against regression (string level; see 🟢 A for the gap).

2. continue-on-error on the guard: ✅ addressed. guard?.["continue-on-error"] is asserted undefined (fails for true and false alike), Step gained the field, and the test name was updated. release.yml has no continue-on-error anywhere today.

3. Detect run: tauri build jobs: SKIP is justified. Issue #3311 section 6 scopes the guard to "every job that uses tauri-apps/tauri-action". release.yml has exactly two GUI builds, both via the action (tauriScript: bunx tauri); no workflow has a run: step calling tauri build. The hard-coded ["build-tauri-macos-arm", "build-tauri"] assertion fails closed if a third tauri-action job appears. Revisit only if a direct tauri build job is added, as the author says.

4. Barrel pin comment: ✅ addressed. One-line note above Object.keys(api).

5. Notes (postinstall/svelte-kit sync, fs.allow scope): acknowledged, no change needed.

New changes

Settings re-exports (0a7c4909): ✅ complete and sound.

  • Exported contribution types in ui-extensions.ts: Contribution, ChromeSlot, ChromeContribution, ViewerTabContribution, SettingsSectionContribution, SettingsSlot, SettingsSlotContribution, SettingsSlotContributionFor, NodespaceExtension. The barrel lists all nine plus the EXTENSION_API_VERSION value. Keyed, UiExtensionRegistry, byPriority, uiExtensionRegistry, registerExtensions are host-internal and correctly stay out. Still an explicit list, no export * (and the runtime Object.keys pin would catch a value export *).
  • Type-equality test: I reproduced it outside the worktree with tsc (scratch tsconfig mapping @nodespace/extension-api to a copy of the barrel). Control (real barrel): 0 errors. Mutations: dropping SettingsSlot gives TS2694, dropping SettingsSlotContributionFor gives TS2724, dropping Contribution gives TS2694, and re-declaring ViewerTabContribution with nodeId?: string gives TS2344 from toEqualTypeOf. So a dropped or reshaped export is detected; it is compile-time only and Vitest will not catch it, but quality:check/svelte-check does (I ran it: clean, and src/**/* in the app tsconfig includes src/tests/build).
  • The test covers only the types the barrel re-exports, so a contribution type added to ui-extensions.ts later is not flagged by it. Fine while Publish the extension host API: services, ui and testing entries, version policy #3315 owns completing the barrel.

BASELINES edits dropped: ✅ confirmed (diff empty, ratchet exit 0). Note for the record: issue #3311's acceptance criterion says "BASELINES equal its printed counts"; that criterion is now intentionally not met, per the coordinator's standing rule. The ratchet passes and prints the lowering hint for proCommands 271/275, editionBranching 104/113, cloudBindState 202/203, cloudSyncHooks 0/4, proWording 274/281, none caused by this PR.

Findings

No 🔴 or 🟡 findings.

🟢 A: the escape unit test covers only half of the regex's character class

📁 packages/desktop-app/src/tests/build/nodespace-extensions-plugin.test.ts:107-111

The test string contains ( ) [ ] { } only. Removing * ? ! + @ | \ from the class in escapeGlob would still pass, yet I found the real scanner needs !(, +(, @(, | and \ escaped (d!(x), e+(x), f@(x), m|x, n\x all mis-glob raw). Cheap fix: add those characters to the path in the test, or add one behavioural case that creates ext (1) and d!(x) temp dirs and globs them with the same scanner Vitest uses. Optional; the runtime behaviour is correct today.
Principle: a test of an escaping function should exercise every character the escape claims to handle.

🟢 B: the content-glob comment could name its residual limit

📁 packages/desktop-app/vite-plugins/nodespace-extensions-entry.js:68-71

Leaving the content glob unescaped is right, and it works for the realistic cases (x (1), Program Files (x86)). It is still a silent Tailwind miss for a directory containing a brace list or extglob (c{1,2}, e+(x), f@(x), o(a|b)), an unbalanced (, a backslash, or an apostrophe (j'x), and pre-escaping cannot fix those because normalizePath turns the backslash into a separator (I replayed all of them). This is Tailwind 3's own limitation, not a defect here; a half-sentence saying so would stop a future reader from "fixing" it by escaping, or from assuming full coverage. Optional.

Recommendation

APPROVE - all prior feedback is addressed or justifiably skipped, the Tailwind/Vitest escape asymmetry is verified against the actual library code, the barrel is complete with a type pin that demonstrably catches drops and reshapes, and the boundary ratchet and issue-reference/wording checks are clean. The two notes above are optional.

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review (re-review): APPROVE (posted as a comment - GitHub blocks self-approval). Full findings in the review comment above.

@mstomar125
mstomar125 force-pushed the issue-3311-extensions-build-entry branch from 0a7c490 to 0889497 Compare September 30, 2026 12:27
@mstomar125

Copy link
Copy Markdown
Contributor Author

Address review (round 2, after the re-review)

The re-review was APPROVE with two optional notes. Both taken in 0889497f; both are test-string and comment changes with no logic change.

Addressed

  • Escape test covered half the regex class (suggestion). The test now uses a directory containing ( ) [ ] { } ! + @ | * ?, and a separate test covers a backslash (skipped on Windows, where it is a path separator and toPosix turns it into a slash first). Mutation: removing each of *, ?, !, +, @, | and backslash from the regex class fails its test.
  • Content-glob comment (suggestion). It now says what Tailwind still cannot match (a directory named with brace, extglob or backslash syntax), so nobody "fixes" it by escaping.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: the round-2 changes are a longer test string, one extra test and a comment sentence; the escape function, the wiring and the workflow are unchanged from what the re-review approved.

State at push

mstomar125 and others added 4 commits September 30, 2026 14:36
…i alias

A build can now inject extensions without core importing them. The virtual
module default-exports [] in core; with NODESPACE_EXTENSIONS=<module path> it
re-exports that module's default export instead. The root layout imports it and
calls registerExtensions before AppShell renders.

- vite-plugins/nodespace-extensions-entry.js: resolves the variable to an
  absolute path (throws naming the variable and path when the file is missing)
  and derives the Tailwind content and Vitest include globs from it.
- vite-plugins/nodespace-extensions.js: the Vite plugin. It resolves and loads
  the virtual module, always dedupes svelte and @tauri-apps/api, and for an
  entry outside the app root restates the workspace root in server.fs.allow and
  adds the entry's directory.
- Wired into vite.config.js, tailwind.config.js and all four Vitest configs, so
  an injected entry is built, styled, served in dev and its *.test.ts files run
  under core's setup. The unit and e2e tiers get the @nodespace/extension-api
  alias directly (they do not use sveltekit()); the others get kit.alias.
- src/lib/extension-api/index.ts: the minimal host API barrel, with an explicit
  export list.
- release.yml: both Tauri build jobs fail before the build when
  NODESPACE_EXTENSIONS is present; a bun:test test pins the guard, its
  behaviour, and that nothing in the workflow sets the variable.
- .gitignore: un-ignores src/tests/build/, which the root build/ rule hid.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…not be skipped over

- extensionTestGlobs escapes glob syntax in the entry directory: Vitest's file
  scanner reads an unescaped "ext (1)" as a pattern and finds no tests.
  extensionContentGlobs stays unescaped on purpose, because Tailwind escapes the
  base directory itself and normalizes a backslash escape into a separator.
- The guard test also asserts the guard step has no continue-on-error.
- A comment on the barrel's runtime export pin says to update it when the
  barrel gains one.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The settings-section and database settings-slot types now live in
ui-extensions, so an extension written against @nodespace/extension-api can use
SettingsSectionContribution, SettingsSlot, SettingsSlotContribution and
SettingsSlotContributionFor. A compile-time test (checked by svelte-check) pins
that every contribution type the barrel re-exports is identical to the host's.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The escape test now uses a directory containing every character escapeGlob
handles (a backslash in its own test, skipped on Windows where it is a path
separator), and the content-glob comment says which directory names Tailwind
still cannot match.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@mstomar125
mstomar125 force-pushed the issue-3311-extensions-build-entry branch from 0889497 to d9ee691 Compare September 30, 2026 12:36
@mstomar125
mstomar125 merged commit 399a5d3 into main Sep 30, 2026
@mstomar125
mstomar125 deleted the issue-3311-extensions-build-entry branch September 30, 2026 12:36
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.

Add the virtual:nodespace-extensions build entry and the extension-api import alias

1 participant