Status: Implemented current architecture
Define the as-built performance-management capability that Guardian currently ships.
This document is the source of truth for the runtime service, web control-plane surface, and assistant tool access for workstation performance operations. The earlier proposal in WINDOWS-11-PERFORMANCE-MANAGER-PROPOSAL.md is historical design context, not the current behavior contract.
Owned implementation surfaces:
- runtime service: performance-service.ts
- OS adapters: windows.ts, fallback.ts
- web callbacks: performance-dashboard-callbacks.ts
- web routes and types: web-runtime-routes.ts, web-types.ts
- web page and client: performance.js, api.js
- assistant tools: performance-tools.ts
- config mutation path: direct-config-update.ts
Out of scope:
- generic host monitoring outside the
Performancepage - autonomous maintenance or background cleanup jobs
- guaranteed application launch/keep-alive behavior
- power-mode enforcement on the host
- non-process cleanup actions beyond the reserved preview/run contract
Performance is a workstation-operations domain. It exists to help the operator:
- inspect current host pressure
- inspect live processes
- maintain named performance profiles
- preview a guarded cleanup action
- execute only the reviewed subset of selectable rows
- review recent profile switches and cleanup actions
The current required web information architecture is defined in WEBUI-DESIGN.md.
The runtime constructs one shared PerformanceService in index.ts and wires it into the web dashboard callbacks in index.ts.
The service owns:
- active profile resolution
- host snapshot collection via the OS adapter
- live process decoration and protection tagging
- latency probe execution and short-lived caching
- preview generation for reviewed actions
- preview expiry
- reviewed action execution
- local history plus durable audit-backed history when an audit log is available
The service does not own layout, direct browser shell execution, or ad hoc config writes.
Performance configuration lives under assistant.performance in types.ts.
Current top-level fields:
enabledsampleIntervalSectrendRetentionDaysalarmsprotectedProcessesprofiles
Profile fields:
idnamepowerModeautoActionsprocessRules.terminateprocessRules.protectlatencyTargets
The default shipped profile lives in types.ts and is currently coding-focus.
Config writes from the web UI are normalized through direct-config-update.ts. The browser does not write raw YAML directly.
Windows uses WindowsPerformanceAdapter.
Current as-built behavior:
- host CPU, memory, disk, and process counts are sampled
- live processes are listed from
Get-Process - executable path and cumulative CPU time are exposed when available
- selected process rows can be terminated with
taskkill - latency probes are supported
Current limitations:
canManagePowerisfalserunCleanupActions()is not implemented- per-process CPU percent is not currently collected, so process ranking is primarily memory-driven on Windows
- exact Task Manager icons are not extracted
Fallback uses FallbackPerformanceAdapter.
Current as-built behavior:
- host CPU, memory, disk, and process counts are sampled
- live processes are listed from
ps - per-process CPU percent and memory are exposed
- latency probes are supported
Current limitations:
- process termination is disabled
- non-process cleanup actions are disabled
- power management is disabled
Protection is assembled in performance-service.ts from:
- global
assistant.performance.protectedProcesses.names - the active profile
processRules.protect - Guardian's own running process names
- an explicit default protection for
node
Protected rows remain visible in the live process browser and cleanup preview, but they are marked non-selectable with a reason.
Important behavior:
protectmeans "Guardian must not target this executable name for cleanup"- it does not mean "ensure this process is launched"
The only supported reviewed action id today is cleanup, enforced in performance-service.ts.
As built, cleanup is primarily a reviewed process-selection workflow:
- explicit candidates come from the active profile
processRules.terminate - if those do not match the live process list, the service falls back to heuristic recommendations
- heuristic recommendations suppress common development, system, and browser processes
- heuristic recommendations favor known background apps and notably heavy CPU or memory usage
Current heuristic families are defined in performance-service.ts and scored in performance-service.ts.
Preview behavior:
- previews expire after 10 minutes
- at most 8 ranked process targets are returned
cleanupTargetsis currently always empty- risk is classified as
low,medium, orhigh - protected rows remain in the preview but are disabled
Reviewed actions run through runAction().
Current behavior:
- the request must reference a non-expired preview
- the request must select at least one explicit target id
- the service rejects stale or now-invalid selections
- selected process targets are passed to the adapter for termination
- selected cleanup target ids are accepted by contract, but no concrete cleanup tasks are implemented today
- every successful or failed run is added to local history and, when available, the audit log
Important non-goals in the current build:
- applying a profile does not kill terminate-listed apps
- applying a profile does not launch protected apps
- the service does not perform autonomous corrective actions in the background
Latency targets are profile-scoped. The service resolves them from either:
targettargetRef
and caches probe results for sampleIntervalSec, implemented in performance-service.ts.
Current target kinds:
internetapi
These are advisory diagnostics for Overview. They do not trigger automatic actions in this build.
Current performance routes:
GET /api/performance/statusGET /api/performance/processesPOST /api/performance/profile/applyPOST /api/performance/action/previewPOST /api/performance/action/run
Privilege model:
statusandprocessesare authenticated read pathsprofile/applyrequires a privileged ticket forperformance.manageaction/runrequires a privileged ticket forperformance.manageaction/previewis read-only and does not require a privileged ticket
The browser client mints privileged tickets through api.js before calling the mutating routes.
The operator-facing page is performance.js.
Current required tabs:
OverviewProfilesCleanupHistory
Current as-built UX:
Overviewshows the current host snapshot, top processes, runtime capability flags, and latency targetsProfilessupports create, edit, apply, and delete for performance profilesProfilesincludes a live running-process browser grouped by executable name with quick-add into terminate/protect rulesCleanupis preview-first and only runs the reviewed subsetHistoryshows profile applications and reviewed action runs
There is no dedicated performance-management skill in skills/.
Assistant access is provided through deferred built-in tools:
performance_status_getperformance_profile_applyperformance_action_previewperformance_action_run
See performance-tools.ts and the deferred-tool inventory note in tool-context.ts.
These tools are:
- runtime-backed, not web-page backed
- category
system - deferred by default and intended to be discovered through
find_tools
performance_action_run supports two modes:
- explicit execution from an existing preview id
- generate-a-preview-first and then run either the default-checked or all selectable rows
Mutating tool calls participate in the shared approval model. Approval copy is specialized in pending-approval-copy.ts.
Durable audit event families:
performance.profile_appliedperformance.action_run
Not implemented in the current build:
- autonomous performance actions
- non-process cleanup task implementations
- host power-mode changes
- startup-app or service management
- exact Windows shell icon extraction
- process launch/keep-alive semantics for protected apps
- dedicated direct-intent routing for performance workflows
- a dedicated performance skill
This capability should not be documented as if those features already exist.
Relevant coverage currently lives in:
- performance-service.test.ts
- performance-tools.test.ts
- performance-dashboard-callbacks.test.ts
- channels.test.ts
When changing this capability, the minimum verification bar should include:
npm run check- focused Vitest coverage for runtime service, tools, callbacks, and channel routes
- relevant web smoke coverage when the local environment can authenticate successfully