Documentation
¶
Overview ¶
Package queryservice defines read-only application services.
Query services answer reporting, search, and inspection requests without exposing persistence details to presentation adapters.
Index ¶
- type CodexCaptureDiagnosticQueryService
- type CommandAuditQueryService
- type EventMetadataQueryService
- type EventPreviewQueryService
- type EventQueryService
- type MemoryQueryService
- type MemoryStatusCountQueryService
- type ReportQueryService
- type SessionQueryService
- type StaleMemoryQueryService
- type WorkspaceIdentityQueryService
- type WorkspaceResolution
- type WorkspaceResolutionCriteria
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CodexCaptureDiagnosticQueryService ¶ added in v0.32.0
type CodexCaptureDiagnosticQueryService interface {
LoadCodexCaptureDiagnostic(
context.Context,
apptypes.CodexCaptureDiagnosticCriteria,
) (apptypes.CodexCaptureDiagnosticEvidence, error)
}
CodexCaptureDiagnosticQueryService loads one complete, body-free projection for the Codex doctor check.
type CommandAuditQueryService ¶ added in v0.31.0
type CommandAuditQueryService interface {
// ListReportWindow returns every command audit matching the report event
// criteria under one SQLite read snapshot. Limit is the internal page size.
ListReportWindow(ctx context.Context, criteria apptypes.EventListCriteria) ([]apptypes.ReportCommandRecord, error)
}
CommandAuditQueryService provides body-free, consumer-oriented audit reads.
type EventMetadataQueryService ¶ added in v0.31.0
type EventMetadataQueryService interface {
// ListRecentMetadata returns body-free events in descending time order.
ListRecentMetadata(ctx context.Context, criteria apptypes.EventListCriteria) ([]apptypes.EventMetadata, error)
// ListWindowMetadata returns every matching body-free event under one
// read snapshot. criteria.Limit() controls the internal page size.
ListWindowMetadata(ctx context.Context, criteria apptypes.EventListCriteria) ([]apptypes.EventMetadata, error)
// SearchMetadata searches event and command content in SQLite but returns
// only body-free event metadata to the caller.
SearchMetadata(ctx context.Context, criteria apptypes.EventSearchCriteria) ([]apptypes.EventMetadata, error)
// GetContextMetadata returns body-free context membership in descending
// time order.
GetContextMetadata(ctx context.Context, criteria apptypes.EventContextCriteria) ([]apptypes.EventMetadata, error)
}
EventMetadataQueryService provides body-free event inspection operations. It is separate from EventQueryService so consumers cannot accidentally request a partial domain Event through an include-body flag.
type EventPreviewQueryService ¶ added in v0.31.0
type EventPreviewQueryService interface {
ListRecentCommandPreviews(ctx context.Context, sessionID types.SessionID, limit, bodyRuneLimit int) ([]apptypes.EventBodyPreview, error)
}
EventPreviewQueryService provides bounded content reads for summary surfaces without materializing full stored event bodies.
type EventQueryService ¶ added in v0.4.0
type EventQueryService interface {
// ListRecent returns events in descending time order.
ListRecent(ctx context.Context, limit, offset int, kind types.EventKind, client types.Client, agent types.Agent, sessionID types.SessionID, workspace types.Workspace, failuresOnly bool, from, to time.Time, sourceHook string) ([]*model.Event, error)
// ListWindow returns every event matching the criteria whose created_at
// falls in [From, To) under a single read snapshot so concurrent writers
// cannot cause the scan to drop events. Callers supply the batch size via
// criteria.Limit(); offset is ignored.
ListWindow(ctx context.Context, criteria apptypes.EventListCriteria) ([]*model.Event, error)
// Search performs full-text search across events.
Search(ctx context.Context, query string, workspace types.Workspace, sessionID types.SessionID, client types.Client, agent types.Agent, kind types.EventKind, from, to time.Time, limit, offset int, failuresOnly bool) ([]*model.Event, error)
// GetContext returns recent events for context retrieval.
GetContext(ctx context.Context, workspace types.Workspace, sessionID types.SessionID, limit int) ([]*model.Event, error)
// GetDetails returns the details for a single event.
GetDetails(ctx context.Context, eventID types.EventID) (apptypes.EventDetails, error)
// ListTimelineBlocks returns work blocks separated by idle gaps.
ListTimelineBlocks(ctx context.Context, workspace types.Workspace, from, to time.Time, gapSeconds, limit int) ([]apptypes.TimelineBlock, error)
}
EventQueryService provides read-side operations for events.
type MemoryQueryService ¶ added in v0.5.0
type MemoryQueryService interface {
// List returns memory summaries matching the provided criteria.
List(ctx context.Context, criteria apptypes.MemoryListCriteria) ([]apptypes.MemorySummary, error)
// Search performs text search across durable memories and their refs.
Search(ctx context.Context, criteria apptypes.MemorySearchCriteria) ([]apptypes.MemorySummary, error)
// GetDetails returns the details for a single memory.
GetDetails(ctx context.Context, memoryID types.MemoryID) (apptypes.MemoryDetails, error)
}
MemoryQueryService provides read-side operations for durable memories.
type MemoryStatusCountQueryService ¶ added in v0.20.0
type MemoryStatusCountQueryService interface {
// CountByStatus returns the true per-status row counts matching the
// criteria, ignoring its Limit/Offset.
CountByStatus(ctx context.Context, criteria apptypes.MemoryListCriteria) (apptypes.MemoryStatusCounts, error)
}
MemoryStatusCountQueryService is the additive read-side query used by the reliability pane to report true candidate/accepted totals when the bounded summary scan is saturated. It mirrors the additive StaleMemoryQueryService pattern so implementers opt in without widening MemoryQueryService.
type ReportQueryService ¶ added in v0.31.0
type ReportQueryService interface {
LoadReportWindow(ctx context.Context, criteria apptypes.ReportCriteria) (apptypes.ReportWindow, error)
}
ReportQueryService loads all body-free report sources under one storage read snapshot. Page size and result cap have separate contracts in criteria.
type SessionQueryService ¶ added in v0.4.0
type SessionQueryService interface {
// FindLatest returns the session_started event for the latest matching session.
// Returns an empty Optional when no matching session exists.
FindLatest(ctx context.Context, client types.Client, agent types.Agent, workspace types.Workspace, activeOnly bool) (types.Optional[*model.Event], error)
// ListSummaries returns session summaries matching the criteria.
ListSummaries(ctx context.Context, limit, offset int, sessionID types.SessionID, workspace types.Workspace, client types.Client, agent types.Agent, label string, activeOnly bool, from, to types.Optional[time.Time]) ([]apptypes.SessionSummary, error)
// ListTreeSummaries returns sessions for the tree view. When rootSessionID is set,
// the root session and its descendants are returned without applying the recent-session limit.
ListTreeSummaries(ctx context.Context, limit int, workspace types.Workspace, rootSessionID types.SessionID) ([]apptypes.SessionSummary, error)
// LineageOf returns the full session tree rooted at the topmost ancestor of sessionID.
LineageOf(ctx context.Context, sessionID types.SessionID) ([]apptypes.SessionSummary, error)
}
SessionQueryService provides read-side operations for sessions.
type StaleMemoryQueryService ¶ added in v0.15.0
type StaleMemoryQueryService interface {
// ListStale returns stale durable-memory rows plus the total count before
// paging.
ListStale(ctx context.Context, criteria apptypes.StaleMemoryListCriteria) (apptypes.StaleMemoryListResult, error)
}
StaleMemoryQueryService provides the additive read-side query used by `traceary top --snapshot --json` to surface stale durable memories without introducing a write-side use case.
type WorkspaceIdentityQueryService ¶ added in v0.31.0
type WorkspaceIdentityQueryService interface {
WorkspaceIdentityReport(ctx context.Context, conflictSampleLimit int) (apptypes.WorkspaceIdentityReport, error)
}
WorkspaceIdentityQueryService provides body-free attribution diagnostics.
type WorkspaceResolution ¶ added in v0.16.0
type WorkspaceResolution struct {
// contains filtered or unexported fields
}
WorkspaceResolution carries the outcome of canonical workspace resolution used by session, event, and memory query paths. matchedSession is the session selected for the requested workspace (either exact match or via ancestor fallback when the requested workspace is a child path). When fallbackApplied is true, matchedSession.Workspace() is an ancestor of the requested workspace and at least one event for the session was recorded under the requested workspace.
func ResolveSessionWorkspace ¶ added in v0.16.0
func ResolveSessionWorkspace( ctx context.Context, sessionQuery SessionQueryService, eventQuery EventQueryService, criteria WorkspaceResolutionCriteria, ) (WorkspaceResolution, error)
ResolveSessionWorkspace selects the session that best matches the requested workspace. The contract is:
- If the requested workspace has at least one matching session row, that session wins (exact-match path — preserves existing behavior including the github.com/org/repo git remote case).
- Otherwise, when the requested workspace looks like a filesystem path, walk its ancestors (closest parent first, up to "/"). For each ancestor workspace, accept the most recent matching session whose event history contains at least one event recorded under the requested workspace. This is the parent/child fallback used when an agent recorded the session under a parent project root but recorded events under a child subdir.
- If no fallback candidate qualifies, return matchedFound=false so the caller can render "no matching session".
The helper deliberately ignores client/agent/label filters during fallback because dogfooding showed they are usually unset for handoff and the goal is to surface evidence of work under <requested>, regardless of which agent recorded the parent session.
func (WorkspaceResolution) FallbackApplied ¶ added in v0.16.0
func (r WorkspaceResolution) FallbackApplied() bool
FallbackApplied reports whether resolution selected an ancestor workspace session after finding event evidence under the originally requested workspace.
func (WorkspaceResolution) MatchedFound ¶ added in v0.16.0
func (r WorkspaceResolution) MatchedFound() bool
MatchedFound reports whether resolution selected a session.
func (WorkspaceResolution) MatchedSession ¶ added in v0.16.0
func (r WorkspaceResolution) MatchedSession() apptypes.SessionSummary
MatchedSession returns the selected session summary.
type WorkspaceResolutionCriteria ¶ added in v0.16.0
type WorkspaceResolutionCriteria struct {
// contains filtered or unexported fields
}
WorkspaceResolutionCriteria describes the common filters used when resolving a requested workspace to the session row that should back read-side context assembly. It deliberately stays independent of any specific usecase criteria type so session, event, and memory context surfaces can share the same parent/child fallback contract.
func WorkspaceResolutionCriteriaOf ¶ added in v0.16.0
func WorkspaceResolutionCriteriaOf(sessionID domtypes.SessionID, workspace domtypes.Workspace, activeOnly bool) WorkspaceResolutionCriteria
WorkspaceResolutionCriteriaOf creates criteria for ResolveSessionWorkspace.
func (WorkspaceResolutionCriteria) ActiveOnly ¶ added in v0.16.0
func (c WorkspaceResolutionCriteria) ActiveOnly() bool
ActiveOnly reports whether session lookup should only consider active sessions.
func (WorkspaceResolutionCriteria) SessionID ¶ added in v0.16.0
func (c WorkspaceResolutionCriteria) SessionID() domtypes.SessionID
SessionID returns the optional exact session ID filter.
func (WorkspaceResolutionCriteria) Workspace ¶ added in v0.16.0
func (c WorkspaceResolutionCriteria) Workspace() domtypes.Workspace
Workspace returns the originally requested workspace.