Skip to content

Rust refactor: consolidate codex+opencode harness adapters; drop WatcherController newtype #328

@willwashburn

Description

@willwashburn

Context

Two separate cleanup wins sit in crates/relayburn-cli/src/harnesses/:

1. harnesses/codex.rs and harnesses/opencode.rs are 95% identical.

Both expose config() + adapter() with the same shape; they differ only in:

  • harness name string,
  • session_root path (a static ~/.codex/sessions vs ~/.local/share/opencode/storage/session),
  • ingest function (ingest_codex_sessions_into vs ingest_opencode_sessions_into).

These adapters are already constructed via harnesses/pending_stamp.rs::createPendingStampAdapter per the project convention; the per-harness file is essentially a parameter pack.

2. harnesses/mod.rs:179-208 WatcherController is pure boilerplate.

It's a newtype around sdk::WatchController with three pass-through methods plus an unused raw(). The doc comment admits "today this is just a newtype" and enumerates speculative future use cases that haven't landed. Use sdk::WatchController directly — saves ~30 LOC and a wrapper allocation per start_watcher call.

Proposed fix

  1. Add pub fn adapter_static(name: &'static str, session_root: &'static Path, ingest: fn(...) -> ...) -> impl HarnessAdapter to harnesses/pending_stamp.rs (or extend the existing factory).
  2. Replace harnesses/codex.rs and harnesses/opencode.rs with one call each, or collapse to a single pending_stamp_harnesses! macro / one struct literal each. Both files become roughly 5 lines.
  3. Replace WatcherController with sdk::WatchController at the call sites (harnesses/mod.rs:65, 75, ...). Drop harnesses/mod.rs:179-208.

Adjacent: harnesses/claude.rs:50, codex.rs:36, opencode.rs:39 triple-define the same let home = std::env::var_os("HOME").map(PathBuf::from).unwrap_or_else(|| PathBuf::from(".")). Hoist into util/.

Verification

cargo test -p relayburn-cli plus the harness-substrate unit tests under harnesses/. The runtime_adapter_names_match_runtime_adapters test is the existing parity check.

References

  • crates/relayburn-cli/src/harnesses/{codex,opencode,mod,pending_stamp}.rs
  • CLI review notes from the May 2026 Rust review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions