mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-07-10 00:14:38 +00:00
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.
46 lines
2.2 KiB
Go
46 lines
2.2 KiB
Go
package ai
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/rcourtman/pulse-go-rewrite/internal/ai/modelresolution"
|
|
"github.com/rcourtman/pulse-go-rewrite/internal/ai/providers"
|
|
"github.com/rcourtman/pulse-go-rewrite/internal/config"
|
|
)
|
|
|
|
// ResolveConfiguredModel returns the effective model for the current AI config.
|
|
// When the operator has not selected a concrete provider model yet, Pulse resolves
|
|
// one from the provider's live catalog instead of relying on hardcoded vendor IDs.
|
|
func ResolveConfiguredModel(ctx context.Context, cfg *config.AIConfig) (string, error) {
|
|
return modelresolution.ResolveConfiguredModel(ctx, cfg)
|
|
}
|
|
|
|
// ResolveConfiguredChatModel returns the effective chat-suitable model for the
|
|
// current AI config.
|
|
func ResolveConfiguredChatModel(ctx context.Context, cfg *config.AIConfig) (string, error) {
|
|
return modelresolution.ResolveConfiguredChatModel(ctx, cfg)
|
|
}
|
|
|
|
// ResolvePreferredModelForProvider returns the best model to use for the requested
|
|
// provider. Explicit provider-scoped selections win; otherwise Pulse resolves a
|
|
// recommended model from the provider's live catalog.
|
|
func ResolvePreferredModelForProvider(ctx context.Context, cfg *config.AIConfig, provider string) (string, error) {
|
|
return modelresolution.ResolvePreferredModelForProvider(ctx, cfg, provider)
|
|
}
|
|
|
|
// ResolveConfiguredProviderModel resolves the best current model for a configured provider.
|
|
func ResolveConfiguredProviderModel(ctx context.Context, cfg *config.AIConfig, provider string) (string, error) {
|
|
return modelresolution.ResolveConfiguredProviderModel(ctx, cfg, provider)
|
|
}
|
|
|
|
// ResolveConfiguredChatProviderModel resolves a chat-suitable model for a
|
|
// configured provider.
|
|
func ResolveConfiguredChatProviderModel(ctx context.Context, cfg *config.AIConfig, provider string) (string, error) {
|
|
return modelresolution.ResolveConfiguredChatProviderModel(ctx, cfg, provider)
|
|
}
|
|
|
|
// SelectRecommendedProviderModel picks the current best candidate from a provider's
|
|
// live model catalog. The policy is intentionally vendor-neutral but Assistant first.
|
|
func SelectRecommendedProviderModel(models []providers.ModelInfo) (providers.ModelInfo, bool) {
|
|
return modelresolution.SelectRecommendedProviderModel(models)
|
|
}
|