Skip to content

refactor(sessions): remove dead _approvalTurnState breadcrumb - #1508

Closed
Aaronontheweb wants to merge 2 commits into
netclaw-dev:devfrom
Aaronontheweb:refactor/remove-dead-approval-turn-state
Closed

refactor(sessions): remove dead _approvalTurnState breadcrumb#1508
Aaronontheweb wants to merge 2 commits into
netclaw-dev:devfrom
Aaronontheweb:refactor/remove-dead-approval-turn-state

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Collaborator

Removes the dead _approvalTurnState breadcrumb from the session actor. Pure dead-code deletion — no behavior change, no persisted-state change.

What it was

_approvalTurnState and its five-subtype ApprovalTurnState hierarchy were write-only. A full-repo grep confirmed:

  • No subtype payload (Context, PendingCallIds, Recovered, CallId, Reason) was ever read to make a behavioral decision.
  • The only reads were self-referential — reading the current value purely to build the next breadcrumb value.
  • No test referenced it; it was never persisted (transient, INoSerializationVerificationNeeded, absent from snapshot/events).

The only live side effect inside its mutators was a _currentTurnContext write piggybacked alongside the breadcrumb.

What changed

  • Deleted the _approvalTurnState field and the ApprovalTurnState record hierarchy from ToolApprovalState.cs, preserving every _currentTurnContext write — these are load-bearing, especially the recovery-time restore in ApplyToolApprovalRequested.
  • ClearApprovalTurnStateClearCurrentTurnContext (body is now just _currentTurnContext = null).
  • Removing the breadcrumb exposed two genuinely dead calls, also removed: MarkApprovalRedrive only re-set _currentTurnContext one line after it was already set, and MarkApprovalRunningAfterRedrive was a no-op on the normal tool-completion path.

Net: LlmSessionActor.cs −58 lines, ToolApprovalState.cs −18 lines.

Verification

  • Full Netclaw.Actors.Tests Sessions suite green — including ApprovalRehydrationTests (the primary net for the preserved _currentTurnContext restore path) and CompactionIntegrationTests.
  • dotnet slopwatch analyze: no new violations. Copyright headers present.

History

Supersedes #1502, which paired this removal with a CurrentTurnScope extraction. That extraction was dropped — it added a layer of indirection (a new type + a _turn. hop at ~40 sites) without improving type safety, coherence, or simplification, so only the unambiguous dead-code removal is carried forward here.

The _approvalTurnState field and its five-subtype ApprovalTurnState
hierarchy were write-only: a full-repo grep confirmed no subtype payload was
ever read to make a behavioral decision, and no test referenced them. Every
reference was a self-referential read (used only to build the next breadcrumb
value) or a pure write; the only live side effect was a _currentTurnContext
write piggybacked inside the mutators.

Remove the field and the hierarchy, preserving every _currentTurnContext write
(load-bearing, especially the recovery-time restore in ApplyToolApprovalRequested).
ClearApprovalTurnState becomes ClearCurrentTurnContext. Removing the breadcrumb
also exposed two dead calls: MarkApprovalRedrive only re-set _currentTurnContext
one line after it was already set, and MarkApprovalRunningAfterRedrive was a
no-op on the normal tool-completion path.

No persisted state changes (the field was transient and never serialized);
event/snapshot shapes are untouched.
@Aaronontheweb Aaronontheweb added cleanup Code quality improvements and tech debt reduction sessions LLM session actor, turn lifecycle, pipelines labels Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Code quality improvements and tech debt reduction sessions LLM session actor, turn lifecycle, pipelines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant