Skip to content

Do not count injector references in removeUnreachableGenesFromRoot#788

Merged
chrxh merged 1 commit into
developfrom
claude/unused-genes-injector-reachability
Jul 8, 2026
Merged

Do not count injector references in removeUnreachableGenesFromRoot#788
chrxh merged 1 commit into
developfrom
claude/unused-genes-injector-reachability

Conversation

@chrxh

@chrxh chrxh commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • removeUnreachableGenesFromRoot used to treat an Injector node's geneIndex as a reachability edge, so any gene it targeted (and everything reachable from that gene via constructor chains) was kept alive even if unrelated to the creature's own body.
  • An injector's referenced gene is a payload for a foreign creature; it should not protect genes from pruning in the host's own genome.
  • Repro: D:/dev/claude/examples/UnusedGenes.genome has 5 genes only bridged in via an injector reference; before this change, removeUnreachableGenesFromRoot kept all 13 genes instead of pruning the 5 unreachable ones.

Changes

  • MutationProcessor.cuh: reachability marking (removeUnreachableGenesFromRoot) now only follows constructor references, not injector references. The remap step now falls back to gene 0 if an injector ends up pointing at a removed gene.
  • UnusedGeneRemovalTests.cpp: inverted keepsGeneReferencedByInjector into removesGeneOnlyReferencedByInjector, and added keepsGeneReferencedByInjectorAndConstructor to confirm a constructor reference still keeps a gene alive independent of any injector reference to it.

Test plan

  • EngineTests.exe --gtest_filter=UnusedGeneRemovalTests.* (7/7 pass)
  • Full EngineTests.exe suite (3074 passed, 3 pre-existing unrelated skips)
  • clang-format --dry-run --Werror clean on both touched files

🤖 Generated with Claude Code

An injector's gene reference is a payload for a foreign creature, not
part of this creature's own construction graph, so it must not keep
the referenced gene alive during root-reachability pruning.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@chrxh chrxh marked this pull request as ready for review July 8, 2026 18:34
@chrxh chrxh merged commit a3d4b99 into develop Jul 8, 2026
1 check passed
@chrxh chrxh deleted the claude/unused-genes-injector-reachability branch July 8, 2026 18:35
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.

1 participant