Skip to content

API Reference parrot_tools.lsp.models

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.lsp.models

View source

Data models for the LSP research pilot (FEAT-580, M1).

Defines the wire-safe evidence/configuration contracts consumed by the public toolkit (LSPToolkit, added by a later task) and the private snapshot/session records consumed by snapshot.py/session.py (also added by later tasks). Every model below performs pure, in-memory validation only: constructing any model here never opens a file, starts a process, or probes an executable.

Two diagnostic representations exist on purpose:

  • :class:LSPDiagnostic is the JSON-safe, public shape returned in :class:LSPResult — its message is bounded to keep tool output small.
  • :class:RawDiagnostic is the private, uncropped shape used internally by :class:DiagnosticBatch / :class:DiagnosticSnapshot so that freshness comparisons never operate on truncated text.

Attribute DIAGNOSTICS_TIMEOUT_DEFAULT_S

Attribute DIAGNOSTICS_TIMEOUT_MAX_S

Attribute DIAGNOSTIC_SNAPSHOT_TTL_SECONDS

Class DiagnosticBatch

Private, complete-or-explicitly-incomplete diagnostic publication set.

Never represents unknown coverage as an empty complete list: if missing_paths or unversioned_paths is non-empty, complete must be False.

Attributes:

Attribute Type Description
diagnostics dict[str, list[RawDiagnostic]]
matched_versions dict[str, int]
missing_paths list[str]
unversioned_paths list[str]
complete bool

Class DiagnosticSnapshot

Private in-memory diagnostic baseline record.

At most :data:MAX_DIAGNOSTIC_SNAPSHOTS snapshots are retained per toolkit instance (LRU eviction), each expiring after :data:DIAGNOSTIC_SNAPSHOT_TTL_SECONDS seconds. Both bounds are enforced by the toolkit (a later task), not by this model.

Attributes:

Attribute Type Description
snapshot_id str
paths tuple[str, ...]
environment_id str
config_digest str
server_version str
generation int
source_states list[SourceState]
diagnostics dict[str, list[RawDiagnostic]]
created_at datetime

Class EvidenceMeta

Provenance/freshness metadata attached to every non-trivial result.

Attributes:

Attribute Type Description
repo_root Path
workspace_id str
generation int
workspace_digest str
environment_id str
server_version str
config_digest str
observed_at datetime
source_states list[SourceState]
elapsed_ms int
cold_start bool
coverage Literal['selected_files', 'static_references']

Attribute IDLE_TIMEOUT_DEFAULT_S

Attribute IDLE_TIMEOUT_MAX_S

Attribute IDLE_TIMEOUT_MIN_S

Class LSPConfig

Trusted, operator-controlled configuration for one toolkit instance.

Validating an :class:LSPConfig never spawns a process, opens a file, or probes an executable — it only checks shapes and bounds.

Attributes:

Attribute Type Description
repo_root Path
server_command list[str]
version_command list[str]
expected_server_version str
python_path Path
source_roots list[Path]
environment_id str
startup_timeout_s float
request_timeout_s float
diagnostics_timeout_s float
idle_timeout_s float
node_heap_mb int

Class LSPDiagnostic

Public, JSON-safe diagnostic evidence with a bounded message.

Attributes:

Attribute Type Description
range SourceRange
severity int
severity_defaulted bool
code str | None
source str | None
message str

Class LSPFailure

Internal failure signal carrying one fixed operational code.

Raised by snapshot.py/session.py (later tasks); the toolkit converts it into an :class:LSPResult rather than letting it escape.

Parameter Type Default Description
code str
detail str ''

Class LSPLocation

One readable, confined Python source/stub location; no source body.

Attributes:

Attribute Type Description
range SourceRange
sha256 SHA256Hex

Class LSPResult

The typed envelope returned by every public toolkit method.

Attributes:

Attribute Type Description
status Literal['ok', 'partial', 'unavailable', 'error']
operation str
code str | None
message str
evidence EvidenceMeta | None
locations list[LSPLocation]
diagnostics list[LSPDiagnostic]
added list[LSPDiagnostic]
removed list[LSPDiagnostic]
snapshot_id str | None
checked_paths list[str]
missing_paths list[str]
truncated bool
omitted_count int
fallback str | None

Attribute LSP_ERROR_CODES

Type: frozenset[str]

Attribute MAX_DIAGNOSTIC_SNAPSHOTS

Attribute NODE_HEAP_DEFAULT_MB

Attribute NODE_HEAP_MAX_MB

Attribute OPERATOR_UNCONFIGURED_ENVIRONMENT_ID

Attribute REQUEST_TIMEOUT_DEFAULT_S

Attribute REQUEST_TIMEOUT_MAX_S

Class RawDiagnostic

Private, uncropped diagnostic record used for freshness comparisons.

Mirrors :class:LSPDiagnostic except full_message is never truncated, so DiagnosticBatch/DiagnosticSnapshot can preserve complete evidence internally while the public LSPDiagnostic stays bounded.

Attributes:

Attribute Type Description
range SourceRange
severity int
severity_defaulted bool
code str | None
source str | None
full_message str

Attribute SHA256Hex

Attribute STARTUP_TIMEOUT_DEFAULT_S

Attribute STARTUP_TIMEOUT_MAX_S

Class SourcePosition

A verified, one-based Unicode position inside a repository file.

Attributes:

Attribute Type Description
path str
line int
column int
expected_sha256 SHA256Hex

Class SourceRange

A one-based, end-exclusive Unicode coordinate range in a file.

Attributes:

Attribute Type Description
path str
start_line int
start_column int
end_line int
end_column int

Class SourceState

The exact hashed content identity of one on-disk file.

Attributes:

Attribute Type Description
path str
sha256 SHA256Hex
document_version int

Class WorkspaceSnapshot

Private bounded snapshot of the exact files a call depends on.

Produced by snapshot.py's capture_workspace (a later task); never opens or hashes anything itself.

Attributes:

Attribute Type Description
digest str
file_hashes dict[str, SHA256Hex]
requested_text dict[str, str]
config_digest str
missing_paths list[str]

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally