Skip to content

Keep archived nodes out of the @ mention picker - #3459

Merged
malibio merged 2 commits into
mainfrom
issue-3428-mention-archived
Oct 1, 2026
Merged

malibio merged 2 commits into
mainfrom
issue-3428-mention-archived

Conversation

@malibio

@malibio malibio commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Closes #3428

What changed

SqliteStore::mention_autocomplete now adds lifecycle_status = 'active' to its query, so the @ mention picker no longer offers archived nodes (ADR-087 §2). The Tauri command, the daemon RPC and the dev-proxy all go through this one query, so the filter covers every path. The type exclusions (collection, schema, ai-chat) are unchanged.

This is a literal lifecycle_status comparison in the query. The issue scopes it that way: the shared participation check from ADR-087 doesn't exist yet, and will replace this condition along with the other scattered comparisons.

Tests

  • New: mention_autocomplete_skips_archived_nodes_until_unarchived creates two tasks with matching titles, archives one and asserts only the active one is offered, then unarchives it and asserts both are offered. It fails with the filter removed.
  • The existing mention tests pass (wildcard escaping; dates offered, schemas not; ai-chats not offered).
  • bun run test:changed passed (Rust and scripts tiers); bun run quality:fix made no changes.

Acceptance criteria

  • mention_autocomplete returns no archived node
  • Unarchiving the node makes it appear again
  • The existing mention autocomplete tests pass
  • bun run test:changed passes; bun run quality:fix clean

🤖 Generated with Claude Code

@malibio

malibio commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review: PR #3459

Review Type: Initial Review (no prior reviews or comments on the PR)

Reviewed commit: 07792bda (1 commit, 2 files: packages/core/src/db/sqlite_store/search.rs, packages/core/src/db/sqlite_store/nodes.rs)

Summary

A one-condition change to SqliteStore::mention_autocomplete plus one store-level test. It does what issue #3428 asks, at the right layer, and nothing else. The filter is in SQL ahead of LIMIT, so archived rows cannot use up the result limit. There is one finding to note against project rules (not blocking) and one optional nit.

Requirements Check (issue #3428)

  • PASS: mention_autocomplete returns no archived node. lifecycle_status = 'active' is added to the query (search.rs:21). The test creates two tasks with matching titles, archives one and asserts that exactly the active id is returned.
  • PASS: Unarchiving makes the node appear again. The same test sets the status back to active and asserts that both ids are returned.
  • PASS: The existing mention tests pass. I ran .tools/bin/cargo-nextest nextest run --lib -p nodespace-core mention_autocomplete: 3 passed (mention_autocomplete_treats_wildcards_literally, the new test, mention_autocomplete_offers_dates_but_not_schemas). I did not run the integration test ai_chat_reference_test::mention_autocomplete_does_not_offer_ai_chats; the PR reports it passing under test:changed.
  • NOT RE-RUN: bun run test:changed and bun run quality:fix. The PR description reports both clean; I did not repeat them.

No deviations from the issue's scope. The type-exclusion list is unchanged, as the issue requires.

What I checked beyond the diff

  • Every path to the picker goes through this query. The Tauri command (app-lib/src/commands/nodes.rs:1037) calls the daemon RPC (daemon/src/services/node_service.rs:1145), which calls NodeService::mention_autocomplete (core/src/services/node_service/query.rs:647), which calls the store. The dev-proxy route /api/mentions/autocomplete calls the same RPC. The frontend has one caller (base-node.svelte:315). No second query needs the same filter.
  • The test would catch a regression. Without the filter the first assertion gets both ids and fails. The second assertion (both ids after unarchiving) proves that the first passed because of the archive and not because the node was never matchable. I reached this by reading the test; I did not revert the fix to watch it fail, because this review makes no edits.
  • = 'active' rather than != 'archived'. This matches ADR-087 §2 (only active nodes participate) and is the stricter form. The title FTS query at nodes.rs:4212 uses != 'archived'; the two are equivalent while the valid set is active / archived.
  • Docs. components/mentions-and-references.md and components/participation.md already describe the picker as excluding archived nodes, so no docs change is needed. This is not a node-type change, so the node type sequence does not apply.
  • Security and performance. The new condition is a constant in the SQL; the user's text is still bound as a parameter and escaped. idx_node_lifecycle exists, and the leading-wildcard LIKE scans as before.

Code Review Findings

1. Important (not blocking): a literal lifecycle_status comparison outside the governance check

packages/core/src/db/sqlite_store/search.rs:20-23

"SELECT * FROM node WHERE title IS NOT NULL AND lifecycle_status = 'active' AND node_type NOT IN ('collection', 'schema', 'ai-chat') AND LOWER(title) LIKE ?1 ESCAPE '\\' LIMIT {}",

CLAUDE.md says "No reads of lifecycle_status outside the governance participation check", and the reviewer checklist lists that as Critical. By the letter of the rule, this line is a violation. I am not blocking on it, for these reasons:

Recommendation: no code change in this PR. Merging is the user's decision; they should know this line knowingly adds one comparison that #3443 must remove. If #3443 lands first, this PR should use its SQL fragment instead.

Principle: single source of truth for a cross-cutting rule (ADR-087 §2), weighed against shipping a net improvement now.

2. Suggestion (optional, outside the diff): stale frontend comment about what the backend filters

packages/desktop-app/src/lib/design/components/base-node.svelte:310-314

// Backend applies SQL-level filtering for performance and scalability:
// - Excludes: date, schema node types

The comment was already wrong before this PR: dates are offered, and collection and ai-chat are excluded. It now also omits archived nodes. Either correct the list (collection, schema, ai-chat, archived) or replace it with a pointer to mention_autocomplete. Leaving it for #3443 is also reasonable, since that issue rewrites these rules.

Principle: comments that restate another layer's behaviour drift; point at the owner instead.

Recommendation

APPROVE

The change is correct, complete for the issue, covers every path to the picker, and is tested by a test that fails without it. Finding 1 is tracked debt with an owner (#3443), not a defect in this PR.

@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 1, 2026

Copy link
Copy Markdown
Collaborator Author

Review addressed

Addressed (1)

  • Suggestion 2, stale comment in base-node.svelte: the comment no longer lists the backend's filters (the list was wrong about dates, collections and ai-chats, and omitted archived nodes). It now points at the backend's mention query. Comment-only change, commit Address review: correct the mention picker comment in BaseNode.

Skipped (1)

Checks: bun run quality:fix made no changes. No tests re-run: the only change since the review is a code comment.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: the review verdict was APPROVE with no critical findings, and the only change since is a comment edit with no logic change.

malibio and others added 2 commits October 1, 2026 18:02
mention_autocomplete now offers only nodes whose lifecycle_status is
active, so an archived node is no longer suggested as a mention target
(ADR-087 §2). A test pins that an archived node is skipped and offered
again once unarchived.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The comment listed backend filters that were already wrong (dates are
offered; collection and ai-chat are excluded) and omitted archived
nodes. It now points at the backend's mention query instead of
restating its rules.

Skipped: the literal lifecycle_status comparison stays. The governance
participation check (ADR-087) does not exist yet; #3443 builds it and
replaces this condition.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@malibio
malibio force-pushed the issue-3428-mention-archived branch from acf6013 to d7ec6f1 Compare October 1, 2026 16:02
@malibio
malibio merged commit 8b71681 into main Oct 1, 2026
@malibio
malibio deleted the issue-3428-mention-archived branch October 1, 2026 16:02
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.

Keep archived nodes out of the @ mention picker

1 participant