Skip to content

Commit 5fab198

Browse files
committed
probe: PR QwenLM#12191 round-3 platform lanes and literal preflight
1 parent 995c68f commit 5fab198

3 files changed

Lines changed: 357 additions & 0 deletions

File tree

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
name: 'PR 12191 round-3 probe'
2+
3+
on:
4+
push:
5+
branches: ['probe/pr12191-r3']
6+
7+
permissions:
8+
contents: 'read'
9+
10+
jobs:
11+
lanes:
12+
name: 'lane ${{ matrix.os }} / ${{ matrix.arm }}'
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: ['windows-2022', 'macos-latest']
17+
arm: ['pr', 'main']
18+
runs-on: '${{ matrix.os }}'
19+
timeout-minutes: 100
20+
defaults:
21+
run:
22+
shell: 'bash'
23+
steps:
24+
- name: 'Disable CRLF conversion'
25+
run: 'git config --global core.autocrlf false'
26+
- uses: 'actions/checkout@v4'
27+
with:
28+
ref: 'probe/pr12191-r3-arm-${{ matrix.arm }}'
29+
- uses: 'actions/checkout@v4'
30+
with:
31+
path: '_probe'
32+
sparse-checkout: '.probe12191'
33+
- name: 'Point temp at a short-alias-free directory (Windows)'
34+
if: "${{ runner.os == 'Windows' }}"
35+
shell: 'powershell'
36+
run: |-
37+
$temp = Join-Path $env:RUNNER_WORKSPACE 'qwen-code-temp'
38+
New-Item -ItemType Directory -Force -Path $temp | Out-Null
39+
"TEMP=$temp" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
40+
"TMP=$temp" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
41+
- uses: 'actions/setup-node@v4'
42+
with:
43+
node-version: '22.x'
44+
- name: 'Record identity'
45+
run: |-
46+
mkdir -p probe-out
47+
echo "PROBE_JSON {\"kind\":\"identity\",\"os\":\"${{ matrix.os }}\",\"arm\":\"${{ matrix.arm }}\",\"sha\":\"$(git rev-parse HEAD)\",\"tree\":\"$(git rev-parse HEAD^{tree})\",\"node\":\"$(node -v)\"}" | tee probe-out/identity.txt
48+
- name: 'Install (runs prepare: build + bundle)'
49+
run: 'corepack pnpm install --frozen-lockfile --reporter=append-only'
50+
- name: 'web-shell test:ci'
51+
id: 'webshell'
52+
continue-on-error: true
53+
env:
54+
NO_COLOR: 'true'
55+
HOME: '${{ runner.temp }}/qwen-ci-home'
56+
USERPROFILE: '${{ runner.temp }}/qwen-ci-home'
57+
run: |-
58+
mkdir -p "$HOME"
59+
cd packages/web-shell
60+
set +e
61+
npm run test:ci > ../../probe-out/webshell-test.log 2>&1
62+
rc=$?
63+
tail -8 ../../probe-out/webshell-test.log
64+
files=$(grep -E '^ *Test Files ' ../../probe-out/webshell-test.log | tail -1 | sed 's/^ *//')
65+
tests=$(grep -E '^ *Tests ' ../../probe-out/webshell-test.log | tail -1 | sed 's/^ *//')
66+
echo "PROBE_JSON {\"kind\":\"webshell-test\",\"rc\":$rc,\"files\":\"$files\",\"tests\":\"$tests\"}" | tee ../../probe-out/webshell-summary.txt
67+
exit $rc
68+
- name: 'root scripts test suite'
69+
id: 'scripts'
70+
continue-on-error: true
71+
env:
72+
NO_COLOR: 'true'
73+
run: |-
74+
set +e
75+
npm run test:scripts > probe-out/scripts-test.log 2>&1
76+
rc=$?
77+
tail -8 probe-out/scripts-test.log
78+
files=$(grep -E '^ *Test Files ' probe-out/scripts-test.log | tail -1 | sed 's/^ *//')
79+
tests=$(grep -E '^ *Tests ' probe-out/scripts-test.log | tail -1 | sed 's/^ *//')
80+
echo "PROBE_JSON {\"kind\":\"scripts-test\",\"rc\":$rc,\"files\":\"$files\",\"tests\":\"$tests\"}" | tee probe-out/scripts-summary.txt
81+
grep -E '(✓|×|FAIL).*(document-mcp-stub-guard|web-terminal-build)' probe-out/scripts-test.log | head -10 || true
82+
exit $rc
83+
- name: 'Publish-artifact verifier (#12188)'
84+
continue-on-error: true
85+
run: |-
86+
cd packages/web-shell
87+
set +e
88+
node scripts/verify-publish-artifacts.mjs > ../../probe-out/verify-publish.log 2>&1
89+
rc=$?
90+
tail -5 ../../probe-out/verify-publish.log
91+
echo "PROBE_JSON {\"kind\":\"verify-publish\",\"rc\":$rc}" | tee ../../probe-out/verify-publish-summary.txt
92+
- name: 'Sizes'
93+
run: 'node _probe/.probe12191/sizes.mjs . | tee probe-out/sizes.txt'
94+
- name: 'Document guard matrix (PR arm)'
95+
if: "${{ matrix.arm == 'pr' }}"
96+
continue-on-error: true
97+
run: 'node _probe/.probe12191/doc-matrix.mjs . probe-out/doc | tee probe-out/doc-matrix.txt'
98+
- name: 'Tree audit'
99+
if: '${{ always() }}'
100+
run: |-
101+
git status --porcelain -- . ':!_probe' ':!probe-out' | tee probe-out/git-status.txt
102+
echo "PROBE_JSON {\"kind\":\"tree\",\"dirty\":$(git status --porcelain -- . ':!_probe' ':!probe-out' | wc -l | tr -d ' ')}" | tee -a probe-out/git-status.txt
103+
- uses: 'actions/upload-artifact@v4'
104+
if: '${{ always() }}'
105+
with:
106+
name: 'lane-${{ matrix.os }}-${{ matrix.arm }}'
107+
path: 'probe-out'
108+
retention-days: 14
109+
110+
preflight:
111+
name: 'literal preflight ubuntu / ${{ matrix.arm }}'
112+
strategy:
113+
fail-fast: false
114+
matrix:
115+
arm: ['pr', 'main']
116+
runs-on: 'ubuntu-latest'
117+
timeout-minutes: 180
118+
steps:
119+
- uses: 'actions/checkout@v4'
120+
with:
121+
ref: 'probe/pr12191-r3-arm-${{ matrix.arm }}'
122+
- uses: 'actions/setup-node@v4'
123+
with:
124+
node-version: '22.x'
125+
- name: 'Record identity'
126+
run: |-
127+
mkdir -p "$RUNNER_TEMP/probe-out"
128+
echo "PROBE_JSON {\"kind\":\"identity\",\"arm\":\"${{ matrix.arm }}\",\"sha\":\"$(git rev-parse HEAD)\",\"node\":\"$(node -v)\"}" | tee "$RUNNER_TEMP/probe-out/identity.txt"
129+
- name: 'Install locked dependencies first (clean imports glob)'
130+
run: 'corepack pnpm install --frozen-lockfile --reporter=append-only'
131+
- name: 'npm run preflight (literal)'
132+
id: 'preflight'
133+
continue-on-error: true
134+
env:
135+
OPENAI_API_KEY: ''
136+
DASHSCOPE_API_KEY: ''
137+
QWEN_API_KEY: ''
138+
GEMINI_API_KEY: ''
139+
run: |-
140+
set +e
141+
start=$(date +%s)
142+
npm run preflight > "$RUNNER_TEMP/probe-out/preflight.log" 2>&1
143+
rc=$?
144+
end=$(date +%s)
145+
tail -40 "$RUNNER_TEMP/probe-out/preflight.log"
146+
echo "PROBE_JSON {\"kind\":\"preflight\",\"rc\":$rc,\"seconds\":$((end-start))}" | tee "$RUNNER_TEMP/probe-out/preflight-summary.txt"
147+
exit $rc
148+
- name: 'Tree audit after preflight'
149+
if: '${{ always() }}'
150+
run: |-
151+
git status --porcelain --untracked-files=all | tee "$RUNNER_TEMP/probe-out/git-status.txt"
152+
echo "PROBE_JSON {\"kind\":\"tree\",\"dirty\":$(git status --porcelain --untracked-files=all | wc -l | tr -d ' ')}" | tee -a "$RUNNER_TEMP/probe-out/git-status.txt"
153+
grep -nE '^> |Test Files |Tests |FAIL |ERR!|npm error' "$RUNNER_TEMP/probe-out/preflight.log" | tail -150 > "$RUNNER_TEMP/probe-out/preflight-outline.txt" || true
154+
- uses: 'actions/upload-artifact@v4'
155+
if: '${{ always() }}'
156+
with:
157+
name: 'preflight-${{ matrix.arm }}'
158+
path: '${{ runner.temp }}/probe-out'
159+
retention-days: 14

