🤖 refactor: auto-cleanup#3550
Open
mux-bot[bot] wants to merge 3 commits into
Open
Conversation
Contributor
Author
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
220f442 to
9c73cf5
Compare
Contributor
Author
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
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, ...).
9c73cf5 to
4718ae4
Compare
Contributor
Author
|
@codex review Rebased onto latest |
|
To use Codex here, create a Codex account and connect to github. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Long-lived auto-cleanup PR. Each pass applies at most one extremely low-risk, behavior-preserving cleanup picked from recently merged
maincommits, then advances the checkpoint below.This pass
Extracted a shared
findNewestWorkspaceRecordhelper insrc/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):getStatusderivedglobalRecordvia anObject.values(...).reduce(...)that returns the record with the maxlastRunAt(ornull).runLaunchSweepderivedglobalLastRunAtviaMath.max(0, ...Object.values(...).map((r) => r.lastRunAt)).Both now call one
findNewestWorkspaceRecord(workspaces)helper;runLaunchSweepreads?.lastRunAt ?? 0off the result.lastRunAt(ornullwhen empty), sogetStatusis byte-equivalent. ForrunLaunchSweep,null -> ?? 0reproduces the oldMath.max(0, ...)empty-case floor, and for non-empty input everylastRunAtis a non-negative timestamp so the max is identical.Validation
bun test src/node/services/memoryConsolidationService.test.ts src/node/services/memoryConsolidation.test.ts— 36 pass (covers status derivation includingglobalRecord, and the launch-sweep qualification/dedupe that consumesglobalLastRunAt).make static-check— eslint, typecheck x2, prettier, eager-import (check-eager-imports), code-docs-links (check-code-docs-links), and shellcheck all pass. Theshfmtandhadolintsteps 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
0floor) 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