Skip to content

🤖 refactor: auto-cleanup#3606

Open
mux-bot[bot] wants to merge 4 commits into
mainfrom
auto-cleanup
Open

🤖 refactor: auto-cleanup#3606
mux-bot[bot] wants to merge 4 commits into
mainfrom
auto-cleanup

Conversation

@mux-bot

@mux-bot mux-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Long-lived auto-cleanup PR maintained by the Auto-Cleanup Agent. Each pass lands at most one extremely low-risk, behavior-preserving cleanup drawn from recently merged main activity, then advances the checkpoint below.

Auto-cleanup checkpoint: 25d1d25

This PR currently contains four accumulated cleanups against main:

  1. src/node/services/taskService.ts — dedupe queued-message foreground backgrounding into a private helper.
  2. src/node/services/workflows/workflowScriptResolver.ts — reuse the SKILL_SCRIPT_PATH_PREFIX constant for canonical-path construction.
  3. src/node/services/workflows/WorkflowTaskServiceAdapter.ts — extract the duplicated agent-task creation arg shape into a shared WorkflowTaskCreateArgs type.
  4. src/constants/workspaceTags.ts (new) — centralize the workspace-turn task tag keys, removing the cross-layer "mux.taskHandleId" string duplication.

This pass

Considered the nine new commits on main since the prior checkpoint:

The workspace-turn task tag key "mux.taskHandleId" is written by TaskService.createWorkspaceTurn (node, #3617/#3619) and read by findWorkspaceForTaskTarget in TaskToolCall.tsx (browser, #3613) — the same magic string duplicated across the node/browser boundary. That cross-layer contract was an exact AGENTS.md "centralize magic constants under src/constants/" case: a silent rename on either side would break workspace-task card linking with no compile-time signal.

Landed one behavior-preserving dedup: extracted the three workspace-turn task tag keys (handle, ownerWorkspaceId, turn) into a new @/constants/workspaceTags module and referenced WORKSPACE_TURN_TASK_TAGS from both the node write site and the browser read site. The grouped keys are written together as a cohesive tag schema, so centralizing all three keeps the source single and self-documenting.

Behavior-preserving:

  • Pure constant substitution: the extracted values are byte-identical to the previous literals, so the persisted tag keys and all lookups are unchanged.
  • No runtime code, control flow, or call semantics change.
  • The taskService.test.ts assertions intentionally keep the raw "mux.taskHandleId" / "mux.taskOwnerWorkspaceId" literals so they continue to pin the exact on-disk key values and would catch any accidental constant drift.
Prior pass — WorkflowTaskServiceAdapter WorkflowTaskCreateArgs type

WorkflowTaskServiceLike (in WorkflowTaskServiceAdapter.ts) declared the agent-task creation argument object twice — once inline in create(args: { ... }) and again inside createMany?(args: Array<{ ... }>) — as byte-identical 10-field shapes (including a nested workflowTask object). #3611 added the onRefusal field to both copies, which is exactly the drift risk this duplication invites. Extracted a named WorkflowTaskCreateArgs interface and referenced it from both create and createMany, giving the agent-task creation shape a single source of truth. Behavior-preserving: structurally identical interface, signatures unchanged.

Prior pass — workflowScriptResolver SKILL_SCRIPT_PATH_PREFIX reuse

In workflowScriptResolver.ts, the skill:// prefix is named by the module-level constant SKILL_SCRIPT_PATH_PREFIX and used when parsing incoming skill:// paths, but the two canonical-path builders re-spelled the literal `skill://${...}` instead of reusing the constant. Both builders now interpolate ${SKILL_SCRIPT_PATH_PREFIX} so the prefix has a single source of truth. Behavior-preserving: SKILL_SCRIPT_PATH_PREFIX is exactly "skill://", so the interpolation is byte-identical.

Prior pass — taskService queued-message dedup

Considered #3605 (fix: background foreground waits for prequeued messages), which open-coded the same queued-message guard at two TaskService wait-registration sites (waitForWorkspaceTurn and the task-await path). Both sites now delegate to a single private helper backgroundForegroundWaitIfQueued(shouldBackgroundOnQueuedMessage, requestingWorkspaceId) placed next to backgroundForegroundWaitsForWorkspace. Behavior-preserving: the helper folds in the requestingWorkspaceId truthiness guard (always true at the workspace-turn site; a verbatim match at the task-await site), and the pushed call is unchanged.

Validation

  • make static-check passes locally for the touched code: ESLint, both TypeScript configs (tsconfig + tsconfig.main.json), and Prettier are green. The only non-passing step is fmt-shell-check, which fails solely because the shfmt binary is not installed in this environment; no shell files are touched by any change.
  • Targeted tests pass: bun test src/node/services/taskService.test.ts src/browser/features/Tools/TaskToolCall.test.tsx (230 tests), including the TaskToolCall "labels workspace tasks and opens their created workspace" test that exercises the mux.taskHandleId tag round-trip across the node/browser boundary.

Risks

Minimal. All changes are pure local extractions / constant reuse; no logic, types, or call semantics change. The latest pass replaces duplicated magic strings with byte-identical shared constants and has no runtime effect.


Generated with mux • Model: anthropic:claude-opus-4-8 • Thinking: xhigh

@mux-bot

mux-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@mux-bot mux-bot Bot force-pushed the auto-cleanup branch from e035f24 to 893fadc Compare June 23, 2026 12:57
@mux-bot

mux-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

This pass adds one behavior-preserving cleanup: in workflowScriptResolver.ts, the two canonical-path builders now reuse the existing SKILL_SCRIPT_PATH_PREFIX constant instead of re-spelling the skill:// literal. The constant value is identical, so the constructed strings are byte-identical. No logic, type, or call-semantics changes.

@mux-bot mux-bot Bot force-pushed the auto-cleanup branch from 893fadc to 2d77a10 Compare June 23, 2026 16:54
@mux-bot

mux-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

mux-bot Bot added 4 commits June 23, 2026 20:40
#3605 introduced two near-identical guard blocks that background registered
foreground waits when a tool-end message is already queued (one in the
workspace-turn wait path, one in the task-await path). Extract a single
private helper backgroundForegroundWaitIfQueued() shared by both sites.

Behavior-preserving: the helper folds in the requestingWorkspaceId truthiness
guard, which is always true at the workspace-turn site (asserted non-empty)
and already implied by shouldBackgroundOnQueuedMessage at the task-await site.
The skill:// prefix is already named by SKILL_SCRIPT_PATH_PREFIX and used
for parsing; reuse it in the two canonical-path builders instead of
re-spelling the literal, so the prefix cannot drift. Behavior-preserving:
the constant value is identical to the literal it replaces.
Dedupe the identical inline argument object declared by WorkflowTaskServiceLike.create and createMany into a named WorkflowTaskCreateArgs interface so the agent-task creation shape has a single source of truth. PR #3611 just added onRefusal to both copies, demonstrating the drift risk. Behavior-preserving: pure type-level refactor, no runtime change.
The 'mux.taskHandleId' workspace tag is written in taskService (node) and read in TaskToolCall (browser); the literal was duplicated across the node/browser boundary. Extract the three workspace-turn task tag keys into a shared @/constants/workspaceTags module so the cross-layer contract has a single source of truth. Pure constant substitution: values are byte-identical, so no behavior changes.
@mux-bot mux-bot Bot force-pushed the auto-cleanup branch from 2d77a10 to 8e48d9e Compare June 23, 2026 20:49
@mux-bot

mux-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

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.

0 participants