fix(ai): sever herolib_ai → hero_aibroker_sdk Stream* cascade (#102 T1 #1) #140

Merged
mik-tf merged 3 commits from development_mik into development 2026-05-16 00:55:18 +00:00
Owner

Summary

s96 hero_lib reconciliation — T1 #1 of the hero_proc#102 workspace service.toml + dep sweep (deps-first re-sequencing).

Three stacked commits:

  1. 481bb322 (s96 starter, local-only since s95) — patches herolib_tools::agent for the new hero_proc_sdk @ 8028f71f+ API shape (5 breaking changes — JobLogsInput.attempt, JobLogsOutput.value shape, LogLine.{line,src,stream,timestamp_ms} non-Option-ization, JobCreateOutput.id non-Option-ization).
  2. f1c5b9b6 — severs the herolib_ai → hero_aibroker_sdk Stream* cascade by clean-deleting the dead streaming surface (5 Stream* re-exports, chat_stream method, streaming field, with_streaming_socket/supports_streaming helpers, StreamError From impl, AiError::Stream variant). Zero external callers verified across all 50+ workspace repos.
  3. 40a2e2b3 — conservative dep audit per playbook §4: strips async-trait/futures/tracing from crates/ai and herolib_core/toml from crates/tools (zero matches under src/, bins/, tests/, examples/).

Net: −64 LOC across 5 files, 1042/1042 workspace lib tests pass, cargo build --workspace --release clean, cargo update cleanly unblocked.

Why this matters beyond hero_lib

Until this PR, cargo update cascade-failed in every downstream consumer of herolib_ai (transitively, almost every repo in the D-07 35-set) because hero_aibroker_sdk @ 00197f6 removed the flat Stream* type family. hero_code PR #15 explicitly documented its D-10 acceptance criterion 3 as deferred for this reason; merging this PR retroactively validates hero_code#15's criterion 3 and unblocks T1 #2-#6 (hero_proc, hero_db, hero_aibroker, hero_router) + every T2/T3 repo in the sweep.

D-10 acceptance state for hero_lib

# Criterion State Notes
1 service.toml canonical per crate deferred → hero_lib#139 hero_lib declares BINARIES="" (library-only) per its own CLAUDE.md, but lab infocheck discovers 4 crates with test/demo binaries (modeltest, ai_direct/{image_gen_test,nemotron_super,ttstest,modeltest_direct}, clients/{opencode_tester,opencode_demo}, web/herolib_web) flagging 21 D-10 issues. Resolution path (delete vs upgrade to canonical infra) deferred to #139 per scope.
2 cargo build --workspace --release clean 2m 16s, 17 crates + git deps
3 cargo update clean THE LOAD-BEARING UNBLOCK hero_proc_sdk advanced 66abdf1f → 8028f71f; no cascade failures. Retro-validates hero_code#15 criterion 3.
4 lab service … --start smoke gate deferred → hero_lib#139 Same reason as #1 — no service binaries to smoke.
5 Conservative dep audit 5 unused deps stripped (3 in crates/ai + 2 in crates/tools).

Out of scope (declared)

  • Workspace fmt drift (~25+ files in crates/ai/agent/, crates/ai/examples/, crates/ai_direct/examples/, etc.) — pre-existing, not introduced by this PR. My 3 edited files emit zero rustfmt --check drift.
  • Workspace clippy -D warnings (8 hits in agent/builder.rs, agent/runner.rs, agent/template.rs, model.rs) — pre-existing, my 3 edited files emit zero clippy findings.
  • Broken examples in crates/ai/examples/ (AiClient::from_env, AiClient::direct) and crates/ai_direct/examples/ (AiClient::get) — pre-existing references to methods that no longer exist; surfaces with cargo test --workspace but not cargo build --workspace --release because examples aren't built by default.
  • Aggressive dep audit — playbook §4 explicit: zero-match strip only, defer broader audit.
  • T1 #2 (hero_proc) — next session.

Intra-T1 sequencing addendum candidate

D-10 intra-T1 ordering was originally hero_proc → hero_router → hero_db → hero_lib → hero_code. s95 (hero_code first under that order) hit deps-first reality: criterion 3 cannot pass until hero_lib's herolib_ai cascade reconciles. Proposing in-place D-10 addendum (not a new D-11) flipping intra-T1 to hero_lib → hero_proc → hero_db → hero_aibroker → hero_router → hero_code-retroactive. Decide at squash gate.

Test plan

  • cargo build --workspace --release — clean, 2m 16s
  • cargo updatehero_proc_sdk @ 66abdf1f → 8028f71f, no failures
  • cargo build --workspace --release post-update — clean
  • cargo test --workspace --lib --release --no-fail-fast — 16 crates, 1042 pass / 6 ignored / 0 fail
  • cargo test -p herolib_ai --lib --release — 45 pass / 0 fail
  • rustfmt --check on the 3 edited source files — clean
  • cargo clippy -p herolib_ai --release --all-targets -- -D warnings on edited source — zero new findings (8 hits pre-existing in unedited files)
  • Workspace-wide grep for chat_stream(, StreamingClient, ChatChunkStream, StreamError — zero external callers
  • hero_aibroker upstream verified at 00197f6 (chat module surface unchanged since refactor)

🤖 Generated with Claude Code

## Summary **s96 hero_lib reconciliation — T1 #1 of the [hero_proc#102](https://forge.ourworld.tf/lhumina_code/hero_proc/issues/102) workspace `service.toml` + dep sweep (deps-first re-sequencing).** Three stacked commits: 1. **`481bb322`** *(s96 starter, local-only since s95)* — patches `herolib_tools::agent` for the new `hero_proc_sdk @ 8028f71f+` API shape (5 breaking changes — `JobLogsInput.attempt`, `JobLogsOutput.value` shape, `LogLine.{line,src,stream,timestamp_ms}` non-`Option`-ization, `JobCreateOutput.id` non-`Option`-ization). 2. **`f1c5b9b6`** — severs the `herolib_ai → hero_aibroker_sdk` Stream* cascade by clean-deleting the dead streaming surface (5 Stream* re-exports, `chat_stream` method, `streaming` field, `with_streaming_socket`/`supports_streaming` helpers, `StreamError` `From` impl, `AiError::Stream` variant). Zero external callers verified across all 50+ workspace repos. 3. **`40a2e2b3`** — conservative dep audit per playbook §4: strips `async-trait`/`futures`/`tracing` from `crates/ai` and `herolib_core`/`toml` from `crates/tools` (zero matches under src/, bins/, tests/, examples/). **Net**: −64 LOC across 5 files, 1042/1042 workspace lib tests pass, `cargo build --workspace --release` clean, `cargo update` cleanly unblocked. ## Why this matters beyond `hero_lib` Until this PR, `cargo update` cascade-failed in **every** downstream consumer of `herolib_ai` (transitively, almost every repo in the D-07 35-set) because `hero_aibroker_sdk @ 00197f6` removed the flat Stream* type family. [hero_code PR #15](https://forge.ourworld.tf/lhumina_code/hero_code/pulls/15) explicitly documented its D-10 acceptance criterion 3 as deferred for this reason; merging this PR **retroactively validates hero_code#15's criterion 3** and unblocks T1 #2-#6 (`hero_proc`, `hero_db`, `hero_aibroker`, `hero_router`) + every T2/T3 repo in the sweep. ## D-10 acceptance state for `hero_lib` | # | Criterion | State | Notes | |---|---|---|---| | 1 | `service.toml` canonical per crate | **deferred → [hero_lib#139](https://forge.ourworld.tf/lhumina_code/hero_lib/issues/139)** | hero_lib declares `BINARIES=""` (library-only) per its own `CLAUDE.md`, but `lab infocheck` discovers 4 crates with test/demo binaries (`modeltest`, `ai_direct/{image_gen_test,nemotron_super,ttstest,modeltest_direct}`, `clients/{opencode_tester,opencode_demo}`, `web/herolib_web`) flagging 21 D-10 issues. Resolution path (delete vs upgrade to canonical infra) deferred to #139 per scope. | | 2 | `cargo build --workspace --release` clean | ✅ | 2m 16s, 17 crates + git deps | | 3 | `cargo update` clean | ✅ — **THE LOAD-BEARING UNBLOCK** | hero_proc_sdk advanced `66abdf1f → 8028f71f`; no cascade failures. Retro-validates [hero_code#15](https://forge.ourworld.tf/lhumina_code/hero_code/pulls/15) criterion 3. | | 4 | `lab service … --start` smoke gate | **deferred → [hero_lib#139](https://forge.ourworld.tf/lhumina_code/hero_lib/issues/139)** | Same reason as #1 — no service binaries to smoke. | | 5 | Conservative dep audit | ✅ | 5 unused deps stripped (3 in `crates/ai` + 2 in `crates/tools`). | ## Out of scope (declared) - **Workspace fmt drift** (~25+ files in `crates/ai/agent/`, `crates/ai/examples/`, `crates/ai_direct/examples/`, etc.) — pre-existing, not introduced by this PR. My 3 edited files emit zero `rustfmt --check` drift. - **Workspace clippy `-D warnings`** (8 hits in `agent/builder.rs`, `agent/runner.rs`, `agent/template.rs`, `model.rs`) — pre-existing, my 3 edited files emit zero clippy findings. - **Broken examples in `crates/ai/examples/`** (`AiClient::from_env`, `AiClient::direct`) and `crates/ai_direct/examples/` (`AiClient::get`) — pre-existing references to methods that no longer exist; surfaces with `cargo test --workspace` but not `cargo build --workspace --release` because examples aren't built by default. - **Aggressive dep audit** — playbook §4 explicit: zero-match strip only, defer broader audit. - **T1 #2 (`hero_proc`)** — next session. ## Intra-T1 sequencing addendum candidate [D-10](https://forge.ourworld.tf/lhumina_code/hero_proc/issues/102#issuecomment-33220) intra-T1 ordering was originally `hero_proc → hero_router → hero_db → hero_lib → hero_code`. s95 (hero_code first under that order) hit deps-first reality: criterion 3 cannot pass until `hero_lib`'s `herolib_ai` cascade reconciles. **Proposing in-place D-10 addendum** (not a new D-11) flipping intra-T1 to **`hero_lib → hero_proc → hero_db → hero_aibroker → hero_router → hero_code-retroactive`**. Decide at squash gate. ## Test plan - [x] `cargo build --workspace --release` — clean, 2m 16s - [x] `cargo update` — `hero_proc_sdk @ 66abdf1f → 8028f71f`, no failures - [x] `cargo build --workspace --release` post-update — clean - [x] `cargo test --workspace --lib --release --no-fail-fast` — 16 crates, 1042 pass / 6 ignored / 0 fail - [x] `cargo test -p herolib_ai --lib --release` — 45 pass / 0 fail - [x] `rustfmt --check` on the 3 edited source files — clean - [x] `cargo clippy -p herolib_ai --release --all-targets -- -D warnings` on edited source — zero new findings (8 hits pre-existing in unedited files) - [x] Workspace-wide grep for `chat_stream(`, `StreamingClient`, `ChatChunkStream`, `StreamError` — zero external callers - [x] hero_aibroker upstream verified at `00197f6` (chat module surface unchanged since refactor) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
WIP starter commit for s96 hero_lib full sweep (T1 #1 deps-first per the
re-sequencing decision filed during s95 — see prompt.md §3 + #102 update).

Patches `herolib_tools::agent` for the breaking changes in
`hero_proc_sdk @ 9390937a+` (originally observed during s95 hero_code
cargo update which cascaded to this crate):

  - `JobLogsInput` now requires `attempt: Option<i64>` (was absent)
  - `JobLogsOutput.value` is `Option<Vec<LogLine>>` (was direct `Vec<LogLine>`)
  - `LogLine.{line, src, stream}` are `String` (were `Option<String>`)
  - `LogLine.timestamp_ms` is `i64` (was `Option<i64>`)
  - `JobCreateOutput.id` is `i64` (was `Option<i64>`)

NOT YET FIXED in this commit (s96 work):
  - `herolib_ai` references types removed from `hero_aibroker_sdk` in
    its chat-module restructure: `ChatChunkStream`, `ChatStreamChunk`,
    `StreamChoice`, `StreamDelta`, `StreamUsage`, `StreamingClient`,
    `StreamError`. Either re-implement `chat_stream` against the new
    `hero_aibroker_sdk::chat` surface, or remove the streaming API.

This commit is LOCAL on `development_mik` and NOT YET PUSHED — s96
picks it up as the first commit of the full hero_lib sweep PR.

Refs: lhumina_code/hero_proc#102
Signed-off-by: mik-tf <logismos@protonmail.ch>
The hero_aibroker_sdk refactor on its `development` (HEAD 00197f6,
"refactor: unify startup banner and socket dir resolution") removed
the flat streaming type family in favor of a per-domain `chat` module:

  - ChatChunkStream, ChatStreamChunk, StreamChoice, StreamDelta,
    StreamUsage — gone (structural removal)
  - StreamingClient — gone (replaced by `chat::Client::ai_chat`)
  - StreamError — gone (folded into OpenRpcError)

The new streaming contract is a `stream: true` flag on ChatRequest
plus an SSE GET /events subscription on the broker's REST socket —
not a typed Rust stream return.

Workspace-wide grep confirms ZERO external callers of
`AiClient::chat_stream(...)`, `StreamingClient`, `ChatChunkStream`,
or any of the removed types. Across all 50+ workspace repos, the only
internal call site was the method body itself. Clean-delete is
correct, not re-implement against the new SSE surface.

This commit:

  - drops the 5 Stream* re-exports from `crates/ai/src/lib.rs`
  - narrows the `hero_aibroker_sdk` use line in `client.rs` to
    `AIBrokerRawClient` only
  - removes `AiClient::chat_stream`, `AiClient::with_streaming_socket`,
    `AiClient::supports_streaming`, and the `streaming` field on the
    `AiClient` struct
  - simplifies `AiClient::default_socket` (no longer auto-attaches a
    REST socket — was the only `with_streaming_socket` caller)
  - removes `impl From<hero_aibroker_sdk::StreamError> for AiError`
  - removes the now-dead `AiError::Stream(String)` variant and the
    docstring reference to it
  - audits + strips 3 unused workspace deps from `crates/ai/Cargo.toml`
    (`async-trait`, `futures`, `tracing` — zero hits under src/, bins/,
    tests/, examples/)
  - updates the package `description` to drop the "streaming" mention

Net: -64 LOC across 4 files, no test regressions (45/45 herolib_ai
lib tests pass; workspace lib tests 16 crates / 1042 passing / 0
failing under `cargo test --workspace --lib --release`).

This is the load-bearing change that unblocks `cargo update` across
the entire 35-repo D-07 demo set. Prior to this commit, every
downstream consumer of `herolib_ai` (i.e. anyone transitively pulling
`hero_aibroker_sdk`) had its `cargo update` fail with E0599 on the
removed Stream* type imports. s95 hero_code PR #15 documented this
explicitly as criterion-3-deferred; this commit retroactively
validates that criterion.

Refs:
  - lhumina_code/hero_proc#102
  - lhumina_code/hero_proc#102 (comment)
  - lhumina_code/hero_code#15

Signed-off-by: mik-tf
Signed-off-by: mik-tf <logismos@protonmail.ch>
chore(tools): strip unused deps surfaced by conservative dep audit
All checks were successful
Lint / lint-linux (pull_request) Successful in 48s
Tests with Services / test-linux (pull_request) Successful in 10m55s
40a2e2b374
`crates/tools` declares `herolib_core` and `toml` in `[dependencies]`
but neither is referenced anywhere under `src/`, `examples/`, `tests/`,
or any other reachable target. Both pure waste; strip per the D-10
playbook §4 conservative dep audit (zero matches → strip).

Build remains clean post-strip.

Refs: lhumina_code/hero_proc#102

Signed-off-by: mik-tf
Signed-off-by: mik-tf <logismos@protonmail.ch>
mik-tf merged commit 9b5912bf38 into development 2026-05-16 00:55:18 +00:00
mik-tf deleted branch development_mik 2026-05-16 00:55:18 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_lib!140
No description provided.