Skip to content

feat(proof-lsp): implement Deno LSP adapter (Coq/Lean/Isabelle/Agda) - #7

Merged
hyperpolymath merged 1 commit into
mainfrom
feat/proof-lsp-adapter
May 26, 2026
Merged

hyperpolymath merged 1 commit into
mainfrom
feat/proof-lsp-adapter

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

First of the 11 LSP cartridge adapter ports per the handover document
docs/handover/2026-05-26/prompts/cartridge-04-lsp-adapter-pattern.adoc.
Ports polystack/poly-proof Elixir LSP to Deno; establishes the pattern
for the remaining 10 LSP cartridges (cloud, container, database, k8s, git,
iac, observe, queues, secrets, ssg).

  • adapter/server.ts — Content-Length framing + JSON-RPC dispatch (CRLF-correct).
  • adapter/handlers/{initialize,diagnostic,hover,completion,executeCommand}.ts.
  • adapter/backends/{coq,lean,isabelle,agda}.ts + base.ts + registry.ts.
  • Manifest states[] advances to adapter-implemented; mod.js#start() now spawns the adapter (was throwing).

Tests

deno test --allow-read --allow-run --allow-env — 28 passed, 0 failed:

  • 14 backend unit tests: registry build, extension dispatch, detect() on temp dirs, lint() short-circuit on wrong extension, complete() for Coq/Lean tactics.
  • 13 server tests: FrameDecoder (single, partial-input, multi-message, CRLF), dispatch per method, unknown-method -32601, notification → null, shutdown round-trip.
  • 1 integration test: spawns deno run adapter/server.ts as a subprocess, sends framed initialize, asserts serverInfo.name === "proof-lsp".

Pitfalls noted in handover doc

  • ✅ Content-Length uses \r\n, not \n (covered by encodeFramed uses CRLF header terminator).
  • ✅ Per-backend output parsing kept distinct (no premature abstraction).
  • ✅ Backend binaries optional: available() checks --version exit, diagnostics surface "not available" as info severity instead of failing.
  • ✅ Subprocess cleanup in integration test (stdout.cancel() + stderr.cancel() + writer close before kill).

Repo housekeeping

  • .gitignore adds **/deno.lock — matches the stack-orchestrator-mcp adapter precedent (lockfile is per-adapter, regenerated on demand).

Test plan

  • deno check adapter/server.ts adapter/types.ts adapter/handlers/*.ts adapter/backends/*.ts passes.
  • deno test --allow-read --allow-run --allow-env passes (28/28).
  • Smoke test spawns the adapter and round-trips initialize.

🤖 Generated with Claude Code

Ports polystack/poly-proof Elixir LSP to Deno per
handover/cartridge-04-lsp-adapter-pattern.adoc. First of 11 LSP cartridge
adapter implementations.

Adapter surface:
- adapter/server.ts: Content-Length framing + JSON-RPC dispatch
- adapter/handlers/{initialize,diagnostic,hover,completion,executeCommand}.ts
- adapter/backends/{coq,lean,isabelle,agda}.ts + base.ts + registry.ts
- 28 tests pass (deno test --allow-read --allow-run --allow-env):
  - 14 backend unit tests (registry, detect, lint, complete)
  - 13 server tests (FrameDecoder, dispatch per method)
  - 1 integration test spawning the adapter subprocess

Manifest changes:
- states[]: added "adapter-implemented"
- mod.js start() now spawns adapter/server.ts (was throwing)

Repo housekeeping:
- .gitignore: **/deno.lock (matches orchestrator-mcp adapter precedent)

This establishes the pattern for the remaining 10 LSP adapter ports
(cloud, container, database, k8s, git, iac, observe, queues, secrets,
ssg) — each is ~2h of focused work, throttled per the secondary
rate-limit memo.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@hyperpolymath
hyperpolymath merged commit 43aea71 into main May 26, 2026
@hyperpolymath
hyperpolymath deleted the feat/proof-lsp-adapter branch May 26, 2026 17:16
hyperpolymath added a commit that referenced this pull request May 26, 2026
…or-mcp (#8)

Ports polystack/poly-orchestrator-lsp/lib/orchestrator/executor.ex +
lsp_client.ex to Deno per handover/cartridge-02-phase-3-execute-rollback.adoc.
Wires the `stack_execute_phase` and `stack_rollback` MCP tools.

New adapter modules:
- adapter/executor.ts: phase loop, parallel-group dispatch, retry,
  output propagation, dryRun matrix, maxParallel slicing
- adapter/lsp_client.ts: LspClient interface + StdioLspClient (spawns
  per-cartridge subprocesses, JSON-RPC over stdio) + MockLspClient for
  testing + lspServerToPath() name resolver (direct + legacy poly-* aliases)
- adapter/rollback.ts: reverse-execute via planner.buildRollbackPlan,
  honours toPhase, skips non-succeeded steps, refuses when disabled

Tests (51 passed, 0 failed; was 23):
- executor_test.ts (13): forward + dryRun + parallel + sibling-failure
  + retry success/exhaustion + maxParallel + interpolation + all-phases
  propagation + halt-on-error + dispatch matrix
- rollback_test.ts (4): reverse order + toPhase + skip-failed + disabled
- lsp_client_test.ts (10): MockLspClient default/override/error/failOnce
  /call-recording + lspServerToPath direct/legacy/unknown
- integration_test.ts: StdioLspClient drives the *real* proof-lsp
  cartridge (from PR #7) end-to-end — verifies framing + JSON-RPC
  round-trip including error responses

Manifest:
- states[] adds `phase-3-execute-rollback`
- deno.json bumps to 0.2.0, exports executor/rollback/lsp_client,
  test task gains --allow-run

Deferred (per handover doc):
- VerisimDB-backed persistence (in-memory only for now)
- Per-LSP `execute_component` handler is the natural next step on each
  domain LSP adapter; until then StdioLspClient surfaces the unknown-
  method error path cleanly

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
hyperpolymath added a commit that referenced this pull request May 26, 2026
Adds STATUS banners to two handover prompts so a future session doesn't
re-execute completed work:

- cartridge-02 (Phase 3 execute+rollback) — landed as PR #8.
- cartridge-04 (LSP adapter pattern) — proof-lsp landed as PR #7;
  remaining 10 listed in suggested order.

The other 8 prompts remain live (cartridge-03 Idris2/Shield,
cartridge-05 boj-server cleanup, cartridge-06 standards#200
follow-through, cartridge-07 boj-server#158 follow-through, plus
earlier-01/02/03).

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
hyperpolymath added a commit that referenced this pull request May 26, 2026
…al (#10)

Aligns the machine-readable handover with the prose banners just landed
in PR #9, so an ingesting agent doesn't pick up tasks that are already
done.

Status updates:
- cartridge-01: done (PR #6)
- cartridge-02: done (PR #8, 28 tests added)
- cartridge-04: partial (proof-lsp done as PR #7; 10 remain)
- earlier-02: closed_abandoned (with resolution rationale)
- earlier-03: in_flight (hypatia#344, auto-merge ON)
- cartridge-06 + cartridge-07: blockers cleared (standards#200 +
  boj-server#158 both merged today)

Remaining live work:
- cartridge-03 Phase 4 Idris2/Shield (12h, blocks on #2 only — now unblocked)
- cartridge-04 sub-tasks (10 LSP adapters, ~20h)
- cartridge-05 (boj-server cartridges/ removal, gated on #158 burn-in judgment)
- cartridge-06/07 follow-throughs (1h + 4h)
- earlier-01 (duplicate-reconciliation, 3h)

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant