Skip to content

Commit 477d403

Browse files
Merge pull request #1401 from corbitsdev/cl-10512-compactor-noop-const
refactor(session): replace compactorNoOpFloor with a constant
2 parents 32144c0 + 21d007b commit 477d403

6 files changed

Lines changed: 16 additions & 18 deletions

File tree

‎src/agent/compaction.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
import {
2525
COMPACT_SPACER_TEXT,
2626
LEGACY_COMPACT_SPACER_TEXT,
27-
compactorNoOpFloor,
27+
COMPACT_NOOP_FLOOR,
2828
} from "../session/compactor.js";
2929
import { buildSummaryPrompt } from "../session/summarizer.js";
3030

@@ -509,7 +509,7 @@ describe("compaction governor", () => {
509509

510510
test("never arms at the exact turn count createPruningCompactor no-ops on", () => {
511511
// The compactor's own no-op floor; arming at or below it spends a cycle that shrinks nothing.
512-
const floor = compactorNoOpFloor();
512+
const floor = COMPACT_NOOP_FLOOR;
513513
const governor = createCompactionGovernor(() => undefined);
514514
governor.noteInferenceDone(
515515
inferenceDone(overThreshold),
@@ -521,7 +521,7 @@ describe("compaction governor", () => {
521521
});
522522

523523
test("arms one turn past the floor createPruningCompactor no-ops on", () => {
524-
const floor = compactorNoOpFloor();
524+
const floor = COMPACT_NOOP_FLOOR;
525525
const governor = createCompactionGovernor(() => undefined);
526526
governor.noteInferenceDone(
527527
inferenceDone(overThreshold),

‎src/agent/compaction.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from "../provider/context-window.js";
1515
import {
1616
assistantTextIsCompactSpacerEcho,
17-
compactorNoOpFloor,
17+
COMPACT_NOOP_FLOOR,
1818
isCompactSpacerEchoTurn,
1919
} from "../session/compactor.js";
2020
import {
@@ -24,9 +24,9 @@ import {
2424
import { onTurnBoundary } from "./reactor-events.js";
2525

2626
const COMPACTOR_NAME = "pruning-compactor";
27-
// Compactor no-op floor, from the same helper so it cannot drift; arming
27+
// Compactor no-op floor, shared from the compactor so it cannot drift; arming
2828
// at or below spends a cycle that shrinks nothing.
29-
const MIN_TURNS_TO_COMPACT = compactorNoOpFloor();
29+
const MIN_TURNS_TO_COMPACT = COMPACT_NOOP_FLOOR;
3030
// Cap overflow retries so an unshrinkable history cannot loop forever;
3131
// cleared once usage drops back under the watermark.
3232
const MAX_OVERFLOW_RECOVERIES = 2;

‎src/agent/director.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { createPermissionGate } from "../permission/gate.js";
2323
import {
2424
COMPACT_SPACER_TEXT,
2525
LEGACY_COMPACT_SPACER_TEXT,
26-
compactorNoOpFloor,
26+
COMPACT_NOOP_FLOOR,
2727
} from "../session/compactor.js";
2828
import {
2929
INFERENCE_ABORT_INTERNAL_RECOVERY,
@@ -785,7 +785,7 @@ function makeToolErrorEvent(callId: string, content: string) {
785785
// One turn past the compactor's no-op floor (session/compactor.ts), so the
786786
// arming check finds history actually worth compacting.
787787
const longState = {
788-
turns: Array.from({ length: compactorNoOpFloor() + 1 }, () => ({
788+
turns: Array.from({ length: COMPACT_NOOP_FLOOR + 1 }, () => ({
789789
role: "user",
790790
content: [],
791791
timestamp: 0,

‎src/context-compactor.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defined } from "../testkit/defined.js";
22
import { describe, test, expect } from "bun:test";
33
import {
44
createPruningCompactor,
5-
compactorNoOpFloor,
5+
COMPACT_NOOP_FLOOR,
66
buildTurnSummary,
77
COMPACTED_PREFIX,
88
COMPACT_SPACER_TEXT,
@@ -93,15 +93,15 @@ describe("createPruningCompactor", () => {
9393
expect(result.output).toBe(turns); // Same reference when no compaction needed
9494
});
9595

96-
test("compactorNoOpFloor names the exact turn count apply() no-ops on", async () => {
97-
// The compaction governor derives its arming floor from this function so
96+
test("COMPACT_NOOP_FLOOR names the exact turn count apply() no-ops on", async () => {
97+
// The compaction governor derives its arming floor from this constant so
9898
// it never arms a compaction guaranteed to no-op; changing apply()'s
9999
// no-op condition without updating the floor breaks that guarantee
100100
// silently.
101101
const compactor = smallCompactor({
102102
summaryMaxChars: 500,
103103
});
104-
const floor = compactorNoOpFloor();
104+
const floor = COMPACT_NOOP_FLOOR;
105105

106106
// Bodies exceed the pinned tail budget, so past-floor always has a folded
107107
// region while at-floor still no-ops on the count check alone.

‎src/session/compactor.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ function extraInstructionParameter(
112112
}
113113

114114
// `apply` no-ops at or below this turn count: one turn cannot shrink.
115-
export function compactorNoOpFloor(): number {
116-
return 1;
117-
}
115+
export const COMPACT_NOOP_FLOOR = 1;
118116

119117
// Query tools dedup by full-argument identity: a later identical call
120118
// reflects newer workspace state, so older results are stale. run_shell is
@@ -884,7 +882,7 @@ export function createPruningCompactor(
884882
// Prior compacted summaries fold into the next handoff, not frozen.
885883
const shape = resolveCompactionShape(cfg.compactionShape);
886884

887-
if (turns.length <= compactorNoOpFloor()) {
885+
if (turns.length <= COMPACT_NOOP_FLOOR) {
888886
return {
889887
output: turns,
890888
record: {

‎src/subagent/nudge-director.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
ReactorState,
77
} from "@intx/types/runtime";
88
import { createCorbitsRetryPolicy } from "../agent/retry-policy.js";
9-
import { compactorNoOpFloor } from "../session/compactor.js";
9+
import { COMPACT_NOOP_FLOOR } from "../session/compactor.js";
1010
import { SubAgentDirector } from "./nudge-director.js";
1111
import type { AdmissionQueue } from "./admission.js";
1212
import { createTestCapabilities } from "./director-test-harness.js";
@@ -19,7 +19,7 @@ import {
1919

2020
const state = { turns: [] } as unknown as ReactorState;
2121
const longState = {
22-
turns: Array.from({ length: compactorNoOpFloor() + 1 }, () => ({
22+
turns: Array.from({ length: COMPACT_NOOP_FLOOR + 1 }, () => ({
2323
role: "user",
2424
content: [],
2525
timestamp: 0,

0 commit comments

Comments
 (0)