Skip to content

feat(orchestrator): Phase 3 — execute + rollback for stack-orchestrator-mcp - #8

Merged
hyperpolymath merged 1 commit into
mainfrom
feat/orchestrator-phase-3
May 26, 2026
Merged

hyperpolymath merged 1 commit into
mainfrom
feat/orchestrator-phase-3

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

Phase 3 of the stack-orchestrator-mcp cartridge per docs/handover/2026-05-26/prompts/cartridge-02-phase-3-execute-rollback.adoc. Ports the polystack Elixir executor.ex + lsp_client.ex to Deno; wires the stack_execute_phase and stack_rollback MCP tools.

What's new in adapter/

  • executor.ts — phase loop, parallel-group dispatch, retry, \${id.field} interpolation, dryRun matrix, maxParallel slicing. Sibling failures don't cancel in-flight peers.
  • lsp_client.ts — LspClient interface, StdioLspClient (spawns target cartridge subprocesses + JSON-RPC over stdio), MockLspClient (test stub), lspServerToPath() direct + legacy poly-* resolver.
  • rollback.ts — reverse-executes a plan via planner.buildRollbackPlan, honours toPhase, skips non-succeeded steps, refuses when the stack's rollback strategy is disabled.

Tests — 51 passed, 0 failed (was 23 on Phase 2)

deno test --allow-read --allow-run --allow-env --allow-write
  • 13 executor_test.ts: forward, dryRun, parallel concurrency, sibling-failure isolation, retry success + exhaustion, maxParallel slicing, interpolateConfig, full-plan propagation, halt-on-error, dispatch matrix.
  • 4 rollback_test.ts: reverse-phase order, toPhase truncation, skip-failed steps, disabled-strategy error.
  • 10 lsp_client_test.ts: MockLspClient default/override/error/failOnce/call-recording, lspServerToPath direct/legacy/unknown.
  • 1 integration_test.ts: StdioLspClient spawns the real proof-lsp cartridge from PR feat(proof-lsp): implement Deno LSP adapter (Coq/Lean/Isabelle/Agda) #7, sends execute_component, asserts the JSON-RPC error round-trip (proof-lsp doesn't yet know execute_component, so -32601 is the expected and verifying response — proves the wire works end-to-end).

Manifest + packaging

  • cartridge.json#/states[] advances: phase-2-parser-planner → phase-3-execute-rollback
  • adapter/deno.json → 0.2.0; new exports for ./executor, ./rollback, ./lsp_client; test task gains --allow-run; adds @std/path@1.

Deferred (per handover doc)

  • VerisimDB-backed persistence — current port is in-memory only. The original Elixir wrote execution traces to VerisimDB; equivalent Deno store is a follow-up.
  • Per-LSP execute_component handler — each domain LSP cartridge needs to learn workspace/executeCommand execute_component for its component types. That's the natural follow-up on each adapter (PR feat(proof-lsp): implement Deno LSP adapter (Coq/Lean/Isabelle/Agda) #7 onward).

Pitfalls noted in handover

  • ✅ Sibling failure does NOT cancel parallel peers (test: executePhase: sibling failure does not abort other siblings).
  • ✅ maxParallel respected (test: maxParallel slices group).
  • ✅ Subprocess cleanup in StdioLspClient.close() — cancels stdout/stderr, closes writer, kills + awaits status.
  • ✅ Rollback respects rollback_strategy.enabled flag.

Test plan

  • deno check executor.ts lsp_client.ts rollback.ts passes.
  • deno test --allow-read --allow-run --allow-env --allow-write passes (51/51).
  • End-to-end test drives against real proof-lsp cartridge.

🤖 Generated with Claude Code

…or-mcp

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
hyperpolymath merged commit e64d7b8 into main May 26, 2026
@hyperpolymath
hyperpolymath deleted the feat/orchestrator-phase-3 branch May 26, 2026 17:23
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