Add run lifecycle report projection

This commit is contained in:
npc0-hue
2026-08-06 20:35:13 +08:00
parent 4e78957a60
commit 68921b3f68
13 changed files with 270 additions and 8 deletions
@@ -9,11 +9,13 @@ The corrected ownership model is: Platform builds and authenticates a server-sco
**Goals:**
- Stop generated Run registration from enqueueing `process.start` or `process.status` jobs as a bootstrap side effect.
- Add a generated-package autonomous lifecycle plan containing plugin lifecycle action refs, dependency declarations, safe deployment inputs, log sources, and selected runtime profile metadata.
- Implement the independent Run repository's generic plan loader/executor so generated packages consume `.platform/autonomous-lifecycle-plan.json` locally and report terminal lifecycle facts back to Platform.
- Add a Platform lifecycle report endpoint that authenticates the active Run session, validates the server binding, records audit evidence, and projects visible server state from Run-reported facts without creating jobs.
- Keep Platform responsible for server records, registration binding, auth, distribution builds, audit, and visible projections from Run reports.
- Update governance and protocol docs so future work treats Run as the lifecycle authority.
**Non-Goals:**
- Implement the independent `run` repository's plan executor in this repo.
- Re-add the independent `run` repository as a source tree owned by this repo.
- Add game-specific SCUM install/start behavior to Platform.
- Move distribution builds to machine-side Run endpoints or expose distribution-build authority to generated Runs.
- Remove explicit operator lifecycle command APIs in this change.
@@ -24,11 +26,12 @@ The corrected ownership model is: Platform builds and authenticates a server-sco
- **Use plugin declarations, not Platform logic, for game behavior.** The plan references action files, dependency probes/install plans, process log sources, DLL extension declarations, and sanitized deployment inputs already declared by the plugin. It does not include SCUM executable names, Steam app IDs, ports, or platform-side command synthesis.
- **Make registration binding-only for generated Run bootstrap.** `RegisterRunHello` continues to authenticate the component, upsert endpoint metadata, and issue a session token. It does not dispatch lifecycle or reconciliation work merely because a generated Run appeared.
- **Keep Platform projections report-driven.** Existing terminal job/result projection can remain for explicit lifecycle commands, but generated Run startup state must converge through Run reports rather than Platform's stale stored state or registration-time probes.
- **Report autonomous execution as observed facts, not job completions.** Run submits terminal autonomous lifecycle results through a signed lifecycle report route. Platform verifies the report belongs to the bound server/run session, then reuses lifecycle projection logic without manufacturing a platform job lease.
- **Preserve builder security boundaries.** The platform-owned builder receives the plaintext component auth key internally and the autonomous plan as build input. Machine-side run endpoints still cannot claim `distribution.build` jobs or fetch plaintext build input.
## Risks / Trade-offs
- **Run repository lag** -> The generated package can carry the plan before the independent Run executable consumes it. Mitigation: protocol and build input are explicit, and this repo does not re-add Run source.
- **Cross-repository release skew** -> Platform can build packages with the plan before every deployed Run binary has the autonomous executor. Mitigation: generated Run logs explicit plan load/skip/failure states, tests cover the independent `run` repository, and this repo still does not own the `run/` source tree.
- **Stored Platform state may look stale until Run reports** -> Registration no longer paper-over probes with Platform jobs. Mitigation: UI/API must treat persisted lifecycle state as projection, not observed process truth.
- **Plan drift between build and execution** -> A package carries the plugin declarations and deployment revision available at build time. Mitigation: include plugin version, profile key, deployment revision, and target release so Run and Platform can report stale-plan evidence.
- **Operator command APIs still dispatch jobs** -> This change fixes generated Run autonomous startup first. Explicit commands remain auditable Platform requests until a later change redesigns command transport around Run-owned intent handling.
@@ -38,6 +41,8 @@ The corrected ownership model is: Platform builds and authenticates a server-sco
- Stop queuing registration-time lifecycle/status jobs for generated Runs.
- Extend run distribution build input and DTOs with `autonomousLifecycle` for Run packages only.
- Update platform builder input materialization so the generated package has a serialized plan alongside the existing workspace seed.
- Add Platform's signed lifecycle report endpoint for Run-owned bootstrap results.
- Update the independent Run repository to load, validate, execute, and report the autonomous plan using generic lifecycle capabilities.
- Update service tests to assert registration does not enqueue bootstrap/reconciliation jobs and build input includes the plan.
## Open Questions
@@ -11,6 +11,10 @@ Generated Run packages SHALL carry a bounded autonomous lifecycle plan that lets
- **WHEN** the generated Run executable starts on its host
- **THEN** Run can read the embedded autonomous lifecycle plan and execute plugin-declared init, dependency verification/install, install-if-needed, readiness/status, and start behavior locally
#### Scenario: Generated Run reports autonomous bootstrap result
- **WHEN** Run completes an autonomous lifecycle bootstrap action from the embedded plan
- **THEN** Run reports the terminal lifecycle result to Platform without requiring a Platform job claim, acknowledgement, lease token, or job result
### Requirement: Platform follows Run-reported lifecycle facts
Platform SHALL treat persisted server lifecycle state as a projection of Run-reported lifecycle facts, heartbeats, logs, and terminal process reports rather than as authoritative observed process truth.
@@ -22,6 +26,10 @@ Platform SHALL treat persisted server lifecycle state as a projection of Run-rep
- **WHEN** Run reports that the managed process is running
- **THEN** Platform projects the server as running based on the Run report
#### Scenario: Run reports through the signed lifecycle report channel
- **WHEN** a registered Run submits a terminal lifecycle report for its bound server instance
- **THEN** Platform validates the active Run session and server binding, records audit evidence, and updates the visible server projection from the reported process facts
### Requirement: Plugins declare game-specific lifecycle behavior
Plugins SHALL declare lifecycle action refs, dependency probes, install plans, runtime profiles, log sources, and deployment templates needed by Run, and Platform SHALL NOT hardcode game-specific install, update, status, or startup behavior.
@@ -14,9 +14,16 @@
- [x] 2.1 Add autonomous lifecycle plan domain/build-input structures without exposing the plan through machine job-channel DTOs.
- [x] 2.2 Populate the plan from plugin lifecycle declarations, runtime profile data, dependency declarations, log sources, DLL extensions, and deployment definition.
- [x] 2.3 Stop generated Run registration from enqueueing bootstrap start or status reconciliation jobs.
- [x] 2.4 Update protocol and governance docs to make Run the lifecycle authority.
- [x] 2.4 Add a signed Platform lifecycle report endpoint that projects server state from Run-owned terminal lifecycle facts without creating jobs.
- [x] 2.5 Update protocol and governance docs to make Run the lifecycle authority.
## 3. Verification
## 3. Independent Run Implementation
- [x] 3.1 Update service tests for autonomous build input and no registration-time lifecycle dispatch.
- [x] 3.2 Run targeted Go tests plus repository structure checks.
- [x] 3.1 Add generic autonomous lifecycle plan protocol types and validation in the independent `run` repository.
- [x] 3.2 Load `.platform/autonomous-lifecycle-plan.json` from the generated package workspace, validate package identity/target, run dependency probes/install plans, execute the bootstrap action, and report the terminal lifecycle result to Platform.
- [x] 3.3 Keep Run generic: no SCUM executable names, Steam app IDs, install paths, ports, or game-specific branches.
## 4. Verification
- [x] 4.1 Update service/API/runtime tests for autonomous build input, no registration-time lifecycle dispatch, Run-owned bootstrap execution, lifecycle reporting, and signed report routing.
- [x] 4.2 Run full Go tests for `platform/` and the independent `run` repository plus repository structure checks.