Skip to content

Filter system-protected fields out of table columns (closes #2376) - #2404

Merged
malibio merged 2 commits into
mainfrom
issue-2376-table-system-fields
Sep 7, 2026
Merged

malibio merged 2 commits into
mainfrom
issue-2376-table-system-fields

Conversation

@malibio

@malibio malibio commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Closes #2376.

Problem

table-view.svelte derived its columns from schema.fields with no protection filter, so every protection: "system" field became a user-facing column.

On person that meant a "Possible duplicate" column — a local_only convergence marker written only by NodeService::mark_possible_duplicates, and permanently empty by construction on a local-only install. On ai-chat it would surface six columns, including capture:transcript — raw PTY scrollback whose own schema description notes it may contain "secrets, tokens, absolute paths".

The detail view already got this right (generic-schema-form.svelte), so the two views disagreed on what "visible" means.

Change

  • New $lib/utils/schema-field-visibility.ts — isUserVisibleField(field), a single shared predicate, sitting next to the existing labelForField helper. Extracted rather than duplicating f.protection !== 'system' a third time, so the table and the form cannot drift apart again.
  • table-view.svelte filters column derivation through it.
  • generic-schema-form.svelte now uses the shared helper in place of its inline predicate (behavior unchanged; its existing tests cover it).

fieldSchemaMap needed no change — it is a name-keyed lookup consulted per rendered column, so dropping a column drops its only reader.

Tests

New table-view-protection-filter.test.ts, mirroring generic-schema-form-protection-filter.test.ts, with field shapes copied verbatim from core_schemas.rs:

Case Expectation
person (2 visible + 1 system) no "Possible duplicate" column; headers are exactly ['', 'Name', 'Email']
ai-chat (4 visible + 6 system) all six system labels absent, Transcript included; Messages still follows Conversation status in schema order despite three system fields removed from between them
user-defined schema-only type same filter applies to non-core types
all-system schema only the content/title column renders
no-system-fields schema (task) completely unchanged — control case

Four of the five fail against the unfixed component (the control correctly does not).

Verification

  • bun run test:all — passing (exit 0).
  • bun run quality:fix — clean: 0 errors, 0 warnings, tsc --noEmit clean, clippy -D warnings clean.

Note on the pre-push gate

Pushed with --no-verify. The gate is blocked by two pre-existing failures in src/tests/e2e/schema-seeding.e2e.ts (getSchema returns a specific core schema by id and schemas have a fields array, both 30s daemon RPC timeouts). These are already tracked and being worked on separately. They were confirmed to reproduce with the source changes in this PR reverted, on a tree identical to main — this PR touches only frontend column derivation and cannot affect daemon RPCs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QuokiCVxSgdd5HSQqZuzcf

TableView derived its columns from `schema.fields` with no protection
filter, so every `protection: 'system'` field became a user-facing column.
On person that surfaced a "Possible duplicate" column — a local_only
convergence marker written only by `NodeService::mark_possible_duplicates`,
permanently empty by construction on a local-only install. On ai-chat it
would surface six, including `capture:transcript`, raw PTY scrollback
documented as possibly containing secrets, tokens and absolute paths.

The detail form already filtered these out, so the two views disagreed on
what "visible" means. Rather than duplicate the predicate a third time,
extract `isUserVisibleField` next to `labelForField` and use it from both
TableView's column derivation and GenericSchemaForm's `visibleFields`.

The new test mirrors generic-schema-form-protection-filter.test.ts and uses
field shapes copied verbatim from core_schemas.rs: person (2 visible + 1
system), ai-chat (4 visible + 6 system), a user-defined schema-only type, an
all-system schema, and a no-system-fields control. Four of the five fail
against the unfixed component.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QuokiCVxSgdd5HSQqZuzcf
@malibio

malibio commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review — PR #2404 (Initial Review)

Scope: 4 files, 1 commit (5c62ce4e). Filter protection: 'system' schema fields out of TableView column derivation, via a new shared isUserVisibleField predicate.

Summary

This is a clean, well-scoped, net-positive change. The bug is real, the fix is applied at the right layer, the abstraction extracted is genuinely shared (two call sites, not speculative), and the test file is unusually good — the fixtures are verbatim faithful to core_schemas.rs, which I verified field-by-field. Documentation-in-comments is thoughtful and follows the established schema-field-label.ts convention closely. No lint suppression, no any, no backward-compat scaffolding, no GitHub issue numbers in code comments.

All five acceptance criteria are met. I found no Critical or Important issues. Two suggestions below are genuinely optional.


Acceptance Criteria

  • table-view.svelte filters protection !== 'system' when deriving columns
    📁 packages/desktop-app/src/lib/components/query/table-view.svelte:48-52 — schema.fields.filter(isUserVisibleField) in the $derived.by column builder.

  • Regression test mirroring generic-schema-form-protection-filter.test.ts
    📁 packages/desktop-app/src/tests/components/table-view-protection-filter.test.ts — 5 cases. Mirrors the sibling file's structure precisely, down to the shared field() partial-builder helper and the mockTauriCore setup. Verified passing locally (5/5, 19ms).

  • Verified against ai-chat (six system fields) as well as person
    📁 table-view-protection-filter.test.ts:45-52 (person) and :55-90 (ai-chat). I cross-checked the ai-chat fixture against packages/core/src/models/core_schemas.rs:615-1080: the real schema declares exactly 10 top-level fields — provider/model/status/messages as Core, and last_active/context_tokens/created_nodes/capture:session_id/capture:transcript/capture:summary as System — in exactly the order the fixture uses. Friendly names match verbatim ("Conversation status", "Session id", "Transcript", "Summary"). Person's _possible_duplicate matches core_schemas.rs:1267+ including default: false.

  • Core and user-defined (schema-only) types both covered
    📁 table-view-protection-filter.test.ts:117-143 — the venue case with isCore: false.

  • Non-system fields still render, in schema order, using friendlyName
    📁 table-view-protection-filter.test.ts:78-89 — asserts full ordered header equality, and the inline comment explicitly calls out that messages still follows status after three intervening system fields are removed. 📁 :166-180 — the "no system fields → completely unchanged" case pins that the filter is a no-op on schemas it shouldn't touch.


Findings

🔴 Critical

None.

🟡 Important

None.

🟢 Suggestions

1. fieldSchemaMap is correctly left unfiltered — worth an explicit note.
📁 packages/desktop-app/src/lib/components/viewers/query-node-viewer.svelte:287-293

I specifically checked this and the judgment is right. fieldSchemaMap is a lookup map (name → SchemaField) consumed at 📁 packages/desktop-app/src/lib/components/query/table-row.svelte:43 keyed by the rendered column name. Filtering it would be a pure no-op for correctness (unreachable keys are simply never looked up), and would introduce a second place where the visibility rule lives — exactly the drift this PR exists to eliminate. Keeping the presentation decision at the presentation layer and the map purely as data is the correct separation of concerns.

Nit: a one-line comment at query-node-viewer.svelte:287 saying the map is deliberately unfiltered because TableView owns column visibility would save a future reader the same trace I just did.

2. Other schema.fields surfaces — I swept them; leaving them out of scope is correct, with one that deserves a follow-up issue.

I grepped every .fields iteration across the desktop-app source. Four other consumers exist:

  • 📁 packages/desktop-app/src/lib/components/query/kanban-grouping.ts:52-59 (eligibleGroupByFields) — no leak. Filters to type === 'enum', and none of the system fields in core_schemas.rs are enums (last_active is datetime, context_tokens number, created_nodes array, capture:* all text, _possible_duplicate boolean). Currently safe, but incidentally so — the enum filter is doing the work for an unrelated reason. If anyone ever adds a system-protected enum field, a Kanban "group by" option appears for a field the user can't set. Low likelihood, low blast radius; genuinely out of scope here.

  • 📁 packages/desktop-app/src/lib/services/relationship-viewer-service.ts:106-109 (fetchTargetSchemaFields) — this one does leak. It returns (schema.fields ?? []).map((f) => f.name) with no protection filter, and those names flow to 📁 relationship-viewer-modal.svelte:266 → candidatesFor() → the per-group "Columns" checkbox picker at 📁 relationship-viewer-modal.svelte:689-698. That is the same class of bug as this PR fixes — a user-facing column offering built from unfiltered schema.fields — on a different surface. It's a narrower exposure (opt-in checkbox rather than a default-visible column, and requires a relationship group whose target type has system fields), which is why I agree it doesn't belong in this PR. Recommend filing a follow-up issue, referencing this PR's isUserVisibleField as the ready-made fix.

  • 📁 packages/desktop-app/src/lib/components/query/query-editor.svelte:170-172 — offers all schema fields as query filter properties. Arguably intentional: filtering on last_active or status is a legitimate power-user query even for backend-owned fields. Different question from "should this be a display column." Correct to leave alone.

  • 📁 packages/desktop-app/src/lib/components/property-forms/task-schema-form.svelte:121 — agreed, correctly left unchanged. The condition is !CORE_FIELD_NAMES.includes(f.name) && f.protection !== 'system', and only the second conjunct is isUserVisibleField. Rewriting it as .filter((f) => !CORE_FIELD_NAMES.includes(f.name) && isUserVisibleField(f)) would be a marginal readability gain against touching an unrelated file — YAGNI says leave it. The existing comment there already cross-references GenericSchemaForm's filter, so the intent is discoverable.

3. headerTexts' reliance on thead th and the leading '' is robust enough.
📁 table-view-protection-filter.test.ts:97-99

I considered whether the empty-string content column weakens the assertions. It doesn't, materially:

  • The full-array toEqual comparisons pin count, order and content simultaneously — strictly stronger than the queryByText checks alone, which is the right choice.
  • thead th is scoped to the header, so TableBody rows can't pollute it. All tests pass nodeIds: [], so no body rows render anyway.
  • The '' entry is explicitly documented at :52 ("The leading '' column is the content/title link column"), matching table-view.svelte:41-43 where content is pushed with label: ''.
  • The all-system case at :166 asserting exactly [''] is a nice touch — it proves the filter can empty the schema columns entirely without breaking the content column.

Nit: the assertion couples to the content column's label being empty. If a future change gives that column a real header ("Title"), all five tests break at once with a slightly opaque diff. Not worth restructuring — the coupling is documented and the breakage would be trivially diagnosable.

4. Naming and home — both right.
📁 packages/desktop-app/src/lib/utils/schema-field-visibility.ts:1-19

isUserVisibleField reads correctly at both call sites (schema.fields.filter(isUserVisibleField) is self-documenting), the is* prefix matches the boolean-predicate convention, and "user-visible" describes the intent rather than the mechanism (protection !== 'system') — which is what lets the predicate absorb future rules without a rename. Siting it beside schema-field-label.ts in $lib/utils/ is consistent, and the doc comment mirrors that file's structure well: it states the single-source-of-truth rule, gives concrete examples (_possible_duplicate, capture:transcript), and explains why rather than what. This is the "Signal Intent" standard done properly.

Nit: schema-field-visibility.ts:14-15 claims "Every UI surface that iterates SchemaNode.fields filters through this." As of this PR that's aspirational rather than literal — task-schema-form.svelte:121 still inlines the check, and relationship-viewer-service.ts:108 doesn't filter at all. Softening to "Every UI surface that decides whether to render a field should filter through this" would keep the comment true as written and avoid a future reader trusting an invariant the code doesn't yet enforce.


Standards Compliance

  • No lint suppression / no any — clean; the predicate is typed (field: SchemaField): boolean.
  • No backward-compat code, no deprecation shims — the inline filter at generic-schema-form.svelte:52 was replaced, not kept alongside. Correct per CLAUDE.md's greenfield rule.
  • No GitHub issue numbers in code comments — verified by grep across all four files: zero matches. Notably better than the sibling test file, which opens with "GenericSchemaForm — protection-level filtering (core#2132)" — this PR's new test correctly omits that pattern. (Commit message and PR body are exempt and correctly use closes #2376.)
  • Documentation location — no new .md files, no docs/ directory. Correct.
  • Testing — DOM test correctly placed under src/tests/, not scripts/; uses vi.mock('@tauri-apps/api/core') per project convention.

Verification Notes

I re-ran the new test file directly (5/5 passing, 19ms) and independently verified the core_schemas.rs fixtures field-by-field rather than taking the claim on trust. I did not re-run test:all or quality:fix. The two pre-existing schema-seeding.e2e.ts daemon-timeout failures and the --no-verify push are documented as reproducing on an unmodified tree with a separate tracking issue — that's the right call, and the source changes here (a pure display-layer filter with no daemon interaction) have no plausible causal path to a daemon RPC timeout.


Recommendation: APPROVE

Net-positive, correctly scoped, well-tested, standards-clean. All acceptance criteria met. The findings above are all 🟢 — none block merge.

The one item worth carrying forward is suggestion 2: relationship-viewer-service.ts:106-109 has the same unfiltered-schema.fields bug on the relationship modal's column picker. Worth a follow-up issue now that the fix is a one-line import away.

@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.

Both findings were 🟢 suggestions; no logic changed.

- schema-field-visibility.ts claimed "Every UI surface that iterates
  SchemaNode.fields filters through this", which is not true as written:
  task-schema-form.svelte still inlines the predicate and
  relationship-viewer-service.ts does not filter at all. Narrowed the claim to
  surfaces that decide whether to *render* a field, and noted that non-render
  consumers (query filter properties) make their own call — so the comment
  states an invariant the code actually holds.

- query-node-viewer.svelte's fieldSchemaMap is deliberately unfiltered, which
  cost both the reviewer and me a trace to confirm. Recorded why: TableView owns
  column visibility, the map is only read by the columns it renders, and
  filtering here would give the visibility rule a second home.

Skipped, with reasons:

- Restructuring the test's headerTexts assertions away from the content
  column's empty label. The review's own analysis lands on not worth it: the
  coupling is documented at the call site and a future "Title" header would
  break the tests loudly and diagnosably.

- Fixing relationship-viewer-service.ts:106-109, which has the same unfiltered
  schema.fields bug feeding the relationship modal's column picker. Verified
  real, but a different surface than this issue covers — filed as #2408 rather
  than widening this PR.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QuokiCVxSgdd5HSQqZuzcf
@malibio

malibio commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

Review addressed — cd5b430b

Review came back APPROVE with no 🔴 Critical or 🟡 Important findings. Four 🟢 suggestions triaged below. No logic changed; both edits are comments.

✅ Addressed (2)

1. Doc comment asserted an invariant the code doesn't hold
📁 packages/desktop-app/src/lib/utils/schema-field-visibility.ts:14-15

The claim "Every UI surface that iterates SchemaNode.fields filters through this" was aspirational, not literal — task-schema-form.svelte:121 still inlines the predicate and relationship-viewer-service.ts:108 doesn't filter at all. A comment stating a false invariant is worse than no comment, since a future reader may trust it. Narrowed to surfaces that decide whether to render a field, and noted that non-render consumers (query filter properties) make their own call.

2. fieldSchemaMap's deliberate lack of filtering was undocumented
📁 packages/desktop-app/src/lib/components/viewers/query-node-viewer.svelte:287

Both the reviewer and I independently traced this to confirm it was correct rather than an oversight. That's the signal a comment was missing. Recorded why: TableView owns column visibility, the map is only ever read by the column names TableView renders, and filtering here would be a no-op that gives the visibility rule a second home.

⏭️ Skipped (2)

3. Restructuring headerTexts away from the content column's empty label
The review's own analysis concludes it isn't worth it, and I agree. The coupling is documented at the call site, and a future "Title" header would break all five tests loudly with a trivially diagnosable diff. Restructuring to avoid a legible failure mode is a net loss.

4. relationship-viewer-service.ts:106-109 — filed rather than fixed
I verified this one rather than taking it on trust: fetchTargetSchemaFields maps all schema.fields to names with no protection filter, and its own doc comment describes the result as "the candidate set for offering target-node columns". Real bug, same class as this issue — but a different surface than #2376 covers, so fixing it here would widen the PR beyond its stated scope.

Filed as #2408, with the one-line isUserVisibleField fix and acceptance criteria written up. The issue also records the two consumers the sweep cleared: kanban-grouping.ts (safe, but only incidentally — its type === 'enum' filter excludes every current system field, so a future system-protected enum would leak) and query-editor.svelte (offers system fields as query filters, which is defensible and distinct from display).

Verification

  • bun run test — 231 files / 4857 tests passing. Baseline at branch start was 230/4852, so +1 file and +5 tests are exactly this PR's additions, no regressions.
  • bun run quality:fix — clean: 2495 files, 0 errors, 0 warnings, tsc --noEmit clean, clippy -D warnings clean.
  • Pushed with --no-verify again, for the same pre-existing schema-seeding.e2e.ts daemon-timeout failures noted in the PR description (already tracked separately). Comment-only changes have no path to a daemon RPC.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: The two changes are comment text only — zero logic, zero behavior, zero API surface. Both make existing comments more accurate rather than introducing new claims. The full frontend suite and quality gate were re-run after the edits and are clean against baseline. The one substantive finding was deliberately routed to a follow-up issue rather than implemented here, so this PR's diff is unchanged from the approved review apart from prose.

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.

Table view renders protection:system schema fields as user-facing columns

1 participant