## Context Item 9 made the console truthful about API-backed operational state, current-session operations, and safe projections. The remaining production gap is not another dashboard facade; it is durable governance: admission control under capacity pressure, alert lifecycle closure, complete plugin lifecycle state, and real provider-backed AI assistance. The implementation must reuse Platform as the authority and Run as a channelized executor while keeping plugin pages and browser code away from raw secrets, direct sockets, host paths, and provider transport details. ## Goals / Non-Goals **Goals:** - Govern server and Run capacity through Platform admission checks, safe endpoint capacity reports, queued/retrying jobs, and explicit capacity-denied responses. - Persist alerts with source, severity, state, acknowledgement, scoped retry, resolution, suppression windows, audit links, and safe diagnostic text. - Model complete plugin lifecycle state and compatibility gates in Platform, and drive lifecycle jobs through the existing job channel. - Add real AI Provider invocation through a provider client that uses Platform-stored key/base URL material and never returns raw credentials or transport details. - Require AI-generated config changes to produce a diff/recommendation that must be approved before any run-side write job is dispatched. - Surface governance, alerts, lifecycle, and AI states in existing first-party pages without replacing the visual system or full-width management surfaces. - Extend Run capacity/lifecycle contracts with bounded metadata only, preserving channel isolation and priority. **Non-Goals:** - No billing, cloud host sales, cloud/agent provider marketplace, or SaaS marketplace expansion. - No arbitrary shell, direct Run socket/endpoint, host path projection, raw PID/socket/DSN/RCON, or raw credential/token/key/base URL exposure. - No browser/plugin storage of provider secrets. - No replacement of the five required first-party areas or the black-mecha/magical-girl theme system. ## Decisions ### Decision 1: Platform owns production admission decisions Run heartbeats report bounded capacity metadata. Platform combines that with server bindings, queued/running job pressure, endpoint capability availability, and configured limits before accepting lifecycle, dependency, backup, update, and plugin jobs. Rejected work returns a safe capacity or compatibility reason and records audit/alert evidence. Alternative considered: let Run reject after claim. Rejected because operators need immediate Platform feedback, and Run-only rejection creates noisy retry loops. ### Decision 2: Alerts are durable state, not transient UI messages Capacity pressure, failed lifecycle work, stale endpoints, AI provider failures, plugin compatibility failures, and unsafe request denials create or update durable alert records. Alerts have explicit acknowledgement and resolution transitions with actor and audit metadata. Current-session UI operations remain separate and cannot close durable alerts by themselves. Alternative considered: derive alerts only from latest jobs/metrics. Rejected because acknowledgement, suppression, and resolution are production workflows that must survive restart. ### Decision 3: Plugin lifecycle state is managed by Platform Marketplace enablement remains a catalog state, while lifecycle operations track installed plugin version, target server compatibility, dependency status, desired state, current state, upgrade/rollback availability, linked job IDs, and audit/alert summaries. Plugin manifests and bridge calls declare capabilities and purposes, but Platform authorizes and dispatches all jobs. Alternative considered: plugin pages manage lifecycle locally through bridge state. Rejected because that would bypass durable authorization and job/audit truth. ### Decision 4: Real AI Provider calls use a redacted provider client Platform selects an active provider, decrypts key/base URL material inside the service boundary, sends bounded requests through a provider client, and returns only safe recommendation/diff/usage metadata. Tests and local mode can still use deterministic clients, but production code must support a real HTTP provider path with redacted failures. Alternative considered: expose base URLs or keys to plugin pages for direct calls. Rejected by the repository AI Provider rules and secret boundary. ### Decision 5: AI config changes are two-step AI can suggest a structured diff for configuration or lifecycle inputs. Platform stores the diff preview and requires explicit approval before dispatching a run-side config write job. Approval is scoped to actor/server/plugin/config revision and stale approvals are denied. Alternative considered: dispatch config writes directly after AI completion. Rejected because AI suggestions must be reviewable before mutation. ### Decision 6: Run receives bounded lifecycle and capacity metadata only Run protocol additions are limited to safe capacity dimensions, pressure reasons, lifecycle capability names, and logical job inputs. They do not carry raw host paths, process IDs, sockets, credentials, provider configuration, or browser/plugin transport material. Alternative considered: add a general operations channel. Rejected because existing control/job/log/artifact/game-client channels already define the isolation model. ## Risks / Trade-offs - [Risk] Alert deduplication can hide repeated incidents. Mitigation: keep occurrence counts, last-seen timestamps, state transitions, and audit references. - [Risk] Capacity admission can reject recoverable work too early. Mitigation: use explicit retry-after hints, scoped retry, and distinguish hard compatibility failures from temporary pressure. - [Risk] Real provider calls can leak transport errors. Mitigation: redact provider failures and validate every response before returning it. - [Risk] Lifecycle state overlaps existing marketplace state. Mitigation: keep marketplace catalog state separate from server/plugin lifecycle installations. - [Risk] Broad verification may be expensive. Mitigation: add focused unit tests first, then run full platform_web, plugins, platform, run, structure, OpenSpec, diff, and browser checks before completion. ## Migration Plan 1. Add OpenSpec artifacts and validate strictly before implementation. 2. Add shared Platform domain/DTO/validator/model/repo/service support for capacity governance, alerts, plugin lifecycle, and AI diff approvals. 3. Add Platform API routes and route docs with named DTOs and OpenAPI-style handler comments. 4. Extend plugin manifest/SDK/bridge contracts and examples with lifecycle and mediated AI purpose metadata. 5. Extend Run protocol/runtime capacity and lifecycle metadata without crossing channel boundaries. 6. Update platform_web contracts/pages/theme/tests to surface capacity, alerts, lifecycle, and AI diff approval using existing first-party surfaces. 7. Run full verification and record evidence in this change's tasks. Rollback is additive: remove the new governance/lifecycle/alert/AI diff approval routes and UI panels, while preserving existing item 9 console behavior and earlier durable job/channel mechanics.