Skip to content

Classify node types by frontend integration, not core-list membership (closes #1998) - #2013

Merged
malibio merged 5 commits into
mainfrom
issue-1998-frontend-integration-predicate
Aug 17, 2026
Merged

malibio merged 5 commits into
mainfrom
issue-1998-frontend-integration-predicate

Conversation

@malibio

@malibio malibio commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

isCustomSchemaType(nodeType) was defined as !CORE_NODE_TYPES.has(nodeType), but every call site used it to ask a different question: does this type have a dedicated frontend integration, or does it need the generic schema-driven fallback? Those two questions coincided until project was added as a core type with no frontend plugin registration.

While auditing, I found the predicate was already wrong in the other direction: person, document, user and ai-chat are registered plugins that the core list never contained, so they were being classified as custom schema types. And there were 7 call sites, not the 4 the issue lists — base-node-viewer.svelte:796, 1197, 1221 (arrow navigation and two slash-command paths) were also affected.

Approach

Replaced the list-membership proxy with predicates that ask the plugin registry, so they stay correct as types register at runtime:

  • hasInlineNodeComponent / rendersAsEntityRow — does a plugin register an inline node component? Types without one render read-only via the BaseNode fallback, so they get the open-in-other-pane button, are skipped by arrow navigation, and open directly rather than resolving to a parent viewer.
  • needsGenericSchemaForm — no hardcoded schema form registered.

Each call site was audited individually rather than given one shared replacement:

Call site New condition Why
schema-form-loader.svelte.ts:62 unconditional Reaching that branch already establishes "no hardcoded form" — the only thing the fallback depends on. This was the blocking gate; fixing the render gate alone would never have populated a schema for project.
base-node-viewer.svelte:1348 drop the check genericSchema is only populated by the loader's no-hardcoded-form path, so a type with no schema still renders no panel.
base-node-viewer.svelte:796, 1197, 1221 rendersAsEntityRow Arrow nav skips rows with no caret; slash commands open entity types in the other pane.
node-row.svelte:164 rendersAsEntityRow Open button belongs on rows with no inline editor.
navigation-service.ts:172 rendersAsEntityRow Standalone entities open directly; inline primitives walk up.
navigation-service.ts:140 ungated getPlugin is already self-limiting, and a registered core type's display name is as good a title here.

Two additional bugs this exposed

  1. Loader cache starved the panel on revisit. loadForm cached "no type-specific form" per type and returned early, so after resetGenericSchema() on navigation, revisiting such a node left the properties panel empty.
  2. GenericSchemaForm read only flat properties. Core types with backend behavior nest schema fields under properties[nodeType] — verified live: a project node stores properties.project.{status, priority, start_date}. The form would have rendered with empty controls. Reads now mirror the backend's nested-first, flat-fallback order (extracted to schema-field-resolution.ts so it is unit-testable); writes stay flat since NodeService hoists schema-defined fields on write.

Deletion

CORE_NODE_TYPES and isCustomSchemaType are removed. The issue listed keeping CORE_NODE_TYPES as a non-goal, but with every call site migrated its only remaining consumer was its own test — exactly the stale abstraction that caused this bug. Flagging it explicitly since it departs from the stated scope.

Verification

Ran the app and opened a project node with status: active, priority: high, start_date: 2026-03-01:

  • Properties form renders with all four fields — status, priority, start_date, end_date
  • Header reads "3/4 fields"; existing values display as Active, High, 2026-03-01, with end_date correctly showing "Pick a date"
  • The status enum renders all five core values with the current one selected
  • Tab title resolves to "Website Redesign"

The generic-form edit path (PATCH) was verified directly against the API and persists correctly to properties.project.status. One caveat: I could not complete the click-to-edit round trip in the UI, because the test node was created via a raw API call and so was absent from the store's persistedNodeIds, making the store route the edit as an insert (500 duplicate key); the daemon then became unresponsive under LLM model loading before I could redo it via a store-hydrated path. The code path itself is unchanged by this PR and is covered by the PATCH verification above.

Tests: 4456 frontend + 24 browser + full Rust suite pass (baseline 4439; +17 new). bun run quality:fix clean.

🤖 Generated with Claude Code

@malibio

malibio commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Review Addressed — commit 5b4840e3

Thanks for the review — finding #1 was a real data-loss bug, and my justifying comment was flat wrong. I verified both halves against the Rust source before fixing, and then reproduced it live.

🔴 #1 Critical — flat writes silently discarded — FIXED

Both claims confirmed:

  • normalize_flat_properties_to_namespace (crud.rs:1715-1720) returns early when properties[nodeType] is already an object — and the form's spread {...node.properties, [field]: value} always includes that namespace, so the new flat key was never hoisted.
  • flatten_properties_for_api (convert.rs:76-86) returns only the namespace contents when that key holds an object, so the stranded top-level key is dropped on read.

Reproduced against the running daemon. Sending the old payload shape produced exactly the predicted broken state:

"properties": { "project": { "status": "active" },   // unchanged
                "status": "completed" }              // stranded top-level

The edit was persisted and then invisible. Sending the new namespaced payload round-trips correctly (planning → active, read back from the namespace).

Writes now go through a new buildFieldWrite, mirroring resolveFieldValue's precedence — the same approach as task-schema-form.svelte:210-225 that you pointed to. Reads and writes are now symmetric, so the asymmetry is resolved rather than rationalized. Corrected all comments asserting backend hoisting.

Added 6 write-path tests including a round-trip assertion in both shapes — that was the coverage gap that let this through, exactly as you identified.

🟡 #2 person flip — CONFIRMED REAL, INTENDED, PINNED

Your flip matrix was correct. I dug into whether the person change is right: PersonNode wraps BaseNode with an editable content area, so /person is typed into in place. handleCustomEntitySlashCommand's own doc comment says it's for entities that are "read-only inline" — which person isn't. The old pane-navigation was a side effect of the same conflated predicate, and yanking focus mid-keystroke would interrupt typing.

So: intended, and now documented at the call site. I also pinned the classification of all 18 registered types in a single test, so any future registration that flips one has to update the list knowingly rather than silently.

🟡 #3 Unconditional getSchema — FIXED

Added a per-type schema cache including negative entries. Schema definitions are immutable for the session, so schema-less structural types now cost one round trip per session instead of one per navigation. Demoted the expected-failure log from warn to debug. Two tests cover the caching (positive and negative).

🟡 #4 CORE_NODE_TYPES removal — already disclosed

This was called out in the PR description under its own "Deletion" heading before your review. Your independent grep confirming zero remaining references and that reserved-name enforcement lives backend-side (ADR-063) is a useful corroboration — thank you.

⏭️ Skipped

  • Tauri desktop app launches successfully #6 null/undefined sentinel nit — pre-existing (getFieldValue returned undefined for a null node before this PR too), fieldStats handles both, and normalizing means touching every field binding for zero behavior change. Worth doing in a dedicated cleanup, not here.
  • Basic storage integration #5 was confirmatory — no action needed. Agreed the 'task Node' → 'Task Node' expectation change is a genuine improvement, not a masked regression.

Verification gap

You were right that it mattered — it's what hid #1. I closed it at the payload level: the exact shape buildFieldWrite produces was verified round-tripping against the live daemon, and the old shape was verified producing the stranded-key state.

I could not complete a UI click round trip: the daemon is the user's real instance and became unresponsive under LLM model loading (children-tree timed out) partway through. The payload-level verification covers the same failure mode, but flagging the residual gap rather than claiming a full UI pass.

Tests

4464 passing (+8 from review fixes). bun run test:all green, quality:fix clean. Test nodes created during verification were deleted.

malibio and others added 3 commits August 17, 2026 12:26
…closes #1998)

isCustomSchemaType(nodeType) was defined as !CORE_NODE_TYPES.has(nodeType) but
every call site used it to ask a different question: "does this type have a
dedicated frontend integration, or does it need the generic schema-driven
fallback?" Those coincided until `project` was added as a core type with no
frontend plugin registration, and they were already wrong in the other
direction for `person`, `document`, `user` and `ai-chat` — registered plugins
that the core list never contained.

Replace the list-membership proxy with predicates that ask the plugin registry,
so they stay correct as types are registered at runtime:

- `hasInlineNodeComponent` / `rendersAsEntityRow` — does a plugin register an
  inline node component? Types without one render read-only via the BaseNode
  fallback, so they get the open-in-other-pane button, are skipped by arrow
  navigation, and open directly rather than resolving to a parent viewer.
- `needsGenericSchemaForm` — no hardcoded schema form registered.

Call sites audited individually rather than given one shared replacement:

- schema-form-loader: the generic-schema fetch is now unconditional inside the
  no-hardcoded-form branch — reaching it already establishes the only condition
  the fallback depends on. This was the blocking gate; fixing the render gate
  alone would not have populated a schema for `project`.
- base-node-viewer render gate: drops the redundant type check — genericSchema
  is only populated by the loader's no-hardcoded-form path, so a type with no
  schema still renders no panel.
- base-node-viewer arrow-nav + slash-command paths: `rendersAsEntityRow`.
- node-row open button, navigation-service routing: `rendersAsEntityRow`.
- navigation-service display name: ungated — getPlugin is already self-limiting
  and a registered core type's display name is as good a title here.

Also fixes two bugs this exposed:

- The loader cached "no type-specific form" per type and returned early, so
  revisiting such a node after resetGenericSchema() left the panel empty.
- GenericSchemaForm read only flat properties, but core types with backend
  behavior nest schema fields under properties[nodeType] (properties.project.*).
  Reads now mirror the backend's nested-first, flat-fallback order; writes stay
  flat since NodeService hoists schema-defined fields on write.

CORE_NODE_TYPES and isCustomSchemaType are deleted — with every call site
migrated, their only remaining consumer was their own test, which is exactly the
stale abstraction that caused this bug.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The reviewer was right and my justifying comment was wrong. I verified both
halves against the Rust source:

- `normalize_flat_properties_to_namespace` (crud.rs:1715-1720) returns early
  when `properties[nodeType]` is already an object — and the form's spread
  `{...node.properties, [field]: value}` always includes that namespace, so the
  new flat key was never hoisted.
- `flatten_properties_for_api` (convert.rs:76-86) returns only the namespace
  contents when that key holds an object, so the stranded top-level key is
  dropped on read.

Reproduced live against the daemon. The old payload produced exactly the
predicted state — `{"project":{"status":"active"},"status":"completed"}` — with
the edit stranded top-level and the namespace unchanged. The namespaced payload
round-trips correctly.

Writes now go through `buildFieldWrite`, which mirrors `resolveFieldValue`'s
precedence (same approach as task-schema-form.svelte:210-225). Corrected the
comments that asserted backend hoisting. Added 6 write-path tests, including a
round-trip assertion in both shapes — the coverage gap that let this through.

Confirmed real and intended. PersonNode wraps BaseNode with an editable content
area, so `/person` is typed into in place; the old pane-navigation was a side
effect of the same conflated predicate, and handleCustomEntitySlashCommand's own
doc says it is for entities that are "read-only inline". Documented at the call
site and pinned the full classification of all 18 registered types in a test, so
any future registration that flips one has to update it knowingly.

Added a per-type schema cache including negative entries, so schema-less
structural types cost one round trip per session rather than one per navigation,
and demoted the expected-failure log from warn to debug.

- #6 null/undefined sentinel nit — pre-existing, `fieldStats` handles both, and
  normalizing means touching every field binding for no behavior change.
- #5 was confirmatory (the changed 'task Node' → 'Task Node' expectations are a
  genuine improvement, not a masked regression); no action needed.

Tests: 4464 passing (+8). quality:fix clean.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
getEnumValues moved from GenericSchemaForm into SchemaFieldLeaf on main, so
the EnumValue type import this branch carried no longer has a use here.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@malibio
malibio force-pushed the issue-1998-frontend-integration-predicate branch from 5b4840e to f17967e Compare August 17, 2026 10:38
@malibio

malibio commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto current main (df27df29) — was ~100 commits behind and showing CONFLICTING; now MERGEABLE/CLEAN.

Four conflicts, all in import blocks, from #2011 (the #2005 fix) landing computeHeaderDisplayValue in node-type-predicates.ts while this branch was replacing isCustomSchemaType. Both sides were wanted, so all four resolved as unions keeping main's addition alongside the new predicates. The substance of the change — node-type-predicates.ts and schema-form-loader.svelte.ts — auto-merged without conflict.

Two things needed a real decision rather than a mechanical resolution:

  1. schema-form-loader.svelte.ts's hasTitleTemplate doc comment described the old world twice over: it cited isCustomSchemaType (deleted here) and asserted genericSchema never loads for core types — which is precisely what this PR changes. Rewrote it to say the quiet part directly: the getter is no longer scoped to custom types, and it stays false for core types only because none ships a title_template yet. That keeps the frontend/backend compute_title() assumption documented in one place, which the original comment (and Tab title and query views show stale cached title instead of current content #2012) both flag as important.

  2. An orphaned EnumValue import in generic-schema-form.svelte (f17967ea). The branch used it for a local getEnumValues helper; main moved that logic into SchemaFieldLeaf (Render and edit nested object/array schema properties (#2009) #2028/Edit nested object/array properties in the namespaced property forms (#2027) #2031), so the import had no remaining use. Verified the enum handling still exists at schema-field-leaf.svelte:53 before removing — this is a dead import, not a dropped feature.

Verification: full frontend suite green (212 files / 4683 tests), quality:fix clean, and the pre-push gate passed end-to-end including Rust and e2e. The four test files covering this change (node-type-predicates, schema-field-resolution, schema-form-loader, navigation-service) pass at 74/74.

Note quality:fix reformats src-tauri/src/commands/nodes.rs (unrelated to this PR, cargo fmt --all behavior) — reverted so the diff stays scoped.

@malibio

malibio commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review — PR #2013

Review Type: Initial Review

Summary

This is a genuinely good change and a net positive. It replaces a hand-maintained CORE_NODE_TYPES list — used as a proxy for "has a frontend integration", which it never actually was — with registry-backed predicates that ask the question the UI actually needs answered. The root-cause framing is correct, and the classification test that pins all 18 registered types (node-type-predicates.test.ts:52-80) is exactly the right way to make a UX-affecting predicate change safe to touch later.

The PR's headline claims were verified against the code rather than taken on trust, including reading the Rust write path end to end. Two hold up; the third is right in its conclusion but wrong in its stated reason — see Finding 2.

  1. The predicate was wrong in both directions — confirmed. person and task register a node component; user, document, collection, ai-chat do not. person was in neither the old core list nor treated as inline-editable, yet person-node.svelte wraps BaseNode with editable content — so the old code gave it an "open in other pane" button and skipped it in arrow navigation. That was a real bug; the flip is correct.
  2. 7 call sites, not 4 — confirmed.
  3. buildFieldWrite's namespaced branch is necessary — confirmed, and it matches the task-schema-form.svelte:235 precedent. But the mechanism documented in the code is not what actually happens; the branch is load-bearing for a different reason, which matters because the comment will mislead the next maintainer.

The rebase was also clean: grep for isCustomSchemaType/CORE_NODE_TYPES across desktop-app and design-system returns zero surviving references, and the rewritten hasTitleTemplate comment now accurately describes the new model. Both rebase judgment calls were correct.


Requirements Check

# Criterion Status
1 project shows generic form with all four fields ✅ needsGenericSchemaForm('project') → true; loader fetches schema
2 Existing values display, not empty controls ✅ resolveFieldValue reads properties.project.*
3 Editing persists via generic-form update path ✅ Verified against the Rust write path; correct in both shapes (documented reason is wrong — Finding 2)
4 loadGenericSchema called for project ✅ Tested, schema-form-loader.svelte.test.ts:44-52
5 project child rows show "open in other pane" ✅ rendersAsEntityRow('project') → true
6 Tab/header titles + routing audited at both nav call sites ⚠️ Both audited and each changed deliberately, but generateTabTitle has a side effect — Finding 1
7 Existing core types unaffected at all call sites ⚠️ Mostly; person's flip is a deliberate fix, but title fallback regresses several types
8 Type with no schema fields renders no form shell ✅ Double-guarded: genericSchema stays null on fetch failure, and generic-schema-form.svelte:135 guards schema.fields.length > 0
9 No new test failures ✅ 4683 tests passing
10 Passes quality:fix ✅

Findings

🟡 Important 1 — Removing the type gate on the tab-title fallback regresses titles for core types

📁 packages/desktop-app/src/lib/services/navigation-service.ts:139-145

The old code consulted pluginRegistry.getPlugin(...).name only for custom schema types, where plugin names are user-authored entity names ("Customer", "Venue"). Removing that gate means every registered core type now falls back to its plugin name — but core plugin names are internal, developer-facing strings:

text  → 'Text Node'      header → 'Header Node'
table → 'Table'          horizontal-line → 'Horizontal Line'

So an untitled text node's tab now reads "Text Node" instead of "text Node". The PR's own test churn is the tell: navigation-service.test.ts:255 and :273 both had to change from 'task Node' to 'Task Node'. Those assertions were updated to match new behavior, not because the old behavior was wrong.

The justification in the comment — "a registered core type's display name is as good a title here as a user-defined one's" — is the part to push back on. It is not equivalent: user-defined plugin names are entity nouns chosen by the user; core plugin names are registry labels with "Node" baked in, which is why you get the stutter.

This is also unrelated to #1998: project registers no plugin at all, so getPlugin('project') returns null and this branch never fires for it. The gate removal does nothing for the stated goal while changing titles for text, header, task, and table.

Recommendation: revert this hunk, or re-gate it so it applies to entity-style types only:

if (rendersAsEntityRow(node.nodeType)) {
  const plugin = pluginRegistry.getPlugin(node.nodeType);
  if (plugin?.name) return plugin.name;
}

Engineering principle: Minimize blast radius — a refactor should not silently change user-visible behavior outside its stated scope. When a test assertion must be edited to accommodate a refactor, that is a signal to re-examine whether the change was intended.


🟡 Important 2 — The doc comment's causal explanation is wrong; the spread it describes is the actual constraint

📁 packages/desktop-app/src/lib/components/schema/schema-field-resolution.ts:39-45, 52-60

The comment asserts:

the backend's hoisting step returns early when properties[nodeType] is already an object, so the flat key is stored as a top-level sibling

The early return is real (crud.rs:1713-1718) — but it is evaluated against the incoming update payload, not the stored node. Stored properties are only touched afterward, via deep_merge_namespaced_properties (crud.rs:1670-1694). A bare flat write into an already-namespaced node works correctly:

existing = {"project":{"status":"active"}},  payload = {"status":"done"}
  normalize(payload) → {"project":{"status":"done"}}   // no early return: payload has no "project" key
  deep_merge         → {"project":{"status":"done"}}   // edit lands

The predicted breakage only occurs because buildFieldWrite spreads the node's entire existing properties map into the payload (lines 52, 58). That spread reintroduces the project key, which is what trips the early return:

payload = {"project":{"status":"active"}, "status":"done"}
  normalize  → returned as-is (early return fires on the payload)
  deep_merge → {"project":{"status":"active"}, "status":"done"}   // edit shadowed

So the code is correct as written, but self-consistently: the namespaced branch is required because of the spread, not because namespaced nodes reject flat writes. Someone "simplifying" the spread away would find the branch inexplicable — and someone trusting the comment would protect the wrong invariant.

Two related premises in the same block are also inaccurate:

  • "user-defined schema types store fields flat" is false. create_node namespaces every type except schema (crud.rs:153-159). User-defined types get properties[<uuid>][field] too. resolveFieldValue's nested-first order handles this correctly by accident, so no live bug — but the flat branch of buildFieldWrite is effectively dead for anything created through NodeService.
  • person reads nested-only, with no flat fallback (behaviors/mod.rs:2237-2246), unlike project (:818-822) and task (:681). Worth knowing before anyone generalizes the "nested-first, flat-fallback" rule.

Recommendation: keep the behavior; fix the explanation. Either (a) drop the spread and send only the changed field, deleting both branches — cleanest, and removes the shadowing hazard at its source; or (b) keep the spread and correct the comment to say the payload spread is what necessitates re-nesting. Also correct the "user-defined types are flat" premise.

Engineering principle: Comments must explain the real "why". A comment that misattributes a constraint to a remote component is worse than none — it obstructs the next person's reasoning.


🟡 Important 3 — loadGenericSchema is fire-and-forget with no staleness guard

📁 packages/desktop-app/src/lib/design/components/schema-form-loader.svelte.ts:81, 96, 122-142

loadGenericSchema is async but invoked unawaited at both call sites in loadForm. It writes this.genericSchema after an await, with no check that nodeType is still the type being viewed.

The viewer calls resetGenericSchema() then loadForm(node.nodeType) on every navigation (base-node-viewer.svelte:346-347). Navigating A → B while A's fetch is in flight lets A's response land after B's reset. Previously rare — the fetch only ran for UUID types; this PR runs it for every type without a hardcoded form, a large increase in exposure.

The new schemaCache narrows the window but does not close it, and consequences reach past a stale panel: hasTitleTemplate derives from genericSchema and drives readonly on the header input (base-node-viewer.svelte:1345,1353,1358). A stale schema with a titleTemplate would make the wrong page's title field read-only.

Recommendation: guard the assignment with the type it was requested for.

this.pendingType = nodeType;
// ... fetch ...
if (this.pendingType !== nodeType) return; // superseded by a newer navigation
this.genericSchema = schemaNode;

Engineering principle: Async writes to shared state need a recency check. Any await between "decide to load" and "apply result" is a window in which the request can be superseded.


🟢 Suggestion 4 — hasInlineNodeComponent and rendersAsEntityRow are one predicate with two names

📁 node-type-predicates.ts:26-42

rendersAsEntityRow is exactly !hasInlineNodeComponent(nodeType), and only rendersAsEntityRow is used in production; hasInlineNodeComponent is referenced solely by its own tests. Normally a YAGNI flag, but it earns its place as the positive framing that makes the negation readable. Keeping both is defensible — just be aware it is one concept. If you'd rather trim, deleting the unused export costs nothing.


🟢 Suggestion 5 — State the cache's instance scoping precisely

📁 schema-form-loader.svelte.ts:35-40, 117-121

The cache is per SchemaFormLoader instance, which is what makes negative caching safe: a user defining a new type opens it in a viewer with a fresh loader, so it isn't permanently negatively cached. Worth saying explicitly, since "immutable for the session" is a stronger claim than the scoping requires — someone later promoting this to a module singleton for efficiency would silently introduce the permanent-negative-cache bug. The warn → debug downgrade is well-judged now that the fetch fires for every structural type.


🟢 Suggestion 6 — Stale top-level siblings shadow silently (follow-up issue)

A node holding both properties.status and properties.project.status keeps the stale top-level copy forever. project/task reads tolerate it, but cel.rs:184-206 flattens the namespace over top-level keys, so evaluation order decides which wins. Since this PR increases the number of types written through this path, a cleanup pass that drops a top-level key once its namespaced twin exists is worth an issue — not this PR.


Verdict

Recommendation: COMMENT — approve-in-principle, with Findings 1 and 3 addressed before merge, and Finding 2's comment corrected.

The architecture is right and the core diagnosis is accurate; this should not be blocked over the items below.

  • Finding 1 is the one behavior regression: it changes titles for types the issue never touched and does nothing for project. Revert or re-gate.
  • Finding 3 is a latent correctness bug this PR makes materially more reachable, and a stale result can make the header read-only. Small, local fix.
  • Finding 2 is documentation-only — the code is correct, the explanation isn't. Worth fixing while context is fresh.

Everything else — registry-backed predicates, the pinned classification test, the loader cache, the log downgrade — is well-judged work.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator 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: COMMENT — approve-in-principle. Full findings in the review comment above. Findings 1 (tab-title regression) and 3 (fire-and-forget schema load) to address before merge; Finding 2 is a doc-comment correction.

Finding 1 (Important) — the plugin-name tab-title fallback was ungated, so
every registered core type fell back to its plugin `name`. Those are registry
labels rather than user-facing nouns, making an untitled text node's tab read
"Text Node". Re-gated to entity rows, where plugin names are entity nouns
worth showing. The two navigation-service assertions changed to 'Task Node'
were reverted to 'task Node' — they had been updated to accommodate the
regression, not because the prior behavior was wrong. This branch never
affected `project` anyway, which registers no plugin.

Finding 3 (Important) — loadGenericSchema is invoked unawaited and wrote
genericSchema with no check that the viewer was still on that type. This PR
runs it for every type lacking a hardcoded form rather than only UUID types,
so a navigate-during-fetch could publish the previous node's schema; because
hasTitleTemplate derives from it, that could leave the wrong page's header
read-only. Added a pendingType recency check around the assignment. The cache
write stays outside the guard — a fetched schema is valid for its own type
regardless of later navigation.

Finding 2 (Important, docs only) — the code was correct but the comment
misattributed why. The backend's normalize step early-returns on the *payload*,
not the stored node, so a bare flat write into a namespaced node merges fine;
it is buildFieldWrite's spread of existing properties that reintroduces the
namespace key and shadows the edit. Also corrected the claim that user-defined
types store fields flat — create_node namespaces every type except `schema` —
and noted `person` reads nested-only, unlike project/task.

Suggestion 5 — documented that schemaCache is per-loader-instance, which is
what makes negative caching safe; hoisting it to a module singleton would be a
behavior change rather than an optimization.

Skipped:
- Suggestion 4 (drop hasInlineNodeComponent): the review itself notes it earns
  its place as the positive framing that makes rendersAsEntityRow readable.
  Removing a tested, coherent export is churn.
- Suggestion 6 (stale top-level sibling cleanup): flagged in the review as
  follow-up issue material, not this PR. Touching the write path here would
  widen scope well past #1998.
- Finding 2 option (a) (drop the spread, delete both branches): cleaner, but a
  live behavior change to the write path justified only by reasoning about Rust
  merge semantics. Not the right risk for a review-response commit on an
  otherwise-ready PR; worth revisiting with a test that exercises the partial
  payload directly.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@malibio

malibio commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

Review addressed — aa53c485

4 of 6 recommendations implemented, 2 skipped. All three 🟡 Important findings addressed.

✅ Addressed

🟡 Finding 1 — tab-title regression (navigation-service.ts:139-147)
Re-gated the plugin-name fallback to rendersAsEntityRow, so it applies only where plugin names are entity nouns. Inline-editable types now land on the <type> Node fallback again rather than the registry label.

The two assertions the review flagged (navigation-service.test.ts:255,273) were reverted from 'Task Node' back to 'task Node', with a comment recording why task takes the fallback. The review's read was right: those had been edited to accommodate the regression rather than because the old behavior was wrong.

🟡 Finding 3 — stale schema publish (schema-form-loader.svelte.ts)
Added a pendingType recency check around the genericSchema assignment. The cache write is deliberately left outside the guard — a fetched schema is valid for its own type no matter where the user navigated in the meantime — and that reasoning is now in the doc comment alongside the read-only-header consequence.

🟡 Finding 2 — doc comment corrected (schema-field-resolution.ts)
Code unchanged; the explanation was wrong. Now states that the backend's normalize step early-returns on the payload rather than the stored node, so a bare flat write into a namespaced node merges correctly — and that it is buildFieldWrite's spread of existing properties that reintroduces the namespace key and shadows the edit. Added an explicit note that dropping the spread is what would make both branches unnecessary, so the next reader doesn't remove the branch and keep the spread.

Both secondary inaccuracies fixed too: the "user-defined types store fields flat" premise (create_node namespaces every type except schema), and person reading nested-only unlike project/task.

🟢 Suggestion 5 — cache scoping
Documented that schemaCache is per-SchemaFormLoader instance, which is what makes negative caching safe, and that hoisting it to a module singleton would be a behavior change rather than an optimization.

⏭️ Skipped

🟢 Suggestion 4 — delete hasInlineNodeComponent. The review itself argues it earns its place as the positive framing that makes rendersAsEntityRow readable. Removing a tested, coherent export is churn for no gain.

🟢 Suggestion 6 — stale top-level sibling cleanup. Flagged in the review as follow-up issue material. Touching the write path here would widen scope well past #1998.

Finding 2, option (a) — drop the spread and delete both branches. Genuinely cleaner and removes the shadowing hazard at its source, but it is a live behavior change to the write path justified only by reasoning about Rust merge semantics. Wrong risk for a review-response commit on an otherwise-ready PR. Worth revisiting behind a test that exercises the partial payload against the real backend.

Verification

  • Full frontend suite: 212 files / 4683 tests passing
  • The four test files for this change: 74/74
  • quality:fix: clean — 2271 files, 0 errors, 0 warnings; tsc --noEmit, cargo fmt, clippy -D warnings all pass
  • Pre-push gate passed end-to-end (frontend + Rust + e2e)

(quality:fix again reformatted the unrelated src-tauri/src/commands/nodes.rs via cargo fmt --all; reverted to keep the diff scoped.)

Finding 4 (Important, new) — the pendingType guard added in the previous
commit only covered navigations that themselves trigger a generic-schema
fetch. `loadForm` skips `loadGenericSchema` entirely for types that ship a
hardcoded form (task, person), so navigating project -> task left the token
naming `project`; a late-resolving project fetch then passed the recency
check and published. The properties panel is shielded by the typed-form branch
winning in the viewer, but hasTitleTemplate is not — it drives the header's
readonly state, which is precisely what the original finding was raised to
prevent. Inert today only because no core type ships a title_template, an
assumption this file already documents as temporary.

Cleared pendingType in resetGenericSchema instead, which is the actual
navigation boundary: the token now tracks where the viewer is rather than what
was last fetched. Also moved its declaration up with the other fields, where
it was orphaned between methods.

Added two regression tests using deferred per-type promises. Verified they
pin the behavior rather than merely passing: with the fix reverted, the
hardcoded-form case fails and the generic-to-generic case still passes,
confirming the second was already covered and the first is what was missing.

Not taken, from the same re-review (both nits, neither blocking):
- The re-gate comment says plugin names are "entity nouns worth showing"; for
  `collection`/`user`/`document` the labels are "Collection Node"/"User
  Reference"/"Document Reference", so the claim is broader than the set it
  admits. The gate is still a strict improvement and a no-op for `project`;
  rewording invites re-litigating naming that predates this PR.
- create_node's namespacing exception list is wider than `schema` alone —
  `task` branches earlier and stores verbatim if its schema fetch fails,
  and database-settings returns before normalization. Worth documenting, but
  it belongs with the stale-sibling cleanup issue rather than expanding a
  comment this PR only touched to correct a causal claim.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@malibio

malibio commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review — PR #2013

Review Type: Re-Review
Base: f17967ea → Head: aa53c485 (1 commit, 4 files, +58/−24)

Previous Review Summary

Count
Previous recommendations 6 (3 🟡 Important, 3 🟢 Suggestion)
Addressed 4 (Findings 1, 2, 3 + Suggestion 5)
Not addressed (deliberately, disclosed) 2 (Suggestions 4, 6) + Finding 2 option (a)
New issues found in the delta 2 (1 🟡 Important, 1 🟢)

All three 🟡 Important findings were addressed, and the two skips are well-reasoned — I agree with both and am not re-raising them. Finding 2 option (a) deferral is also the right call: verification below found the write path has more edge cases than either review knew, which vindicates not touching it in a review-response commit.

Each claim was verified independently rather than accepted from the response summary, including reading the Rust source end to end. Findings 1 and 2 are fully and correctly resolved. Finding 3's guard is real but has a hole the response did not consider.


Requirements Check (delta impact only)

# Criterion Prior Now
6 Nav call sites audited ⚠️ regression ✅ resolved — fallback re-gated, assertions reverted
7 Existing core types unaffected ⚠️ regression ✅ resolved — text/header/task/table back to <type> Node
3 Edit persists via generic form ✅ (wrong reason) ✅ reason now accurate

No criterion regressed. Criteria 6 and 7 moved from ⚠️ to ✅.


Findings

✅ Finding 1 — tab-title regression: correctly fixed

📁 navigation-service.ts:139-147

Checked the gate against every registered plugin rather than trusting the reasoning:

Gate admits (entity rows) plugin name resulting title
project, schema no plugin project Node (branch no-ops)
collection 'Collection Node' "Collection Node"
user 'User Reference' "User Reference"
document 'Document Reference' "Document Reference"
ai-chat 'AI Chat' "AI Chat"

The gate now excludes all 12 inline types, including person ('Person') and task ('Task Node'). The 'task Node' reversion is correct: task registers a node component → rendersAsEntityRow('task') === false → falls to ${nodeType} Node. The tests match real behavior, and the added comments record why, which makes the assertion safe against future churn.

One honest caveat, not a blocker: the gate's stated rationale — "plugin names are entity nouns worth showing as a title" — is only half-true for the set it admits. user and document yield "User Reference"/"Document Reference"; collection yields "Collection Node", carrying the same "Node" stutter the fix was meant to eliminate. The gate is a strict improvement (fixes the four flagged types, no-op for project), so this is worth knowing, not fixing here.


🟡 Important 4 (NEW) — the pendingType guard has a hole: a type with a hardcoded form never updates it

📁 schema-form-loader.svelte.ts:142-155

Every interleaving was traced. The guard handles the cases the response describes:

  • generic → generic: A sets pendingType=A, B sets pendingType=B; A resolves → pendingType !== A → dropped. ✅
  • generic → cache hit: B's early return assigns synchronously and sets pendingType=B first (line 143 precedes the cache check), so a later A resolution is still dropped. ✅ The ordering is load-bearing.

The hole is the third case. pendingType is only ever written inside loadGenericSchema, but loadForm does not call it when a hardcoded form exists (loadForm:93 — needsGenericSchemaForm(B) is false for task and person):

nav A (project): pendingType = 'A', await getSchema('A')
nav B (task):    resetGenericSchema() → genericSchema = null
                 loadForm('task') → hardcoded form branch → loadGenericSchema NEVER called
                 → pendingType is STILL 'A'
A resolves:      pendingType === 'A' === nodeType → genericSchema = schema_A   ← stale publish

The properties panel is protected by luck: the typed-form branch (base-node-viewer.svelte:1367) wins over the genericSchema branch. But hasTitleTemplate is not behind that branch — it feeds readonly, the readonly CSS class, the placeholder (:1345-1356) and computeHeaderDisplayValue (:377). That is exactly the consequence Finding 3 was raised to prevent, still reachable on project → task.

Mitigating: no core type currently ships a title_template (grepped packages/core — only the interpolation util and its tests), so this is latent, not live. Hence Important, not Critical. But the loader's own doc comment already flags "no core template exists yet" as an assumption that will be broken deliberately.

Recommendation — make the field track navigation rather than fetches:

resetGenericSchema(): void {
  this.genericSchema = null;
  this.pendingType = null;   // a fetch in flight for the previous node is now superseded
}

Engineering principle: A recency token must be updated on every event that changes recency, not only on the paths that read it. Guarding one branch while a sibling silently leaves the token stale reintroduces the race it was added to close.


🟢 Suggestion 7 (NEW) — the guard ships with no test

📁 schema-form-loader.svelte.test.ts

Nothing in the test file references the guard. Finding 3 was a race that had to be reasoned about statically, the fix is three lines of ordering-sensitive logic, and nothing pins it — a future refactor moving this.pendingType = nodeType below the cache check silently breaks the cache-hit case with all tests green. A deferred-promise test is cheap.


✅ Finding 3 (partial) — remaining sub-questions answered

📁 schema-form-loader.svelte.ts:142-164

  • No hang/blank-panel regression. The non-isSchemaNode and catch branches set the cache but never assign genericSchema — true before this commit too. resetGenericSchema() already nulled it on navigation, so "no schema" correctly renders nothing. No behavior change.
  • Cache write outside the guard is correct and well-justified — a fetched schema is keyed by its own type and valid regardless of navigation.

✅ Finding 2 — doc comment: now accurate, verified against Rust

📁 schema-field-resolution.ts:3-16, 40-55

This was the failure mode last time — an eloquent but wrong comment — so the Rust source was read independently rather than accepting the rewrite.

  • "person reads nested-only, unlike project/task" — CONFIRMED exactly. person uses bare .get("person").and_then(...) at behaviors/mod.rs:2237, 2246, 2265 with no fallback; task has .or(Some(&node.properties)) at :681; project at :816-820 adds .filter(|v| v.is_object()), strictly more robust than task's.
  • Payload-vs-stored-node distinction — CONFIRMED end to end. normalize_flat_properties_to_namespace receives the incoming payload, never the stored node (crud.rs:673, :803); the early return at :1713-1718 tests the payload. A bare {"status":"done"} normalizes and deep-merges correctly; the spread payload trips the early return and strands a top-level sibling that deep_merge_namespaced_properties (:1670-1694) neither cleans nor rejects. The causal claim is correct, and the "anyone tempted to drop the spread" note protects the right invariant.

One inaccuracy survives, minor:

"NodeService namespaces on create for every type except schema"

schema is not the only exception. create_node branches if node.node_type == "task" { … } else if node.node_type != "schema" { … } (crud.rs:99-160). Because the branch is on node type, task can never reach the else if, so if any of its three nested guards fails — no schema (:102), no "fields" key (:108), or field parse failure (:109) — the payload is stored verbatim, unnamespaced. database-settings also returns early at :66-79. So task is precisely a type that can end up genuinely flat, making resolveFieldValue's flat fallback less vestigial than the comment implies.


Verdict

Recommendation: COMMENT — approve-in-principle. One small fix worth taking before merge.

The delta does what it claimed. Finding 1's fix was verified against all 16 plugin registrations; Finding 2's rewritten comment survived a line-by-line Rust audit that its predecessor failed, which is a genuine turnaround. The two skips are correctly scoped.

  • Finding 4 is the one item to fix here: a one-line addition to resetGenericSchema(). It closes the same race Finding 3 identified, on a navigation path (project → task) this PR makes routine.
  • Suggestion 7 (a test for the guard) and the two nits are optional polish.

If Finding 4 is fixed, this needs no further re-review — a localized change to an already-traced function, with the existing suite covering surrounding behavior.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator 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 of aa53c485): COMMENT — approve-in-principle. Findings 1 and 2 verified as correctly resolved; one new Important finding (stale recency token on the hardcoded-form navigation path) has since been fixed in c9322894.

@malibio

malibio commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

Re-review addressed — c9322894

🟡 Finding 4 — fixed. The trace is correct, and it's a real hole in the previous commit's guard: pendingType was only ever written inside loadGenericSchema, but loadForm skips that call entirely for types with a hardcoded form. Navigating project → task therefore left the token naming project, and a late-resolving fetch passed the recency check. Confirmed against loadForm:93 before fixing.

Took the recommended fix — clearing the token in resetGenericSchema() — because that is the actual navigation boundary, so the field now tracks where the viewer is rather than what was last fetched. Also moved the declaration up with the other fields; it had been orphaned between methods.

🟢 Suggestion 7 — added. Two tests using deferred per-type promises, covering both interleavings.

Worth recording how they were validated: with the fix reverted, the hardcoded-form test fails and the generic-to-generic test still passes. That confirms the second case was already covered by the prior commit and the first is exactly what was missing — the tests pin the invariant rather than merely passing alongside it.

Nits not taken

The re-gate comment's "entity nouns" claim. Correct that collection/user/document produce "Collection Node"/"User Reference"/"Document Reference", so the rationale is broader than the set it admits. Left as-is: the gate is a strict improvement and a no-op for project, and rewording invites re-litigating plugin naming that predates this PR. Worth its own pass if those titles bother anyone.

create_node's namespacing exceptions are wider than schema. Also correct, and the task case is the interesting one — it branches earlier and stores verbatim if its schema fetch or field parse fails, so task can genuinely end up flat. That makes resolveFieldValue's flat fallback less vestigial than the comment implies. Left as-is because it belongs with the stale-sibling cleanup (Suggestion 6) rather than expanding a comment this PR touched only to correct a causal claim — both are really about "what shapes can properties actually be in", and that deserves one coherent treatment.

Verification

  • Full frontend suite: 212 files / 4685 tests (up 2 — the new guard tests)
  • The four test files for this change: 76/76
  • quality:fix: clean — 2271 files, 0 errors, 0 warnings
  • Pre-push gate passed end-to-end

Per the re-review's own criterion — "if Finding 4 is fixed, this needs no further re-review" — this should be ready.

@malibio
malibio merged commit e57af24 into main Aug 17, 2026
@malibio
malibio deleted the issue-1998-frontend-integration-predicate branch August 17, 2026 11:45
malibio added a commit that referenced this pull request Sep 5, 2026
Post-review step 4 tagged HEAD "for future delta reviews". Nothing consumed
those tags: the command's own Review Mode Selection derives the re-review
baseline from `gh pr view --json reviews,comments`, which is how the PR #2013
re-review established its base range without one.

They were not inert. A tag is a strong ref, so each pinned a pre-squash branch
commit that would otherwise be collectable once its branch was deleted, under a
bare-timestamp name carrying no PR, issue, or branch.

Removed at the source rather than instructing agents to skip it, so the three
sibling dev clones inherit the fix on pull.

Also pruned the accumulated tags (43 local / 32 remote review-*, plus
pr-634-reviewed-*) after confirming each was safe: 36 mapped to merged PRs via
the GitHub commits/pulls API, and the rest had lost their PR association only
because their branches were deleted.

Co-Authored-By: Claude Opus 5 (1M context) <[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