[BUG] tag_applications drops 100% of applications for tags using `extends` — 3-child definition tuple never enters the tag registry
Summary
For my workspace's #book tag, tag_applications reports 0 rows, but the raw tuple data in nodes contains 1,150 correctly-formed tag-application tuples for that exact tag ID. The tag isn't empty — the indexer is silently failing to register any of its applications. I traced this to how the tag itself is registered when it uses extends (my #book tag extends a #source tag), and I think I can pin down the exact mechanism.
Symptom
SELECT COUNT(*) FROM tag_applications WHERE tag_id='<my-book-tag-id>'→ 0- But
SELECT COUNT(*) FROM nodes WHERE json_extract(raw_data,'$.children[0]')='SYS_A13' AND json_extract(raw_data,'$.children[1]')='<my-book-tag-id>'→ 1,150 - A live
search_nodesquery for the same tag returns over a thousand real nodes — so the data and the live app both agree the tag is heavily used. Only the derivedtag_applicationstable disagrees. - This is not a general problem with my graph: other tags in the same workspace keep 92–99.96% of their applications (a "highlights" tag keeps 8,058 of 8,061; an "author" tag keeps 1,117 of 1,125). One specific tag drops from 100% to 0%.
What's different about the tag that breaks
The tag that breaks (#book) is defined with extends — it inherits from another tag (#source). I compared its underlying tuple shape to a tag that works fine:
- A working tag's own-definition tuple has 2 children:
["SYS_A13", "SYS_T01"] - The broken tag's own-definition tuple has 3 children:
["SYS_A13", "SYS_T01", "<parent-tag-id>"]— the extra element is the tag it extends
I believe whatever internal registry maps a tag ID to "this ID is a real supertag, index its applications" is built by scanning for tuples that match the 2-child shape exactly. A 3-child tuple (which is what any tag using extends produces) doesn't match, so the tag never enters that registry — even though the tag's own applications (the actual per-node tag-assignment tuples, which are separate from this definition tuple) are completely normal 2-child tuples and clearly present in the data.
Confirming that this is a registry-membership problem and not a general "extends" bug: I found an empty duplicate of my book tag (0 real applications) that happens to be registered correctly, apparently because IT was originally created without extends and only later configured to extend #source, leaving its OWN definition tuple in the older, unextended 2-child shape. So the same workspace has two versions of "the book tag" — the real one (1,150 applications, unregistered) and an empty stand-in (0 applications, registered) — and any tool that trusts the registry silently picks the empty one.
I counted across my whole graph: 68 tuples use this 3-child extends shape, across several different tags. I'd expect all of them to have the same problem to varying degrees, though #book is the most dramatic case I found (100% drop; a full accounting across all 68 wasn't practical for me to do by hand).
What I checked to rule out other causes
- The tag applications themselves are structurally identical to a working tag's applications — same
_docType, same shape, same relationship to their owner node. I compared one directly against a working highlight-tag application and they match field-for-field except for the tag ID. - The tag's metadata IS present elsewhere in the index — there's a separate table that correctly lists the tag's name, its parent (the
#sourcetag it extends), and its fields. So the indexer clearly knows the tag exists and knows what it extends; it just isn't using that knowledge to also index the tag's applications. - Registry membership isn't strictly required for other tags to keep their applications — I found one tag with 0% registry presence that still keeps 99.3% of its applications, so there's likely a secondary path that makes this work for most tags. Whatever that path is, it isn't reached for the extends-shaped tags. I wasn't able to fully close this last piece — it's possible there's an additional contributing factor I haven't found, but the registry-shape mismatch is clearly real and clearly correlates with the drop.
Reproduction
- Create a tag
A(noextends). - Create a tag
Bthat extendsA. - Apply
Bto several nodes. - Query the derived tag-applications data for
B's applications. - Compare against a raw scan of the underlying node data for tuples referencing
B's ID directly.
Expected: the derived count matches the raw count.
Actual (in my workspace): the derived count is 0 regardless of how many real applications exist, whenever the tag being applied uses extends.
Impact
Any integration, export, or automation that reads tag membership through the derived/aggregate layer (rather than scanning raw node data directly) will see zero results for any extends-based tag with this shape, no matter how heavily it's actually used in the graph. For anyone using tag inheritance as a modeling pattern (e.g., "a book IS a source, plus book-specific fields"), this makes the child tag invisible to that read path entirely.
What would help
Either: (a) have the tag-registration scan also match the 3-child extends-shaped definition tuple, so extends-based tags get indexed the same as plain tags, or (b) if there's a reason the two need different handling, at least have the derived-applications count reconcile against the raw tuple data so a total miss like this surfaces as a warning instead of a silent, indistinguishable-from-real-zero result.
Happy to share the exact tag IDs / a redacted export if useful — I did all of the above against a local read-only copy of my own index, no changes made.
Thanks for digging into this. I checked current main (v2.5.11), and there's no 2-child-shape check in tag registration. buildGraph (src/parsers/tana-export.ts) uses flags for whether a child list contains SYS_A13/SYS_T01/SYS_T02, regardless of how many children there are. So a [SYS_A13, SYS_T01, parentId] tuple is registered as a supertag, with the parent recorded as its superclass.
The 0-applications symptom is real, but the cause must be somewhere else, and I don't want to guess at it. Could you share a redacted sample:
- the
#booktag definition node and its own-definition tuple, - one or two of its application tuples with their owner nodes (
props+children), - the matching rows from
supertagsandsupertag_parents?
I'll build a fixture from that and track down where the applications are lost.
Follow-up: #123 is the likely cause of the "an empty duplicate is registered" symptom.
buildGraph keys the supertags map by tag name. When two tagDefs share a name, the later one overwrites the earlier one, so supertags lists only one of them, often an empty duplicate, while tag_applications keeps the applications under the real tag ID. A tool that resolves the tag by name through that registry then lands on the empty one.
The 0-applications count itself did not reproduce. On a workspace with 136 extends-shaped tags, 96% of applications were kept, and every dropped node was trashed or missing from the export.
Could you check whether your workspace has more than one tag named book (for example in supertag tags show book, which lists duplicates with their IDs)? That would confirm #123 is what you hit.
I think I found it, and it isn't the extends shape or #123.
There's one live tag named book (prTgdAQeTOTL). The other tagDefs named "book…" are in the trash, most renamed "book(deprecated) (merged into #book)". On v2.6.0, after a sync index of a fresh export (2026-11-17), book still has 0 of 1,450 applications in tag_applications and no row in supertags. 54 other tags with a 3-child definition tuple register fine, so the shape isn't it.
What book has that they don't: the workspace _TRASH node's children list includes prTgdAQeTOTL, even though the tag's _ownerId chain is live and never reaches the trash. buildGraph adds every trash child to trash, so it skips the tag's own tuple (trash.has(tagId)) and every application (trash.has(childId)). That happens in the graph itself, so a from-scratch reindex wouldn't help book. article (PFDxJcmymr34) and recipe are on the same list and missing too. Across the export, the trash lists 161,201 children, and 115 of them aren't owned by the trash: 57 aren't in the export at all, and of the rest about 45 sit under live nodes. My guess is they're leftovers from merging duplicate tags.
One possible fix: count a node as trashed only when its _ownerId is the trash node (or its owner chain reaches it), not just because it's on the trash's list.
podcast isn't on that list, and it's missing from supertags too, but it keeps all 8 of its applications. I think that one is left over from the 2.5.11 index rather than a second cause: sync index took the change-detection path (node_checksums already existed), which only rewrites supertags rows for changed tuples, and podcast's tuple didn't change. If that's right, a from-scratch reindex would bring it back. Happy to send a redacted slice for a fixture if that's useful.