Skip to content

test: Phase 4 exit-criteria sweep and long-run hardening (Phase 4, PR 5/5) - #101

Merged
CodeByBryant merged 1 commit into
mainfrom
test/genetics-hardening
Oct 24, 2026
Merged

CodeByBryant merged 1 commit into
mainfrom
test/genetics-hardening

Conversation

@CodeByBryant

Copy link
Copy Markdown
Owner

Summary

Fifth and final Phase 4 PR. Test-only: no source changes, no behavior changes, no golden changes. It closes the phase by checking every roadmap exit criterion end to end on a real running world, and by hardening the long-run determinism suite for genomes and lineage.

Exit-criteria sweep (phase4-exit-criteria.test.ts, 17 checks)

Births are audited by stepping a world one tick at a time and remembering every living genome from the previous tick, so each child's parents are known exactly as they were at conception even if they die later. Over 6,000 ticks (25+ audited births) it checks, per birth:

  • Inherits from both parents: every scalar gene lies within the blend of the parents' values plus a mutation allowance; brain weights come from both parents (in every single birth); both parent genomes are recorded, ascending.
  • Compatible neural weights: the parents' architecture and weight count are kept.
  • Mutations stay in range: every child genome validates; the whole world validates.
  • Genomes can be compared: distances stay in [0, 1] on every axis; a child is closer to each parent than the parents are to each other, and its brain far closer than unrelated founders' brains are.
  • Lineage survives parent death: the record of a parent that has since died is still there, with its child among its descendants.
  • Learning inheritance is configurable: default partial / 0.15, all three modes accepted, anything else rejected, and the three modes give three different results.
  • No unrelated fresh brains: ~95% of a child's weights are its parents' own (matching the 5% weight mutation rate) and essentially none match a freshly drawn brain.

The eighth criterion (broad unit-test coverage) is the contents of tests/genetics/, lineage.test.ts and traits.test.ts; docs/genetics/genome.md now has a table mapping each guarantee to the test that checks it.

Long-run additions (determinism suite, 4 new tests)

  • Chunked vs direct runs now also match on the lineage store, which is deliberately not in the state hash, so its equivalence is asserted explicitly (size, founders, a record, ancestry, and the historical records).
  • Genomes stay valid, and every trait mean stays within 0.35 of its range width of baseline over 100,000 ticks. I measured the worst case first: 0.20 on one seed and 0.10 on another, so the bound has real margin. The lineage also has exactly one record per genome ever created.
  • Genomes stay valid under ten times the default mutation rate and strength (30,000 ticks, validated every 250).
  • After extinction the whole lineage stays queryable (every founder lineage extinct, every record and parent link present) and does not change over 80,000 more ticks.

Test plan

  • pnpm format:check clean in a fresh clone
  • pnpm check green in a fresh clone: 7 contracts, 55 config, 441 simulation
  • pnpm build green (all 8 packages/apps)
  • pnpm test:determinism: 21/21 (17 existing plus 4 new)

This completes Phase 4 (genetics and inheritance).

🤖 Generated with Claude Code

Phase 4 PR 5, test-only. Closes the phase by checking every roadmap exit
criterion end to end on a real running world, and by hardening the long-run
determinism suite for genomes and lineage.

phase4-exit-criteria.test.ts audits births by stepping a world tick by tick
and remembering every living genome from the previous tick, so each child's
parents are known exactly as they were at conception even if they die later.
Over 6,000 ticks it checks, per birth: scalar genes lie within the blend of
the parents' values plus mutation; brain weights come from both parents;
the parents' architecture and weight count are kept; the genome is valid;
the child is closer to each parent than the parents are to each other, and
its brain far closer than unrelated founders' brains are; roughly 95% of its
weights are its parents' own and essentially none match a freshly drawn
brain; and lineage records survive parent death. The learning-inheritance
mode is configurable, accepts all three modes, rejects others, and produces
three different results.

Long-run suite additions: chunked and direct runs now also match on the
lineage store (which is deliberately not hashed); genomes stay valid and
every trait mean stays within 0.35 of its range width of baseline over
100,000 ticks (measured worst case on two seeds: 0.20); genomes stay valid
under ten times the default mutation rate and strength; and after extinction
the whole lineage stays queryable and does not change over 80,000 more ticks.

docs/genetics/genome.md gains a map from each guarantee to the test that
checks it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 24, 2026 03:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@CodeByBryant
CodeByBryant merged commit 637504a into main Oct 24, 2026
11 checks passed
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