homegraph 1.1.2 → 1.2.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.
- package/LICENSE +21 -21
- package/README.md +268 -243
- package/dist/arkts/ohos-api-index.d.ts +15 -0
- package/dist/arkts/ohos-api-index.d.ts.map +1 -0
- package/dist/arkts/ohos-api-index.js +190 -0
- package/dist/arkts/ohos-api-index.js.map +1 -0
- package/dist/arkts/ohos-sdk-input.d.ts +36 -0
- package/dist/arkts/ohos-sdk-input.d.ts.map +1 -0
- package/dist/arkts/ohos-sdk-input.js +214 -0
- package/dist/arkts/ohos-sdk-input.js.map +1 -0
- package/dist/bin/command-supervision.d.ts +12 -0
- package/dist/bin/command-supervision.d.ts.map +1 -0
- package/dist/bin/command-supervision.js +86 -0
- package/dist/bin/command-supervision.js.map +1 -0
- package/dist/bin/homegraph.d.ts +1 -1
- package/dist/bin/homegraph.js +971 -71
- package/dist/bin/homegraph.js.map +1 -1
- package/dist/db/index.d.ts +20 -0
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +39 -0
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations.d.ts +1 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +58 -19
- package/dist/db/migrations.js.map +1 -1
- package/dist/db/queries.d.ts +14 -0
- package/dist/db/queries.d.ts.map +1 -1
- package/dist/db/queries.js +314 -143
- package/dist/db/queries.js.map +1 -1
- package/dist/db/schema.sql +172 -152
- package/dist/directory.d.ts +32 -0
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +88 -5
- package/dist/directory.js.map +1 -1
- package/dist/extraction/arkts-batch-worker.d.ts +2 -0
- package/dist/extraction/arkts-batch-worker.d.ts.map +1 -0
- package/dist/extraction/arkts-batch-worker.js +28 -0
- package/dist/extraction/arkts-batch-worker.js.map +1 -0
- package/dist/extraction/context.d.ts +11 -0
- package/dist/extraction/context.d.ts.map +1 -1
- package/dist/extraction/context.js +20 -0
- package/dist/extraction/context.js.map +1 -1
- package/dist/extraction/index.d.ts +16 -2
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +619 -380
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/languages/arkts-state-decorators.d.ts +13 -0
- package/dist/extraction/languages/arkts-state-decorators.d.ts.map +1 -0
- package/dist/extraction/languages/arkts-state-decorators.js +26 -0
- package/dist/extraction/languages/arkts-state-decorators.js.map +1 -0
- package/dist/extraction/languages/arkts-viewtree.d.ts +4 -2
- package/dist/extraction/languages/arkts-viewtree.d.ts.map +1 -1
- package/dist/extraction/languages/arkts-viewtree.js +21 -6
- package/dist/extraction/languages/arkts-viewtree.js.map +1 -1
- package/dist/extraction/languages/arkts.d.ts +98 -2
- package/dist/extraction/languages/arkts.d.ts.map +1 -1
- package/dist/extraction/languages/arkts.js +1290 -61
- package/dist/extraction/languages/arkts.js.map +1 -1
- package/dist/extraction/languages/c-cpp.d.ts +56 -0
- package/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/dist/extraction/languages/c-cpp.js +198 -1
- package/dist/extraction/languages/c-cpp.js.map +1 -1
- package/dist/extraction/languages/ohos-api-consumer.d.ts +34 -0
- package/dist/extraction/languages/ohos-api-consumer.d.ts.map +1 -0
- package/dist/extraction/languages/ohos-api-consumer.js +283 -0
- package/dist/extraction/languages/ohos-api-consumer.js.map +1 -0
- package/dist/extraction/parse-pool.d.ts +126 -0
- package/dist/extraction/parse-pool.d.ts.map +1 -0
- package/dist/extraction/parse-pool.js +319 -0
- package/dist/extraction/parse-pool.js.map +1 -0
- package/dist/extraction/tree-sitter-types.d.ts +17 -0
- package/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.d.ts +21 -0
- package/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.js +198 -27
- package/dist/extraction/tree-sitter.js.map +1 -1
- package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
- package/dist/graph/traversal.d.ts.map +1 -1
- package/dist/graph/traversal.js +76 -17
- package/dist/graph/traversal.js.map +1 -1
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -4
- package/dist/index.js.map +1 -1
- package/dist/installer/instructions-template.js +9 -9
- package/dist/installer/targets/shared.d.ts +5 -6
- package/dist/installer/targets/shared.d.ts.map +1 -1
- package/dist/installer/targets/shared.js +5 -6
- package/dist/installer/targets/shared.js.map +1 -1
- package/dist/mcp/daemon-paths.d.ts +30 -3
- package/dist/mcp/daemon-paths.d.ts.map +1 -1
- package/dist/mcp/daemon-paths.js +50 -10
- package/dist/mcp/daemon-paths.js.map +1 -1
- package/dist/mcp/daemon-registry.d.ts.map +1 -1
- package/dist/mcp/daemon-registry.js +7 -3
- package/dist/mcp/daemon-registry.js.map +1 -1
- package/dist/mcp/daemon.d.ts +48 -0
- package/dist/mcp/daemon.d.ts.map +1 -1
- package/dist/mcp/daemon.js +196 -32
- package/dist/mcp/daemon.js.map +1 -1
- package/dist/mcp/engine.d.ts +17 -0
- package/dist/mcp/engine.d.ts.map +1 -1
- package/dist/mcp/engine.js +73 -1
- package/dist/mcp/engine.js.map +1 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +25 -43
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/liveness-watchdog.js +16 -16
- package/dist/mcp/ppid-watchdog.d.ts +18 -0
- package/dist/mcp/ppid-watchdog.d.ts.map +1 -1
- package/dist/mcp/ppid-watchdog.js +37 -0
- package/dist/mcp/ppid-watchdog.js.map +1 -1
- package/dist/mcp/query-cache.d.ts +25 -0
- package/dist/mcp/query-cache.d.ts.map +1 -0
- package/dist/mcp/query-cache.js +191 -0
- package/dist/mcp/query-cache.js.map +1 -0
- package/dist/mcp/query-pool.d.ts +94 -0
- package/dist/mcp/query-pool.d.ts.map +1 -0
- package/dist/mcp/query-pool.js +297 -0
- package/dist/mcp/query-pool.js.map +1 -0
- package/dist/mcp/query-worker.d.ts +24 -0
- package/dist/mcp/query-worker.d.ts.map +1 -0
- package/dist/mcp/query-worker.js +87 -0
- package/dist/mcp/query-worker.js.map +1 -0
- package/dist/mcp/server-instructions.d.ts +5 -7
- package/dist/mcp/server-instructions.d.ts.map +1 -1
- package/dist/mcp/server-instructions.js +72 -74
- package/dist/mcp/server-instructions.js.map +1 -1
- package/dist/mcp/tools.d.ts +94 -4
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +877 -71
- package/dist/mcp/tools.js.map +1 -1
- package/dist/project-config.d.ts +20 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +42 -2
- package/dist/project-config.js.map +1 -1
- package/dist/reasoning/login.js +1 -1
- package/dist/reasoning/login.js.map +1 -1
- package/dist/reasoning/reasoner.js +32 -32
- package/dist/resolution/c-fnptr-synthesizer.d.ts +0 -28
- package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
- package/dist/resolution/c-fnptr-synthesizer.js +765 -79
- package/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
- package/dist/resolution/callback-synthesizer.d.ts +1 -1
- package/dist/resolution/callback-synthesizer.d.ts.map +1 -1
- package/dist/resolution/callback-synthesizer.js +72 -11
- package/dist/resolution/callback-synthesizer.js.map +1 -1
- package/dist/resolution/cooperative-yield.d.ts +32 -0
- package/dist/resolution/cooperative-yield.d.ts.map +1 -0
- package/dist/resolution/cooperative-yield.js +42 -0
- package/dist/resolution/cooperative-yield.js.map +1 -0
- package/dist/resolution/index.d.ts +11 -2
- package/dist/resolution/index.d.ts.map +1 -1
- package/dist/resolution/index.js +72 -4
- package/dist/resolution/index.js.map +1 -1
- package/dist/resolution/name-matcher.d.ts +22 -0
- package/dist/resolution/name-matcher.d.ts.map +1 -1
- package/dist/resolution/name-matcher.js +317 -20
- package/dist/resolution/name-matcher.js.map +1 -1
- package/dist/spec/config.d.ts +39 -0
- package/dist/spec/config.d.ts.map +1 -0
- package/dist/spec/config.js +304 -0
- package/dist/spec/config.js.map +1 -0
- package/dist/spec/db/commit-node.d.ts +23 -0
- package/dist/spec/db/commit-node.d.ts.map +1 -0
- package/dist/spec/db/commit-node.js +62 -0
- package/dist/spec/db/commit-node.js.map +1 -0
- package/dist/spec/db/fragment-node.d.ts +24 -0
- package/dist/spec/db/fragment-node.d.ts.map +1 -0
- package/dist/spec/db/fragment-node.js +128 -0
- package/dist/spec/db/fragment-node.js.map +1 -0
- package/dist/spec/db/fts.d.ts +74 -0
- package/dist/spec/db/fts.d.ts.map +1 -0
- package/dist/spec/db/fts.js +324 -0
- package/dist/spec/db/fts.js.map +1 -0
- package/dist/spec/db/index.d.ts +13 -0
- package/dist/spec/db/index.d.ts.map +1 -0
- package/dist/spec/db/index.js +50 -0
- package/dist/spec/db/index.js.map +1 -0
- package/dist/spec/db/relations.d.ts +55 -0
- package/dist/spec/db/relations.d.ts.map +1 -0
- package/dist/spec/db/relations.js +158 -0
- package/dist/spec/db/relations.js.map +1 -0
- package/dist/spec/db/schema.d.ts +33 -0
- package/dist/spec/db/schema.d.ts.map +1 -0
- package/dist/spec/db/schema.js +119 -0
- package/dist/spec/db/schema.js.map +1 -0
- package/dist/spec/db/schema.sql +117 -0
- package/dist/spec/db/spec-node.d.ts +41 -0
- package/dist/spec/db/spec-node.d.ts.map +1 -0
- package/dist/spec/db/spec-node.js +114 -0
- package/dist/spec/db/spec-node.js.map +1 -0
- package/dist/spec/evolve/impact-locator.d.ts +13 -0
- package/dist/spec/evolve/impact-locator.d.ts.map +1 -0
- package/dist/spec/evolve/impact-locator.js +25 -0
- package/dist/spec/evolve/impact-locator.js.map +1 -0
- package/dist/spec/evolve/llm-client.d.ts +50 -0
- package/dist/spec/evolve/llm-client.d.ts.map +1 -0
- package/dist/spec/evolve/llm-client.js +176 -0
- package/dist/spec/evolve/llm-client.js.map +1 -0
- package/dist/spec/evolve/logic-checker.d.ts +12 -0
- package/dist/spec/evolve/logic-checker.d.ts.map +1 -0
- package/dist/spec/evolve/logic-checker.js +24 -0
- package/dist/spec/evolve/logic-checker.js.map +1 -0
- package/dist/spec/evolve/pipeline.d.ts +42 -0
- package/dist/spec/evolve/pipeline.d.ts.map +1 -0
- package/dist/spec/evolve/pipeline.js +567 -0
- package/dist/spec/evolve/pipeline.js.map +1 -0
- package/dist/spec/evolve/spec-rewriter.d.ts +42 -0
- package/dist/spec/evolve/spec-rewriter.d.ts.map +1 -0
- package/dist/spec/evolve/spec-rewriter.js +230 -0
- package/dist/spec/evolve/spec-rewriter.js.map +1 -0
- package/dist/spec/graph/queries.d.ts +155 -0
- package/dist/spec/graph/queries.d.ts.map +1 -0
- package/dist/spec/graph/queries.js +440 -0
- package/dist/spec/graph/queries.js.map +1 -0
- package/dist/spec/llm/client.d.ts +29 -0
- package/dist/spec/llm/client.d.ts.map +1 -0
- package/dist/spec/llm/client.js +123 -0
- package/dist/spec/llm/client.js.map +1 -0
- package/dist/spec/llm/index.d.ts +3 -0
- package/dist/spec/llm/index.d.ts.map +1 -0
- package/dist/spec/llm/index.js +11 -0
- package/dist/spec/llm/index.js.map +1 -0
- package/dist/spec/llm/prompts.d.ts +13 -0
- package/dist/spec/llm/prompts.d.ts.map +1 -0
- package/dist/spec/llm/prompts.js +75 -0
- package/dist/spec/llm/prompts.js.map +1 -0
- package/dist/spec/mining/diff-parser.d.ts +33 -0
- package/dist/spec/mining/diff-parser.d.ts.map +1 -0
- package/dist/spec/mining/diff-parser.js +166 -0
- package/dist/spec/mining/diff-parser.js.map +1 -0
- package/dist/spec/mining/git-scanner.d.ts +103 -0
- package/dist/spec/mining/git-scanner.d.ts.map +1 -0
- package/dist/spec/mining/git-scanner.js +307 -0
- package/dist/spec/mining/git-scanner.js.map +1 -0
- package/dist/spec/mining/pipeline.d.ts +53 -0
- package/dist/spec/mining/pipeline.d.ts.map +1 -0
- package/dist/spec/mining/pipeline.js +178 -0
- package/dist/spec/mining/pipeline.js.map +1 -0
- package/dist/spec/mining/scope-resolver.d.ts +45 -0
- package/dist/spec/mining/scope-resolver.d.ts.map +1 -0
- package/dist/spec/mining/scope-resolver.js +103 -0
- package/dist/spec/mining/scope-resolver.js.map +1 -0
- package/dist/spec/mining/spec-extractor.d.ts +69 -0
- package/dist/spec/mining/spec-extractor.d.ts.map +1 -0
- package/dist/spec/mining/spec-extractor.js +369 -0
- package/dist/spec/mining/spec-extractor.js.map +1 -0
- package/dist/spec/types.d.ts +149 -0
- package/dist/spec/types.d.ts.map +1 -0
- package/dist/spec/types.js +15 -0
- package/dist/spec/types.js.map +1 -0
- package/dist/spec/utils.d.ts +167 -0
- package/dist/spec/utils.d.ts.map +1 -0
- package/dist/spec/utils.js +463 -0
- package/dist/spec/utils.js.map +1 -0
- package/dist/sync/worktree.d.ts +9 -0
- package/dist/sync/worktree.d.ts.map +1 -1
- package/dist/sync/worktree.js +40 -0
- package/dist/sync/worktree.js.map +1 -1
- package/dist/types.d.ts +6 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/shimmer-progress.d.ts +2 -0
- package/dist/ui/shimmer-progress.d.ts.map +1 -1
- package/dist/ui/shimmer-progress.js +19 -2
- package/dist/ui/shimmer-progress.js.map +1 -1
- package/dist/upgrade/index.js +1 -1
- package/dist/upgrade/index.js.map +1 -1
- package/package.json +58 -57
- package/scripts/add-lang/bench.sh +60 -60
- package/scripts/add-lang/check-grammar.mjs +75 -75
- package/scripts/add-lang/dump-ast.mjs +103 -103
- package/scripts/add-lang/verify-extraction.mjs +70 -70
- package/scripts/agent-eval/ab-adoption.sh +91 -91
- package/scripts/agent-eval/ab-hook.sh +86 -86
- package/scripts/agent-eval/ab-impl.sh +78 -78
- package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -102
- package/scripts/agent-eval/ab-sufficiency.sh +78 -78
- package/scripts/agent-eval/arms-F.sh +21 -21
- package/scripts/agent-eval/arms-matrix.sh +37 -37
- package/scripts/agent-eval/audit.sh +68 -68
- package/scripts/agent-eval/bench-readme.sh +28 -28
- package/scripts/agent-eval/bench-why-repo.sh +22 -22
- package/scripts/agent-eval/block-read-hook.sh +19 -19
- package/scripts/agent-eval/hook-settings.json +15 -15
- package/scripts/agent-eval/itrun.sh +120 -120
- package/scripts/agent-eval/offload-eval-3arm.sh +72 -72
- package/scripts/agent-eval/offload-eval-cost.mjs +133 -133
- package/scripts/agent-eval/offload-eval-effort.mjs +108 -108
- package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -25
- package/scripts/agent-eval/offload-eval-frontload.sh +47 -47
- package/scripts/agent-eval/offload-eval-ground-truth.json +18 -18
- package/scripts/agent-eval/offload-eval-hook.mjs +84 -84
- package/scripts/agent-eval/offload-eval-judge.mjs +103 -103
- package/scripts/agent-eval/offload-eval-matrix.sh +20 -20
- package/scripts/agent-eval/offload-eval-metrics.mjs +94 -94
- package/scripts/agent-eval/offload-eval-refs1.sh +50 -50
- package/scripts/agent-eval/offload-eval-setup.sh +24 -24
- package/scripts/agent-eval/offload-eval-styles.sh +71 -71
- package/scripts/agent-eval/offload-eval-summarize.mjs +68 -68
- package/scripts/agent-eval/offload-eval.md +76 -76
- package/scripts/agent-eval/parse-arms.mjs +116 -116
- package/scripts/agent-eval/parse-bench-readme.mjs +84 -84
- package/scripts/agent-eval/parse-run.mjs +45 -45
- package/scripts/agent-eval/parse-session.mjs +93 -93
- package/scripts/agent-eval/probe-context.mjs +21 -21
- package/scripts/agent-eval/probe-explore.mjs +40 -40
- package/scripts/agent-eval/probe-node.mjs +20 -20
- package/scripts/agent-eval/probe-sweep.mjs +119 -119
- package/scripts/agent-eval/probe-trace.mjs +20 -20
- package/scripts/agent-eval/redirect-read-hook.sh +38 -38
- package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
- package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
- package/scripts/agent-eval/run-agent.sh +34 -34
- package/scripts/agent-eval/run-all.sh +69 -69
- package/scripts/agent-eval/run-arms.sh +56 -56
- package/scripts/agent-eval/seq-matrix.mjs +137 -137
- package/scripts/build-bundle.sh +118 -118
- package/scripts/exp_boundary_eval/README.md +247 -0
- package/scripts/exp_boundary_eval/__pycache__/_utils.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/analyze.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/deveco_arm.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_one.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_session.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/setup.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/_test_mcp_chain.py +78 -0
- package/scripts/exp_boundary_eval/_test_stdin.py +8 -0
- package/scripts/exp_boundary_eval/_utils.py +1116 -0
- package/scripts/exp_boundary_eval/analyze.py +1313 -0
- package/scripts/exp_boundary_eval/data/agents.json +109 -0
- package/scripts/exp_boundary_eval/data/experiments.json +140 -0
- package/scripts/exp_boundary_eval/deveco_arm.py +519 -0
- package/scripts/exp_boundary_eval/run_all.py +378 -0
- package/scripts/exp_boundary_eval/run_one.py +165 -0
- package/scripts/exp_boundary_eval/run_session.py +158 -0
- package/scripts/exp_boundary_eval/setup.py +120 -0
- package/scripts/exp_boundary_eval/win_mcp_launcher.py +73 -0
- package/scripts/exp_boundary_eval/win_mcp_stdio_wrap.js +36 -0
- package/scripts/exp_boundary_eval/win_node_launcher.py +24 -0
- package/scripts/extract-release-notes.mjs +130 -130
- package/scripts/local-install.sh +41 -41
- package/scripts/npm-sdk.js +75 -75
- package/scripts/npm-shim.js +268 -246
- package/scripts/ohos-sdk-publish.mjs +133 -0
- package/scripts/pack-npm.sh +119 -119
- package/scripts/prepare-release.mjs +270 -270
- package/scripts/qa_eval/README.md +407 -404
- package/scripts/qa_eval/_test_deveco_probe.py +41 -41
- package/scripts/qa_eval/agent_runner.py +526 -526
- package/scripts/qa_eval/data/.gitignore +4 -4
- package/scripts/qa_eval/data/test-set.jsonl +2 -22
- package/scripts/qa_eval/eval_metrics.py +274 -233
- package/scripts/qa_eval/external_agent.py +976 -671
- package/scripts/qa_eval/llm_config.py +92 -92
- package/scripts/qa_eval/memory_monitor.py +132 -132
- package/scripts/qa_eval/my_answer_accuracy.py +187 -187
- package/scripts/qa_eval/requirements.txt +2 -2
- package/scripts/qa_eval/run_pipeline.py +804 -711
- package/scripts/qa_eval/stats_efficiency.py +279 -279
- package/scripts/qa_eval/stats_scores.py +207 -207
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# FRONTLOAD arm (approach 1): homegraph attached (offload-disabled) + the front-load
|
|
3
|
-
# UserPromptSubmit hook (offload-eval-hook.mjs), n reps, appended to $RESULTS. Compare against
|
|
4
|
-
# the matrix's raw/nocg baselines. Usage: offload-eval-frontload.sh <indexed-repo> <tier> <reps> "<Q>"
|
|
5
|
-
# Env: MODEL=sonnet EFFORT=high RESULTS=<file> AGENT_EVAL_OUT=<scratch dir>
|
|
6
|
-
set -uo pipefail
|
|
7
|
-
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
8
|
-
ENGINE="$(cd "$HERE/../.." && pwd)"
|
|
9
|
-
BIN="$ENGINE/dist/bin/homegraph.js"
|
|
10
|
-
OUT="${AGENT_EVAL_OUT:-/tmp/cg-offload-eval}"
|
|
11
|
-
TARGET="${1:?repo}"; TIER="${2:?tier}"; REPS="${3:?reps}"; Q="${4:?question}"
|
|
12
|
-
RUNS="$OUT/runs"
|
|
13
|
-
EXTRACT="$HERE/offload-eval-metrics.mjs"
|
|
14
|
-
RESULTS="${RESULTS:-$OUT/results-fl.jsonl}"
|
|
15
|
-
REPO=$(basename "$TARGET")
|
|
16
|
-
mkdir -p "$RUNS"
|
|
17
|
-
[ -d "$TARGET/.homegraph" ] || { echo "not indexed: $TARGET"; exit 1; }
|
|
18
|
-
TARGET=$(cd "$TARGET" && pwd -P)
|
|
19
|
-
|
|
20
|
-
CFG="$RUNS/mcp-fl-$REPO.json"
|
|
21
|
-
printf '{"mcpServers":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","HOMEGRAPH_OFFLOAD_DISABLE=1","node","%s","serve","--mcp","--path","%s"]}}}' "$BIN" "$TARGET" > "$CFG"
|
|
22
|
-
# Generate the hook settings pointing at the persisted hook; enable its debug log so we can
|
|
23
|
-
# count injections (claude passes this env down to the spawned hook process).
|
|
24
|
-
HOOKCFG="$RUNS/frontload-settings.json"
|
|
25
|
-
printf '{"hooks":{"UserPromptSubmit":[{"hooks":[{"type":"command","command":"node %s/offload-eval-hook.mjs"}]}]}}' "$HERE" > "$HOOKCFG"
|
|
26
|
-
export CG_FRONTLOAD_DEBUG="$RUNS/hook-debug.log"
|
|
27
|
-
|
|
28
|
-
prewarm() {
|
|
29
|
-
pkill -9 -f "serve --mcp --path $1" 2>/dev/null; rm -f "$1/.homegraph/daemon.sock" 2>/dev/null; sleep 0.6
|
|
30
|
-
env HOMEGRAPH_OFFLOAD_DISABLE=1 HOMEGRAPH_DAEMON_IDLE_TIMEOUT_MS=1800000 node "$BIN" serve --mcp --path "$1" </dev/null >/dev/null 2>&1 &
|
|
31
|
-
node -e 'const fs=require("fs");let n=0;const t=setInterval(()=>{if(fs.existsSync(process.argv[1]+"/.homegraph/daemon.sock")){clearInterval(t);process.exit(0)}if(n++>150){clearInterval(t);process.exit(1)}},100)' "$1" \
|
|
32
|
-
&& echo " daemon warm" || echo " WARN no daemon"
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
echo "###### FRONTLOAD repo=$REPO tier=$TIER reps=$REPS"
|
|
36
|
-
prewarm "$TARGET"
|
|
37
|
-
for r in $(seq 1 "$REPS"); do
|
|
38
|
-
tag="$REPO-frontload-$r"
|
|
39
|
-
( cd "$TARGET" && claude -p "$Q" --output-format stream-json --verbose --permission-mode bypassPermissions \
|
|
40
|
-
--model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4 \
|
|
41
|
-
--strict-mcp-config --mcp-config "$CFG" --settings "$HOOKCFG" \
|
|
42
|
-
</dev/null > "$RUNS/$tag.jsonl" 2>"$RUNS/$tag.err" )
|
|
43
|
-
node "$EXTRACT" --run "$RUNS/$tag.jsonl" --usage "-" --arm frontload --rep "$r" --repo "$REPO" --tier "$TIER" --q "$Q" >> "$RESULTS"
|
|
44
|
-
node -e 'const o=JSON.parse(require("fs").readFileSync(process.argv[1],"utf8").trim().split("\n").pop());console.log(` [frontload #${o.rep}] ${o.durationSec}s | main $${o.costUsdMain} ${o.tokBillable}tok | read=${o.read} grep=${o.grep} agentExplore=${o.explore} | ok=${o.ok}`)' "$RESULTS"
|
|
45
|
-
done
|
|
46
|
-
pkill -9 -f "serve --mcp --path $TARGET" 2>/dev/null; rm -f "$TARGET/.homegraph/daemon.sock" 2>/dev/null
|
|
47
|
-
echo "###### FRONTLOAD DONE $REPO (cumulative hook injections: $(grep -c INJECTED "$CG_FRONTLOAD_DEBUG" 2>/dev/null))"
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# FRONTLOAD arm (approach 1): homegraph attached (offload-disabled) + the front-load
|
|
3
|
+
# UserPromptSubmit hook (offload-eval-hook.mjs), n reps, appended to $RESULTS. Compare against
|
|
4
|
+
# the matrix's raw/nocg baselines. Usage: offload-eval-frontload.sh <indexed-repo> <tier> <reps> "<Q>"
|
|
5
|
+
# Env: MODEL=sonnet EFFORT=high RESULTS=<file> AGENT_EVAL_OUT=<scratch dir>
|
|
6
|
+
set -uo pipefail
|
|
7
|
+
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
8
|
+
ENGINE="$(cd "$HERE/../.." && pwd)"
|
|
9
|
+
BIN="$ENGINE/dist/bin/homegraph.js"
|
|
10
|
+
OUT="${AGENT_EVAL_OUT:-/tmp/cg-offload-eval}"
|
|
11
|
+
TARGET="${1:?repo}"; TIER="${2:?tier}"; REPS="${3:?reps}"; Q="${4:?question}"
|
|
12
|
+
RUNS="$OUT/runs"
|
|
13
|
+
EXTRACT="$HERE/offload-eval-metrics.mjs"
|
|
14
|
+
RESULTS="${RESULTS:-$OUT/results-fl.jsonl}"
|
|
15
|
+
REPO=$(basename "$TARGET")
|
|
16
|
+
mkdir -p "$RUNS"
|
|
17
|
+
[ -d "$TARGET/.homegraph" ] || { echo "not indexed: $TARGET"; exit 1; }
|
|
18
|
+
TARGET=$(cd "$TARGET" && pwd -P)
|
|
19
|
+
|
|
20
|
+
CFG="$RUNS/mcp-fl-$REPO.json"
|
|
21
|
+
printf '{"mcpServers":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","HOMEGRAPH_OFFLOAD_DISABLE=1","node","%s","serve","--mcp","--path","%s"]}}}' "$BIN" "$TARGET" > "$CFG"
|
|
22
|
+
# Generate the hook settings pointing at the persisted hook; enable its debug log so we can
|
|
23
|
+
# count injections (claude passes this env down to the spawned hook process).
|
|
24
|
+
HOOKCFG="$RUNS/frontload-settings.json"
|
|
25
|
+
printf '{"hooks":{"UserPromptSubmit":[{"hooks":[{"type":"command","command":"node %s/offload-eval-hook.mjs"}]}]}}' "$HERE" > "$HOOKCFG"
|
|
26
|
+
export CG_FRONTLOAD_DEBUG="$RUNS/hook-debug.log"
|
|
27
|
+
|
|
28
|
+
prewarm() {
|
|
29
|
+
pkill -9 -f "serve --mcp --path $1" 2>/dev/null; rm -f "$1/.homegraph/daemon.sock" 2>/dev/null; sleep 0.6
|
|
30
|
+
env HOMEGRAPH_OFFLOAD_DISABLE=1 HOMEGRAPH_DAEMON_IDLE_TIMEOUT_MS=1800000 node "$BIN" serve --mcp --path "$1" </dev/null >/dev/null 2>&1 &
|
|
31
|
+
node -e 'const fs=require("fs");let n=0;const t=setInterval(()=>{if(fs.existsSync(process.argv[1]+"/.homegraph/daemon.sock")){clearInterval(t);process.exit(0)}if(n++>150){clearInterval(t);process.exit(1)}},100)' "$1" \
|
|
32
|
+
&& echo " daemon warm" || echo " WARN no daemon"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
echo "###### FRONTLOAD repo=$REPO tier=$TIER reps=$REPS"
|
|
36
|
+
prewarm "$TARGET"
|
|
37
|
+
for r in $(seq 1 "$REPS"); do
|
|
38
|
+
tag="$REPO-frontload-$r"
|
|
39
|
+
( cd "$TARGET" && claude -p "$Q" --output-format stream-json --verbose --permission-mode bypassPermissions \
|
|
40
|
+
--model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4 \
|
|
41
|
+
--strict-mcp-config --mcp-config "$CFG" --settings "$HOOKCFG" \
|
|
42
|
+
</dev/null > "$RUNS/$tag.jsonl" 2>"$RUNS/$tag.err" )
|
|
43
|
+
node "$EXTRACT" --run "$RUNS/$tag.jsonl" --usage "-" --arm frontload --rep "$r" --repo "$REPO" --tier "$TIER" --q "$Q" >> "$RESULTS"
|
|
44
|
+
node -e 'const o=JSON.parse(require("fs").readFileSync(process.argv[1],"utf8").trim().split("\n").pop());console.log(` [frontload #${o.rep}] ${o.durationSec}s | main $${o.costUsdMain} ${o.tokBillable}tok | read=${o.read} grep=${o.grep} agentExplore=${o.explore} | ok=${o.ok}`)' "$RESULTS"
|
|
45
|
+
done
|
|
46
|
+
pkill -9 -f "serve --mcp --path $TARGET" 2>/dev/null; rm -f "$TARGET/.homegraph/daemon.sock" 2>/dev/null
|
|
47
|
+
echo "###### FRONTLOAD DONE $REPO (cumulative hook injections: $(grep -c INJECTED "$CG_FRONTLOAD_DEBUG" 2>/dev/null))"
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mtkruto": {
|
|
3
|
-
"question": "How does calling the high-level client.sendMessage() method get the message serialized into a TL/MTProto request and sent over the network transport to Telegram's servers? Trace the call path.",
|
|
4
|
-
"truth": "Verified call path (small TS Telegram-client lib):\n1. Client.sendMessage — client/6_client.ts:1852 → calls this.#messageManager.sendMessage(...) (1853)\n2. MessageManager.sendMessage — client/3_message_manager.ts:330 → builds the TL function {_:\"messages.sendMessage\", peer, message,...} and calls this.#c.invoke(...) (~377)\n3. c.invoke closure / Client.#invoke — client/6_client.ts:279/887 → resolves a ClientEncrypted and calls client.invoke(function_) (897)\n4. ClientEncrypted.invoke — client/2_client_encrypted.ts:324 → this.#send(function_) (325)\n5. ClientEncrypted.#send — client/2_client_encrypted.ts:261 → SERIALIZES via Api.serializeObject(function_) (290), then this.session.send(body) (296)\n - Serialization: Api.serializeObject (tl/2_telegram.ts:38) → new TLWriter().writeObject(...) (tl/1_tl_writer.ts) writes constructor id + fields\n6. SessionEncrypted.send — session/2_session_encrypted.ts:193 → ENQUEUES a PendingMessage and wakes the send loop (#awakeSendLoop) [DYNAMIC: async queue, not a direct call]\n7. SessionEncrypted.#sendLoopBody (AbortableLoop) — session/2_session_encrypted.ts:282 → #encryptMessage (serializeMessage tl/2_message.ts + IGE-256 AES) then this.transport.transport.send(payload) (339)\n8. Transport.send — TransportAbridged.send (transport/1_transport_abridged.ts:71) or TransportIntermediate → this.#connection.write(encrypt(framed))\n9. ConnectionTCP.write (connection/1_connection_tcp.ts:96) or ConnectionWebSocket.write — bytes exit the process.\nKEY SYMBOLS a correct answer must hit: sendMessage → MessageManager.sendMessage → invoke (ClientEncrypted.invoke/#send) → Api.serializeObject/TLWriter → SessionEncrypted.send (queue) → #sendLoopBody/#encryptMessage → Transport.send → Connection.write.\nDYNAMIC BOUNDARIES: the invoke indirection (closure→#invoke→ClientEncrypted), and the send-loop QUEUE between SessionEncrypted.send and #sendLoopBody (async, no direct edge)."
|
|
5
|
-
},
|
|
6
|
-
"postybirb": {
|
|
7
|
-
"question": "How does submitting/queueing a post reach the website-specific code that actually uploads to a target website? Trace the path from the submission entry point in the NestJS server to a concrete website service's post implementation.",
|
|
8
|
-
"truth": "Verified call path (NestJS+Electron, server under electron-app/src/server/):\n1. Entry: PostController.queue (submission/post/post.controller.ts:33, POST queue/:id) OR SubmissionService.queueScheduledSubmissions (submission/submission.service.ts, @Interval(60000) scheduler) — both call PostService.queue\n2. PostService.queue — submission/post/post.service.ts:68 → this.post(submission)\n3. PostService.post (private) — post.service.ts:206 → this.createPoster(...) for each non-default SubmissionPart\n4. PostService.createPoster — post.service.ts:373 → website = this.websites.getWebsiteModule(part.website) [part.website is a STRING]\n5. WebsiteProvider.getWebsiteModule — websites/website-provider.service.ts:86 → websiteModulesMap[name.toLowerCase()] [DYNAMIC: string-keyed registry of DI-injected Website singletons]; then new Poster(..., website, ...)\n6. Poster constructor — submission/post/poster.ts:117 → setTimeout(this.post.bind(this), delay) [DYNAMIC: async timer, min ~5s]\n7. Poster.post (poster.ts:131) → performPost (171) → attemptPost (217)\n8. Poster.attemptPost — poster.ts:217 → this.website.postFileSubmission(token, data, accountData) [DYNAMIC: polymorphic dispatch on abstract Website] (or postNotificationSubmission)\n9. Website.postFileSubmission (abstract) — websites/website.base.ts:102\n10. Concrete e.g. FurAffinity.postFileSubmission — websites/fur-affinity/fur-affinity.service.ts:231 → multi-step HTTP upload (GET /submit, POST /submit/upload multipart, POST /submit/finalize)\nKEY SYMBOLS: PostService.queue → PostService.post → createPoster → WebsiteProvider.getWebsiteModule (registry) → Poster (setTimeout) → Poster.attemptPost → Website.postFileSubmission (abstract base) → a concrete website service (e.g. FurAffinity).\nDYNAMIC BOUNDARIES: NestJS DI builds the website registry; string-keyed map lookup; setTimeout defers Poster.post; polymorphic dispatch on the abstract Website base. A correct answer must reach a concrete website's post via the registry + base class, not stop at PostService."
|
|
9
|
-
},
|
|
10
|
-
"shapeshift": {
|
|
11
|
-
"question": "How does executing a swap work in ShapeShift — from the code that fetches quotes and selects a swapper down to a specific swapper's execute/trade? Name the swapper interface, the registry, and one concrete swapper, and trace the path.",
|
|
12
|
-
"truth": "Verified call path (large multi-package monorepo; swap logic in packages/swapper + execution in src/lib):\nQUOTE/REGISTRY layer:\n- Swapper interface = the `Swapper` type (execute methods) + `SwapperApi` type (getTradeQuote/getUnsignedTx) — packages/swapper/src/types.ts (~846/897)\n- Registry = `swappers: Record<SwapperName,(SwapperApi & Swapper)>` — packages/swapper/src/constants.ts:52 (merges e.g. thorchainSwapper + thorchainApi)\n- Aggregator: swapperApi RTK endpoint getTradeQuote/getTradeRates (src/state/apis/swapper/swapperApi.ts:78/156) → getTradeQuotes (packages/swapper/src/swapper.ts:18/26): swapper = swappers[swapperName]; swapper.getTradeQuote(...) [DYNAMIC interface dispatch]\n- Concrete (THORChain): thorchainApi.getTradeQuote (swappers/ThorchainSwapper/endpoints.ts → getTradeQuote/getTradeQuote.ts:15) → getL1RateOrQuote → getQuote (thorService HTTP)\nSELECTION: tradeQuoteSlice selectors rank quotes (selectSortedTradeQuotes / selectActiveSwapperName) [DYNAMIC: winner chosen by ranking/user]\nEXECUTION layer:\n- useTradeExecution (src/components/MultiHopTrade/.../hooks/useTradeExecution.tsx:200/476) → new TradeExecution(); execution.execEvmTransaction(...) (CowSwap: execEvmMessage)\n- TradeExecution.execEvmTransaction — src/lib/tradeExecution.ts:326 → _execWalletAgnostic(...) (372)\n- TradeExecution._execWalletAgnostic — tradeExecution.ts:136 → swapper = swappers[swapperName] (149) [DYNAMIC registry]; buildSignBroadcast → swapper.getUnsignedEvmTransaction(...) (355) then swapper.executeEvmTransaction(unsignedTx, {signAndBroadcastTransaction}) (367) [DYNAMIC SwapperApi/Swapper interface]\n- Concrete (THORChain): thorchainSwapper.executeEvmTransaction (swappers/ThorchainSwapper/ThorchainSwapper.ts → utils.ts:181) delegates to callbacks.signAndBroadcastTransaction (wallet). CowSwap alt: cowSwapper.executeEvmMessage → signCowOrder + cowService.post.\nKEY SYMBOLS: Swapper/SwapperApi types, swappers registry (constants.ts), getTradeQuotes (swapper.ts), TradeExecution._execWalletAgnostic, swapper.getUnsignedEvmTransaction/executeEvmTransaction, one concrete swapper (thorchainSwapper/zrxSwapper/cowSwapper).\nDYNAMIC BOUNDARIES: swappers[name] registry lookup (2 sites); all hops into a concrete swapper are via the Swapper/SwapperApi interface, never a direct function. A correct answer must name the interface + registry and reach a concrete swapper through interface dispatch."
|
|
13
|
-
},
|
|
14
|
-
"trezor": {
|
|
15
|
-
"question": "How does sending a crypto transaction flow from the send form's review/sign action through to signing it via @trezor/connect (TrezorConnect.signTransaction)? Trace the call path.",
|
|
16
|
-
"truth": "Verified call path (trezor-suite monorepo; app in packages/suite, shared logic in suite-common/wallet-core, device API in packages/connect):\n1. ReviewButton.handleButtonReviewClick — packages/suite/src/views/wallet/send/TotalSent/ReviewButton.tsx:120 → signTransaction() (= useSendForm's sign)\n2. useSendForm.sign (exported as signTransaction) — packages/suite/src/hooks/wallet/useSendForm.ts:278 → dispatch(signAndPushSendFormTransactionThunk({formState, precomposedTransaction, selectedAccount})) [DYNAMIC: redux thunk]\n3. signAndPushSendFormTransactionThunk — packages/suite/src/actions/wallet/send/sendFormThunks.ts:237 → (first enhancePrecomposedTransactionThunk) then dispatch(signTransactionThunk({...})) [cross-package: thunk from suite-common/wallet-core]\n4. signTransactionThunk (coin-routing hub) — suite-common/wallet-core/src/send/sendFormThunks.ts:532/573 → networkType branch → dispatch(signBitcoinSendFormTransactionThunk) (ethereum→signEthereumSendFormTransactionThunk, etc.) [DYNAMIC: runtime coin dispatch]\n5. signBitcoinSendFormTransactionThunk — suite-common/wallet-core/src/send/sendFormBitcoinThunks.ts:394 → await TrezorConnect.signTransaction(signPayload)\n6. TrezorConnect.signTransaction (facade) — packages/connect-common/src/factory.ts → closure calls impl.call({method:'signTransaction',...}) [DYNAMIC: facade / iframe-or-module boundary]\n7. CoreInModule.call — packages/connect/src/impl/core-in-module.ts:171 → posts CORE_CALL to core (deferred promise)\n8. Core.onCall → getMethod — packages/connect/src/core/index.ts → getMethod resolves 'signTransaction' → new SignTransaction(message) [DYNAMIC: name→class]\n9. SignTransaction.run — packages/connect/src/api/signTransaction.ts:317 → signTx via device.getCommands().typedCall (protobuf to device). After signing, signAndPushSendFormTransactionThunk → pushSendFormTransactionThunk → TrezorConnect.pushTransaction.\nKEY SYMBOLS: ReviewButton → useSendForm.sign → signAndPushSendFormTransactionThunk (suite) → signTransactionThunk (wallet-core, coin hub) → signBitcoinSendFormTransactionThunk → TrezorConnect.signTransaction → connect factory/CoreInModule.call → SignTransaction.run.\nDYNAMIC BOUNDARIES: every suite→wallet-core hop is a redux thunk dispatch; signTransactionThunk branches by networkType at runtime; TrezorConnect is a dynamically-built facade crossing an iframe/module boundary; the SignTransaction class is resolved by name. A correct answer must cross suite→wallet-core→connect and reach TrezorConnect.signTransaction / SignTransaction.run, not stop at the UI."
|
|
17
|
-
}
|
|
18
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"mtkruto": {
|
|
3
|
+
"question": "How does calling the high-level client.sendMessage() method get the message serialized into a TL/MTProto request and sent over the network transport to Telegram's servers? Trace the call path.",
|
|
4
|
+
"truth": "Verified call path (small TS Telegram-client lib):\n1. Client.sendMessage — client/6_client.ts:1852 → calls this.#messageManager.sendMessage(...) (1853)\n2. MessageManager.sendMessage — client/3_message_manager.ts:330 → builds the TL function {_:\"messages.sendMessage\", peer, message,...} and calls this.#c.invoke(...) (~377)\n3. c.invoke closure / Client.#invoke — client/6_client.ts:279/887 → resolves a ClientEncrypted and calls client.invoke(function_) (897)\n4. ClientEncrypted.invoke — client/2_client_encrypted.ts:324 → this.#send(function_) (325)\n5. ClientEncrypted.#send — client/2_client_encrypted.ts:261 → SERIALIZES via Api.serializeObject(function_) (290), then this.session.send(body) (296)\n - Serialization: Api.serializeObject (tl/2_telegram.ts:38) → new TLWriter().writeObject(...) (tl/1_tl_writer.ts) writes constructor id + fields\n6. SessionEncrypted.send — session/2_session_encrypted.ts:193 → ENQUEUES a PendingMessage and wakes the send loop (#awakeSendLoop) [DYNAMIC: async queue, not a direct call]\n7. SessionEncrypted.#sendLoopBody (AbortableLoop) — session/2_session_encrypted.ts:282 → #encryptMessage (serializeMessage tl/2_message.ts + IGE-256 AES) then this.transport.transport.send(payload) (339)\n8. Transport.send — TransportAbridged.send (transport/1_transport_abridged.ts:71) or TransportIntermediate → this.#connection.write(encrypt(framed))\n9. ConnectionTCP.write (connection/1_connection_tcp.ts:96) or ConnectionWebSocket.write — bytes exit the process.\nKEY SYMBOLS a correct answer must hit: sendMessage → MessageManager.sendMessage → invoke (ClientEncrypted.invoke/#send) → Api.serializeObject/TLWriter → SessionEncrypted.send (queue) → #sendLoopBody/#encryptMessage → Transport.send → Connection.write.\nDYNAMIC BOUNDARIES: the invoke indirection (closure→#invoke→ClientEncrypted), and the send-loop QUEUE between SessionEncrypted.send and #sendLoopBody (async, no direct edge)."
|
|
5
|
+
},
|
|
6
|
+
"postybirb": {
|
|
7
|
+
"question": "How does submitting/queueing a post reach the website-specific code that actually uploads to a target website? Trace the path from the submission entry point in the NestJS server to a concrete website service's post implementation.",
|
|
8
|
+
"truth": "Verified call path (NestJS+Electron, server under electron-app/src/server/):\n1. Entry: PostController.queue (submission/post/post.controller.ts:33, POST queue/:id) OR SubmissionService.queueScheduledSubmissions (submission/submission.service.ts, @Interval(60000) scheduler) — both call PostService.queue\n2. PostService.queue — submission/post/post.service.ts:68 → this.post(submission)\n3. PostService.post (private) — post.service.ts:206 → this.createPoster(...) for each non-default SubmissionPart\n4. PostService.createPoster — post.service.ts:373 → website = this.websites.getWebsiteModule(part.website) [part.website is a STRING]\n5. WebsiteProvider.getWebsiteModule — websites/website-provider.service.ts:86 → websiteModulesMap[name.toLowerCase()] [DYNAMIC: string-keyed registry of DI-injected Website singletons]; then new Poster(..., website, ...)\n6. Poster constructor — submission/post/poster.ts:117 → setTimeout(this.post.bind(this), delay) [DYNAMIC: async timer, min ~5s]\n7. Poster.post (poster.ts:131) → performPost (171) → attemptPost (217)\n8. Poster.attemptPost — poster.ts:217 → this.website.postFileSubmission(token, data, accountData) [DYNAMIC: polymorphic dispatch on abstract Website] (or postNotificationSubmission)\n9. Website.postFileSubmission (abstract) — websites/website.base.ts:102\n10. Concrete e.g. FurAffinity.postFileSubmission — websites/fur-affinity/fur-affinity.service.ts:231 → multi-step HTTP upload (GET /submit, POST /submit/upload multipart, POST /submit/finalize)\nKEY SYMBOLS: PostService.queue → PostService.post → createPoster → WebsiteProvider.getWebsiteModule (registry) → Poster (setTimeout) → Poster.attemptPost → Website.postFileSubmission (abstract base) → a concrete website service (e.g. FurAffinity).\nDYNAMIC BOUNDARIES: NestJS DI builds the website registry; string-keyed map lookup; setTimeout defers Poster.post; polymorphic dispatch on the abstract Website base. A correct answer must reach a concrete website's post via the registry + base class, not stop at PostService."
|
|
9
|
+
},
|
|
10
|
+
"shapeshift": {
|
|
11
|
+
"question": "How does executing a swap work in ShapeShift — from the code that fetches quotes and selects a swapper down to a specific swapper's execute/trade? Name the swapper interface, the registry, and one concrete swapper, and trace the path.",
|
|
12
|
+
"truth": "Verified call path (large multi-package monorepo; swap logic in packages/swapper + execution in src/lib):\nQUOTE/REGISTRY layer:\n- Swapper interface = the `Swapper` type (execute methods) + `SwapperApi` type (getTradeQuote/getUnsignedTx) — packages/swapper/src/types.ts (~846/897)\n- Registry = `swappers: Record<SwapperName,(SwapperApi & Swapper)>` — packages/swapper/src/constants.ts:52 (merges e.g. thorchainSwapper + thorchainApi)\n- Aggregator: swapperApi RTK endpoint getTradeQuote/getTradeRates (src/state/apis/swapper/swapperApi.ts:78/156) → getTradeQuotes (packages/swapper/src/swapper.ts:18/26): swapper = swappers[swapperName]; swapper.getTradeQuote(...) [DYNAMIC interface dispatch]\n- Concrete (THORChain): thorchainApi.getTradeQuote (swappers/ThorchainSwapper/endpoints.ts → getTradeQuote/getTradeQuote.ts:15) → getL1RateOrQuote → getQuote (thorService HTTP)\nSELECTION: tradeQuoteSlice selectors rank quotes (selectSortedTradeQuotes / selectActiveSwapperName) [DYNAMIC: winner chosen by ranking/user]\nEXECUTION layer:\n- useTradeExecution (src/components/MultiHopTrade/.../hooks/useTradeExecution.tsx:200/476) → new TradeExecution(); execution.execEvmTransaction(...) (CowSwap: execEvmMessage)\n- TradeExecution.execEvmTransaction — src/lib/tradeExecution.ts:326 → _execWalletAgnostic(...) (372)\n- TradeExecution._execWalletAgnostic — tradeExecution.ts:136 → swapper = swappers[swapperName] (149) [DYNAMIC registry]; buildSignBroadcast → swapper.getUnsignedEvmTransaction(...) (355) then swapper.executeEvmTransaction(unsignedTx, {signAndBroadcastTransaction}) (367) [DYNAMIC SwapperApi/Swapper interface]\n- Concrete (THORChain): thorchainSwapper.executeEvmTransaction (swappers/ThorchainSwapper/ThorchainSwapper.ts → utils.ts:181) delegates to callbacks.signAndBroadcastTransaction (wallet). CowSwap alt: cowSwapper.executeEvmMessage → signCowOrder + cowService.post.\nKEY SYMBOLS: Swapper/SwapperApi types, swappers registry (constants.ts), getTradeQuotes (swapper.ts), TradeExecution._execWalletAgnostic, swapper.getUnsignedEvmTransaction/executeEvmTransaction, one concrete swapper (thorchainSwapper/zrxSwapper/cowSwapper).\nDYNAMIC BOUNDARIES: swappers[name] registry lookup (2 sites); all hops into a concrete swapper are via the Swapper/SwapperApi interface, never a direct function. A correct answer must name the interface + registry and reach a concrete swapper through interface dispatch."
|
|
13
|
+
},
|
|
14
|
+
"trezor": {
|
|
15
|
+
"question": "How does sending a crypto transaction flow from the send form's review/sign action through to signing it via @trezor/connect (TrezorConnect.signTransaction)? Trace the call path.",
|
|
16
|
+
"truth": "Verified call path (trezor-suite monorepo; app in packages/suite, shared logic in suite-common/wallet-core, device API in packages/connect):\n1. ReviewButton.handleButtonReviewClick — packages/suite/src/views/wallet/send/TotalSent/ReviewButton.tsx:120 → signTransaction() (= useSendForm's sign)\n2. useSendForm.sign (exported as signTransaction) — packages/suite/src/hooks/wallet/useSendForm.ts:278 → dispatch(signAndPushSendFormTransactionThunk({formState, precomposedTransaction, selectedAccount})) [DYNAMIC: redux thunk]\n3. signAndPushSendFormTransactionThunk — packages/suite/src/actions/wallet/send/sendFormThunks.ts:237 → (first enhancePrecomposedTransactionThunk) then dispatch(signTransactionThunk({...})) [cross-package: thunk from suite-common/wallet-core]\n4. signTransactionThunk (coin-routing hub) — suite-common/wallet-core/src/send/sendFormThunks.ts:532/573 → networkType branch → dispatch(signBitcoinSendFormTransactionThunk) (ethereum→signEthereumSendFormTransactionThunk, etc.) [DYNAMIC: runtime coin dispatch]\n5. signBitcoinSendFormTransactionThunk — suite-common/wallet-core/src/send/sendFormBitcoinThunks.ts:394 → await TrezorConnect.signTransaction(signPayload)\n6. TrezorConnect.signTransaction (facade) — packages/connect-common/src/factory.ts → closure calls impl.call({method:'signTransaction',...}) [DYNAMIC: facade / iframe-or-module boundary]\n7. CoreInModule.call — packages/connect/src/impl/core-in-module.ts:171 → posts CORE_CALL to core (deferred promise)\n8. Core.onCall → getMethod — packages/connect/src/core/index.ts → getMethod resolves 'signTransaction' → new SignTransaction(message) [DYNAMIC: name→class]\n9. SignTransaction.run — packages/connect/src/api/signTransaction.ts:317 → signTx via device.getCommands().typedCall (protobuf to device). After signing, signAndPushSendFormTransactionThunk → pushSendFormTransactionThunk → TrezorConnect.pushTransaction.\nKEY SYMBOLS: ReviewButton → useSendForm.sign → signAndPushSendFormTransactionThunk (suite) → signTransactionThunk (wallet-core, coin hub) → signBitcoinSendFormTransactionThunk → TrezorConnect.signTransaction → connect factory/CoreInModule.call → SignTransaction.run.\nDYNAMIC BOUNDARIES: every suite→wallet-core hop is a redux thunk dispatch; signTransactionThunk branches by networkType at runtime; TrezorConnect is a dynamically-built facade crossing an iframe/module boundary; the SignTransaction class is resolved by name. A correct answer must cross suite→wallet-core→connect and reach TrezorConnect.signTransaction / SignTransaction.run, not stop at the UI."
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// UserPromptSubmit hook — APPROACH 1: additive context-injection.
|
|
3
|
-
// Front-loads homegraph's structural answer for flow/impact/"how/where" prompts so the
|
|
4
|
-
// agent's reflex grep/read has nothing left to find. Strictly additive (never blocks),
|
|
5
|
-
// gated to structural prompts (no cost otherwise), and uses RAW explore (offload disabled)
|
|
6
|
-
// so the injected context is accurate — never the (currently low-fidelity) synthesis.
|
|
7
|
-
//
|
|
8
|
-
// Reads {prompt, cwd} as JSON on stdin; prints the explore result to stdout (which Claude
|
|
9
|
-
// Code injects into the agent's context). Any failure -> silent exit 0 (degradable).
|
|
10
|
-
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
11
|
-
import { resolve, join, dirname } from 'node:path';
|
|
12
|
-
import { existsSync, readFileSync, appendFileSync } from 'node:fs';
|
|
13
|
-
|
|
14
|
-
// Resolve the engine repo from this script's own location (scripts/agent-eval/ -> ../..),
|
|
15
|
-
// overridable with CG_ENGINE. The hook ships inside the repo, so it finds its own dist.
|
|
16
|
-
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
17
|
-
const ENGINE = process.env.CG_ENGINE || resolve(HERE, '..', '..');
|
|
18
|
-
const BUDGET = Number(process.env.CG_FRONTLOAD_BUDGET || 16000);
|
|
19
|
-
|
|
20
|
-
// Debug log only when CG_FRONTLOAD_DEBUG is set to a file path (the harness points it at a
|
|
21
|
-
// log to count injections); off by default so the shipped hook writes nothing extra.
|
|
22
|
-
const DBG = process.env.CG_FRONTLOAD_DEBUG;
|
|
23
|
-
const dbg = (m) => { if (!DBG) return; try { appendFileSync(DBG, `[${new Date().toISOString()}] ${m}\n`); } catch { /* ignore */ } };
|
|
24
|
-
|
|
25
|
-
let input = {};
|
|
26
|
-
try { input = JSON.parse(readFileSync(0, 'utf8')); } catch (e) { dbg('stdin parse fail: ' + e.message); }
|
|
27
|
-
const prompt = String(input.prompt || '');
|
|
28
|
-
const cwd = String(input.cwd || process.cwd());
|
|
29
|
-
dbg(`invoked: promptLen=${prompt.length} cwd=${cwd}`);
|
|
30
|
-
|
|
31
|
-
// Gate: only structural / flow / impact / where-how questions. Cheap regex; silent no-op
|
|
32
|
-
// otherwise so non-structural prompts ("fix this typo") cost nothing.
|
|
33
|
-
const STRUCTURAL = /\b(how|where|trace|flow|path|reach(es|ed)?|call(s|ed|er|ers|ee)?|depend|impact|affect|wire[ds]?|connect|implement|architect|structure|breaks?|what calls|why does)\b/i;
|
|
34
|
-
if (!prompt || !STRUCTURAL.test(prompt)) { dbg('gate: non-structural, no-op'); process.exit(0); }
|
|
35
|
-
dbg('gate: structural PASS');
|
|
36
|
-
|
|
37
|
-
// Find the index: cwd, then walk up a few levels.
|
|
38
|
-
let root = cwd, found = null;
|
|
39
|
-
for (let i = 0; i < 6 && root; i++) {
|
|
40
|
-
if (existsSync(join(root, '.homegraph'))) { found = root; break; }
|
|
41
|
-
const parent = resolve(root, '..'); if (parent === root) break; root = parent;
|
|
42
|
-
}
|
|
43
|
-
if (!found) { dbg(`no .homegraph found from cwd=${cwd}`); process.exit(0); }
|
|
44
|
-
dbg(`found index at ${found}`);
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
process.env.HOMEGRAPH_OFFLOAD_DISABLE = '1'; // raw, accurate — never the unfixed offload
|
|
48
|
-
process.env.HOMEGRAPH_TELEMETRY = '0'; process.env.DO_NOT_TRACK = '1';
|
|
49
|
-
const load = async (rel) => import(pathToFileURL(resolve(ENGINE, rel)).href);
|
|
50
|
-
const idx = await load('dist/index.js');
|
|
51
|
-
const tools = await load('dist/mcp/tools.js');
|
|
52
|
-
const HomeGraph = idx.default?.default ?? idx.default ?? idx.HomeGraph;
|
|
53
|
-
const ToolHandler = tools.ToolHandler ?? tools.default?.ToolHandler;
|
|
54
|
-
if (typeof HomeGraph?.openSync !== 'function' || typeof ToolHandler !== 'function') process.exit(0);
|
|
55
|
-
|
|
56
|
-
// Retry once on a transient busy/locked index (the hook's openSync can race a
|
|
57
|
-
// freshly-warming daemon on the first prompt of a session).
|
|
58
|
-
let text = '';
|
|
59
|
-
for (let attempt = 1; attempt <= 2; attempt++) {
|
|
60
|
-
try {
|
|
61
|
-
const cg = HomeGraph.openSync(found);
|
|
62
|
-
const h = new ToolHandler(cg);
|
|
63
|
-
const res = await h.execute('homegraph_explore', { query: prompt });
|
|
64
|
-
text = res?.content?.[0]?.text ?? '';
|
|
65
|
-
try { cg.close?.(); } catch { /* ignore */ }
|
|
66
|
-
dbg(`explore attempt ${attempt} returned ${text.length} chars`);
|
|
67
|
-
break;
|
|
68
|
-
} catch (e) {
|
|
69
|
-
dbg(`explore attempt ${attempt} failed: ${e?.message || e}`);
|
|
70
|
-
if (attempt === 2) throw e;
|
|
71
|
-
await new Promise((r) => setTimeout(r, 800));
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (!text.trim()) { dbg('empty explore result, no-op'); process.exit(0); }
|
|
75
|
-
if (text.length > BUDGET) text = text.slice(0, BUDGET) + '\n…[front-load truncated to budget]';
|
|
76
|
-
|
|
77
|
-
process.stdout.write(
|
|
78
|
-
`## HomeGraph structural context (auto-retrieved for this question)\n` +
|
|
79
|
-
`The code graph was queried for your question; the relevant symbols, source, and call flow are below. ` +
|
|
80
|
-
`Treat the quoted source as already read. If you need more, call homegraph_explore with specific symbol names rather than grepping or reading files.\n\n` +
|
|
81
|
-
text + '\n'
|
|
82
|
-
);
|
|
83
|
-
dbg(`INJECTED ${text.length} chars`);
|
|
84
|
-
} catch (e) { dbg('ERROR: ' + (e?.stack || e?.message || e)); process.exit(0); } // degradable
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// UserPromptSubmit hook — APPROACH 1: additive context-injection.
|
|
3
|
+
// Front-loads homegraph's structural answer for flow/impact/"how/where" prompts so the
|
|
4
|
+
// agent's reflex grep/read has nothing left to find. Strictly additive (never blocks),
|
|
5
|
+
// gated to structural prompts (no cost otherwise), and uses RAW explore (offload disabled)
|
|
6
|
+
// so the injected context is accurate — never the (currently low-fidelity) synthesis.
|
|
7
|
+
//
|
|
8
|
+
// Reads {prompt, cwd} as JSON on stdin; prints the explore result to stdout (which Claude
|
|
9
|
+
// Code injects into the agent's context). Any failure -> silent exit 0 (degradable).
|
|
10
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
11
|
+
import { resolve, join, dirname } from 'node:path';
|
|
12
|
+
import { existsSync, readFileSync, appendFileSync } from 'node:fs';
|
|
13
|
+
|
|
14
|
+
// Resolve the engine repo from this script's own location (scripts/agent-eval/ -> ../..),
|
|
15
|
+
// overridable with CG_ENGINE. The hook ships inside the repo, so it finds its own dist.
|
|
16
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
const ENGINE = process.env.CG_ENGINE || resolve(HERE, '..', '..');
|
|
18
|
+
const BUDGET = Number(process.env.CG_FRONTLOAD_BUDGET || 16000);
|
|
19
|
+
|
|
20
|
+
// Debug log only when CG_FRONTLOAD_DEBUG is set to a file path (the harness points it at a
|
|
21
|
+
// log to count injections); off by default so the shipped hook writes nothing extra.
|
|
22
|
+
const DBG = process.env.CG_FRONTLOAD_DEBUG;
|
|
23
|
+
const dbg = (m) => { if (!DBG) return; try { appendFileSync(DBG, `[${new Date().toISOString()}] ${m}\n`); } catch { /* ignore */ } };
|
|
24
|
+
|
|
25
|
+
let input = {};
|
|
26
|
+
try { input = JSON.parse(readFileSync(0, 'utf8')); } catch (e) { dbg('stdin parse fail: ' + e.message); }
|
|
27
|
+
const prompt = String(input.prompt || '');
|
|
28
|
+
const cwd = String(input.cwd || process.cwd());
|
|
29
|
+
dbg(`invoked: promptLen=${prompt.length} cwd=${cwd}`);
|
|
30
|
+
|
|
31
|
+
// Gate: only structural / flow / impact / where-how questions. Cheap regex; silent no-op
|
|
32
|
+
// otherwise so non-structural prompts ("fix this typo") cost nothing.
|
|
33
|
+
const STRUCTURAL = /\b(how|where|trace|flow|path|reach(es|ed)?|call(s|ed|er|ers|ee)?|depend|impact|affect|wire[ds]?|connect|implement|architect|structure|breaks?|what calls|why does)\b/i;
|
|
34
|
+
if (!prompt || !STRUCTURAL.test(prompt)) { dbg('gate: non-structural, no-op'); process.exit(0); }
|
|
35
|
+
dbg('gate: structural PASS');
|
|
36
|
+
|
|
37
|
+
// Find the index: cwd, then walk up a few levels.
|
|
38
|
+
let root = cwd, found = null;
|
|
39
|
+
for (let i = 0; i < 6 && root; i++) {
|
|
40
|
+
if (existsSync(join(root, '.homegraph'))) { found = root; break; }
|
|
41
|
+
const parent = resolve(root, '..'); if (parent === root) break; root = parent;
|
|
42
|
+
}
|
|
43
|
+
if (!found) { dbg(`no .homegraph found from cwd=${cwd}`); process.exit(0); }
|
|
44
|
+
dbg(`found index at ${found}`);
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
process.env.HOMEGRAPH_OFFLOAD_DISABLE = '1'; // raw, accurate — never the unfixed offload
|
|
48
|
+
process.env.HOMEGRAPH_TELEMETRY = '0'; process.env.DO_NOT_TRACK = '1';
|
|
49
|
+
const load = async (rel) => import(pathToFileURL(resolve(ENGINE, rel)).href);
|
|
50
|
+
const idx = await load('dist/index.js');
|
|
51
|
+
const tools = await load('dist/mcp/tools.js');
|
|
52
|
+
const HomeGraph = idx.default?.default ?? idx.default ?? idx.HomeGraph;
|
|
53
|
+
const ToolHandler = tools.ToolHandler ?? tools.default?.ToolHandler;
|
|
54
|
+
if (typeof HomeGraph?.openSync !== 'function' || typeof ToolHandler !== 'function') process.exit(0);
|
|
55
|
+
|
|
56
|
+
// Retry once on a transient busy/locked index (the hook's openSync can race a
|
|
57
|
+
// freshly-warming daemon on the first prompt of a session).
|
|
58
|
+
let text = '';
|
|
59
|
+
for (let attempt = 1; attempt <= 2; attempt++) {
|
|
60
|
+
try {
|
|
61
|
+
const cg = HomeGraph.openSync(found);
|
|
62
|
+
const h = new ToolHandler(cg);
|
|
63
|
+
const res = await h.execute('homegraph_explore', { query: prompt });
|
|
64
|
+
text = res?.content?.[0]?.text ?? '';
|
|
65
|
+
try { cg.close?.(); } catch { /* ignore */ }
|
|
66
|
+
dbg(`explore attempt ${attempt} returned ${text.length} chars`);
|
|
67
|
+
break;
|
|
68
|
+
} catch (e) {
|
|
69
|
+
dbg(`explore attempt ${attempt} failed: ${e?.message || e}`);
|
|
70
|
+
if (attempt === 2) throw e;
|
|
71
|
+
await new Promise((r) => setTimeout(r, 800));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (!text.trim()) { dbg('empty explore result, no-op'); process.exit(0); }
|
|
75
|
+
if (text.length > BUDGET) text = text.slice(0, BUDGET) + '\n…[front-load truncated to budget]';
|
|
76
|
+
|
|
77
|
+
process.stdout.write(
|
|
78
|
+
`## HomeGraph structural context (auto-retrieved for this question)\n` +
|
|
79
|
+
`The code graph was queried for your question; the relevant symbols, source, and call flow are below. ` +
|
|
80
|
+
`Treat the quoted source as already read. If you need more, call homegraph_explore with specific symbol names rather than grepping or reading files.\n\n` +
|
|
81
|
+
text + '\n'
|
|
82
|
+
);
|
|
83
|
+
dbg(`INJECTED ${text.length} chars`);
|
|
84
|
+
} catch (e) { dbg('ERROR: ' + (e?.stack || e?.message || e)); process.exit(0); } // degradable
|
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Accuracy judge. For each run in results.jsonl:
|
|
3
|
-
// - end-to-end: agent finalAnswer vs verified ground truth (all arms)
|
|
4
|
-
// - fidelity: offload synthesized answer vs ground truth (offload arm only)
|
|
5
|
-
// Judge = claude -p sonnet --effort high, no tools, run from a neutral cwd,
|
|
6
|
-
// JSON-only verdicts. Writes judged.jsonl (one line per run, verdicts merged).
|
|
7
|
-
//
|
|
8
|
-
// Usage: judge.mjs --results <f> --truth <f> --out <f> [--concurrency 4]
|
|
9
|
-
import { readFileSync, writeFileSync, existsSync } from 'fs';
|
|
10
|
-
import { execFile } from 'child_process';
|
|
11
|
-
|
|
12
|
-
const A = {};
|
|
13
|
-
for (let i = 2; i < process.argv.length; i += 2) A[process.argv[i].replace(/^--/, '')] = process.argv[i + 1];
|
|
14
|
-
const results = readFileSync(A.results, 'utf8').split('\n').filter(Boolean).map(l => JSON.parse(l));
|
|
15
|
-
const truth = JSON.parse(readFileSync(A.truth, 'utf8'));
|
|
16
|
-
const OUT = A.out || '/tmp/cg-offload-eval/judged.jsonl';
|
|
17
|
-
const CONC = Number(A.concurrency || 4);
|
|
18
|
-
|
|
19
|
-
function askJudge(prompt) {
|
|
20
|
-
return new Promise((resolve) => {
|
|
21
|
-
execFile('claude', ['-p', prompt, '--model', 'sonnet', '--effort', 'high',
|
|
22
|
-
'--max-budget-usd', '0.5', '--strict-mcp-config', '--mcp-config', '{"mcpServers":{}}'],
|
|
23
|
-
// Run from a neutral dir with no repo files so the judge can't "cheat" by reading source.
|
|
24
|
-
{ cwd: process.env.AGENT_EVAL_OUT || '/tmp', maxBuffer: 1 << 24, timeout: 120000 },
|
|
25
|
-
(err, stdout) => {
|
|
26
|
-
const raw = (stdout || '').trim();
|
|
27
|
-
const m = raw.match(/\{[\s\S]*\}/);
|
|
28
|
-
if (!m) return resolve({ verdict: 'error', score: null, note: (err ? 'exec ' + err.message : 'no json').slice(0, 80) });
|
|
29
|
-
try { resolve(JSON.parse(m[0])); } catch { resolve({ verdict: 'error', score: null, note: 'parse fail' }); }
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const e2ePrompt = (gt, ans) => `You are scoring whether an AI coding agent correctly answered a code-flow question about a repository. Judge ONLY against the verified ground truth. Do NOT use any tools.
|
|
35
|
-
|
|
36
|
-
QUESTION: ${gt.question}
|
|
37
|
-
|
|
38
|
-
VERIFIED GROUND TRUTH (the actual call path + files):
|
|
39
|
-
${gt.truth}
|
|
40
|
-
|
|
41
|
-
AGENT'S ANSWER:
|
|
42
|
-
${ans || '(empty)'}
|
|
43
|
-
|
|
44
|
-
Score how correct the agent's answer is vs the ground truth. A "pass" means it identifies the core mechanism and the major hops with the right files/symbols and makes no materially wrong claim. "partial" = right area but misses major hops or has notable errors. "fail" = wrong layer, fabricated, or misses the mechanism.
|
|
45
|
-
Output ONLY minified JSON, no prose, no code fences:
|
|
46
|
-
{"verdict":"pass|partial|fail","score":<0-100>,"missedHops":["..."],"wrongClaims":["..."],"note":"<=20 words"}`;
|
|
47
|
-
|
|
48
|
-
const fidPrompt = (gt, ans) => `You are scoring the FIDELITY of a machine-synthesized code-exploration answer against verified ground truth. The synthesized answer claims to trace a flow and cite file:line locations. Do NOT use any tools.
|
|
49
|
-
|
|
50
|
-
QUESTION: ${gt.question}
|
|
51
|
-
|
|
52
|
-
VERIFIED GROUND TRUTH (the actual call path + files):
|
|
53
|
-
${gt.truth}
|
|
54
|
-
|
|
55
|
-
SYNTHESIZED ANSWER (to score):
|
|
56
|
-
${ans || '(empty)'}
|
|
57
|
-
|
|
58
|
-
Judge: (1) is the traced call path correct vs ground truth? (2) are the cited files/symbols correct (not fabricated)? (3) if it gave a "Coverage:" verdict, was that verdict honest about what it actually covered? A confident WRONG trace is the worst outcome — penalize it harder than an honest "partial/not found".
|
|
59
|
-
Output ONLY minified JSON, no prose, no code fences:
|
|
60
|
-
{"verdict":"pass|partial|fail","score":<0-100>,"fabrication":<true|false>,"coverageHonest":<true|false>,"missedHops":["..."],"note":"<=20 words"}`;
|
|
61
|
-
|
|
62
|
-
// Build the job list
|
|
63
|
-
const jobs = [];
|
|
64
|
-
for (const r of results) {
|
|
65
|
-
const gt = truth[r.repo];
|
|
66
|
-
if (!gt) { r._nojudge = true; continue; }
|
|
67
|
-
jobs.push({ r, kind: 'e2e', prompt: e2ePrompt(gt, r.finalAnswer) });
|
|
68
|
-
if (r.arm === 'offload' && Array.isArray(r.offloadAnswers))
|
|
69
|
-
r.offloadAnswers.forEach((ans, i) => { if (ans && ans.trim()) jobs.push({ r, kind: 'fid', idx: i, prompt: fidPrompt(gt, ans) }); });
|
|
70
|
-
}
|
|
71
|
-
console.error(`judging ${jobs.length} verdicts across ${results.length} runs (concurrency ${CONC})...`);
|
|
72
|
-
|
|
73
|
-
let done = 0;
|
|
74
|
-
async function worker(queue) {
|
|
75
|
-
while (queue.length) {
|
|
76
|
-
const job = queue.shift();
|
|
77
|
-
const v = await askJudge(job.prompt);
|
|
78
|
-
if (job.kind === 'e2e') job.r.e2e = v; else (job.r._fid ??= []).push(v);
|
|
79
|
-
console.error(` [${++done}/${jobs.length}] ${job.r.repo}/${job.r.arm}#${job.r.rep} ${job.kind}: ${v.verdict}${v.score != null ? ' ' + v.score : ''}`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
const q = [...jobs];
|
|
83
|
-
await Promise.all(Array.from({ length: CONC }, () => worker(q)));
|
|
84
|
-
|
|
85
|
-
// Aggregate per-answer fidelity verdicts into one fidelity object per offload run.
|
|
86
|
-
const medOf = (a) => { a = [...a].sort((x, y) => x - y); return a.length ? (a.length % 2 ? a[(a.length - 1) / 2] : (a[a.length / 2 - 1] + a[a.length / 2]) / 2) : null; };
|
|
87
|
-
for (const r of results) {
|
|
88
|
-
if (r._fid?.length) {
|
|
89
|
-
const scores = r._fid.map(v => v.score).filter(x => x != null);
|
|
90
|
-
r.fidelity = {
|
|
91
|
-
n: r._fid.length, scores,
|
|
92
|
-
max: scores.length ? Math.max(...scores) : null,
|
|
93
|
-
min: scores.length ? Math.min(...scores) : null,
|
|
94
|
-
median: medOf(scores),
|
|
95
|
-
anyFabrication: r._fid.some(v => v.fabrication === true),
|
|
96
|
-
allCoverageHonest: r._fid.every(v => v.coverageHonest !== false),
|
|
97
|
-
verdicts: r._fid.map(v => v.verdict),
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
delete r._fid;
|
|
101
|
-
}
|
|
102
|
-
writeFileSync(OUT, results.map(r => JSON.stringify(r)).join('\n') + '\n');
|
|
103
|
-
console.error(`wrote ${OUT}`);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Accuracy judge. For each run in results.jsonl:
|
|
3
|
+
// - end-to-end: agent finalAnswer vs verified ground truth (all arms)
|
|
4
|
+
// - fidelity: offload synthesized answer vs ground truth (offload arm only)
|
|
5
|
+
// Judge = claude -p sonnet --effort high, no tools, run from a neutral cwd,
|
|
6
|
+
// JSON-only verdicts. Writes judged.jsonl (one line per run, verdicts merged).
|
|
7
|
+
//
|
|
8
|
+
// Usage: judge.mjs --results <f> --truth <f> --out <f> [--concurrency 4]
|
|
9
|
+
import { readFileSync, writeFileSync, existsSync } from 'fs';
|
|
10
|
+
import { execFile } from 'child_process';
|
|
11
|
+
|
|
12
|
+
const A = {};
|
|
13
|
+
for (let i = 2; i < process.argv.length; i += 2) A[process.argv[i].replace(/^--/, '')] = process.argv[i + 1];
|
|
14
|
+
const results = readFileSync(A.results, 'utf8').split('\n').filter(Boolean).map(l => JSON.parse(l));
|
|
15
|
+
const truth = JSON.parse(readFileSync(A.truth, 'utf8'));
|
|
16
|
+
const OUT = A.out || '/tmp/cg-offload-eval/judged.jsonl';
|
|
17
|
+
const CONC = Number(A.concurrency || 4);
|
|
18
|
+
|
|
19
|
+
function askJudge(prompt) {
|
|
20
|
+
return new Promise((resolve) => {
|
|
21
|
+
execFile('claude', ['-p', prompt, '--model', 'sonnet', '--effort', 'high',
|
|
22
|
+
'--max-budget-usd', '0.5', '--strict-mcp-config', '--mcp-config', '{"mcpServers":{}}'],
|
|
23
|
+
// Run from a neutral dir with no repo files so the judge can't "cheat" by reading source.
|
|
24
|
+
{ cwd: process.env.AGENT_EVAL_OUT || '/tmp', maxBuffer: 1 << 24, timeout: 120000 },
|
|
25
|
+
(err, stdout) => {
|
|
26
|
+
const raw = (stdout || '').trim();
|
|
27
|
+
const m = raw.match(/\{[\s\S]*\}/);
|
|
28
|
+
if (!m) return resolve({ verdict: 'error', score: null, note: (err ? 'exec ' + err.message : 'no json').slice(0, 80) });
|
|
29
|
+
try { resolve(JSON.parse(m[0])); } catch { resolve({ verdict: 'error', score: null, note: 'parse fail' }); }
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const e2ePrompt = (gt, ans) => `You are scoring whether an AI coding agent correctly answered a code-flow question about a repository. Judge ONLY against the verified ground truth. Do NOT use any tools.
|
|
35
|
+
|
|
36
|
+
QUESTION: ${gt.question}
|
|
37
|
+
|
|
38
|
+
VERIFIED GROUND TRUTH (the actual call path + files):
|
|
39
|
+
${gt.truth}
|
|
40
|
+
|
|
41
|
+
AGENT'S ANSWER:
|
|
42
|
+
${ans || '(empty)'}
|
|
43
|
+
|
|
44
|
+
Score how correct the agent's answer is vs the ground truth. A "pass" means it identifies the core mechanism and the major hops with the right files/symbols and makes no materially wrong claim. "partial" = right area but misses major hops or has notable errors. "fail" = wrong layer, fabricated, or misses the mechanism.
|
|
45
|
+
Output ONLY minified JSON, no prose, no code fences:
|
|
46
|
+
{"verdict":"pass|partial|fail","score":<0-100>,"missedHops":["..."],"wrongClaims":["..."],"note":"<=20 words"}`;
|
|
47
|
+
|
|
48
|
+
const fidPrompt = (gt, ans) => `You are scoring the FIDELITY of a machine-synthesized code-exploration answer against verified ground truth. The synthesized answer claims to trace a flow and cite file:line locations. Do NOT use any tools.
|
|
49
|
+
|
|
50
|
+
QUESTION: ${gt.question}
|
|
51
|
+
|
|
52
|
+
VERIFIED GROUND TRUTH (the actual call path + files):
|
|
53
|
+
${gt.truth}
|
|
54
|
+
|
|
55
|
+
SYNTHESIZED ANSWER (to score):
|
|
56
|
+
${ans || '(empty)'}
|
|
57
|
+
|
|
58
|
+
Judge: (1) is the traced call path correct vs ground truth? (2) are the cited files/symbols correct (not fabricated)? (3) if it gave a "Coverage:" verdict, was that verdict honest about what it actually covered? A confident WRONG trace is the worst outcome — penalize it harder than an honest "partial/not found".
|
|
59
|
+
Output ONLY minified JSON, no prose, no code fences:
|
|
60
|
+
{"verdict":"pass|partial|fail","score":<0-100>,"fabrication":<true|false>,"coverageHonest":<true|false>,"missedHops":["..."],"note":"<=20 words"}`;
|
|
61
|
+
|
|
62
|
+
// Build the job list
|
|
63
|
+
const jobs = [];
|
|
64
|
+
for (const r of results) {
|
|
65
|
+
const gt = truth[r.repo];
|
|
66
|
+
if (!gt) { r._nojudge = true; continue; }
|
|
67
|
+
jobs.push({ r, kind: 'e2e', prompt: e2ePrompt(gt, r.finalAnswer) });
|
|
68
|
+
if (r.arm === 'offload' && Array.isArray(r.offloadAnswers))
|
|
69
|
+
r.offloadAnswers.forEach((ans, i) => { if (ans && ans.trim()) jobs.push({ r, kind: 'fid', idx: i, prompt: fidPrompt(gt, ans) }); });
|
|
70
|
+
}
|
|
71
|
+
console.error(`judging ${jobs.length} verdicts across ${results.length} runs (concurrency ${CONC})...`);
|
|
72
|
+
|
|
73
|
+
let done = 0;
|
|
74
|
+
async function worker(queue) {
|
|
75
|
+
while (queue.length) {
|
|
76
|
+
const job = queue.shift();
|
|
77
|
+
const v = await askJudge(job.prompt);
|
|
78
|
+
if (job.kind === 'e2e') job.r.e2e = v; else (job.r._fid ??= []).push(v);
|
|
79
|
+
console.error(` [${++done}/${jobs.length}] ${job.r.repo}/${job.r.arm}#${job.r.rep} ${job.kind}: ${v.verdict}${v.score != null ? ' ' + v.score : ''}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const q = [...jobs];
|
|
83
|
+
await Promise.all(Array.from({ length: CONC }, () => worker(q)));
|
|
84
|
+
|
|
85
|
+
// Aggregate per-answer fidelity verdicts into one fidelity object per offload run.
|
|
86
|
+
const medOf = (a) => { a = [...a].sort((x, y) => x - y); return a.length ? (a.length % 2 ? a[(a.length - 1) / 2] : (a[a.length / 2 - 1] + a[a.length / 2]) / 2) : null; };
|
|
87
|
+
for (const r of results) {
|
|
88
|
+
if (r._fid?.length) {
|
|
89
|
+
const scores = r._fid.map(v => v.score).filter(x => x != null);
|
|
90
|
+
r.fidelity = {
|
|
91
|
+
n: r._fid.length, scores,
|
|
92
|
+
max: scores.length ? Math.max(...scores) : null,
|
|
93
|
+
min: scores.length ? Math.min(...scores) : null,
|
|
94
|
+
median: medOf(scores),
|
|
95
|
+
anyFabrication: r._fid.some(v => v.fabrication === true),
|
|
96
|
+
allCoverageHonest: r._fid.every(v => v.coverageHonest !== false),
|
|
97
|
+
verdicts: r._fid.map(v => v.verdict),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
delete r._fid;
|
|
101
|
+
}
|
|
102
|
+
writeFileSync(OUT, results.map(r => JSON.stringify(r)).join('\n') + '\n');
|
|
103
|
+
console.error(`wrote ${OUT}`);
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Drive the 3-arm campaign (offload/raw/nocg) across all 4 tiers, n reps each, into one
|
|
3
|
-
# results.jsonl. Reads the canonical question per repo from offload-eval-ground-truth.json.
|
|
4
|
-
# Env: REPS (default 3) AGENT_EVAL_OUT=<scratch dir>
|
|
5
|
-
set -uo pipefail
|
|
6
|
-
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
7
|
-
OUT="${AGENT_EVAL_OUT:-/tmp/cg-offload-eval}"
|
|
8
|
-
GT="$HERE/offload-eval-ground-truth.json"
|
|
9
|
-
REPS="${REPS:-3}"
|
|
10
|
-
export RESULTS="$OUT/results.jsonl"
|
|
11
|
-
: > "$RESULTS"
|
|
12
|
-
for repo in mtkruto postybirb shapeshift trezor; do
|
|
13
|
-
case "$repo" in mtkruto) tier=small;; postybirb) tier=medium;; shapeshift) tier=complex;; trezor) tier=large;; esac
|
|
14
|
-
Q=$(node -e "console.log(JSON.parse(require('fs').readFileSync(process.argv[1],'utf8'))[process.argv[2]].question)" "$GT" "$repo")
|
|
15
|
-
echo ""; echo "### $repo ($tier) $(date +%H:%M:%S)"
|
|
16
|
-
bash "$HERE/offload-eval-3arm.sh" "$OUT/repos/$repo" "$tier" "$REPS" "$Q"
|
|
17
|
-
done
|
|
18
|
-
echo ""; echo "###### MATRIX DONE -> $RESULTS ($(wc -l < "$RESULTS") runs). Judge + summarize with:"
|
|
19
|
-
echo " node $HERE/offload-eval-judge.mjs --results $RESULTS --truth $GT --out $OUT/judged.jsonl"
|
|
20
|
-
echo " node $HERE/offload-eval-summarize.mjs $OUT/judged.jsonl"
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Drive the 3-arm campaign (offload/raw/nocg) across all 4 tiers, n reps each, into one
|
|
3
|
+
# results.jsonl. Reads the canonical question per repo from offload-eval-ground-truth.json.
|
|
4
|
+
# Env: REPS (default 3) AGENT_EVAL_OUT=<scratch dir>
|
|
5
|
+
set -uo pipefail
|
|
6
|
+
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
7
|
+
OUT="${AGENT_EVAL_OUT:-/tmp/cg-offload-eval}"
|
|
8
|
+
GT="$HERE/offload-eval-ground-truth.json"
|
|
9
|
+
REPS="${REPS:-3}"
|
|
10
|
+
export RESULTS="$OUT/results.jsonl"
|
|
11
|
+
: > "$RESULTS"
|
|
12
|
+
for repo in mtkruto postybirb shapeshift trezor; do
|
|
13
|
+
case "$repo" in mtkruto) tier=small;; postybirb) tier=medium;; shapeshift) tier=complex;; trezor) tier=large;; esac
|
|
14
|
+
Q=$(node -e "console.log(JSON.parse(require('fs').readFileSync(process.argv[1],'utf8'))[process.argv[2]].question)" "$GT" "$repo")
|
|
15
|
+
echo ""; echo "### $repo ($tier) $(date +%H:%M:%S)"
|
|
16
|
+
bash "$HERE/offload-eval-3arm.sh" "$OUT/repos/$repo" "$tier" "$REPS" "$Q"
|
|
17
|
+
done
|
|
18
|
+
echo ""; echo "###### MATRIX DONE -> $RESULTS ($(wc -l < "$RESULTS") runs). Judge + summarize with:"
|
|
19
|
+
echo " node $HERE/offload-eval-judge.mjs --results $RESULTS --truth $GT --out $OUT/judged.jsonl"
|
|
20
|
+
echo " node $HERE/offload-eval-summarize.mjs $OUT/judged.jsonl"
|