Skip to content

perf(birth): place a lifecycle birth on the live engine, no full-world checkpoint (Scaling A13) - #2624

Draft
genekogan wants to merge 2 commits into
mainfrom
agent/2621-live-birth-placement
Draft

genekogan wants to merge 2 commits into
mainfrom
agent/2621-live-birth-placement

Conversation

@genekogan

@genekogan genekogan commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Problem

When a Soul is born through the lifecycle (the account and Eden capabilities path), a busy world runs probeNativeHumanBirth two or three times per birth: a full snapshot of the world, then a restore that rebuilds the spatial ground. On Eden 2026 with 50 Souls acting, that is about 6 to 7 s of the clock thread per birth. At even one create a second the world goes black and restarts (exit 75), and 0 of 100 creates complete. This PR places the birth on the live engine instead. Closes #2621.

Acceptance

  • A1 An oracle test across many births in Eden 2026 (and a crowded variant): birthPlacementV1 on the live engine agrees with probeNativeHumanBirth's outcome (placement or refusal) on every case. State hashes are equal with the change off and on over the walk goldens and the birth tests. — evidence:
    • node --test apps/server/src/birth-placement-eden.test.ts -> pass, 32 births on Eden 2026 compared: {"ready":30,"unavailable":2}. That is 16 plain births while a Soul walks, the arrival rings crowded until a birth is refused, and both hinted forms.
    • node --test packages/engine-mars/src/birth.test.ts -> 10/10 pass. The crowd fills the arrival point on green field (91 ready, 4 refused, 4 hinted), on the legacy commons (13 ready, 4 refused, 4 hinted: the humanBirthIssue refusal) and on the safe commons (83 ready, 4 refused, 4 hinted). Existing, conflicting and deferred births are also covered. On every case the live outcome deep-equals the probe's, the state hash and tick are unchanged, and spawnHuman lands where the placement said.
    • node --test apps/server/src/lifecycle-runner.test.ts -> 24/24 pass. A new test runs lifecycle births with SIM_BIRTH_PROBE=1 (off), unset (on) and =oracle: the events, poses, engine state hash and kernel hash are equal.
    • SIM_BIRTH_PROBE=oracle node --test packages/engine-mars/src/birth.test.ts packages/engine-mars/src/arrival-clearance.test.ts apps/server/src/lifecycle-runner.test.ts -> 35/35 pass, with every placement checked against the probe.
    • Walk goldens: spawnHuman's search is now an extraction with the same statements in the same order, and it has no switch. node tools/test-harness/walk/walk.mjs -> "walk: no place worse than the baseline". The hash-pinned engine tests (hash, commons-kitchen, terrain, water-geometry) pass 47/47, run together with arrival-clearance, commons, connected-shore-engine and commons-arrival.
  • A2 No full-world snapshot or restore on the birth path; the probe runs only under a test or oracle flag. — evidence: on a world with no ground or paged ground (Eden 2026 and every default ground world: NAV_PAGED defaults on), the guard (lifecycle-runner.ts) and the preview (arrival-placement.ts planNativeBirth) call nativeBirthPlacement, which runs the probe only when SIM_BIRTH_PROBE is 1 or oracle. Test "A13: the birth path never snapshots or restores…" -> 0 snapshots and 0 restores by default. Test "four pending births … with no detached probe" -> 0 restores for four lifecycle births, against 8 with SIM_BIRTH_PROBE=1. One exception: a world on whole (non-paged) ground (NAV_PAGED=0) keeps the probe, because there the live search grew the ground window and moved the navigation epoch (review finding on this PR). Test 'A13: on whole (non-paged) ground…' covers it: same navigation and the same later far walk as a twin that never placed a birth. The oracle tests also assert the live placement leaves the epoch and window unmoved.
  • A3 Bars declared before the runs (settled --wave, 100 creates at 1 a second with 50 acting, 2 repeats, base against candidate): clock ms per birth down at least 80 %; no black and no exit 75 at 1 a second; creates completed reported. — pending: the bars and the scoring rule were declared on the issue before any run (comment 6922107940). Eight runs were dispatched in one batch, uniform and event shapes × base and candidate × seeds 1 and 2 (comment 6922120597).

Proof

Tier: T3 (node tools/proof/tier.mjs; the coordinator expects T4 for the engine core)

  • proof.json: to follow with the A3 runs
  • clips: pending, from timed-run clip with the kit join-burst (12 Souls join Eden 2026 one a second, on the candidate). The kit lives only on the proof branch agent/2621-clip, not in this PR.
  • images: none
  • playtest: the A3 timed runs (2 repeats per arm, base and candidate, even and uneven shapes)

Self-audit

  • Checks run:
    • tsc --noEmit -p packages/engine-mars -> clean
    • tsc --noEmit -p apps/server -> clean
    • the tests listed under A1 -> all pass
    • node tools/test-harness/walk/walk.mjs -> no place worse than the baseline
    • node tools/changelog/compile.mjs --check -> 39 valid fragments
  • Failed attempts: the first head (f07c43d) let the live search run on whole (non-paged) ground, where it moved the navigation epoch. The review caught it, and 2c903b7 keeps the probe there. The A3 candidate runs measure f07c43d; for Eden 2026 on paged ground the code path is the same.
  • Long tail / externalities:
    • Each birth still runs spawnHuman's search twice: once in the guard and once in the apply. That is two walk_to plans per ring spot tried, and it is A8a's proposed follow-up 2.
    • The one-birth-at-a-time pacing in LifecycleRunner is unchanged.
    • Direct (non-lifecycle) creates are unchanged; they never probed.
  • Known limits:
    • A birth during non-resumable native activity is still deferred, as the probe deferred it (birth.checkpoint-required). Keeping that answer is what makes this no rule change. The live placement no longer needs a checkpoint, so dropping the deferral would be a later rule change with its own id.
    • The off/on hash comparison runs over the lifecycle birth tests. The walk gate covers the spawnHuman extraction, which has no switch.
  • Docs: docs/architecture/engine-contract.md gets a Birth placement line documenting SIM_BIRTH_PROBE=1 (rollback) and =oracle. The code comments in lifecycle-runner.ts, arrival-placement.ts, birth.ts and engine.ts are updated.

Changelog

changes/2621-birth-on-live-engine.md (perf)

Risk

  • What could break: a live placement that differed from the probe would put a birth in a different spot, or refuse it differently. It cannot differ from the apply, because the guard runs the apply's own search on the same state just before it, with no engine change in between.
  • How it is tested: the oracle tests compare against the probe on Eden 2026, the commons and green field, plain and crowded. SIM_BIRTH_PROBE=oracle checks it live.
  • Rollback: set SIM_BIRTH_PROBE=1 on the world (the probe decides again), or revert this PR.
  • Why the playtest covers it: the A3 waves run real lifecycle births at 1 a second on a busy Eden 2026, the journey that went black.

Time: started 16:05 UTC. Work so far is about 0.5 h of the 4 h ceiling (draft at 16:25, review fixes 16:30-16:40 UTC), not counting runner waits. The A3 runs are still queued.

Outside Touches:

  • packages/engine-mars/src/engine.ts: spawnHuman's search extracted, plus birthPlacementV1. The design names it ("move spawnHuman's placement into a read-only birthPlacementV1 on the live engine").
  • apps/server/src/arrival-placement.ts: the runner's preview (planNativeBirth) lives there.
  • apps/server/src/birth-placement-eden.test.ts: a new test for the birth path.
  • docs/architecture/engine-contract.md: one line documenting the flag (the coordinator asked for it).

🤖 Generated with Claude Code

…d checkpoint (Scaling A13)

The lifecycle guard in drainInputs and the runner's preview ran probeNativeHumanBirth, a full
snapshot and restore of the world, two or three times per birth (about 6-7 s of clock per birth
on Eden 2026 with 50 acting). They now run MarsEngine.birthPlacementV1: spawnHuman's own placement
search on the live engine, changing nothing, with the probe's verdict (humanBirthIssue) at the spot.
The probe stays as the oracle: SIM_BIRTH_PROBE=1 decides by it, =oracle checks every placement
against it. Same outcome, same reasons: no rule change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@genekogan genekogan added the ci:run Open the CI window: run this ready PR's heavy CI jobs (docs/testing.md#ci-window) label Nov 16, 2026
…e navigation is unmoved (#2624 review)

On whole ground the live search grew the ground window to the trial body and moved spatial.epoch,
so a later far walk could be refused live and admitted on replay. nativeBirthPlacement now uses the
probe there (livePlacementExact: no ground, or paged ground); placeNativeHumanBirth refuses it. The
oracle tests also assert the epoch and window are unchanged by the live placement. engine-contract.md
documents SIM_BIRTH_PROBE=1 (rollback) and =oracle.

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run Open the CI window: run this ready PR's heavy CI jobs (docs/testing.md#ci-window)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scaling A13 · A Soul's birth costs a busy world 6–7 s of clock (full-world probe); place births on the live engine instead

1 participant