package agentapi import ( "context" "encoding/json" "fmt" ) // CrashGuardState mirrors the agent's GET /host/crash-guard (R-856, `09` §3 decision 143): what the // host's crash guard (`felhom-crash-guard`, `11` §5.9) recorded about the most recent HOST boot. The // agent reads /var/lib/felhom-crash-guard/state.json (0644) and passes these fields through. // // Present=false: the host has no crash guard or no state yet. An agent that predates the route answers // 404 (a *StatusError) — both mean UNKNOWN, and the controller then keeps its normal boot grace. type CrashGuardState struct { Present bool `json:"present"` LastBootAt string `json:"last_boot_at,omitempty"` // RFC3339 UTC ("2006-01-02T15:04:05Z") LastBootUnclean bool `json:"last_boot_unclean"` Tripped bool `json:"tripped"` } // CrashGuard calls GET /host/crash-guard. func (c *Client) CrashGuard(ctx context.Context) (CrashGuardState, error) { var out CrashGuardState body, err := c.get(ctx, "/host/crash-guard") if err != nil { return out, err } if err := json.Unmarshal(body, &out); err != nil { return out, fmt.Errorf("agentapi: decode /host/crash-guard: %w", err) } return out, nil }