mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-16 03:09:33 +01:00
fix(git): the interval fetches one run per folder, and the rest of the review (review)
The scheduler is the part that runs with nobody watching, so it is decided per folder rather than per session: sessions sharing a folder are the same clone and share one run that both see, `inFlight`/`lastRunAt` are keyed by the resolved folder, the schedule is stamped when a folder is picked instead of when its run starts, and a tick is skipped while the previous one is still going. The click route joins a run already going for the same folder rather than starting a second fetch in one clone. The tick keeps ONE bound for the git processes of the whole run and hands it to every folder, and bounds its folders with a bound of its own: the same semaphore cannot serve both levels, because a folder holding a slot would then wait for a slot its own fetch needs. Both bounds are `FETCH_CONCURRENCY`, so the ceiling is unchanged. The bound claim in CLAUDE.md, the `Limiter` jsdoc and docs/api-reference.md now describes it as it is. Before anything is fetched the folder is probed with the bounded path probe, so a case on a mount that stopped answering is skipped and never touched. The rest of the review: the hooks are named as they really are (`reference-transaction`, `pre-auto-gc` through the maintenance a fetch triggers, config commands such as `credential.helper`) and `FETCH_CONFIG_ARGS` turns maintenance and gc off for an unattended run; the claim that an agent in the same repository is not disturbed is replaced by the ref-lock collision it actually is; the click route publishes its own run as `trigger: 'click'`; `autoSaveGitFetch` uses `_apiJson` so a 400 shows the error toast and applies the returned settings; and the two wording fixes. Tests: the scheduler pins one run per folder, the two bounds, the probe before anything runs, and that closing the session holding the override keeps the folder while another session is still open on it; the route test pins the click publish and the join, asserting the join before the held run is released — releasing first lets the run finish and clears the lane, so the joiner would be entitled to its own fetch and the test would pass for the wrong reason.
This commit is contained in:
1 parent
9432d9f9e2
commit
ea4318947b
20 files changed
+774
-209
No files matched your search
+11
-3
@@ -124,8 +124,9 @@ import { AI_CHECK_MODEL } from '../config/ai-defaults.js';
|
||||
import { approvalInbox } from './approval-inbox.js';
|
||||
import { SCREEN_BLOCKED_SOURCE } from './screen-blocked.js';
|
||||
import { PromptCacheKeepWarmService } from '../prompt-cache-keepwarm.js';
|
||||
import { fetchGitWorkspaceOverview } from '../git-fetch.js';
|
||||
import { fetchWorkspaceOnce } from '../git-fetch.js';
|
||||
import { GitFetchScheduler } from '../git-fetch-scheduler.js';
|
||||
import { probePathKind } from '../utils/bounded-path-probe.js';
|
||||
import { defaultDockerWorkspaces } from './routes/git-status-routes.js';
|
||||
import { composerIsEmpty, plainFrame } from '../session-submit-verifier.js';
|
||||
import { detectUsageLimitPause } from '../usage-limit-patterns.js';
|
||||
@@ -405,12 +406,19 @@ export class WebServer extends EventEmitter {
|
||||
readSettings: readGitFetchSettings,
|
||||
// The same Docker list the panel's routes use: the rule has to be one rule.
|
||||
dockerWorkspaces: defaultDockerWorkspaces,
|
||||
fetch: (cwd, opts) => fetchGitWorkspaceOverview(cwd, opts),
|
||||
// Bounded probe, DEFAULT options (rule #516): a tick is a bulk scan, so it keeps the stall cap and must
|
||||
// never be handed `pastCap`. A folder on a mount that stopped answering is skipped, not fetched.
|
||||
probePath: (path) => probePathKind(path),
|
||||
// Through the join, so the tick and the panel's Fetch button are the same run: a click on a folder the
|
||||
// tick is already fetching joins it rather than starting a second `git fetch` in the same clone.
|
||||
fetch: (cwd, opts) => fetchWorkspaceOnce(cwd, opts),
|
||||
publish: (id, status) => {
|
||||
const session = this.sessions.get(id);
|
||||
if (!session?.setGitFetchStatus(status)) return;
|
||||
// No new SSE event: the status rides the session state the page already listens for, and the Git
|
||||
// panel polls on its own clock. Persisted, because what a run found is the panel's current truth.
|
||||
// panel polls on its own clock. It is written to disk with the rest of the record, but the restore
|
||||
// copies only the fields its own config lists and this is not one of them (src/types/session.ts), so
|
||||
// what a run found is the panel's truth for the life of the session, not across a restart.
|
||||
this.persistSessionState(session);
|
||||
this.broadcast(SseEvent.SessionUpdated, this.getSessionStateWithRespawn(session));
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user