Documentation
¶
Overview ¶
Package diagnose builds the bounded, machine-readable diagnostic snapshot reported by `bridgectl session diagnose`.
The snapshot answers "what does bridgectl believe about this session right now". It is derived only from the Supervisor's public session API (bridgev1.GetSessionResponse) plus two small local control-client files; it never reads telemetry, Bridge, terminal output, logs or the filesystem of the session, and it never infers interaction state. Report is the single canonical model: the JSON serializer and the human renderer both consume it, and neither recalculates anything.
The shape is a published contract (schema_version 1). Every string-typed field is enumerated in the privacy allowlist test, so adding one is a deliberate, reviewed act. See docs/agent-diagnostics.md.
Index ¶
Constants ¶
const (
// MaxIDRunes bounds the provider-supplied pending request ID.
MaxIDRunes = 128
)
const SchemaVersion = 1
SchemaVersion is the diagnostic JSON schema version. Field names, types and enum values of a published version never change; incompatible changes bump this number.
const UnknownVersion = "unknown"
UnknownVersion is the bridgectl_version reported when the daemon's version cannot be determined.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Capability ¶
type Capability struct {
InteractionStateSupported bool `json:"interaction_state_supported"`
ApprovalStateSupported bool `json:"approval_state_supported"`
PendingSummarySupported bool `json:"pending_summary_supported"`
RemoteResponseSupported bool `json:"remote_response_supported"`
StructuredApprovalSupported bool `json:"structured_approval_supported"`
}
Capability mirrors bridge.InteractionCapabilities. A null interaction_capability means the capability is unknown (the server reported no interaction block); an all-false object means the provider explicitly supports nothing.
type Control ¶
type Control struct {
// State is one of the bridgecontrol.State values, or "unknown" when the
// status path is not configured, unreadable, or holds an unrecognized value.
State string `json:"state"`
// UpdatedAt is when the status last changed (or, while connected, last
// heartbeated).
UpdatedAt *string `json:"updated_at"`
// LastConnectedAt is the last time the control client was observed
// connected, or null if never recorded (including status files written
// by older versions).
LastConnectedAt *string `json:"last_connected_at"`
// Stale is true when UpdatedAt is older than bridgecontrol.StatusStaleAfter.
// A stale "connected" entry means no live client is behind it.
Stale bool `json:"stale"`
}
Control is the local Bridge control connection status, read from the file the daemon persists. It never reflects Bridge reachability measured now.
type ControlInput ¶
type ControlInput struct {
Configured bool
Status *bridgecontrol.Status
}
ControlInput is the raw control-client status. Configured is false when no control files exist; Status is nil when the file is missing or unreadable.
type ErrorReport ¶
type ErrorReport struct {
SchemaVersion int `json:"schema_version"`
Error ErrorBody `json:"error"`
}
ErrorReport is what `--json` prints on failure, in place of a Report. It never echoes caller-supplied input or server error text.
func NewErrorReport ¶
func NewErrorReport(code ErrorCode) *ErrorReport
NewErrorReport builds the schema-v1 error document for code.
type Inputs ¶
type Inputs struct {
Version string
Now time.Time
Control ControlInput
LifecycleRevisionWire *int64
InteractionRevisionWire *int64
}
Inputs is everything Build needs besides the session itself. It is plain data so Build is a pure function.
func LoadInputs ¶
LoadInputs reads the control client's persisted status and revision counters from stateDir. It is read-only (it never creates or modifies a file) and never fails: anything missing or unreadable becomes unknown/null, so diagnostics work identically when Bridge is not enrolled or unavailable.
type Pending ¶
type Pending struct {
ID string `json:"id"`
Type string `json:"type"`
// IDSHA256 is "sha256:" plus the hex SHA-256 of the provider's original,
// untruncated request ID. Consumers that hold the same ID (Bridge's
// registry) compare fingerprints instead of the bounded, sanitized ID, so
// a long or odd ID can never produce a false mismatch.
IDSHA256 string `json:"id_sha256"`
// Kind is the provider-assigned category: command, file_change, tool,
// question, other, or unknown when the provider did not classify it. Any
// other value from a provider is reported as other, so this can never
// carry free text.
Kind string `json:"kind"`
// SummaryAvailable reports that the provider supplied a pending summary.
// The text itself is never included: provider summaries (e.g. Codex
// approvals) can embed working directories, full commands and anything
// typed into them, which no sanitizer can make safe.
SummaryAvailable bool `json:"summary_available"`
}
Pending identifies the request the session is blocked on.
type Report ¶
type Report struct {
SchemaVersion int `json:"schema_version"`
BridgectlVersion string `json:"bridgectl_version"`
SessionID string `json:"session_id"`
Provider string `json:"provider"`
ProjectID string `json:"project_id"`
Status string `json:"status"`
ExitCode *int32 `json:"exit_code"`
CreatedAt *string `json:"created_at"`
StoppedAt *string `json:"stopped_at"`
InteractionState string `json:"interaction_state"`
InteractionCapability *Capability `json:"interaction_capability"`
InteractionUpdatedAt *string `json:"interaction_updated_at"`
InteractionLastReportAt *string `json:"interaction_last_report_at"`
PendingRequest *Pending `json:"pending_request"`
LifecycleRevisionWire *int64 `json:"lifecycle_revision_wire"`
InteractionRevisionWire *int64 `json:"interaction_revision_wire"`
InteractionRevisionLocal *uint64 `json:"interaction_revision_local"`
ActiveWriter bool `json:"active_writer"`
ObserverCount int `json:"observer_count"`
Control Control `json:"control"`
}
Report is the schema-v1 diagnostic snapshot. Field order is the serialization order; schema_version is always first. Optional values are pointers and serialize as explicit null — never omitted — so "unknown" is always distinguishable from "false"/"0".
func Build ¶
func Build(resp *bridgev1.GetSessionResponse, in Inputs) *Report
Build converts the Supervisor's public session view into a Report. It never derives interaction state from runtime status, timestamps or output.
func (*Report) MarshalJSON ¶
MarshalJSON is the canonical serialization: compact, deterministic (struct field order), one document.