Skip to content

Commit af611ec

Browse files
committed
test(agent): require native readiness for precision contrast
1 parent 7e4c87f commit af611ec

2 files changed

Lines changed: 72 additions & 1 deletion

File tree

‎docs/evaluations/2026-10-07-qwen3-instruct2507-q6-native.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ try {
198198
}),
199199
);
200200
}
201-
if (!row.modelStatus) throw Error('Initial model setup failed; stop duplicate loading attempts');
201+
if (!row.modelStatus || !row.modelNote?.includes('模型已加载')) throw Error('Initial native readiness failed; stop duplicate loading attempts');
202202
}
203203
} finally {
204204
await browser.close();
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
"""Validate frozen Q4/Q6 known-failure contrast evidence mechanics separately from semantic review."""
2+
import argparse
3+
import hashlib
4+
import json
5+
from pathlib import Path
6+
7+
root = Path(__file__).parent
8+
parser = argparse.ArgumentParser(description=__doc__)
9+
mode = parser.add_mutually_exclusive_group()
10+
mode.add_argument('--partial', action='store_true', help='Check only captured rows; cannot certify completion')
11+
parser.add_argument('--receipt', type=Path, help='Partial receipt override for diagnostic counterchecks')
12+
args = parser.parse_args()
13+
fixtures = json.loads((root / '2026-10-07-qwen3-instruct2507-seven-language-cases.json').read_text())
14+
fixtures = [x for x in fixtures if x['id'] in ['zh-CN-summarize','es-rewrite','ja-translate','de-rewrite']]
15+
fixtures = [(x,variant) for x in fixtures for variant in ['Q4_K_M','Q6_K']]
16+
assert len(fixtures) == 8
17+
if args.partial:
18+
workspace = root.resolve().parents[1]
19+
initial = json.loads((workspace / '.scratch/2026-10-07-qwen3-instruct2507-q6-initial-bindings.json').read_text())
20+
for name, expected in initial['sha256'].items():
21+
assert hashlib.sha256((workspace / name).read_bytes()).hexdigest() == expected, name
22+
receipt = args.receipt or workspace / '.scratch/2026-10-07-qwen3-instruct2507-q6-native.json'
23+
report = json.loads(receipt.read_text())
24+
assert 0 < len(report['cases']) <= 8
25+
else:
26+
assert args.receipt is None, 'Receipt override requires explicit partial mode'
27+
bindings = json.loads((root / '2026-10-07-qwen3-instruct2507-q6-bindings.json').read_text())
28+
for name, expected in bindings['evidenceSHA256'].items():
29+
assert hashlib.sha256((root / name).read_bytes()).hexdigest() == expected, name
30+
report = json.loads((root / '2026-10-07-qwen3-instruct2507-q6-native.json').read_text())
31+
assert len(report['cases']) == 8
32+
assert report['browserClosed']
33+
assert bindings['processExitCode'] == 0
34+
q4 = json.loads((root / '2026-10-07-qwen3-instruct2507-artifact.json').read_text())
35+
q6 = json.loads((root / '2026-10-07-qwen3-instruct2507-q6-artifact.json').read_text())['files'][0]
36+
assert report['verifiedArtifacts'] == [{'variant': 'Q4_K_M', 'file': q4['file'], 'bytes': q4['expectedBytes'], 'sha256': q4['expectedSHA256']}, {'variant': 'Q6_K', **{k:q6[k] for k in ['file','bytes','sha256']}}]
37+
verified = 0
38+
for (fixture,variant), row in zip(fixtures, report['cases']):
39+
assert row['prompt'] == fixture and row['variant'] == variant
40+
assert row['finished'] and row['contextClosed'] and not row.get('error')
41+
assert 'qwen3-4b-instruct-2507' in row['modelStatus'].lower() and variant.lower() in row['modelStatus'].lower()
42+
assert row['runtimeEnvironment']['crossOriginIsolated']
43+
assert row['runtimeEnvironment']['sharedArrayBuffer'] == 'function'
44+
load = row['loads'][0]
45+
assert load['requested'] == {'n_threads': 4, 'n_ctx': 2048, 'n_gpu_layers': 0, 'reasoning': False}
46+
assert load['actualThreads'] == 4 and load['multithread']
47+
assert row['selected'] == row['documentBefore'] == fixture['source'] + '\r\n'
48+
verified += 1
49+
assert not row['crashed'] and not row['errors'] and row['previewCount'] == 0
50+
assert len(row['sdk']) == 1
51+
probe = row['sdk'][0]
52+
request = probe['request']
53+
assert row['counts'][-1] == request
54+
assert probe['originalMessages'] == request['messages']
55+
assert request['temperature'] == .7 and request['top_p'] == .8 and request['top_k'] == 20
56+
assert request['seed'] == 42 and request['max_tokens'] == 512
57+
users = [message for message in request['messages'] if message['role'] == 'user']
58+
assert len(users) == 1
59+
task = json.loads(users[0]['content'].splitlines()[-1])
60+
assert task == {'task': fixture['task'], 'targetLanguage': fixture['targetLanguage'], 'text': row['selected'].replace('\r\n', '\n'), 'instruction': fixture['instruction']}
61+
if row['documentUnchanged']:
62+
assert row['documentAfter'] == row['documentBefore']
63+
else:
64+
assert row['afterUndo'] == row['documentBefore']
65+
assert row['afterRedo'] == row['documentAfter']
66+
raw = probe['completion']['choices'][0]['message']['content']
67+
assert json.loads(raw)['text'].replace('\r\n', '\n') + '\n' == row['documentAfter'].replace('\r\n', '\n')
68+
if args.partial:
69+
print(f"PARTIAL ONLY: {len(report['cases'])}/8 inference rows/mechanics checked. No completion or semantic acceptance.")
70+
else:
71+
print('Frozen eight Q4/Q6 known-source requests and native application/history checked; refusals and semantics require separate review.')

0 commit comments

Comments
 (0)