@tangle-network/agent-bench 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/adapters.js +2 -2
- package/dist/benchmarks/humaneval.d.ts +10 -1
- package/dist/benchmarks/humaneval.js +5 -3
- package/dist/{chunk-PPYSEKFM.js → chunk-5H5XV76F.js} +73 -15
- package/dist/chunk-5H5XV76F.js.map +1 -0
- package/dist/{chunk-5SBJCB6W.js → chunk-PWQVGAJB.js} +2 -2
- package/dist/index.js +2 -2
- package/package.json +5 -4
- package/scripts/run-package-tests.mjs +30 -8
- package/scripts/verify-pier-agent.mts +1 -0
- package/src/benchmarks/humaneval.test.mts +122 -0
- package/src/benchmarks/humaneval.ts +100 -27
- package/src/david-attribution.mts +78 -0
- package/src/david-goliath.mts +149 -0
- package/src/hev-improve.mts +25 -6
- package/src/humaneval-object-ablation.mts +201 -0
- package/src/live-improve-campaign-mbpp.mts +641 -0
- package/src/live-improve-campaign.mts +500 -0
- package/src/mbpp-structural.mts +12 -7
- package/src/stream-observe.py +45 -0
- package/src/stream-observe.tpl.html +247 -0
- package/src/supervisor-arena.mts +816 -0
- package/src/swe-arena/analyze.ts +211 -0
- package/src/swe-arena/arms.ts +788 -0
- package/src/swe-arena/bootstrap-meta.mts +188 -0
- package/src/swe-arena/bootstrap-meta.test.mts +51 -0
- package/src/swe-arena/calibrate.ts +116 -0
- package/src/swe-arena/capabilities.mts +76 -0
- package/src/swe-arena/capabilities.test.mts +57 -0
- package/src/swe-arena/capacity.ts +194 -0
- package/src/swe-arena/cell-evidence.mts +405 -0
- package/src/swe-arena/cell-evidence.test.mts +248 -0
- package/src/swe-arena/diagnosis-ensemble.test.mts +210 -0
- package/src/swe-arena/diagnosis-ensemble.ts +520 -0
- package/src/swe-arena/execution.test.mts +1170 -0
- package/src/swe-arena/fixtures/analyze.py +80 -0
- package/src/swe-arena/fixtures/excludes.txt +8 -0
- package/src/swe-arena/fixtures/gen1-salvage/README.md +45 -0
- package/src/swe-arena/fixtures/gen1-salvage/cand0-e6d7361.diff +116 -0
- package/src/swe-arena/fixtures/gen1-salvage/cand1-76a8590.diff +293 -0
- package/src/swe-arena/fixtures/holdout-preregister.log +12 -0
- package/src/swe-arena/fixtures/holdout.json +44 -0
- package/src/swe-arena/fixtures/instances.json +146 -0
- package/src/swe-arena/fixtures/ledger.jsonl +12 -0
- package/src/swe-arena/fixtures/patches/pallets__flask-5014.solo.patch +36 -0
- package/src/swe-arena/fixtures/patches/pydata__xarray-4687.sup.patch +33 -0
- package/src/swe-arena/fixtures/rejudge.jsonl +15 -0
- package/src/swe-arena/fixtures/rematch.jsonl +3 -0
- package/src/swe-arena/fixtures/rematch2.jsonl +3 -0
- package/src/swe-arena/fixtures/rematch3.jsonl +3 -0
- package/src/swe-arena/fixtures/sup-journal-true.json +19 -0
- package/src/swe-arena/fixtures/verify/astropy__astropy-13033.sh +48 -0
- package/src/swe-arena/fixtures/verify/django__django-11532.sh +50 -0
- package/src/swe-arena/fixtures/verify/matplotlib__matplotlib-20826.sh +76 -0
- package/src/swe-arena/fixtures/verify/pydata__xarray-4687.sh +44 -0
- package/src/swe-arena/fixtures/verify/pytest-dev__pytest-6197.sh +32 -0
- package/src/swe-arena/fixtures/verify/sphinx-doc__sphinx-9658.sh +51 -0
- package/src/swe-arena/fixtures/worker-tokens.json +42 -0
- package/src/swe-arena/fixtures.ts +104 -0
- package/src/swe-arena/holdout-certify.mts +408 -0
- package/src/swe-arena/holdout-certify.test.mts +160 -0
- package/src/swe-arena/judge-child.mts +37 -0
- package/src/swe-arena/manifest.mts +293 -0
- package/src/swe-arena/manifest.test.mts +169 -0
- package/src/swe-arena/materialize.ts +142 -0
- package/src/swe-arena/outer-loop.mts +2145 -0
- package/src/swe-arena/outer-loop.test.mts +696 -0
- package/src/swe-arena/parity.test.mts +87 -0
- package/src/swe-arena/proc.test.mts +174 -0
- package/src/swe-arena/proc.ts +260 -0
- package/src/swe-arena/profiles/default-author.profile.json +4 -0
- package/src/swe-arena/proposer-fanout.mts +489 -0
- package/src/swe-arena/proposer-fanout.test.mts +372 -0
- package/src/swe-arena/reconcile.ts +0 -0
- package/src/swe-arena/replay.mts +183 -0
- package/src/swe-arena/replay.test.mts +300 -0
- package/src/swe-arena/run-experiment.mts +361 -0
- package/src/swe-arena/run-supervisor.mjs +297 -0
- package/src/swe-arena/run-supervisor.test.mts +498 -0
- package/src/swe-arena/serialized-judge.ts +414 -0
- package/src/swe-arena/types.ts +166 -0
- package/src/swe-code-improve.mts +328 -0
- package/src/swe-emit-patch.mts +104 -0
- package/src/swe-improve.mts +232 -0
- package/src/swe-jail.ts +2 -2
- package/src/swe-local-proof.mts +169 -0
- package/src/swe-repro-calibrate.mts +446 -0
- package/src/swe-stream.mts +1497 -0
- package/dist/chunk-PPYSEKFM.js.map +0 -1
- /package/dist/{chunk-5SBJCB6W.js.map → chunk-PWQVGAJB.js.map} +0 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace materialization from SWE-bench instance images — the typed port of
|
|
3
|
+
* the experiment's `setup-ws.sh`, stage for stage:
|
|
4
|
+
*
|
|
5
|
+
* docker create <image> → docker cp <container>:/testbed <dest> → docker rm
|
|
6
|
+
* → git reset --hard <base_commit> → git clean -fd → work branch checkout
|
|
7
|
+
*
|
|
8
|
+
* IMAGE materialization is the DEFAULT and must stay so. A plain `git clone`
|
|
9
|
+
* at `base_commit` is insufficient: the instance's runnable environment (conda
|
|
10
|
+
* env, compiled C extensions, version pins) is built by the official harness at
|
|
11
|
+
* `environment_setup_commit` and lives only in the image's /testbed. Round-2 of
|
|
12
|
+
* the supervisor evolution proved this live — clone-materialized worker
|
|
13
|
+
* sandboxes dropped those build artifacts and every verify run died on imports
|
|
14
|
+
* (astropy/matplotlib), which is exactly the failure mode the image path
|
|
15
|
+
* removes. Clone materialization may only ever be an explicit opt-in for
|
|
16
|
+
* pure-python instances, never the default.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { randomUUID } from 'node:crypto'
|
|
20
|
+
import { mkdir, rm, stat } from 'node:fs/promises'
|
|
21
|
+
import { dirname } from 'node:path'
|
|
22
|
+
import { run, runOk } from './proc'
|
|
23
|
+
|
|
24
|
+
export interface MaterializeOptions {
|
|
25
|
+
instanceId: string
|
|
26
|
+
/** Instance image, e.g. swebench/sweb.eval.x86_64.pallets_1776_flask-5014:latest. */
|
|
27
|
+
image: string
|
|
28
|
+
baseCommit: string
|
|
29
|
+
/** Destination directory; removed and recreated (setup-ws.sh `rm -rf`). */
|
|
30
|
+
dest: string
|
|
31
|
+
/** Work branch forced to base_commit and checked out. Default matches the bash. */
|
|
32
|
+
workBranch?: string
|
|
33
|
+
/** Cancels Docker/Git setup before a cell begins model execution. */
|
|
34
|
+
signal?: AbortSignal
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface MaterializedWorkspace {
|
|
38
|
+
head: string
|
|
39
|
+
/** `git status --porcelain` empty after materialization. */
|
|
40
|
+
clean: boolean
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** setup-ws.sh container-name sanitization: `tr '_/' '--'` + unique suffix. */
|
|
44
|
+
export function containerName(instanceId: string): string {
|
|
45
|
+
const sanitized = instanceId.replace(/[_/]/g, '-')
|
|
46
|
+
return `ext-${sanitized}-${process.pid}-${randomUUID()}`
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const DOCKER_CREATE_TIMEOUT_MS = 5 * 60_000
|
|
50
|
+
const DOCKER_COPY_TIMEOUT_MS = 10 * 60_000
|
|
51
|
+
const DOCKER_CLEANUP_TIMEOUT_MS = 60_000
|
|
52
|
+
const GIT_COMMAND_TIMEOUT_MS = 2 * 60_000
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Materialize a pristine workspace for `instanceId` at `dest`. Throws with the
|
|
56
|
+
* setup-ws.sh stage label (create-fail / cp-fail / no-git / reset-fail) so
|
|
57
|
+
* failures stay greppable against the bash experiment's logs.
|
|
58
|
+
*/
|
|
59
|
+
export async function materializeWorkspace(opts: MaterializeOptions): Promise<MaterializedWorkspace> {
|
|
60
|
+
const { instanceId, image, baseCommit, dest } = opts
|
|
61
|
+
const workBranch = opts.workBranch ?? 'hh-work'
|
|
62
|
+
const container = containerName(instanceId)
|
|
63
|
+
|
|
64
|
+
opts.signal?.throwIfAborted()
|
|
65
|
+
await rm(dest, { recursive: true, force: true })
|
|
66
|
+
await mkdir(dirname(dest), { recursive: true })
|
|
67
|
+
opts.signal?.throwIfAborted()
|
|
68
|
+
|
|
69
|
+
const create = await run('docker', ['create', '--name', container, image], {
|
|
70
|
+
signal: opts.signal,
|
|
71
|
+
timeoutMs: DOCKER_CREATE_TIMEOUT_MS,
|
|
72
|
+
})
|
|
73
|
+
let stageError: unknown
|
|
74
|
+
try {
|
|
75
|
+
opts.signal?.throwIfAborted()
|
|
76
|
+
if (create.code !== 0) {
|
|
77
|
+
throw new Error(`materialize ${instanceId}: create-fail (${image}): ${create.stderr.slice(0, 500)}`)
|
|
78
|
+
}
|
|
79
|
+
const cp = await run('docker', ['cp', `${container}:/testbed`, dest], {
|
|
80
|
+
signal: opts.signal,
|
|
81
|
+
timeoutMs: DOCKER_COPY_TIMEOUT_MS,
|
|
82
|
+
})
|
|
83
|
+
opts.signal?.throwIfAborted()
|
|
84
|
+
if (cp.code !== 0) {
|
|
85
|
+
throw new Error(`materialize ${instanceId}: cp-fail: ${cp.stderr.slice(0, 500)}`)
|
|
86
|
+
}
|
|
87
|
+
} catch (cause) {
|
|
88
|
+
stageError = cause
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Cleanup must still run after the caller signal fires, so it gets its own
|
|
92
|
+
// short deadline instead of the already-aborted cell signal.
|
|
93
|
+
let cleanupError: unknown
|
|
94
|
+
try {
|
|
95
|
+
const cleanup = await run('docker', ['rm', '-f', container], {
|
|
96
|
+
timeoutMs: DOCKER_CLEANUP_TIMEOUT_MS,
|
|
97
|
+
})
|
|
98
|
+
const detail = cleanup.stderr || cleanup.stdout
|
|
99
|
+
const absent = /no such container/iu.test(detail)
|
|
100
|
+
if (cleanup.code !== 0 && !absent) {
|
|
101
|
+
cleanupError = new Error(
|
|
102
|
+
`materialize ${instanceId}: cleanup-fail container=${container} exit=${cleanup.code}: ${detail.slice(0, 500)}`,
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
} catch (cause) {
|
|
106
|
+
cleanupError = cause
|
|
107
|
+
}
|
|
108
|
+
if (stageError !== undefined && cleanupError !== undefined) {
|
|
109
|
+
throw new AggregateError(
|
|
110
|
+
[stageError, cleanupError],
|
|
111
|
+
`materialize ${instanceId}: workspace extraction and container cleanup both failed`,
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
if (stageError !== undefined) throw stageError
|
|
115
|
+
if (cleanupError !== undefined) throw cleanupError
|
|
116
|
+
|
|
117
|
+
opts.signal?.throwIfAborted()
|
|
118
|
+
const gitDir = await stat(`${dest}/.git`).catch(() => null)
|
|
119
|
+
if (!gitDir?.isDirectory()) {
|
|
120
|
+
throw new Error(`materialize ${instanceId}: no-git (image ${image} has no /testbed git repo)`)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const gitOpts = { signal: opts.signal, timeoutMs: GIT_COMMAND_TIMEOUT_MS }
|
|
124
|
+
const reset = await run('git', ['-C', dest, 'reset', '-q', '--hard', baseCommit], gitOpts)
|
|
125
|
+
opts.signal?.throwIfAborted()
|
|
126
|
+
if (reset.code !== 0) {
|
|
127
|
+
throw new Error(`materialize ${instanceId}: reset-fail base=${baseCommit}: ${reset.stderr.slice(0, 500)}`)
|
|
128
|
+
}
|
|
129
|
+
// Tolerated failure in the bash (`|| true`): a clean error must not kill setup.
|
|
130
|
+
const clean = await run('git', ['-C', dest, 'clean', '-qfd'], gitOpts)
|
|
131
|
+
opts.signal?.throwIfAborted()
|
|
132
|
+
if (clean.timedOut) {
|
|
133
|
+
throw new Error(`materialize ${instanceId}: clean-timeout: ${(clean.stderr || clean.stdout).slice(0, 500)}`)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
await runOk('git', ['-C', dest, 'branch', '-f', workBranch, baseCommit], gitOpts)
|
|
137
|
+
await runOk('git', ['-C', dest, 'checkout', '-q', workBranch], gitOpts)
|
|
138
|
+
|
|
139
|
+
const head = (await runOk('git', ['-C', dest, 'rev-parse', 'HEAD'], gitOpts)).stdout.trim()
|
|
140
|
+
const status = (await runOk('git', ['-C', dest, 'status', '--porcelain'], gitOpts)).stdout.trim()
|
|
141
|
+
return { head, clean: status.length === 0 }
|
|
142
|
+
}
|