Goal
Make repeated semantic queries over one loaded Wright session reuse the semantic state that is valid for that program/configuration instead of reconstructing full-program analysis state for each query.
Context
ToolService holds one loaded canonical program, but its semantic-query path constructs a fresh SemanticService for individual query operations. The canonical service construction builds semantic indexes and analysis-derived data over the loaded program. Query-heavy consumers such as inspect/tool/agent workflows can therefore repeat work that is invariant within the same loaded session.
This is a performance and allocation issue, not an API redesign objective. The change must preserve query semantics and should be justified by measurements on representative Wright workloads rather than assumed percentage improvements.
Scope
- Measure the current cost of repeated
Rules, Symbols, References, Usage, Cfg, findings, persistent-object, and lint-related queries over representative canonical Workshop inputs.
- Identify which semantic/index/analysis products are invariant for the lifetime of one loaded
ToolService and which depend on lint configuration or request-specific inputs.
- Reuse invariant semantic state across requests without weakening configuration correctness or introducing stale results.
- Review
inspect construction for avoidable in-process JSON Value round-trips and repeated per-symbol service requests; use a structured internal path where this materially removes measured overhead without expanding the public contract.
- Preserve the existing transport-neutral
ToolService request/response surface.
Non-goals
- Changing lint/analyze semantics or rule ownership.
- Adding a general cache framework or cross-session/global cache.
- Exposing internal
SemanticIndex representation as a public API solely for optimization.
- Optimizing unmeasured micro-costs unrelated to repeated semantic-query work.
- Changing provider/source-language semantics.
Acceptance criteria
- Representative measurements demonstrate the repeated semantic work present before the change and record the workload used for comparison.
- Repeated semantic queries over one unchanged loaded program do not rebuild invariant full-program semantic/index state for each request.
- Lint configuration-dependent results remain correct when the effective configuration differs from the default query path.
inspect avoids repeated serialization/deserialization or per-symbol query loops where the same result can be obtained from already-built internal semantic state, when supported by the measured workload.
- Public
ToolRequest/ToolResponse behavior and deterministic output remain unchanged unless a separately documented contract defect is discovered.
- Memory ownership/lifetimes remain local to the loaded service/session; no global mutable cache is introduced.
- Relevant service, inspect, CLI, and embedding tests remain green.
- Independent ablation of the reuse path restores the measured repeated-work regression.
Dependencies / ownership
wright: owns ToolService, inspect composition, analyzer/query orchestration, and performance of its product/tooling surfaces.
workshop-rs: remains the owner of canonical Workshop semantics; this issue must not duplicate or cache source-owner semantics outside the existing canonical program contract.
Goal
Make repeated semantic queries over one loaded Wright session reuse the semantic state that is valid for that program/configuration instead of reconstructing full-program analysis state for each query.
Context
ToolServiceholds one loaded canonical program, but its semantic-query path constructs a freshSemanticServicefor individual query operations. The canonical service construction builds semantic indexes and analysis-derived data over the loaded program. Query-heavy consumers such as inspect/tool/agent workflows can therefore repeat work that is invariant within the same loaded session.This is a performance and allocation issue, not an API redesign objective. The change must preserve query semantics and should be justified by measurements on representative Wright workloads rather than assumed percentage improvements.
Scope
Rules,Symbols,References,Usage,Cfg, findings, persistent-object, and lint-related queries over representative canonical Workshop inputs.ToolServiceand which depend on lint configuration or request-specific inputs.inspectconstruction for avoidable in-process JSONValueround-trips and repeated per-symbol service requests; use a structured internal path where this materially removes measured overhead without expanding the public contract.ToolServicerequest/response surface.Non-goals
SemanticIndexrepresentation as a public API solely for optimization.Acceptance criteria
inspectavoids repeated serialization/deserialization or per-symbol query loops where the same result can be obtained from already-built internal semantic state, when supported by the measured workload.ToolRequest/ToolResponsebehavior and deterministic output remain unchanged unless a separately documented contract defect is discovered.Dependencies / ownership
wright: ownsToolService, inspect composition, analyzer/query orchestration, and performance of its product/tooling surfaces.workshop-rs: remains the owner of canonical Workshop semantics; this issue must not duplicate or cache source-owner semantics outside the existing canonical program contract.