Skip to content

Refactor indexing methods for clarity ahead of "transitive" indexing - #1066

Merged
myronmarston merged 2 commits into
block:mainfrom
marcdaniels-toast:prep-refactor-index-naming
Mar 4, 2026
Merged

Refactor indexing methods for clarity ahead of "transitive" indexing#1066
myronmarston merged 2 commits into
block:mainfrom
marcdaniels-toast:prep-refactor-index-naming

Conversation

@marcdaniels-toast

Copy link
Copy Markdown
Collaborator

Summary

Refactors indexing-related methods to clarify their semantic intent ahead of transitive indexing support (related to #1029).

Changes

  • Renames index_def to own_index_def to clarify it returns nil for types that inherit indexing from abstract parents
  • Splits indexed? into two more precisely-named methods:
    • has_own_index_def? - checks if a type has its own index definition (not inherited)
    • root_document_type? - checks if a type is queryable at the document root in the datastore
  • Updates all call sites to use the appropriate method based on semantic intent

Context

This prep work makes the distinction between "has own index" vs "is queryable at root" explicit. When we implement transitive indexing (letting a parent type's index setting cascade to its subtypes), root_document_type? will expand to also return true for types that inherit indexing from their parents. Today it already returns true for abstract types whose subtypes are indexed; with transitive indexing, it will also return true for concrete subtypes that inherit their parent's index.

The intent is we can keep the semantics consistent during the implementation of this feature: root_document_type? means "is this type queryable at the document root?" regardless of whether that's via its own index, inherited from a parent, or because its subtypes are indexed.

Renames `index_def` to `own_index_def` to clarify it returns nil for types that inherit indexing from abstract parents. Splits `indexed?` into `has_own_index_def?` (checks for own index definition) and `root_document_type?` (checks if queryable at document root). This makes the semantic intent clearer at each call site and prepares the codebase for transitive indexing support.

Related to #1029

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

@myronmarston myronmarston left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 Thanks for taking the time to spin this off. Left a few minor suggestions!

Updates terminology and naming throughout the codebase based on PR #1066 review feedback to use "root document type" consistently instead of "indexed" where semantically appropriate.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

@myronmarston myronmarston left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I'll merge once the build passes.

@myronmarston
myronmarston merged commit 6f78637 into block:main Mar 4, 2026
30 of 32 checks passed
@marcdaniels-toast
marcdaniels-toast deleted the prep-refactor-index-naming branch March 6, 2026 18:19
jwils added a commit that referenced this pull request Apr 23, 2026
Distills the patterns Myron Marston applies when reviewing merged PRs
(naming at the caller's level of abstraction, respond_to? as a code
smell, wrapper-class DI pattern, load-bearing tests, RBS/YARD hygiene,
etc.) into an edit-first skill.

Invoked as /myron-polish, the skill walks the current branch's diff
against main and applies fixes directly rather than producing review
comments. It loops — re-scan, apply edits, run script/lint --fix /
script/spellcheck -w / script/type_check / script/run_gem_specs — until
a full iteration makes zero edits and every verification command passes.
Capped at 8 iterations.

Source material: Myron's review bodies and inline comments on merged
PRs #974, #973, #1067, #1066, #1108, #1120, #1131, #1134, #1144, #1107.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants