{"record":{"id":"ea4299ebd1ba5e8c","repo":"pbakaus/impeccable","slug":"impeccable-variant-wrapper-not-found-in-source-f","errorCode":null,"errorMessage":"[impeccable] Variant wrapper not found in source file.","messagePattern":"\\[impeccable\\] Variant wrapper not found in source file\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"skill/scripts/live-browser.js","lineNumber":6414,"sourceCode":"      }\n      return;\n    }\n    const url = 'http://localhost:' + PORT + '/source?token=' + TOKEN + '&path=' + encodeURIComponent(filePath);\n    fetch(url)\n      .then(r => { if (!r.ok) throw new Error(r.status); return r.text(); })\n      .then(html => {\n        const parser = new DOMParser();\n        const startMark = '<!-- impeccable-variants-start ' + sessionId + ' -->';\n        const endMark = '<!-- impeccable-variants-end ' + sessionId + ' -->';\n        const startIdx = html.indexOf(startMark);\n        const endIdx = html.indexOf(endMark);\n        const block = startIdx !== -1 && endIdx !== -1 && endIdx > startIdx\n          ? html.slice(startIdx + startMark.length, endIdx).trim()\n          : html;\n        const doc = parser.parseFromString(block, 'text/html');\n        const srcWrapper = doc.querySelector('[data-impeccable-variants=\"' + sessionId + '\"]');\n        if (!srcWrapper) {\n          console.warn('[impeccable] Variant wrapper not found in source file.');\n          // A resumed cycling session whose wrapper is gone from source is an\n          // ORPHAN: the file was edited or regenerated out from under it, so\n          // no reload, HMR push, or server restart can ever complete it, and\n          // the frozen picker it leaves behind used to need a manual\n          // live-complete --discarded. Retry a few reads first (an agent\n          // rewrite or HMR patch may be mid-flight), then self-discard and\n          // hand the surface back to the picker.\n          if (opts.orphanDiscard && sessionId === currentSessionId) {\n            const attempt = opts._orphanAttempt || 0;\n            if (attempt < COMPLETED_SOURCE_FALLBACK_RETRIES) {\n              setTimeout(() => {\n                if (sessionId !== currentSessionId) return;\n                if (state !== 'GENERATING' && state !== 'CYCLING') return;\n                injectVariantsFromSource(filePath, sessionId, { ...opts, _orphanAttempt: attempt + 1 });\n              }, COMPLETED_SOURCE_FALLBACK_RETRY_MS);\n            } else {\n              discardOrphanedSession('variant wrapper missing from source');\n            }","sourceCodeStart":6396,"sourceCodeEnd":6432,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/skill/scripts/live-browser.js#L6396-L6432","documentation":"While re-injecting variants from the source file (HTML path), the script parses the fetched source and queries for the [data-impeccable-variants=\"<sessionId>\"] wrapper. When it is absent this warning fires: the resumed cycling session's wrapper is gone from source, making the session an ORPHAN that no reload/HMR/restart can complete. If orphanDiscard is set, the script retries the read a few times (an agent rewrite or HMR patch may be mid-flight) before calling discardOrphanedSession.","triggerScenarios":"injectVariantsFromSource fetched the source successfully but the parsed HTML contains no wrapper matching the current sessionId — the file was edited, regenerated, reverted, or the wrapper markers were stripped after the session started.","commonSituations":"Git revert or checkout replaced the file; an agent rewrite rewrote the whole file without the markers; HMR patch dropped the scaffolding; resuming a saved session against a changed file; comment markers removed by a formatter/minifier.","solutions":["Wait a moment — the script retries up to 3 times (1.2s apart) in case an HMR patch or agent rewrite is in flight.","If the session self-discards, pick an element to start a fresh session.","Restore the file state containing the impeccable-variants wrapper markers if the removal was accidental.","Stop editors/formatters from stripping the HTML comment markers in source files during live sessions."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"const res = await fetch(srcUrl);\nif (res.ok) {\n  const html = await res.text();\n  const hasWrapper = html.indexOf('data-impeccable-variants=\"' + sessionId + '\"') !== -1;\n  if (!hasWrapper) { /* retry up to 3x at 1.2s before discarding */ }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wait through the built-in retry window (3 x 1.2s) — an HMR patch or agent rewrite may be mid-flight.","Do not rewrite the target file wholesale during an active variant session; preserve the wrapper markers.","Revert accidental file edits (git checkout) before the session exhausts its retry budget.","Resume saved sessions against the same file revision they were created from."],"tags":["session","source-file","orphan","html","browser"],"backgroundTag":"stale-session-state","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}