Skip to content

gut: remove vestigial embedded Pi orchestrator stubs and call sites#2273

Merged
alexey-pelykh merged 1 commit intomainfrom
gut/remove-embedded-pi-stubs-2146
Apr 11, 2026
Merged

gut: remove vestigial embedded Pi orchestrator stubs and call sites#2273
alexey-pelykh merged 1 commit intomainfrom
gut/remove-embedded-pi-stubs-2146

Conversation

@alexey-pelykh
Copy link
Copy Markdown

Summary

  • Remove all embeddedPi-related stubs, call sites, config schema entries, and test mock names (gut: remove vestigial embedded Pi orchestrator stubs and call sites #2146)
  • The embedded Pi runner was gutted but its undefined/false/0-returning stubs remained, silently no-op-ing code paths that should either be removed or replaced
  • 21 files changed: 131 insertions, 238 deletions

Production (11 files)

  • agent-runner.ts: Remove queueEmbeddedPiMessage stub and dead steer block; remove unused shouldSteer/isStreaming params
  • get-reply-run.ts: Remove 4 stubs (abortEmbeddedPiRun, isEmbeddedPiRunActive, isEmbeddedPiRunStreaming, resolveEmbeddedSessionLane); inline session lane key; hardcode isActive=false
  • subagents-tool.ts: Remove abortEmbeddedPiRun stub and both call sites
  • commands-session.ts + commands-core.ts: Remove handleAbortTrigger/handleStopCommand no-op stubs and their import/registration
  • server-reload-handlers.ts + server.impl.ts: Remove getActiveEmbeddedRunCount stubs and call sites
  • queue/cleanup.ts: Inline resolveEmbeddedSessionLane as template literal

Config (4 files)

  • Remove embeddedPi type, Zod schema, help text, and labels

Tests (8 files)

  • Rename runEmbeddedPiAgentMockrunAgentMock
  • Rename isEmbeddedPiRunActive/isEmbeddedPiRunStreaming/queueEmbeddedPiMessage/waitForEmbeddedPiRunEnd mock properties
  • Remove shouldSteer/isStreaming from test call sites

Test plan

  • grep -ri "embeddedPi" src/ extensions/ returns zero matches
  • pnpm check passes (format + typecheck + lint)
  • pnpm test passes (693 test files, 5926 tests)

Closes #2146

🤖 Generated with Claude Code

@alexey-pelykh alexey-pelykh enabled auto-merge (squash) April 11, 2026 09:05
…2146)

Remove all embeddedPi-related stubs, call sites, config schema entries,
and rename test mocks. The embedded Pi runner was gutted but its
undefined-returning stubs remained, silently no-op-ing code paths.

Production changes:
- Remove queueEmbeddedPiMessage stub and dead steer block (agent-runner)
- Remove abortEmbeddedPiRun, isEmbeddedPiRunActive, isEmbeddedPiRunStreaming,
  resolveEmbeddedSessionLane stubs (get-reply-run, subagents-tool, cleanup)
- Remove getActiveEmbeddedRunCount stubs (server-reload-handlers, server.impl)
- Remove handleAbortTrigger/handleStopCommand no-op stubs (commands-session)
- Remove shouldSteer/isStreaming params from runReplyAgent (now dead)
- Remove embeddedPi config type, Zod schema, help text, and labels

