Repository navigation
refactor(compactionpoint): move the compaction-point choice out of the proxy - #1320
Conversation
…e proxy Move the client match, the choice order, the three settings readers and the Bob window clean-up from proxy/compactioncfg.go into internal/compactionpoint. The readers take getenv and an fs.FS. The host keeps the file system, the Bob system-settings path and the in-memory window store. Closes #1300. Refs #1309. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.331 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | cb628c7fe2f2 |
approve |
Verdict: approve
Findings
None. The move keeps the behavior. I checked each moved piece against the old proxy code, line by line:
ReadClaude,ReadBob,ReadCodexininternal/compactionpoint/client.goare copies of the oldReadClaudeCompact,ReadBobCompact,ReadCodexCompact, with the same off switch, the same path guards (IsAbs, empty home), the same merge order, the same size caps and the sameshort()rule.ClientOfmatches the oldclientOf: the samebobshell/andcodexprefix tests on the trimmed, lowercased header, then the Claude test. The Claude test (Containsofclaude-codeorclaude-clion the lowercased raw header) gives the same answers as the olddash.AgentForswitch, becausedash.AgentForreturnsclaude-codeorclaude-cliexactly when one of those substrings is present (dash/event.go:1263).clientdash_test.gopins the two together.Settings.Pickmakes the same three calls the old switch made, with the same arguments (Claude.Resolve(model, window),Bob.Resolve(window, bobWindow(model)),Codex.Resolve(window)). The hosted-proxy guard (Tenants == nil,r != nil) stays incompactionPointFor.CleanBobWindowskeeps the oldnoteBobWindowsresult: same bounds, same copy, nil when nothing is stored.MaxBobWindows = 512equalsbob.MaxModelWindows(agent/bob/controlplane.go:16).- The proxy keeps wrappers (
ReadClaudeCompactetc.) soproxyappand the existing proxy tests are unchanged, as issue #1300 asks. The new library file imports noproxy,proxyappordashpackage. - No leftover users of the removed helpers (
clientOf,readSmall,short) inproxy/; the remaining imports inproxy/compactioncfg.goare all used.
Non-blocking
internal/compactionpoint/client.go:26—openAbscannot open a Windows drive-letter path (C:\Users\...failsfs.ValidPathafterToSlash), so on Windows every settings read would silently fail open. The Makefile builds darwin only, so this is not live today. Note it if a Windows build ever lands.internal/compactionpoint/client.go:26— a relativehomenow resolves under/(DirFS root); the old code opened it relative to the working directory. Onlyproxyapppasseshome, and it usesos.UserHomeDir()(absolute or empty), so the case is unreachable in practice. It is an edge-case behavior difference; issue #1300 says "no change in behaviour". The new side is the safer one (it cannot read a project file).internal/compactionpoint/client.go:16—MaxBobWindows = 512is a second copy ofbob.MaxModelWindows. The comment says this is on purpose. No test ties the two constants together (agent/bob/controlplane_test.go:131pins only its own). If one changes, nothing fails.proxy/compactioncfg.go:48—hostFSis a mutable package-level var. Fine as a test seam; just keep writes to it in tests only.
What I checked
- The full diff
30a80767..HEAD(one commit) and the code around each change. - Line-by-line equivalence of the three readers,
ClientOf,PickandCleanBobWindowsagainst the removed proxy code. dash.AgentFor(dash/event.go:1263) against the repeated Claude rule, plus the pin test.Bob.Resolve,Codex.Resolve,ClaudeCode.Resolvesignatures and zero-value behavior.- Callers:
proxyapp/claudecompact.go,proxy/proxy.go, and the unchangedproxy/compactioncfg_test.go(itst.TempDir()paths work throughos.DirFS("/")on darwin and Linux). - Import direction:
dashimportscompactionpoint; the new pin test sits in the externalcompactionpoint_testpackage, so no cycle. - Issue #1300 (the refactor's rules) — the PR follows them; no proxy test was edited.
- Build targets in the Makefile for the Windows question above.
- No data-dependence change: the move changes no feature's data dependence, so no
docs/data-dependence/row edit is needed. - I did not run builds or tests (not approved for this review).
b8bd50e to
cb628c7
Compare
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.331 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | cb628c7fe2f2 |
approve |
Verdict: approve
Findings
None. The change is a move, not a behavior change. I checked each moved piece against the code it replaced, line by line.
Non-blocking
internal/compactionpoint/client.go:124—openAbsroots atos.DirFS("/")(proxy/compactioncfg.go:48). On Windows, a home likeC:\Users\mepassesfilepath.IsAbs, butDirFS("/")cannot open it. The old code usedos.Openand could. The read then fails open and C comes from the table. The repo ships linux and darwin only (.goreleaser.yaml), so no released build is affected.internal/compactionpoint/client.go:124—fs.FSnames reject.and..elements, whichos.Openaccepted. All current callers pass paths cleaned byfilepath.Joinand checked withIsAbs, so no reachable change. OnlyBOB_SHELL_CLI_SYSTEM_SETTINGS_PATHfrom the env reachesopenAbsuncleaned; a value with a.element is now skipped instead of read. Fail open.internal/compactionpoint/client.go:63—MaxBobWindows = 512no longer tracksbob.MaxModelWindows(proxy keptbobWindowMax = bob.MaxModelWindowsbefore). If the agent's cap rises,CleanBobWindowsreturns nil for every catalog over 512 and Bob's windows stop being recorded. The comment says this is deliberate. No test pins the two constants together.proxy/compactioncfg.go:118—bobSystemSettingsPathstays in the proxy, because it readsruntime.GOOS. A second host must copy it to get the same Bob C. That weakens the stated goal ("every host gets the same C") a little. Fine for now; only one host exists.
What I checked
- The full diff of all six files, and the code around each change.
- Parity of the moved readers:
ReadClaude,ReadBob,ReadCodex,readOff,readSmall,shortininternal/compactionpoint/client.goare the removed proxy code verbatim. The only difference is the file-system injection (os.Open(path)becomesopenAbs(fsys, path)). - Parity of
ClientOfwith the removedclientOf: the inline Claude rule (Contains(lower(raw UA), "claude-code" || "claude-cli"), no trim) equals whatdash.AgentForreturns for those two names, becausedashchecks them first in its list (dash/event.go:1264). The Bob and Codex prefix rules are unchanged.clientdash_test.gopins the Claude rule todash.AgentFor. - Parity of
Settings.Pickwith the removed switch incompactionPointFor: same calls, same arguments;h.bobWindowis never nil, so the nil guard changes nothing. TheTenants == nilandr != nilguards are unchanged. - Parity of
CleanBobWindowswith the removednoteBobWindowsbody: same empty, over-cap and non-positive-window rules.MaxBobWindows = 512equalsbob.MaxModelWindows(agent/bob/controlplane.go:16). - Callers:
proxyapp/claudecompact.gostill calls the proxy wrappers;homeis absolute or""there. No code outsideproxy/compactioncfg.goused the removed helpersclientOf,readSmallorshort. - No identifier clashes in
internal/compactionpoint(Client,Settings,Pick,CleanBobWindowsare new;short,readSmall,readOffexist once). Test helpers do not clash across the two test packages. - Library boundary:
internal/compactionpoint/client.goimports only stdlib and gjson, neverproxy. - Tests: new tests cover
ClientOf,Pick,CleanBobWindowsand all three readers, including the off switch, the merge order and fail-open cases. The old proxy tests still cover the wrappers through the real file system. - Data dependence: unchanged. The feature row
docs/data-dependence/features/client-compaction-setting.mdstays accurate; no row edit is needed for a move. - Docs: no stale references to
proxy.ReadClaudeCompactand friends outside the proxy package; the package comments inbobcodex.goandclaudecode.gowere updated to the new names.
… in the library - Read settings files through an injected Open (os.Open in the host), so relative, `.` and Windows paths work as before. - CleanBobWindows takes the cap. The proxy passes bob.MaxModelWindows. - BobSystemSettingsPath moves to the library and takes goos. - Add a test for a `.` element in the Bob system path. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
b8bd50e to
aa5b6c8
Compare
|
Fixed in aa5b6c8.
|
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.331 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 2 of 2 | aa5b6c8d89ee |
approve |
Verdict: approve
Findings
None. The new commit fixes every note from both round-1 reviews and adds no defect.
Status of the earlier notes
My round-1 notes (all non-blocking):
openAbsbroke Windows drive paths — fixed.Open(client.go:123) is an injected opener; the host passeshostOpen, a wrapper overos.Open(proxy/compactioncfg.go:49). AC:\Users\...path now reachesos.Openas before.fs.FSrejected.and..elements — fixed. Same injection. The library hands the path to the opener unchanged.TestReadersPassPathsUnchangedToTheOpener(client_test.go:140) pins that, andTestReadBobCompactAcceptsADotElementInTheSystemPath(proxy/compactioncfg_test.go:314) reads a real file through a.element.MaxBobWindowswas a second copy ofbob.MaxModelWindows— fixed. The constant is gone.CleanBobWindowstakes the cap (client.go:95) and the proxy passesbobWindowMax = bob.MaxModelWindows(proxy/compactioncfg.go:98). One definition.bobSystemSettingsPathstayed host-side — fixed. It moved to the library asBobSystemSettingsPath(getenv, goos)(client.go:233), a verbatim copy. The proxy passesruntime.GOOS(proxy/compactioncfg.go:121).TestBobSystemSettingsPathcovers env override, trim, darwin, linux and windows.
Reviewer 1's notes: 1 and 2 (Windows, relative home) fixed by the same Open injection — a relative home now opens relative to the working directory, the base behavior that issue #1300 asks to keep. 3 (copied constant) fixed as above. 4 (hostFS mutable var) addressed: it is now hostOpen with a comment that only tests may write it. I checked each fix myself; I agree with all of them.
Non-blocking
internal/compactionpoint/client.go:17— the file-header comment still says the host passes "Bob's system-settings path". The host now passesgoos, and the library finds the path itself (client.go:217, 233). One stale sentence; the rest of the comment is right.
What I checked
- Last review: round 1, cb628c7, 2026-11-24T09:00:16Z.
- New commits read: 1 — aa5b6c8 "refactor(compactionpoint): keep the old path behaviour, one cap, GOOS in the library".
- Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files
.review-in-reviews.txt,.review-in-comments.txt,.review-in-inline.txt). - New items since my last review: the author's comment at 2026-11-24T09:51:57Z ("Fixed in aa5b6c8", four points) — I checked each point against the code; commit aa5b6c8 — full diff and the four changed files read around each change.
- The new
Openseam:hostOpenwrapsos.Openbecauseos.Open's result type does not assign toOpendirectly; the wrapper keeps the same semantics (nil, err on error).readSmallandReadCodexcallopen(path)with the path exactly as built — no rewriting, so relative,./..and Windows paths behave as in the base. - Parity of
BobSystemSettingsPathwith the removed proxy function: verbatim (env override with trim, darwin path, else/etc/bob-shell/settings.json).ReadBobcalls it itself; the proxy passesruntime.GOOS. CleanBobWindows(windows, max): same empty, over-cap and non-positive rules as before, now with the caller's cap. The proxy passesbobWindowMax = bob.MaxModelWindows, so the cap has one definition again.- No leftover references:
MaxBobWindows,openAbs,hostFSandbobSystemSettingsPathare gone from the repo; everyReadBobcaller uses the new 4-argument form. - Imports:
stringsremoved from proxy/compactioncfg.go (no user left),io/fsadded (used byhostOpen);path/filepathandio/fsstill used in client.go. - Tests: the round-1 tests were updated to the new signatures, plus three new tests (
TestBobSystemSettingsPath,TestReadersPassPathsUnchangedToTheOpener,TestReadBobCompactAcceptsADotElementInTheSystemPath). The path-recording test asserts the exact string, so a future rewrite of paths would fail it. - The old proxy tests still run through
hostOpenand the real file system, so the wrappers stay covered. - Library boundary unchanged: client.go imports only stdlib and gjson.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.331 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 2 of 2 | aa5b6c8d89ee |
approve |
Verdict: approve
Findings
None. The new commit aa5b6c8d fixes every round-1 finding, mine and reviewer 2's, and adds no defect. I checked each fix in the code:
- Path behavior restored.
Open func(path string) (fs.File, error)(internal/compactionpoint/client.go:123) replaces thefs.FS+openAbspair. The host passes a wrapper overos.Open(proxy/compactioncfg.go:49), so a path means what it meant before the PR: relative paths resolve against the working directory,.and..elements work, and a Windows drive path works.readSmall,ReadClaude,ReadBobandReadCodexpass the path to the opener unchanged — no rewriting anywhere in the library. - One cap.
MaxBobWindowsis gone.CleanBobWindows(windows, max)takes the cap (internal/compactionpoint/client.go:95) and the proxy passesbobWindowMax = bob.MaxModelWindows(proxy/compactioncfg.go:98,106). The cap has one definition again, as before the PR. - Bob path rule in the library.
bobSystemSettingsPathmoved from the proxy toBobSystemSettingsPath(getenv, goos)(internal/compactionpoint/client.go:233), a verbatim copy withgoosin place ofruntime.GOOS.ReadBobtakesgoosand finds the path itself; the proxy passesruntime.GOOS(proxy/compactioncfg.go:121). A second host now gets the same rule for free. hostOpen. Renamed fromhostFS, still a package-level var, now with "Only tests may write this variable" in its comment. That covers my note.
Status of round-1 findings
Mine (all non-blocking, all fixed):
- Windows drive-letter paths broke under
DirFS— fixed (os.Open throughhostOpen). - Relative
homeresolved under/— fixed (os.Open semantics restored). MaxBobWindows = 512duplicatedbob.MaxModelWindows— fixed (cap passed as a parameter).hostFSmutable var — fixed (renamed, documented).
Reviewer 2's (all non-blocking, all fixed):
- Windows
DirFS— same fix as my 1. Fixed. ./..elements rejected — fixed, and covered by two new tests (see below).MaxBobWindowsno longer tracks the agent's cap — fixed (one definition).bobSystemSettingsPathstays in the proxy — fixed (moved to the library).
The author's comment (2026-11-24T09:51:57Z) lists the same four fixes. Each claim checks out in the diff.
New tests in aa5b6c8d
TestReadersPassPathsUnchangedToTheOpener(internal/compactionpoint/client_test.go) proves the library hands/a/./b/../s.jsonto the opener verbatim.TestReadBobCompactAcceptsADotElementInTheSystemPath(proxy/compactioncfg_test.go) proves a.element in the env path reads the file through the realos.Open. The author says it fails oncb628c7f; that matchesfs.ValidPathrejecting.elements, so the claim is right.TestBobSystemSettingsPathcovers darwin, linux, windows and a trimmed env value.
Non-blocking
internal/compactionpoint/client.go:16— the file-header comment still says a host passes "the file system, and Bob's system-settings path". The host now passes an opener andgoos, and the library finds Bob's path itself. The comment is one commit behind the code.
What I checked
- Last review: round 1, cb628c7, 2026-11-24T08:58:50Z.
- New commits read: 1 —
aa5b6c8d"refactor(compactionpoint): keep the old path behaviour, one cap, GOOS in the library". - Read in full: 2 reviews, 1 comment, 0 inline comments (from
.review-in-reviews.txt,.review-in-comments.txt,.review-in-inline.txt). - New items since my last review: reviewer 2's round-1 review (read in full; its four non-blocking findings match mine or add the
./..and host-copy points, all now fixed), the author's fix comment (each claim verified in the diff), and commitaa5b6c8d(reviewed below). - The full diff
cb628c7f..aa5b6c8dand the final state ofinternal/compactionpoint/client.go,proxy/compactioncfg.goand both test files. - No other package uses the changed API (
ReadBob,ReadClaude,ReadCodex,CleanBobWindows):dashuses onlyPointsources,proxyappgoes through the proxy wrappers. - Imports:
stringsleftproxy/compactioncfg.gowith its last user;io/fsentered forfs.File; every remaining import in both files is used. - Issue #1300's rules still hold: no proxy behavior change (the os.Open path semantics are the pre-PR ones), no library import of
proxy,proxyappordash. - I did not run builds or tests (not approved).
Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
Head is now 85f3d14. Output of |
Summary
The proxy no longer decides the compaction point C. The choice and the settings readers now live in
internal/compactionpoint. Closes #1300. Refs #1309.What changed
internal/compactionpoint/client.go:Clienttype: the library takes the client as an input.Settings.Pick(client, ...): the selection order (client rule first, else the caller uses the price table).ReadClaude,ReadBob,ReadCodex: takegetenv,homeand anOpenfunction.ReadBobalso takesgoos.CleanBobWindows(windows, max): the clean-up of Bob's window catalog. The proxy passesbob.MaxModelWindows.BobSystemSettingsPath(getenv, goos): Bob's system-settings path. The proxy passesruntime.GOOS.Open: the readers open files through it. The proxy passesos.Open.proxy/compactioncfg.goshrinks from 328 to 135 lines. It keepsclientOf,hostOpen(os.Open), theHandlerwindow store and its mutex, and thin wrappers with the old names and signatures.proxy/proxy.gois not touched.Behaviour
None. Existing tests pass with no edit.
Differences from the issue text, kept on purpose:
noteBobWindowsdoes not move whole. The tests readh.bobWinas a map. A move would edit tests. Only the pure clean-up moved. The mutex and map stay in the host, as host state.clientOfstays in the proxy, unchanged (scope change). Issue refactor(agent): move Claude Code rules into agent/claudecode; add OpenCode and Pi labels #1312 replaces it with one library entry point inagent/. The library takes the client, not the User-Agent.ClaudeCompactOffEnvis now an alias ofcompactionpoint.OffEnv. Same value.Data dependence
Unchanged. Same inputs: env, the user's settings files, the User-Agent, model id and window numbers. No transcript text. No row in
docs/data-dependence.mdchanges.How it was tested
macOS, Go 1.27.4, at head
aa5b6c8d.go build ./... && go vet ./... && gofmt -l .: clean.go test -count=1 ./internal/compactionpoint ./proxyapp ./dash/...: pass, exceptTestNoHooksKeepsTheBinaryDefaultsinproxyapp. It also fails onorigin/main.CGO_ENABLED=1 go test -race ./internal/compactionpoint: pass../proxyin 9 parts (-run ^Test[A], B, C, D-E, F-L, M-O, P-R, S, T-Z): all pass except one test.TestRegistrationRateLimitedPerIPfailed once in the P-R part (7 s, while other agents ran suites on this machine).-racehere, and 3 of 3 onorigin/main. It is a timing test. It does not touch compaction code.TestReadBobCompactAcceptsADotElementInTheSystemPathfails oncb628c7f(Thresholdempty) and passes now.TestReadersPassPathsUnchangedToTheOpener,TestBobSystemSettingsPath, and the reader tests on an in-memory tree.CleanBobWindowsmadeTestCleanBobWindowsfail. Reverted.Technical notes
MapFS. The host opens files withos.Open, so relative,.and Windows paths behave as before.