Skip to content

Add a link field type: a title and URL pair for schema fields - #3579

Merged
malibio merged 1 commit into
mainfrom
issue-3541-link-field-type
Oct 5, 2026
Merged

malibio merged 1 commit into
mainfrom
issue-3541-link-field-type

Conversation

@malibio

@malibio malibio commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #3541. Implements ADR-092 §4.

What changed

Adds link to the schema field types: a title and an absolute URL. This is a field-type change, not a node-type change: no core type, field, relationship or rule is added, and node-types.md is unaffected. The core fields that will use it (project.repository, task.pull_request, task.commits) are not part of this PR.

Wire type (nodespace-types)

  • SchemaFieldType::Link, listed in ALL.
  • LinkValue { title, url }: snake_case keys, deny_unknown_fields, generated to TypeScript (link-value.ts).
  • LinkValue::from_json is the one check of a link's shape. url must parse with a scheme and a host; the scheme is not restricted.

Core

  • Write validation (check_field_value) refuses a missing key, an extra key, a non-string part, a relative URL, a URL carrying whitespace or a bare string, naming the field and the problem. An array field with itemType: link checks each item and names its index.
  • A schema write that marks a link field (or a list of links) unique is refused.
  • link is refused as an edge field type: no write validates edge values of that type.
  • Play validation lets a condition read node.<field>.title and node.<field>.url. It previously treated every field as terminal, so these paths were rejected at save time.
  • A title is plain text: a title template that names a link field takes the link's title, or its URL when the title is empty.

Agent

  • create_schema / update_schema list link among the field types (Stage-2 tool-surface golden re-recorded: two description lines).
  • A link field in field_values is declared to the model as an object with title and url.

App

  • LinkFieldControl: shows a link as its title, opens the URL through the existing opener, edits title and URL. A link is written whole, so the two inputs are a draft committed only when complete; blank clears it.
  • Only http and https are opened. Any other scheme is shown as text.
  • A list of links is edited in the nested editor: links are added once complete, and removed.
  • Table cells, header summaries and the client-side title preview show the title.

Docs

  • packages/skill/references/cli.md: writing, clearing and reading a link.
  • nodespace-docs: architecture/data-layer.md (field types and the link shape) and components/creating-node-types.md, pushed to main alongside this PR.

How the acceptance criteria were read

  • "The schema form offers Link as a field type." The app has no schema-authoring UI with a field-type picker; schemas are authored through the CLI and the agent. This is implemented as the schema-driven property form rendering and editing link fields.
  • "Markdown export renders a link field as a Markdown link." Not met. Node export writes content only and has no field rendering to extend, and a title is plain text, so nothing in this PR renders a link as Markdown. Whether export should write fields at all is a separate decision.
  • "Cannot be used as a kanban grouping field, and the schema write that tries is refused." Kanban grouping is enum-only in the app and nothing in the backend checks groupBy. No refusal was added; a test pins that a link field is never offered and a stored selection naming one is ignored.
  • "Prints it in human output as its title and URL." Human output is unchanged: the properties line prints the link's object, which carries both.

Tests

  • nodespace-types: link shape, vocabulary round trip.
  • nodespace-core: link_field_type_test (store, clear, every refusal, lists, unique refusal on create and update, title template), CEL condition reads, Play path validation, edge-field refusal.
  • nodespace-agent: write tools accept a link and refuse a bare string; declared field_values shape.
  • nodespace-cli: --property sets, reads and clears a link; schema get reports link.
  • Frontend: link-values, link-field-control, nested editor list of links, table row, title template, kanban eligibility.

bun run test:changed passes on every tier.

🤖 Generated with Claude Code

@malibio

malibio commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review: PR #3579 (link field type, issue #3541 / ADR-092 §4)

Review Type: Initial Review (no prior reviews or comments on the PR). Reviewed the three PR commits at head 274557f8.

Summary

The change is well layered and a clear net improvement. No blockers. One Important item: the title-template rendering puts Markdown syntax into node.title, which is plain text everywhere else.

