Skip to content

🤖 refactor: auto-cleanup#3695

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

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

Conversation

@mux-bot

@mux-bot mux-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

This is the long-lived auto-cleanup PR. Each run, the auto-cleanup agent reviews new commits merged to main, rebases onto the latest main, and applies at most one extremely low-risk, behavior-preserving cleanup. The branch accumulates a small stack of independent cleanups until it is merged.

Cleanups in this branch

  1. Dedupe memory sweep recordUsage callbacks (MemoryConsolidationService). The consolidation sweep and the harvest sweep each inlined the same 15-line callback that routes billed usage to the headless-usage sidecar and emits analyticsIngest. Extracted into a private makeSweepUsageRecorder(...) helper.
  2. Dedupe the "memory scope is full" cap check (MemoryService). The create and saveFile (new-file) paths each inlined a byte-identical block that called store.listFiles(), compared the count against MEMORY_MAX_FILES_PER_SCOPE, and threw a MemoryCommandError with the same message. Extracted into a private assertScopeHasRoom(store, scope) helper.
  3. Dedupe blockquote line formatting in the bash monitor wake prompt (bashMonitorWakeStore.ts). buildBashMonitorWakePrompt rendered both the matched-output lines and the lost-monitor script with the identical .map((line) => \> ${line}`).join("\n")blockquote pattern in two places. Extracted into a module-levelblockquoteLines(lines)` helper.
  4. Dedupe the tool_search removal in prepareToolSearch (toolCatalog.ts). Both fallback branches (PTC enabled, and empty deferred catalog) inlined the identical { [TOOL_SEARCH_TOOL_NAME]: _removed, ...rest } destructure to drop the built-in tool_search entry from the tool record. Extracted into a module-level withoutToolSearch(tools) helper.
  5. Dedupe the Anthropic cache-create token extraction in accumulateProviderMetadata (usageHelpers.ts). The function inlined the same verbose (metadata.anthropic as { cacheCreationInputTokens?: number } | undefined)?.cacheCreationInputTokens ?? 0 cast twice (once for the accumulated metadata, once for the current step). Extracted into a module-private getAnthropicCacheCreateTokens(metadata) helper.
  6. Dedupe capability-model thinking-policy resolution (thinking/policy.ts). After 🤖 feat: integrate GPT-5.6 Sol/Terra/Luna with native max effort and pro-mode toggle #3708 taught the thinking policy to resolve mappedToModel aliases, both getThinkingPolicyForModel and hasExplicitThinkingPolicy inlined the identical getExplicitThinkingPolicy(resolveModelForMetadata(modelString, providersConfig ?? null)) call. Extracted into a private getExplicitThinkingPolicyForModel(modelString, providersConfig) helper.
  7. Dedupe queue entry clear-callback projection (messageQueue.ts). After 🤖 feat: queue messages behind special sends instead of erroring (FIFO message queue) #3696 rewrote MessageQueue into FIFO QueueEntry items, both getClearCallbacks and removeWorkspaceTurn inlined the identical spread that builds a QueueClearCallbacks object from an entry's optional onCanceled / onAcceptedPreStreamFailure fields. Extracted into a private entryClearCallbacks(entry) helper.

This run

Considered origin/main through 956ac533e, which added two commits since the last checkpoint: the FIFO message queue (#3696) and the MCP OAuth authorization-server binding fix (#3710).

Validation

  • make static-check locally: ESLint, both TypeScript configs, and Prettier pass. (shfmt is unavailable in the sandbox and stops the target at fmt-shell-check, but this change touches only a single TypeScript file — no shell files.)
  • bun test src/node/services/messageQueue.test.ts: 51 pass / 0 fail.

Risks

Very low. All cleanups are pure same-file simplifications that preserve semantics. Every cleanup extracts byte-identical inlined logic into a helper — no control flow, arguments, thresholds, error types, emitted events, or rendered text change.

Auto-cleanup checkpoint: 956ac53


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

@mux-bot

mux-bot Bot commented Jul 8, 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 a2454d3 to 450337d Compare July 8, 2026 17:01
@mux-bot

mux-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

⚠️ Auto-fixup: CI failure appears to be infrastructure/flaky, not caused by this cleanup commit — no code pushed.

Root cause: The Static Checks job failed with the runner annotation "The self-hosted runner lost communication with the server" after running the full 10m, and its log blob was never uploaded (BlobNotFound). Test / Integration was cancelled and Required failure are both downstream of that (Required only aggregates results).

Verification: Ran make static-check locally on this PR's HEAD (a2454d31b). ESLint, both TypeScript configs (tsgo --noEmit ×2), and Prettier all pass. The only local miss is fmt-shell-check because shfmt isn't installed in the fixup sandbox — and this PR changes no shell files, so it's irrelevant.

Recommendation: Re-run the failed CI jobs. No code change needed.

@mux-bot mux-bot Bot force-pushed the auto-cleanup branch from 450337d to e32952d Compare July 9, 2026 00:30
@mux-bot

mux-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Latest push rebases onto origin/main (through #3698) and adds one low-risk, behavior-preserving cleanup: extract the duplicated per-scope "memory scope is full" cap check in MemoryService.create / saveFile into a private assertScopeHasRoom(store, scope) helper. No control flow, thresholds, error types, or events change. make static-check (ESLint + both tsconfigs + Prettier) and bun test memoryService.test.ts (75/0) pass locally.

@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 e32952d to d8d0ba5 Compare July 9, 2026 09:10
@mux-bot

mux-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

New in this run: cleanup #3 — deduped the identical blockquote line-prefixing (> per line, joined by newlines) in buildBashMonitorWakePrompt into a module-level blockquoteLines(lines) helper. Behavior-preserving; validated by the existing buildBashMonitorWakePrompt output-format tests (21/21 pass).

@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 d8d0ba5 to 78cd7b2 Compare July 9, 2026 20:38
@mux-bot

mux-bot Bot commented Jul 9, 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 78cd7b2 to a676f79 Compare July 10, 2026 00:30
@mux-bot

mux-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Added auto-cleanup #5: getCodexOauthContextLimit now reuses the already-resolved, non-null compatibilityModelId with the isCodexOauthAllowedModelId / isCodexOauthRequiredModelId variants instead of re-invoking isCodexOauthAllowedModel / isCodexOauthRequiredModel (which re-derive the same id and re-scan providersConfig). Behavior-preserving; targeted tests + make static-check (minus sandbox-only shfmt) pass.

@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 a676f79 to 32928e3 Compare July 10, 2026 09:08
@mux-bot

mux-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Added cleanup #6: extracted a module-private getAnthropicCacheCreateTokens(metadata) helper in usageHelpers.ts to dedupe two byte-identical Anthropic cache-create token reads inside accumulateProviderMetadata. Behavior-preserving; rebased onto latest main (checkpoint ec47caf).

@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 32928e3 to 8afce4c Compare July 10, 2026 16:47
@mux-bot

mux-bot Bot commented Jul 10, 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 7 commits July 11, 2026 00:19
Extract the byte-identical consolidation/harvest sweep `recordUsage`
callbacks in MemoryConsolidationService into a shared
`makeSweepUsageRecorder` helper. Behavior-preserving: same sidecar
recording and analyticsIngest emit; only the workspaceId source and
analyticsSource literal differ per call site.

Auto-cleanup checkpoint: f7f0f02
Both fallback branches in prepareToolSearch inlined the identical
{ [TOOL_SEARCH_TOOL_NAME]: _removed, ...rest } destructure to drop the
built-in tool_search entry from the record. Extract a module-level
withoutToolSearch(tools) helper; output is byte-identical.
accumulateProviderMetadata inlined the same verbose (metadata.anthropic as { cacheCreationInputTokens?: number }).cacheCreationInputTokens ?? 0 cast twice. Extracted a module-private getAnthropicCacheCreateTokens(metadata) helper. Behavior-preserving; the displayUsage.ts site is intentionally left alone because its chain has an extra usage.inputTokenDetails.cacheWriteTokens fallback.
Both getThinkingPolicyForModel and hasExplicitThinkingPolicy inlined the
identical getExplicitThinkingPolicy(resolveModelForMetadata(model, providersConfig ?? null))
call after #3708 added alias resolution to each. Extract a private
getExplicitThinkingPolicyForModel helper; behavior-preserving.
@mux-bot mux-bot Bot force-pushed the auto-cleanup branch from 8afce4c to 990576b Compare July 11, 2026 00:26
@mux-bot

mux-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Added cleanup #7: deduped the byte-identical QueueClearCallbacks projection in MessageQueue.getClearCallbacks and removeWorkspaceTurn into a private entryClearCallbacks(entry) helper (behavior-preserving). Rebased onto latest main and advanced the checkpoint to 956ac533e.

@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