11#!/usr/bin/env node
22process.env.VISOR_VERSION = '0.1.42';
33process.env.PROBE_VERSION = '0.6.0-rc201';
4- process.env.VISOR_COMMIT_SHA = '57b6a087992acc17594f92f29a6b92d1fac09d5e ';
5- process.env.VISOR_COMMIT_SHORT = '57b6a087 ';
4+ process.env.VISOR_COMMIT_SHA = '202fcaa45d1de898a8ce2b798cdeae175a8f6beb ';
5+ process.env.VISOR_COMMIT_SHORT = '202fcaa4 ';
66/******/ (() => { // webpackBootstrap
77/******/ var __webpack_modules__ = ({
88
@@ -175775,13 +175775,21 @@ async function executeCheckWithForEachItems(checkId, forEachParent, forEachItems
175775175775Object.defineProperty(exports, "__esModule", ({ value: true }));
175776175776exports.buildOutputHistoryFromJournal = buildOutputHistoryFromJournal;
175777175777const logger_1 = __nccwpck_require__(86999);
175778+ function getHistoryLimit() {
175779+ const raw = process.env.VISOR_TEST_HISTORY_LIMIT || process.env.VISOR_OUTPUT_HISTORY_LIMIT;
175780+ if (!raw)
175781+ return undefined;
175782+ const n = parseInt(raw, 10);
175783+ return Number.isFinite(n) && n > 0 ? n : undefined;
175784+ }
175778175785/**
175779175786 * Build output history Map from journal for template rendering
175780175787 * This matches the format expected by AI providers.
175781175788 * Moved from LevelDispatch to reduce file size and improve reuse.
175782175789 */
175783175790function buildOutputHistoryFromJournal(context) {
175784175791 const outputHistory = new Map();
175792+ const limit = getHistoryLimit();
175785175793 try {
175786175794 const snapshot = context.journal.beginSnapshot();
175787175795 const allEntries = context.journal.readVisible(context.sessionId, snapshot, undefined);
@@ -175811,8 +175819,13 @@ function buildOutputHistoryFromJournal(context) {
175811175819 }
175812175820 }
175813175821 catch { }
175814- if (payload !== undefined)
175815- outputHistory.get(checkId).push(payload);
175822+ if (payload !== undefined) {
175823+ const arr = outputHistory.get(checkId);
175824+ arr.push(payload);
175825+ if (limit && arr.length > limit) {
175826+ arr.splice(0, arr.length - limit);
175827+ }
175828+ }
175816175829 }
175817175830 }
175818175831 catch (error) {
@@ -177160,12 +177173,20 @@ function recordOnFinishRoutingEvent(args) {
177160177173 attrs.goto_event = args.gotoEvent;
177161177174 (0, trace_helpers_1.addEvent)('visor.routing', attrs);
177162177175}
177176+ function getHistoryLimit() {
177177+ const raw = process.env.VISOR_TEST_HISTORY_LIMIT || process.env.VISOR_OUTPUT_HISTORY_LIMIT;
177178+ if (!raw)
177179+ return undefined;
177180+ const n = parseInt(raw, 10);
177181+ return Number.isFinite(n) && n > 0 ? n : undefined;
177182+ }
177163177183/**
177164177184 * Build output history Map from journal for template rendering
177165177185 * This matches the format expected by AI providers
177166177186 */
177167177187function buildOutputHistoryFromJournal(context) {
177168177188 const outputHistory = new Map();
177189+ const limit = getHistoryLimit();
177169177190 try {
177170177191 const snapshot = context.journal.beginSnapshot();
177171177192 const allEntries = context.journal.readVisible(context.sessionId, snapshot, undefined);
@@ -177179,8 +177200,13 @@ function buildOutputHistoryFromJournal(context) {
177179177200 // code-review where issues are returned directly). This ensures
177180177201 // outputs_history['security'].last.issues[...] works in prompts and tests.
177181177202 const payload = entry.result.output !== undefined ? entry.result.output : entry.result;
177182- if (payload !== undefined)
177183- outputHistory.get(checkId).push(payload);
177203+ if (payload !== undefined) {
177204+ const arr = outputHistory.get(checkId);
177205+ arr.push(payload);
177206+ if (limit && arr.length > limit) {
177207+ arr.splice(0, arr.length - limit);
177208+ }
177209+ }
177184177210 }
177185177211 }
177186177212 catch (error) {
@@ -180316,6 +180342,13 @@ function createMemoryHelpers() {
180316180342 },
180317180343 };
180318180344}
180345+ function getHistoryLimit() {
180346+ const raw = process.env.VISOR_TEST_HISTORY_LIMIT || process.env.VISOR_OUTPUT_HISTORY_LIMIT;
180347+ if (!raw)
180348+ return undefined;
180349+ const n = parseInt(raw, 10);
180350+ return Number.isFinite(n) && n > 0 ? n : undefined;
180351+ }
180319180352function formatScopeLabel(scope) {
180320180353 if (!scope || scope.length === 0)
180321180354 return '';
@@ -181168,6 +181201,7 @@ async function processOnFail(checkId, scope, result, checkConfig, context, state
181168181201async function evaluateRunJs(runJs, checkId, checkConfig, result, context, _state) {
181169181202 try {
181170181203 const sandbox = (0, sandbox_1.createSecureSandbox)();
181204+ const historyLimit = getHistoryLimit();
181171181205 // Build outputs record and outputs_history
181172181206 const snapshotId = context.journal.beginSnapshot();
181173181207 const contextView = new ((__nccwpck_require__(3355).ContextView))(context.journal, context.sessionId, snapshotId, [], context.event);
@@ -181193,8 +181227,11 @@ async function evaluateRunJs(runJs, checkId, checkConfig, result, context, _stat
181193181227 try {
181194181228 const history = contextView.getHistory(checkIdFromJournal);
181195181229 if (history && history.length > 0) {
181230+ const trimmed = historyLimit && history.length > historyLimit
181231+ ? history.slice(history.length - historyLimit)
181232+ : history;
181196181233 // Extract outputs from history (prefer output field if available)
181197- outputsHistory[checkIdFromJournal] = history .map((r) => r.output !== undefined ? r.output : r);
181234+ outputsHistory[checkIdFromJournal] = trimmed .map((r) => r.output !== undefined ? r.output : r);
181198181235 }
181199181236 }
181200181237 catch {
@@ -181282,6 +181319,7 @@ async function evaluateGoto(gotoJs, gotoStatic, checkId, checkConfig, result, co
181282181319 if (gotoJs) {
181283181320 try {
181284181321 const sandbox = (0, sandbox_1.createSecureSandbox)();
181322+ const historyLimit = getHistoryLimit();
181285181323 // Build outputs record and outputs_history from the full session snapshot.
181286181324 // Do not filter by event here — on_finish (especially forEach post-children) may
181287181325 // need to see results committed under different event triggers within the same run.
@@ -181309,8 +181347,11 @@ async function evaluateGoto(gotoJs, gotoStatic, checkId, checkConfig, result, co
181309181347 try {
181310181348 const history = contextView.getHistory(checkIdFromJournal);
181311181349 if (history && history.length > 0) {
181350+ const trimmed = historyLimit && history.length > historyLimit
181351+ ? history.slice(history.length - historyLimit)
181352+ : history;
181312181353 // Extract outputs from history (prefer output field if available)
181313- outputsHistory[checkIdFromJournal] = history .map((r) => r.output !== undefined ? r.output : r);
181354+ outputsHistory[checkIdFromJournal] = trimmed .map((r) => r.output !== undefined ? r.output : r);
181314181355 }
181315181356 }
181316181357 catch {
@@ -181430,6 +181471,7 @@ async function evaluateTransitions(transitions, checkId, checkConfig, result, co
181430181471 return undefined;
181431181472 try {
181432181473 const sandbox = (0, sandbox_1.createSecureSandbox)();
181474+ const historyLimit = getHistoryLimit();
181433181475 // Build outputs record and outputs_history from the full session snapshot
181434181476 const snapshotId = context.journal.beginSnapshot();
181435181477 const ContextView = (__nccwpck_require__(3355).ContextView);
@@ -181448,7 +181490,10 @@ async function evaluateTransitions(transitions, checkId, checkConfig, result, co
181448181490 try {
181449181491 const hist = view.getHistory(cid);
181450181492 if (hist && hist.length > 0) {
181451- outputsHistory[cid] = hist.map((r) => (r.output !== undefined ? r.output : r));
181493+ const trimmed = historyLimit && hist.length > historyLimit
181494+ ? hist.slice(hist.length - historyLimit)
181495+ : hist;
181496+ outputsHistory[cid] = trimmed.map((r) => r.output !== undefined ? r.output : r);
181452181497 }
181453181498 }
181454181499 catch { }
@@ -185350,6 +185395,7 @@ const config_1 = __nccwpck_require__(22973);
185350185395const state_machine_execution_engine_1 = __nccwpck_require__(39004);
185351185396const github_recorder_1 = __nccwpck_require__(81493);
185352185397const memory_store_1 = __nccwpck_require__(18216);
185398+ const session_registry_1 = __nccwpck_require__(46059);
185353185399const global_recorder_1 = __nccwpck_require__(54325);
185354185400const flow_stage_1 = __nccwpck_require__(12758);
185355185401const test_execution_wrapper_1 = __nccwpck_require__(30392);
@@ -185358,6 +185404,16 @@ const environment_1 = __nccwpck_require__(13228);
185358185404const mocks_1 = __nccwpck_require__(20490);
185359185405const fixture_1 = __nccwpck_require__(29716);
185360185406const validator_1 = __nccwpck_require__(8075);
185407+ function ensureTestEnvDefaults() {
185408+ if (!process.env.VISOR_TEST_MODE)
185409+ process.env.VISOR_TEST_MODE = 'true';
185410+ if (!process.env.VISOR_TEST_PROMPT_MAX_CHARS) {
185411+ process.env.VISOR_TEST_PROMPT_MAX_CHARS = process.env.CI === 'true' ? '4000' : '8000';
185412+ }
185413+ if (!process.env.VISOR_TEST_HISTORY_LIMIT) {
185414+ process.env.VISOR_TEST_HISTORY_LIMIT = process.env.CI === 'true' ? '200' : '500';
185415+ }
185416+ }
185361185417/**
185362185418 * Very small glob-to-RegExp converter supporting **, *, and ?
185363185419 * - ** matches across path separators
@@ -185487,6 +185543,7 @@ function discoverSuites(rootOrPattern, cwd = process.cwd()) {
185487185543 return Array.from(new Set(suites)).sort((a, b) => a.localeCompare(b));
185488185544}
185489185545async function runSuites(files, options) {
185546+ ensureTestEnvDefaults();
185490185547 const perSuite = [];
185491185548 let failedSuites = 0;
185492185549 let totalCases = 0;
@@ -185613,6 +185670,11 @@ class VisorTestRunner {
185613185670 memory_store_1.MemoryStore.resetInstance();
185614185671 }
185615185672 catch { }
185673+ // Always clear AI sessions between cases to prevent cross-case leakage
185674+ try {
185675+ session_registry_1.SessionRegistry.getInstance().clearAllSessions();
185676+ }
185677+ catch { }
185616185678 // Always use StateMachineExecutionEngine
185617185679 const engine = new state_machine_execution_engine_1.StateMachineExecutionEngine(undefined, recorder);
185618185680 try {
@@ -185996,7 +186058,10 @@ class VisorTestRunner {
185996186058 const defaultStrict = defaultsAny?.strict !== false;
185997186059 const aiProviderDefault = defaultsAny?.ai_provider || 'mock';
185998186060 const ghRec = defaultsAny?.github_recorder;
185999- const defaultPromptCap = options.promptMaxChars ||
186061+ const envPromptCapRaw = process.env.VISOR_TEST_PROMPT_MAX_CHARS;
186062+ const envPromptCap = envPromptCapRaw ? parseInt(envPromptCapRaw, 10) : undefined;
186063+ const defaultPromptCap = options.promptMaxChars ??
186064+ (Number.isFinite(envPromptCap) ? envPromptCap : undefined) ??
186000186065 (typeof defaultsAny?.prompt_max_chars === 'number'
186001186066 ? defaultsAny.prompt_max_chars
186002186067 : undefined);
@@ -186416,6 +186481,11 @@ class VisorTestRunner {
186416186481 memory_store_1.MemoryStore.resetInstance();
186417186482 }
186418186483 catch { }
186484+ // Clear AI sessions before each stage to avoid leakage across stages
186485+ try {
186486+ session_registry_1.SessionRegistry.getInstance().clearAllSessions();
186487+ }
186488+ catch { }
186419186489 // Prepare default tag filters for this flow (inherit suite defaults)
186420186490 const parseTags = (v) => {
186421186491 if (!v)
0 commit comments