Documentation
¶
Index ¶
- Constants
- Variables
- func CheckDeletionBindingV2(pairing persist.PairingAuthority, sessionID, binding string) error
- func DeletionBindingV2(pairing persist.PairingAuthority, sessionID string) (string, error)
- func DisplaySessionMetadataTitle(title string) string
- func EmbeddedWebUI() (fs.FS, bool)
- func ExpiredSessionCookie(secure bool) string
- func HashPassword(password string) (string, error)
- func InspectPairingAuthority(store persist.Store) (persist.PairingAuthority, bool, error)
- func IsBrowserControlMethod(method string) bool
- func IsDrainGatedMethod(method string) bool
- func IsPairingRecoveryBlocked(err error) bool
- func IsUngroupedProjectKey(key *string) bool
- func PairAuthority(store persist.Store, hostIdentity, storageKey, secret string) (persist.PairingAuthority, error)
- func PairAuthorityWithFaults(store persist.Store, hostIdentity, storageKey, secret string, ...) (persist.PairingAuthority, persist.PublishOutcome, error)
- func PairedDeletionBinding(pairing persist.PairingAuthority, sessionID string) (string, error)
- func PasswordHashValid(encoded string) bool
- func PlanQueueProjectMigration(associations []QueueAssociation, moves []QueueProjectMove, ...) (planned []QueueAssociation, retained []QueueAssociation, conflicts []string, ...)
- func ReadAuthCookie(request *http.Request) string
- func RequirePairedRecovery(store persist.Store, liveHostIdentity, liveStorageKey string, ...) (persist.PairingAuthority, error)
- func RevokePairingAuthority(store persist.Store) (persist.PairingAuthority, error)
- func RevokePairingAuthorityWithFaults(store persist.Store, faults persist.PublishFaults) (persist.PairingAuthority, persist.PublishOutcome, error)
- func RotatePairingSecret(store persist.Store, currentSecret, newSecret string) (persist.PairingAuthority, error)
- func RotatePairingSecretWithFaults(store persist.Store, currentSecret, newSecret string, ...) (persist.PairingAuthority, persist.PublishOutcome, error)
- func ScryptKey(password, salt []byte, n, r, p, keyLen int) ([]byte, error)
- func SessionCookie(value string, secure bool) string
- func SessionMetadataKey(hostID, sessionID string) string
- func SessionMetadataSelectedKey(metadata SessionMetadata) string
- func ValidateBrowserFrame(payload []byte) error
- func ValidateDeletionPreservation(before, after DeletionLedgerSummary) error
- func ValidateOptionalProjectID(id string) error
- func ValidateOptionalProjectKey(key *string) error
- func ValidateQueuePreservation(before, after QueueLedgerSummary) error
- func ValidateSchedulePreservation(before, after ScheduleLedgerSummary) error
- func ValidateSessionMetadataKey(hostID, sessionID string) error
- func VerifyPairingSecret(store persist.Store, secret string) error
- func VerifyPassword(encoded, candidate string) bool
- type AdmissionGate
- type AgentOperations
- type AgentProfile
- type AggregateByteAdmission
- func (a *AggregateByteAdmission) OrdinaryBytes() int
- func (a *AggregateByteAdmission) ReleaseControl(size int)
- func (a *AggregateByteAdmission) ReleaseOrdinary(size int)
- func (a *AggregateByteAdmission) TryAcquireControl(size int) bool
- func (a *AggregateByteAdmission) TryAcquireOrdinary(size int) bool
- type AppConfig
- type AppConfigPatch
- type Auth
- type AuthConfig
- func (c AuthConfig) ExpectedOrigin(request *http.Request) (string, error)
- func (c AuthConfig) IsAllowedAuthority(request *http.Request) bool
- func (c AuthConfig) IsAllowedTransport(request *http.Request) bool
- func (c AuthConfig) IsAuthorizedHTTPRequest(request *http.Request, auth *Auth) bool
- func (c AuthConfig) IsAuthorizedRoute(request *http.Request, auth *Auth) bool
- func (c AuthConfig) IsExpectedOrigin(request *http.Request) bool
- func (c AuthConfig) IsStrictAllowedAuthority(request *http.Request) bool
- func (c AuthConfig) IsStrictAuthorizedHTTPRequest(request *http.Request, auth *Auth) bool
- func (c AuthConfig) SecureCookie(request *http.Request) bool
- type AuthHardening
- type AuthOptions
- type BrowserAdmission
- func (a *BrowserAdmission) Release(clientKey, method string, size int)
- func (a *BrowserAdmission) ReleaseControl(size int)
- func (a *BrowserAdmission) ReleaseOrdinary(clientKey string, size int)
- func (a *BrowserAdmission) TryAcquireControl(size int) bool
- func (a *BrowserAdmission) TryAcquireOrdinary(clientKey string, size int) bool
- type BrowserAdmissionLimits
- type BrowserMCPConfig
- type BrowserMCPServerInfo
- type BrowserMCPStatus
- type CoreHandler
- type DeletionAuthorityMode
- type DeletionLedgerSummary
- type DeletionMigrationDecision
- type DeletionProjectMove
- type DeletionReconciliation
- type DeletionRecovery
- type DeletionTombstone
- type ErrControllerQuiescing
- type HTTPHandler
- type Handler
- type HealthTransition
- type HistoryIndex
- type ImageContent
- type LedgerKind
- type LedgerPublishDecision
- func DecideDeletionPublish(outcome persist.PublishOutcome) LedgerPublishDecision
- func DecideLedgerPublish(ledger LedgerKind, outcome persist.PublishOutcome) LedgerPublishDecision
- func DecideQueuePublish(outcome persist.PublishOutcome) LedgerPublishDecision
- func DecideSchedulePublish(outcome persist.PublishOutcome) LedgerPublishDecision
- type ModelReference
- type ObjectiveHandler
- type Objectives
- func (o *Objectives) ClearGoal(projectID, sessionID string) error
- func (o *Objectives) Forget(projectID, sessionID string) error
- func (o *Objectives) Get(projectID, sessionID string) (SessionGoal, error)
- func (o *Objectives) Update(projectID, sessionID string, goal *string, tasks *[]SessionTask) (SessionGoal, error)
- type PiAdmin
- func (a *PiAdmin) AdapterStatus(ctx context.Context) map[string]any
- func (a *PiAdmin) BrowserMCPStatus(ctx context.Context, projectDir string) (BrowserMCPStatus, error)
- func (a *PiAdmin) ClearDefaults(ctx context.Context) (PiProviderDefaults, error)
- func (a *PiAdmin) ConfigureBrowserMCP(ctx context.Context, request map[string]any) (BrowserMCPStatus, error)
- func (a *PiAdmin) Handle(ctx context.Context, method string, raw json.RawMessage, clientKey string) (any, error)
- func (a *PiAdmin) LogoutProvider(ctx context.Context, providerID string) error
- func (a *PiAdmin) Models(ctx context.Context) ([]WireModel, error)
- func (a *PiAdmin) ProviderReadiness(ctx context.Context, providerID string) (map[string]any, error)
- func (a *PiAdmin) ProviderStatus(ctx context.Context) (map[string]any, error)
- func (a *PiAdmin) ReadDefaults(ctx context.Context) (PiProviderDefaults, error)
- func (a *PiAdmin) ReadPreferences(ctx context.Context) (PiPreferences, error)
- func (a *PiAdmin) RefreshModels(ctx context.Context) (map[string]any, error)
- func (a *PiAdmin) RemoveBrowserMCP(ctx context.Context, projectDir string) (BrowserMCPStatus, error)
- func (a *PiAdmin) ResetPreferences(ctx context.Context, keys []string) (PiPreferences, error)
- func (a *PiAdmin) SaveDefaults(ctx context.Context, providerID string, modelID *string) (PiProviderDefaults, error)
- func (a *PiAdmin) SavePreferences(ctx context.Context, preferences PiPreferences) (PiPreferences, error)
- func (a *PiAdmin) SetAllModelVisibility(ctx context.Context, hidden bool) ([]WireModel, error)
- func (a *PiAdmin) SetModelVisibility(ctx context.Context, provider, id string, hidden bool) ([]WireModel, error)
- type PiClient
- func (c *PiClient) CallPi(ctx context.Context, method string, params any) (json.RawMessage, error)
- func (c *PiClient) CallPiUntilDone(ctx context.Context, method string, params any) (json.RawMessage, error)
- func (c *PiClient) Cancel(ctx context.Context, sessionID string) error
- func (c *PiClient) Close()
- func (c *PiClient) DeleteSession(ctx context.Context, sessionID string) error
- func (c *PiClient) ForkSession(ctx context.Context, request piwire.LoadSessionRequest) (piwire.NewSessionResponse, error)
- func (c *PiClient) ListSessions(ctx context.Context, request piwire.ListSessionsRequest) (piwire.ListSessionsResponse, error)
- func (c *PiClient) LoadSession(ctx context.Context, request piwire.LoadSessionRequest) (piwire.LoadSessionResponse, error)
- func (c *PiClient) NewSession(ctx context.Context, request piwire.NewSessionRequest) (piwire.NewSessionResponse, error)
- func (c *PiClient) Profile(ctx context.Context) (generation uint64, profile AgentProfile, err error)
- func (c *PiClient) Prompt(ctx context.Context, request piwire.PromptRequest) (piwire.PromptResponse, error)
- func (c *PiClient) Ready(ctx context.Context) (uint64, error)
- func (c *PiClient) ReleaseSession(ctx context.Context, sessionID, cwd string) error
- func (c *PiClient) Reset()
- func (c *PiClient) SetConfig(ctx context.Context, request piwire.SetSessionConfigOptionRequest) (piwire.SetSessionConfigOptionResponse, error)
- type PiEvents
- type PiPreferenceDescriptor
- type PiPreferences
- type PiProviderDefaults
- type ProjectSessionRecord
- type ProviderLogins
- func (p *ProviderLogins) Cancel(clientKey, loginID string) error
- func (p *ProviderLogins) Close()
- func (p *ProviderLogins) DeviceCode(value map[string]any)
- func (p *ProviderLogins) Reply(clientKey, loginID, value string) error
- func (p *ProviderLogins) Snapshot(clientKey string) any
- func (p *ProviderLogins) Start(ctx context.Context, clientKey, providerID, kind string) (any, error)
- type QueueAssociation
- type QueueBlock
- type QueueLedgerSummary
- type QueueProjectMove
- type ReplayCache
- func (c *ReplayCache) Acknowledge(client string, ids []string)
- func (c *ReplayCache) ClearClient(client string) bool
- func (c *ReplayCache) ReleaseClient(client string)
- func (c *ReplayCache) Retain(client string, ids []string)
- func (c *ReplayCache) Run(ctx context.Context, client, id, fingerprint string, ...) ([]byte, error)
- type Runtime
- type RuntimeConfig
- type RuntimeDiagnosticsCapabilities
- type RuntimeDiagnosticsDeletionReconciliation
- type RuntimeDiagnosticsHealth
- type RuntimeDiagnosticsHost
- type RuntimeDiagnosticsReport
- type RuntimeDiagnosticsRuns
- type RuntimeDiagnosticsSchedule
- type Schedule
- type ScheduleCanceler
- type ScheduleCancellationOutcome
- type ScheduleLedgerSummary
- type ScheduleMigrationPlan
- type ScheduleRun
- type ScheduleRunner
- type ScheduleRuntimePolicy
- type Schedules
- func (s *Schedules) Close(ctx context.Context)
- func (s *Schedules) Handle(ctx context.Context, method string, p map[string]any) (any, error)
- func (s *Schedules) Health() string
- func (s *Schedules) SetCancellationHandler(cancel ScheduleCanceler)
- func (s *Schedules) SetPublishFaults(faults persist.PublishFaults)
- func (s *Schedules) Start()
- func (s *Schedules) Watchdog(now time.Time)
- type SessionDeletions
- func (deletions *SessionDeletions) Confirm(projectID, sessionID string) error
- func (deletions *SessionDeletions) Forget(projectID, sessionID string) error
- func (deletions *SessionDeletions) List() ([]sessionDeletion, error)
- func (deletions *SessionDeletions) Request(projectID, sessionID, agentBinding string) error
- func (deletions *SessionDeletions) SetPublishFaults(faults persist.PublishFaults)
- type SessionGoal
- type SessionManager
- func (m *SessionManager) Abort(ctx context.Context, sessionID string) error
- func (m *SessionManager) Archive(ctx context.Context, projectID, sessionID, cwd string) error
- func (m *SessionManager) Branch(ctx context.Context, projectID, sessionID, cwd, entryID string) (SessionSummary, error)
- func (m *SessionManager) CancelDialog(ctx context.Context, sessionID, requestID string) error
- func (m *SessionManager) ClampThinking(sessionID, requested string) (string, error)
- func (m *SessionManager) ClearObjectiveGoal(ctx context.Context, projectID, sessionID string) (SessionGoal, error)
- func (m *SessionManager) ConfirmExternalDeletion(projectID, sessionID string) error
- func (m *SessionManager) Create(ctx context.Context, projectID, cwd string, model *WireModel, ...) (map[string]any, error)
- func (m *SessionManager) CreateDeferred(ctx context.Context, projectID, cwd string, model *WireModel, ...) (any, error)
- func (m *SessionManager) Delete(ctx context.Context, projectID, sessionID, cwd string) error
- func (m *SessionManager) DeletionReconciliationStatus() []DeletionReconciliation
- func (m *SessionManager) DeletionRecoveryStatus() []DeletionRecovery
- func (m *SessionManager) EditQueue(ctx context.Context, sessionID, lane string, index int, text, revision string) error
- func (m *SessionManager) EnsureAttached(ctx context.Context, sessionID, projectID, cwd string) (*sessionEntry, error)
- func (m *SessionManager) Extension(ctx context.Context, method string, params json.RawMessage) error
- func (m *SessionManager) Fork(ctx context.Context, projectID, sessionID, cwd string) (SessionSummary, error)
- func (m *SessionManager) IdleReleaseEligible(sessionID string) (bool, string)
- func (m *SessionManager) List(ctx context.Context, projectID string, archived any) ([]SessionSummary, error)
- func (m *SessionManager) Messages(ctx context.Context, sessionID, projectID, cwd, clientKey string) (map[string]any, error)
- func (m *SessionManager) Objective(ctx context.Context, projectID, sessionID string) (SessionGoal, error)
- func (m *SessionManager) ObjectiveOwner(token string) (string, string, bool)
- func (m *SessionManager) Prompt(ctx context.Context, sessionID, text string, images []ImageContent, ...) error
- func (m *SessionManager) Queue(ctx context.Context, sessionID, text string) error
- func (m *SessionManager) RecordedCWD(projectID, sessionID string) (string, error)
- func (m *SessionManager) RecoverDeletions(ctx context.Context) error
- func (m *SessionManager) RefreshFromDisk(ctx context.Context, sessionID, projectID, cwd string) (bool, error)
- func (m *SessionManager) RegisterSessionLiveness(sessionID, name string, isActive func() bool) func()
- func (m *SessionManager) Release(sessionID, projectID, cwd, clientKey string)
- func (m *SessionManager) ReleaseClient(clientKey string)
- func (m *SessionManager) ReleaseIdleRuntime(ctx context.Context, sessionID string) error
- func (m *SessionManager) ReleaseIdleRuntimeForClient(ctx context.Context, sessionID, projectID, clientKey string) error
- func (m *SessionManager) ReleaseProject(projectID string)
- func (m *SessionManager) RemoveQueue(ctx context.Context, sessionID, lane string, index int, revision string) error
- func (m *SessionManager) Rename(ctx context.Context, projectID, sessionID, cwd, title string) error
- func (m *SessionManager) ResolveDialog(ctx context.Context, sessionID, requestID string, result map[string]any) error
- func (m *SessionManager) RetainExternalDeletion(projectID, sessionID string) error
- func (m *SessionManager) RetryQueue(ctx context.Context, sessionID, lane string, index int, revision string) error
- func (m *SessionManager) SessionSchemaSummary() *diagnostics.SessionSchemaSummary
- func (m *SessionManager) SessionUpdate(ctx context.Context, notification piwire.SessionNotification) error
- func (m *SessionManager) SetAdmissionGate(gate *AdmissionGate)
- func (m *SessionManager) SetClient(client *PiClient)
- func (m *SessionManager) SetConfigOption(ctx context.Context, sessionID, configID, value string) error
- func (m *SessionManager) SetDeletionAuthority(mode DeletionAuthorityMode, storageKey string)
- func (m *SessionManager) SetDeletionPublishFaults(faults persist.PublishFaults)
- func (m *SessionManager) SetLeases(clientKey string, revision uint64, requested []sessionLease) error
- func (m *SessionManager) SetMCPRegistry(registry *mcpserver.Registry)
- func (m *SessionManager) SetModel(ctx context.Context, sessionID string, model WireModel) error
- func (m *SessionManager) SetObjectiveURL(url string)
- func (m *SessionManager) SetSettings(settings *Settings)
- func (m *SessionManager) SetThinking(ctx context.Context, sessionID, level string) error
- func (m *SessionManager) Stats(sessionID string) (SessionStats, error)
- func (m *SessionManager) Steer(ctx context.Context, sessionID, text string, images []ImageContent, ...) error
- func (m *SessionManager) Stop(ctx context.Context, sessionID string) (StopOutcome, error)
- func (m *SessionManager) ThinkingLevels(sessionID string) ([]string, error)
- func (m *SessionManager) Unarchive(ctx context.Context, projectID, sessionID string) error
- func (m *SessionManager) UpdateObjective(ctx context.Context, projectID, sessionID string, goal *string, ...) (SessionGoal, error)
- func (m *SessionManager) UpdateObjectiveFromAgent(ctx context.Context, projectID, sessionID string, goal *string, ...) (SessionGoal, error)
- type SessionMetadata
- func SelectSessionMetadataSubset(sessions []SessionMetadata, selectedKey string, limit int, expanded bool) (visible []SessionMetadata, hiddenCount int)
- func SessionMetadataFromSummary(hostID string, summary SessionSummary) SessionMetadata
- func SortSessionMetadataRecentFirst(sessions []SessionMetadata) []SessionMetadata
- type SessionMetadataCatalog
- type SessionPlanEntry
- type SessionPlanState
- type SessionPublisher
- type SessionQueue
- type SessionQueues
- func (queues *SessionQueues) Forget(projectID, sessionID string) error
- func (queues *SessionQueues) Get(projectID, sessionID string) (sessionQueueState, bool, error)
- func (queues *SessionQueues) List() ([]storedSessionQueue, error)
- func (queues *SessionQueues) Save(projectID, sessionID string, state sessionQueueState) error
- func (queues *SessionQueues) SetPublishFaults(faults persist.PublishFaults)
- type SessionRecords
- type SessionSettlement
- type SessionStats
- type SessionSummary
- type SessionTask
- type SessionTokens
- type Settings
- func (s *Settings) BrowserMCP() (BrowserMCPConfig, error)
- func (s *Settings) Get() (AppConfig, error)
- func (s *Settings) SetBrowserMCP(value BrowserMCPConfig) (BrowserMCPConfig, error)
- func (s *Settings) SetModelVisibility(provider, id string, hidden bool) (AppConfig, error)
- func (s *Settings) SetPublishFaults(faults persist.PublishFaults)
- func (s *Settings) Update(patch AppConfigPatch) (AppConfig, error)
- type StopOutcome
- type SupportSnapshotAuthenticationRequiredError
- type TextResourceAttachment
- type WebSocketServer
- func (s *WebSocketServer) BeginDrain()
- func (s *WebSocketServer) Close(ctx context.Context)
- func (s *WebSocketServer) Publish(ctx context.Context, channel string, data any) error
- func (s *WebSocketServer) PublishToClient(ctx context.Context, clientKey, channel string, data any) error
- func (s *WebSocketServer) Quiescing() bool
- func (s *WebSocketServer) ServeHTTP(response http.ResponseWriter, request *http.Request)
- func (s *WebSocketServer) WaitForDrain(ctx context.Context)
- type Welcome
- type WireModel
Constants ¶
const ( AuthCookieName = "pixie_auth" SessionMaxAge = 90 * 24 * time.Hour // PasswordHashPrefix identifies the encoded scrypt credential format. PasswordHashPrefix = "scrypt" )
const ( DefaultControllerPort = 7312 // DefaultDataDir is the last-resort state directory when neither // PIXIE_DATA_DIR nor a home directory is available. Containers pin // PIXIE_DATA_DIR explicitly; see defaultDataDir. DefaultDataDir = "/var/lib/pixie" // DefaultStaticDir is the last-resort web asset directory, matching the // container layout. Release binaries serve embedded assets instead; see // resolveStaticFiles. DefaultStaticDir = "/app/web" )
const ( ScheduleMigrationPhasePrepared = "prepared" ScheduleMigrationPhaseMigrating = "migrating" )
const ( DeletionMigrationPhasePrepared = "prepared" DeletionMigrationPhaseMigrating = "migrating" )
Repeatable deletion migration phases mirror the project-root journal: prepared inspects and stages, migrating publishes through checkpoints.
const ( DeletionDecisionPreserve = "preserve" DeletionDecisionMigrate = "migrate" DeletionDecisionBlocked = "retain-recovery-blocked" )
Deletion migration decisions. Tombstones are never discarded and a delete is never replayed against a new endpoint.
const ( StopStatusStopping = "stopping" StopStatusStopped = "stopped" StopStatusUncertain = "uncertain" )
const ( QueueMigrationPhasePrepared = "prepared" QueueMigrationPhaseMigrating = "migrating" )
Repeatable queue migration phases mirror the project-root journal: prepared inspects and stages, migrating publishes through checkpoints.
const ( BrowserProtocolVersion = 88 BrowserFrameMaxBytes = 32 * 1024 * 1024 BrowserAggregateMaxBytes = 64 * 1024 * 1024 BrowserOrdinaryInflightPerConnection = 128 BrowserOrdinaryInflightPerEngine = 256 BrowserControlInflightMax = 8 BrowserControlFrameMaxBytes = 64 * 1024 BrowserControlReserveBytes = 1024 * 1024 BrowserEnvelopeMaxKeys = 8 BrowserIDMaxBytes = 256 BrowserMethodMaxBytes = 128 BrowserAckMaxIDs = 512 BrowserSessionIDMaxBytes = 4096 )
Browser transport bounds for LIMIT-01/X07-X08.
Effective units and bounds at this level:
- Frame/record: serialized UTF-8 bytes per browser/host frame, BrowserFrameMaxBytes (32 MiB). Not an allocation budget; decoded structures are bounded separately below.
- Ordinary in-flight: BrowserOrdinaryInflightPerConnection (128 per connection) and BrowserOrdinaryInflightPerEngine (256 per controller process), additionally constrained by aggregate bytes.
- Aggregate: BrowserAggregateMaxBytes (64 MiB serialized request bytes) per controller process across admitted ordinary in-flight browser inputs. Per-socket output (32 MiB, see socket_output.go) and replay retention (16 MiB per namespace, see replay.go) compose under the same process ceiling; reservations are held while a request is dispatched and released on every terminal path.
- Control lane: BrowserControlInflightMax (8) small operations per engine, each at most BrowserControlFrameMaxBytes (64 KiB) within BrowserControlReserveBytes (1 MiB) reserved storage. Only Stop/UI cancellation (session.abort, session.uiCancel) use this lane; normal traffic cannot consume it and it never bypasses auth/schema checks.
- Decoded structures: envelope keys, id/method lengths and ack/resume fan-out bounded separately from serialized bytes; Unicode is counted in UTF-8 bytes so escaping cannot bypass byte limits.
const BrowserMaxConnections = 64
BrowserMaxConnections bounds every tracked browser identity: an active socket and a disconnected client still inside its replay-reap grace period both count. Reconnect load above this bound is shed before it can grow sockets, per-socket writers, replay namespaces or reap timers without limit.
const UntitledSessionTitle = "Untitled chat"
UntitledSessionTitle is the explicit fallback for missing native titles. No model call is used to generate titles.
Variables ¶
var ProviderInventoryTTL = 60 * time.Second
ProviderInventoryTTL bounds how long a successfully resolved provider projection is reused. It is short by design: Pi stays authoritative, and a configuration mutation invalidates the entry immediately through the revision identity guard. Tests override it to exercise expiry without a real minute-long wait.
Functions ¶
func CheckDeletionBindingV2 ¶
func CheckDeletionBindingV2(pairing persist.PairingAuthority, sessionID, binding string) error
CheckDeletionBindingV2 verifies a v2 deletion binding with a constant-time comparison. Legacy endpoint-derived bindings and bindings for another authority, storage or session stay recovery-blocked with an actionable error instead of replaying against a new endpoint.
func DeletionBindingV2 ¶
func DeletionBindingV2(pairing persist.PairingAuthority, sessionID string) (string, error)
DeletionBindingV2 binds a destructive recovery to the durable pairing plus the exact session association. It replaces endpoint/secret-derived bindings: only authorityBindingId, hostIdentity, verified storage and session ID feed the digest.
func DisplaySessionMetadataTitle ¶
DisplaySessionMetadataTitle returns the native title as-is with an explicit unresolved fallback. No model call is used.
func EmbeddedWebUI ¶
EmbeddedWebUI returns the embedded web bundle and whether it holds a real build. Binaries compiled before `bun run build:web` embed only the tracked placeholder and report false, so disk assets apply instead.
func ExpiredSessionCookie ¶
func HashPassword ¶
HashPassword derives a fresh scrypt credential with a random salt. The returned encoding records the cost parameters so a later parameter bump still verifies existing credentials.
func InspectPairingAuthority ¶
InspectPairingAuthority returns the durable pairing without writes.
func IsBrowserControlMethod ¶
IsBrowserControlMethod reports whether a browser method uses the reserved control lane. Only Stop (session.abort) and UI cancellation (session.uiCancel) are control; history/data work stays ordinary.
func IsDrainGatedMethod ¶
IsDrainGatedMethod reports whether a browser method creates or resumes runnable work and therefore participates in the admission gate.
func IsPairingRecoveryBlocked ¶
IsPairingRecoveryBlocked reports whether an error is the actionable recovery-blocked quarantine rather than another failure.
func IsUngroupedProjectKey ¶
IsUngroupedProjectKey reports whether a nullable host-side project key means an ungrouped session. Only nil or the empty string is ungrouped.
func PairAuthority ¶
func PairAuthority(store persist.Store, hostIdentity, storageKey, secret string) (persist.PairingAuthority, error)
PairAuthority performs the explicit pairing ceremony without fault injection.
func PairAuthorityWithFaults ¶
func PairAuthorityWithFaults(store persist.Store, hostIdentity, storageKey, secret string, faults persist.PublishFaults) (persist.PairingAuthority, persist.PublishOutcome, error)
PairAuthorityWithFaults performs the explicit pairing ceremony: it binds a fresh durable authority ID to the verified host identity and native storage under an explicit secret verifier. It never records endpoint, port, boot ID or transport credentials. Pairing while paired is rejected so re-pairing after revoked status or changed storage stays explicit.
func PairedDeletionBinding ¶
func PairedDeletionBinding(pairing persist.PairingAuthority, sessionID string) (string, error)
PairedDeletionBinding returns the versioned binding persisted with a requested deletion record while a durable pairing is active. It is the existing DeletionBindingV2 digest shape carried under deletionBindingV2Prefix so paired recovery can tell a record-level v2 binding from a legacy agent digest and verify the exact paired session.
func PasswordHashValid ¶
PasswordHashValid reports whether encoded is a well-formed scrypt credential within the accepted parameter range.
func PlanQueueProjectMigration ¶
func PlanQueueProjectMigration(associations []QueueAssociation, moves []QueueProjectMove, verified map[string]bool) (planned []QueueAssociation, retained []QueueAssociation, conflicts []string, err error)
PlanQueueProjectMigration is a pure, repeatable dry-run: re-running identical inputs yields identical outputs. It converts project-required queue keys only where verified[sourceProject\x00session] is true and otherwise retains the association instead of fabricating a hidden all-files project. Conversion must preserve revision, follow-ups, dispatch/blocked uncertainty and handled mutation/delivery IDs; callers verify payload equality except for the project key before applying. Unknown source files are never touched by this plan.
func ReadAuthCookie ¶
func RequirePairedRecovery ¶
func RequirePairedRecovery(store persist.Store, liveHostIdentity, liveStorageKey string, authenticated bool) (persist.PairingAuthority, error)
RequirePairedRecovery guards destructive recovery against the durable pairing. It requires the stored binding plus an authenticated connection to the paired host/storage. Boot ID, port and endpoint are intentionally not parameters: they are ephemeral dialing state and never prove or break pairing. A claimed host identity alone is not proof without authentication.
func RevokePairingAuthority ¶
func RevokePairingAuthority(store persist.Store) (persist.PairingAuthority, error)
RevokePairingAuthority explicitly revokes the durable pairing without fault injection.
func RevokePairingAuthorityWithFaults ¶
func RevokePairingAuthorityWithFaults(store persist.Store, faults persist.PublishFaults) (persist.PairingAuthority, persist.PublishOutcome, error)
RevokePairingAuthorityWithFaults explicitly revokes the durable pairing. The record is retained while destructive recovery stays blocked until an explicit re-pairing ceremony.
func RotatePairingSecret ¶
func RotatePairingSecret(store persist.Store, currentSecret, newSecret string) (persist.PairingAuthority, error)
RotatePairingSecret performs verified secret rotation without fault injection.
func RotatePairingSecretWithFaults ¶
func RotatePairingSecretWithFaults(store persist.Store, currentSecret, newSecret string, faults persist.PublishFaults) (persist.PairingAuthority, persist.PublishOutcome, error)
RotatePairingSecretWithFaults performs verified secret rotation: proof of the current secret authorizes a new verifier while the durable binding, host identity and storage stay unchanged. A new port, boot ID or rotated credential is therefore not a new native session.
func ScryptKey ¶
ScryptKey derives a key using the scrypt construction from RFC 7914. It is implemented with the standard library so the controller adds no dependency; the RFC test vectors in the controller tests pin the output.
func SessionCookie ¶
func SessionMetadataKey ¶
SessionMetadataKey returns the stable host/session association key. Host and session IDs are paired opaquely; duplicate native session IDs across hosts never collapse by first match.
func SessionMetadataSelectedKey ¶
func SessionMetadataSelectedKey(metadata SessionMetadata) string
SessionMetadataSelectedKey returns the host/session key for one metadata row.
func ValidateBrowserFrame ¶
ValidateBrowserFrame bounds one serialized browser frame and its decoded envelope separately. Units are serialized UTF-8 bytes; Unicode/escaping cannot bypass the byte limits because len counts UTF-8 bytes.
func ValidateDeletionPreservation ¶
func ValidateDeletionPreservation(before, after DeletionLedgerSummary) error
ValidateDeletionPreservation confirms a staged conversion kept every requested/confirmed phase and tombstone. It never touches storage.
func ValidateOptionalProjectID ¶
ValidateOptionalProjectID accepts an empty (ungrouped) project reference or a grouped project identifier without touching storage.
func ValidateOptionalProjectKey ¶
ValidateOptionalProjectKey accepts a nil/empty (ungrouped) project key or a grouped project identifier. Grouped identifiers share the durable identity bound used by controller records: no NUL, no slashes, no surrounding whitespace, UTF-16 length within 256.
func ValidateQueuePreservation ¶
func ValidateQueuePreservation(before, after QueueLedgerSummary) error
ValidateQueuePreservation confirms a staged conversion kept every follow-up, uncertain dispatch/block and handled mutation identity. It never touches storage.
func ValidateSchedulePreservation ¶
func ValidateSchedulePreservation(before, after ScheduleLedgerSummary) error
func ValidateSessionMetadataKey ¶
ValidateSessionMetadataKey validates the stable host/session association without touching storage. The host may be empty for the default host, but the native session ID is always required and never used as a path.
func VerifyPairingSecret ¶
VerifyPairingSecret checks an explicit ceremony secret against the stored verifier. Revoked or missing pairings fail closed without verifying.
func VerifyPassword ¶
VerifyPassword derives the candidate with the stored parameters and compares it in constant time. Any parse or parameter failure fails closed.
Types ¶
type AdmissionGate ¶
type AdmissionGate struct {
// contains filtered or unexported fields
}
AdmissionGate is the process-local drain gate. BeginDrain flips it to refusing new gated work; WaitForDrain then blocks until the already-admitted set empties (or the context ends). The zero value is not usable; use NewAdmissionGate.
func NewAdmissionGate ¶
func NewAdmissionGate(grace time.Duration) *AdmissionGate
NewAdmissionGate builds an open gate. BeginDrain refuses new runnable work immediately: the grace argument is accepted for call-site compatibility but does not delay the refusal or wait for work already on the wire.
func (*AdmissionGate) BeginDrain ¶
func (g *AdmissionGate) BeginDrain()
BeginDrain flips the gate to refusing new runnable work. It is idempotent and never revokes work that was already admitted. It returns only after the refusal is visible, so a caller that proceeds knows new work is paused.
func (*AdmissionGate) Quiescing ¶
func (g *AdmissionGate) Quiescing() bool
Quiescing reports whether the gate is refusing new runnable work.
func (*AdmissionGate) Release ¶
func (g *AdmissionGate) Release(method string) bool
Release settles one admission for method. It is method-scoped: a non-gated method never decrements the in-flight count, so a read-only request completing can never settle an admitted runnable slot. Call it exactly once for each gated method that TryAdmit admitted. It reports whether the gated in-flight set is now empty.
func (*AdmissionGate) TryAdmit ¶
func (g *AdmissionGate) TryAdmit(method string) bool
TryAdmit reports whether a method may start now. Run-creating methods are counted as in-flight so a drain waits for them. An admission that starts an asynchronous run is handed to that run through runAdmission, which holds the count past dispatch and releases it when the run settles; every admission must be released exactly once with the same method (see Release). Non-gated methods are never counted.
func (*AdmissionGate) WaitForDrain ¶
func (g *AdmissionGate) WaitForDrain(ctx context.Context)
WaitForDrain blocks until no admitted gated method remains or ctx ends.
type AgentOperations ¶
type AgentOperations struct {
DeleteSession bool `json:"deleteSession"`
ForkSession bool `json:"forkSession"`
PromptImage bool `json:"promptImage"`
PromptEmbeddedContext bool `json:"promptEmbeddedContext"`
HTTPMCP bool `json:"httpMcp"`
Steer bool `json:"steer"`
RenameSession bool `json:"renameSession"`
ArchiveSession bool `json:"archiveSession"`
Administration bool `json:"administration"`
}
type AgentProfile ¶
type AgentProfile struct {
Capabilities map[string]int `json:"capabilities"`
Name string `json:"name"`
Version string `json:"version"`
BootID string `json:"bootId,omitempty"`
Pi bool `json:"pi"`
Compatible bool `json:"compatible"`
MissingRequired []string `json:"missingRequired"`
Operations AgentOperations `json:"operations"`
// OperationSet is negotiated by host hello and contains a support bit for
// each retained operation. It is intentionally distinct from the specific
// operation projections above so unsupported optional routes remain visible.
OperationSet map[string]bool `json:"operationSet,omitempty"`
// contains filtered or unexported fields
}
type AggregateByteAdmission ¶
type AggregateByteAdmission struct {
// contains filtered or unexported fields
}
AggregateByteAdmission accounts retained ordinary and reserved control bytes for one controller process. The same instance is shared by browser request admission, replay retention and socket output queues, so a large history response cannot evade the process-wide aggregate ceiling by moving between subsystems. Control storage is independent and is never consumed by ordinary traffic.
func NewAggregateByteAdmission ¶
func NewAggregateByteAdmission(ordinaryLimit, controlLimit int) *AggregateByteAdmission
NewAggregateByteAdmission creates a byte budget. Non-positive limits use the controller contract defaults.
func (*AggregateByteAdmission) OrdinaryBytes ¶
func (a *AggregateByteAdmission) OrdinaryBytes() int
OrdinaryBytes reports currently retained ordinary bytes.
func (*AggregateByteAdmission) ReleaseControl ¶
func (a *AggregateByteAdmission) ReleaseControl(size int)
ReleaseControl releases a prior control reservation.
func (*AggregateByteAdmission) ReleaseOrdinary ¶
func (a *AggregateByteAdmission) ReleaseOrdinary(size int)
ReleaseOrdinary releases a prior ordinary reservation.
func (*AggregateByteAdmission) TryAcquireControl ¶
func (a *AggregateByteAdmission) TryAcquireControl(size int) bool
TryAcquireControl reserves bytes from the independent control lane.
func (*AggregateByteAdmission) TryAcquireOrdinary ¶
func (a *AggregateByteAdmission) TryAcquireOrdinary(size int) bool
TryAcquireOrdinary reserves ordinary serialized bytes.
type AppConfig ¶
type AppConfig struct {
HiddenModels []ModelReference `json:"hiddenModels"`
BrowserMCP BrowserMCPConfig `json:"browserMCP"`
}
func (*AppConfig) UnmarshalJSON ¶
Persisted settings accept partial objects and normalize individual fields, as the existing controller does; request patches remain separately typed.
type AppConfigPatch ¶
type AppConfigPatch struct {
HiddenModels *[]ModelReference `json:"hiddenModels"`
}
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
func NewAuthFromConfig ¶
func NewAuthFromConfig(config AuthConfig, dataDir string) (*Auth, error)
NewAuthFromConfig applies the optional AuthConfig hardening and loads the persisted signing secret and password hash from dataDir when they are not supplied explicitly.
func NewAuthWithOptions ¶
func NewAuthWithOptions(options AuthOptions) (*Auth, error)
NewAuthWithOptions builds an Auth with the optional hardening. A signing secret is required (explicit, token-derived, or generated in DataDir), and the login credential is either the controller token or a stored scrypt hash.
func (*Auth) LockedUntil ¶
LockedUntil reports the client's lockout expiry. An expired lockout is cleared so the next failure starts a fresh window.
func (*Auth) LoginWithClient ¶
LoginWithClient adds the per-client lockout to Login. clientKey is the request peer identity (for example the remote IP); a locked client is refused even when it presents the correct credential.
type AuthConfig ¶
type AuthConfig struct {
Enabled bool
ControllerToken string
MCPToken string
ControllerHost string
// ControllerPort is the port on which the application listener accepts
// requests. ReadAuthConfig supplies the documented default and Runtime
// overwrites it with the effective configured port. A zero value does not
// admit local authorities because the listener port is then unknown;
// directly constructed handlers should set it explicitly.
ControllerPort int
// TrustedProxyCIDRs identifies TLS-terminating peers that may forward a
// cleartext request. Such a peer must rewrite Host to PublicOrigin's
// authority and set exactly X-Forwarded-Proto: https. Forwarded and
// X-Forwarded-Host remain ignored.
TrustedProxyCIDRs []net.IPNet
PublicOrigin string
AllowRemoteWithout bool
// DataDir is the controller state directory used to load or create the
// persisted signing secret and stored password hash. Empty keeps the
// legacy in-memory token-only behavior.
DataDir string
// Hardening carries the optional authenticated-mode protections. The zero
// value keeps the legacy token-only behavior.
Hardening AuthHardening
}
func ReadAuthConfig ¶
func ReadAuthConfig(getenv func(string) string) (AuthConfig, error)
func (AuthConfig) ExpectedOrigin ¶
func (c AuthConfig) ExpectedOrigin(request *http.Request) (string, error)
ExpectedOrigin returns the separately configured browser origin. Without a public origin, it derives the origin from an already-approved local Host; an arbitrary Host can therefore never manufacture an expected Origin.
func (AuthConfig) IsAllowedAuthority ¶
func (c AuthConfig) IsAllowedAuthority(request *http.Request) bool
IsAllowedAuthority checks the HTTP Host independently of Origin. Public origins describe the browser-facing authority, while local loopback forms are admitted on the configured listener port. An omitted local port is only equivalent when that listener uses the HTTP or HTTPS default port. Forwarded host headers are deliberately not consulted; cleartext TLS termination is handled only by the explicit trusted-peer transport policy.
func (AuthConfig) IsAllowedTransport ¶
func (c AuthConfig) IsAllowedTransport(request *http.Request) bool
IsAllowedTransport rejects cleartext access to an HTTPS public origin unless the request is an actual loopback service call or came from an explicitly configured TLS-terminating peer. The peer policy requires Host rewriting at the edge, so a remote request cannot opt into HTTPS with Origin or token headers alone.
func (AuthConfig) IsAuthorizedHTTPRequest ¶
func (c AuthConfig) IsAuthorizedHTTPRequest(request *http.Request, auth *Auth) bool
func (AuthConfig) IsAuthorizedRoute ¶
func (c AuthConfig) IsAuthorizedRoute(request *http.Request, auth *Auth) bool
IsAuthorizedRoute applies the strict Fetch Metadata and Host policy to unsafe write methods and the existing policy to safe methods. This is the boundary used by authenticated HTTP routes so a cross-site or navigation-style write cannot ride a valid session cookie.
func (AuthConfig) IsExpectedOrigin ¶
func (c AuthConfig) IsExpectedOrigin(request *http.Request) bool
IsExpectedOrigin enforces the browser Origin check after the independent Host check. A missing Origin is intentionally not accepted here; callers that represent explicitly authenticated service traffic use IsAuthorizedHTTPRequest, which permits an absent Origin after authority and credential checks.
func (AuthConfig) IsStrictAllowedAuthority ¶
func (c AuthConfig) IsStrictAllowedAuthority(request *http.Request) bool
IsStrictAllowedAuthority tightens IsAllowedAuthority for the optional authenticated mode: a loopback authority is admitted only from a loopback peer, so a remote client cannot claim the local authority with a rewritten Host header.
func (AuthConfig) IsStrictAuthorizedHTTPRequest ¶
func (c AuthConfig) IsStrictAuthorizedHTTPRequest(request *http.Request, auth *Auth) bool
IsStrictAuthorizedHTTPRequest layers Fetch Metadata onto IsAuthorizedHTTPRequest. Safe methods keep the existing policy; an unsafe method must carry an explicit same-origin fetch site and must not be a top-level navigation or a no-cors fetch. It also applies the strict Host check so a remote peer cannot use the loopback authority.
func (AuthConfig) SecureCookie ¶
func (c AuthConfig) SecureCookie(request *http.Request) bool
SecureCookie derives the cookie transport policy from the real TLS state or the configured public origin. Forwarded proto headers from an untrusted peer cannot turn an HTTP request into a Secure-cookie request.
type AuthHardening ¶
type AuthHardening struct {
SigningSecret string
PasswordHash string
LoginAttemptLimit int
LoginLockout time.Duration
InactivityTimeout time.Duration
}
AuthHardening is the optional authenticated-mode protection set: an explicit signing secret, a stored scrypt password hash, per-client login lockout, a sliding inactivity timeout, and the strict Host/Fetch-Metadata policy applied by IsStrictAuthorizedHTTPRequest.
type AuthOptions ¶
type AuthOptions struct {
Token string
PasswordHash string
SigningSecret string
LoginAttemptLimit int
LoginLockout time.Duration
InactivityTimeout time.Duration
// DataDir loads or persists the signing secret and password hash when they
// are not supplied explicitly.
DataDir string
// Now overrides the clock; nil uses time.Now.
Now func() time.Time
}
AuthOptions configures an Auth instance. Zero hardening durations and limits disable the optional protections, preserving the legacy token-only behavior.
type BrowserAdmission ¶
type BrowserAdmission struct {
// contains filtered or unexported fields
}
BrowserAdmission tracks composed ordinary in-flight counts with aggregate-byte admission plus an independent control reserve. It is safe for concurrent use. Callers must Release every acquired reservation on every terminal path.
func NewBrowserAdmission ¶
func NewBrowserAdmission(limits BrowserAdmissionLimits) *BrowserAdmission
NewBrowserAdmission creates an admission tracker; zero limit fields select contract defaults.
func NewBrowserAdmissionWithAggregate ¶
func NewBrowserAdmissionWithAggregate(limits BrowserAdmissionLimits, aggregate *AggregateByteAdmission) *BrowserAdmission
NewBrowserAdmissionWithAggregate shares one process-wide byte budget with replay retention and socket output queues.
func (*BrowserAdmission) Release ¶
func (a *BrowserAdmission) Release(clientKey, method string, size int)
Release releases admission by method kind.
func (*BrowserAdmission) ReleaseControl ¶
func (a *BrowserAdmission) ReleaseControl(size int)
ReleaseControl releases a reservation acquired by TryAcquireControl.
func (*BrowserAdmission) ReleaseOrdinary ¶
func (a *BrowserAdmission) ReleaseOrdinary(clientKey string, size int)
ReleaseOrdinary releases a reservation acquired by TryAcquireOrdinary.
func (*BrowserAdmission) TryAcquireControl ¶
func (a *BrowserAdmission) TryAcquireControl(size int) bool
TryAcquireControl reserves one control slot plus size bytes from the independent control reserve. Ordinary load never consumes this reserve.
func (*BrowserAdmission) TryAcquireOrdinary ¶
func (a *BrowserAdmission) TryAcquireOrdinary(clientKey string, size int) bool
TryAcquireOrdinary reserves one ordinary slot plus size serialized bytes. Size is counted in serialized UTF-8 bytes.
type BrowserAdmissionLimits ¶
type BrowserAdmissionLimits struct {
OrdinaryPerEngine int
OrdinaryPerConnection int
AggregateMaxBytes int
ControlMax int
ControlFrameMaxBytes int
ControlReserveBytes int
}
BrowserAdmissionLimits configures composed admission. Zero values select the contract defaults via DefaultBrowserAdmissionLimits.
func DefaultBrowserAdmissionLimits ¶
func DefaultBrowserAdmissionLimits() BrowserAdmissionLimits
DefaultBrowserAdmissionLimits returns the LIMIT-01 contract defaults.
type BrowserMCPConfig ¶
type BrowserMCPConfig struct {
Name string `json:"name"`
URL string `json:"url"`
Enabled bool `json:"enabled"`
OwnershipToken string `json:"ownershipToken,omitempty"`
}
BrowserMCPConfig is the persisted browser-MCP registration intent. Pixie registers Name in Pi's own configuration and reports the endpoint state; it never proxies MCP traffic.
type BrowserMCPServerInfo ¶
type BrowserMCPServerInfo struct {
Name string `json:"name,omitempty"`
Version string `json:"version,omitempty"`
}
BrowserMCPServerInfo is retained for wire compatibility. Browser MCP probe responses are endpoint-controlled, so BrowserMCPStatus never populates it.
type BrowserMCPStatus ¶
type BrowserMCPStatus struct {
Name string `json:"name"`
Enabled bool `json:"enabled"`
Registered bool `json:"registered"`
Layer string `json:"layer,omitempty"`
Path string `json:"path,omitempty"`
Disabled bool `json:"disabled"`
Reachable bool `json:"reachable"`
ServerInfo *BrowserMCPServerInfo `json:"serverInfo,omitempty"`
ProtocolVersion string `json:"protocolVersion,omitempty"`
Tools []string `json:"tools"`
Error string `json:"error,omitempty"`
}
BrowserMCPStatus is the browser-safe projection of Pixie's persisted identity and a bounded endpoint probe. It intentionally excludes the raw endpoint, native definition and adapter diagnostics.
type CoreHandler ¶
type CoreHandler struct {
Schedules *Schedules
Projects *workspace.Projects
Files *workspace.Files
Sessions *SessionManager
Settings *Settings
Admin *PiAdmin
Git *workspace.Git
Watches *workspace.ProjectWatches
Requests *diagnostics.RequestCounter
RuntimeStatus func(context.Context) runtimeStatusReport
RuntimeDiagnostics func(context.Context) RuntimeDiagnosticsReport
// SupportSnapshot is deliberately separate from runtime diagnostics. Its
// already-marshaled, bounded JSON contains only the support-export allowlist.
SupportSnapshot func(context.Context) (json.RawMessage, error)
SupportSnapshotAuthEnabled bool
ControllerEvents *diagnostics.ControllerEventRing
MCPRegistry *mcpserver.Registry
}
type DeletionAuthorityMode ¶
type DeletionAuthorityMode string
DeletionAuthorityMode selects how requested deletion records are authorized for replay during recovery.
const ( // DeletionAuthorityAuto requires pairing when a durable pairing record // exists and otherwise keeps the legacy agent-binding match. DeletionAuthorityAuto DeletionAuthorityMode = "auto" // DeletionAuthorityPaired requires a valid durable pairing for every // requested record. Unpaired or mismatched recovery is quarantined. DeletionAuthorityPaired DeletionAuthorityMode = "paired" // DeletionAuthorityLegacy keeps the pre-pairing agent-binding behavior // byte-for-byte, even when a pairing record exists. DeletionAuthorityLegacy DeletionAuthorityMode = "legacy" )
func ParseDeletionAuthorityMode ¶
func ParseDeletionAuthorityMode(value string) (DeletionAuthorityMode, error)
ParseDeletionAuthorityMode resolves PIXIE_DELETION_AUTHORITY case-insensitively. Empty selects auto, the compatibility default.
type DeletionLedgerSummary ¶
type DeletionLedgerSummary struct {
Present bool
Version int
SchemaSupported bool
Requested int
Confirmed int
Tombstones []DeletionTombstone
}
DeletionLedgerSummary is a read-only dry-run view of pi-session-deletions.json with no writes and no destructive effects.
func InspectDeletionLedger ¶
func InspectDeletionLedger(store persist.Store) (DeletionLedgerSummary, error)
InspectDeletionLedger reads the deletion journal with no writes. The primary file is the only deletion authority: a missing or corrupt primary fails closed and never resurrects a completed delete from the older backup.
func ReconcileDeletionAfterPublish ¶
func ReconcileDeletionAfterPublish(store persist.Store, outcome persist.PublishOutcome) (DeletionLedgerSummary, error)
ReconcileDeletionAfterPublish rereads the validated deletion primary after publication. A missing or corrupt primary keeps an uncertain outcome unresolved instead of resurrecting a tombstone from backup.
type DeletionMigrationDecision ¶
type DeletionMigrationDecision struct {
ProjectID string
SessionID string
Phase string
Decision string
Reason string
}
DeletionMigrationDecision records the planned treatment for one deletion record. Unverifiable destructive recovery stays quarantined as retain-recovery-blocked with its tombstone preserved.
func PlanDeletionMigration ¶
func PlanDeletionMigration(tombstones []DeletionTombstone, moves []DeletionProjectMove, verifiedAssociations map[string]bool, verifiedBindings map[string]bool) ([]DeletionMigrationDecision, error)
PlanDeletionMigration is a pure, repeatable dry-run: re-running identical inputs yields identical decisions. It migrates a deletion project key only when both the paired host/native session association and the old agent binding are verified; otherwise it retains the tombstone as recovery-blocked. It never discards a tombstone and never authorizes replaying a delete against a new endpoint or boot credential. Unknown source files are never touched by this plan.
type DeletionProjectMove ¶
DeletionProjectMove proposes one project reassociation for a deletion record. The binding itself never changes during a project move.
type DeletionReconciliation ¶
type DeletionReconciliation struct {
DeletionRecovery
// Remediation is an actionable hint for the confirm/retain decision. It is
// derived from the stored reason and never clears the tombstone.
Remediation string `json:"remediation"`
// Uncertain reports whether the native outcome is unknown (requested phase
// or an uncertain dispatch) rather than a confirmed local-cleanup backlog.
Uncertain bool `json:"uncertain"`
}
DeletionReconciliation is one retained tombstone plus operator guidance. It embeds the wire-compatible DeletionRecovery so existing session.deletionRecovery callers keep working; Remediation never changes the tombstone itself.
type DeletionRecovery ¶
type DeletionRecovery struct {
ProjectID string `json:"projectId"`
SessionID string `json:"sessionId"`
Phase string `json:"phase"`
Reason string `json:"reason"`
}
DeletionRecovery is one retained unauthorized deletion record that could not be safely resumed. It is surfaced for operator reconciliation; the tombstone is never replayed or discarded implicitly.
type DeletionTombstone ¶
DeletionTombstone is the exportable project/session/phase/binding view of one deletion record. Confirmed entries are tombstones that must survive every migration and rollback.
type ErrControllerQuiescing ¶
type ErrControllerQuiescing struct{}
ErrControllerQuiescing is the typed refusal returned to a caller that asks for new work while the controller is draining. It is a deliberate state, not a failure, so the Web UI can report quiescing instead of an error.
func (ErrControllerQuiescing) Error ¶
func (ErrControllerQuiescing) Error() string
func (ErrControllerQuiescing) ErrorCode ¶
func (ErrControllerQuiescing) ErrorCode() string
type HTTPHandler ¶
type HTTPHandler struct {
WebSocket *WebSocketServer
Objective ObjectiveHandler
Projects *workspace.Projects
Files *workspace.Files
Auth AuthConfig
StaticDir string
Ready http.HandlerFunc
MCPRegistry http.Handler
// MODULE-01 module/scope wiring: scope authority plus trusted
// descriptors gate module resource requests before any module service
// delegation. Host/Origin/proxy handling stays untouched.
ModuleScopes *mcpserver.ScopeAuthority
ModuleDescriptors map[string]mcpserver.FrontendDescriptor
ModuleService http.Handler
// SessionRecords is the controller-owned project/session association used
// before delegating Canvas management requests. A route ID alone is never
// treated as permission.
SessionRecords *SessionRecords
// contains filtered or unexported fields
}
func NewHTTPHandler ¶
func NewHTTPHandler(webSocket *WebSocketServer, objective ObjectiveHandler, projects *workspace.Projects, files *workspace.Files, authConfig AuthConfig, staticDir string, ready http.HandlerFunc) (*HTTPHandler, error)
func (*HTTPHandler) ServeHTTP ¶
func (h *HTTPHandler) ServeHTTP(response http.ResponseWriter, request *http.Request)
type HealthTransition ¶
type HealthTransition struct {
At string `json:"at"`
Component string `json:"component"`
From string `json:"from,omitempty"`
To string `json:"to"`
}
HealthTransition is one bounded, secret-free component state change. Only stable state tokens cross this boundary, so operator diagnostics can show a transition history without exporting raw host errors or filesystem paths.
type HistoryIndex ¶
type HistoryIndex struct {
// contains filtered or unexported fields
}
func (*HistoryIndex) Forget ¶
func (h *HistoryIndex) Forget(sessionID string)
type ImageContent ¶
type LedgerKind ¶
type LedgerKind string
LedgerKind names the durable ledger a publication decision guards.
const ( LedgerSchedules LedgerKind = "schedules" LedgerQueue LedgerKind = "queue" LedgerDeletions LedgerKind = "deletions" )
type LedgerPublishDecision ¶
type LedgerPublishDecision struct {
Ledger LedgerKind
MayDispatch bool
MustReconcile bool
MustRetainMutation bool
Reason string
}
LedgerPublishDecision tells callers whether an uncertain or failed publication may dispatch, must reconcile or must retain mutation identity. Only an installed outcome allows dependent mutations or unsafe effects.
func DecideDeletionPublish ¶
func DecideDeletionPublish(outcome persist.PublishOutcome) LedgerPublishDecision
DecideDeletionPublish guards deletion publication. Tombstones never resurrect through fallback and a delete is never replayed against a new endpoint, including after an uncertain publish.
func DecideLedgerPublish ¶
func DecideLedgerPublish(ledger LedgerKind, outcome persist.PublishOutcome) LedgerPublishDecision
DecideLedgerPublish maps a typed persist outcome onto ledger policy: known-uncommitted preserves the prior commit, uncertain blocks dispatch until the validated primary is reconciled, and installed allows progress.
func DecideQueuePublish ¶
func DecideQueuePublish(outcome persist.PublishOutcome) LedgerPublishDecision
DecideQueuePublish guards queue publication. An uncertain queue claim keeps its mutation/delivery identity and must never restore an older runnable queue over dispatched effects.
func DecideSchedulePublish ¶
func DecideSchedulePublish(outcome persist.PublishOutcome) LedgerPublishDecision
DecideSchedulePublish guards schedule publication. An uncertain schedule claim must never dispatch a missed job; ambiguous restarts stay paused until the validated primary is reconciled.
type ModelReference ¶
type ObjectiveHandler ¶
type ObjectiveHandler struct {
Sessions *SessionManager
Schedules *Schedules
}
func (ObjectiveHandler) ServeHTTP ¶
func (h ObjectiveHandler) ServeHTTP(response http.ResponseWriter, request *http.Request)
type Objectives ¶
type Objectives struct {
// contains filtered or unexported fields
}
func NewObjectives ¶
func NewObjectives(store persist.Store) *Objectives
func (*Objectives) ClearGoal ¶
func (o *Objectives) ClearGoal(projectID, sessionID string) error
func (*Objectives) Forget ¶
func (o *Objectives) Forget(projectID, sessionID string) error
Forget removes every objective field and both persisted schema generations. ClearGoal remains separate because clearing a user goal intentionally keeps agent-managed tasks.
func (*Objectives) Get ¶
func (o *Objectives) Get(projectID, sessionID string) (SessionGoal, error)
func (*Objectives) Update ¶
func (o *Objectives) Update(projectID, sessionID string, goal *string, tasks *[]SessionTask) (SessionGoal, error)
type PiAdmin ¶
type PiAdmin struct {
// contains filtered or unexported fields
}
func NewPiAdmin ¶
func (*PiAdmin) AdapterStatus ¶
AdapterStatus projects the pi-mcp-adapter bridge state (`adapter.status` host capability) into the Tools UI. It stays fail-open: when Pi is unreachable or the `pi-mcp-adapter` profile is not enabled, the UI shows the adapter as unavailable instead of failing the settings load.
func (*PiAdmin) BrowserMCPStatus ¶
func (a *PiAdmin) BrowserMCPStatus(ctx context.Context, projectDir string) (BrowserMCPStatus, error)
BrowserMCPStatus reads Pi's effective configuration for the persisted server name, probes the endpoint and reports the composed state. A missing client or a failed host call is an error, never a success-shaped status.
func (*PiAdmin) ClearDefaults ¶
func (a *PiAdmin) ClearDefaults(ctx context.Context) (PiProviderDefaults, error)
func (*PiAdmin) ConfigureBrowserMCP ¶
func (a *PiAdmin) ConfigureBrowserMCP(ctx context.Context, request map[string]any) (BrowserMCPStatus, error)
ConfigureBrowserMCP persists the setting and registers or removes Pixie's instance-wide Pi entry. It returns the same composed status the settings surface reports.
func (*PiAdmin) LogoutProvider ¶
func (*PiAdmin) ProviderReadiness ¶
func (*PiAdmin) ProviderStatus ¶
func (*PiAdmin) ReadDefaults ¶
func (a *PiAdmin) ReadDefaults(ctx context.Context) (PiProviderDefaults, error)
func (*PiAdmin) ReadPreferences ¶
func (a *PiAdmin) ReadPreferences(ctx context.Context) (PiPreferences, error)
func (*PiAdmin) RefreshModels ¶
func (*PiAdmin) RemoveBrowserMCP ¶
func (a *PiAdmin) RemoveBrowserMCP(ctx context.Context, projectDir string) (BrowserMCPStatus, error)
RemoveBrowserMCP unregisters Pixie's instance-wide Pi entry and disables the persisted setting.
func (*PiAdmin) ResetPreferences ¶
func (*PiAdmin) SaveDefaults ¶
func (*PiAdmin) SavePreferences ¶
func (a *PiAdmin) SavePreferences(ctx context.Context, preferences PiPreferences) (PiPreferences, error)
func (*PiAdmin) SetAllModelVisibility ¶
type PiClient ¶
type PiClient struct {
Version string
Timeout time.Duration
Events PiEvents
// contains filtered or unexported fields
}
func NewPiClient ¶
NewPiClient builds a v1 client, preserving today's byte-identical hello. Callers that select a protocol mode use NewPiClientWithProtocol.
func NewPiClientWithProtocol ¶
func NewPiClientWithProtocol(url, secret, version string, events PiEvents, protocolMode piwire.HostProtocolMode) *PiClient
NewPiClientWithProtocol builds a client that negotiates PIXIE_PI_PROTOCOL against the host. The mode applies to every connection the client dials.
func (*PiClient) CallPiUntilDone ¶
func (*PiClient) DeleteSession ¶
func (*PiClient) ForkSession ¶
func (c *PiClient) ForkSession(ctx context.Context, request piwire.LoadSessionRequest) (piwire.NewSessionResponse, error)
func (*PiClient) ListSessions ¶
func (c *PiClient) ListSessions(ctx context.Context, request piwire.ListSessionsRequest) (piwire.ListSessionsResponse, error)
func (*PiClient) LoadSession ¶
func (c *PiClient) LoadSession(ctx context.Context, request piwire.LoadSessionRequest) (piwire.LoadSessionResponse, error)
func (*PiClient) NewSession ¶
func (c *PiClient) NewSession(ctx context.Context, request piwire.NewSessionRequest) (piwire.NewSessionResponse, error)
func (*PiClient) Profile ¶
func (c *PiClient) Profile(ctx context.Context) (generation uint64, profile AgentProfile, err error)
Profile returns the connection generation and the capabilities negotiated by that same connection. The returned profile does not share mutable storage with the connection.
func (*PiClient) Prompt ¶
func (c *PiClient) Prompt(ctx context.Context, request piwire.PromptRequest) (piwire.PromptResponse, error)
func (*PiClient) ReleaseSession ¶
func (*PiClient) SetConfig ¶
func (c *PiClient) SetConfig(ctx context.Context, request piwire.SetSessionConfigOptionRequest) (piwire.SetSessionConfigOptionResponse, error)
type PiPreferenceDescriptor ¶
type PiPreferenceDescriptor struct {
Key string `json:"key"`
Writable bool `json:"writable"`
Source string `json:"source"`
}
PiPreferenceDescriptor carries per-key writability and source for the focused preference projection. It never contains a credential, token, URL or path.
type PiPreferences ¶
type PiPreferences struct {
CompactionReserveTokens *float64 `json:"compactionReserveTokens,omitempty"`
PiThinkingEffort *string `json:"piThinkingEffort,omitempty"`
Keys []PiPreferenceDescriptor `json:"keys,omitempty"`
}
type PiProviderDefaults ¶
type ProjectSessionRecord ¶
type ProviderLogins ¶
type ProviderLogins struct {
// contains filtered or unexported fields
}
func NewProviderLogins ¶
func NewProviderLogins(admin *PiAdmin, publish func(string, any)) *ProviderLogins
func (*ProviderLogins) Cancel ¶
func (p *ProviderLogins) Cancel(clientKey, loginID string) error
func (*ProviderLogins) Close ¶
func (p *ProviderLogins) Close()
func (*ProviderLogins) DeviceCode ¶
func (p *ProviderLogins) DeviceCode(value map[string]any)
Authentication frames come from Pi's own provider adapters. The controller only routes them to the browser that started the login.
func (*ProviderLogins) Reply ¶
func (p *ProviderLogins) Reply(clientKey, loginID, value string) error
func (*ProviderLogins) Snapshot ¶
func (p *ProviderLogins) Snapshot(clientKey string) any
type QueueAssociation ¶
QueueAssociation is the minimal project/session key used for migration planning. Full queue payloads stay in the ledger; planning only moves the project key after paired host/native associations are verified.
type QueueBlock ¶
type QueueLedgerSummary ¶
type QueueLedgerSummary struct {
Present bool
Version int
SchemaSupported bool
RecordCount int
FollowUpCount int
DispatchCount int
BlockedCount int
UncertainCount int
HandledCount int
Sessions []string
}
QueueLedgerSummary is a read-only dry-run view of pi-session-queues.json. It preserves mutation/delivery IDs, attempted/accepted/uncertain claims and paused work without restoring an older runnable queue over dispatched effects.
func InspectQueueLedger ¶
func InspectQueueLedger(store persist.Store) (QueueLedgerSummary, error)
InspectQueueLedger reads the queue ledger with no writes and no dispatch. A missing or corrupt primary fails closed; the backup generation is never execution input and is never replayed automatically.
func ReconcileQueueAfterPublish ¶
func ReconcileQueueAfterPublish(store persist.Store, outcome persist.PublishOutcome) (QueueLedgerSummary, error)
ReconcileQueueAfterPublish rereads the validated queue primary after publication with the same fail-closed, no-backup-replay rule.
type QueueProjectMove ¶
QueueProjectMove proposes one project reassociation for a session queue.
type ReplayCache ¶
type ReplayCache struct {
// contains filtered or unexported fields
}
func NewReplayCache ¶
func NewReplayCache() *ReplayCache
func NewReplayCacheWithAdmission ¶
func NewReplayCacheWithAdmission(aggregate *AggregateByteAdmission) *ReplayCache
NewReplayCacheWithAdmission shares retained response accounting with the controller aggregate transport budget when one is supplied.
func (*ReplayCache) Acknowledge ¶
func (c *ReplayCache) Acknowledge(client string, ids []string)
func (*ReplayCache) ClearClient ¶
func (c *ReplayCache) ClearClient(client string) bool
func (*ReplayCache) ReleaseClient ¶
func (c *ReplayCache) ReleaseClient(client string)
ReleaseClient drops a client namespace unconditionally, releasing every settled reservation. An execution still in flight keeps ownership of its result for its current waiters but will not reserve bytes once it settles because the namespace is no longer registered.
func (*ReplayCache) Retain ¶
func (c *ReplayCache) Retain(client string, ids []string)
func (*ReplayCache) Run ¶
func (c *ReplayCache) Run(ctx context.Context, client, id, fingerprint string, execute func() ([]byte, error)) ([]byte, error)
Run retains the bytes transferred by execute. Neither execute nor callers may modify or reuse that storage: first delivery and retries share the same result.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
func NewRuntime ¶
func NewRuntime(config RuntimeConfig) (*Runtime, error)
func (*Runtime) BeginDrain ¶
func (r *Runtime) BeginDrain()
BeginDrain starts the AUX-19 quiesce: new prompts, forks and resume-style session creation are refused immediately while already-admitted work, including asynchronous prompt runs, keeps the admission it was granted. WaitForDrain is bounded by the caller's context (controllerQuiesceTimeout in production); once that expires, Shutdown cancels any still-active runs. It is safe to call before or during Shutdown.
func (*Runtime) WaitForDrain ¶
WaitForDrain blocks until admitted runnable work has settled or ctx ends.
type RuntimeConfig ¶
type RuntimeConfig struct {
Host string
Port int
DataDir string
StaticDir string
AppVersion string
AppRevision string
// Optional embedding/test endpoint; the production entrypoint uses pinned host Pi.
PiURL string
Policy *workspace.PathPolicy
Getenv func(string) string
// ProtocolMode is the raw PIXIE_PI_PROTOCOL value (v1, auto or v2,
// case-insensitive). Empty selects the byte-identical v1 default. An
// invalid value fails NewRuntime.
ProtocolMode string
// AgentDir is the selected full-host native agent directory. When set, the
// deletion pairing storage key is derived from it. Controller-only runs
// leave it empty and read PIXIE_PI_STORAGE_KEY instead.
AgentDir string
// Optional worker/parser composition is explicit. Runtime never discovers
// Canvas/Design helpers from PATH or substitutes an unrestricted fallback.
CanvasConfig *canvas.Config
DesignConfig *design.Config
// ScheduleRuntime is parsed by the entrypoint when supplied. Nil keeps
// embedded/test callers on the process environment policy.
ScheduleRuntime *ScheduleRuntimePolicy
}
type RuntimeDiagnosticsCapabilities ¶
type RuntimeDiagnosticsCapabilities struct {
Compatible *bool `json:"compatible,omitempty"`
MissingRequired []string `json:"missingRequired,omitempty"`
Operations *AgentOperations `json:"operations,omitempty"`
Capabilities map[string]int `json:"capabilities,omitempty"`
OperationSet map[string]bool `json:"operationSet,omitempty"`
}
type RuntimeDiagnosticsDeletionReconciliation ¶
type RuntimeDiagnosticsDeletionReconciliation struct {
Count *int `json:"count,omitempty"`
Records []DeletionReconciliation `json:"records"`
}
type RuntimeDiagnosticsHealth ¶
type RuntimeDiagnosticsHealth struct {
Transitions []HealthTransition `json:"transitions"`
}
RuntimeDiagnosticsHealth is the diagnostics projection of the health ring.
type RuntimeDiagnosticsHost ¶
type RuntimeDiagnosticsReport ¶
type RuntimeDiagnosticsReport struct {
Capabilities RuntimeDiagnosticsCapabilities `json:"capabilities"`
Host RuntimeDiagnosticsHost `json:"host"`
Runs RuntimeDiagnosticsRuns `json:"runs"`
DeletionReconciliation RuntimeDiagnosticsDeletionReconciliation `json:"deletionReconciliation"`
Schedule RuntimeDiagnosticsSchedule `json:"schedule"`
Health RuntimeDiagnosticsHealth `json:"health"`
Remediation []string `json:"remediation"`
}
RuntimeDiagnosticsReport is the authenticated, browser-safe operator projection. Its optional facts stay absent when the controller cannot establish them; clients must not turn absence into a healthy zero value.
type RuntimeDiagnosticsRuns ¶
type RuntimeDiagnosticsRuns struct {
ActiveCount *int `json:"activeCount,omitempty"`
}
RuntimeDiagnosticsRuns deliberately carries only an active count. It does not imply an individual current run exists or identify one.
type Schedule ¶
type Schedule struct {
ID string `json:"id"`
ProjectID string `json:"projectId"`
Root string `json:"root"`
Prompt string `json:"prompt"`
Cron string `json:"cron"`
Timezone string `json:"timezone"`
Model *WireModel `json:"model,omitempty"`
MaxRuntimeSeconds *int64 `json:"maxRuntimeSeconds"`
Paused bool `json:"paused"`
NextRun time.Time `json:"nextRun"`
Runs []ScheduleRun `json:"runs"`
}
type ScheduleCanceler ¶
type ScheduleCanceler func(context.Context, string) (ScheduleCancellationOutcome, error)
ScheduleCanceler confirms native cancellation. A returned nil outcome with Confirmed false is deliberately nonterminal: Pi may still be working.
type ScheduleLedgerSummary ¶
type ScheduleLedgerSummary struct {
Present bool
Version int
Legacy bool
SchemaSupported bool
JobCount int
IDs []string
Timezones []string
RunCount int
SessionLinks int
Interrupted int
RunningUncertain int
OperationCount int
PausedCount int
}
ScheduleLedgerSummary is a read-only migration/rollback view. It carries only stable schedule identities and execution counts, never prompt content.
func InspectScheduleLedger ¶
func InspectScheduleLedger(store persist.Store) (ScheduleLedgerSummary, error)
InspectScheduleLedger performs no conversion, write, or dispatch. Unknown versions remain inspectable so rollback logic can fail closed explicitly.
func ReconcileScheduleAfterPublish ¶
func ReconcileScheduleAfterPublish(store persist.Store, outcome persist.PublishOutcome) (ScheduleLedgerSummary, error)
ReconcileScheduleAfterPublish rereads the validated schedule primary after publication. An uncertain outcome stays unresolved until this read succeeds; it never replays the older backup generation.
type ScheduleMigrationPlan ¶
type ScheduleMigrationPlan struct {
Phase string
JobCount int
DispatchBlocked bool
MutationsBlocked bool
Preserved []string
Conflicts []string
Note string
Unresolved []string
}
func PlanScheduleMigration ¶
func PlanScheduleMigration(summary ScheduleLedgerSummary) (ScheduleMigrationPlan, error)
PlanScheduleMigration is a dry-run guard. Runtime migration is only the v1-to-v2 durable conversion in NewSchedules; this helper never writes it.
type ScheduleRun ¶
type ScheduleRun struct {
ID string `json:"id"`
SessionID string `json:"sessionId,omitempty"`
// CreationPending is durably installed before session.create. It remains
// set when Pixie cannot durably link or settle the resulting native ID, so
// the occurrence cannot be terminalized or dispatched again by guessing.
CreationPending bool `json:"creationPending,omitempty"`
StartedAt time.Time `json:"startedAt"`
FinishedAt *time.Time `json:"finishedAt,omitempty"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
CancellationRequestedAt *time.Time `json:"cancellationRequestedAt,omitempty"`
CancellationReason string `json:"cancellationReason,omitempty"`
}
type ScheduleRunner ¶
ScheduleRunner reports the durable session ID before submitting its prompt.
type ScheduleRuntimePolicy ¶
ScheduleRuntimePolicy separates the persisted budget from watchdog enforcement. Turning deadlines off leaves every stored budget untouched.
func DefaultScheduleRuntimePolicy ¶
func DefaultScheduleRuntimePolicy() ScheduleRuntimePolicy
func ParseScheduleRuntimePolicy ¶
func ParseScheduleRuntimePolicy(getenv func(string) string) (ScheduleRuntimePolicy, error)
ParseScheduleRuntimePolicy reads the two process settings once at startup. "off" makes new schedules unlimited; an omitted default remains 24 hours.
type Schedules ¶
type Schedules struct {
// contains filtered or unexported fields
}
func NewSchedules ¶
func NewSchedulesWithRuntime ¶
func NewSchedulesWithRuntime(store persist.Store, validateRoot func(string, string) (string, error), run ScheduleRunner, runtime ScheduleRuntimePolicy) (*Schedules, error)
func (*Schedules) SetCancellationHandler ¶
func (s *Schedules) SetCancellationHandler(cancel ScheduleCanceler)
SetCancellationHandler installs the native confirmation boundary. It is separate from ScheduleRunner so schedule.stop can retry an unconfirmed cancellation after the original runner has already returned.
func (*Schedules) SetPublishFaults ¶
func (s *Schedules) SetPublishFaults(faults persist.PublishFaults)
SetPublishFaults injects deterministic post-rename faults into schedule publication for X04 coverage. Production code leaves it zero-valued.
type SessionDeletions ¶
type SessionDeletions struct {
// contains filtered or unexported fields
}
SessionDeletions is a fail-closed journal. Its primary file is the only deletion authority: an older backup must never resurrect a completed delete.
func NewSessionDeletions ¶
func NewSessionDeletions(store persist.Store) *SessionDeletions
func (*SessionDeletions) Confirm ¶
func (deletions *SessionDeletions) Confirm(projectID, sessionID string) error
func (*SessionDeletions) Forget ¶
func (deletions *SessionDeletions) Forget(projectID, sessionID string) error
func (*SessionDeletions) List ¶
func (deletions *SessionDeletions) List() ([]sessionDeletion, error)
func (*SessionDeletions) Request ¶
func (deletions *SessionDeletions) Request(projectID, sessionID, agentBinding string) error
func (*SessionDeletions) SetPublishFaults ¶
func (deletions *SessionDeletions) SetPublishFaults(faults persist.PublishFaults)
SetPublishFaults injects deterministic post-rename faults into deletion publication for X04 coverage. Production code leaves it zero-valued.
type SessionGoal ¶
type SessionGoal struct {
ProjectID string `json:"projectId"`
SessionID string `json:"sessionId"`
Goal *string `json:"goal"`
Tasks []SessionTask `json:"tasks"`
UpdatedAt *float64 `json:"updatedAt"`
}
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
func NewSessionManager ¶
func NewSessionManager(projects *workspace.Projects, policy *workspace.PathPolicy, records *SessionRecords, queues *SessionQueues, objectives *Objectives, publish SessionPublisher) *SessionManager
func (*SessionManager) Abort ¶
func (m *SessionManager) Abort(ctx context.Context, sessionID string) error
func (*SessionManager) Archive ¶
func (m *SessionManager) Archive(ctx context.Context, projectID, sessionID, cwd string) error
func (*SessionManager) Branch ¶
func (m *SessionManager) Branch(ctx context.Context, projectID, sessionID, cwd, entryID string) (SessionSummary, error)
Branch implements "edit from here": an in-file sibling of entryID in the same native session file. The host serves this as session.fork plus an optional entryId (src/assistant/host.ts branchSession), so the request forwards the entry and never falls back to a new-file fork. The native session header keeps the true parent link; the controller deliberately adds no custom branch schema and records no fabricated parent link, so forks and in-file branches are roots in the controller's ancestry and only subagent sessions nest.
func (*SessionManager) CancelDialog ¶
func (m *SessionManager) CancelDialog(ctx context.Context, sessionID, requestID string) error
CancelDialog dismisses one pending dialog as cancelled and tells the host its extension call can stop waiting. Idempotent: settling twice is a no-op.
func (*SessionManager) ClampThinking ¶
func (m *SessionManager) ClampThinking(sessionID, requested string) (string, error)
func (*SessionManager) ClearObjectiveGoal ¶
func (m *SessionManager) ClearObjectiveGoal(ctx context.Context, projectID, sessionID string) (SessionGoal, error)
func (*SessionManager) ConfirmExternalDeletion ¶
func (m *SessionManager) ConfirmExternalDeletion(projectID, sessionID string) error
ConfirmExternalDeletion is the operator reconciliation action that asserts the native session is already gone. It records the confirmation and finishes local cleanup without dispatching another delete.
func (*SessionManager) CreateDeferred ¶
func (*SessionManager) Delete ¶
func (m *SessionManager) Delete(ctx context.Context, projectID, sessionID, cwd string) error
func (*SessionManager) DeletionReconciliationStatus ¶
func (m *SessionManager) DeletionReconciliationStatus() []DeletionReconciliation
DeletionReconciliationStatus projects every retained tombstone: the recovery-blocked quarantine plus any pending journal records not yet quarantined. Quarantine entries win on session identity so their actionable reason is preserved. The projection never dispatches, confirms or forgets.
func (*SessionManager) DeletionRecoveryStatus ¶
func (m *SessionManager) DeletionRecoveryStatus() []DeletionRecovery
DeletionRecoveryStatus returns the retained deletion records for operator reconciliation. It unions the recovery-blocked quarantine with any pending journal tombstones that have not been quarantined yet (for example an uncertain dispatch that has not been through restart recovery), so unmatched and uncertain records are never invisible. It never dispatches or forgets them; only ConfirmExternalDeletion finishes a record and RetainExternalDeletion explicitly leaves it in place.
func (*SessionManager) EnsureAttached ¶
func (m *SessionManager) EnsureAttached(ctx context.Context, sessionID, projectID, cwd string) (*sessionEntry, error)
func (*SessionManager) Extension ¶
func (m *SessionManager) Extension(ctx context.Context, method string, params json.RawMessage) error
func (*SessionManager) Fork ¶
func (m *SessionManager) Fork(ctx context.Context, projectID, sessionID, cwd string) (SessionSummary, error)
func (*SessionManager) IdleReleaseEligible ¶
func (m *SessionManager) IdleReleaseEligible(sessionID string) (bool, string)
IdleReleaseEligible reports whether a resident session may be explicitly released. Active, queued, uncertain, scheduled, pinned or lifecycle-busy sessions are never eligible.
func (*SessionManager) List ¶
func (m *SessionManager) List(ctx context.Context, projectID string, archived any) ([]SessionSummary, error)
func (*SessionManager) Objective ¶
func (m *SessionManager) Objective(ctx context.Context, projectID, sessionID string) (SessionGoal, error)
func (*SessionManager) ObjectiveOwner ¶
func (m *SessionManager) ObjectiveOwner(token string) (string, string, bool)
func (*SessionManager) Prompt ¶
func (m *SessionManager) Prompt(ctx context.Context, sessionID, text string, images []ImageContent, resources []TextResourceAttachment) error
func (*SessionManager) Queue ¶
func (m *SessionManager) Queue(ctx context.Context, sessionID, text string) error
func (*SessionManager) RecordedCWD ¶
func (m *SessionManager) RecordedCWD(projectID, sessionID string) (string, error)
func (*SessionManager) RecoverDeletions ¶
func (m *SessionManager) RecoverDeletions(ctx context.Context) error
RecoverDeletions resumes or quarantines retained deletion records. Only an unreadable journal fails startup; a record that cannot be matched to the connected authority, or whose host does not support deletion, is retained and surfaced as recovery-blocked. This is what keeps an ordinary restart (new runtime identity, ephemeral port, rotated secret) from aborting boot.
func (*SessionManager) RefreshFromDisk ¶
func (m *SessionManager) RefreshFromDisk(ctx context.Context, sessionID, projectID, cwd string) (bool, error)
RefreshFromDisk re-reads a resident, non-streaming session from its native file after a foreign writer advanced it. The host takes an advisory lease only for its own mutations, so an external Pi CLI append is invisible to the resident projection until the native runtime is released and reattached. A streaming or prompt-active session is left untouched: replacing its runtime mid-run would interleave two owners. Returns false when no refresh was needed or possible.
func (*SessionManager) RegisterSessionLiveness ¶
func (m *SessionManager) RegisterSessionLiveness(sessionID, name string, isActive func() bool) func()
RegisterSessionLiveness scopes an activity probe to one exact session. The returned function unregisters the probe. A failing probe preserves the session: losing extension work is worse than delaying eviction.
func (*SessionManager) Release ¶
func (m *SessionManager) Release(sessionID, projectID, cwd, clientKey string)
func (*SessionManager) ReleaseClient ¶
func (m *SessionManager) ReleaseClient(clientKey string)
func (*SessionManager) ReleaseIdleRuntime ¶
func (m *SessionManager) ReleaseIdleRuntime(ctx context.Context, sessionID string) error
ReleaseIdleRuntime frees residence for a verified idle session while retaining its durable history, queue, selection and metadata. The next read or prompt reloads the authoritative transcript from Pi.
func (*SessionManager) ReleaseIdleRuntimeForClient ¶
func (m *SessionManager) ReleaseIdleRuntimeForClient(ctx context.Context, sessionID, projectID, clientKey string) error
ReleaseIdleRuntimeForClient requires the caller to own the session lease before allowing an idle resident to be released. The lease check stays separate from Release so an idle-runtime action cannot silently change view selection ownership.
func (*SessionManager) ReleaseProject ¶
func (m *SessionManager) ReleaseProject(projectID string)
func (*SessionManager) RemoveQueue ¶
func (*SessionManager) Rename ¶
func (m *SessionManager) Rename(ctx context.Context, projectID, sessionID, cwd, title string) error
func (*SessionManager) ResolveDialog ¶
func (m *SessionManager) ResolveDialog(ctx context.Context, sessionID, requestID string, result map[string]any) error
ResolveDialog validates the browser's answer for one pending dialog and relays it to the Pi host, which settles the extension's awaiting call. Session-bound and single-use: foreign or replayed answers are rejected.
func (*SessionManager) RetainExternalDeletion ¶
func (m *SessionManager) RetainExternalDeletion(projectID, sessionID string) error
RetainExternalDeletion is the explicit retain reconciliation action. It verifies a tombstone exists in the quarantine or the durable journal and then leaves it untouched: it never dispatches a delete, confirms, or forgets. A missing record is an error so the UI never reports a silent keep.
func (*SessionManager) RetryQueue ¶
func (*SessionManager) SessionSchemaSummary ¶
func (m *SessionManager) SessionSchemaSummary() *diagnostics.SessionSchemaSummary
SessionSchemaSummary returns the bounded AUX-12 native session-schema degradation summary for the most degraded resident session. It reads only the header version and record counters; no native text, path or session identity is exported. Nil means no resident session carried a schema summary. The support-snapshot owner maps this into SupportSnapshotRuntime.SessionSchema.
func (*SessionManager) SessionUpdate ¶
func (m *SessionManager) SessionUpdate(ctx context.Context, notification piwire.SessionNotification) error
func (*SessionManager) SetAdmissionGate ¶
func (m *SessionManager) SetAdmissionGate(gate *AdmissionGate)
SetAdmissionGate wires the process-local AUX-19 drain gate so controller-owned follow-up dispatch participates in quiesce admission. Runtime installs the WebSocket server's gate after both are constructed; a nil gate keeps the pre-drain behavior for embeddings and focused tests.
func (*SessionManager) SetClient ¶
func (m *SessionManager) SetClient(client *PiClient)
func (*SessionManager) SetConfigOption ¶
func (m *SessionManager) SetConfigOption(ctx context.Context, sessionID, configID, value string) error
func (*SessionManager) SetDeletionAuthority ¶
func (m *SessionManager) SetDeletionAuthority(mode DeletionAuthorityMode, storageKey string)
SetDeletionAuthority wires the configured destructive-recovery authority and the resolved pairing storage key before the first recovery. Recovery defaults to auto with legacy matching when it is never called.
func (*SessionManager) SetDeletionPublishFaults ¶
func (m *SessionManager) SetDeletionPublishFaults(faults persist.PublishFaults)
SetDeletionPublishFaults injects deterministic deletion-journal publication faults so AUX-27 admission ordering can be exercised without disk failures. Production leaves it zero-valued; it mirrors the queue/schedule seams.
func (*SessionManager) SetLeases ¶
func (m *SessionManager) SetLeases(clientKey string, revision uint64, requested []sessionLease) error
func (*SessionManager) SetMCPRegistry ¶
func (m *SessionManager) SetMCPRegistry(registry *mcpserver.Registry)
SetMCPRegistry attaches the live publisher's instance-owned scope registry. The narrow interface keeps session lifecycle code from issuing or authorizing native MCP credentials itself.
func (*SessionManager) SetObjectiveURL ¶
func (m *SessionManager) SetObjectiveURL(url string)
func (*SessionManager) SetSettings ¶
func (m *SessionManager) SetSettings(settings *Settings)
func (*SessionManager) SetThinking ¶
func (m *SessionManager) SetThinking(ctx context.Context, sessionID, level string) error
func (*SessionManager) Stats ¶
func (m *SessionManager) Stats(sessionID string) (SessionStats, error)
func (*SessionManager) Steer ¶
func (m *SessionManager) Steer(ctx context.Context, sessionID, text string, images []ImageContent, resources []TextResourceAttachment) error
func (*SessionManager) Stop ¶
func (m *SessionManager) Stop(ctx context.Context, sessionID string) (StopOutcome, error)
Stop freezes controller dispatch first, clears continuation, requests cancellation and verifies generation quiescence with distinct stopping/stopped/uncertain reporting. Unsent outbox items are retained paused; resume or discard stays an explicit user decision and never happens automatically here.
func (*SessionManager) ThinkingLevels ¶
func (m *SessionManager) ThinkingLevels(sessionID string) ([]string, error)
func (*SessionManager) Unarchive ¶
func (m *SessionManager) Unarchive(ctx context.Context, projectID, sessionID string) error
func (*SessionManager) UpdateObjective ¶
func (m *SessionManager) UpdateObjective(ctx context.Context, projectID, sessionID string, goal *string, tasks *[]SessionTask) (SessionGoal, error)
func (*SessionManager) UpdateObjectiveFromAgent ¶
func (m *SessionManager) UpdateObjectiveFromAgent(ctx context.Context, projectID, sessionID string, goal *string, tasks *[]SessionTask) (SessionGoal, error)
type SessionMetadata ¶
type SessionMetadata struct {
HostID string `json:"hostId"`
SessionID string `json:"sessionId"`
ProjectID *string `json:"projectId"`
Title string `json:"title"`
UpdatedAt int64 `json:"updatedAt"`
IsStreaming bool `json:"isStreaming"`
Archived bool `json:"archived"`
}
SessionMetadata carries host/session-keyed catalog metadata with a nullable host-side project key. A nil or empty ProjectID means the session is ungrouped. There is no hidden all-files project.
func SelectSessionMetadataSubset ¶
func SelectSessionMetadataSubset(sessions []SessionMetadata, selectedKey string, limit int, expanded bool) (visible []SessionMetadata, hiddenCount int)
SelectSessionMetadataSubset returns the concise recent subset that never hides the selected or running session behind Show more/Expand. Order is preserved; hiddenCount is the number of rows behind the subset.
func SessionMetadataFromSummary ¶
func SessionMetadataFromSummary(hostID string, summary SessionSummary) SessionMetadata
SessionMetadataFromSummary bridges an existing project-required summary to nullable host/session-keyed metadata. An empty project ID becomes an explicit ungrouped (nil) key; grouped IDs are copied verbatim.
func SortSessionMetadataRecentFirst ¶
func SortSessionMetadataRecentFirst(sessions []SessionMetadata) []SessionMetadata
SortSessionMetadataRecentFirst returns a newest-first copy with a stable host/session-key tie-break. The input order is not mutated.
func (SessionMetadata) ProjectIDOrEmpty ¶
func (m SessionMetadata) ProjectIDOrEmpty() string
ProjectIDOrEmpty returns the grouped project ID or the empty string for ungrouped metadata, preserving compatibility with project-required transports.
type SessionMetadataCatalog ¶
type SessionMetadataCatalog struct {
Grouped map[string][]SessionMetadata
Ungrouped []SessionMetadata
Flat []SessionMetadata
}
SessionMetadataCatalog is the grouped/flat/ungrouped view built from one host/session-keyed catalog.
func PartitionSessionMetadata ¶
func PartitionSessionMetadata(sessions []SessionMetadata, knownProjectIDs []string) SessionMetadataCatalog
PartitionSessionMetadata builds grouped/flat/ungrouped views from one host/session-keyed catalog. Inputs may mix grouped records and explicit ungrouped metadata. Sessions whose project key is ungrouped or has no open project land in ungrouped rather than hiding. Archived sessions stay out of the Chats catalog. Duplicate native IDs across hosts are kept by their host/session key. No hidden all-files project is fabricated.
type SessionPlanEntry ¶
type SessionPlanEntry struct {
Content string `json:"content"`
Priority string `json:"priority"`
Status string `json:"status"`
// ID and BlockedBy carry the upstream `todo` tool's task identity and
// dependencies. They are absent for legacy update_plan entries.
ID *int `json:"id,omitempty"`
BlockedBy []int `json:"blockedBy,omitempty"`
}
type SessionPlanState ¶
type SessionPlanState struct {
Entries []SessionPlanEntry `json:"entries"`
Truncated bool `json:"truncated,omitempty"`
}
type SessionPublisher ¶
type SessionQueue ¶
type SessionQueue struct {
Revision string `json:"revision"`
Steering []string `json:"steering"`
FollowUp []string `json:"followUp"`
Blocked *QueueBlock `json:"blocked,omitempty"`
}
type SessionQueues ¶
type SessionQueues struct {
// contains filtered or unexported fields
}
func NewSessionQueues ¶
func NewSessionQueues(store persist.Store) *SessionQueues
func (*SessionQueues) Forget ¶
func (queues *SessionQueues) Forget(projectID, sessionID string) error
func (*SessionQueues) Get ¶
func (queues *SessionQueues) Get(projectID, sessionID string) (sessionQueueState, bool, error)
func (*SessionQueues) List ¶
func (queues *SessionQueues) List() ([]storedSessionQueue, error)
func (*SessionQueues) Save ¶
func (queues *SessionQueues) Save(projectID, sessionID string, state sessionQueueState) error
func (*SessionQueues) SetPublishFaults ¶
func (queues *SessionQueues) SetPublishFaults(faults persist.PublishFaults)
SetPublishFaults injects deterministic post-rename faults into queue publication for X04 coverage. Production code leaves it zero-valued.
type SessionRecords ¶
type SessionRecords struct {
// contains filtered or unexported fields
}
func NewSessionRecords ¶
func NewSessionRecords(store persist.Store) *SessionRecords
func (*SessionRecords) Forget ¶
func (s *SessionRecords) Forget(projectID, sessionID string) error
func (*SessionRecords) List ¶
func (s *SessionRecords) List() ([]ProjectSessionRecord, error)
func (*SessionRecords) Record ¶
func (s *SessionRecords) Record(record ProjectSessionRecord) error
func (*SessionRecords) SetTitle ¶
func (s *SessionRecords) SetTitle(projectID, sessionID, title string) error
SetTitle persists the last title observed for a session without requiring callers to reconstruct the rest of its durable association. Pi can emit generated titles as session updates, but those updates are not guaranteed to be returned by a later session.load, so the controller keeps this small local projection as a restart fallback.
type SessionSettlement ¶
type SessionStats ¶
type SessionStats struct {
SessionID string `json:"sessionId"`
TotalMessages int `json:"totalMessages"`
Tokens SessionTokens `json:"tokens"`
Cost float64 `json:"cost"`
CostCurrency string `json:"costCurrency,omitempty"`
Reported map[string]bool `json:"reported,omitempty"`
ContextUsage map[string]any `json:"contextUsage,omitempty"`
}
type SessionSummary ¶
type SessionSummary struct {
Capabilities map[string]int `json:"capabilities,omitempty"`
ConfigOptions []any `json:"configOptions,omitempty"`
SessionID string `json:"sessionId"`
ProjectID string `json:"projectId"`
CWD string `json:"cwd"`
ParentSessionID string `json:"parentSessionId,omitempty"`
Title string `json:"title"`
Model *WireModel `json:"model"`
ThinkingLevel string `json:"thinkingLevel"`
IsStreaming bool `json:"isStreaming"`
MessageCount int `json:"messageCount"`
UpdatedAt int64 `json:"updatedAt"`
Live bool `json:"live"`
Archived bool `json:"archived"`
LastSettlement *SessionSettlement `json:"lastSettlement,omitempty"`
Queue *SessionQueue `json:"queue,omitempty"`
}
type SessionTask ¶
type SessionTokens ¶
type Settings ¶
type Settings struct {
// contains filtered or unexported fields
}
func (*Settings) BrowserMCP ¶
func (s *Settings) BrowserMCP() (BrowserMCPConfig, error)
BrowserMCP returns the persisted browser-MCP registration setting.
func (*Settings) SetBrowserMCP ¶
func (s *Settings) SetBrowserMCP(value BrowserMCPConfig) (BrowserMCPConfig, error)
SetBrowserMCP persists the browser-MCP registration setting.
func (*Settings) SetModelVisibility ¶
SetModelVisibility applies a single change against the latest persisted list.
func (*Settings) SetPublishFaults ¶
func (s *Settings) SetPublishFaults(faults persist.PublishFaults)
SetPublishFaults injects deterministic publication faults for X04 coverage. Production code leaves it zero-valued.
type StopOutcome ¶
type StopOutcome struct {
Status string `json:"status"`
Generation uint64 `json:"generation"`
RetainedPaused int `json:"retainedPaused"`
ForcedTermination bool `json:"forcedTermination"`
Reason string `json:"reason,omitempty"`
}
StopOutcome reports a verified Stop with distinct stopped/uncertain states. A forwarded abort/UI response is never treated as acceptance by itself; Status is stopped only after generation quiescence is verified.
type SupportSnapshotAuthenticationRequiredError ¶
type SupportSnapshotAuthenticationRequiredError struct{}
SupportSnapshotAuthenticationRequiredError is a typed, actionable denial. Support exports remain unavailable for every unauthenticated controller, including a trusted-loopback controller.
func (*SupportSnapshotAuthenticationRequiredError) Error ¶
func (*SupportSnapshotAuthenticationRequiredError) Error() string
func (*SupportSnapshotAuthenticationRequiredError) ErrorCode ¶
func (*SupportSnapshotAuthenticationRequiredError) ErrorCode() string
type TextResourceAttachment ¶
type WebSocketServer ¶
type WebSocketServer struct {
Handler Handler
Welcome Welcome
LoginSnapshot func(string) any
// Called after disconnected requests settle, before a replacement is admitted.
ClientReaped func(string)
Auth AuthConfig
// contains filtered or unexported fields
}
func NewWebSocketServer ¶
func NewWebSocketServer(handler Handler, welcome Welcome, config AuthConfig) (*WebSocketServer, error)
func (*WebSocketServer) BeginDrain ¶
func (s *WebSocketServer) BeginDrain()
BeginDrain requests the AUX-19 quiesce. New runnable work is refused immediately; already-admitted work keeps running, and a browser prompt holds its admission until its asynchronous run settles (or the caller's bounded WaitForDrain context expires).
func (*WebSocketServer) Close ¶
func (s *WebSocketServer) Close(ctx context.Context)
func (*WebSocketServer) PublishToClient ¶
func (*WebSocketServer) Quiescing ¶
func (s *WebSocketServer) Quiescing() bool
Quiescing reports whether the gate is refusing new runnable work.
func (*WebSocketServer) ServeHTTP ¶
func (s *WebSocketServer) ServeHTTP(response http.ResponseWriter, request *http.Request)
func (*WebSocketServer) WaitForDrain ¶
func (s *WebSocketServer) WaitForDrain(ctx context.Context)
WaitForDrain blocks until admitted runnable work has settled or ctx ends.
type WireModel ¶
type WireModel struct {
MetadataComplete *bool `json:"metadataComplete,omitempty"`
ID string `json:"id"`
Name string `json:"name"`
Provider string `json:"provider"`
ContextWindow *int `json:"contextWindow,omitempty"`
MaxTokens *int `json:"maxTokens,omitempty"`
Reasoning *bool `json:"reasoning,omitempty"`
ThinkingLevels []string `json:"thinkingLevels,omitempty"`
Input []string `json:"input,omitempty"`
Cost any `json:"cost,omitempty"`
Available bool `json:"available"`
Hidden bool `json:"hidden"`
}
Source Files
¶
- admission.go
- aggregate_admission.go
- auth.go
- handler.go
- history.go
- mcp_adapter.go
- mcp_browser.go
- mcp_persistence_outcomes.go
- objective_http.go
- pairing_authority.go
- pi_admin.go
- pi_agents.go
- pi_client.go
- pi_client_v2.go
- pi_completions.go
- pi_events.go
- pi_extensions.go
- pi_helpers.go
- pi_models.go
- pi_native_extensions.go
- project_root_migration.go
- provider_configuration.go
- provider_inventory.go
- provider_login.go
- replay.go
- runtime.go
- runtime_status.go
- schedule_migration.go
- schedules.go
- server.go
- session_actions.go
- session_config.go
- session_deletion_migration.go
- session_deletions.go
- session_dialogs.go
- session_events.go
- session_history.go
- session_lifecycle.go
- session_liveness.go
- session_manager.go
- session_metadata.go
- session_objectives.go
- session_operations.go
- session_plans.go
- session_queue_migration.go
- session_queues.go
- session_state.go
- settings.go
- socket_output.go
- static_files.go
- stream_frames.go
- types.go
- websocket.go