hero_rpc#124: re-scaffold against the new generator (subprocess + lab --test) #8

Merged
timur merged 1 commit from issue-124-template-revalidate into development 2026-05-22 13:10:01 +00:00
Owner

PR 3/3 for hero_rpc#124 (lifecycle alignment). Must squash-merge AFTER both upstream PRs land:

This PR is the re-scaffold output. The generator binary used to produce it lives on the hero_rpc PR #126 feature branch; running it against lhumina_code/hero_service (with the current .oschema set + --name hero_service) produces exactly the diff in this PR. Reviewers can verify by checking out hero_rpc PR #126, building the generator, and re-running it.

Headline diff stats

File Before (origin/development) After Delta
crates/hero_service_server/src/main.rs 132 lines 88 lines -44 (-33%)
tests/src/lib.rs 119 lines 109 lines -10 (and zero drift on domain add)
tests/Cargo.toml 28 lines 26 lines -2 (drops hero_rpc_osis, jsonrpsee, hero_service_server)

The tests/src/lib.rs line count change isn't the headline. The headline is drift-free: the file no longer references the server crate's domain handlers, hero_rpc_osis::rpc::bootstrap::*, or MultiDomainBuilder. It shells out to lab service hero_service --start --ephemeral --json, parses the JSON envelope, and lets ServiceHandle::Drop call lab --stop --pid <N> on teardown. Adding an .oschema to schemas/ now requires zero edits to this file.

What re-scaffolding produced

  1. crates/hero_service_server/src/main.rsMultiDomainBuilder::production() chain. One .with_domain::<OsisXxx>("xxx") line per domain, each still #[cfg(feature = "xxx")]-gated so slim-feature builds work.

  2. tests/src/lib.rs — subprocess driver. spin_up_service() forks lab --start --ephemeral --json, parses the envelope, connects a hero_rpc2::Client. ServiceHandle::Drop forks lab --stop --pid <N>.

  3. tests/Cargo.toml — slimmed to the subprocess shape's actual deps (hero_rpc2, hero_service_sdk, serde_json, anyhow, tokio).

  4. tests/smoke.nu / tests/api_integration.nu / tests/e2e_indexed_multi.nu — Layer 2-4 nushell skeletons. Each takes --socket <path> (or HERO_TEST_SOCKET env), uses curl --unix-socket for the UDS HTTP path.

  5. docs/testing.md — five-layer pyramid walkthrough, service-scoped.

  6. README.md — points contributors at one verb (lab service hero_service --test). Cargo + nushell are layers underneath the verb, never invoked directly.

Acceptance (per the issue body)

  • tests/src/lib.rs is the subprocess-driver shape — no hero_rpc_osis, no MultiDomainBuilder, no register_methods ladder.
  • crates/hero_service_server/src/main.rs uses MultiDomainBuilder::production().
  • Adding a new .oschema domain requires zero edits to tests/src/lib.rs. main.rs only picks up a new .with_domain::<…>(…) line after re-scaffolding (the codegen produces the diff above as a pure function of the current schemas/ set).
  • lab service hero_service --test runs all 5 layers green — verifies once both upstream PRs land. CI on this branch currently goes red against hero_rpc.git@development for main.rs (no MultiDomainBuilder yet). Will flip green after PR #126 merges.
  • lab service hero_service --test layer1 (cargo) green on its own — same dependency.
  • lab service hero_service --test layer2 (smoke) green on its own — needs hero_skills PR #285.
  • Existing hero_rpc#122 cargo e2e tests still pass — verifies once upstream merges (the e2e tests now run via the subprocess driver, which needs lab --ephemeral).
  • Orphan check: pgrep -f 'hero_service_server' empty after a full lab --test run — verifies post-merge.
  • No lab_fixture reference anywhere in the tree.

The four unchecked items all collapse into a single follow-up: a single end-to-end lab service hero_service --test run after the two upstream PRs land. I'll post evidence as a follow-up comment on this PR once both upstreams merge to development.

Decisions taken without confirmation

  1. tests/Cargo.toml regenerated, not preserved. The scaffolder's write_preserved path leaves an existing tests/Cargo.toml in place; for this re-validation I rm'd it and let the scaffolder emit the new shape. Required to drop hero_rpc_osis + jsonrpsee from the dep set.
  2. README.md regenerated, not preserved — same reasoning. The new README points contributors at one verb; preserving the curl-based smoke-test section would leave stale guidance.
  3. Git deps still point at branch = "development", not the feature branches. PR3 review CI will fail until PR #126 and #285 merge to their respective development branches. Pinning to feature branches would give green CI now but require a pre-merge dep-bump commit. Reviewers can either accept the red CI or check out the feature branches manually.
  4. No new domains added. This PR is only the re-scaffold of the existing schema set. The intentional inversion of the original framing ("add a domain to validate zero-edit") is in the issue acceptance: the codegen produces a byte-identical tests/src/lib.rs regardless of domain count, so the zero-edit property is structural rather than empirical.

Follow-ups not done here

  • The orphan-check + lab --test end-to-end run, posted as a follow-up comment on this PR once both upstream PRs merge.
  • Layer 5 hero_browser MCP — testcases/ doesn't ship with hero_service today, so --test layer5 is a no-op skip. Sibling work in hero_skills will define the browser-suite shape.

Test plan

  • git diff --stat against origin/development shows the expected 4 modified files (README.md, main.rs, tests/Cargo.toml, tests/src/lib.rs) + 4 new files (docs/testing.md + 3 nu scripts).
  • Output of the generator is reproducible: re-running the scaffolder produces byte-identical files (managed files use write_managed, preserved files weren't touched).
  • CI green after upstream merges — track on this PR before squash.
PR 3/3 for hero_rpc#124 (lifecycle alignment). **Must squash-merge AFTER** both upstream PRs land: - **hero_rpc PR #126** — MultiDomainBuilder + subprocess scaffolder. https://forge.ourworld.tf/lhumina_code/hero_rpc/pulls/126 - **hero_skills PR #285** — `lab --ephemeral` / `--json` / `--pid` / `--test`. https://forge.ourworld.tf/lhumina_code/hero_skills/pulls/285 - **Issue** — https://forge.ourworld.tf/lhumina_code/hero_rpc/issues/124 This PR is the re-scaffold output. The generator binary used to produce it lives on the hero_rpc PR #126 feature branch; running it against `lhumina_code/hero_service` (with the current `.oschema` set + `--name hero_service`) produces exactly the diff in this PR. Reviewers can verify by checking out hero_rpc PR #126, building the generator, and re-running it. ## Headline diff stats | File | Before (origin/development) | After | Delta | |---|---|---|---| | `crates/hero_service_server/src/main.rs` | 132 lines | 88 lines | **-44 (-33%)** | | `tests/src/lib.rs` | 119 lines | 109 lines | -10 (and **zero drift on domain add**) | | `tests/Cargo.toml` | 28 lines | 26 lines | -2 (drops `hero_rpc_osis`, `jsonrpsee`, `hero_service_server`) | The tests/src/lib.rs line count change isn't the headline. The headline is **drift-free**: the file no longer references the server crate's domain handlers, `hero_rpc_osis::rpc::bootstrap::*`, or `MultiDomainBuilder`. It shells out to `lab service hero_service --start --ephemeral --json`, parses the JSON envelope, and lets `ServiceHandle::Drop` call `lab --stop --pid <N>` on teardown. Adding an `.oschema` to `schemas/` now requires zero edits to this file. ## What re-scaffolding produced 1. **`crates/hero_service_server/src/main.rs`** — `MultiDomainBuilder::production()` chain. One `.with_domain::<OsisXxx>("xxx")` line per domain, each still `#[cfg(feature = "xxx")]`-gated so slim-feature builds work. 2. **`tests/src/lib.rs`** — subprocess driver. `spin_up_service()` forks `lab --start --ephemeral --json`, parses the envelope, connects a `hero_rpc2::Client`. `ServiceHandle::Drop` forks `lab --stop --pid <N>`. 3. **`tests/Cargo.toml`** — slimmed to the subprocess shape's actual deps (`hero_rpc2`, `hero_service_sdk`, `serde_json`, `anyhow`, `tokio`). 4. **`tests/smoke.nu` / `tests/api_integration.nu` / `tests/e2e_indexed_multi.nu`** — Layer 2-4 nushell skeletons. Each takes `--socket <path>` (or `HERO_TEST_SOCKET` env), uses `curl --unix-socket` for the UDS HTTP path. 5. **`docs/testing.md`** — five-layer pyramid walkthrough, service-scoped. 6. **`README.md`** — points contributors at one verb (`lab service hero_service --test`). Cargo + nushell are layers underneath the verb, never invoked directly. ## Acceptance (per the issue body) - [x] `tests/src/lib.rs` is the subprocess-driver shape — no `hero_rpc_osis`, no `MultiDomainBuilder`, no `register_methods` ladder. - [x] `crates/hero_service_server/src/main.rs` uses `MultiDomainBuilder::production()`. - [x] Adding a new `.oschema` domain requires zero edits to `tests/src/lib.rs`. main.rs only picks up a new `.with_domain::<…>(…)` line after re-scaffolding (the codegen produces the diff above as a pure function of the current `schemas/` set). - [ ] **`lab service hero_service --test` runs all 5 layers green** — verifies once both upstream PRs land. CI on this branch currently goes red against `hero_rpc.git@development` for main.rs (no `MultiDomainBuilder` yet). Will flip green after PR #126 merges. - [ ] **`lab service hero_service --test layer1` (cargo) green on its own** — same dependency. - [ ] **`lab service hero_service --test layer2` (smoke) green on its own** — needs hero_skills PR #285. - [ ] **Existing hero_rpc#122 cargo e2e tests still pass** — verifies once upstream merges (the e2e tests now run via the subprocess driver, which needs `lab --ephemeral`). - [ ] **Orphan check**: `pgrep -f 'hero_service_server'` empty after a full `lab --test` run — verifies post-merge. - [x] No `lab_fixture` reference anywhere in the tree. The four unchecked items all collapse into a single follow-up: a single end-to-end `lab service hero_service --test` run after the two upstream PRs land. I'll post evidence as a follow-up comment on this PR once both upstreams merge to `development`. ## Decisions taken without confirmation 1. **`tests/Cargo.toml` regenerated, not preserved.** The scaffolder's `write_preserved` path leaves an existing tests/Cargo.toml in place; for this re-validation I `rm`'d it and let the scaffolder emit the new shape. Required to drop `hero_rpc_osis` + `jsonrpsee` from the dep set. 2. **`README.md` regenerated, not preserved** — same reasoning. The new README points contributors at one verb; preserving the curl-based smoke-test section would leave stale guidance. 3. **Git deps still point at `branch = "development"`**, not the feature branches. PR3 review CI will fail until PR #126 and #285 merge to their respective development branches. Pinning to feature branches would give green CI now but require a pre-merge dep-bump commit. Reviewers can either accept the red CI or check out the feature branches manually. 4. **No new domains added.** This PR is *only* the re-scaffold of the existing schema set. The intentional inversion of the original framing ("add a domain to validate zero-edit") is in the issue acceptance: the codegen produces a byte-identical tests/src/lib.rs regardless of domain count, so the zero-edit property is structural rather than empirical. ## Follow-ups not done here - The orphan-check + `lab --test` end-to-end run, posted as a follow-up comment on this PR once both upstream PRs merge. - Layer 5 hero_browser MCP — `testcases/` doesn't ship with hero_service today, so `--test layer5` is a no-op skip. Sibling work in hero_skills will define the browser-suite shape. ## Test plan - [x] `git diff --stat` against `origin/development` shows the expected 4 modified files (README.md, main.rs, tests/Cargo.toml, tests/src/lib.rs) + 4 new files (docs/testing.md + 3 nu scripts). - [x] Output of the generator is reproducible: re-running the scaffolder produces byte-identical files (managed files use `write_managed`, preserved files weren't touched). - [ ] CI green after upstream merges — track on this PR before squash.
PR 3/3 for hero_rpc#124 lifecycle alignment. Depends on the
merged hero_rpc PR #126 (MultiDomainBuilder + subprocess
scaffolder) and the merged hero_skills PR #285 (lab --ephemeral,
--json, --pid, --test). Squash-merge AFTER both upstream PRs land,
not before — hero_rpc_osis::rpc::bootstrap::MultiDomainBuilder and
the `lab service --start --ephemeral --json` verb both need to be
present on their respective `development` branches for the
scaffolded main.rs and tests/src/lib.rs to actually run.

