ADR-0069: LSP Server for IDE Integration¶
- Status: Accepted
- Date: 2026-05-02
- Supersedes: —
- Superseded by: —
- Related: ADR-0021 (Progressive Enhancement), ADR-0006 (Cedar Policy), ADR-0017 (ActiveGraph ORM)
Context¶
Trails developers work across multiple languages in a single project:
Python decorators (@capability, @node_type, @shape), Cedar .cedar
policy files, SPARQL queries embedded in triple-quoted strings, and
trails.toml configuration. Without IDE support, errors like duplicate
capability names, undefined node-type references, and unknown config keys
surface only at runtime.
The VS Code extension client stub (editor/vscode/src/lsp-client.ts)
already expects trails lsp --stdio but there is no server to connect to.
Decision¶
Implement a trails.lsp module using pygls (Python Language Server
Protocol library), served via trails lsp --stdio.
Features¶
- Diagnostics — on save/change:
- Duplicate capability names across files
- Undefined node-type references in field declarations
- Missing required fields on decorators
- Cedar policy references to non-existent capabilities
-
Unknown keys in
trails.toml -
Completions:
- Python type suggestions inside
@node_type(fields={...}) - Capability name suggestions inside
.cedarfiles -
Registered prefix suggestions inside SPARQL strings
-
Hover:
@capabilitysignature + docstring-
@node_typefield listing -
Go-to-definition:
- From node-type name references to their
@node_typedeclaration
Design constraints¶
- Pure AST analysis via Python's
astmodule — no Store or runtime import required. pyglsis an optional dependency; the module guards the import and raises a clear error if missing.- Lazy-loaded via the CLI's existing
LazyGroupmechanism.
Consequences¶
- IDE users get immediate feedback on cross-language consistency errors.
- The server can evolve incrementally: new diagnostic rules or completion sources are additive.
pyglsbecomes an optional dependency (not added to core requirements).