Skip to content

Companion editor and linter workflow plan (adotenv-lint 0.4.0 and adotenv-lsp 0.8.0)

Status: Planned. Tracking issues: #277 (adotenv-lint 0.4.0) and #278 (adotenv-lsp 0.8.0).

This cycle focuses on companion editor and CI workflow capabilities across two sequenced minor releases while keeping adotenv, adotenv-process, and adotenv-cli unchanged on 1.8.x:

  1. Track 1 (adotenv-lint 0.4.0, #277): enrich the shared schema model with key metadata, zero-new-dependency std value shapes and literal bounds, value-safe MissingKey placeholder fixes, SARIF 2.1.0 output, and --explain <rule>.
  2. Track 2 (adotenv-lsp 0.8.0, #278): adopt published adotenv-lint 0.4.0 (folding in PR #276’s post-0.7.2 fixes), surface schema metadata, deprecation tags, and MissingKey quick fixes, add dialect-accurate semanticTokens/full and foldingRange, and support bounded live reload of configured/discovered .adotenv-lint.toml and [schema] example files.

Invariants preserved across both tracks:

  • adotenv core stays untouched (1.8.1), dependency-free, no_std/alloc compatible, and Rust 1.81 MSRV.
  • adotenv-lint and adotenv-lsp preserve Rust 1.81 MSRV, forbid(unsafe_code), semver-checked 0.x lines, zero new runtime dependencies for schema shapes, and linear-time bounded reads on untrusted configs and documents.
  • Diagnostics, schema findings, hover text, SARIF reports, and placeholder fixes remain strictly value-free: MissingKey fixes insert KEY= with an empty value and never copy values from .env.example.
  • Add optional description: Option<String> and deprecated: Option<String> (or boolean/message form in TOML [schema.keys.<KEY>]) on KeySchema, with with_description / with_deprecated builders and per-key merge parity in LintConfig::apply.
  • Add Rule::DeprecatedKey (deprecated-key, default warning when a Schema marks a declared key deprecated; configurable as off, warning, or error in [rules]). Findings report the key and optional deprecation note without including document values.

2. Zero-new-dependency ValueShape variants and literal bounds

Section titled “2. Zero-new-dependency ValueShape variants and literal bounds”
  • Extend #[non_exhaustive] ValueShape using std-only, linear-time validation (no new crate dependencies; preserving Debug, Clone, PartialEq, Eq, Hash, Default):
    • ValueShape::IpAddr (std::net::IpAddr)
    • ValueShape::Host (RFC 1123 hostname or IP address)
    • ValueShape::SocketAddr (std::net::SocketAddr)
    • ValueShape::Email (practical linear-time RFC-style local@domain check without ASCII whitespace or control characters)
  • Add optional literal bounds on KeySchema and [schema.keys.*]: prefix: Option<String>, suffix: Option<String>, min_len: Option<usize>, and max_len: Option<usize> (validated for contradiction such as min_len > max_len during config loading; non-empty bounds follow existing allow_empty rules).

3. Value-safe MissingKey placeholder fixes

Section titled “3. Value-safe MissingKey placeholder fixes”
  • Add Fix::InsertEmpty { key: String } backed by adotenv::Edit::Insert with an empty value "" (never copying .env.example values) and attach it to Rule::MissingKey findings.
  • Classification and batching policy:
    • Explicit single-fix application (apply_fix / apply_fix_with_options) applies Fix::InsertEmpty directly through VerifiedEdits while honoring EditOptions bounds.
    • Default batch application (apply_batch / apply_batch_with_options) and CLI adotenv-lint --fix remain style-only (renames, sort, format) by default so routine style fixes never inject empty KEY= stubs silently.
    • Opt-in scaffolding via CLI --fix-missing (with --fix) and an explicit batch option/helper applies Fix::InsertEmpty insertions cleanly ahead of sort/format stages in one verified pipeline.
  • Add --format=sarif (OutputFormat::Sarif) emitting SARIF 2.1.0 JSON for GitHub Code Scanning and IDE problem matchers (including rule metadata, levels mapped from RuleSeverity, UTF-8/line-column regions, and strictly value-free messages with control/Bidi escaping where needed).
  • Add --explain <rule> (and --list-rules) printing an offline reference for each rule’s identifier, default severity, autofix support, and TOML/CLI configuration keys.

Built on published adotenv-lint 0.4.0 and including PR #276’s post-0.7.2 audit fixes (no separate 0.7.3 patch release):

1. Schema-rich editor UX and MissingKey quick fixes

Section titled “1. Schema-rich editor UX and MissingKey quick fixes”
  • Enrich hover and completion with value-free KeySchema metadata: description, expected ValueShape and literal bounds (prefix, suffix, min_len, max_len), required/optional status, and deprecation notice, applying existing control/Bidi/Markdown escaping.
  • Emit DiagnosticTag::DEPRECATED on deprecated-key diagnostics and CompletionItemTag::DEPRECATED on deprecated keys in completion.
  • Wire Fix::InsertEmpty into explicit quickfix code actions (Add 'KEY=' placeholder and a multi-key Add all missing keys quick fix when multiple required keys are missing), while keeping source.fixAll strictly style-only so save-on-fix never inserts empty stubs unexpectedly. Advertise codeActionProvider whenever either fixable style rules or an active schema with missing-key is configured.

2. Dialect-accurate semantic tokens and folding ranges

Section titled “2. Dialect-accurate semantic tokens and folding ranges”
  • Add ParsedDocument::semantic_tokens (and stateless semantic_tokens) plus textDocument/semanticTokens/full in the stdio server, using Document spans and adotenv’s active dialect to classify export keywords, declarations/keys (with declaration and deprecated modifiers), =/: operators, values, $VAR/${VAR}/$(...) references, and comments under the negotiated positionEncoding (utf-16, utf-8, utf-32) with limit_error() enforcement.
  • Add ParsedDocument::folding_ranges (and stateless folding_ranges) plus textDocument/foldingRange for multiline quoted values and contiguous comment blocks.
  • Active automatically whenever the stdio server is launched with --config <path> or --discover-lint-config (preserving zero implicit filesystem reads when neither flag is passed).
  • After initialized, when InitializeParams.capabilities.workspace .didChangeWatchedFiles.dynamicRegistration == true, issue a non-blocking client/registerCapability request watching the active config file and configured [schema] example file (updating registrations if schema.example changes on reload).
  • Also react to client-sent workspace/didChangeWatchedFiles and textDocument/didSave notifications matching the active config or example URI so clients without dynamic registration still reload directly.
  • Enforce the existing min(--max-input-bytes, 4 MiB) regular-file cap on config reloads and --max-input-bytes regular-file cap on [schema] example reloads.
  • On invalid, oversized, or unreadable reload: retain the last-known-good policy, emit a window/showMessage (Warning) notification, and recover automatically on the next valid save. If a discovered .adotenv-lint.toml is deleted under --discover-lint-config, re-run ancestor discovery (falling back to parser-only policy if none remains); under explicit --config, retain last-known-good and warn. Republish versioned diagnostics for all open buffers whenever the active policy changes.

Release sequencing and verification checklist

Section titled “Release sequencing and verification checklist”
  1. Implement, review/audit, run --in-diff remote mutation sweeps (1 worker, 8 GiB cap; see Heavy validation), and publish Track 1 (adotenv-lint 0.4.0) first via .github/workflows/release.yml (publish_linter=true).
  2. Verify adotenv-lint 0.4.0 on crates.io, docs.rs, GitHub Releases (4-way SHA-256 + Sigstore attestation), and cargo semver-checks.
  3. Implement Track 2 (adotenv-lsp 0.8.0) on top of published adotenv-lint 0.4.0, run full audit + --in-diff remote mutation sweeps, and publish Track 2 (adotenv-lsp 0.8.0) via release.yml (publish_lsp=true).
  4. Verify adotenv-lsp 0.8.0 on crates.io, docs.rs, GitHub Releases (4-way SHA-256 + Sigstore attestation), CI (MSRV 1.81, --no-default-features, cargo semver-checks), and Docs headless-browser smoke.