Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(eval-lab): 修复 Greptile 审查提出的 4 项问题(修复下载确认、缓存内容重算哈希、近满分截断、移除失效图标链接)
- preview_download 探测已安装题目的缓存完整性并在需要修复时要求弹窗确认;start 在 downloadConfirmed=false 时拒绝绕过确认触发宿主下载。
- 钉死索引落盘保留原始 raw 字节,并在 cached/plan/step 读取时重新计算 SHA-256 核验,防止正确哈希目录内文件被替换。
- 连续数值指标未达 target 时禁止四舍五入进位成精确满分 1(上限 999/1000),避免未达标参考解通过校准。
- 移除根目录中英文 README 中对已删除占位图标 eval-lab/assets/icon.png 的引用。

Assisted-by: Cindy (https://cindy.app)
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
  • Loading branch information
dashhuang committed Dec 4, 2026
commit 9f153c68e0ab5b3a0f201e43d659e2e07b51ab87
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ permission gate.
| <img src="./ntfy/assets/icon.png" width="22" alt=""> | ntfy | [`ntfy`](./ntfy) | Push notifications to your phone or desktop through your own ntfy server; the access token is stored by Cindy and sent only to that server; opt-in |
| <img src="./decision-gate/assets/icon.png" width="22" alt=""> | Decision Gate | [`decision-gate`](./decision-gate) | Decides by your rules: picks a model when a new task starts and judges before an automation or routine runs whether it needs to |
| <img src="./agentcompass/assets/icon.png" width="22" alt=""> | AgentCompass | [`agentcompass`](./agentcompass) | Hands independent work to the model that fits it: a model profiles the task through Cindy's quick-text channel (a Cindy account is required), the built-in AgentCompass engine picks harness, model and effort from the models this Cindy can run (capability fit only: no quota economy and no fast mode), starts an ordinary Cindy task with `bypassPermissions` (Claude) / `full-access` (Codex, Pi) in the parent project directory, and collects its exact result; opt-in |
| <img src="./eval-lab/assets/icon.png" width="22" alt=""> | Evaluation Lab | [`eval-lab`](./eval-lab) | Run real-project model evaluations with isolated Orca Workers and independent Python graders (supports built-in models and local ACP plugin engines), author private questions from selected task excerpts with 3-way calibration, and export sanitized standalone HTML results; opt-in |
| — | Evaluation Lab | [`eval-lab`](./eval-lab) | Run real-project model evaluations with isolated Orca Workers and independent Python graders (supports built-in models and local ACP plugin engines), author private questions from selected task excerpts with 3-way calibration, and export sanitized standalone HTML results; opt-in |

GitHub's default-off [optional CI recovery](docs/github-ci-retry.md) can recover
confirmed transient failures when a contributor cannot rerun Actions.
Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
| <img src="./ntfy/assets/icon.png" width="22" alt=""> | ntfy | [`ntfy`](./ntfy) | 通过你自己的 ntfy 服务器向手机或电脑发送推送通知;访问令牌由 Cindy 保管,只发送给对应服务器;自选安装 |
| <img src="./decision-gate/assets/icon.png" width="22" alt=""> | 决策闸门 | [`decision-gate`](./decision-gate) | 按你写的规则开新任务时选模型,并在自动化和例行任务运行前判断要不要跑 |
| <img src="./agentcompass/assets/icon.png" width="22" alt=""> | AgentCompass | [`agentcompass`](./agentcompass) | 把独立工作交给最合适的模型:通过 Cindy 的 quick-text 通道由模型为任务做画像(需要 Cindy 账号),内置 AgentCompass 引擎在这台 Cindy 能运行的模型中选出 harness、模型与档位(仅按能力匹配,不做额度经济,也没有 fast 模式),在父项目目录以 `bypassPermissions`(Claude)/ `full-access`(Codex、Pi)启动普通 Cindy 任务并取回确切结果;自选安装 |
| <img src="./eval-lab/assets/icon.png" width="22" alt=""> | 评测工坊 | [`eval-lab`](./eval-lab) | 用真实项目题目、隔离 Orca Worker 与独立 Python 评分器横向评测本机模型(支持内置模型与本机 ACP 插件引擎),支持从选定任务片段出题、三组校准并导出脱敏单文件 HTML 成绩;自选安装 |
| — | 评测工坊 | [`eval-lab`](./eval-lab) | 用真实项目题目、隔离 Orca Worker 与独立 Python 评分器横向评测本机模型(支持内置模型与本机 ACP 插件引擎),支持从选定任务片段出题、三组校准并导出脱敏单文件 HTML 成绩;自选安装 |

GitHub 的[可选 CI 恢复](docs/github-ci-retry.zh-CN.md)默认关闭,可在贡献者无权重跑
Actions 时,为已确认的临时故障提供有限恢复途径。
Expand Down
3 changes: 2 additions & 1 deletion eval-lab/i18n.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion eval-lab/lib/core.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ function score(s,items,metrics){
const rawRatio=gatePassed?metricRatio(m,val):0;
if(!Number.isFinite(rawRatio))throw Error('Invalid metric ratio');
const ratio=Math.max(0,Math.min(1,rawRatio));
const milli=Math.round(ratio*1000);
let milli=Math.round(ratio*1000);
if(ratio<1&&milli>=1000)milli=999;
total=add(total,mul(parse(g.weight),fraction(milli,1000n)));
metricRows.push({id:m.id,label:m.label?m.label.trim():m.id,unit:m.unit||'',direction:m.direction,value:val,baseline:m.baseline,target:m.target,score:milli/1000,gatePassed,beatTarget:gatePassed&&(m.direction==='lower'?val<m.target:val>m.target)});
}else{
Expand Down
28 changes: 23 additions & 5 deletions eval-lab/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,18 @@ async function inspectQuestions(args,callId){
if(downloadBusy)throw Error('题库正在准备,请稍候');
downloadBusy=true;try{return await node('online_inspect',args,callId);}finally{downloadBusy=false;}
}
async function installQuestion(args,fromLaunch=false){
async function isCachedQuestionHealthy(indexId,question){
let opId;
try{
opId=(await node('online_begin')).operationId;
if(typeof opId!=='string')return false;
let current;
do{current=await node('online_step',{indexId,question,operationId:opId,requireHostDownloads:true});}while(!current.done&&current.phase==='cached');
return !!current.done;
}catch{return false;}
finally{if(opId)await node('online_cancel',{operationId:opId}).catch(()=>{});}
}
async function installQuestion(args,fromLaunch=false,allowDownload=true){
if(fromLaunch&&launchCancelled)throw Error('已停止准备。');
if(downloadBusy)throw Error('题库正在准备,请稍候');
downloadBusy=true;if(!fromLaunch)downloadCancelled=false;
Expand All @@ -227,6 +238,7 @@ async function installQuestion(args,fromLaunch=false){
if(!current.done){
// Host downloads may outlive the Node process. Finish this cache probe first.
await node('online_cancel',{operationId:activeInstall});activeInstall=null;
if(!allowDownload)throw Error('检测到题库需要下载或修复,请重试以确认下载体积。');
if(!cindy.downloads?.start)throw Error('请更新 Cindy 开发版以使用题库下载');
const plan=await node('online_plan',args),downloadTokens={};
for(const a of plan.artifacts){
Expand All @@ -249,7 +261,7 @@ async function installQuestion(args,fromLaunch=false){
}catch(e){channel.postMessage({type:'download-progress',phase:downloadCancelled?'cancelled':'failed'});throw e;}
finally{try{if(activeInstall)await node('online_cancel',{operationId:activeInstall});}catch{/* Cleanup cannot replace the installation outcome. */}finally{downloadBusy=false;activeDownload=null;activeInstall=null;}}
}
async function resolveQuestions(wanted,fromLaunch=false,expectedIndexId){
async function resolveQuestions(wanted,fromLaunch=false,expectedIndexId,allowDownload=true){
const c=await readyConfig(),available=(await node('bank')).questions,resolved=[];let remote;
for(const key of wanted){
if(fromLaunch&&launchCancelled)throw Error('已停止准备。');
Expand All @@ -261,7 +273,7 @@ async function resolveQuestions(wanted,fromLaunch=false,expectedIndexId){
if(!remote){progress('正在准备默认题库…');remote=await inspectQuestions({url:c.indexUrl||DEFAULT_INDEX,...(expectedIndexId?{expectedSha256:expectedIndexId}:{})});}
if(fromLaunch&&launchCancelled)throw Error('已停止准备。');
progress('正在下载并校验:'+key);
const installed=await installQuestion({indexId:remote.indexId,question:key},fromLaunch);
const installed=await installQuestion({indexId:remote.indexId,question:key},fromLaunch,allowDownload);
const after=(await node('bank')).questions,q=after.find(q=>q.key==='online:'+installed.bank.split(/[\\/]/).pop()+':'+installed.key);
if(!q)throw Error('下载的题目不可用,请检查题库后重试。');resolved.push(q.key);
}
Expand Down Expand Up @@ -547,7 +559,12 @@ async function action(name,args={},callId){
const c=await readyConfig(),available=new Set((await node('bank')).questions.map(q=>q.key));
const url=args.url||c.indexUrl||DEFAULT_INDEX;
const remote=await inspectQuestions({url},callId);
const missing=onlineWanted.map(key=>remote.questions.find(x=>x.key===key)).filter(q=>q&&!available.has(q.installedKey));
const missing=[];
for(const key of onlineWanted){
const q=remote.questions.find(x=>x.key===key);
if(!q)continue;
if(!available.has(q.installedKey)||!(await isCachedQuestionHealthy(remote.indexId,q.key)))missing.push(q);
}
if(!missing.length)return {needsDownload:false,url,indexId:remote.indexId,pinned:!!remote.pinned,items:[],totalDownloadBytes:0,totalExpandedBytes:0};
const items=missing.map(q=>({key:q.key,title:q.title,bytes:q.bytes||0,expandedBytes:q.expandedBytes||0}));
const uniqueArtifacts=new Map();
Expand All @@ -570,7 +587,8 @@ async function action(name,args={},callId){
const requested=[...new Set(args.questions)];if(requested.length*chosen.length>200)throw Error('单批最多 200 份作答,请分批运行');
const concurrency=args.concurrency??null;if(concurrency!==null&&(!Number.isInteger(concurrency)||concurrency<1))throw Error('同时作答数必须为正整数');
const expectedIndexId=typeof args.expectedIndexId==='string'&&args.expectedIndexId?args.expectedIndexId:undefined;
const questions=await resolveQuestions(requested,true,expectedIndexId);
const allowDownload=args.downloadConfirmed!==false;
const questions=await resolveQuestions(requested,true,expectedIndexId,allowDownload);
if(launchCancelled)return {id:'preparation',status:'cancelled',phase:'cancelled',total:0,finished:0,items:[],message:'已停止准备。'};
const batch={concurrency,id:crypto.randomUUID(),mode:'coordinator',status:'running',createdAt:new Date().toISOString(),items:questions.flatMap(question=>chosen.map(config=>({runId:crypto.randomUUID(),question,config,status:'pending'})))};
await updateConfig(c=>({...c,batch}));if(launchCancelled){batch.stopRequestedAt=Date.now();await updateConfig(c=>({...c,batch}));return stopBatch(batch);}progress('题库已就绪,正在创建独立任务…');return await advanceBatch();
Expand Down
8 changes: 4 additions & 4 deletions eval-lab/node/install-steps.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const digest=x=>crypto.createHash('sha256').update(x).digest('hex');
const invalid=()=>Object.assign(Error('Question content mismatch'),{code:'PACKAGE_INVALID'});
const chunkSize=1024*1024;
// Each operation owns its archives. Borrowed Host files are closed before a step returns.
module.exports=function installSteps({home,within,validate,verifyPin,checkPlatform,verifySpec,preflight,platform,arch,stepBytes=32*1024*1024}){
module.exports=function installSteps({home,within,loadStoredIndex,checkPlatform,verifySpec,preflight,platform,arch,stepBytes=32*1024*1024}){
const limit=Math.max(1,Math.min(stepBytes,32*1024*1024));
async function* entries(root,rel=''){
for(const e of (await fs.readdir(path.join(root,rel),{withFileTypes:true})).sort((a,b)=>a.name.localeCompare(b.name))){
Expand Down Expand Up @@ -48,11 +48,11 @@ module.exports=function installSteps({home,within,validate,verifyPin,checkPlatfo
async function initialize(op,p){
if(!/^[a-f0-9]{64}$/.test(p.indexId))throw invalid();
const h=await home(p.root),saved=await readMetadata(path.join(h,'indices',p.indexId,'index.json'));
if(verifyPin)verifyPin(p.indexId,saved.url);
const index=validate(saved.index,saved.url),q=index.questions.find(q=>q.key===p.question);
const {canonicalUrl,index}=loadStoredIndex(saved,p.indexId);
const q=index.questions.find(q=>q.key===p.question);
if(!q)throw invalid();checkPlatform(index.platform,platform,arch);
const release=digest(JSON.stringify(q)),dest=await within(h,'banks/'+release);
Object.assign(op,{identity:JSON.stringify([p.indexId,p.question]),h,index,q,saved,release,dest,result:{bank:dest,key:q.key,title:q.title},checked:0});
Object.assign(op,{identity:JSON.stringify([p.indexId,p.question]),h,index,q,saved:{...saved,url:canonicalUrl},release,dest,result:{bank:dest,key:q.key,title:q.title},checked:0});
try{
const manifest=await readMetadata(path.join(dest,'distribution.json'));
if(manifest.format!=='eval-lab-bank-v1'||JSON.stringify(manifest.questions)!==JSON.stringify([q]))throw invalid();
Expand Down
32 changes: 22 additions & 10 deletions eval-lab/node/online.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,17 @@ function pinnedSha256(url,expected){
if(builtin&&expected&&expected!==builtin)throw Object.assign(Error('题库索引哈希校验失败,可能已被修改,已拒绝使用。'),{code:'INDEX_PIN_MISMATCH'});
return builtin||expected||null;
}
function verifyPin(indexId,url,expected){const want=pinnedSha256(url,expected);if(want&&indexId!==want)throw Object.assign(Error('题库索引哈希校验失败,可能已被修改,已拒绝使用。'),{code:'INDEX_PIN_MISMATCH'});return !!want;}
function loadStoredIndex(saved,indexId,expected){
const canonicalUrl=source(saved?.url).href;
const want=pinnedSha256(canonicalUrl,expected);
if(typeof saved.raw==='string'){
const actual=digest(Buffer.from(saved.raw,'utf8'));
if(actual!==indexId||(want&&actual!==want))throw Object.assign(Error('题库索引哈希校验失败,可能已被修改,已拒绝使用。'),{code:'INDEX_PIN_MISMATCH'});
return {canonicalUrl,index:parseIndex(saved.raw,canonicalUrl),pinned:!!want};
}
if(want)throw Object.assign(Error('题库索引哈希校验失败,可能已被修改,已拒绝使用。'),{code:'INDEX_PIN_MISMATCH'});
return {canonicalUrl,index:validate(saved.index,canonicalUrl),pinned:false};
}
function redirect(url){const u=new URL(url);if(u.protocol!=='https:'||u.username||u.password||u.port||!['github.com','release-assets.githubusercontent.com','objects.githubusercontent.com'].includes(u.hostname))throw Error('Unsupported download redirect');return u;}
function downloadError(status){
if(status===403||status===429)return 'GitHub 限制了公开附件下载,请稍后重试或检查网络访问限制;插件不需要 GitHub Token。';
Expand Down Expand Up @@ -61,7 +71,7 @@ function installError(e){
function service({base,within,runCommand,fetchFile=download,platform=process.platform,arch=process.arch,stepBytes}){
const preflight=()=>python.preflight(runCommand);
const operations=new Map();
const staged=require('./install-steps.cjs')({home,within,validate,verifyPin,checkPlatform,verifySpec,preflight,platform,arch,stepBytes});
const staged=require('./install-steps.cjs')({home,within,loadStoredIndex,checkPlatform,verifySpec,preflight,platform,arch,stepBytes});
async function verifySpec(dir,q){
let spec;try{spec=await readMetadata(path.join(dir,'question.json'),q.files['question.json']||'');validateSpec(spec);if(q.key!==spec.id+'@'+spec.revision||q.revision!==spec.revision)throw Error('Question identity mismatch');}
catch(e){if(e.code&&!['ENOENT','PACKAGE_INVALID'].includes(e.code))throw e;throw Object.assign(Error('Invalid question specification'),{code:'PACKAGE_INVALID'});}
Expand Down Expand Up @@ -99,16 +109,18 @@ function service({base,within,runCommand,fetchFile=download,platform=process.pla
const h=await home(p.root),tmp=path.join(h,crypto.randomUUID()+'.part');let pending;
try{
const canonicalUrl=source(p.url).href;
pinnedSha256(canonicalUrl,p.expectedSha256);
const want=pinnedSha256(canonicalUrl,p.expectedSha256);
const hash=await fetchFile(canonicalUrl,tmp,16*1024*1024);
const pinned=verifyPin(hash.sha256,canonicalUrl,p.expectedSha256);
const index=parseIndex(await fs.readFile(tmp,'utf8'),canonicalUrl);
if(want&&hash.sha256!==want)throw Object.assign(Error('题库索引哈希校验失败,可能已被修改,已拒绝使用。'),{code:'INDEX_PIN_MISMATCH'});
const rawText=await fs.readFile(tmp,'utf8');
const index=parseIndex(rawText,canonicalUrl);
const dest=path.join(h,'indices',hash.sha256);await fs.mkdir(dest,{recursive:true});
pending=path.join(dest,crypto.randomUUID()+'.tmp');
await fs.writeFile(pending,JSON.stringify({url:canonicalUrl,index}),{flag:'wx'});
const wrapper=want?{url:canonicalUrl,raw:rawText}:{url:canonicalUrl,index};
await fs.writeFile(pending,JSON.stringify(wrapper),{flag:'wx'});
await readMetadata(pending); // Published wrappers must satisfy the same budget as later reads.
await fs.rename(pending,path.join(dest,'index.json'));
return project(hash.sha256,index,canonicalUrl,pinned);
return project(hash.sha256,index,canonicalUrl,!!want);
}catch(e){if(['ENOSPC','EACCES','EPERM','EDQUOT','EIO','EROFS'].includes(e.code))throw storageError(e);throw e;}
finally{await fs.rm(tmp,{force:true});if(pending)await fs.rm(pending,{force:true});}
}
Expand All @@ -121,14 +133,14 @@ function service({base,within,runCommand,fetchFile=download,platform=process.pla
for(const id of entries.filter(x=>/^[a-f0-9]{64}$/.test(x))){
if(expected&&id!==expected)continue;
const file=path.join(h,'indices',id,'index.json');
try{const saved=await readMetadata(file);if(saved?.url!==canonicalUrl)continue;found.push({id,index:validate(saved.index,canonicalUrl),mtime:(await fs.stat(file)).mtimeMs});}
catch(e){if(e instanceof SyntaxError||['ENOENT','PACKAGE_INVALID'].includes(e.code)||e.message===invalidIndex)continue;throw e;}
try{const saved=await readMetadata(file);if(saved?.url!==canonicalUrl)continue;const loaded=loadStoredIndex(saved,id,p.expectedSha256);found.push({id,index:loaded.index,mtime:(await fs.stat(file)).mtimeMs});}
catch(e){if(e instanceof SyntaxError||['ENOENT','PACKAGE_INVALID','INDEX_PIN_MISMATCH'].includes(e.code)||e.message===invalidIndex)continue;throw e;}
}
found.sort((a,b)=>b.mtime-a.mtime||a.id.localeCompare(b.id));
return found.length?{...project(found[0].id,found[0].index,canonicalUrl,!!expected),cached:true}:{questions:[]};
}

async function plan(p){if(!/^[a-f0-9]{64}$/.test(p.indexId))throw Error('Invalid index ID');const h=await home(p.root),saved=await readMetadata(path.join(h,'indices',p.indexId,'index.json'));const canonicalUrl=source(saved.url).href;verifyPin(p.indexId,canonicalUrl);const index=validate(saved.index,canonicalUrl),q=index.questions.find(q=>q.key===p.question);if(!q)throw Error('Question not found');checkPlatform(index.platform,platform,arch);await preflight();return {artifacts:[...new Set(q.layers.map(l=>l.artifact))].map(k=>index.artifacts[k])};}
async function plan(p){if(!/^[a-f0-9]{64}$/.test(p.indexId))throw Error('Invalid index ID');const h=await home(p.root),saved=await readMetadata(path.join(h,'indices',p.indexId,'index.json'));const {index}=loadStoredIndex(saved,p.indexId);const q=index.questions.find(q=>q.key===p.question);if(!q)throw Error('Question not found');checkPlatform(index.platform,platform,arch);await preflight();return {artifacts:[...new Set(q.layers.map(l=>l.artifact))].map(k=>index.artifacts[k])};}
async function banks(p){const h=await home(p.root);let names;try{names=await fs.readdir(path.join(h,'banks'));}catch(e){if(e.code==='ENOENT')return [];throw e;}return names.filter(n=>/^[a-f0-9]{64}$/.test(n)).map(n=>({id:n,path:path.join(h,'banks',n)}));}
return {inspect,cached,plan,begin,cancel,step,banks};
}
Expand Down
Loading
Loading