@tangle-network/agent-bench 0.1.0

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.
Files changed (111) hide show
  1. package/README.md +15 -0
  2. package/package.json +35 -0
  3. package/src/adapters.ts +60 -0
  4. package/src/aec-gate.mts +217 -0
  5. package/src/atom-humaneval.mts +197 -0
  6. package/src/atom-mcp-e2e.mts +223 -0
  7. package/src/benchmarks/_harness.ts +206 -0
  8. package/src/benchmarks/aec-bench.test.mts +53 -0
  9. package/src/benchmarks/aec-bench.ts +319 -0
  10. package/src/benchmarks/appworld.test.mts +45 -0
  11. package/src/benchmarks/appworld.ts +426 -0
  12. package/src/benchmarks/cad-design.ts +429 -0
  13. package/src/benchmarks/cadbench.ts +135 -0
  14. package/src/benchmarks/cadgenbench.ts +121 -0
  15. package/src/benchmarks/commit0.test.mts +71 -0
  16. package/src/benchmarks/commit0.ts +266 -0
  17. package/src/benchmarks/enterpriseops-gym.test.mts +77 -0
  18. package/src/benchmarks/enterpriseops-gym.ts +343 -0
  19. package/src/benchmarks/finsearchcomp.ts +371 -0
  20. package/src/benchmarks/frames.ts +520 -0
  21. package/src/benchmarks/hotpotqa.ts +320 -0
  22. package/src/benchmarks/humaneval.ts +251 -0
  23. package/src/benchmarks/mind2web.ts +311 -0
  24. package/src/benchmarks/programbench.test.mts +60 -0
  25. package/src/benchmarks/programbench.ts +210 -0
  26. package/src/benchmarks/simpleqa.ts +390 -0
  27. package/src/benchmarks/swe-bench.ts +152 -0
  28. package/src/benchmarks/terminal-bench.ts +182 -0
  29. package/src/benchmarks/trata-hedge.ts +496 -0
  30. package/src/benchmarks/types.ts +58 -0
  31. package/src/browser/adapters/bad-design-audit.ts +153 -0
  32. package/src/browser/adapters/bad-design-audit.verify.ts +85 -0
  33. package/src/browser/adapters/bad.ts +165 -0
  34. package/src/browser/agent-adapter.ts +145 -0
  35. package/src/browser/process-adapter.ts +146 -0
  36. package/src/browser/run-to-spans.ts +105 -0
  37. package/src/browser/run-to-spans.verify.ts +89 -0
  38. package/src/browser/ui-reviewer.ts +200 -0
  39. package/src/browser/ui-reviewer.verify.ts +94 -0
  40. package/src/browser/verify.ts +96 -0
  41. package/src/clbench-codebase-gate.mts +314 -0
  42. package/src/clbench-context-gate.mts +305 -0
  43. package/src/cloud-loop.mts +138 -0
  44. package/src/coding-skills/minimal-diff.md +9 -0
  45. package/src/coding-skills/read-before-edit.md +9 -0
  46. package/src/coding-skills/reproduce-first.md +10 -0
  47. package/src/coding-skills/run-tests-after-edit.md +9 -0
  48. package/src/coding-skills/trace-the-failure.md +9 -0
  49. package/src/commit0-env-run.mts +59 -0
  50. package/src/commit0-env.ts +173 -0
  51. package/src/commit0-gate.mts +529 -0
  52. package/src/commit0-prereqs.sh +48 -0
  53. package/src/corpus-replay.mts +300 -0
  54. package/src/corpus-report.mts +504 -0
  55. package/src/corpus.test.mts +273 -0
  56. package/src/corpus.ts +325 -0
  57. package/src/decoder-live.mts +133 -0
  58. package/src/directives.ts +84 -0
  59. package/src/diverse-gate.mjs +112 -0
  60. package/src/egress-probe.mts +26 -0
  61. package/src/eops-skills/address-every-subtask.md +5 -0
  62. package/src/eops-skills/exact-tools-and-args.md +5 -0
  63. package/src/eops-skills/full-sequence-to-goal.md +5 -0
  64. package/src/eops-skills/ground-every-value.md +5 -0
  65. package/src/eops-skills/honor-the-policies.md +5 -0
  66. package/src/examples/README.md +58 -0
  67. package/src/examples/math-demo.mts +110 -0
  68. package/src/examples/strategy-demo.mts +119 -0
  69. package/src/fleet.mts +121 -0
  70. package/src/gate-cli.mts +101 -0
  71. package/src/gate.test.mts +129 -0
  72. package/src/gate.ts +460 -0
  73. package/src/generate-eval/certify.ts +178 -0
  74. package/src/generate-eval/schema.ts +78 -0
  75. package/src/humaneval-gate.mts +204 -0
  76. package/src/humaneval-repair-gate.mts +143 -0
  77. package/src/index.ts +19 -0
  78. package/src/mcp-mount-probe.mts +126 -0
  79. package/src/profile-coordinates.ts +134 -0
  80. package/src/profiles.ts +128 -0
  81. package/src/refine-loop.test.mts +106 -0
  82. package/src/refine-loop.ts +106 -0
  83. package/src/research-gate.mts +132 -0
  84. package/src/research-shot.ts +134 -0
  85. package/src/resolve-client.ts +58 -0
  86. package/src/router-executor.ts +51 -0
  87. package/src/run-pool.ts +48 -0
  88. package/src/runtime-hook-recorder.ts +137 -0
  89. package/src/sandbox-run.ts +125 -0
  90. package/src/search-bench/bridge.ts +124 -0
  91. package/src/search-bench/export.mts +0 -0
  92. package/src/search-bench/parametric-check.mts +63 -0
  93. package/src/search-bench/profiles.ts +98 -0
  94. package/src/search-bench/run.mts +287 -0
  95. package/src/search-bench/tasks-fresh.ts +688 -0
  96. package/src/search-bench/tasks.ts +129 -0
  97. package/src/search-tool.ts +95 -0
  98. package/src/selector.test.mts +189 -0
  99. package/src/selector.ts +366 -0
  100. package/src/skill-sandbox-smoke.mts +100 -0
  101. package/src/stats.mts +90 -0
  102. package/src/terminal-compare.ts +519 -0
  103. package/src/trajectory-assemble.mjs +130 -0
  104. package/src/trata-gate.mts +243 -0
  105. package/src/trata-gepa.mts +434 -0
  106. package/src/worker-blender.ts +230 -0
  107. package/src/worker-browser.ts +102 -0
  108. package/src/worker-build123d.ts +143 -0
  109. package/src/worker-cad.ts +451 -0
  110. package/src/worker.ts +136 -0
  111. package/src/workspace-loop.mts +133 -0
