Validate
Rejects inputs the tool cannot possibly run, before any container or network resource is spent.
- Runs before execution. Keep it cheap — no network calls, no process spawns.
- Return an error to block the run; return
nilto allow it. - Upstream validation against the connector’s
inputsSchemaalready runs in the worker, so this is a second line of defense for anything the schema cannot express.
Execute
Runs the tool and streams findings to out.
- Stream, do not buffer. Send each finding to
outas it is produced. A long scan should return results before it finishes. - Honor cancellation. Stop when
ctx.Done()is closed — the runtime may cancel a run mid-flight.selectonctx.Done()when sending. - Never close
out. The runtime owns the channel. - Keep tool-specific code in this package and nowhere else.
Error convention
The worker uses an error’s prefix to decide whether to retry. Apply the prefix to every error you return.
The SDK applies the prefix to errors it raises itself. An error with no prefix is treated as retryable.
Wrapping the adapter
connector.New wraps your adapter so the runtime can drive it. You do not call Validate or Execute yourself.
Design notes
- Prefer in-process embedding over a CLI wrapper where the tool offers a library — no subprocess lifecycle, no output-format drift, cancellation propagates naturally.
- Remote-API tools ship no bundled binary. The adapter is the client; credentials belong in
configSchema, never in code or the image. - Map severities explicitly with a lookup table, not string guessing. See Finding.
- Never leak secrets into findings or logs. Findings are persisted and displayed; config values are not.
