package protocol

import "time"

const TurnUpdatedEventType = "knowledge_qa.turn.updated"

// RuntimeActivity is the bounded internal projection of one runtime event for
// owner history. Thinking summaries contain only reasoning summaries that the
// runtime already marked visible. Tool summaries contain the exact user-visible
// target fields plus bounded result metadata and duration. Diagnostic activities
// use stable content-free warning codes. Activities never contain hidden
// reasoning, returned knowledge bodies, or answer text.
type RuntimeActivity struct {
	ID             string
	Sequence       int64
	Kind           string
	Status         string
	Summary        string
	ToolName       string
	ModelCalls     int
	Stage          string
	DiagnosticCode string
	Counts         *RuntimeActivityCounts
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

// RuntimeActivityCounts is the bounded, content-free count projection for a
// known runtime stage. Pointer fields preserve the difference between an
// explicit zero and a count that was absent or rejected by the projector.
type RuntimeActivityCounts struct {
	AuthorizedKnowledgeBases  *int
	AuthorizedSources         *int
	MissingKnowledgeBases     *int
	MissingSources            *int
	UnavailableKnowledgeBases *int
	UnavailableSources        *int
	PartiallyAvailableSources *int
	ContextTurns              *int
	SearchCalls               *int
	ListCalls                 *int
	ReadCalls                 *int
	WebSearchCalls            *int
	WebReadCalls              *int
	WebSources                *int
	RefCalls                  *int
	ModelCalls                *int
	SearchedRoots             *int
}

// TurnUpdate identifies the owner-visible turn projection that changed. The
// event carries stable correlation IDs and a content-free formal-message
// projection marker; browsers reload bounded owner-authorized projections.
type TurnUpdate struct {
	WorkspaceID              string
	OwnerMemberID            string
	ThreadChannelID          string
	TurnID                   string
	MessageProjectionChanged bool
}
