Commit Graph

7 Commits

Author SHA1 Message Date
rcourtman
b94d8473ce Count the days external agents read Pulse history
The agent event-record experiment is reviewed on 2027-01-27 against one
test: at least 15 install IDs on stable versions reading history on
three or more separate days in a 30-day window. No existing counter can
answer it: they count requests, fold these reads into general context,
and the activity history keeps only its newest 500 records, so a busy
agent pushes out the days it read on.

After a successful list_recent_changes or get_metric_history response,
an external-agent request now also records one content-free history_read
marker per UTC day. The marker skips Pulse's own pages, is deduplicated
in memory and on disk, and sits outside the 500-record cap. Telemetry
schema 21 reports the number of distinct marker days as
pulse_intelligence_external_agent_history_read_days_30d (0 to 30). The
per-request records are unchanged, so existing counters keep their
meaning.
2026-10-29 12:59:09 +00:00
rcourtman
f458de49e8 Let agents read a resource's metric history
Agents could read current values and, since list_recent_changes, what
changed, but not how a resource's metrics moved: whether a disk filled
gradually or suddenly, whether memory climbed before a restart. Pulse
records that history for its own charts.

get_metric_history (GET /api/agent/metric-history, monitoring:read,
on the Pulse MCP surface) takes the canonical resource id the other
agent reads return, resolves the resource's metrics target through the
registry, and delegates to the chart history read. Agents and charts
therefore share tiers, fallbacks, downsampling and the licensed history
limit: a window beyond it returns the same license_required error.

The history route now accepts the registry's Kubernetes target kinds
(pod, k8s-cluster, k8s-node, k8s-deployment) as the k8s store type.
The frontend translated them client-side; any other caller passing a
target through got a 400.
2026-10-29 09:26:02 +00:00
rcourtman
015c583b7e Stop counting the Pulse UI as external agent use
The setup wizard leaves the browser authenticated with the wildcard
admin token it creates, and kiosk links authenticate with ?token=. The
UI's own GET /api/config/nodes and GET /api/ai/patrol/findings calls
therefore recorded external-agent activity, so
pulse_intelligence_external_agent_used_30d mostly measured installs
set up in the last 30 days: a third to a half of installs under 30 days
old reported it, against 2-3% of older ones. Its fall from 1,541 to
1,081 installs between September and October tracked fewer new
installs, not agents leaving.

Skip the marker when the browser marks the request Sec-Fetch-Site:
same-origin, which only a page Pulse served can produce. Scripts, MCP
adapters and dashboards on other origins still count. This is a
deliberate telemetry semantics change: expect the counter to drop on
upgraded installs.
2026-10-29 07:55:47 +00:00
rcourtman
32d8fd308e Let agents read what changed across the fleet
Pulse keeps 30 days of observed resource changes, but the agent
capability manifest, and so Pulse MCP, only exposed the five most recent
changes per resource inside get_resource_context. An assistant asked
"what happened overnight?" had no tool to answer it.

list_recent_changes (GET /api/agent/changes, monitoring:read) reads the
existing change store with since/before/resourceId/kind/sourceType
filters, a limit capped at 200 and a truncated flag. It writes nothing,
so it adds no disk load. Each change carries the resource's current name
and type, and history for removed resources stays readable.

The raw /api/resources/timeline route returns command text and output
excerpts to read-only tokens. This route instead applies the agent
redaction rule: without ai:execute, command and runbook changes keep only
allowlisted metadata and the command is cut from the reason.

The shared projection now forwards integral JSON numbers as query
parameters, so manifest integer filters such as limit reach GET routes
through MCP instead of being dropped.
2026-10-29 06:41:57 +00:00
rcourtman
f4c2fd0c38 Fail closed on unknown remediation lock state for autonomous dispatches
The AI action broker treated an unreadable operator lock as unlocked:
isResourceRemediationLocked returned (false, nil) with no audit store
wired, and the caller logged store errors then dispatched anyway. An
operator's NeverAutoRemediate=true could be silently ignored whenever
the policy store was missing or erroring, which is unacceptable while
Patrol and Assistant run at assisted or full autonomy.

Posture change at the dispatch decision point:
- isResourceRemediationLocked now reports unknown state (nil store or
  lookup failure) as an ErrRemediationLockStateUnknown-wrapped error
  instead of silently defaulting to unlocked.
- New checkRemediationLockForDispatch gate: dispatches without an
  approved human decision fail CLOSED on unknown lock state and
  surface "remediation lock state unknown; operator approval
  required". Human-approved dispatches keep the historical fail-open
  behavior with a warning log. A confirmed lock still refuses even
  approved dispatches, as before.
- executeNativeActionWithAudit (TrueNAS app start/stop/restart) now
  enforces the lock too; it previously skipped the check entirely.
- Refusals persist Failed audit records with stable
  remediation_lock_state_unknown: / resource_remediation_locked:
  ErrorMessage prefixes.
- ai-runtime subsystem contract updated to pin the new posture.

Tests cover store-error and nil-store at both autonomy postures on
both dispatch paths; routing/control tests now wire an in-memory
audit store since autonomous dispatch without one is refused.
2026-07-10 00:14:01 +01:00
rcourtman
20c2f27057 feat(mcp): add list_resource_capabilities tool
Agents had no way to discover which governed capabilities a resource
advertises before calling plan_action. The data existed (Resource.Capabilities
with full param schemas) but was only surfaced as count-limited prose
facts inside get_resource_context, which deliberately omits parameter
schemas. This forced agents to guess capabilityName and params.

Add a dedicated structured surface: GET /api/agent/resource-capabilities/{id}
returns the canonical ResourceCapability list (name, type, approval level,
platform, full parameter schemas) for a single resource. A resource with
no advertised capabilities returns 200 with an empty array, the signal
to skip plan_action.

Internal plumbing already existed (registry.Get + Resource.Capabilities,
the same path plan_action validates against); this is the wiring work at
the canonical agent-surface layer. The tools/call dispatch is fully
generic so no mcp.go changes were needed.

Companion to get_resource_context: that tool remains the human-readable
prose summary; this is the structured schema surface for action planning.

- Manifest capability, name/path constants, output schema helper
- Handler mirroring HandleResourceContext error/scope patterns
- Route registration behind monitoring:read
- Activity telemetry mapping to resource_context class
- Regenerated cmd/pulse-mcp/README.md via generate-pulse-intelligence-docs
- Contract updates: api-contracts, ai-runtime, agent-lifecycle, storage-recovery
- Tests: manifest ownership/addressing/table-test, handler happy/empty/404/405,
  contract pinning capability presence/scope/wire-shape
2026-07-03 17:07:41 +01:00
rcourtman
ee8a24e14a backend and governance: MCP contract, agent capabilities, API, and release-control
Manifest-backed MCP tools, prompts, and resources with surface affordance contracts; agent capability manifest and governance projection; API contract tests and capability route projection; operations-loop and intelligence-funnel telemetry; release-control subsystem documentation, registry, and tooling; licensing and configuration.
2026-06-23 17:26:15 +01:00