Skip to content

refactor(#2806): runtime cleanup — Ansi consolidation, suspending ses…#73

Merged
Skobeltsyn merged 1 commit into
mainfrom
refactor/2806-runtime-cleanup
May 30, 2026
Merged

refactor(#2806): runtime cleanup — Ansi consolidation, suspending ses…#73
Skobeltsyn merged 1 commit into
mainfrom
refactor/2806-runtime-cleanup

Conversation

@Skobeltsyn
Copy link
Copy Markdown
Contributor

…sion send, BuildInfo version source

Three independent code smells in the runtime + MCP layers, fixed in one behavior-preserving pass.

Ansi consolidation (LiveShow.kt)

  • New internal agents_engine.runtime.Ansi object owns ESC / RESET / ERASE_LINE constants.
  • AnsiColor.code values reference Ansi.ESC instead of embedding the raw escape byte; AnsiColor.wrap terminates with Ansi.RESET instead of an inline [0m.
  • Spinner clear in runWithSpinner uses Ansi.ERASE_LINE instead of raw [2K.
  • Deleted the dead AnsiColor.Companion.RESET const — never referenced, while wrap hardcoded its own copy.
  • Pinned by new AnsiTest.

Session emitter backpressure (#2806 acceptance criterion 2)

  • Bracket events (Completed / Failed) on Agent / Pipeline / Branch / Parallel session extensions switched from non-suspending trySend to suspending send. They run inside scope.launch { }; suspending is safe and guarantees terminal events are never dropped.
  • The inner per-token emitter stays on trySend (the typealias is a non-suspending lambda), but now logs a JUL warning with the event class name + agent id on failure — silent drops become visible.

MCP version single-source-of-truth

  • New internal agents_engine.internal.BuildInfo reads Implementation-Version from the JAR manifest, falling back to "dev" on non-sealed classpaths.
  • tasks.jar { manifest { attributes(...) } } in build.gradle.kts now stamps the manifest from project.version.
  • McpServer.SERVER_VERSION, McpClient.CLIENT_VERSION, McpRunner.VERSION all forward to BuildInfo.version. The three had drifted independently ("0.1.3" / "0.1.3" / "0.3.0").
  • McpServerInfoSnapshotTest updated to assert against BuildInfo.version instead of the stale "0.1.3" literal.

Optional acceptance items (per-flag handler extraction in resolveConfig, URI-based host parsing in McpServer.hostOnly) deferred — not blocking the bundle and out of scope for the targeted maintainability fix.

…sion send, BuildInfo version source

Three independent code smells in the runtime + MCP layers, fixed in one
behavior-preserving pass.

Ansi consolidation (LiveShow.kt)
- New internal `agents_engine.runtime.Ansi` object owns ESC / RESET /
  ERASE_LINE constants.
- `AnsiColor.code` values reference `Ansi.ESC` instead of embedding the
  raw escape byte; `AnsiColor.wrap` terminates with `Ansi.RESET` instead
  of an inline `[0m`.
- Spinner clear in `runWithSpinner` uses `Ansi.ERASE_LINE` instead of
  raw `[2K`.
- Deleted the dead `AnsiColor.Companion.RESET` const — never referenced,
  while `wrap` hardcoded its own copy.
- Pinned by new `AnsiTest`.

Session emitter backpressure (#2806 acceptance criterion 2)
- Bracket events (Completed / Failed) on Agent / Pipeline / Branch /
  Parallel session extensions switched from non-suspending `trySend` to
  suspending `send`. They run inside `scope.launch { }`; suspending is
  safe and guarantees terminal events are never dropped.
- The inner per-token emitter stays on `trySend` (the typealias is a
  non-suspending lambda), but now logs a JUL warning with the event
  class name + agent id on failure — silent drops become visible.

MCP version single-source-of-truth
- New internal `agents_engine.internal.BuildInfo` reads
  `Implementation-Version` from the JAR manifest, falling back to "dev"
  on non-sealed classpaths.
- `tasks.jar { manifest { attributes(...) } }` in build.gradle.kts now
  stamps the manifest from `project.version`.
- `McpServer.SERVER_VERSION`, `McpClient.CLIENT_VERSION`,
  `McpRunner.VERSION` all forward to `BuildInfo.version`. The three had
  drifted independently ("0.1.3" / "0.1.3" / "0.3.0").
- `McpServerInfoSnapshotTest` updated to assert against
  `BuildInfo.version` instead of the stale "0.1.3" literal.

Optional acceptance items (per-flag handler extraction in resolveConfig,
URI-based host parsing in McpServer.hostOnly) deferred — not blocking
the bundle and out of scope for the targeted maintainability fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Skobeltsyn Skobeltsyn merged commit f14a817 into main May 30, 2026
3 checks passed
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