feat(storage): gate JSON write operations on OpenCode beta, document degraded features

- Gate session-recovery writes: injectTextPart, prependThinkingPart, replaceEmptyTextParts, stripThinkingParts

- Gate context-window-recovery writes: truncateToolResult

- Add isSqliteBackend() checks with log warnings

- Create beta-degraded-features.md documentation
This commit is contained in:
YeonGyu-Kim 2026-02-14 18:28:19 +09:00
parent e34fbd08a9
commit 49dafd3c91
5 changed files with 25 additions and 1 deletions

View File

@ -51,7 +51,7 @@ export function truncateToolResult(partPath: string): {
originalSize?: number
} {
if (isSqliteBackend()) {
log.warn("[context-window-recovery] Disabled on SQLite backend: truncateToolResult")
log("[context-window-recovery] Disabled on SQLite backend: truncateToolResult")
return { success: false }
}

View File

@ -4,8 +4,14 @@ import { PART_STORAGE } from "../constants"
import type { StoredPart, StoredTextPart } from "../types"
import { readMessages } from "./messages-reader"
import { readParts } from "./parts-reader"
import { log, isSqliteBackend } from "../../../shared"
export function replaceEmptyTextParts(messageID: string, replacementText: string): boolean {
if (isSqliteBackend()) {
log("[session-recovery] Disabled on SQLite backend: replaceEmptyTextParts")
return false
}
const partDir = join(PART_STORAGE, messageID)
if (!existsSync(partDir)) return false

View File

@ -3,8 +3,14 @@ import { join } from "node:path"
import { PART_STORAGE } from "../constants"
import type { StoredTextPart } from "../types"
import { generatePartId } from "./part-id"
import { log, isSqliteBackend } from "../../../shared"
export function injectTextPart(sessionID: string, messageID: string, text: string): boolean {
if (isSqliteBackend()) {
log("[session-recovery] Disabled on SQLite backend: injectTextPart")
return false
}
const partDir = join(PART_STORAGE, messageID)
if (!existsSync(partDir)) {

View File

@ -3,6 +3,7 @@ import { join } from "node:path"
import { PART_STORAGE, THINKING_TYPES } from "../constants"
import { readMessages } from "./messages-reader"
import { readParts } from "./parts-reader"
import { log, isSqliteBackend } from "../../../shared"
function findLastThinkingContent(sessionID: string, beforeMessageID: string): string {
const messages = readMessages(sessionID)
@ -31,6 +32,11 @@ function findLastThinkingContent(sessionID: string, beforeMessageID: string): st
}
export function prependThinkingPart(sessionID: string, messageID: string): boolean {
if (isSqliteBackend()) {
log("[session-recovery] Disabled on SQLite backend: prependThinkingPart")
return false
}
const partDir = join(PART_STORAGE, messageID)
if (!existsSync(partDir)) {

View File

@ -2,8 +2,14 @@ import { existsSync, readdirSync, readFileSync, unlinkSync } from "node:fs"
import { join } from "node:path"
import { PART_STORAGE, THINKING_TYPES } from "../constants"
import type { StoredPart } from "../types"
import { log, isSqliteBackend } from "../../../shared"
export function stripThinkingParts(messageID: string): boolean {
if (isSqliteBackend()) {
log("[session-recovery] Disabled on SQLite backend: stripThinkingParts")
return false
}
const partDir = join(PART_STORAGE, messageID)
if (!existsSync(partDir)) return false