Skip to content

fix(pb): clean up actor stop decision handling#4566

Merged
MasterPtato merged 1 commit intomainfrom
04-06-fix_pb_clean_up_actor_stop_decision_handling
Apr 8, 2026
Merged

fix(pb): clean up actor stop decision handling#4566
MasterPtato merged 1 commit intomainfrom
04-06-fix_pb_clean_up_actor_stop_decision_handling

Conversation

@MasterPtato
Copy link
Copy Markdown
Contributor

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@MasterPtato MasterPtato requested a review from NathanFlurry April 6, 2026 19:54
@claude
Copy link
Copy Markdown

claude bot commented Apr 6, 2026

PR Review: fix(pb): clean up actor stop decision handling

Good refactor overall — the Decision enum makes the control flow much cleaner and easier to reason about. A few issues to flag:


Bug: SleepIntent { rewake_after_stop: false } maps to Decision::Reallocate

engine/packages/pegboard/src/workflows/actor2/runtime.rs

(
    Transition::SleepIntent {
        rewake_after_stop: true,
        ..
    },
    _,
    _,
) => Decision::Reallocate,
(
    Transition::SleepIntent {
        rewake_after_stop: false,
        ..
    },
    _,
    _,
) => Decision::Reallocate,   // <- should this be Decision::Sleep?

In the old code, SleepIntent { rewake_after_stop } decoded to (try_reallocate = rewake_after_stop, going_away = false). When rewake_after_stop: false, the actor fell through to the else branch which set Transition::Sleeping and returned Continue without calling AllocateInput. The new code sends both arms to Decision::Reallocate, which always calls AllocateInput — this looks like a behavior regression. The two arms could also just be merged into one SleepIntent { .. } arm if they're intentionally identical.


Behavior change: SetSleepingInput now called on Transition::Reallocating

Old code:

if let Transition::Sleeping = state.transition {
    ctx.activity(SetSleepingInput {}).await?;
}

New code:

match state.transition {
    Transition::Sleeping | Transition::Reallocating { .. } => {
        ctx.activity(SetSleepingInput {}).await?;
    }
    _ => {}
}

SetSleepingInput is now invoked whenever the actor transitions to Reallocating, which was not the case before. Is this intentional? If so, a comment explaining why Reallocating also needs this activity would help.


Missing Decision::Sleep match arm closing brace

The Decision::Sleep arm in the match decision block has a misaligned closing structure — StoppedResult::Continue appears outside the arm body in the diff:

Decision::Sleep => {
    if let Some(alarm_ts) = state.alarm_ts {
        let now = ctx.activity(GetTsInput {}).await?;
        if now >= alarm_ts {
            state.alarm_ts = None;
        }
    }

// Transition to sleeping
state.transition = Transition::Sleeping;

StoppedResult::Continue    // <- indentation suggests this may be outside the arm

May be a diff display artifact, but worth double-checking the compiled output is correct.


test-envoy: envoy no longer shut down on SSE abort

engine/sdks/typescript/test-envoy/src/index.ts

Old code called envoy.shutdown(true) when the SSE connection was aborted:

c.req.raw.signal.addEventListener("abort", () => {
    getLogger().debug("SSE aborted, shutting down runner");
    envoy!.shutdown(true);
});

The new code only logs:

c.req.raw.signal.addEventListener("abort", () => {
    getLogger().debug("SSE aborted");
});

If the client disconnects, the envoy process is never explicitly shut down. Is it now cleaned up through another mechanism (e.g., when startServerlessActor resolves)? Also, the old code forwarded a "stopping" SSE event on "serverless-early-exit" — that signal is gone in the new implementation. Is the client no longer expected to react to early exits?


Minor

  • The proxy_service.rs and server.rs changes are pure formatting fixes — no behavior change, looks fine.
  • The rename from StoppedVariant::Normal to StoppedVariant::Stopped is a good clarity improvement.

@MasterPtato MasterPtato force-pushed the 04-06-fix_pb_clean_up_actor_stop_decision_handling branch from 0c23581 to 9e8e9e5 Compare April 6, 2026 22:18
@MasterPtato MasterPtato force-pushed the 04-06-fix_envoy_use_global_instance_add_signal_handlers branch from 6c9af76 to 94f54ba Compare April 6, 2026 22:18
@MasterPtato MasterPtato mentioned this pull request Apr 6, 2026
11 tasks
@MasterPtato MasterPtato force-pushed the 04-06-fix_pb_clean_up_actor_stop_decision_handling branch from 9e8e9e5 to b41869a Compare April 7, 2026 01:30
@MasterPtato MasterPtato force-pushed the 04-06-fix_envoy_use_global_instance_add_signal_handlers branch from 94f54ba to ef85f3e Compare April 7, 2026 01:30
@MasterPtato MasterPtato mentioned this pull request Apr 7, 2026
11 tasks
@MasterPtato MasterPtato force-pushed the 04-06-fix_pb_clean_up_actor_stop_decision_handling branch from b41869a to b8ea46f Compare April 8, 2026 20:11
@MasterPtato MasterPtato force-pushed the 04-06-fix_envoy_use_global_instance_add_signal_handlers branch 2 times, most recently from 5bcccc7 to 8d964a5 Compare April 8, 2026 20:14
@MasterPtato MasterPtato force-pushed the 04-06-fix_pb_clean_up_actor_stop_decision_handling branch from b8ea46f to 2249b28 Compare April 8, 2026 20:14
Copy link
Copy Markdown
Contributor Author

MasterPtato commented Apr 8, 2026

Merge activity

  • Apr 8, 8:52 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 8, 9:00 PM UTC: Graphite rebased this pull request as part of a merge.
  • Apr 8, 9:00 PM UTC: @MasterPtato merged this pull request with Graphite.

@MasterPtato MasterPtato changed the base branch from 04-06-fix_envoy_use_global_instance_add_signal_handlers to graphite-base/4566 April 8, 2026 20:56
@MasterPtato MasterPtato changed the base branch from graphite-base/4566 to main April 8, 2026 20:58
@MasterPtato MasterPtato force-pushed the 04-06-fix_pb_clean_up_actor_stop_decision_handling branch from 2249b28 to 225b40e Compare April 8, 2026 20:59
@MasterPtato MasterPtato merged commit 66ed698 into main Apr 8, 2026
5 of 12 checks passed
@MasterPtato MasterPtato deleted the 04-06-fix_pb_clean_up_actor_stop_decision_handling branch April 8, 2026 21:00
@MasterPtato MasterPtato mentioned this pull request Apr 9, 2026
11 tasks
@NathanFlurry NathanFlurry mentioned this pull request Apr 9, 2026
11 tasks
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