Files
rengine/shared/models/asset_query.py
T
Yogesh OjhaandClaude Fable 5.1 d4072b8efa perf: make the read path scale with the estate
Scan page froze on a duplicate each key; every tab body now sits in a
svelte:boundary. Composite discovered_at indexes on the five result
tables, leads counted in one FILTER pass, dashboard and scan-service
first-seen counts bounded to the scans in the window, ANALYZE at
finalize, shm_size on the db service, SQL_ECHO instead of DEBUG, an
entrypoint that serves with workers outside reload.

Settled-scope aggregates and search pages are cached by target
revision; triage, dismissal, interest evaluation, notes, certificate
rechecks and re-ranking bump it. Requests per page cut: single-flight
GETs, one schemas endpoint, batched whois correlations, a counts
endpoint for the dashboard, deduped store loads, trimmed coverage
payloads.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NWRq8utu7KXsVBVU3gYNi7
2026-09-12 08:49:41 +05:30

108 lines
2.4 KiB
Python

from pydantic import BaseModel, Field
class QueryFieldSpec(BaseModel):
name: str
type: str
group: str
description: str
example: str
aliases: list[str] = Field(default_factory=list)
values: list[str] = Field(default_factory=list)
facet: str | None = None
operators: list[str] = Field(default_factory=list)
free_text: bool = False
unit: str | None = None
dynamic_sub: str | None = None
class QueryOperatorSpec(BaseModel):
symbol: str
description: str
class QueryExampleSpec(BaseModel):
query: str
description: str
group: str = ""
generic: bool = False
class QueryLead(QueryExampleSpec):
count: int = 0
capped: bool = False
class QueryLeads(BaseModel):
leads: list[QueryLead] = Field(default_factory=list)
total: int = 0
total_capped: bool = False
filtered: bool = False
computed: bool = False
class QueryCountRequest(BaseModel):
queries: list[str] = Field(default_factory=list, max_length=32)
class QueryCounts(BaseModel):
counts: dict[str, int] = Field(default_factory=dict)
capped: dict[str, bool] = Field(default_factory=dict)
computed: bool = False
class QueryGroupSpec(BaseModel):
key: str
label: str
description: str
class QueryGroup(BaseModel):
value: str
label: str
count: int
query: str
class QueryGroups(BaseModel):
dimension: str = ""
groups: list[QueryGroup] = Field(default_factory=list)
total_groups: int = 0
truncated: bool = False
rows: int = 0
covered: int = 0
class QueryFlagSpec(BaseModel):
value: str
description: str
class QuerySchema(BaseModel):
max_length: int = 0
max_terms: int = 0
noun: str = "host"
noun_plural: str = "hosts"
groups: list[str] = Field(default_factory=list)
example_groups: list[str] = Field(default_factory=list)
group_dimensions: list[QueryGroupSpec] = Field(default_factory=list)
fields: list[QueryFieldSpec] = Field(default_factory=list)
operators: list[QueryOperatorSpec] = Field(default_factory=list)
connectors: list[QueryOperatorSpec] = Field(default_factory=list)
flags: list[QueryFlagSpec] = Field(default_factory=list)
examples: list[QueryExampleSpec] = Field(default_factory=list)
class QueryError(BaseModel):
message: str
hint: str | None = None
start: int = 0
end: int = 0
class MatchEvidence(BaseModel):
field: str
label: str
term: str
snippet: str | None = None