Skip to content

Enable Wire runtime debugging in ferret debug - #109

Merged
ziflex merged 2 commits into
mainfrom
feat/remote-debugger
Nov 16, 2026
Merged

ziflex merged 2 commits into
mainfrom
feat/remote-debugger

Conversation

@ziflex

@ziflex ziflex commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

ferret debug now compiles local FQL source on the selected runtime and opens a portable debugger session. For example, ferret debug --runtime wire --runtime-endpoint tcp://127.0.0.1:54321 --param limit=10 script.fql can step through FQL that calls a host-only function and inspect local variables. Builtin remains the default.

The prompt renders a returned stop or completion result before handling an accompanying error. If a start or resume response has no event, the command exits nonzero because the last known stop can no longer be trusted. A clean completion keeps the existing prompt. Both runtimes can list retained breakpoints after completion. The builtin runtime also permits setting and deleting them. Wire alpha.4 rejects pause from an already stopped prompt, after which stepping and continuing remain available.

The command closes the session, plan, and runtime in order. Both the debugger and REPL detect unexpected termination of Wire's Connect stream, including when the TCP connection remains open. They release the runtime before waiting for borrowed input to settle. Callers injecting an indefinitely blocking reader into StartWithIO can implement ReadContext(context.Context, []byte) (int, error) or wake it themselves. Process stdin is interruptible on Linux, macOS, and Windows.

The Go prompt and renderer now accept github.com/MontFerret/api/source.Source, and the owned debugger exposes api/debugger.Session. The legacy HTTP Worker reports errors.ErrUnsupported for debug compilation.

Validation included go test ./..., make lint, affected packages under go test -race, and a smoke test of the built CLI against the example Wire host. Integration tests cover inspection and stepping on both runtimes, completion with a cleanup failure, an undeliverable completion response, and physical connection release on interruption or early exit. Unix pseudo-terminal checks exercised normal exit and cancellation. Native Windows CI exercises console mode restoration and redirected stdin reuse.

On Apple M2 Max, five runs of go test ./pkg/runtime -run '^$' -bench '^BenchmarkBuiltinDebugLifecycle$' -benchmem -count=5 measured a median of 1.672 ms before the UAPI change and 1.763 ms after, with 18,022 and 18,038 allocations per session. For the follow-up change to Wire disconnect detection, go test ./pkg/runtime -run '^$' -bench '^BenchmarkWireConnection$' -benchmem -count=5 measured median connection setup of 342 µs before and 357 µs after, with 1,050 and 1,053 allocations.

Comment on lines +55 to +62
name: Windows console and redirected input
runs-on: windows-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: '>=1.26'
- run: go test -count=1 -timeout=1m ./internal/prompt
@ziflex
ziflex merged commit 9bf903c into main Nov 16, 2026
10 checks passed
@ziflex
ziflex deleted the feat/remote-debugger branch November 16, 2026 23:15
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.

2 participants