Skip to content

feat(adapters): add GoAdapter driving dlv dap#3

Closed
niradler wants to merge 1 commit into
feat/adapter-interfacefrom
feat/go-adapter
Closed

feat(adapters): add GoAdapter driving dlv dap#3
niradler wants to merge 1 commit into
feat/adapter-interfacefrom
feat/go-adapter

Conversation

@niradler
Copy link
Copy Markdown
Owner

Summary

Second PR in the multi-language stack. Stacks on top of #2 (Adapter ABC refactor) — merge that first; once merged, this PR's base will be main.

GoAdapter implements the Adapter contract for Go programs:

  • Adapter spawndlv dap --listen=127.0.0.1:<port>, with a clear "delve not installed" error pointing at the go install command when dlv isn't on PATH (no cryptic ENOENT).
  • Launch payloadmode: "debug" so delve compiles + runs in one step from a .go file or package directory.
  • spawn_listen_mode for IDE attach (VS Code Go extension dap-mode).
  • parse_traceback understands both panic: and fatal error: dumps, including extended runtime frames with +0xN fp=0x... sp=0x... pc=0x... annotations. Frames stored oldest-first so the shared deepest_user_frame heuristic lands on the panic site. runtime.* / sync.* / reflect.* / internal/* frames are marked is_user_code=False.
  • resolve_launch_target peels go run [-flags] <main.go> args... into (main.go, args) for dbga diagnose. go test is out of scope (would need mode: "test").

CLI

dbga session start --break-at main.go:12 -- main.go
dbga diagnose --timeout 30 -- go run main.go
dbga localize --lang go --file panic.txt

Language is auto-detected from the script extension; --lang go forces it.

Test plan

  • 14 new unit tests (tests/unit/test_go_adapter.py) — registry, detection, listen-mode flag, launch-payload shape, go run peeling, panic + fatal-error parsing, missing-dlv error path.
  • 1 new integration test (tests/integration/test_go_session.py) — drives real dlv dap end-to-end (initialize / launch / stopOnEntry / continue / terminated). Auto-skips when dlv or go isn't on PATH.
  • uv run pytest -v — 128 passed (61 unit + 14 Go unit + 1 misc, 8 integration, 45 e2e), driven against real delve 1.22+ on Windows.
  • uv run ruff check . clean
  • uv run ruff format --check . clean
  • uv run mypy src clean (29 files)
  • __debug_bin* + *.test added to .gitignore (dlv dap leaves the compiled binary in cwd).

Out of scope (deferred)

  • go test ./... debugging (needs DAP mode: "test" + --test.run plumbing).
  • dbga instrument probe templates for Go (fmt.Println defaults).

Stack

Second PR in the multi-language stack. Stacks on top of #2 (Adapter ABC
refactor); merge that first.

GoAdapter implements the Adapter contract for Go programs:

  * spawn `dlv dap --listen=127.0.0.1:<port>` as the DAP server, with a
    clear "delve not installed" error pointing at the `go install` command
    when `dlv` isn't on PATH (no cryptic ENOENT).
  * launch payload uses `mode: "debug"` so delve compiles + runs in one
    step from a `.go` file or package directory.
  * `spawn_listen_mode` for IDE attach (VS Code Go extension dap-mode).
  * `parse_traceback` understands both `panic:` and `fatal error:` dumps,
    including extended runtime frames with `+0xN fp=0x... sp=0x... pc=0x...`
    annotations. Frames stored oldest-first (matches Python convention) so
    the shared `deepest_user_frame` heuristic lands on the panic site.
  * runtime / sync / reflect / internal frames are marked `is_user_code=False`
    so the deepest-user heuristic skips runtime scaffolding when reporting
    crash locations.
  * `resolve_launch_target` peels `go run [-flags] <main.go> args...` into
    `(main.go, args)` for `dbga diagnose`. `go test` is out of scope (would
    need `mode: "test"`); it returns None and surfaces the crash without
    rerun, matching the existing Python `-m` behavior.

CLI surface:

  $ dbga session start --break-at main.go:12 -- main.go
  $ dbga diagnose --timeout 30 -- go run main.go
  $ dbga localize --lang go --file panic.txt

Language is auto-detected from the script extension; `--lang go` forces it.

Test plan:

  * 14 new unit tests (`tests/unit/test_go_adapter.py`) covering registry,
    detection, listen-mode flag, launch-payload shape, `go run` peeling,
    panic + fatal-error parsing, and the missing-dlv error path.
  * 1 new integration test (`tests/integration/test_go_session.py`)
    drives real `dlv dap`: initialize / launch / stopOnEntry / continue /
    terminated. Auto-skips when `dlv` or `go` isn't on PATH so the suite
    stays green on Python-only machines.
  * `__debug_bin*` + `*.test` added to .gitignore — `dlv dap` leaves the
    compiled debug binary in cwd.

Local validation:
  - 76 unit tests pass (61 prior + 14 new + 1 misc).
  - 8 integration tests pass (7 Python + 1 Go) — driven against real
    delve 1.22+ on Windows.
  - 45 e2e tests pass unchanged.
  - ruff check + ruff format + mypy --strict all clean.

Out of scope for this PR (deferred to future work):
  - `go test ./...` debugging (needs DAP `mode: "test"` + `--test.run` plumbing).
  - `dbga instrument` probe templates for Go (`fmt.Println` defaults).
@niradler
Copy link
Copy Markdown
Owner Author

Superseded by #5, which consolidates the refactor + Go + Node work into a single PR against main (with post-review fixes applied). Closing in favor of #5.

@niradler niradler closed this May 29, 2026
niradler added a commit that referenced this pull request May 29, 2026
…E usage guidance

node-expert: make the top-level evidence stance unconditional (mirrors
python-expert rule #3) so the RUNTIME-VERIFIED/INSPECTION-ONLY labeling
discipline applies to review/audit tasks, not just crash-fix flows.

README: add usage guidance (architect delegation cliff, review-vs-debug
expectations, opus override for hard single-language tasks).
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