MCPcopy
hub / github.com/codeaashu/claude-code / partitionByPriorDecision

Function partitionByPriorDecision

src/utils/toolResultStorage.ts:649–667  ·  view source on GitHub ↗

* Partition candidates by their prior decision state: * - mustReapply: previously replaced → re-apply the cached replacement for * prefix stability * - frozen: previously seen and left unreplaced → off-limits (replacing * now would change a prefix that was already cached) * - fresh: ne

(
  candidates: ToolResultCandidate[],
  state: ContentReplacementState,
)

Source from the content-addressed store, hash-verified

647 * - fresh: never seen → eligible for new replacement decisions
648 */
649function partitionByPriorDecision(
650 candidates: ToolResultCandidate[],
651 state: ContentReplacementState,
652): CandidatePartition {
653 return candidates.reduce<CandidatePartition>(
654 (acc, c) => {
655 const replacement = state.replacements.get(c.toolUseId)
656 if (replacement !== undefined) {
657 acc.mustReapply.push({ ...c, replacement })
658 } else if (state.seenIds.has(c.toolUseId)) {
659 acc.frozen.push(c)
660 } else {
661 acc.fresh.push(c)
662 }
663 return acc
664 },
665 { mustReapply: [], frozen: [], fresh: [] },
666 )
667}
668
669/**
670 * Pick the largest fresh results to replace until the model-visible total

Callers 1

enforceToolResultBudgetFunction · 0.85

Calls 3

getMethod · 0.65
pushMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected