File size: 8,392 Bytes
0e239c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
"""Read real execution evidence from the five frozen Node/npm protocols."""
from collections import Counter
import json
from pathlib import Path
import re


def packets(text, prefix):
    return [json.loads(line[len(prefix):]) for line in text.splitlines() if line.startswith(prefix)]


def parse_report(iid, repository, kind, stdout, stderr, returncode, cell):
    phase = 'p2p' if kind == 'pass_to_pass' else 'f2p'
    rows = []; issues = []; metadata = {}
    try:
        if iid == 'buildpkg-npm-cli-8703':
            raw = packets(stdout, 'CROSSREPO_GIT_CHAIN_CASE ')
            summaries = packets(stdout, 'CROSSREPO_GIT_CHAIN_SUMMARY ')
            expected = 19 if phase == 'p2p' else 31
            if len(raw) != expected or len(summaries) != 1:
                raise ValueError('Incomplete public Git-chain cases')
            s = summaries[0]
            rows = [{'id': r['name'], 'passed': r['pass']} for r in raw]
            if any(type(r['passed']) is not bool for r in rows):
                issues.append('Nonboolean Git-chain case outcome')
            if s['mode'] != phase or s['executed'] != expected or s['passed'] != sum(r['passed'] for r in rows) or s['failed'] != sum(not r['passed'] for r in rows):
                issues.append('Git-chain summary differs from cases')
            if not s['real_cli'] or not s['provider'].startswith('/testbed/npm/pacote/'):
                issues.append('Missing paired provider/real CLI evidence')
            metadata['count_unit'] = 'public provider/CLI behavioral case; shared suite executed separately per repository command'
        elif iid == 'buildpkg-npm-cli-9026':
            report_path = Path(cell) / (repository + '-' + kind + '-tap-report-v2.json')
            if not report_path.exists(): report_path = Path(cell) / (repository + '-' + kind + '-tap-report.json')
            report = json.loads(report_path.read_text())
            all_assertions = report['assertions']; assertions = []
            filtered = []
            for r in all_assertions:
                if r.get('skip'):
                    if 'filter' not in str(r['skip']).lower():
                        issues.append('Native TAP assertion skipped outside frozen grep selection')
                    filtered.append(r)
                elif r.get('todo'):
                    issues.append('Native TAP TODO assertion')
                else:
                    assertions.append(r)
            if report['parser_errors'] or report['bailouts'] or not assertions:
                issues.append('Native TAP plan/parser/bailout or empty execution error')
            summaries = report['summaries']
            if not summaries or any(s['plan']['start'] is None or s['plan']['end'] is None for s in summaries):
                issues.append('Missing native TAP completion plan')
            native_failed = sum(r['ok'] is False for r in assertions)
            if returncode != int(bool(native_failed)):
                issues.append('Harness exit differs from executed native assertions')
            rows = [{'id': repository + '/' + phase + '/native-TAP-contract', 'passed': not native_failed}]
            metadata = {'count_unit': 'native TAP contract command', 'native_assertions': len(assertions),
                        'native_passed': len(assertions) - native_failed, 'native_failed': native_failed,
                        'grep_filtered_assertions': len(filtered), 'native_cases': assertions,
                        'tap_summary_count': len(summaries)}
        elif iid == 'buildpkg-npm-cli-9586':
            summaries = packets(stdout, 'CROSSSWE_COUNTS ')
            if len(summaries) != 1:
                raise ValueError('Missing npm policy scenario outcomes')
            s = summaries[0]; raw = s['cases']
            expected = {('npm-cli', 'p2p'): 3, ('npm-packlist', 'p2p'): 2, ('npm-cli', 'f2p'): 7, ('npm-packlist', 'f2p'): 1}[repository, phase]
            rows = [{'id': r['name'], 'passed': r['passed']} for r in raw]
            if len(rows) != expected or s['tests_run'] != expected or s['mode'] != phase or s['repo'] != repository or s['skipped']:
                issues.append('Incomplete npm policy scenario inventory')
            if s['passed'] != sum(r['passed'] for r in rows) or s['failed'] != sum(not r['passed'] for r in rows):
                issues.append('npm policy summary differs from raw cases')
            metadata['count_unit'] = 'public npm install/pack scenario'
        elif iid == 'mcp-specification-2508':
            data = [json.loads(line) for line in stdout.splitlines() if line.startswith('{')]
            compilers = [r for r in data if 'compiler' in r]
            positives = [r for r in data if r.get('check') == 'valid-json-capabilities']
            final = [r for r in data if r.get('status') == 'passed']
            if not compilers or not positives or any(r['diagnostics'] for r in positives):
                issues.append('Missing real compiler or positive regression evidence')
            if returncode == 0:
                if len(final) != 1 or final[0]['repo'] != repository or final[0]['mode'] != phase:
                    issues.append('Missing full MCP runtime completion')
            else:
                if phase != 'f2p' or 'JSON safety regression: compiler accepted non-JSON extension settings:' not in stderr:
                    issues.append('MCP failure is not the frozen behavioral assertion')
                if not any(r.get('check') == 'non-json-capabilities' for r in data):
                    issues.append('Negative compiler behavior did not execute')
            if repository == 'typescript_sdk':
                commands = [r for r in data if 'command' in r]
                if not commands or any(r['status'] != 0 for r in commands) or not any(r.get('generatedFileRestored') for r in data):
                    issues.append('Production generator did not complete and restore its output')
            rows = [{'id': repository + '/' + phase + '/compiler-generator-contract', 'passed': returncode == 0}]
            metadata = {'count_unit': 'compiler/generator contract command', 'compiler_evidence': compilers,
                        'checks': [r for r in data if 'check' in r], 'completion': final}
        elif iid == 'mcp-specification-2663':
            raw = re.findall(r'^CONTRACT_(PASS|FAIL) (.+)$', stdout, re.M)
            summaries = packets(stdout, 'CONTRACT_SUMMARY ')
            expected_names = {('spec', 'p2p'): ['core-schema-valid-and-invalid', 'mrtr-and-tool-result-regression'],
                              ('spec', 'f2p'): ['core-request-removal', 'public-ts-client-request-removal'],
                              ('conformance', 'p2p'): ['default-connection-core-wire'],
                              ('conformance', 'f2p'): ['extension-public-behavior']}[repository, phase]
            if [r[1] for r in raw] != expected_names or len(summaries) != 1:
                raise ValueError('Incomplete MCP scenario execution')
            rows = [{'id': name, 'passed': status == 'PASS'} for status, name in raw]
            s = summaries[0]
            if s['group'] != repository + ':' + phase or s['total'] != len(rows) or s['skipped'] or s['passed'] != sum(r['passed'] for r in rows) or s['failed'] != sum(not r['passed'] for r in rows):
                issues.append('MCP scenario summary differs from raw execution')
            metadata = {'count_unit': 'schema or live HTTP conformance scenario',
                        'observations': packets(stdout, 'OBSERVATION '), 'wire_evidence_records': len(packets(stdout, 'WIRE_EVIDENCE '))}
        else:
            raise ValueError('Unsupported batch03 protocol')
    except (ValueError, KeyError, TypeError, IndexError, OSError) as error:
        issues.append('Incomplete/malformed case evidence: ' + type(error).__name__)
    ids = [r['id'] for r in rows]
    if not rows or len(ids) != len(set(ids)):
        issues.append('Empty or duplicate case inventory')
    if any(token in stdout + stderr for token in ['MODULE_NOT_FOUND', 'ERR_MODULE_NOT_FOUND', 'Cannot find module', 'ModuleNotFoundError:', 'TimeoutExpired:']):
        issues.append('Import/dependency/infrastructure failure')
    if rows and returncode != int(any(r['passed'] is False for r in rows)):
        issues.append('Exit status disagrees with case outcomes')
    return rows, issues, metadata