jcfischer / jcfischer/supertag-cli
Field-value references (Connected To, Related Project, etc.) not indexed as graph edges
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 49
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
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
- In Tana, create a node (e.g. an
#issue) and set itsConnected Tofield to a#threadnode - Call
tana_relatedwith the issue node's ID - 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,486Related Project: 4,069Arena/Task Arena: 6,798 combinedConnected To: 307Project: 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").
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the supertag sync index entry point and trace how the field_values and references tables are populated. Verify how tana_related reads graph edges, then ensure valid field-value node references are indexed and confirm that those connections appear in related-node results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100