refactor(host): derive the fold bounds and drop the duplicated decode-tally aliases
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<FoldBounds> with Partial<PluginSettings> — 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.
This commit is contained in:
1 parent
c4f5500de7
commit
d746d57435
2 files changed
+11
-35
No files matched your search
+9
-29
@@ -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<FoldBounds> & Partial<PluginSettings>
|
||||
|
||||
/** 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<S extends z>(field: S): S {
|
||||
|
||||
@@ -37,13 +37,9 @@ export function decodeKindOfBlock(blockType: unknown): DecodeKind | undefined {
|
||||
return undefined
|
||||
}
|
||||
|
||||
type DecodeSpans = Record<DecodeKind, number>
|
||||
|
||||
type DecodeCounts = Record<DecodeKind, number>
|
||||
|
||||
export interface DecodeTally {
|
||||
spans: DecodeSpans
|
||||
blocks: DecodeCounts
|
||||
spans: Record<DecodeKind, number>
|
||||
blocks: Record<DecodeKind, number>
|
||||
}
|
||||
|
||||
/** Decode spans and `block-start` counts inside one embedded assistant stream, tiling
|
||||
|
||||
Reference in new issue
Block a user