Skip to content

feat: Go-first opentmux runtime with TS compatibility shims#6

Open
AnganSamadder wants to merge 2 commits intomainfrom
refactor/go-rewrite
Open

feat: Go-first opentmux runtime with TS compatibility shims#6
AnganSamadder wants to merge 2 commits intomainfrom
refactor/go-rewrite

Conversation

@AnganSamadder
Copy link
Owner

Summary

This PR introduces a Go-first runtime architecture for opentmux while preserving plugin/CLI compatibility through thin TypeScript shims and legacy fallbacks.

The objective is to move high-throughput and process-heavy behavior out of Node/TS and into Go, while keeping user-facing behavior stable and preserving the existing package entrypoints.

What Changed

1. Go platform foundation

  • Added Go module and dependency management:
    • go.mod, go.sum
  • Added Buf v2 config and lockfile:
    • buf.yaml, buf.gen.yaml, buf.lock
  • Added control-plane protobuf contract:
    • proto/opentmux/v1/opentmux.proto
  • Added generated artifacts:
    • gen/go/...
    • gen/ts/...

2. Go runtime binaries

  • Added Go CLI wrapper:
    • cmd/opentmux/main.go
  • Added Go daemon:
    • cmd/opentmuxd/main.go
  • Added Go control client:
    • cmd/opentmuxctl/main.go

3. Core Go runtime packages

  • Config loading + normalization:
    • internal/config/config.go
  • Structured logging:
    • internal/logging/logger.go
  • Metrics snapshot support:
    • internal/metrics/metrics.go
  • Process helpers (PID lookup/kill/wait/etc):
    • internal/process/process.go
  • tmux operations:
    • internal/tmux/tmux.go
  • Spawn queue implementation:
    • internal/spawnqueue/queue.go
  • Zombie reaper:
    • internal/reaper/reaper.go
  • Session manager lifecycle and polling:
    • internal/sessionmanager/manager.go
  • RPC control service:
    • internal/control/service.go

4. TypeScript compatibility shim

  • Replaced plugin entrypoint with Go-control shim:
    • src/index.ts
  • Replaced bin entrypoint with Go-CLI shim:
    • src/bin/opentmux.ts
  • Added runtime binary resolver/executor:
    • src/utils/go-runtime.ts
  • Preserved legacy behavior as fallback:
    • src/legacy-plugin.ts
    • src/bin/opentmux-legacy.ts

5. Build/CI and benchmarking

  • Bun-driven Go runtime build script:
    • scripts/build-go-runtime.ts
  • Burst benchmark harness:
    • scripts/bench/run-burst.ts
    • internal/spawnqueue/queue_bench_test.go
  • Updated npm scripts:
    • build, build:go, proto:generate, bench:burst
  • Updated publish workflow to install Go and build release binaries:
    • .github/workflows/publish.yml

6. Documentation updates

  • Rewrite/development notes added to:
    • README.md
    • docs/LOCAL_DEVELOPMENT.md

Behavior/Parity Notes

  • TS compatibility is preserved via shim + fallback.
  • Go queue parity was improved to match TS duplicate coalescing behavior for both queued and in-flight items.

Tests and Validation

Automated checks run

  • go test ./...
  • go test -race ./internal/spawnqueue ./internal/control ./internal/config
  • go vet ./...
  • bun run proto:generate
  • bun run typecheck
  • bun test
  • bun run build
  • bun run scripts/bench/run-burst.ts

Manual smoke checks run

  • Daemon lifecycle:
    • start opentmuxd
    • opentmuxctl init
    • opentmuxctl stats
    • opentmuxctl shutdown
    • verified clean daemon exit

Known Constraints

  • edition = "2024" was not fully compatible with the current stable generation path used here; proto currently uses syntax = "proto3" for reliable generation.
  • Existing repo scripts test-plugin.sh and test-multiport.sh are environment/path-sensitive:
    • test-plugin.sh requires an active tmux session
    • test-multiport.sh references a legacy path outside this repo

Impact

This PR establishes a production-ready migration scaffold: Go-first runtime, compatibility shims, build pipeline integration, and parity-focused tests, without removing legacy fallback paths yet.

- add Go module, Buf config, protobuf control-plane contract, and generated stubs

- implement Go daemon/CLI/control binaries and core packages (session manager, queue, tmux, process, reaper, metrics, config, logging)

- replace TS plugin/bin entrypoints with thin Go runtime shims and preserve legacy TS fallback paths

- add Bun-driven Go build pipeline, benchmark harness, and CI Go setup for publish workflow

- add Go parity tests for queue/config/control and fix in-flight duplicate coalescing behavior

- update docs for local development and rewrite architecture
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

Comments