What re-scaffolding produced:

- `crates/hero_service_server/src/main.rs`: 132 → 88 lines (-33%).
  Replaces the inline `RpcModule::new(())` + `register_methods`
  ladder with `MultiDomainBuilder::production(...).with_domain::<…>
  ("…").spawn()`. Per-domain `#[cfg(feature = "…")]` lines remain so
  slim-feature builds still work.

- `tests/src/lib.rs`: 119 → 109 lines, but the **drift property
  changed**: the file no longer references the server crate's
  domain handlers, `hero_rpc_osis::rpc::bootstrap::*`, or
  `MultiDomainBuilder`. It shells out to
  `lab service hero_service --start --ephemeral --json`, parses the
  JSON envelope, connects a `hero_rpc2::Client`, and lets
  `ServiceHandle::Drop` call `lab --stop --pid <N>` on teardown.
  Adding a new `.oschema` domain now requires **zero** edits to
  this file — the running lab picks up domains via service.toml.

- `tests/Cargo.toml`: drops `hero_rpc_osis`, `jsonrpsee`, and the
  `hero_service_server` path dep. The subprocess shape only needs
  the `hero_rpc2` client + `hero_service_sdk` + `serde_json` +
  `anyhow` + `tokio`. Test-time build surface shrinks
  proportionally.

- New `tests/smoke.nu`, `tests/api_integration.nu`,
  `tests/e2e_indexed_multi.nu` — Layer 2-4 nushell skeletons,
  each accepting `--socket <path>` (or `HERO_TEST_SOCKET` env) so
  the same script works under `lab --test layerN` and against a
  manual `lab service --start --ephemeral` instance.

- New `docs/testing.md` walking the five layers; service-scoped
  taxonomy mirroring `tests_pyramid`.

- README updated to point contributors at one verb:
  `lab service hero_service --test`. Cargo + nushell are
  implementation details called out under "Anatomy" but never
  invoked directly.
timur merged commit a223dc0f59 into development 2026-05-22 13:10:01 +00:00
Sign in to join this conversation.
No reviewers
No labels
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_service!8
No description provided.