Test changes:
- Rename runEmbeddedPiAgentMock → runAgentMock across all test files
- Rename embeddedPi mock properties in subagent-announce tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@alexey-pelykh alexey-pelykh force-pushed the gut/remove-embedded-pi-stubs-2146 branch from 43c0cef to 16b1c2c Compare April 11, 2026 09:08
@alexey-pelykh alexey-pelykh merged commit f749ed3 into main Apr 11, 2026
10 checks passed
@alexey-pelykh alexey-pelykh deleted the gut/remove-embedded-pi-stubs-2146 branch April 11, 2026 09:14
alexey-pelykh added a commit that referenced this pull request Apr 17, 2026
Production code no longer imports `pi-embedded.js` or
`pi-embedded-runner/runs.js` — they were removed by prior gut commits
(#2146/#2273, #2367, #2377). These 6 vi.mock calls registered mock
factories against paths nothing resolves; vitest never invoked them.

Deleted mocks:
- src/agents/subagent-announce.timeout.test.ts
- src/agents/subagent-announce.format.e2e.test.ts
- src/auto-reply/reply/abort.test.ts
- src/auto-reply/reply/get-reply-run.media-only.test.ts
- src/cli/gateway-cli/run-loop.test.ts
- src/cron/isolated-agent/run.test-harness.ts

Also removed dead state tied to each mock:
- run-loop.test.ts: local abortEmbeddedPiRun / getActiveEmbeddedRunCount /
  waitForActiveEmbeddedRuns vi.fn()s plus their setup calls and the
  comment at the SIGUSR1 restart assertion
- run.test-harness.ts: runEmbeddedPiAgentMock export and its
  makeDefaultEmbeddedResult/reset helpers

Pre-existing failures in four of the touched files
(subagent-announce.timeout.test.ts, abort.test.ts,
get-reply-run.media-only.test.ts, subagent-announce.format.e2e.test.ts)
are unrelated semantic drift (session routing, ACP cancel flow,
think-level extraction, message format) — pass/fail counts are
identical before and after this change.

Follow-up: ratchet the fork-openclaw skill's "≤6" invariant back to
"0 matches" in HQ once this lands.

Refs: remoteclaw/hq#35

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
alexey-pelykh added a commit that referenced this pull request Apr 17, 2026
Production code no longer imports `pi-embedded.js` or
`pi-embedded-runner/runs.js` — they were removed by prior gut commits
(#2146/#2273, #2367, #2377). These 6 vi.mock calls registered mock
factories against paths nothing resolves; vitest never invoked them.

Deleted mocks:
- src/agents/subagent-announce.timeout.test.ts
- src/agents/subagent-announce.format.e2e.test.ts
- src/auto-reply/reply/abort.test.ts
- src/auto-reply/reply/get-reply-run.media-only.test.ts
- src/cli/gateway-cli/run-loop.test.ts
- src/cron/isolated-agent/run.test-harness.ts

Also removed dead state tied to each mock:
- run-loop.test.ts: local abortEmbeddedPiRun / getActiveEmbeddedRunCount /
  waitForActiveEmbeddedRuns vi.fn()s plus their setup calls and the
  comment at the SIGUSR1 restart assertion
- run.test-harness.ts: runEmbeddedPiAgentMock export and its
  makeDefaultEmbeddedResult/reset helpers

Pre-existing failures in four of the touched files
(subagent-announce.timeout.test.ts, abort.test.ts,
get-reply-run.media-only.test.ts, subagent-announce.format.e2e.test.ts)
are unrelated semantic drift (session routing, ACP cancel flow,
think-level extraction, message format) — pass/fail counts are
identical before and after this change.

Follow-up: ratchet the fork-openclaw skill's "≤6" invariant back to
"0 matches" in HQ once this lands.

Refs: remoteclaw/hq#35

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
alexey-pelykh added a commit that referenced this pull request Apr 22, 2026
…d-turn termination (#2345)

`server-reload-handlers.ts::getActiveCounts()` and
`server.impl.ts::setPreRestartDeferralCheck()` both computed gateway
capacity / restart-deferral as `queueSize + pendingReplies`, silently
omitting active CLI agent subprocess runs. Result: a config reload or
SIGUSR1-triggered restart would fire while CLI agents were mid-turn,
killing live subprocess runs.

Fix: include `getActiveSessionRunCount()` from
`src/agents/session-run-registry.ts` in both sums. The registry is
already populated by `ChannelBridge` (register at `:160`, unregister
at `:349`) and was designed as the replacement for the
`getActiveEmbeddedRunCount()` stub that was gutted with the Pi-embedded
execution engine.

Changes:
- `src/gateway/server-reload-handlers.ts`: import
  `getActiveSessionRunCount`; add `activeCliRuns` field to
  `getActiveCounts()` return; fold into `totalActive` sum; extend
  `formatActiveDetails()` with an `activeCliRuns > 0` branch so the
  deferral log reports "N active CLI run(s)" alongside operations
  and replies. Field name `activeCliRuns` (not `activeRuns`) to
  disambiguate from the per-channel `activeRuns` concept used in
  `channels/run-state-machine.ts`, `gateway/channel-health-policy.ts`,
  and related modules.
- `src/gateway/server.impl.ts`: import `getActiveSessionRunCount`;
  add `+ getActiveSessionRunCount()` to the `setPreRestartDeferralCheck`
  callback arrow.

Note on stale issue body: #2345 prescribes editing a hardcoded
`embeddedRuns = 0` in `server-reload-handlers.ts:150-158` and
replacing a `getActiveEmbeddedRunCount()` import + call at
`server.impl.ts:302`. Neither exists in the current tree — both were
removed during the pi-embedded-runner gut (`f749ed3fb6`, #2146/#2273)
and the subsequent cherry-pick cleanup (`028566c42b`, #2442). The
semantic bug the issue names (capacity sums miscount active CLI runs
as zero) is still present as an *omission* rather than a hardcoded
literal, and this PR fixes it.

Verification:
- `pnpm check` (format + tsgo + lint + project-specific lints) → exit 0
- `pnpm vitest run --config vitest.unit.config.ts src/infra/restart
  src/infra/infra-runtime src/agents/session-run-registry
  src/gateway/server.impl` → 5 files, 71 tests, all passed
- Rescan: `git grep "getTotalQueueSize() + getTotalPendingReplies"`
  returns only the one site I updated; no other sum call sites in the
  codebase need the same fix
- Adversarial validation (fresh-context subclaude): CLEAN verdict on
  8 AC + 11 adversarial checks — confirms `getActiveSessionRunCount`
  is LIVE (not a stub), registry is actively populated by ChannelBridge,
  no import cycle possible (session-run-registry has zero imports),
  `formatActiveDetails` correctly handles multi-counter output

Closes #2345

Refs: #2089

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
alexey-pelykh added a commit that referenced this pull request Apr 22, 2026
…d-turn termination (#2345) (#2460)

`server-reload-handlers.ts::getActiveCounts()` and
`server.impl.ts::setPreRestartDeferralCheck()` both computed gateway
capacity / restart-deferral as `queueSize + pendingReplies`, silently
omitting active CLI agent subprocess runs. Result: a config reload or
SIGUSR1-triggered restart would fire while CLI agents were mid-turn,
killing live subprocess runs.

Fix: include `getActiveSessionRunCount()` from
`src/agents/session-run-registry.ts` in both sums. The registry is
already populated by `ChannelBridge` (register at `:160`, unregister
at `:349`) and was designed as the replacement for the
`getActiveEmbeddedRunCount()` stub that was gutted with the Pi-embedded
execution engine.

Changes:
- `src/gateway/server-reload-handlers.ts`: import
  `getActiveSessionRunCount`; add `activeCliRuns` field to
  `getActiveCounts()` return; fold into `totalActive` sum; extend
  `formatActiveDetails()` with an `activeCliRuns > 0` branch so the
  deferral log reports "N active CLI run(s)" alongside operations
  and replies. Field name `activeCliRuns` (not `activeRuns`) to
  disambiguate from the per-channel `activeRuns` concept used in
  `channels/run-state-machine.ts`, `gateway/channel-health-policy.ts`,
  and related modules.
- `src/gateway/server.impl.ts`: import `getActiveSessionRunCount`;
  add `+ getActiveSessionRunCount()` to the `setPreRestartDeferralCheck`
  callback arrow.

Note on stale issue body: #2345 prescribes editing a hardcoded
`embeddedRuns = 0` in `server-reload-handlers.ts:150-158` and
replacing a `getActiveEmbeddedRunCount()` import + call at
`server.impl.ts:302`. Neither exists in the current tree — both were
removed during the pi-embedded-runner gut (`f749ed3fb6`, #2146/#2273)
and the subsequent cherry-pick cleanup (`028566c42b`, #2442). The
semantic bug the issue names (capacity sums miscount active CLI runs
as zero) is still present as an *omission* rather than a hardcoded
literal, and this PR fixes it.

Verification:
- `pnpm check` (format + tsgo + lint + project-specific lints) → exit 0
- `pnpm vitest run --config vitest.unit.config.ts src/infra/restart
  src/infra/infra-runtime src/agents/session-run-registry
  src/gateway/server.impl` → 5 files, 71 tests, all passed
- Rescan: `git grep "getTotalQueueSize() + getTotalPendingReplies"`
  returns only the one site I updated; no other sum call sites in the
  codebase need the same fix
- Adversarial validation (fresh-context subclaude): CLEAN verdict on
  8 AC + 11 adversarial checks — confirms `getActiveSessionRunCount`
  is LIVE (not a stub), registry is actively populated by ChannelBridge,
  no import cycle possible (session-run-registry has zero imports),
  `formatActiveDetails` correctly handles multi-counter output

Closes #2345

Refs: #2089

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

gut: remove vestigial embedded Pi orchestrator stubs and call sites

1 participant