Skip to content

refactor(harness,transport,tui): share SDK manifest and wire framing, enforce TUI attached state - #1856

Merged
nikhilunni merged 3 commits into
mainfrom
audit/p2-harness-framing-dedup
Dec 2, 2026
Merged

nikhilunni merged 3 commits into
mainfrom
audit/p2-harness-framing-dedup

Conversation

@nikhilunni

@nikhilunni nikhilunni commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Deduplicates harness plumbing and wire framing, adds real transport test coverage, and removes TUI screen-state .expect() panics:

  • Shared harness SDK plumbing: Moves the ENGRAM_TOOLS manifest types, parse_tool_manifest, manifest_from_env, and with_browser_view into engram-harness-sdk/src/tool_manifest.rs, and removes duplicated emit and QueuedPrompt definitions in engram-harness-claude. Both harnesses use one serde decoder. A non-string native binding for the other provider now makes the manifest invalid; the orchestrator types every binding as an optional string, so it never sends one.
  • Unified length-prefixed framing: engram-transport/src/framing.rs owns the 4-byte big-endian length prefix (body length only), async and blocking. engram-agentd, engram-harness-proto, engram-egress-proto (async and blocking), and the host-agent async migrate codec use it. Each caller keeps its max frame size and error text. The length is checked before the body is allocated. Wire bytes, EOF behavior (UnexpectedEof mid-prefix and mid-body), and cancel behavior are unchanged.
  • Transport tests: Replaces the empty from_env_defaults_to_vsock_and_rejects_garbage test in engram-transport with real unit assertions, and adds framing tests for wire bytes, limits before body I/O, and truncated frames.
  • TUI invariant: Removes the duplicate Screen field. App::screen() derives the screen from attached, so render paths no longer rely on .expect("attached screen has a session").

Not changed: engram-migrate-proto (blocking, no tokio) and engram-substrate-proto (one write per frame) keep their own codecs, because a dependency on engram-transport would pull tokio into both.

Validation

  • cargo fmt --check, native cargo clippy --all-targets -- -D warnings on the touched crates, Linux cross-clippy on engram-harness-claude, engram-harness-codex, engram-transport, and engram-egress-proto, cargo hakari generate --diff.
  • cargo nextest run on engram-transport, engram-egress-proto, engram-harness-sdk, engram-harness-codex, engram-harness-proto, engram-agentd (279 passed, including the wire-golden and decode-never-panics suites), the host-agent migrate tests, and engram-tui (perf 3.09 ms p99).

🤖 Generated with Claude Code

nikhilunni and others added 3 commits December 1, 2026 16:38
…gh framing

The egress-proto blocking codec and the host-agent async migrate codec
kept their own copies of the 4-byte big-endian framing. Add blocking
read_sync/write_sync to engram_transport::framing and use them, so one
place owns the length check before allocation and the prefix encoding.
The bytes on the wire and the error kinds and messages do not change.

framing::read now states that it is not cancel safe. The prefix counts
the body only. The u32 check uses try_from.

Review pass: engram-migrate-proto (blocking, no tokio) and
engram-substrate-proto (one write per frame) keep their own codecs; a
dependency on engram-transport would pull tokio into both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shared module still held two decoders for ENGRAM_TOOLS: serde for
Claude and a hand-written parser for Codex, chosen by a ToolProvider
argument, with a generic ManifestTool<B> and a private ClaudeBindings
shim. Both decode the same orchestrator type, where every binding is
an optional string. Use one serde decoder for both harnesses and
remove ToolProvider, the generic parameter, and the shim.

A non-string binding for the other provider now makes the manifest
invalid. The orchestrator never sends one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nikhilunni
nikhilunni marked this pull request as ready for review December 2, 2026 21:54
@nikhilunni
nikhilunni merged commit fa6fe0d into main Dec 2, 2026
29 checks passed
@nikhilunni
nikhilunni deleted the audit/p2-harness-framing-dedup branch December 2, 2026 21:54
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.

1 participant