You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(core): validate maxHistory option and document hierarchyDepth: 0 behaviour #254
Two small API hardening improvements surfaced during a code audit:
1. maxHistory accepts invalid values silently
createAskableContext({ maxHistory: -1 }) stores -1 without error. The history cap check then behaves oddly (history.length > -1 is always true, so every push trims the array immediately). Passing NaN falls through to the default of 50 silently.
Fix: Add a runtime guard in the constructor:
if(options?.maxHistory!==undefined&&(options.maxHistory<0||!Number.isInteger(options.maxHistory))){thrownewRangeError('maxHistory must be a non-negative integer');}
2. hierarchyDepth: 0 is undocumented
Passing hierarchyDepth: 0 to any serialization method returns an empty ancestors array (all ancestor context is suppressed). This is intentional and the implementation is correct, but it is not documented in the type definition or API docs, so users may be confused when their ancestors disappear.
Fix: Add a JSDoc note to AskablePromptContextOptions.hierarchyDepth:
/** * Maximum number of ancestor segments to include. * Pass `0` to suppress all ancestor context. * Defaults to unlimited. */
hierarchyDepth?: number;
Acceptance criteria
createAskableContext({ maxHistory: -1 }) throws a RangeError
createAskableContext({ maxHistory: NaN }) throws a RangeError
hierarchyDepth JSDoc clarifies that 0 suppresses all ancestors
Existing tests pass; new tests cover the invalid-maxHistory cases
Activity
fix: audit fixes for sanitizer leaks, context cleanup, and listener t…