Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge remote-tracking branch 'origin/capy/6712-pr4b' into capy/6712-pr4b-gate-e
garrytan0ec306434a5f
diff --cc src/core/persistence/sync-pass-run.tsindex 00fb18547c,df2dcee047..93c8c94156--- a/src/core/persistence/sync-pass-run.ts+++ b/src/core/persistence/sync-pass-run.ts@@@ -421,22 -400,13 +421,21 @@@ export async function runSyncPass(enginlet costDeferred: string | null = null;if (costDecision.defer && !processingOptions.noEmbed) { processingOptions.noEmbed = true; costDeferred = costDecision.defer; }- const counts = { added: 0, modified: 0, deleted: 0, renamed: 0, chunks: 0, waivedImports: 0, waivedDeletes: 0, held: 0, pausedDeletes: 0, collisions: 0, episodeReleased: 0, costDeferred: costDeferred ? 1 : 0 };+ const counts = { added: 0, modified: 0, deleted: 0, renamed: 0, chunks: 0, waivedImports: 0, waivedDeletes: 0, held: 0, pausedDeletes: 0, collisions: 0, episodeReleased: 0, costDeferred: costDeferred ? 1 : 0,+ skippedContextualMode: 0, skippedCanonicalBytes: 0 };const collisions: SyncSlugCollision[] = [];+ // What the batches report beside their counts, as a cursor run reported it: committed pages' size states and #5751's legacy skips.+ let sizeStates: SyncSizeStates | undefined;- const legacySkips = { contextualMode: 0, canonicalBytes: 0 };- const foldReport = (sizes: SyncSizeStates | undefined, skips: { contextualMode?: number; canonicalBytes?: number } | undefined) => {++ const foldReport = (sizes: SyncSizeStates | undefined) => {+ if (sizes?.total) sizeStates = { total: (sizeStates?.total ?? 0) + sizes.total, pages: [...sizeStates?.pages ?? [], ...sizes.pages].slice(0, SIZE_STATE_SAMPLE) };- legacySkips.contextualMode += skips?.contextualMode ?? 0; legacySkips.canonicalBytes += skips?.canonicalBytes ?? 0;+ };const S = new Map<string, string>();+ // #5751: (path, level) keys a legacy kernel waiver passed. The waiver records no import, so the path classifies as before;+ // it is settled for this pass (never re-admitted, never a settle mismatch) and re-screened by the next one.+ const legacyWaived = new Set<string>();const settledKey = (path: string, level: string | null) => `${path}\0${level ?? ''}`;- // The entries this round's batches settled before the round folds its candidates into S: a slice that yields mid-round- // (writer_yield) reports them (yieldSettled); a blocked stop reports S as it replays.+ // The entries this round's batches settled before the round folds its candidates into S: a slice that stops mid-round+ // reports them (yieldSettled); a blocked stop reports S as it replays.let roundSettled = 0, yieldSettled = 0;const retryConsumed = new Set<string>(retry);const sliceBase = { started: performance.now(), pages: 0 };@@@ -461,8 -431,8 +460,9 @@@const result = (status: SyncResult['status'], reason?: SyncResult['reason']): SyncResult => ({ status, fromCommit: remote ? null : context.source.last_commit, toCommit: remote ? '' : head,added: counts.added, modified: counts.modified, deleted: counts.deleted, renamed: counts.renamed, chunksCreated: counts.chunks, embedded: 0, pagesAffected: [],filesImported: sliceBase.pages, bankedFiles: sliceBase.pages, waived: { imports: counts.waivedImports, deletes: counts.waivedDeletes }, prescreened: 0,+ ...(counts.skippedContextualMode || counts.skippedCanonicalBytes ? { legacySkips: { contextualMode: counts.skippedContextualMode, canonicalBytes: counts.skippedCanonicalBytes } } : {}),- ...(collisions.length ? { slugCollisions: collisions } : {}), ...(identityDowngrades.length ? { identityDowngrades } : {}), ...(inherited.length ? { inherited_options: inherited } : {}), ...(reason ? { reason } : {}),+ ...(collisions.length ? { slugCollisions: collisions } : {}), ...(fileRefusals.size ? { fileRefusals: [...fileRefusals.values()] } : {}), ...(identityDowngrades.length ? { identityDowngrades } : {}), ...(inherited.length ? { inherited_options: inherited } : {}), ...(reason ? { reason } : {}),- ...(sizeStates ? { size_states: sizeStates } : {}), ...(keptCount() ? { working_tree_kept: keptCount() } : {}), ...(legacySkips.contextualMode || legacySkips.canonicalBytes ? { legacySkips: { ...legacySkips } } : {}),++ ...(sizeStates ? { size_states: sizeStates } : {}), ...(keptCount() ? { working_tree_kept: keptCount() } : {}),pass: { pass_id: passId, kind, round: value.telemetry.round, outcome: value.telemetry.outcome, stop_reason: value.telemetry.stop_reason, candidates: candidatesFirst,settled: S.size + yieldSettled, remaining: value.telemetry.remaining, not_converged_streak: value.obligations.not_converged_streak } });try {@@@ -496,14 -466,11 +496,12 @@@if ('entries' in drained) {const c = drained.counts;Object.assign(counts, { added: counts.added + c.added, modified: counts.modified + c.modified, deleted: counts.deleted + c.deleted, renamed: counts.renamed + (c.renamed ?? 0),- chunks: counts.chunks + c.chunks, waivedImports: counts.waivedImports + (c.waived?.imports ?? 0), waivedDeletes: counts.waivedDeletes + (c.waived?.deletes ?? 0), held: counts.held + (c.held ?? 0) });+ chunks: counts.chunks + c.chunks, waivedImports: counts.waivedImports + (c.waived?.imports ?? 0), waivedDeletes: counts.waivedDeletes + (c.waived?.deletes ?? 0), held: counts.held + (c.held ?? 0),+ skippedContextualMode: counts.skippedContextualMode + (c.skippedContextualMode ?? 0), skippedCanonicalBytes: counts.skippedCanonicalBytes + (c.skippedCanonicalBytes ?? 0) });+ for (const index of drained.passLegacyWaived ?? []) legacyWaived.add(settledKey(entries[index]!.path, entries[index]!.level));sliceBase.pages += drained.index;roundSettled += drained.index;- foldReport(c.sizeStates, { contextualMode: c.skippedContextualMode, canonicalBytes: c.skippedCanonicalBytes });- for (const index of drained.legacyWaived ?? []) {- const entry = drained.entries[index] as PassEntry;- legacyWaived.add(settledKey(lastLevel?.scope ? `${lastLevel.scope}/${entry.path}` : entry.path, entry.level ?? null));- }++ foldReport(c.sizeStates);return null;}return drained;@@@ -511,10 -478,16 +509,17 @@@const stop = async (drained: SyncResult): Promise<SyncResult> => {Object.assign(counts, { added: counts.added + drained.added, modified: counts.modified + drained.modified, deleted: counts.deleted + drained.deleted,renamed: counts.renamed + drained.renamed, chunks: counts.chunks + drained.chunksCreated, waivedImports: counts.waivedImports + (drained.waived?.imports ?? 0),- waivedDeletes: counts.waivedDeletes + (drained.waived?.deletes ?? 0) });+ waivedDeletes: counts.waivedDeletes + (drained.waived?.deletes ?? 0), skippedContextualMode: counts.skippedContextualMode + (drained.legacySkips?.contextualMode ?? 0),+ skippedCanonicalBytes: counts.skippedCanonicalBytes + (drained.legacySkips?.canonicalBytes ?? 0) });sliceBase.pages += drained.filesImported ?? 0;- foldReport(drained.size_states, drained.legacySkips);- if (drained.reason === 'writer_yield') yieldSettled = roundSettled + (drained.managedCursor?.index ?? 0);++ foldReport(drained.size_states);+ // A slice that stops mid-batch (a writer yield, a deadline, an abort) settled the entries its cursor passed: they count as+ // settled and leave the round's remaining; a blocked stop reports what its replay reports.+ if (drained.status !== 'blocked_by_failures') {+ const passed = drained.managedCursor?.index ?? 0;+ yieldSettled = roundSettled + passed;+ value.telemetry.remaining = Math.max(0, value.telemetry.remaining - passed);+ }const outcome: PassOutcome = drained.status === 'blocked_by_failures' ? 'blocked' : 'resumable';const blockedOn = drained.managedWrite?.path ? drained.managedWrite.write_request.request_id : null;if (outcome === 'blocked' && blockedOn && obligations.blocked?.request_id !== blockedOn) obligations.blocked = { request_id: blockedOn, pass_id: passId };