Skip to content

Add nodes.updateNode to the host API and resolve subtype viewers through isA - #3622

Merged
mstomar125 merged 3 commits into
mainfrom
issue-3414-updatenode-isa
Oct 5, 2026
Merged

mstomar125 merged 3 commits into
mainfrom
issue-3414-updatenode-isa

Conversation

@mstomar125

@mstomar125 mstomar125 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Part of #3414. Two leftovers from the umbrella's progress comment, both frontend only.

Summary

  • nodes.updateNode(id, changes) on the host API's nodes facade (ADR-082 section 3.6). changes is { content?, properties? } (type ExtensionNodeChanges). It delegates to sharedNodeStore.updateNode, the app's own update path, attributed to a viewer source with id extension-api. getNode shows the change at once and the store saves it in the background. It returns nothing: it does not wait for the save or report a failed one, and a node the store does not hold is left alone and logged.
  • The isA fallback for subtype viewers. pane-content.svelte now resolves the viewer through the type's extends chain (resolveViewerFallback, built on the existing typeChain): the exact type first, then ancestors nearest first, and an exact registration wins. UiExtensionRegistry.viewerTabsFor follows the same chain, and collection-node-viewer.svelte asks for the tabs of the node's real type instead of the literal collection, so a subtype of collection gets its own tabs and then collection's.

Extension API

Minor bump, 2.2 to 2.3: nodes.updateNode and the ExtensionNodeChanges type are new, optional additions to the host API. Nothing is removed or retyped. Changed: EXTENSION_API_VERSION in app-lib/src/extensions/mod.rs and src/lib/plugins/ui-extensions.ts; the pinned fixture test is now extension_api_version_is_two_three; the surface snapshot is re-recorded. scripts/check-extension-api-version.ts passes.

Viewer-tab resolution also changes behaviour for extensions: a tab registered for a type now shows on the viewers of its subtypes. This is additive, so it is covered by the same minor bump.

Tests

  • viewer-node-type.test.ts: parent's viewer for a subtype without one, nearest ancestor, own registration wins, no viewer anywhere.
  • ui-extensions.test.ts: tabs include ancestors', subtype's own first regardless of priority.
  • collection-node-viewer-extensions.test.ts: a board node extending collection shows Contents, its own tab, then collection's.
  • extension-api-facades.svelte.test.ts: updateNode goes through the store with the extension source and a reactive getNode read sees it; an unknown node is left alone.

Mutation-checked, each caught: viewer-tab lookup by exact type only (3 tests fail), ancestors before the subtype (2), reversed chain in the viewer lookup (2), no fallback (2), skipping the type's own viewer (1), updateNode as a no-op (1), wrong update source (1), collection viewer asking for the literal collection (1). Not covered: the one-line wiring of resolveViewerFallback in pane-content.svelte, because that component is not mounted in tests; the function itself is covered.

Documentation

Companion docs PR updates architecture/extension-points.md (removes the two "not built yet" items, documents updateNode, the fallback and 2.3): https://github.com/NodeSpaceAI/nodespace-docs/pull/108

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Review round 1 (pragmatic-code-reviewer, medium depth) — verdict: APPROVE, no blockers

Summary: small, additive change that follows ADR-082 section 3.6 and existing patterns; version bump consistent across the Rust constant, Rust test, TS constant and snapshot.

Suggested improvements

  1. nodes.updateNode narrows to content/properties only at compile time; an untyped extension could pass nodeType, version, etc. Pick the two fields before delegating, with a test.
  2. State that properties merges, so a key cannot be deleted; check the failure-signal wording.
  3. No test that pane-content wires resolveViewerFallback (component not mounted in tests).
  4. hasViewer is non-reactive; say in the comment that a late viewer registration is not picked up.
  5. Transient cold-start flash before schemas load (self-heals).

Nits: single-pass grouping in viewerTabsFor; shared extension-api source id; docs should list ExtensionNodeChanges.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Address-review (round 1)

  • 1 fixed: nodes.updateNode now forwards only content and properties at runtime. New test "passes on only content and properties, whatever an untyped caller sends"; mutation-checked (passing changes through unchanged fails it).
  • 2 fixed: doc and TSDoc say properties merges, so a key cannot be removed. The failure wording stays: the store's generic write-failure handling (metrics plus a write-failure conflict notification) applies to any non-conflict persist failure.
  • 4 fixed: pane-content comment says a late viewer registration is not picked up.
  • 3 not done: pane-content is not mounted in any test in this repo (its tests mirror its logic), and a mount harness is out of scope for this PR. The decision logic is covered by resolveViewerFallback tests; the one-line wiring is not. Noted in the PR body.
  • 5: no code change; the cold-start case self-heals as the reviewer traced (the stale board cache entry is harmless).
  • Nits: ExtensionNodeChanges now listed in the docs PR; single-pass grouping and per-extension attribution left as is (trivial cost; attribution needs an API change).

