From d746d57435ca90b6243d8445ffdf4706ea67d99b Mon Sep 17 00:00:00 2001 From: bowenliang123 Date: Sat, 10 Oct 2026 01:20:25 +0800 Subject: [PATCH] refactor(host): derive the fold bounds and drop the duplicated decode-tally aliases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FoldBounds restated six Config fields, DEFAULT_BOUNDS restated them again, and resolveBounds listed them a third time. Deriving the type from the defaults leaves one source for the bound vocabulary, and Config now composes Partial with Partial — which also declares defaultDeltaBase, a field the schema already carried while the interface omitted it. DecodeSpans and DecodeCounts were byte-identical aliases of the same record shape. --- src/host/config.ts | 38 +++++++++----------------------------- src/host/logShapes.ts | 8 ++------ 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/src/host/config.ts b/src/host/config.ts index 173239c..219e4f3 100644 --- a/src/host/config.ts +++ b/src/host/config.ts @@ -10,44 +10,24 @@ */ import z from '@deepseek-ai/schemastery' -import type { DefaultFileSort, DefaultGranularity, DefaultDurationCurve, DefaultPlacement, DefaultTrendMode, DefaultToolSort, InsightsEntry } from '../shared/types' +import type { PluginSettings } from '../shared/types' -export interface Config { - maxRequestSteps?: number - /** Newest whole-turn window kept; trimming crosses whole turns, never mid-turn. */ - maxKeptTurns?: number - maxEvents?: number - /** Pathological-session backstop only: each push ships the whole value (~150B/node). */ - maxNodes?: number - maxArchiveNodes?: number - maxFileOps?: number - defaultPlacement?: DefaultPlacement - defaultGranularity?: DefaultGranularity - defaultTrendMode?: DefaultTrendMode - defaultToolSort?: DefaultToolSort - defaultFileSort?: DefaultFileSort - insightsEntry?: InsightsEntry - defaultDurationCurve?: DefaultDurationCurve -} - -export interface FoldBounds { - maxRequestSteps: number - maxKeptTurns: number - maxEvents: number - maxNodes: number - maxArchiveNodes: number - maxFileOps: number -} - -export const DEFAULT_BOUNDS: FoldBounds = { +export const DEFAULT_BOUNDS = { maxRequestSteps: 1500, + /** Newest whole-turn window kept; trimming crosses whole turns, never mid-turn. */ maxKeptTurns: 300, maxEvents: 400, + /** Pathological-session backstop only: each push ships the whole value (~150B/node). */ maxNodes: 2000, maxArchiveNodes: 400, maxFileOps: 400, } +/** The resolved fold bounds; derived from {@link DEFAULT_BOUNDS} so the two cannot drift. */ +export type FoldBounds = typeof DEFAULT_BOUNDS + +export type Config = Partial & Partial + /** Mark a field live-editable where the harness's schemastery ships `.volatile()`; a plain * field where the modifier is absent, so one schema serves every harness the gate admits. */ export function volatileField(field: S): S { diff --git a/src/host/logShapes.ts b/src/host/logShapes.ts index ddc8a06..23ac536 100644 --- a/src/host/logShapes.ts +++ b/src/host/logShapes.ts @@ -37,13 +37,9 @@ export function decodeKindOfBlock(blockType: unknown): DecodeKind | undefined { return undefined } -type DecodeSpans = Record - -type DecodeCounts = Record - export interface DecodeTally { - spans: DecodeSpans - blocks: DecodeCounts + spans: Record + blocks: Record } /** Decode spans and `block-start` counts inside one embedded assistant stream, tiling