Skip to content

ADFA-5365 fix(server-lifecycle): judge a boot on movement, not on the flap grace - #514

Merged
luisguzman-adfa merged 2 commits into
mainfrom
fix/ADFA-5362-proot-seccomp-capability
Sep 1, 2026
Merged

luisguzman-adfa merged 2 commits into
mainfrom
fix/ADFA-5362-proot-seccomp-capability

Conversation

@luisguzman-adfa

Copy link
Copy Markdown
Collaborator

What

Stop killing a healthy environment mid-boot. One 20 s threshold was answering two different
questions, and on a slow device the boot lost.

Why

Device-measured: the box reaches /k2go-api in ~40 s. The service-down grace is 20 s plus a 3 s
tick, so KILL_AND_RELAUNCH fired at ~24 s — forever, 24.02 s apart. The device was capable; our
own timer stopped it.

The cause is a conflation: during a boot the services have been down since the proot started, so
servicesDownMs is the boot time; during a flap it is the time since the drop. Same number, two
meanings, one threshold.

The fix

The missing fact is whether this proot has ever answered since it appeared — a boot never has,
a flap has. ServerLiveness now carries it from observations it already makes, threaded and reset
like the downtime clock. Nothing else in the app knew it.

A boot is then judged on whether it is still moving, not on how long it has taken. Measured on a
real boot: 37 s total, longest gap between two guest lines 13 s. Total boot time grows with the
content installed; the longest quiet step does not — which is why a bigger number would just be
outgrown again. The silence grace is 60 s, 4.6x the worst gap measured.

The progress fact lives in EnvironmentProgress, app-scoped, because the two launch paths hold two
different engines: reading it off "my engine" made a boot started in the foreground and then
backgrounded look silent to the reconciler. Only the environment launches' listeners write it, so a
module install cannot make a stalled environment look alive. Clearing lives in
EnvironmentControl.stop — three call sites stop the environment, and an invariant only one of
them upholds rots.

Reduction

before after
service-down grace constants 2 (ServerController held a private copy beside an EnvironmentEnsure javadoc claiming to be the single source) 1
questions per threshold 2 1
holders of "last sign of life" — 1 (a per-engine copy was written, then removed rather than kept alongside)

Device verification — all four paths, build under test, driven through the app

path result
cold boot UP in ~40 s, 0 kills
boot, app backgrounded 12 s in UP, 0 kills
flap (dash-node killed) relaunched at 21 s — today's grace, unchanged
stop → start from Settings clean teardown, restart UP in 43 s, 0 kills

The last one is the user-visible one: turning the server off and on used to drop the device back
into the loop, because the restart outlives the old grace.

Worth knowing

  • A boot that keeps talking but never serves is now waited on indefinitely (previously died at
    20 s). Deliberate — the same trade ADR-5343a §12 accepted for the rebuild. No known instance.
  • An observation gap over 9 s (Doze) during a boot returns it to the flap rule for that proot's
    life. After a gap we cannot honestly claim it never served, so the fallback is sticky by design.
  • EnvironmentProgress is shared mutable static state, which CLAUDE.md discourages. The
    environment outlives every Activity so a fact about it must too; ServerStateRepository is the
    existing precedent. Flagged rather than slipped in.
  • launched() is called from both launch paths because there still are two. Clearing could be
    centralised, stamping cannot until the launch paths are unified — a third one would forget.

Tests

EnvironmentEnsureTest pins both clocks, including the case that fails on main (a 37 s boot
still talking is not killed) and the one that must never change (a mature environment is never
judged on silence — it produces no output at all). ServerLivenessTest covers the new fact across
a full startup, the moment it answers, a replacement proot, and the gap fallback.

Pairing

ADFA-5362 closed the capability half; this is the lifecycle half. Together they are what makes an
affected device reach its services and stay up.

No server change, no new strings, no UI change.

… flap grace

A boot and a flap are both "alive, not answering", and one 20s threshold was
answering both. A boot has been down since its proot started, so its downtime
IS its boot time: a device-measured 37s boot was killed at ~24s and relaunched
forever, never finishing.

The missing fact is whether this proot has ever answered. ServerLiveness now
carries it from the observations it already makes, so a boot can be judged on
whether it is still moving -- the guest keeps talking while it comes up, and
the longest quiet step (13s measured) does not grow with content the way total
boot time does. The flap path is untouched.

Also removes ServerController's copy of the service-down grace, which sat
beside an EnvironmentEnsure javadoc claiming to be the single source.

Device-verified: boot reaches UP in 39.9s with zero kills; a killed dash-node
is still relaunched at 21s.
…e environment

Reading the progress stamp off "my engine" meant a boot started by the foreground
actuator and then backgrounded looked silent to the reconciler, which fell back to
the downtime rule and killed it at 20s -- the very bug this ticket removes. There
are two launch paths holding two different engines, so the fact cannot live on
either one.

EnvironmentProgress holds it once, app-scoped like ServerStateRepository, and is
written only by the environment launches' own listeners so a module install
streaming through the same engine class cannot make a stalled environment look
alive. PRootEngine's per-instance copy is removed rather than kept alongside it.

Clearing lives in EnvironmentControl.stop, symmetric with the launch stamp: three
call sites stop the environment, and an invariant only one of them upholds rots.

Device-verified: a boot backgrounded 12s in reaches UP with zero kills.
@luisguzman-adfa
luisguzman-adfa merged commit aeb9900 into main Sep 1, 2026
3 checks passed
@luisguzman-adfa
luisguzman-adfa deleted the fix/ADFA-5362-proot-seccomp-capability branch September 1, 2026 11:07
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