Skip to content

refactor(custom-engine): extract customTransport interface with localTransport (#51)#88

Merged
zpzjzj merged 1 commit into
mainfrom
refactor/custom-transport-seam
Jun 5, 2026
Merged

refactor(custom-engine): extract customTransport interface with localTransport (#51)#88
zpzjzj merged 1 commit into
mainfrom
refactor/custom-transport-seam

Conversation

@zpzjzj
Copy link
Copy Markdown
Collaborator

@zpzjzj zpzjzj commented Jun 5, 2026

Summary

Resolves #51. Introduces an internal customTransport interface seam in the agent package so the planned HTTP transport (Phase 2) can drop in without rewriting the local-transport logic or the shared result handling. Pure refactor — no behavior, config, contract, or CLI change.

What changed

CustomAgent.Run now does three transport-agnostic steps and dispatches the rest:

  1. selectTransport — maps engine.custom.transport to an implementation (localTransport, or the http not-yet-implemented stub). HTTP later just returns &httpTransport{} from this one switch.
  2. prepareRun — builds the effective timeout, the full template variable set, and the marshaled SessionInput into a customRunPrep.
  3. assembleResult — maps a transportOutcome to a SessionResult, applying the shared exit-code / error semantics.

The local-specific work — resolving I/O files, persisting the input, clearing a stale output, building+executing the command, and reading the result payload from output_file or stdout — moves behind localTransport.run in the new internal/agent/custom_local.go, which returns a uniform transportOutcome.

runLocal / finishLocal / localRunContext are removed; registerFrameworkIO (bool flag-param) becomes appendFrameworkFiles([]string).

Behavior-preserving (verified)

  • Two-tier errors: setup errors (pre-exec) still return errorResult(0); exec-phase failures are carried in transportOutcome.execErr so a partial result is still assembled — including the post-timeout fresh-context output read.
  • raw vs stdout kept distinct so a bookkeeping output_file is never graded as a text-format answer.
  • Framework-file registration keeps the "input always, output iff produced-or-cleared" rule.
  • The http transport still returns the exact custom engine http transport is not yet implemented error.

Test plan

  • make test (go test -race ./...) — all green; internal/agent/custom_test.go (~50 TestCustomAgent_RunLocal_*) unchanged and passing (the safety net).
  • make verify (fmt + vet + revive + golangci-lint) — 0 issues.
  • make e2e custom-engine suite — TestPipeline_CustomEngine_{LocalTransport,Validate,RejectsMissingEnvVar} all pass.

Notes for reviewers

🤖 Generated with Claude Code

…Transport (#51)

Introduce an internal `customTransport` seam in the agent package so a future
HTTP transport drops in without rewriting the local-transport logic.

`CustomAgent.Run` now does three transport-agnostic steps: `selectTransport`
(local vs the http not-yet-implemented stub), `prepareRun` (build the timeout,
template vars, and SessionInput), and `assembleResult` (map the outcome to a
SessionResult with the shared exit-code/error semantics). The local-specific
work — resolving I/O files, persisting the input, clearing a stale output,
building+executing the command, and reading the result payload — moves behind
`localTransport.run` in custom_local.go, which returns a uniform
`transportOutcome`.

Behavior-preserving:
- Setup errors (pre-exec) still return errorResult(0); exec-phase failures are
  carried in transportOutcome.execErr so a partial result is still assembled,
  including the post-timeout fresh-context output read.
- transportOutcome keeps `raw` and `stdout` distinct so a bookkeeping
  output_file is never graded as a text-format answer.
- Framework input/output file registration keeps the "input always, output iff
  produced-or-cleared" rule; registerFrameworkIO becomes appendFrameworkFiles
  (no flag parameter, so the revive suppression is dropped).
- The http transport still returns the exact "not yet implemented" error.

All internal/agent tests are unchanged and pass (the safety net); make test,
make verify (0 issues), and the e2e custom-engine suite are green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@zpzjzj zpzjzj requested a review from hittyt as a code owner June 5, 2026 02:30
@zpzjzj zpzjzj requested review from jwx0925, lbfsc and lijunfeng722 June 5, 2026 02:36
@zpzjzj
Copy link
Copy Markdown
Collaborator Author

zpzjzj commented Jun 5, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@zpzjzj zpzjzj self-assigned this Jun 5, 2026
@zpzjzj zpzjzj added the enhancement New feature or request label Jun 5, 2026
Copy link
Copy Markdown
Collaborator

@lbfsc lbfsc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zpzjzj zpzjzj merged commit 43b9858 into main Jun 5, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom Engine: define internal transport interface seam before HTTP lands

2 participants