fix(kernel): carry agent transport in specs - #412
Conversation
Session-Id: 01a09c40-ce3b-7f11-a7df-b6b7ccab6fd9
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review swarm: maintainabilityMaintainability Review: PR #412Title: fix(kernel): carry agent transport in specs SummaryThis PR adds an Maintainability Assessment Through Six-Month Stranger LensWhat Changed and Why It ExistsThe PR adds:
Clear Boundaries — ✓ PASSThe kernel-worker boundary is explicit and correct. Lines 427-430 of the diff state: /// How the attached worker invokes the declared CLI. The kernel does
/// not implement either transport; it journals and dispatches the
/// choice so the worker can honor it deterministically.
This matches the observed implementation:
The comment makes the non-responsibility explicit. A stranger can read this and know the kernel is not responsible for transport semantics. Implicit Contracts — FINDINGSFinding 1: Default behavior is documented but not enforced structurallyThe field is Impact on maintainability: A stranger reading only kernel code sees spec.transport === 'relay' ? 'relay' : 'direct'This is a soft contract — the default exists only in worker implementation, not kernel type system. It works but forces the reader to trace execution to discover the rule. Could this break silently? No. The test validates both declared values round-trip. If a worker fails to handle Verdict: Documented adequately in SDK layer (spec.ts). The kernel's Finding 2: Transport semantics are documented outside the kernelThe enum variants
Impact on maintainability: The kernel enum is a pure data carrier. The comment "kernel does not implement either transport" establishes this. A maintainer changing the kernel layer knows to look at worker implementation for semantics. Could this be clearer? Yes — a doc comment on each enum variant pointing to the authoritative semantics doc would eliminate a search step. Example: /// `'direct'` (default): spawn CLI as local subprocess.
/// See `docs/AGENT-RELAY-TRANSPORT.md` for relay semantics.
Is the absence a blocker? No. The kernel layer's role is clear, and the external docs exist. A stranger can find the answer in one hop (search codebase for "transport" or "relay"). Verdict: Acceptable. Would be improved by brief variant docs, but current state is maintainable. Missing Failure Handling — FINDINGSFinding 3: Journal contract is implicit but observableThe previous review claimed "no evidence journal schema accommodates this field." Investigation shows:
What happens if transport changes between attempts? The spec cannot change between attempts — it is journaled once at run creation. A stranger reading Could this break silently? No. The test validates unknown values fail closed (line 68-79). A typo or future transport variant not in the enum causes parse failure at spec submission, not mid-run. Verdict: Journal contract is satisfied implicitly by the existing spec persistence design. Not a gap. Finding 4: Worker enforcement is soft but fail-fastThe previous review noted "no mechanism ensuring the worker respects the transport." Investigation shows:
Could this fail silently? No. Relay transport requires specific environment setup (
The worker cannot "silently use wrong transport and corrupt data" because transport affects process creation, not data persistence. Verdict: Soft contract, but failure is loud and early. Acceptable for a pass-through field. Tests Assert Actual Behavior — FINDINGSFinding 5: Test coverage matches the kernel's responsibilityThe test
What the test does NOT validate: That dispatch hands the field to the worker, that journal preserves it across restart, that worker honors it. Is this a gap? No. The kernel's contract is "parse and carry." The test validates that. Higher-level integration (dispatch → worker) is tested in SDK layer:
The kernel test matches the kernel's scope. A stranger can see "this layer parses and validates; effects are elsewhere." Verdict: Test coverage is correct for the layer boundary. Pass. Finding 6: Missing test would be: mutation verification that breaking serialization failsThe test validates round-trip. It does not validate that removing the field from STEP_AGENT_FIELDS would cause failure. Why this matters: Is there a test that would catch this? Yes, indirectly: the round-trip test parses a spec with Mutation verification: Reverting the Verdict: Adequate. The test would catch the most likely maintenance error (forgetting to whitelist the field). Unclear Contracts and Comments — FINDINGSFinding 7: The comment describes what the code does, not what it does NOT doLines 427-430: /// How the attached worker invokes the declared CLI. The kernel does
/// not implement either transport; it journals and dispatches the
/// choice so the worker can honor it deterministically.
Assertion: "journals and dispatches the choice" The comment claims the kernel "journals" the choice. The code skips serialization when Observed behavior: When Is the comment wrong? Borderline. "Journals the choice" is true for explicit Could this mislead? A stranger might read "journals the choice" and expect Severity: Low. The confusion is about serialization format, not behavior. The worker's handling is deterministic either way. Verdict: Comment is slightly loose but not misleading about responsibility boundary. Acceptable. Structural Quality — ✓ PASS
All structural standards met. Summary of Findings
Six-Month Stranger TestCan a stranger read this and change it safely? Yes, with one caveat:
The caveat: A stranger must look outside
A maintainer adding a third transport variant would:
This is a straightforward change with clear breadcrumbs. Comparison to Previous ReviewThe previous review (20260915-0940) failed on four findings:
All four findings were based on inspecting kernel code in isolation. Examining the full data flow (spec → journal → dispatch → worker) shows the contracts are satisfied, just not all in one file. VerdictREVIEW_PASSED This change is maintainable. A stranger can read the kernel layer and understand its role, follow clear boundaries to worker implementation, and safely add new transport variants. The lack of inline enum docs is a missed opportunity for clarity, not a defect. All contracts are either explicit (fail-closed validation), implicit but observable (journal carries spec), or documented externally (transport semantics in The change fits the RFC-0001 covenant: kernel is small and pure, boundaries are protocol-enforced (spec → dispatch), and the journal is the source of truth (spec journaled once, never replayed). REVIEW_PASSED |
Review swarm: historyNo fresh transcript was produced for run |
Review swarm: structureNo fresh transcript was produced for run |
Review swarm: FAILED
Cloud run: |
Authored
f.agent(..., { transport: "direct" | "relay" })compiles the transport into the kernel spec, but the Rust parser currently rejects that field as unknown before dispatch. This carries the validated transport through the kernel journal and worker dispatch, while continuing to reject unknown transport values.Validation:
cargo test -p relayflowd-core(79 tests passed)cargo check --workspacegit diff --checkThis closes the SDK/kernel gap introduced with the authored Relay transport surface. It does not change the omitted-field behavior; the worker continues to default an omitted transport to direct.
Note
Low Risk
Spec schema and fail-closed validation only; no runtime transport or dispatch logic changes in this diff.
Overview
Agent steps in run specs can now include an optional
transportfield (directorrelay) without the kernel treating it as an unknown step field. The parser addsAgentTransporton agent step kinds and whiteliststransportin agent step field validation so SDK-compiled specs that already set transport parse, validate, serialize, and journal like other carried agent metadata—the kernel still does not implement either transport.A parity test asserts
directandrelayround-trip throughRunSpec::parse/validateand that invalid values (e.g.telepathy) fail closed at parse time. Omittedtransportbehavior is unchanged; workers keep defaulting when absent.Reviewed by Cursor Bugbot for commit 0dcbe7f. Bugbot is set up for automated code reviews on this repo. Configure here.