What I checked:

  • Wire type and validation: SchemaFieldType::Link and LinkValue are defined once in nodespace-types, with snake_case keys and deny_unknown_fields. LinkValue::from_json is the only shape check, and nested object fields reach it through check_nested_fields.
  • Project rules: generated TypeScript matches the Rust types. Added lines contain no lint suppression, any, raw console logging, compatibility code, issue numbers in comments, or literal node_type comparisons.
  • Security: a link is opened only when it passes two independent http/https checks (isOpenableLink, then openUrl's own guard). Other schemes render as escaped text, and there is no {@html}.
  • Persistence wiring: the link control's onChange reaches updateField / updateUserField in both schema forms, so edits are saved.
  • Tests run: .tools/bin/cargo-nextest nextest run -p nodespace-types -p nodespace-core -E 'test(link)' gave 58 passed; bun run skill:check reports up to date. I did not re-run test:changed or quality:fix.

Requirements Check

# Acceptance criterion Status Notes
1 Link variant, defined once, in ALL, TypeScript regenerated ✅ link-value.ts and schema-field-type.ts are generated output.
2 Stored as {title, url}; malformed writes refused naming field and problem ✅ Covered case by case in link_field_type_test.rs.
3 Array with item type link validates each item ✅ The error names the item index.
4 create_schema / update_schema accept link and itemType: link ✅ Covered in the core and agent tests.
5 Cannot be unique or a kanban grouping field; the schema write is refused ✅ / ⚠️ unique is refused on create and update. Kanban has no refusal. I agree with the PR's reading: groupBy lives in a query node's view_config, not in a schema, so there is no schema write to refuse, and the app's grouping is enum-only (test added).
6 Play condition reads .url / .title; has() false when unset ✅ See finding 4 on test depth.
7 CLI sets and clears; human output shows title and URL; --json returns the object; schema get shows link ✅ / ⚠️ Human output is unchanged: the properties: line prints the JSON object, which carries both parts. Acceptable, but no test asserts it.
8 Agent write tools accept a link and reject a bare string ✅ link_field_values.rs.
9 Markdown export renders a link field as a Markdown link ❌ (reinterpreted) See finding 1.
10 App: schema form offers Link; property editor shows, opens and edits; list add/remove; table and kanban cells show the title ✅ / ⚠️ There is no schema-authoring UI with a type picker, so "offers Link" has nothing to attach to; the PR's reading is fair. Kanban cards show only the node title, so there is no kanban cell to change.
11 Opened only for http / https; other schemes shown as text ✅ See finding 2 for an edge case that fails closed.
12 references/cli.md documents links; skill:check passes ✅ Ran it.
13 Docs updated ✅ Present in the local nodespace-docs checkout (architecture/data-layer.md, components/creating-node-types.md). I did not check that they are pushed to the docs remote.
14 quality:fix Not re-run
15 test:changed Not re-run Focused link tests pass.

Code Review Findings

1. 🟡 Important: the title template writes Markdown into a plain-text title

📁 packages/core/src/utils/markdown.rs:152-155, 191-212, packages/nodespace-types/src/schema.rs (LinkValue::to_markdown), packages/desktop-app/src/lib/utils/title-template.ts:69-73, packages/desktop-app/src/lib/utils/link-values.ts (linkFieldMarkdown)

This is partly a judgment call on the acceptance criterion; the inconsistency itself is confirmed in code.

  • The criterion is not met by this change. export_node_hierarchy and export_node_with_context (packages/core/src/markdown/mod.rs:1953-1962, 2069-2081) write only node.content. They never write node.title or any field, so rendering a link in a title template does not reach Markdown export.
  • The substitute changes node.title. A schema with title_template: "{target}" now gets the title [Docs](https://example.com/docs); the new integration test asserts exactly that.
  • node.title is plain text everywhere else.
    • Content-derived titles go through strip_markdown (crud.rs:3610), which turns [link](url) into link.
    • The title is printed verbatim in list rows, kanban cards, the table content column and tab titles.
    • It is indexed by node_title_fts, so URL tokens enter the title index.
  • The PR is inconsistent with itself. evaluateSummaryTemplate and table cells show the link's label, while the title shows Markdown.

Recommendation: render a link in a title as its plain label (the title, or the URL when the title is empty), the same rule linkLabel already uses. Then delete link_field_markdown, to_markdown and the TypeScript linkFieldMarkdown mirror. For the criterion, either record it as not applicable (export has no field rendering to extend) or implement field rendering in export as its own decision.

Principle: least surprise, and one representation per field (title is a plain-text name). Removing the Markdown renderer also removes a Rust/TypeScript mirror that must be kept in sync.

2. 🟢 Suggestion: isOpenableLink and openUrl disagree on some URLs

📁 packages/desktop-app/src/lib/utils/link-values.ts:34-41, packages/desktop-app/src/lib/components/schema/link-field-control.svelte:78-82, 119-129

isOpenableLink parses with new URL; openUrl requires the raw string to start with lowercase http:// or https://. I confirmed with bun -e that HTTPS://Example.com/a, http:example.com and a URL with leading whitespace all parse as http(s) and fail the prefix check.

Such a value (typed in the app with an uppercase scheme, or written through the CLI or agent) renders as a clickable title that does nothing except log an error. It fails closed, so this is a usability bug, not a security one.

Recommendation: make isOpenableLink use the same rule as openUrl (for example, reuse isExternalUrl), or pass new URL(url).href to openUrl. Principle: one definition of "openable".

3. 🟢 Suggestion: the URL is validated parsed but stored raw

📁 packages/nodespace-types/src/schema.rs (LinkValue::from_json)

Url::parse follows the WHATWG rules: it trims surrounding whitespace and drops tabs and newlines inside the string. The value stored is the original string. I confirmed the same leniency in JavaScript's new URL; I did not execute the Rust case and rely on the url crate's documented behaviour.

A CLI or agent write of " https://example.com\n" is therefore accepted and stored with the whitespace. That feeds finding 2 and any exact-match comparison in a Play condition.

Recommendation: refuse a url with leading or trailing whitespace or control characters (simplest), and add one test case. Judgment call; low priority.

4. 🟢 Suggestion: no test reads a link's parts through the graph resolver

📁 packages/core/src/playbook/cel.rs (a_link_field_reads_as_its_title_and_url), packages/core/src/playbook/graph_resolver.rs:441-466, 741-814

The CEL test evaluates with resolver: None. In production, node.repository.url is a three-segment path, so enrich_context sends it to the resolver.

I traced that path and it works: own_value returns the link object, settle marks the path Missing because a scalar is not the last segment, nothing is injected, and CEL reads the base node map. That correctness depends on settle and inject_resolved_paths leaving the base map alone.

Recommendation: add one condition test for node.<link>.url with a real GraphResolver, so a later resolver change cannot break link reads silently.

5. 🟢 Suggestion: a list of links is not declared to the model with its item shape

📁 packages/agent/src/local_agent/tools.rs:1353-1360

A link field is declared in field_values with properties and required. An array field with itemType: link is declared as a bare array, so the model learns the item shape only from a validation error.

Recommendation: emit items: { type: object, properties: {title, url}, required: [...] } when the descriptor carries the item type. If EntityFieldDescriptor does not expose item_type, leave it for the change that adds task.commits.

Nits

  • Nit: packages/cli/tests/it/cli_integration.rs: nothing asserts the human-readable properties: line for a link, although criterion 7 calls it out.
  • Nit: link-field-control.svelte: in a list, each item's edit state lives in a component keyed by index, so removing an earlier item while a later one is being edited moves the open editor to a different link. This is the same index-keying the existing editor uses.

Recommendation

APPROVE. Nothing blocks the merge: validation, security posture and layering are sound, and the tests are meaningful.

Finding 1 should be resolved or consciously accepted before merge. It is cheap to change now and it sets what users see as a node's name. Findings 2 to 5 are optional hardening.

@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: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

@malibio

malibio commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Address-review summary (commit 86bc324f)

Addressed

  1. 🟡 Title template wrote Markdown into a plain-text title. A title template now takes a link's title, or its URL when the title is empty; a list of links is those, comma-separated. LinkValue::to_markdown, link_field_markdown and the TypeScript linkFieldMarkdown mirror are removed. The client-side title preview uses the same label rule as table cells and header summaries.
  2. 🟢 isOpenableLink and openUrl disagreed. isOpenableLink now uses the opener's own rule (isExternalUrl), so a link offered as openable is one the opener accepts. HTTPS://… and a URL with leading whitespace are shown as text.
  3. 🟢 URL validated parsed, stored raw. A url carrying whitespace or control characters is refused; test cases added.
  4. 🟢 No resolver-backed condition test. Added a_link_fields_parts_read_through_the_resolver, which evaluates node.<link>.url, .title and has(...) with a real GraphResolver, set and unset.

Skipped

  1. 🟢 Item shape for a list of links in the tool schema. EntityFieldDescriptor carries no item type. Adding one changes what every array field declares to the model, which is a prompt-surface change to make and measure with the core fields that use a list of links.
  • Nit, CLI human-output assertion. The human formatter prints straight to stdout and the CLI tests have no capture for it; the --json shape is asserted.
  • Nit, index-keyed edit state in a list. Same keying as the existing nested editor; changing it is a change to that editor, not to links.

Acceptance criterion "Markdown export renders a link field as a Markdown link": with finding 1 addressed, nothing in this PR renders a link as Markdown. Node export writes content only and has no field rendering to extend, so this criterion is not met and is left for a decision on whether export should write fields at all.

bun run test:changed passes on every tier.

Re-Review Decision

Decision: RE-REVIEW NEEDED

Rationale: Finding 1 changed what a title holds and removed code on both sides of the Rust/TypeScript mirror, and finding 3 tightened write validation.

@malibio

malibio commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review: PR #3579 (link field type, issue #3541 / ADR-092 §4)

Review Type: Re-Review. Reviewed commit 86bc324f only (git diff 274557f8..HEAD), against the previous review at 274557f8 and the address-review summary.

Previous Review Summary

  • Previous recommendations: 5 findings and 2 nits.
  • Addressed: 4 (findings 1 to 4), each confirmed in code.
  • Not addressed: 1 finding and 2 nits. All three skips are justified.
  • New issues found: 1 improvement and 3 nits. None blocks the merge.
# Previous finding Status What I checked
1 🟡 Title template wrote Markdown into node.title Addressed link_field_label (packages/core/src/utils/markdown.rs:195-217) and LinkValue::label return the trimmed title, or the URL when the title is empty or whitespace. to_markdown, link_field_markdown, linkFieldMarkdown and linkMarkdown are gone, with no remaining reference in packages/ or scripts/.
2 🟢 isOpenableLink and openUrl disagreed Addressed isOpenableLink returns isExternalUrl(url), a lowercase http:// / https:// prefix test. Everything it accepts passes openUrl's own guard. openUrl also takes mailto:, which stays text here, as the control's header says.
3 🟢 URL validated parsed, stored raw Addressed LinkValue::from_json refuses any whitespace or control character in url. Three cases added (leading space, trailing newline, tab inside the host). See new finding 1 for the frontend side.
4 🟢 No resolver-backed condition test Addressed See below.
5 🟢 Item shape of a list of links in the tool schema Skipped, justified EntityFieldDescriptor has no item type. Adding one changes what every array field declares to the model, and no core field uses a list of links yet. The previous review offered this deferral itself.
Nit CLI human-output assertion Skipped, justified The --json shape is asserted; the human line prints the same object.
Nit Index-keyed edit state in a list Skipped, justified Belongs to the nested editor, not to this change.

Title parity, Rust against TypeScript. I traced both sides for the same stored value:

Value Rust (interpolate_title_template_with_schema) TypeScript (evaluateTitleTemplate)
{title: "Core", url} Core Core
{title: "", url} the URL the URL
{title: " ", url} the URL the URL
{title: " Core ", url} Core Core
List of valid links labels joined by , labels joined by ,
Empty list empty empty
A string in a link field the string the string

They agree for every value a validated write can store. They differ only for values validation refuses (nit 2).

The resolver test does exercise the resolver. node.repository.url is a three-segment path, so enrich_context does not take its two-segment property shortcut and calls resolve_path(["repository", "url"]). The walk reads repository off the node as a scalar, settle marks the path Missing because the scalar is not the last segment, and nothing is injected, so CEL reads the base map. The unset node covers the other branch: repository is neither a property nor a declared relationship. The two has(...) cases on the set node are skipped by the property shortcut; on the unset node they reach the resolver.

Tests run at HEAD

  • .tools/bin/cargo-nextest nextest run -p nodespace-core -p nodespace-types -E "test(link)": 59 passed.
  • bun run test -- link-values title-template link-field-control: 58 passed.
  • I did not re-run test:changed or quality:fix.

Code Review Findings

1. 🟡 Improvement: the app's link editor accepts a URL the backend now refuses

📁 packages/desktop-app/src/lib/utils/link-values.ts:41-47, 82-90 (isAbsoluteUrl, resolveLinkDraft), packages/nodespace-types/src/schema.rs:237-244

This commit made the backend refuse any whitespace in a link's url. The editor's check was not changed: resolveLinkDraft trims the ends and then asks new URL(...), which accepts whitespace inside the URL.

  • Confirmed with Bun. https://example.com/a b and https://example.com/?q=a b parse with a host, so the draft is accepted. https://example.com/a<TAB>b parses too.
  • Before this commit the backend took these, since Url::parse percent-encodes a space in a path or query. The disagreement is new.
  • What the user sees. LinkFieldControl.save() closes the editor and calls onChange. updateField writes optimistically and updates the title preview. The backend then refuses the write. The store has a rollback path for a failed write; I did not trace what it shows the user. Either way the editor's own inline message ("Enter a full URL…") is never shown, and the typed link is lost.

A pasted search URL with a space in its query is a realistic input.

Recommendation: in resolveLinkDraft, return invalid when the trimmed URL contains whitespace or a control character, and add one test case beside the existing invalid cases. Principle: one rule for what a link is. The backend is the authority, and a client pre-check that is looser than it turns a clear inline message into a failed write.

Nits

  • Nit: the PR description is stale. It still says "A title template renders a link field as [title](url)", "the client-side title preview mirrors the backend's Markdown rendering", lists "title template" under a Markdown reading of the export criterion, and says "Only http and https are opened" without the stricter prefix rule. Update it before merge, since the squash commit is titled and described from the PR. The criterion "Markdown export renders a link field as a Markdown link" should be stated there as not met, as the address-review summary already says. packages/skill/references/cli.md and nodespace-docs/architecture/data-layer.md:137 are correct.
  • Nit: packages/desktop-app/src/lib/utils/link-values.ts:54-69. The doc comment says a title computed by linkFieldText "matches the backend's". For a list holding a non-link item, asLinkList skips the item and joins the rest, while Rust's link_field_label returns None and the title falls back to the JSON text. For a list field holding a non-array, TypeScript gives an empty string and Rust gives the value. The removed linkFieldMarkdown had the links.length === value.length guard that kept these in step. Validated writes cannot store either value, so this is unreachable today; either restore the guard or leave it.
  • Nit: packages/nodespace-types/src/schema.rs:243-249. A URL refused for whitespace gets the message "not an absolute URL (a scheme and a host…)", which does not name the cause for https://example.com/a b. A caller, the agent included, has to spot the space in the quoted value. A separate message would be clearer.
  • Nit: packages/desktop-app/src/tests/unit/title-template.test.ts:253-270 covers one titled link. A list of links and an empty-title link in a title are covered only on the Rust side and in linkLabel's own test.

Recommendation

APPROVE. The commit resolves the one Important finding from the first review and the three optional ones it took on, and the skips are sound. node.title is plain text again and the Rust and TypeScript titles agree for every storable value.

Finding 1 is a small fix worth folding in before merge, because this commit introduced the mismatch. The PR description should be corrected at the same time.

@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): APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

@malibio

malibio commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Address-review summary, re-review (commit 73d4bf37)

Addressed

  1. 🟡 The link editor accepted a URL the backend refuses. resolveLinkDraft now refuses whitespace or a control character inside the URL, with its own inline message, before the write is attempted.
  • Nit, whitespace error message. The backend names the cause (has a 'url' that contains whitespace) instead of "not an absolute URL".
  • Nit, list parity. linkFieldText reads a list as links only when every item is one, matching the backend's title for values validation would refuse.
  • Nit, title tests. Added an untitled link and a list of links in a title on the TypeScript side.
  • Nit, PR description. Corrected: titles take the link's label, and the Markdown-export criterion is stated as not met.

Skipped: nothing new. The three skips from the first round stand.

bun run test:changed passes on every tier.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: One extra client-side refusal that mirrors a rule the backend already enforces, a reworded error message, a parity guard on an unreachable value, and tests. No design change and nothing interconnected.

@malibio

malibio commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Merge queue: #3579 was taken out of the queue — it conflicts with main in: packages/core/src/models/mod.rs. Merge or rebase origin/main, resolve the conflicts, push, and re-run bun run merge 3579.

@malibio

malibio commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Merge queue: #3579 was taken out of the queue — it conflicts with main or with #3578, queued ahead of it, in: packages/cli/tests/it/cli_integration.rs, packages/skill/references/cli.md. Merge or rebase origin/main, resolve the conflicts, push, and re-run bun run merge 3579.

@malibio

malibio commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review: PR #3579 (link field type, issue #3541 / ADR-092 §4)

Review Type: Re-Review. Reviewed head 89cfae8d0 as the net change against origin/main, covering everything since the last reviewed commit 86bc324f.

Previous Review Summary

  • Previous recommendations (second review): 1 improvement and 4 nits.
  • Addressed: all 5, each confirmed in code.
  • Not addressed: none. The three skips from the first round still stand.
  • New issues found: 1 that stops the PR landing (it conflicts with main again), and 1 nit.
# Second-review item Status What I checked
1 🟡 The link editor accepted a URL the backend refuses Addressed resolveLinkDraft returns invalid for whitespace or a control character in the trimmed URL, before the absolute-URL check. Tests cover a space in the path, a space in the query and a tab.
Nit Whitespace error message Addressed LinkValue::from_json returns "has a 'url' that contains whitespace" before parsing; the "not an absolute URL" message is left for relative URLs. Tests split to match.
Nit List parity in linkFieldText Addressed A list is read as links only when it is an array and every item is a link; otherwise null, as the backend's title does. An empty list gives an empty string.
Nit Title tests on the TypeScript side Addressed An untitled link and a list of links in a title are now covered.
Nit Stale PR description Addressed The description says titles take the link's label and states the Markdown-export criterion as not met.

Merge resolutions (three merges of main). Nothing from main was dropped:

  • The net diff against the merge base is additions only in all three conflicted files: the LinkValue re-export in packages/core/src/models/mod.rs, the link section in packages/skill/references/cli.md, and one import plus the link test in packages/cli/tests/it/cli_integration.rs.
  • No conflict markers remain in the tree.
  • The link CLI test sets the two fields main added (version, properties_json).

Query paths into a link field. The change is correct, and it matches at run time, not only at the schema check:

  • Schema check. resolve_property accepts a link field followed by exactly title or url. Any other continuation (repository.host, repository.url.scheme) is refused with a message naming the field and the two parts.
  • SQL. The filter compiles to json_extract(properties, '$.<scope>.<path>') for any dotted path, and a link is stored as a JSON object. The new test runs an equals filter on .url, an exists filter and a sort on .title against a real database.
  • In-memory sort pass. It walks property_segments through the stored value, so it needs no change.
  • App matcher. filterSubject in packages/desktop-app/src/lib/components/query/query-node-model.ts:246-255 walks the path through any object value. The app has no schema check of its own, so nothing there disagrees.
  • Inherited link field. The link arm returns the same scope an object path returns, taken from the owner of the first segment. Not tested for a link specifically; the code path is shared with object fields.
  • A link inside an object field (meta.repo.url) works: the walk steps into the object's declared fields and then reaches the link arm.
  • A list of links followed by .url is refused by the existing arm: "'commits' is a array field ... with no declared fields inside it, so a path cannot continue past it". Clear enough.

Landing this code inside merge commit 9e1059f94 is fine for the queue, which stacks a branch with merge commits as its net change.

Tests run at HEAD

  • .tools/bin/cargo-nextest nextest run -p nodespace-core -p nodespace-types -E 'test(reach_into) | test(link)': 61 passed.
  • bun run test -- link-values title-template link-field-control query-node-model: 114 passed.

Code Review Findings

1. 🔴 Blocker for landing: the branch conflicts with current main again, and the resolution is not mechanical

📁 packages/core/src/services/node_service/crud.rs:3508-3559 (branch), packages/desktop-app/src/lib/components/schema/nested-field-editor.svelte:246-250 (branch)

main moved after the last merge into this branch (the "Type-check array fields on write" change and the clippy-in-gate change). A trial merge (git merge-tree --write-tree HEAD origin/main) reports content conflicts in both files above, so the queue will eject the PR as it stands.

The code I reviewed is sound. The verdict below is about this merge, because each resolution carries a decision:

  • crud.rs, check_field_value. main rewrote the array check as a match field.item_type, with a final Some(item_type) arm that calls the new scalar_mismatch.
    • scalar_mismatch matches SchemaFieldType exhaustively, so it needs a Link case; the compiler will ask for it.
    • The compiler will not ask for the other half. If Link only joins the return None group, a list of links falls into the scalar arm and no item is checked, unless the branch's separate Array + item_type == Link block is kept. Prefer a Some(SchemaFieldType::Link) arm inside main's match, which checks each item with LinkValue::from_json, and drop the separate block. The array-shape check then happens once, with main's message.
    • The branch's tests in link_field_type_test.rs that refuse a bad item in a list of links will catch a wrong resolution; run them after the merge. A non-array value in a list-of-links field will get main's message, so any assertion on "(item type 'link')" needs updating.
  • nested-field-editor.svelte, the item onChange. main now calls editArrayItem, which ignores a null item (an element is removed, never cleared). The branch removes a link from the list when its control reports null. Keep both: for itemType === 'link' a null removes the item; everything else goes through editArrayItem. Taking main's side alone makes clearing a link in a list do nothing; taking the branch's side alone brings back the date-picker bug main fixed. nested-field-editor.test.ts on this branch covers the link case.

Recommendation: merge origin/main, resolve as above, and run bun run test:changed (clippy now runs in the merge gate). Principle: one definition of "this value satisfies this declaration"; main made check_field_value's array match that place, and the link item check belongs in it.

Nits

  • Nit: packages/skill/references/cli.md:264, 279, 927 and packages/cli/src/commands/query.rs:42-43 still describe a dotted path as reaching into an object field, and line 279's example says "when the project schema declares a repository object field with a url inside it". The link section added by this PR says a link's parts are read the same way, so nothing is wrong. Once project.repository is a link, that example should say so; it fits the change that adds the field.

Recommendation

REQUEST CHANGES, for the merge only. The second review's finding and nits are all resolved, the three earlier merge resolutions kept both sides, and the query-path change is correct in the schema check, in SQL and in the app. No design change is asked for.

What is needed before bun run merge: merge current main and resolve the two conflicts as described in finding 1, then re-run the link tests. The crud.rs resolution decides whether items in a list of links are still validated, so it is worth a look after it is made.

@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): REQUEST CHANGES (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

@malibio

malibio commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Address-review summary, third review

Addressed

  1. 🔴 Conflicts with main in crud.rs and nested-field-editor.svelte. Merged origin/main and resolved both as the review prescribed:
    • check_field_value: the per-link item check is a Some(SchemaFieldType::Link) arm inside main's array-item match, and the branch's separate array-of-links block is gone. The array-shape check happens once, with main's message. Link joins the types scalar_mismatch does not check. The single-link check stays beside the object check.
    • Nested editor: for itemType === 'link' a null from the control removes the item; every other item edit goes through main's editArrayItem.
    • One assertion in link_field_type_test.rs now expects main's wording for a non-array value in a list-of-links field. The tests that refuse a bad item in a list (naming its index) and that remove a link from a list pass unchanged.

Skipped

  • Nit, cli.md and query.rs describe a dotted path as reaching into an object field. The link section says a link's parts are read by path. The example naming project.repository as an object field belongs to the change that makes that field a link.

Also in this round (from the comment on #3541): a query filter and sort can read <field>.title and <field>.url on a link field; the third review covered it.

bun run test:changed passes on every tier and bun run rust:lint is clean at head.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: The only change since the third review is the merge of main, resolved exactly as that review specified, with both halves covered by tests that existed before the merge and still pass.

@mstomar125

Copy link
Copy Markdown
Contributor

Merge queue: #3579 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 3579.

Checking toml_edit v0.20.2
    Checking nix v0.25.1
    Checking downcast-rs v1.2.1
    Checking time v0.3.47
    Checking opentelemetry-http v0.32.0
    Checking memo-map v0.3.3
    Checking shell-words v1.1.1
    Checking alloc-no-stdlib v2.0.4
    Checking utf8parse v0.2.2
    Checking env_home v0.1.0
    Checking unic-common v0.9.0
    Checking unic-char-range v0.9.0
    Checking portable-pty v0.8.1
    Checking alloc-stdlib v0.2.2
    Checking toml v0.8.2
    Checking opentelemetry-otlp v0.32.0
error: consider using `sort_by_key`
   --> packages/core/src/ops/search_ops.rs:368:9
    |
368 |         merged.sort_by(|a, b| b.modified_at.cmp(&a.modified_at));
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#unnecessary_sort_by
    = note: `-D clippy::unnecessary-sort-by` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::unnecessary_sort_by)]`
help: try
    |
368 -         merged.sort_by(|a, b| b.modified_at.cmp(&a.modified_at));
368 +         merged.sort_by_key(|b| std::cmp::Reverse(b.modified_at));
    |
error: could not compile `nodespace-core` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: script "rust:lint" exited with code 101
[stage exited with code 101]

  full output: /var/folders/3w/y9kj522n1_j9wqmt6vl_sb6r0000gp/T/nodespace-gate-logs/_gate-merge-2026-10-05T08-48-22-339Z/rust-lint-clippy-whole-workspace.log

✗ rust:lint (clippy, whole workspace) failed — merge blocked.
  Fix the failure, push, and re-run: bun run merge <PR#>

@malibio

malibio commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Merge queue: #3579 was taken out of the queue — it conflicts with main in: packages/agent/tests/it/main.rs. Merge or rebase origin/main, resolve the conflicts, push, and re-run bun run merge 3579.

@malibio
malibio force-pushed the issue-3541-link-field-type branch from 1353624 to e2d39ec Compare October 5, 2026 10:36
@malibio
malibio merged commit 6f66b0c into main Oct 5, 2026
@malibio
malibio deleted the issue-3541-link-field-type branch October 5, 2026 10: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 a link field type: a title and URL pair for schema fields

2 participants