Re-review not needed: only the runtime pick, a comment, and doc text changed, all covered by the above.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Merge queue: #3622 was taken out of the queue — the merge gate failed on it, on top of main. Reproduce by merging or rebasing origin/main and running bun run test:changed, fix, push, and re-run bun run merge 3622.

✓ src/tests/components/chat-link-navigation.test.ts (3 tests) 0ms
stdout | src/tests/unit/relationship-orientation.test.ts
✅ Core plugins registered in test setup (browser context)
 ✓ src/tests/unit/relationship-orientation.test.ts (3 tests) 0ms
stdout | src/tests/utils/schema-field-label.test.ts
✅ Core plugins registered in test setup (browser context)
 ✓ src/tests/utils/schema-field-label.test.ts (3 tests) 0ms
stdout | src/tests/design/icon-registry.test.ts
✅ Core plugins registered in test setup (browser context)
 ✓ src/tests/design/icon-registry.test.ts (2 tests) 0ms
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯
 FAIL  src/tests/services/shared-node-store-pin-guard.test.ts > SharedNodeStore pin-reachability guard > never reads a node from SharedNodeStore without an in-file pin or a documented reachability exemption
AssertionError: lib/components/viewers/collection-node-viewer.svelte read a SharedNodeStore node without pinning it and without a documented REACHABLE_WITHOUT_PIN exemption in this test file. A node this displays outside its own document's structureTree can be silently evicted while still on screen. Either pin the id(s) it reads with pinReachableNodes(ownerId, ids) (see pin-node-reachability.ts), or — only if it genuinely reads its own tab's node or an id a parent already pinned — add it to REACHABLE_WITHOUT_PIN with the reason.: expected [ Array(1) ] to deeply equal []
- Expected
+ Received
- []
+ [
+   "lib/components/viewers/collection-node-viewer.svelte",
+ ]
 ❯ src/tests/services/shared-node-store-pin-guard.test.ts:172:7
    170|             `own tab's node or an id a parent already pinned — add it …
    171|         : undefined
    172|     ).toEqual([]);
       |       ^
    173|   });
    174| 
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
 Test Files  1 failed | 321 passed (322)
      Tests  1 failed | 5874 passed (5875)
   Start at  15:48:30
   Duration  103.91s (transform 7.61s, setup 9.77s, collect 7.57s, tests 80.67s, environment 183ms, prepare 65ms)
error: script "test" exited with code 1
error: script "test" exited with code 1
[stage exited with code 1]

  full output: /var/folders/3w/y9kj522n1_j9wqmt6vl_sb6r0000gp/T/nodespace-gate-logs/_gate-merge-2026-10-05T13-47-48-266Z/test-frontend-happy-dom.log

✗ test (frontend, Happy-DOM) failed — merge blocked.
  Fix the failure, push, and re-run: bun run merge <PR#>

@mstomar125
mstomar125 force-pushed the issue-3414-updatenode-isa branch from 4125e54 to 2a71483 Compare October 5, 2026 13:55
@mstomar125

Copy link
Copy Markdown
Contributor Author

Merge-gate fix (head 2a714838, rebased on main 0597f3df)

The gate's frontend stage failed on shared-node-store-pin-guard.test.ts. collection-node-viewer.svelte read its node's type from SharedNodeStore without pinning it.

Fix: the tabs now derive from the collection the viewer already loads (collection?.nodeType, through $derived.by so TypeScript doesn't narrow it to null). The SharedNodeStore import is gone. The subtype tab test stubs collectionService.getCollectionByName with a board node instead of seeding the store.

Checks

  • Pin guard and the viewer tests: pass.
  • Mutation: hard-coding 'collection' fails the subtype tab test.
  • quality:fix: 0 errors.
  • Full frontend suite: 322 files and 5875 tests pass.
  • Push check: passes.

No re-review is needed: the change is mechanical, reading the same value from the viewer's own loaded node.

🤖 Generated with Claude Code

mstomar125 and others added 3 commits October 5, 2026 16:00
…ugh isA

The nodes facade of the host API gains updateNode, which ADR-082 §3.6 lists,
delegating to the shared node store's update path. Viewer and viewer-tab
resolution fall back through a type's extends chain, nearest first, so a
subtype opens in its parent's viewer with its tabs; an exact registration
still wins. The extension API goes from 2.2 to 2.3.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
An untyped extension could pass nodeType or version through the compile-time
only narrowing; the facade now forwards content and properties alone. The
pane-content comment says a late viewer registration is not picked up.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The viewer read its node's type from SharedNodeStore without pinning it,
which the pin-reachability guard rejects. The collection it already loads
carries the real node type, so the tabs derive from that instead. The
subtype tab test now stubs the collection service with a subtype node.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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