Skip to content

Commit 719e665

Browse files
committed
chore: apply biome format autofixes for plan v6 stack
1 parent 9e28f7e commit 719e665

12 files changed

Lines changed: 26 additions & 74 deletions

packages/plugin/src/features/magic-context/migrations.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,7 @@ const MIGRATIONS: Migration[] = [
510510
// NULL — see `getSessionsWithPendingMarker` / `healNullTextColumns`
511511
// contracts in storage-db.ts. Plan v6 §3.
512512
if (!cols.some((c) => c.name === "pending_compaction_marker_state")) {
513-
db.exec(
514-
"ALTER TABLE session_meta ADD COLUMN pending_compaction_marker_state TEXT",
515-
);
513+
db.exec("ALTER TABLE session_meta ADD COLUMN pending_compaction_marker_state TEXT");
516514
}
517515
},
518516
},

packages/plugin/src/features/magic-context/storage-meta-persisted.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { sessionLog } from "../../shared/logger";
22
import type { Database } from "../../shared/sqlite";
3-
import { stableStringify } from '../../shared/stable-json';
3+
import { stableStringify } from "../../shared/stable-json";
44
import { ensureSessionMetaRow } from "./storage-meta-shared";
55
import type { ContextUsage } from "./types";
66

@@ -706,7 +706,6 @@ export function removeStrippedPlaceholderId(
706706
return true;
707707
}
708708

709-
710709
// ── Pending compaction marker state (plan v6 deferred drain) ──
711710

