Skip to content

Strands: index the registry by child worldline #902

Open

Description

@flyingrobots

Raised by CodeRabbit on PR #890 (#890 (comment)). StrandRegistry::find_by_child_worldline scans every strand. The occurrence-inheritance walk calls it once per ancestry level, and once on every occurrence admission without a local binding, so admission costs O(strands × depth). The trusted host caps strands at 64, so this is bounded today.

Now that StrandRegistry::insert enforces one relation per child worldline (ChildWorldlineAlreadyRelated, #890), the relation is a function. Keep a BTreeMap<WorldlineId, StrandId> index, maintained in insert and remove, and back find_by_child_worldline with it, so the walk is O(depth · log n) and stays deterministic.

Acceptance: the index stays consistent across insert, remove and recovery; existing strand tests pass.

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

    taskSmall, 1–3h task

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions