-
Notifications
You must be signed in to change notification settings - Fork 172
173 lines (142 loc) · 6.25 KB
/
Copy patheval.yml
File metadata and controls
173 lines (142 loc) · 6.25 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: eval
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
eval:
name: run eval
runs-on: ubuntu-latest
steps:
- name: Checkout heimdall-rs (PR branch)
uses: actions/checkout@v4
- name: Checkout heimdall-eval
uses: actions/checkout@v4
with:
repository: Jon-Becker/heimdall-eval
path: heimdall-eval
token: ${{ secrets.EVAL_REPO_TOKEN }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Build heimdall
run: cargo build --release --bin heimdall
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Add heimdall to PATH
run: echo "${{ github.workspace }}/target/release" >> $GITHUB_PATH
- name: Run evals
working-directory: heimdall-eval
run: make run-all
- name: Run AI evaluation
working-directory: heimdall-eval
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
npm install -g @anthropic-ai/claude-code
make eval-all
- name: Comment on PR
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');
const evalsJson = JSON.parse(fs.readFileSync('heimdall-eval/heimdall/evals.json', 'utf8'));
const entries = Object.entries(evalsJson);
const cfgScores = entries.map(([_, v]) => v.cfg).filter(x => x != null);
const decompScores = entries.map(([_, v]) => v.decompilation).filter(x => x != null);
const avgCfg = cfgScores.length ? Math.floor(cfgScores.reduce((a, b) => a + b, 0) / cfgScores.length) : 'N/A';
const avgDecomp = decompScores.length ? Math.floor(decompScores.reduce((a, b) => a + b, 0) / decompScores.length) : 'N/A';
const icon = avgDecomp >= 70 ? ':white_check_mark:' : (avgDecomp >= 50 ? ':warning:' : ':x:');
// Identify low-scoring evals for detailed breakdown
const lowScoringEntries = entries.filter(([_, scores]) => {
const cfg = scores.cfg ?? null;
const decomp = scores.decompilation ?? null;
return (cfg != null && cfg < 70) || (decomp != null && decomp < 70);
});
let tableRows = entries.map(([name, scores]) => {
const cfg = scores.cfg ?? 'N/A';
const decomp = scores.decompilation ?? 'N/A';
return `| ${name} | ${cfg} | ${decomp} |`;
}).join('\n');
// Collect detailed breakdowns for low-scoring evals
let detailsSections = [];
for (const [name, scores] of lowScoringEntries) {
const cfg = scores.cfg ?? null;
const decomp = scores.decompilation ?? null;
let details = [`### ${name} (CFG: ${cfg ?? 'N/A'}, Decompilation: ${decomp ?? 'N/A'})\n`];
// Read decompilation eval details if score < 70
if (decomp != null && decomp < 70) {
const evalPath = path.join('heimdall-eval/heimdall', name, 'eval.json');
if (fs.existsSync(evalPath)) {
try {
const evalData = JSON.parse(fs.readFileSync(evalPath, 'utf8'));
details.push(`**Decompilation**\n\`\`\`json\n${JSON.stringify(evalData, null, 2)}\n\`\`\`\n`);
} catch (e) {
details.push(`**Decompilation** - Could not read details\n`);
}
}
}
// Read CFG eval details if score < 70
if (cfg != null && cfg < 70) {
const cfgEvalPath = path.join('heimdall-eval/heimdall', name, 'cfg_eval.json');
if (fs.existsSync(cfgEvalPath)) {
try {
const cfgEvalData = JSON.parse(fs.readFileSync(cfgEvalPath, 'utf8'));
details.push(`**CFG**\n\`\`\`json\n${JSON.stringify(cfgEvalData, null, 2)}\n\`\`\`\n`);
} catch (e) {
details.push(`**CFG** - Could not read details\n`);
}
}
}
if (details.length > 1) {
detailsSections.push(details.join('\n'));
}
}
let detailsBlock = '';
if (detailsSections.length > 0) {
detailsBlock = `\n\n<details>\n<summary>:warning: ${lowScoringEntries.length} eval(s) scoring <70%</summary>\n\n${detailsSections.join('\n---\n\n')}\n</details>`;
}
const body = `## ${icon} Eval Report for ${context.sha}
| Test Case | CFG | Decompilation |
|-----------|-----|---------------|
${tableRows}
| **Average** | **${avgCfg}** | **${avgDecomp}** |${detailsBlock}`;
// Delete old eval comments
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const evalComments = comments.filter(
c => c.user.login === 'github-actions[bot]' && c.body.includes('Eval Report for')
);
for (const comment of evalComments) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
});
}
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
- name: Upload eval artifacts
uses: actions/upload-artifact@v4
with:
name: eval-results
path: |
heimdall-eval/heimdall/*/eval.json
heimdall-eval/heimdall/*/cfg_eval.json
heimdall-eval/heimdall/evals.json