Skip to content

🤖 refactor: auto-cleanup#3550

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

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

Conversation

@mux-bot

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

Copy link
Copy Markdown
Contributor

Summary

Long-lived auto-cleanup PR. Each pass applies at most one extremely low-risk, behavior-preserving cleanup picked from recently merged main commits, then advances the checkpoint below.

This pass

Extracted a shared findNewestWorkspaceRecord helper in src/node/services/memoryConsolidationService.ts. After #3551 ("consolidate project memory in dream runs"), two methods independently computed "the newest consolidation run across all workspaces" (which doubles as the last time global scope was covered, since every run consolidates global):

  • getStatus derived globalRecord via an Object.values(...).reduce(...) that returns the record with the max lastRunAt (or null).
  • runLaunchSweep derived globalLastRunAt via Math.max(0, ...Object.values(...).map((r) => r.lastRunAt)).

Both now call one findNewestWorkspaceRecord(workspaces) helper; runLaunchSweep reads ?.lastRunAt ?? 0 off the result.

  • Behavior-preserving: the helper returns the record with the greatest lastRunAt (or null when empty), so getStatus is byte-equivalent. For runLaunchSweep, null -> ?? 0 reproduces the old Math.max(0, ...) empty-case floor, and for non-empty input every lastRunAt is a non-negative timestamp so the max is identical.
  • Single file, two call sites collapsed into one helper; no type, schema, or public-API changes.

Validation

  • bun test src/node/services/memoryConsolidationService.test.ts src/node/services/memoryConsolidation.test.ts — 36 pass (covers status derivation including globalRecord, and the launch-sweep qualification/dedupe that consumes globalLastRunAt).
  • make static-check — eslint, typecheck x2, prettier, eager-import (check-eager-imports), code-docs-links (check-code-docs-links), and shellcheck all pass. The shfmt and hadolint steps are skipped because those binaries are unavailable in this environment; no shell scripts or Dockerfiles were touched.

Risks

Negligible. Pure local dedup of two equivalent "newest run across all workspaces" computations into one helper within a single file, with per-input results preserved (including the empty-case 0 floor) and unit coverage over both consuming code paths.


Auto-cleanup checkpoint: 5ac7532


Generated with mux • Model: anthropic:claude-opus-4-8 • Thinking: xhigh • Cost: n/a

@mux-bot

mux-bot Bot commented Jun 13, 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 220f442 to 9c73cf5 Compare June 13, 2026 16:35
@mux-bot

mux-bot Bot commented Jun 13, 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 3 commits June 14, 2026 16:30
Deduplicate the two near-identical post-policy 'upgrade index-only memory
context to the token-budgeted hot block for this model' blocks added in
#3548 (the final-stream-context path and the fallback-model path) into a
single upgradeMemoryContextForModel closure. Behavior-preserving: the
helper returns the unchanged pre-policy memoryContext reference when hot
preloading is off or the memory tool was stripped, so the existing
identity comparison that decides whether to rebuild the system prompt is
unaffected.
After #3547 made project memory host-local, plan-like agents gained
`project: "readwrite"`, so resolveMemoryAccessPolicy's plan-like and
editing-capable branches now return byte-identical matrices. Collapse
them into one branch backed by a shared READ_WRITE_ACCESS constant,
mirroring the existing READ_ONLY_ACCESS pattern. Behavior-preserving:
the policy object is read-only at every callsite.
getStatus and runLaunchSweep both independently computed the newest consolidation run across all workspaces (one as a record reduce, one as a Math.max over lastRunAt). Extract a single findNewestWorkspaceRecord helper and derive globalLastRunAt from it. Behavior-preserving: empty -> null -> 0 floor matches the prior Math.max(0, ...).
@mux-bot mux-bot Bot force-pushed the auto-cleanup branch from 9c73cf5 to 4718ae4 Compare June 14, 2026 16:37
@mux-bot

mux-bot Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Rebased onto latest main and added one new low-risk, behavior-preserving cleanup: extracted a shared findNewestWorkspaceRecord helper in memoryConsolidationService.ts, replacing two duplicate "newest run across all workspaces" computations (getStatus reduce + runLaunchSweep Math.max). Checkpoint advanced to 5ac7532.

@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