Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.
HTML agent-skillsai-agentsarchitecture-diagramclaude-codeclaude-skillscodexcoding-agentsdeepseek-harnessdeveloper-toolsdiagramsdiagrams-as-codedsh-pluginflowchartllmmermaidopencodesequence-diagramsoftware-architecturesystem-designvisualization
fix(browser): isolate inherited Windows app-health shim
tt-a1i4351c01ccaf0
diff --git a/archify.zip b/archify.zipindex 59fe579c..4fecec0e 100644Binary files a/archify.zip and b/archify.zip differdiff --git a/archify/bin/visual-check.mjs b/archify/bin/visual-check.mjsindex a3b2502e..b2b8ef17 100644--- a/archify/bin/visual-check.mjs+++ b/archify/bin/visual-check.mjs@@ -1522,9 +1522,20 @@ async function evaluate(cdp, sessionId, expression, awaitPromise = false) {return response.result?.value;}+function browserEnvironment(env, platform) {+ if (platform !== 'win32') return env;+ // Agent-launched Git Bash can inherit this app-health shim. Edge then+ // relaunches and loses the DevTools pipes (#790). Change the browser's copy+ // only, and leave unknown/combined layers (including privilege settings) alone.+ return Object.fromEntries(Object.entries(env).filter(([name, value]) =>+ !(name.toUpperCase() === '__COMPAT_LAYER'+ && /^\s*DetectorsAppHealth\s*$/i.test(String(value)))));+}+export class ChromeVisualBrowser {#profile;constructor(chromePath, {+ platform = process.platform,env = process.env,getuid = typeof process.getuid === 'function' ? () => process.getuid() : null,spawnImpl = spawn,@@ -1536,7 +1547,10 @@ export class ChromeVisualBrowser {this.shutdownTimeoutMs = shutdownTimeoutMs;this.stderr = '';const args = chromeVisualBrowserArgs(this.profileRoot, { env, getuid });- this.child = spawnImpl(chromePath, args, { stdio: ['ignore', 'ignore', 'pipe', 'pipe', 'pipe'] });+ this.child = spawnImpl(chromePath, args, {+ stdio: ['ignore', 'ignore', 'pipe', 'pipe', 'pipe'],+ env: browserEnvironment(env, platform),+ });this.child.stderr.setEncoding('utf8');this.child.stderr.on('data', (chunk) => {this.stderr = `${this.stderr}${chunk}`.slice(-8000);@@ -1553,6 +1567,11 @@ export class ChromeVisualBrowser {return [`Chrome process: ${exit}.`,stderr ? `Chrome stderr:\n${stderr}` : '',+ platform === 'win32' && this.cdp?.receivedBytes === 0+ ? 'Windows browser startup may have relaunched before connecting to the DevTools pipe. '+ + 'Retry from a non-elevated PowerShell opened normally, outside an elevated or compatibility-mode parent. '+ + 'Archify does not disable browser de-elevation or the sandbox to preserve pipe handles.'+ : '',].filter(Boolean).join('\n');},});diff --git a/archify/references/delivery-contract.md b/archify/references/delivery-contract.mdindex ddab4e8b..71aacba7 100644--- a/archify/references/delivery-contract.md+++ b/archify/references/delivery-contract.md@@ -463,6 +463,18 @@ Retry an environmental failure in a browser-capable execution context whenpractical. Keep the packaged transport unchanged unless the failure reproducesthrough that seam in a capable environment.+On Windows, Chrome/Edge startup relaunches can lose the inherited DevTools+pipe before any response arrives. Archify removes a standalone+`__COMPAT_LAYER=DetectorsAppHealth` from the browser child's environment only+(case-insensitive name and value); the parent environment, unknown layers,+combined layers, and privilege-related compatibility settings are unchanged.+This targets the reported non-elevated Git Bash app-health case, not every+AppCompat mode. Elevated-shell relaunches remain unsupported: rerun from a+non-elevated PowerShell opened normally, outside an elevated or compatibility-mode+parent. Archify does not suppress browser de-elevation or disable the sandbox+as a relaunch workaround. A zero-response startup diagnostic suggests this+remedy without claiming that elevation or AppCompat caused every pipe failure.+A provenance failure exits before browser inspection and persists a failedbrowser-check receipt bound to the attempted artifact. If the failure receiptcannot be written, the diagnostic names that incomplete evidence.diff --git a/test/visual-check.test.mjs b/test/visual-check.test.mjsindex a05074c9..ae4ff563 100644--- a/test/visual-check.test.mjs+++ b/test/visual-check.test.mjs@@ -257,6 +257,143 @@ test('visual-check disables the Chrome sandbox only for root or an explicit enviassert.equal(root.includes('--no-sandbox'), true);});+test('Windows browser launch removes only the standalone inherited app-health layer', async () => {+ for (const [key, layer] of [+ ['__COMPAT_LAYER', 'DetectorsAppHealth'],+ ['__compat_layer', 'detectorsapphealth'],+ ['__Compat_Layer', ' DetectorsAppHealth '],+ ]) {+ const env = Object.freeze({+ [key]: layer,+ Path: String.raw`C:\Windows\System32`,+ SystemRoot: String.raw`C:\Windows`,+ TEMP: String.raw`C:\Temp`,+ ARCHIFY_CHROME_NO_SANDBOX: '0',+ UNRELATED_SETTING: 'preserved',+ });+ const child = fakeChromeChild();+ let launched;+ const browser = new ChromeVisualBrowser('/fake/msedge.exe', {+ platform: 'win32', env, getuid: null,+ spawnImpl: (executable, args, options) => {+ launched = { executable, args, options };+ return child;+ },+ });+ const attached = browser.sessionPromise.catch(() => {});+ try {+ assert.equal(launched.executable, '/fake/msedge.exe');+ assert.equal(Object.hasOwn(launched.options.env, key), false);+ assert.deepEqual(launched.options.env, Object.fromEntries(+ Object.entries(env).filter(([name]) => name !== key),+ ));+ assert.equal(env[key], layer, 'the parent environment is untouched');+ assert.deepEqual(launched.args, chromeVisualBrowserArgs(browser.profileRoot, { env, getuid: null }));+ assert.ok(launched.args.includes('--remote-debugging-pipe'));+ assert.ok(launched.args.includes(`--user-data-dir=${browser.profileRoot}`));+ assert.equal(launched.args.includes('--no-sandbox'), false);+ assert.equal(launched.args.includes('--do-not-de-elevate'), false);+ assert.equal(launched.args.includes('--edge-skip-compat-layer-relaunch'), false);+ assert.deepEqual(launched.options.stdio, ['ignore', 'ignore', 'pipe', 'pipe', 'pipe']);+ } finally {+ await browser.close();+ await attached;+ }+ assert.equal(fs.existsSync(browser.profileRoot), false);+ }+});++test('browser launch preserves unknown, combined and non-Windows compatibility layers', async () => {+ for (const [platform, layer] of [+ ['win32', 'Installer'],+ ['win32', 'RunAsInvoker'],+ ['win32', 'DetectorsAppHealth RunAsInvoker'],+ ['win32', 'UnknownLayer'],+ ['darwin', 'DetectorsAppHealth'],+ ['linux', 'DetectorsAppHealth'],+ ]) {+ const env = Object.freeze({ __COMPAT_LAYER: layer, UNRELATED_SETTING: 'preserved' });+ const child = fakeChromeChild();+ let spawnOptions;+ const browser = new ChromeVisualBrowser('/fake/chrome', {+ platform, env, getuid: () => 1001,+ spawnImpl: (_executable, _args, options) => {+ spawnOptions = options;+ return child;+ },+ });+ const attached = browser.sessionPromise.catch(() => {});+ try {+ assert.deepEqual(spawnOptions.env, env, `${platform}: ${layer}`);+ } finally {+ await browser.close();+ await attached;+ }+ assert.equal(fs.existsSync(browser.profileRoot), false);+ }+});++test('browser environment defaults to the actual host platform', async () => {+ const env = Object.freeze({ __COMPAT_LAYER: 'DetectorsAppHealth' });+ const child = fakeChromeChild();+ let spawnOptions;+ const browser = new ChromeVisualBrowser('/fake/chrome', {+ env, getuid: () => 1001,+ spawnImpl: (_executable, _args, options) => {+ spawnOptions = options;+ return child;+ },+ });+ const attached = browser.sessionPromise.catch(() => {});+ try {+ assert.deepEqual(spawnOptions.env, process.platform === 'win32' ? {} : env);+ } finally {+ await browser.close();+ await attached;+ }+});++test('browser relaunch hint is absent after a response or on non-Windows hosts', async () => {+ for (const [platform, response] of [['win32', true], ['linux', false], ['darwin', false]]) {+ const child = fakeChromeChild();+ const browser = new ChromeVisualBrowser('/fake/chrome', {+ platform, env: {}, getuid: () => 1001, spawnImpl: () => child,+ });+ try {+ const failed = assert.rejects(browser.sessionPromise, (error) => {+ assert.doesNotMatch(error.message, /Windows browser startup/);+ return true;+ });+ if (response) child.stdio[4].write('{"method":"Target.targetCreated","params":{}}\0');+ child.stdio[4].end();+ await failed;+ } finally {+ await browser.close();+ }+ }+});++test('Windows pipe startup failure provides a non-elevated remedy without claiming its cause', async () => {+ const child = fakeChromeChild();+ const browser = new ChromeVisualBrowser('/fake/msedge.exe', {+ platform: 'win32', env: {}, getuid: null, spawnImpl: () => child,+ });+ try {+ const failed = assert.rejects(browser.sessionPromise, (error) => {+ assert.match(error.message, /receivedBytes=0/);+ assert.match(error.message, /Windows browser startup may have relaunched/);+ assert.match(error.message, /non-elevated PowerShell/);+ assert.match(error.message, /does not disable browser de-elevation or the sandbox/);+ return true;+ });+ child.stdio[4].end();+ await failed;+ } finally {+ await browser.close();+ }+ assert.equal(fs.existsSync(browser.profileRoot), false);+});+test('visual-check converts a Chrome DevTools pipe reset and captured stderr into a structured failure', async () => {const input = artifact('chrome-pipe-reset.html');const child = fakeChromeChild();