Documentation
¶
Overview ¶
Package liveprovider isolates the minimum credential state needed by opt-in live provider tests. It never recursively copies an agent home and never returns source paths or credential contents.
Index ¶
- Constants
- func CLIVersion(provider string, outputs ...string) string
- func CaptureRuntimeConnectionEnv(runtimeName string) (map[string]string, error)
- func ChildEnvironment(layout procharness.Layout, spec ChildSpec) ([]string, error)
- func CleanupSupervisor(ctx context.Context, spec SupervisorCleanupSpec, ops SupervisorCleanupOps) error
- func ConsultChildEnvironment(layout procharness.Layout, spec ConsultChildSpec) ([]string, error)
- func ControlFilePresent(root, path string) bool
- func CopyRegularTree(sourceRoot, source, destination string, maxBytes int64) error
- func CredentialDetailCode(err error) string
- func InitRepository(layout procharness.Layout) error
- func NewProcessControl(layout procharness.Layout, registry bool) (*os.File, string, error)
- func ParseTargets(raw string) ([]agents.Target, bool, error)
- func ProcessDeadlineExceeded(result procharness.Result) bool
- func ProcessEnvironment(layout procharness.Layout, path string, runtime RuntimeSettings, ...) ([]string, error)
- func ReadSessionID(root, path string) (string, error)
- func ValidateConsultTargets(requested []agents.Target) error
- func ValidateStrictTargets(strict bool, requested []agents.Target) error
- type BoundedBuffer
- type ChildProcessObservation
- type ChildSpec
- type ConsultChildSpec
- type ConsultEdgeResult
- type ConsultSummary
- type Prepared
- func (p *Prepared) Account(provider string) string
- func (p *Prepared) CredentialPresent(provider, account string) bool
- func (p *Prepared) PreflightReason(provider, account string, deadline time.Time) string
- func (p *Prepared) RevocationPath() (string, error)
- func (p *Prepared) Revoke() error
- func (p *Prepared) SafeThrough(provider, account string, deadline time.Time) bool
- func (p *Prepared) VerifySources() error
- type ProcessSpec
- type ProviderResult
- type RepositorySnapshot
- type RuntimeSettings
- type Selection
- type Summary
- type SummaryTotals
- type SupervisorCleanupOps
- type SupervisorCleanupSpec
- type VerificationFailures
Constants ¶
const ( // SummaryPrefix makes the one machine-readable line easy to extract from verbose go test output. SummaryPrefix = "COOP_PROVIDER_LIVE_SUMMARY " // LoopSummaryPrefix keeps writable task-completion evidence distinct from a read-only marker probe. LoopSummaryPrefix = "COOP_PROVIDER_LOOP_LIVE_SUMMARY " // ResumeSummaryPrefix identifies the two-process native-session continuity probe. ResumeSummaryPrefix = "COOP_PROVIDER_RESUME_LIVE_SUMMARY " // ConsultSummaryPrefix identifies the separate four-provider live consult result contract. ConsultSummaryPrefix = "COOP_CONSULT_LIVE_SUMMARY " // SupervisorLabelKey is the test-only label used to reap an ACP process even after its outer // supervisor is force-killed before normal cleanup. SupervisorLabelKey = "coop.live-test" StatusPassed = "passed" StatusSkipped = "skipped" StatusFailed = "failed" ReasonMissingRuntime = "missing_runtime" ReasonMissingImage = "missing_image" ReasonMissingCredential = "missing_credential" ReasonCredentialRefresh = "credential_refresh_required" ReasonCredentialNotPortable = "credential_not_portable" ReasonMissingCLI = "missing_cli" ReasonUnsafeCredential = "unsafe_credential" ReasonVersionProbe = "version_probe_failed" ReasonPromptExit = "prompt_exit" ReasonPromptTimeout = "prompt_timeout" ReasonMarkerMismatch = "marker_mismatch" ReasonRepositoryChanged = "repository_changed" ReasonSourceChanged = "source_changed" ReasonCleanupFailed = "cleanup_failed" ReasonHarnessFailed = "harness_failed" ReasonRingPrerequisite = "ring_prerequisite" )
Variables ¶
This section is empty.
Functions ¶
func CLIVersion ¶
CLIVersion extracts only a semver-like token and composes it with a registry-trusted label. Raw --version lines can contain paths, control sequences, environment echoes, or other secret data; none of that belongs in the stable live summary.
func CaptureRuntimeConnectionEnv ¶
CaptureRuntimeConnectionEnv resolves the selected host runtime's endpoint/TLS/SSH/storage capability before starting a scrubbed child. It never forwards Docker or Podman behavior-bearing config: those files may inject proxy env, mounts, hooks, or other defaults into the live box.
func ChildEnvironment ¶
func ChildEnvironment(layout procharness.Layout, spec ChildSpec) ([]string, error)
ChildEnvironment builds an allowlist-only environment. It never reads os.Environ; callers must pass PATH and resolved runtime settings explicitly. Provider tokens live only in layout.Config/env.
func CleanupSupervisor ¶
func CleanupSupervisor(ctx context.Context, spec SupervisorCleanupSpec, ops SupervisorCleanupOps) error
CleanupSupervisor best-effort removes known cidfile containers, then authoritatively sweeps the supervisor label across running and stopped state until it remains quiet for a full grace period.
func ConsultChildEnvironment ¶
func ConsultChildEnvironment(layout procharness.Layout, spec ConsultChildSpec) ([]string, error)
ConsultChildEnvironment is allowlist-only and fixes every control path to the disposable layout.
func ControlFilePresent ¶
ControlFilePresent reports only a regular, single-link control file below root as present.
func CopyRegularTree ¶
CopyRegularTree publishes a bounded private copy of one source subtree. It rejects links and special files, reads every file through the same replacement-resistant boundary as credentials, and leaves no partial destination on failure.
func CredentialDetailCode ¶
CredentialDetailCode converts a redacted copier error to a stable operator diagnostic.
func InitRepository ¶
func InitRepository(layout procharness.Layout) error
InitRepository creates the clean committed repo used by live provider tests. Git config is isolated by the process layout, so ambient aliases/hooks/signing cannot affect the fixture.
func NewProcessControl ¶
NewProcessControl creates the authenticated descriptor shared by tagged live helpers. ACP also requests a private generation registry; direct probes need only the descriptor.
func ParseTargets ¶
ParseTargets resolves the explicit provider set for an opt-in live run. `all` is deliberately strict and registry-generated; explicit lists preserve their order and may allow prerequisite skips. Account ladders are rejected because one live prompt must consume one credential only.
func ProcessDeadlineExceeded ¶
func ProcessDeadlineExceeded(result procharness.Result) bool
ProcessDeadlineExceeded derives timeout truth from the managed process result, not from a parent context that may expire after the child has already exited.
func ProcessEnvironment ¶
func ProcessEnvironment(layout procharness.Layout, path string, runtime RuntimeSettings, spec ProcessSpec) ([]string, error)
ProcessEnvironment is the shared allowlist-only environment for a live test process. It grants runtime connectivity and the isolated Coop layout, but no ambient Coop overrides or provider keys.
func ReadSessionID ¶
ReadSessionID accepts one private, bounded provider session identifier written by the fresh helper. Provider-owned history is never searched by the parent live harness.
func ValidateConsultTargets ¶
ValidateConsultTargets requires one concrete target for every registered provider.
Types ¶
type BoundedBuffer ¶
type BoundedBuffer struct {
// contains filtered or unexported fields
}
BoundedBuffer captures subprocess output without applying backpressure after the cap. Write always reports success so a verbose provider cannot turn output truncation into a pipe failure.
func NewBoundedBuffer ¶
func NewBoundedBuffer(max int) *BoundedBuffer
func (*BoundedBuffer) String ¶
func (b *BoundedBuffer) String() string
func (*BoundedBuffer) Truncated ¶
func (b *BoundedBuffer) Truncated() bool
type ChildProcessObservation ¶
type ChildProcessObservation struct {
Result procharness.Result
DeadlineExceeded bool
Attempted bool
}
type ChildSpec ¶
type ChildSpec struct {
Path string
Target string
Workflow string
Stage string
SessionID string
SessionFile string
Marker string
ResultFile string
AttemptFile string
Supervisor string
PreflightReason string
CIDDir string
ControlFD int
RevokePath string
Runtime RuntimeSettings
}
ChildSpec is the complete authority granted to one clean live helper process.
type ConsultChildSpec ¶
type ConsultChildSpec struct {
Path, Marker, ResultFile, AttemptDir, Supervisor, CIDDir string
Targets []agents.Target
PreflightReasons map[string]string
Strict bool
ControlFD int
RevokePath string
Runtime RuntimeSettings
}
ConsultChildSpec is the complete authority granted to the one clean four-provider live helper.
type ConsultEdgeResult ¶
type ConsultEdgeResult struct {
Lead string `json:"lead"`
Peer ProviderResult `json:"peer"`
}
type ConsultSummary ¶
type ConsultSummary struct {
Schema int `json:"schema"`
Strict bool `json:"strict"`
Results []ConsultEdgeResult `json:"results"`
Totals SummaryTotals `json:"totals"`
}
ConsultSummary is the stable four-provider consult-ring compatibility result schema.
func NewConsultSummary ¶
func NewConsultSummary(strict bool, requested []agents.Target, results []ProviderResult) (ConsultSummary, error)
func ReadConsultChildSummary ¶
func ReadConsultChildSummary(root, path string, strict bool, targets []agents.Target) (ConsultSummary, error)
ReadConsultChildSummary accepts one bounded, closed-schema provider-ring result and recomputes its totals.
func (ConsultSummary) Line ¶
func (s ConsultSummary) Line() (string, error)
func (ConsultSummary) PeerResults ¶
func (s ConsultSummary) PeerResults() []ProviderResult
func (ConsultSummary) Success ¶
func (s ConsultSummary) Success() bool
type Prepared ¶
type Prepared struct {
ConfigDir string
// contains filtered or unexported fields
}
Prepared is an isolated credential config plus the opaque source-integrity baseline that made it.
func Prepare ¶
Prepare copies only selected adapter-declared auth material into destination. Destination must not exist. Construction happens in a sibling staging directory and becomes visible by rename only after source stability and destination inode checks pass.
func (*Prepared) Account ¶
Account returns the account marked default in the isolated config for provider.
func (*Prepared) CredentialPresent ¶
CredentialPresent reports whether the isolated account has a primary file or an explicit env assignment belonging to that account in the source config.
func (*Prepared) PreflightReason ¶
PreflightReason returns the stable prerequisite skip reason for an isolated credential.
func (*Prepared) RevocationPath ¶
RevocationPath is the private, parent-known tombstone shared with the tagged timeout path.
func (*Prepared) Revoke ¶
Revoke atomically removes the published credential path, then deletes the renamed private tree. Source fingerprints remain usable because they describe the original vault, never ConfigDir. A failed tree removal is retryable by this process even when the tagged child performed the move.
func (*Prepared) SafeThrough ¶
SafeThrough reports whether using this isolated credential through deadline cannot require a refresh of copied remote state. Explicit env/API-key credentials are safe; file credentials must prove an access token remains valid through the deadline in their adapter.
func (*Prepared) VerifySources ¶
VerifySources fails when any selected source credential changed after Prepare. The error reveals no source location, account, artifact name, token, or digest.
type ProcessSpec ¶
ProcessSpec is the authority granted to a live ACP supervisor. ProcessDir is a private, append-only registry activated only when the tagged binary also receives ControlFD.
type ProviderResult ¶
type ProviderResult struct {
Provider string `json:"provider"`
CLIVersion string `json:"cli_version,omitempty"`
Attempted bool `json:"attempted"`
Passed bool `json:"passed"`
Status string `json:"status"`
ReasonCode string `json:"reason_code,omitempty"`
Phase string `json:"phase,omitempty"`
ExitCode int `json:"exit_code,omitempty"`
TimedOut bool `json:"timed_out,omitempty"`
Truncated bool `json:"output_truncated,omitempty"`
ErrorClass string `json:"error_class,omitempty"`
DetailCode string `json:"detail_code,omitempty"`
}
ProviderResult is intentionally path/account/token-free so the summary can be retained as CI or task evidence. Attempted becomes true only when the marker command starts.
func ClassifyChildProcess ¶
func ClassifyChildProcess( expectedProvider, root, resultPath string, observation ChildProcessObservation, ) ProviderResult
ClassifyChildProcess turns process state plus the separately-owned attempt marker into one stable result. A clean child wins over a racing expired context; otherwise deadlines retain whether the paid prompt had begun.
func FinalizeResult ¶
func FinalizeResult(child ProviderResult, failures VerificationFailures) ProviderResult
FinalizeResult applies the security precedence: cleanup, source integrity, repository integrity, then the child outcome. Higher-priority verification must not be masked by a provider failure.
func ReadChildResult ¶
func ReadChildResult(root, path, expectedProvider string) (ProviderResult, error)
ReadChildResult accepts exactly one bounded, root-owned result and validates it through the same summary contract used for persisted evidence.
type RepositorySnapshot ¶
RepositorySnapshot covers the Git and working-tree state a read-only live command must preserve.
func SnapshotRepository ¶
func SnapshotRepository(layout procharness.Layout) (RepositorySnapshot, error)
func VerifyRepository ¶
func VerifyRepository(layout procharness.Layout, baseline RepositorySnapshot) (RepositorySnapshot, error)
VerifyRepository hashes the complete repository before invoking Git. A provider-controlled local config or hook therefore cannot execute in the host-side semantic checks.
func (RepositorySnapshot) Equal ¶
func (s RepositorySnapshot) Equal(other RepositorySnapshot) bool
type RuntimeSettings ¶
type RuntimeSettings struct {
Name string
Image string
BaseImage string
HomeInBox string
AgentPackages string
ConnectionEnv map[string]string
}
RuntimeSettings is the narrow host-runtime capability copied from the user's resolved Coop config. ConnectionEnv may point at runtime-owned configuration, so it must reach only the runtime process; it is never forwarded as container environment or persisted in live evidence.
type Selection ¶
Selection is one source credential account to isolate. SourceDefault says the source env file belongs to this account; the destination always marks one selected account per provider default.
func DefaultSelections ¶
DefaultSelections returns exactly one selected credential account per registered provider. ACP live conformance switches providers, but it does not need authority from unrelated named accounts.
func SelectionForTarget ¶
SelectionForTarget resolves one concrete account without changing the source config. A live compatibility prompt deliberately supports one account only; account ladders belong to the deterministic rotation suites.
type Summary ¶
type Summary struct {
Schema int `json:"schema"`
Strict bool `json:"strict"`
Results []ProviderResult `json:"results"`
Totals SummaryTotals `json:"totals"`
}
Summary is the stable provider-live result schema.