@@ -0,0 +1,133 @@
1
+ /**
2
+ * The decisive de-risk: does a git-backed shared workspace make accumulating,
3
+ * resumable, multi-worker loops REAL on a share-nothing substrate?
4
+ *
5
+ * The red-team's fatal finding: each cloud worker is a fresh box with no shared
6
+ * filesystem, so "worker N+1 builds on worker N's code" is impossible and resume
7
+ * restores decisions, not the mutated workspace. The proposed fix: a git-backed
8
+ * contract. This proves or kills it on 3 dependency-ordered modules (a←b←c).
9
+ *
10
+ * - The DURABLE WORKSPACE = a bare git repo (models a GitHub branch in cloud).
11
+ * - Each WORKER = a FRESH temp clone (models a fresh box's empty FS), torn down
12
+ * after it commits+pushes. State survives ONLY because git persisted it.
13
+ * - THE PROOF: a worker asserts its dependency's file is on disk in its fresh
14
+ * clone. Fails on share-nothing (names-in-a-string); passes on the git seam.
15
+ *
16
+ * Test (a) — does it link? full run → integration test imports a←b←c, must pass.
17
+ * Test (b) — resume? KILL_AFTER=b, then RESUME=1: c clones a repo that
18
+ * HAS a+b committed (durable), re-runs ONLY c, links.
19
+ *
20
+ * pnpm exec tsx src/workspace-loop.mts # (a) happy path
21
+ * KILL_AFTER=b pnpm exec tsx src/workspace-loop.mts # die after b
22
+ * RESUME=1 pnpm exec tsx src/workspace-loop.mts # (b) resume → finish c
23
+ */
24
+ import { execFileSync } from 'node:child_process'
25
+ import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
26
+ import { appendFileSync } from 'node:fs'
27
+ import { tmpdir } from 'node:os'
28
+ import { join } from 'node:path'
29
+
30
+ const BARE = '/tmp/workspace-loop.git' // the durable shared workspace (≈ a remote branch)
31
+ const JOURNAL = '/tmp/workspace-loop.journal' // the decision record (which modules are committed)
32
+
33
+ const sh = (cmd: string, args: string[], cwd?: string): string =>
34
+ execFileSync(cmd, args, { cwd, stdio: 'pipe', encoding: 'utf-8' })
35
+ const git = (args: string[], cwd?: string): string =>
36
+ // hooksPath=/dev/null: these are throwaway test clones, not project repos — the
37
+ // operator's global ai-agent-hooks must not run on them.
38
+ sh('git', ['-c', 'core.hooksPath=/dev/null', '-c', 'user.email=loop@tangle', '-c', 'user.name=loop', ...args], cwd)
39
+
40
+ /** a←b←c: c.top(1) = ((1+1)*2)+3 = 7. The integration test imports the whole chain,
41
+ * so it passes ONLY if all three files accumulated in the workspace. */
42
+ const modules = [
43
+ { id: 'a', file: 'a.py', dep: null as string | null, code: 'def base(x):\n return x + 1\n' },
44
+ { id: 'b', file: 'b.py', dep: 'a', code: 'from a import base\n\ndef mid(x):\n return base(x) * 2\n' },
45
+ { id: 'c', file: 'c.py', dep: 'b', code: 'from b import mid\n\ndef top(x):\n return mid(x) + 3\n' },
46
+ ]
47
+ const depFile = (id: string): string => modules.find((m) => m.id === id)!.file
48
+
49
+ function initWorkspace(): void {
50
+ rmSync(BARE, { recursive: true, force: true })
51
+ rmSync(JOURNAL, { force: true })
52
+ git(['init', '--bare', '-b', 'main', BARE])
53
+ // seed: the integration test, on the branch from commit 0.
54
+ const seed = mkdtempSync(join(tmpdir(), 'wl-seed-'))
55
+ git(['clone', BARE, seed])
56
+ writeFileSync(join(seed, 'test_all.py'), 'from c import top\n\nassert top(1) == 7, top(1)\nprint("INTEGRATION OK")\n')
57
+ git(['add', '-A'], seed)
58
+ git(['commit', '-m', 'seed: integration test'], seed)
59
+ git(['push', 'origin', 'main'], seed)
60
+ rmSync(seed, { recursive: true, force: true })
61
+ }
62
+
63
+ function loadJournal(): Set<string> {
64
+ if (!existsSync(JOURNAL)) return new Set()
65
+ return new Set(readFileSync(JOURNAL, 'utf-8').split('\n').filter(Boolean))
66
+ }
67
+
68
+ /** One worker: fresh clone (empty box FS) → verify dep is ON DISK → port → push → torn down. */
69
+ function runWorker(m: (typeof modules)[number]): void {
70
+ const work = mkdtempSync(join(tmpdir(), `wl-${m.id}-`))
71
+ try {
72
+ git(['clone', BARE, work]) // a brand-new, otherwise-empty box
73
+ // THE PROOF: did the durable workspace carry my dependency's code to this fresh box?
74
+ if (m.dep) {
75
+ const present = existsSync(join(work, depFile(m.dep)))
76
+ console.error(` [${m.id}] fresh clone — dependency ${depFile(m.dep)} on disk? ${present ? 'YES ✓ (git carried it)' : 'NO ✗ (share-nothing)'}`)
77
+ if (!present) throw new Error(`SHARE-NOTHING: ${m.id} cannot see ${m.dep} — the seam is broken`)
78
+ } else {
79
+ console.error(` [${m.id}] fresh clone — root module, no dependency`)
80
+ }
81
+ writeFileSync(join(work, m.file), m.code) // port the module
82
+ git(['add', '-A'], work)
83
+ git(['commit', '-m', `port ${m.id}`], work)
84
+ git(['push', 'origin', 'main'], work) // accumulate into the durable workspace
85
+ appendFileSync(JOURNAL, `${m.id}\n`) // record the decision durably
86
+ console.error(` [${m.id}] ported + committed + pushed → torn down`)
87
+ } finally {
88
+ rmSync(work, { recursive: true, force: true }) // teardown — the box dies, git survives
89
+ }
90
+ }
91
+
92
+ /** Test (a): a fresh clone of the durable workspace must pass the integration test. */
93
+ function integrationLinks(): boolean {
94
+ const check = mkdtempSync(join(tmpdir(), 'wl-check-'))
95
+ try {
96
+ git(['clone', BARE, check])
97
+ const out = sh('python3', ['test_all.py'], check)
98
+ console.error(` integration: ${out.trim()}`)
99
+ return out.includes('INTEGRATION OK')
100
+ } catch (e) {
101
+ console.error(` integration FAILED: ${e instanceof Error ? e.message.split('\n').slice(-3).join(' ') : e}`)
102
+ return false
103
+ } finally {
104
+ rmSync(check, { recursive: true, force: true })
105
+ }
106
+ }
107
+
108
+ function main(): void {
109
+ const resume = process.env.RESUME === '1'
110
+ const killAfter = process.env.KILL_AFTER
111
+ if (!resume) initWorkspace()
112
+ const done = loadJournal()
113
+ console.error(`\n=== git-backed workspace loop · ${resume ? 'RESUME' : 'fresh'}${done.size ? ` (done: ${[...done].join(',')})` : ''} ===`)
114
+
115
+ for (const m of modules) {
116
+ if (done.has(m.id)) {
117
+ console.error(` [${m.id}] skip — already committed (resumed from durable git)`)
118
+ continue
119
+ }
120
+ if (m.dep && !loadJournal().has(m.dep)) throw new Error(`${m.id} blocked: dependency ${m.dep} not done (topo order)`)
121
+ runWorker(m)
122
+ if (killAfter === m.id) {
123
+ console.error(`\n💥 KILLED after ${m.id} (orchestrator death). Durable git has: ${[...loadJournal()].join(',')}. Re-run with RESUME=1.\n`)
124
+ process.exit(1)
125
+ }
126
+ }
127
+
128
+ const links = integrationLinks()
129
+ console.error(`\n=== ${links ? '✅ LINKS — git-backed workspace + resume is REAL' : '❌ does not link'} ===`)
130
+ process.exit(links ? 0 : 1)
131
+ }
132
+
133
+ main()