Skip to content

Field-value references (Connected To, Related Project, etc.) not indexed as graph edges #100

Description

@evielync

Version: 2.5.10

Description

Field-value node references — fields like Connected To, Related Project, Related People, Arena, Task Arena — are stored correctly in the field_values table but are never added to the references table. This means tana_related returns no connections for any relationship established via a reference-type field, even when those connections are clearly visible in Tana.

Steps to reproduce

  1. In Tana, create a node (e.g. an #issue) and set its Connected To field to a #thread node
  2. Call tana_related with the issue node's ID
  3. Observe: the thread connection does not appear in results

Root cause

The references table is only populated with inline_ref type entries (nodes mentioned inline in text as [[Node]]). Reference-type field values — where field_values.value_node_id points to another node — are not indexed here.

Scale of the gap:

-- Inline refs indexed (all that's currently in references table)
SELECT COUNT(*) FROM references WHERE reference_type = 'inline_ref';
-- Result: 5,793

-- Field-value references NOT indexed (missing graph edges)
SELECT COUNT(*) 
FROM field_values fv
JOIN nodes n_from ON fv.parent_id = n_from.id
JOIN nodes n_to ON fv.value_node_id = n_to.id
WHERE fv.value_node_id != '' AND fv.value_node_id != fv.value_text;
-- Result: 552,178

Top missing reference fields by count:

  • Related People: 5,486
  • Related Project: 4,069
  • Arena / Task Arena: 6,798 combined
  • Connected To: 307
  • Project: 217

Expected behaviour

tana_related should surface connections made via reference-type fields, not just inline text mentions. If I've explicitly connected an issue to a thread via the Connected To field, that relationship should be traversable.

Workaround

I'm currently running a post-sync script that injects field-value references into the references table as inline_ref edges after supertag sync index rebuilds it:

INSERT OR IGNORE INTO references (from_node, to_node, reference_type)
SELECT DISTINCT fv.parent_id, fv.value_node_id, 'inline_ref'
FROM field_values fv
JOIN nodes n_from ON fv.parent_id = n_from.id
JOIN nodes n_to ON fv.value_node_id = n_to.id
WHERE fv.value_node_id != '' AND fv.value_node_id != fv.value_text;

This injects ~550K edges and tana_related correctly surfaces field-value connections after. But it needs to run after every full reindex.

Suggested fix

During supertag sync index, when building the references table, also iterate field_values and add a field_ref (or separate type) entry for each row where value_node_id is a valid node reference. Ideally with the field name encoded so graph traversal can filter by relationship type (e.g. CONNECTED TO "thread" VIA "Connected To").

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions