/** * Shared identifiers for pi-context-epochs session entries and markers. * * All package-owned session artifacts are namespaced under * "pi-context-epochs/" so they can be recognized on reload, resume, * branch navigation, and by diagnostics tooling. */ /** details.kind marker persisted on package-owned epoch-boundary compaction entries. */ export const EPOCH_KIND = "pi-context-epochs/epoch"; /** EPOCH_DETAILS_VERSION of the epoch boundary payload format. */ export const EPOCH_DETAILS_VERSION = 1; /** custom entry type used to persist note write/delete events. */ export const NOTE_ENTRY_TYPE = "pi-context-epochs/note"; /** custom message type used for the continuation nudge after a model/manual rollover. */ export const CONTINUATION_MESSAGE_TYPE = "pi-context-epochs/continuation"; /** custom message type used for one-shot context-pressure reminders. */ export const REMINDER_MESSAGE_TYPE = "pi-context-epochs/reminder"; /** * customInstructions prefix that routes a manual compaction through the * package-owned epoch boundary instead of the native summarizer. * Only ever produced by this package (new_context tool, /epoch new). */ export const ROLLOVER_INSTRUCTIONS_PREFIX = "pi-context-epochs/rollover:"; /** * firstKeptEntryId used on epoch-boundary compactions. * * Pi entry ids are 8 hex characters, so this value can never match a real * entry. buildContextEntries() then keeps ONLY the compaction entry itself * plus entries appended after it - which is exactly "prior history fully * exits the active model context while the raw transcript stays intact". */ export const IMPOSSIBLE_FIRST_KEPT_ENTRY_ID = "ctx-epochs:none"; /** Default settings used when no config file exists or values are invalid. */ export interface EpochConfig { enabled: boolean; softRemainingRatio: number; criticalRemainingRatio: number; autoRollover: boolean; historySearchLimit: number; historyReadAround: number; historyMaxChars: number; noteMaxChars: number; continuationAnchorMaxChars: number; } export const DEFAULT_CONFIG: EpochConfig = { enabled: true, softRemainingRatio: 0.25, criticalRemainingRatio: 0.1, autoRollover: true, historySearchLimit: 8, historyReadAround: 2, historyMaxChars: 16_000, noteMaxChars: 8_000, continuationAnchorMaxChars: 2_000, }; export type EpochTrigger = "model" | "threshold" | "manual" | "overflow";