‎.probe12191/doc-matrix.mjs‎

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
// Negative-control matrix for the /export html document build (PR #12191).
2+
// Portable (Windows/macOS/Linux): mutations are exact String.replace calls that
3+
// throw when the target text is missing, so a silent no-op mutation is impossible.
4+
// Usage: node doc-matrix.mjs <repoRoot> <outDir>
5+
import { spawnSync } from 'node:child_process';
6+
import { createHash } from 'node:crypto';
7+
import {
8+
copyFileSync,
9+
existsSync,
10+
mkdirSync,
11+
readFileSync,
12+
rmSync,
13+
writeFileSync,
14+
} from 'node:fs';
15+
import { createRequire } from 'node:module';
16+
import { dirname, join, resolve } from 'node:path';
17+
18+
const root = resolve(process.argv[2] ?? '.');
19+
const out = resolve(process.argv[3] ?? 'probe-out');
20+
mkdirSync(out, { recursive: true });
21+
const wt = join(root, 'packages/web-templates');
22+
const B = join(wt, 'src/export-html/build.mjs');
23+
const ws = join(root, 'packages/web-shell');
24+
const T = join(ws, 'dist/transcript.js');
25+
const PKG = join(ws, 'package.json');
26+
const CAND_WARN = process.env.CAND_WARN ?? '1_880_000';
27+
const CAND_MAX = process.env.CAND_MAX ?? '1_930_000';
28+
29+
const sha = (p) => createHash('sha256').update(readFileSync(p)).digest('hex');
30+
const pristine = {
31+
build: readFileSync(B, 'utf8'),
32+
transcript: readFileSync(T),
33+
pkg: readFileSync(PKG, 'utf8'),
34+
};
35+
const pristineSha = { build: sha(B), transcript: sha(T), pkg: sha(PKG) };
36+
37+
const MUTATIONS = {
38+
'no-engagement': [
39+
['if (!hasDocumentMcpAppBridgeStubInput(', 'if (false && !hasDocumentMcpAppBridgeStubInput('],
40+
],
41+
'no-stub': [
42+
['{ filter: /^@modelcontextprotocol\\/ext-apps\\/app-bridge$/ }', '{ filter: /^__never__$/ }'],
43+
],
44+
'no-forbidden-mcp': [
45+
[
46+
'pattern: /(^|\\/)node_modules\\/@modelcontextprotocol\\/(ext-apps|sdk)\\//,',
47+
'pattern: /__never__/,',
48+
],
49+
],
50+
'tight-caps': [
51+
['const DOCUMENT_RUNTIME_WARNING_BYTES = 1_970_000;', `const DOCUMENT_RUNTIME_WARNING_BYTES = ${CAND_WARN};`],
52+
['const MAX_DOCUMENT_RUNTIME_BYTES = 2_030_000;', `const MAX_DOCUMENT_RUNTIME_BYTES = ${CAND_MAX};`],
53+
],
54+
};
55+
56+
function applyMutations(src, names) {
57+
for (const name of names) {
58+
for (const [from, to] of MUTATIONS[name]) {
59+
const count = src.split(from).length - 1;
60+
if (count !== 1) throw new Error(`mutation ${name}: expected 1 match, got ${count} for ${from}`);
61+
src = src.replace(from, to);
62+
}
63+
}
64+
return src;
65+
}
66+
67+
// 1. A transcript entry with the MCP bridge pre-bundled: drop ext-apps from the
68+
// manifest (externals derive from it) and rebuild only the transcript mode.
69+
const req = createRequire(PKG);
70+
const viteBin = join(dirname(req.resolve('vite/package.json')), 'bin/vite.js');
71+
const preDir = join(out, 'prebundled-transcript');
72+
rmSync(preDir, { recursive: true, force: true });
73+
const pkg = JSON.parse(pristine.pkg);
74+
delete pkg.dependencies['@modelcontextprotocol/ext-apps'];
75+
writeFileSync(PKG, JSON.stringify(pkg, null, 2) + '\n');
76+
const vb = spawnSync(
77+
process.execPath,
78+
[viteBin, 'build', '--config', 'vite.lib.config.ts', '--mode', 'transcript', '--outDir', preDir, '--emptyOutDir'],
79+
{ cwd: ws, encoding: 'utf8' },
80+
);
81+
writeFileSync(PKG, pristine.pkg);
82+
writeFileSync(join(out, 'prebundle-vite.log'), `${vb.stdout}\n${vb.stderr}`);
83+
const preT = join(preDir, 'transcript.js');
84+
if (vb.status !== 0 || !existsSync(preT)) throw new Error(`prebundle build failed: ${vb.status}`);
85+
const preText = readFileSync(preT, 'utf8');
86+
const healthyText = pristine.transcript.toString('utf8');
87+
const bridgeImport = /from\s*["']@modelcontextprotocol\/ext-apps\/app-bridge["']/;
88+
const prebundleInfo = {
89+
healthyImportsBridge: bridgeImport.test(healthyText),
90+
prebundledImportsBridge: bridgeImport.test(preText),
91+
healthyBytes: Buffer.byteLength(healthyText),
92+
prebundledBytes: Buffer.byteLength(preText),
93+
};
94+
console.log('PROBE_JSON ' + JSON.stringify({ kind: 'prebundle', ...prebundleInfo }));
95+
if (prebundleInfo.prebundledImportsBridge || !prebundleInfo.healthyImportsBridge) {
96+
throw new Error('prebundle control is not a pre-inlined bridge');
97+
}
98+
99+
// 2. The matrix.
100+
const CASES = [
101+
['C0-intact', 'healthy', []],
102+
['C0t-intact-candidate-caps', 'healthy', ['tight-caps']],
103+
['C1-prebundled', 'prebundled', []],
104+
['C2-prebundled-no-engagement', 'prebundled', ['no-engagement']],
105+
['C2t-prebundled-no-engagement-candidate-caps', 'prebundled', ['no-engagement', 'tight-caps']],
106+
['C3-no-stub', 'healthy', ['no-stub']],
107+
['C4-no-stub-no-engagement', 'healthy', ['no-stub', 'no-engagement']],
108+
['C5-no-stub-no-engagement-no-forbidden', 'healthy', ['no-stub', 'no-engagement', 'no-forbidden-mcp']],
109+
];
110+
for (const [name, transcript, muts] of CASES) {
111+
writeFileSync(B, applyMutations(pristine.build, muts));
112+
if (transcript === 'healthy') writeFileSync(T, pristine.transcript);
113+
else copyFileSync(preT, T);
114+
const metafile = join(out, `${name}.metafile.json`);
115+
const r = spawnSync(process.execPath, ['src/export-html/build.mjs'], {
116+
cwd: wt,
117+
encoding: 'utf8',
118+
env: { ...process.env, EXPORT_HTML_METAFILE: metafile },
119+
});
120+
const log = `${r.stdout}\n${r.stderr}`;
121+
writeFileSync(join(out, `${name}.log`), log);
122+
const bytes = log.match(/renderer JS is (\d+) bytes/)?.[1] ?? null;
123+
const err = log.match(/Error: ([^\n]{0,160})/)?.[1] ?? null;
124+
const forbidden = log.match(/reached (\d+) forbidden input/)?.[1] ?? null;
125+
const warned = /exceeds the \d+-byte warning threshold/.test(log);
126+
let meta = null;
127+
if (existsSync(metafile)) {
128+
const keys = Object.keys(JSON.parse(readFileSync(metafile, 'utf8')).inputs);
129+
meta = {
130+
inputs: keys.length,
131+
backslashKeys: keys.filter((k) => k.includes('\\')).length,
132+
stubKey: keys.find((k) => k.includes('document-mcp-app-bridge-stub')) ?? null,
133+
mcpKeys: keys.filter((k) => k.includes('@modelcontextprotocol')).length,
134+
sampleNodeModulesKey: keys.find((k) => k.includes('node_modules')) ?? null,
135+
};
136+
rmSync(metafile);
137+
}
138+
console.log(
139+
'PROBE_JSON ' +
140+
JSON.stringify({ kind: 'case', name, transcript, muts, rc: r.status, bytes, warned, forbidden, err, meta }),
141+
);
142+
}
143+
144+
// 3. Restore and rebuild the healthy document; prove the tree is byte-exact.
145+
writeFileSync(B, pristine.build);
146+
writeFileSync(T, pristine.transcript);
147+
const rebuild = spawnSync(process.execPath, ['src/export-html/build.mjs'], { cwd: wt, encoding: 'utf8' });
148+
const status = spawnSync('git', ['status', '--porcelain'], { cwd: root, encoding: 'utf8' }).stdout.trim();
149+
const restored = {
150+
kind: 'restore',
151+
rebuildRc: rebuild.status,
152+
build: sha(B) === pristineSha.build,
153+
transcript: sha(T) === pristineSha.transcript,
154+
pkg: sha(PKG) === pristineSha.pkg,
155+
gitStatus: status,
156+
};
157+
console.log('PROBE_JSON ' + JSON.stringify(restored));
158+
if (!restored.build || !restored.transcript || !restored.pkg || rebuild.status !== 0) process.exit(1);

‎.probe12191/sizes.mjs‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Published-entry shape and ratchet headroom for PR #12191, per platform/arm.
2+
// Usage: node sizes.mjs <repoRoot>
3+
import { existsSync, readFileSync } from 'node:fs';
4+
import { join, resolve } from 'node:path';
5+
6+
const root = resolve(process.argv[2] ?? '.');
7+
const dist = join(root, 'packages/web-shell/dist');
8+
const read = (f) => readFileSync(join(dist, f), 'utf8');
9+
const esc = (v) => v.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
10+
const imports = (bundle, dep) => new RegExp(`from\\s*["']${esc(dep)}(?:/[^"']*)?["']`).test(bundle);
11+
12+
const index = read('index.js');
13+
const transcript = read('transcript.js');
14+
const transcriptJs = transcript.replace(/^const __qwenWebShellCss=[^\n]*\n/, '');
15+
const DEPS = [
16+
'@modelcontextprotocol/ext-apps',
17+
'@tanstack/react-table',
18+
'@tanstack/react-virtual',
19+
'@xterm/addon-fit',
20+
'@xterm/xterm',
21+
'fzf',
22+
];
23+
const doc = join(root, 'packages/web-templates/src/export-html/dist/export-transcript-document.js');
24+
const docText = existsSync(doc) ? readFileSync(doc, 'utf8') : null;
25+
console.log(
26+
'PROBE_JSON ' +
27+
JSON.stringify({
28+
kind: 'sizes',
29+
indexBytes: Buffer.byteLength(index),
30+
transcriptBytes: Buffer.byteLength(transcript),
31+
transcriptJsUnits: transcriptJs.length,
32+
transcriptJsBytes: Buffer.byteLength(transcriptJs),
33+
ratchetHeadroomUnits: 1_150_000 - transcriptJs.length,
34+
ratchetHeadroomBytes: 1_150_000 - Buffer.byteLength(transcriptJs),
35+
externalInIndex: DEPS.filter((d) => imports(index, d)).length,
36+
transcriptImportsBridge: /from\s*["']@modelcontextprotocol\/ext-apps\/app-bridge["']/.test(transcript),
37+
documentRendererBytes: docText === null ? null : Buffer.byteLength(docText),
38+
documentHasAppBridgeMarker: docText === null ? null : /ui\/initialize/.test(docText),
39+
}),
40+
);

0 commit comments

Comments
 (0)