712711
/**
@@ -749,9 +748,7 @@ export function getPendingCompactionMarkerState(
749748
sessionId: string,
750749
): PendingCompactionMarker | null {
751750
const row = db
752-
.prepare(
753-
"SELECT pending_compaction_marker_state FROM session_meta WHERE session_id = ?",
754-
)
751+
.prepare("SELECT pending_compaction_marker_state FROM session_meta WHERE session_id = ?")
755752
.get(sessionId) as { pending_compaction_marker_state?: string | null } | null;
756753
const raw = row?.pending_compaction_marker_state;
757754
// Defensive: NULL is the canonical absence, but legacy / cross-version

packages/plugin/src/features/magic-context/storage-meta.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ export {
99
clearPersistedStickyTurnReminder,
1010
clearPersistedTodoSyntheticAnchor,
1111
getHistorianFailureState,
12-
getPendingCompactionMarkerState,
13-
getSessionsWithPendingMarker,
1412
getNoteLastReadAt,
1513
getOverflowState,
14+
getPendingCompactionMarkerState,
1615
getPersistedNoteNudge,
1716
getPersistedNudgePlacement,
1817
getPersistedReasoningWatermark,
1918
getPersistedStickyTurnReminder,
2019
getPersistedTodoSyntheticAnchor,
20+
getSessionsWithPendingMarker,
2121
getStrippedPlaceholderIds,
2222
incrementHistorianFailure,
2323
loadPersistedUsage,

packages/plugin/src/features/magic-context/storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ export {
4141
getOverflowState,
4242
getPendingCompactionMarkerState,
4343
getPersistedNoteNudge,
44-
getSessionsWithPendingMarker,
4544
getPersistedNudgePlacement,
4645
getPersistedReasoningWatermark,
4746
getPersistedStickyTurnReminder,
4847
getPersistedTodoSyntheticAnchor,
48+
getSessionsWithPendingMarker,
4949
getStrippedPlaceholderIds,
5050
incrementHistorianFailure,
5151
loadPersistedUsage,

packages/plugin/src/features/magic-context/tool-definition-tokens.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import { createHash } from "node:crypto";
4242
import { estimateTokens } from "../../hooks/magic-context/read-session-formatting";
4343
import type { Database, Statement } from "../../shared/sqlite";
44-
import { stableStringify } from '../../shared/stable-json';
44+
import { stableStringify } from "../../shared/stable-json";
4545

4646
// Inner map: toolID → measured tokens for that tool (description + params).
4747
// Outer map: composite key → per-tool breakdown.

packages/plugin/src/hooks/magic-context/compaction-marker-manager.test.ts

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,13 @@ function createOpenCodeDb(dataHome: string): Database {
6060
return db;
6161
}
6262

63-
function insertUserMessage(
64-
db: Database,
65-
id: string,
66-
sessionId: string,
67-
timeCreated: number,
68-
): void {
63+
function insertUserMessage(db: Database, id: string, sessionId: string, timeCreated: number): void {
6964
db.prepare(
7065
"INSERT INTO message (id, session_id, time_created, time_updated, data) VALUES (?, ?, ?, ?, ?)",
7166
).run(id, sessionId, timeCreated, timeCreated, JSON.stringify({ role: "user" }));
7267
}
7368

74-
function makePending(
75-
overrides: Partial<PendingCompactionMarker> = {},
76-
): PendingCompactionMarker {
69+
function makePending(overrides: Partial<PendingCompactionMarker> = {}): PendingCompactionMarker {
7770
return {
7871
ordinal: 10,
7972
endMessageId: "msg-boundary",
@@ -122,12 +115,7 @@ describe("applyDeferredCompactionMarker — outcomes", () => {
122115
// Seed session_meta row so the manager can write boundary state into it.
123116
db.prepare("INSERT INTO session_meta (session_id) VALUES (?)").run("ses-1");
124117

125-
const outcome = applyDeferredCompactionMarker(
126-
db,
127-
"ses-1",
128-
makePending(),
129-
dataHome,
130-
);
118+
const outcome = applyDeferredCompactionMarker(db, "ses-1", makePending(), dataHome);
131119

132120
expect(outcome.kind).toBe("applied");
133121
if (outcome.kind === "applied") {
@@ -180,12 +168,7 @@ describe("applyDeferredCompactionMarker — outcomes", () => {
180168
insertCompartment(db, "ses-1", 10, "msg-boundary");
181169
db.prepare("INSERT INTO session_meta (session_id) VALUES (?)").run("ses-1");
182170

183-
const outcome = applyDeferredCompactionMarker(
184-
db,
185-
"ses-1",
186-
makePending(),
187-
dataHome,
188-
);
171+
const outcome = applyDeferredCompactionMarker(db, "ses-1", makePending(), dataHome);
189172

190173
expect(outcome.kind).toBe("stale-skip");
191174
if (outcome.kind === "stale-skip") {
@@ -203,12 +186,7 @@ describe("applyDeferredCompactionMarker — outcomes", () => {
203186
// No compartment inserted — simulates a recomp that wiped local state
204187
db.prepare("INSERT INTO session_meta (session_id) VALUES (?)").run("ses-1");
205188

206-
const outcome = applyDeferredCompactionMarker(
207-
db,
208-
"ses-1",
209-
makePending(),
210-
dataHome,
211-
);
189+
const outcome = applyDeferredCompactionMarker(db, "ses-1", makePending(), dataHome);
212190

213191
expect(outcome.kind).toBe("stale-skip");
214192
if (outcome.kind === "stale-skip") {
@@ -265,25 +243,14 @@ describe("applyDeferredCompactionMarker — outcomes", () => {
265243
.prepare(
266244
"INSERT INTO message (id, session_id, time_created, time_updated, data) VALUES (?, ?, ?, ?, ?)",
267245
)
268-
.run(
269-
"msg-boundary",
270-
"ses-1",
271-
1_000,
272-
1_000,
273-
JSON.stringify({ role: "assistant" }),
274-
);
246+
.run("msg-boundary", "ses-1", 1_000, 1_000, JSON.stringify({ role: "assistant" }));
275247
closeQuietly(opencodeDb);
276248

277249
const db = openDatabase();
278250
insertCompartment(db, "ses-1", 10, "msg-boundary");
279251
db.prepare("INSERT INTO session_meta (session_id) VALUES (?)").run("ses-1");
280252

281-
const outcome = applyDeferredCompactionMarker(
282-
db,
283-
"ses-1",
284-
makePending(),
285-
dataHome,
286-
);
253+
const outcome = applyDeferredCompactionMarker(db, "ses-1", makePending(), dataHome);
287254

288255
// No user message exists at or before the boundary → inject returns
289256
// null → retryable-failure.
@@ -307,12 +274,7 @@ describe("applyDeferredCompactionMarker — outcomes", () => {
307274
insertCompartment(db, "ses-1", 10, "msg-boundary");
308275
db.prepare("INSERT INTO session_meta (session_id) VALUES (?)").run("ses-1");
309276

310-
const outcome = applyDeferredCompactionMarker(
311-
db,
312-
"ses-1",
313-
makePending(),
314-
dataHome,
315-
);
277+
const outcome = applyDeferredCompactionMarker(db, "ses-1", makePending(), dataHome);
316278

317279
expect(outcome.kind).toBe("retryable-failure");
318280
});

packages/plugin/src/hooks/magic-context/compartment-runner-partial-recomp.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,7 @@ export async function executePartialRecompInternal(
337337
// prior in-flight incremental publish may have left behind — partial
338338
// recomp now owns the boundary up to lastEnd.
339339
if (deps.experimentalCompactionMarkers && lastEnd > 0) {
340-
updateCompactionMarkerAfterPublication(
341-
db,
342-
sessionId,
343-
lastEnd,
344-
deps.directory,
345-
);
340+
updateCompactionMarkerAfterPublication(db, sessionId, lastEnd, deps.directory);
346341
const stalePending = getPendingCompactionMarkerState(db, sessionId);
347342
if (stalePending) {
348343
clearPendingCompactionMarkerStateIf(db, sessionId, stalePending);

packages/plugin/src/hooks/magic-context/event-handler.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { createCompactionHandler } from "../../features/magic-context/compaction";
22
import { scheduleClearAndReindex } from "../../features/magic-context/message-index-async";
33
import { detectOverflow } from "../../features/magic-context/overflow-detection";
4-
import { clearPendingCompactionMarkerStateIf, getPendingCompactionMarkerState } from '../../features/magic-context/storage';
54
import {
65
clearHistorianFailureState,
6+
clearPendingCompactionMarkerStateIf,
77
clearPersistedNoteNudge,
88
clearPersistedNudgePlacement,
99
clearPersistedStickyTurnReminder,
@@ -14,6 +14,7 @@ import {
1414
getMaxTagNumberBySession,
1515
getOrCreateSessionMeta,
1616
getOverflowState,
17+
getPendingCompactionMarkerState,
1718
getPersistedNoteNudge,
1819
getPersistedNudgePlacement,
1920
getPersistedReasoningWatermark,
@@ -29,7 +30,6 @@ import type { Tagger } from "../../features/magic-context/tagger";
2930
import type { ContextUsage } from "../../features/magic-context/types";
3031
import { log, sessionLog } from "../../shared/logger";
3132
import { removeCompactionMarkerForSession } from "./compaction-marker-manager";
32-
import { resetDegradedCacheCount } from "./transform-postprocess-phase";
3333
import { checkCompartmentTrigger } from "./compartment-trigger";
3434
import { deriveTriggerBudget } from "./derive-budgets";
3535
import {
@@ -50,6 +50,7 @@ import { clearNoteNudgeState } from "./note-nudger";
5050
import { readRawSessionMessages } from "./read-session-chunk";
5151
import { clearMessageTokensCache, type NudgePlacementStore } from "./transform";
5252
import { clearCompressorCooldown } from "./transform-compartment-phase";
53+
import { resetDegradedCacheCount } from "./transform-postprocess-phase";
5354

5455
const CONTEXT_USAGE_TTL_MS = 60 * 60 * 1000;
5556

packages/plugin/src/hooks/magic-context/hook.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import {
1515
} from "../../features/magic-context/dreamer";
1616
import { resolveProjectIdentity } from "../../features/magic-context/memory/project-identity";
1717
import type { Scheduler } from "../../features/magic-context/scheduler";
18-
import { getSessionsWithPendingMarker } from '../../features/magic-context/storage';
1918
import {
2019
getDatabasePersistenceError,
20+
getSessionsWithPendingMarker,
2121
isDatabasePersisted,
2222
openDatabase,
2323
} from "../../features/magic-context/storage";

packages/plugin/src/hooks/magic-context/transform-postprocess-phase.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -905,10 +905,7 @@ export async function runPostTransformPhase(
905905
// only conditionally suppress it when the marker apply returned
906906
// `retryable-failure`, so the next consuming pass retries.
907907
let suppressV12HistoryDrain = false;
908-
if (
909-
historyWasConsumedThisPass &&
910-
args.deferredHistoryRefreshSessions.has(args.sessionId)
911-
) {
908+
if (historyWasConsumedThisPass && args.deferredHistoryRefreshSessions.has(args.sessionId)) {
912909
const pending = getPendingCompactionMarkerState(args.db, args.sessionId);
913910
if (pending) {
914911
const outcome = applyDeferredCompactionMarker(

0 commit comments

Comments
 (0)