Repository navigation
Description
Part of #1732.
Scope
Core can settle seeds in the background: it decides which quick seed to settle and when, holds the reservation and claim, stops on daemon stop, nuke and memory pressure, and reports settled and leases in doctor --json. Drivers do not offer the verbs yet, so nothing settles until #1747 or #1748 lands; a worker behaves as today.
If this goes wrong, a user would notice a background settle starting while leases boot, a full device's RAM held under memory pressure, or a daemon stop that hangs.
Technical spec
Commit fb42676.
Rows
- Behaviours: B1, B2, B3, B4, B5, B6, B7, B8, B9, B23
- Stored state: S5
- Interfaces: I1, I2, I3, I4, I5, I6, I10, I11, I12, I13
- Existing code: X12, X13, X14, X15, X16, X17, X18, X24, X26
Facts
| # | Fact | Source |
|---|---|---|
| F1 | The doctor report's source object is a zod object with kind seed | baseline, inside sources (at most 100 000) |
src/contract/report-schemas.ts:119-134 |
| F2 | The memory pressure reader the warm pool takes has current() and onReading() |
src/core/core-ports.ts:25-42 |
| F3 | The warm pool's test harness builds a fake memory pressure with current and onReading |
src/core/warm-pool/test-fixtures.ts:114-124 |
| F4 | PowerShell CIM reads on Windows go through the process runner with a bound, and a failed read is an error the caller handles | src/ports/host-load.ts:164-181 |
Modules touched
Searches: tryReserveProvisioning, onReservationsChanged, closeWarmPool, NukeServiceOptions, DoctorSource, doctorSourceSchema, MemoryPressureReader, diskFree, DriverDiscoveryContext, EventMap, EVENT_NAMES.
Also: createCore's handle exposes the settler as seedSettler for the daemon (#1749 reads it); worker-composition.ts builds one NodeProcessTable and passes it through DriverDiscoveryContext (src/daemon/driver-discovery.ts), so #1747 and #1748 each add it to their own driver's create options; website/src/content/docs/docs/reference/cli.mdx (the doctor sources fields, line 500) gains settled and leases.
flowchart LR
P[ports/process-table] --> I[core/idle-watch]
C[core/capacity] --> S[core/seed-settle]
S --> N[core/nuke-service]
S --> K[core/create-core]
K --> W[daemon/worker-composition]
D[core/driver + contract/report-schemas] --> S
Rules in play
- architecture.md rule 16:
nextSettle(I6) is the pure policy, the settler the mechanism. - architecture.md rule 18:
src/core/seed-settle/index.tsexports onlycreateSeedSettlerand its types. - architecture.md rule 11:
listSourcesis bounded at 60 s inside the settler;NodeProcessTablebounds each read. - architecture.md rule 9 and ports manual:
psand PowerShell only through the new port. - core manual "No driver I/O inside it": the reservation and claim are taken in
decisions.run; the driver call is outside it. - ADR 0068 §3 and §4: a settle starts at
noneonly and is aborted atnew-devices-paused. - ADR 0090 §2: one settle per worker, the quiet rule, the reservation and claim.
- events.md rules 1, 3, 6 and 8: subject plus past-tense fact,
seed.settle-endedafter the driver's swap is committed, self-contained payloads, both catalogs in this PR. - contract manual "Protocol version": I1's schema change bumps
PROTOCOL_VERSION_RANGEby one.
Tests
The settler is driven through createSeedSettler with a fake driver, fake clock, a real CapacityCoordinator and the fixtures of src/core/warm-pool/test-fixtures.ts, modelled on src/core/warm-pool/converger-memory-pressure.test.ts.
- B1: core settles the most-leased quick seed in the background: two candidates; 0 leases, settled, stale, orphan; a reservation under way; one taken and released between checks; released 4 min 59 s ago, then 5 min;
warming-paused,new-devices-paused; disk under and at the threshold; a driver with no settle verb; the reservation refused;listSourcesthrows;listSourcespast 60 s; gates shut (nolistSourcescall) - B2: one settle at a time: a second candidate; a lease's reservation mid-settle; two platforms
- B3: reservation and component claim for the whole run: settled; driver throws; aborted;
component removemeanwhile; an operator make then settle - B4: daemon stop: mid-settle (awaited before driver dispose); none running; an operator waiting
- B5: a failed settle waits an hour: driver throws; within the hour; after it; an operator call within it
- B6: memory pressure mid-settle:
new-devices-paused;warming-paused; back tonone; an operator's settle aborted; an operator's make under way - B7: nuke holds the settler: nuke during a settle; none running; an operator waiting
- B8:
doctor --jsonlistssettledandleases: a quick seed with 3 leases; a settled seed; a baseline - B23: every settle emits
seed.settle-startedandseed.settle-ended: settled; cap; failed; aborted by memory pressure, daemon stop and nuke; an operator settle; an operator call for a settled kind (no event) - B9: the idle check and the process table: idle at 181 s; a wave then idle; an exited process; root not found; the cap;
pstime formats; a PowerShell answer; a timed-out read
Done when
pnpm test:changedpasses, with the B1 to B9 cases above.pnpm typecheckpasses.docs/internal/EVENTS.mdandwebsite/src/content/docs/docs/reference/events.mdxlistseed.settle-startedandseed.settle-endedwith I13's payloads,src/bus/index.ts'sEventMapandsrc/bus/index.test.ts'sEVENT_NAMEShold them.PROTOCOL_VERSION_RANGEinsrc/contract/protocol.tsis one higher than before this PR.pnpm --dir website install && pnpm --dir website build && node website/scripts/check-openapi.mjspasses, andcli.mdx's doctorsourcesfields listsettledandleases.- A worker on this branch with today's drivers starts, leases and stops as on main (
pnpm test:e2e e2e/daemon-lifecycle.test.ts e2e/lease-lifecycle.test.ts).
Out of scope
- The drivers'
settleSeedandensureSeed(iOS: a quick seed is replaced by its settled copy, and each plain lease counts against its seed #1747, Android: a quick seed's snapshot is saved again from an idle copy, and copies and deletions take turns #1748). seed.makeandsimlock seed(simlock seed makes and settles a kind's seed on a worker #1749).
Depends on
Written by an agent.
Activity
test: one settle at a time (#1746)
test: a settle holds a reservation and a component claim for its whol…
feat(core): a settle holds a reservation and a claim, and an operator…
test: a daemon stop ends the settler (#1746)
feat(core): a daemon stop ends the settler and fails an operator's wa…
test: a failed settle waits an hour (#1746)
feat(core): a failed settle is logged and its seed waits an hour (#1746)
test: memory pressure mid-settle (#1746)
feat(core): memory pressure aborts a running settle and sends an oper…
test: a nuke holds the settler (#1746)
4 remaining items
feat(ports): a process table and an idle watch over a booted tree's C…
test: the warm pool's dispose test counts the seed settler's timer (#…
refactor(core): split the settler's run and shrink the process table'…
refactor(core): split the settler's operator make from its choice (#1746
test: the settler's gates, grandchild CPU and the 500-character messa…
test(daemon): a daemon stop awaits a running seed settle before the d…
fix(core): an operator's settle joins the running settle, its failure…
refactor(core): split the settler's failure path and the policy's clo…
test(daemon): the shutdown test's driver returns on a timer, so it fa…
github-actions commentedon Nov 23, 2026
Claim released: no activity for 3 days. The label is unchanged; the next agent starts from the branch and the last handoff.
fix(seed-settle): the settler uses errorMessage from src/shared (#1746)
feat(core): core settles quick seeds in the background, one at a time…
feat(seed): simlock seed makes and settles a kind's seed (#1837)