Skip to content

Core settles quick seeds in the background, one at a time, when the worker is quiet #1746

Done

Description

@V3RON

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
Loading

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.ts exports only createSeedSettler and its types.
  • architecture.md rule 11: listSources is bounded at 60 s inside the settler; NodeProcessTable bounds each read.
  • architecture.md rule 9 and ports manual: ps and 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 none only and is aborted at new-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-ended after 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_RANGE by 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; listSources throws; listSources past 60 s; gates shut (no listSources call)
  • 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 remove meanwhile; 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 to none; 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 --json lists settled and leases: a quick seed with 3 leases; a settled seed; a baseline
  • B23: every settle emits seed.settle-started and seed.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; ps time formats; a PowerShell answer; a timed-out read

Done when

  • pnpm test:changed passes, with the B1 to B9 cases above.
  • pnpm typecheck passes.
  • docs/internal/EVENTS.md and website/src/content/docs/docs/reference/events.mdx list seed.settle-started and seed.settle-ended with I13's payloads, src/bus/index.ts's EventMap and src/bus/index.test.ts's EVENT_NAMES hold them.
  • PROTOCOL_VERSION_RANGE in src/contract/protocol.ts is one higher than before this PR.
  • pnpm --dir website install && pnpm --dir website build && node website/scripts/check-openapi.mjs passes, and cli.mdx's doctor sources fields list settled and leases.
  • 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

Depends on

Written by an agent.

Activity

  1. added
    task:draft
    on Nov 19, 2026
  2. added
    task:ready
    and removed
    task:draft
    on Nov 19, 2026
  3. self-assigned this
    on Nov 19, 2026
  4. 4 remaining items

  5. github-actions commented on Nov 23, 2026

    @github-actions
    Contributor

    Claim released: no activity for 3 days. The label is unchanged; the next agent starts from the branch and the last handoff.

  6. added 2 commits that reference this issue on Nov 25, 2026
    a03c88c
    21742f0
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

    task:ready

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions