Make Run runtime state authoritative

This commit is contained in:
npc0-hue
2026-08-06 10:07:01 +08:00
parent d8d07914da
commit 0875a1b17e
10 changed files with 324 additions and 12 deletions
@@ -0,0 +1,23 @@
## Why
Manual generated Run execution exposed a stale lifecycle design: platform persisted `running` after the previous supervised process was gone, so a newly-started Run worker could register successfully but had no way to correct the visible server state before an operator issued another lifecycle command. The machine-side Run must be the source of observed runtime truth; platform state should converge from Run-reported process facts instead of blocking actions based only on stale stored state.
## What Changes
- Add runtime-state reconciliation for generated Run registration so a Run endpoint can report the actual managed process state for its server after reconnect/startup.
- Project `process.status` results into server lifecycle state using Run-reported `processState` values such as `running`, `stopped`, `not-started`, and `exited`.
- Prevent stale platform `running` from surviving when the active Run reports no managed process for that server.
- Keep lifecycle command authorization and job dispatch platform-owned; only observed runtime/process state becomes Run-authoritative.
## Capabilities
### New Capabilities
- `run-runtime-state-authority`: Defines how platform reconciles server lifecycle state from generated Run process observations.
### Modified Capabilities
## Impact
- Affects `platform/service` lifecycle projection, Run registration handling, and lifecycle tests.
- No new product areas, billing, provider workflow, or plugin-specific hardcoding.
- No new external dependencies.