@aliip/pilah 0.0.0-stage → 1.0.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/BUILD_STATUS.md +23 -0
- package/LICENSE +21 -0
- package/README.md +108 -2
- package/assets/logo.svg +5 -0
- package/docs/AB_EVALUATION.md +62 -0
- package/docs/ACCEPTANCE_GATE.md +41 -0
- package/docs/ADAPTIVE_RCA_WORKFLOW.md +93 -0
- package/docs/AGENT_DECISION_REVIEW.md +17 -0
- package/docs/AGENT_TRACE_BENCHMARK.md +17 -0
- package/docs/ALWAYS_ON_5_WHYS.md +75 -0
- package/docs/ARCHITECTURE.md +43 -0
- package/docs/BEHAVIORAL_5_WHYS_V2_0_1.md +117 -0
- package/docs/CHECKPOINT_RECOVERY.md +86 -0
- package/docs/CI_EFFICIENCY.md +63 -0
- package/docs/COMPATIBILITY.md +84 -0
- package/docs/CONTRACTS.md +177 -0
- package/docs/CONVERSATION_USAGE.md +52 -0
- package/docs/ENGINEERING_METHOD.md +68 -0
- package/docs/HOST_VALIDATION.md +35 -0
- package/docs/INDEPENDENT_ACCEPTANCE_RUNBOOK.md +72 -0
- package/docs/INTERVENTION_LEDGER.md +25 -0
- package/docs/MAIN_VALIDATION_BACKLOG.md +19 -0
- package/docs/NATIVE_FIRST_WORKFLOW.md +27 -0
- package/docs/OPEN_SOURCE_ENGINEERING_STANDARDS.md +62 -0
- package/docs/ORCHESTRATION_ADVISOR.md +36 -0
- package/docs/PRE_VNEXT_INTEGRATION.md +27 -0
- package/docs/PRIVATE_BENCHMARK_EXPORT.md +14 -0
- package/docs/README.md +58 -0
- package/docs/RELEASE.md +33 -0
- package/docs/RELEASE_AUTHORIZATION.md +33 -0
- package/docs/RISK_GUIDANCE.md +18 -0
- package/docs/SECURITY.md +76 -0
- package/docs/SECURITY_RELIABILITY_AUDIT_V2_0_1.md +55 -0
- package/docs/SEMANTIC_EVIDENCE.md +27 -0
- package/docs/SOURCES.md +13 -0
- package/docs/STOCKROOM_BENCHMARK_RECHECK_2026_11_18.md +53 -0
- package/docs/TOKEN_EFFICIENCY.md +71 -0
- package/docs/TOKEN_PROVENANCE.md +15 -0
- package/docs/V2_0_1_TRACEABILITY.md +66 -0
- package/hooks.json +45 -0
- package/mcp_config.json +16 -0
- package/package.json +31 -4
- package/plugin.json +27 -0
- package/rules/AGENTS.md +2 -0
- package/schemas/database.sql +84 -0
- package/schemas/mcp-tools.json +552 -0
- package/scripts/a2a.mjs +343 -0
- package/scripts/check-release.mjs +42 -0
- package/scripts/check-syntax.mjs +30 -0
- package/scripts/checkpoint.mjs +50 -0
- package/scripts/compare-agent-traces.mjs +53 -0
- package/scripts/context-guardian.mjs +132 -0
- package/scripts/evaluate-acceptance.mjs +110 -0
- package/scripts/export-benchmark.mjs +31 -0
- package/scripts/generate-contracts.mjs +6 -0
- package/scripts/hook.mjs +406 -0
- package/scripts/host-check.mjs +40 -0
- package/scripts/intervention-ledger.mjs +94 -0
- package/scripts/pilah.mjs +3 -0
- package/scripts/release-authorization.mjs +137 -0
- package/scripts/review-agent-decisions.mjs +34 -0
- package/scripts/semantic-evidence.mjs +15 -0
- package/scripts/verifykit.mjs +3 -0
- package/skills/pilah/SKILL.md +24 -0
- package/src/acceptance-matrix.mjs +84 -0
- package/src/browser-evidence.mjs +40 -0
- package/src/context-health.mjs +14 -0
- package/src/conversations.mjs +302 -0
- package/src/engine.mjs +494 -0
- package/src/graph.mjs +169 -0
- package/src/mcp-diagnostics.mjs +53 -0
- package/src/mcp.mjs +151 -0
- package/src/model-recovery.mjs +108 -0
- package/src/native-tool-recovery.mjs +45 -0
- package/src/node-runtime.mjs +13 -0
- package/src/orchestration-advisor.mjs +24 -0
- package/src/rca.mjs +174 -0
- package/src/risk-guidance.mjs +95 -0
- package/src/scanner.mjs +303 -0
- package/src/security.mjs +793 -0
- package/src/semantic-evidence.mjs +144 -0
- package/src/skill-discovery.mjs +23 -0
- package/src/sqlite-compat.mjs +11 -0
- package/src/storage.mjs +455 -0
- package/src/tokens.mjs +627 -0
- package/src/tools.mjs +164 -0
- package/src/verification.mjs +567 -0
- package/src/workflow-router.mjs +34 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Optional Antigravity PreInvocation advisor. Not registered until explicitly enabled.
|
|
3
|
+
// No transcript reads, no model calls, no persistent user content or token estimates.
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {fileURLToPath} from 'node:url';
|
|
7
|
+
import {getHomeDir,readSafeBytesFile,readSafeJsonFile} from '../src/security.mjs';
|
|
8
|
+
|
|
9
|
+
const KEY='a2a-context-guardian';
|
|
10
|
+
const SCRIPT=fileURLToPath(import.meta.url);
|
|
11
|
+
const LIMITS=Object.freeze({yellow:80,red:140,yellowCooldown:35,redCooldown:25});
|
|
12
|
+
const hookFile=()=>path.join(getHomeDir(),'.gemini','config','hooks.json');
|
|
13
|
+
function safeCommandPath(value){
|
|
14
|
+
return typeof value==='string'&&value.length>0&&value.length<=4096&&path.isAbsolute(value)&&
|
|
15
|
+
![...value].some(char=>char.codePointAt(0)<32||[34,36,96,37,33,127].includes(char.codePointAt(0)));
|
|
16
|
+
}
|
|
17
|
+
export function guardianHookCommand(pluginFile=SCRIPT,nodeBinary=process.execPath){
|
|
18
|
+
if(!safeCommandPath(pluginFile)||!safeCommandPath(nodeBinary))throw new Error('Unsafe plugin or Node binary path for hook command');
|
|
19
|
+
return '"' + nodeBinary + '" "' + pluginFile + '" hook';
|
|
20
|
+
}
|
|
21
|
+
const command=()=>guardianHookCommand();
|
|
22
|
+
const owned=()=>({PreInvocation:[{type:'command',command:command(),timeout:5}]});
|
|
23
|
+
function isOwnedGuardian(value){
|
|
24
|
+
if(!value||typeof value!=='object'||Array.isArray(value))return false;
|
|
25
|
+
const entry=value.PreInvocation;
|
|
26
|
+
if(!Array.isArray(entry)||entry.length!==1)return false;
|
|
27
|
+
const hook=entry[0];
|
|
28
|
+
if(!hook||typeof hook!=='object'||typeof hook.command!=='string')return false;
|
|
29
|
+
const cmd=hook.command;
|
|
30
|
+
const oldCommand='node "'+SCRIPT+'" hook';
|
|
31
|
+
const match=/^"([^"]+)" "([^"]+)" hook$/.exec(cmd);
|
|
32
|
+
const validNew=!!match&&match[2]===SCRIPT&&safeCommandPath(match[1])&&
|
|
33
|
+
['node','node.exe'].includes(path.basename(match[1]).toLowerCase());
|
|
34
|
+
return (cmd===oldCommand||validNew)&&
|
|
35
|
+
JSON.stringify(value)===JSON.stringify({PreInvocation:[{type:'command',command:cmd,timeout:5}]});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function adviseInvocation(p){
|
|
39
|
+
if(!p||typeof p!=='object'||p.hookEventName&&p.hookEventName!=='PreInvocation')return {};
|
|
40
|
+
const steps=p.initialNumSteps,turn=p.invocationNum;
|
|
41
|
+
if(!Number.isSafeInteger(steps)||steps<0||steps>1000000||
|
|
42
|
+
!Number.isSafeInteger(turn)||turn<0||turn>1000000)return {};
|
|
43
|
+
const zone=steps>=LIMITS.red?'red':steps>=LIMITS.yellow?'yellow':'normal';
|
|
44
|
+
if(zone==='normal')return {};
|
|
45
|
+
const cooldown=zone==='red'?LIMITS.redCooldown:LIMITS.yellowCooldown;
|
|
46
|
+
if(turn%cooldown!==0)return {};
|
|
47
|
+
const advice=zone==='red'
|
|
48
|
+
? 'Review handoff to a new session only after the current atomic work and tests finish.'
|
|
49
|
+
: 'Review whether native /compact is useful at the next completed milestone.';
|
|
50
|
+
return {injectSteps:[{ephemeralMessage:
|
|
51
|
+
`A2A Context Guardian (${zone}; ${steps} planner steps, heuristic only): ${advice} Never compact mid-task. No action was taken.`}]};
|
|
52
|
+
}
|
|
53
|
+
function readManifest(){
|
|
54
|
+
const result=readSafeJsonFile(hookFile(),{maxBytes:128*1024,checkParentDir:true});
|
|
55
|
+
if(result.reason==='missing')return {config:{},previous:null};
|
|
56
|
+
if(!result.ok)throw new Error('Existing hooks manifest is unreadable or unsafe; no changes made.');
|
|
57
|
+
if(!result.value||typeof result.value!=='object'||Array.isArray(result.value))
|
|
58
|
+
throw new Error('Existing hooks manifest must be a JSON object; no changes made.');
|
|
59
|
+
return {config:result.value,previous:result.bytes};
|
|
60
|
+
}
|
|
61
|
+
function ensureSafeParents(dir){
|
|
62
|
+
const home=path.resolve(getHomeDir()),relative=path.relative(home,path.resolve(dir));
|
|
63
|
+
if(relative==='..'||relative.startsWith('..'+path.sep)||path.isAbsolute(relative))throw Error('Invalid hooks directory');
|
|
64
|
+
let current=home;
|
|
65
|
+
if(fs.lstatSync(current).isSymbolicLink())throw Error('Symlink home denied');
|
|
66
|
+
for(const segment of relative.split(path.sep).filter(Boolean)){
|
|
67
|
+
current=path.join(current,segment);
|
|
68
|
+
try{fs.mkdirSync(current,{mode:0o700})}catch(e){if(e.code!=='EEXIST')throw e}
|
|
69
|
+
const st=fs.lstatSync(current);
|
|
70
|
+
if(st.isSymbolicLink()||!st.isDirectory())throw Error('Unsafe hooks directory');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function saveManifest(config,previous){
|
|
74
|
+
const file=hookFile(),folder=path.dirname(file);
|
|
75
|
+
ensureSafeParents(folder);
|
|
76
|
+
const current=readSafeBytesFile(file,{maxBytes:128*1024,checkParentDir:true});
|
|
77
|
+
if(previous===null ? current.reason!=='missing' : !current.ok||!current.bytes.equals(previous))
|
|
78
|
+
throw Error('Hooks configuration changed; refusing to overwrite');
|
|
79
|
+
const payload=JSON.stringify(config,null,2)+'\n';
|
|
80
|
+
if(Buffer.byteLength(payload)>128*1024)throw Error('Hooks configuration exceeds safe limit');
|
|
81
|
+
const tmp=file+'.'+process.pid+'.tmp';
|
|
82
|
+
let fd=null;
|
|
83
|
+
try{
|
|
84
|
+
fd=fs.openSync(tmp,fs.constants.O_WRONLY|fs.constants.O_CREAT|fs.constants.O_EXCL|(fs.constants.O_NOFOLLOW||0),0o600);
|
|
85
|
+
fs.writeFileSync(fd,payload);fs.closeSync(fd);fd=null;
|
|
86
|
+
fs.renameSync(tmp,file);
|
|
87
|
+
}finally{if(fd!==null)fs.closeSync(fd);try{fs.unlinkSync(tmp)}catch{}}
|
|
88
|
+
}
|
|
89
|
+
export function configureGuardian(action){
|
|
90
|
+
if(!['status','enable','disable'].includes(action))throw Error('Expected status, enable or disable');
|
|
91
|
+
const {config,previous}=readManifest(),present=Object.hasOwn(config,KEY);
|
|
92
|
+
const valid=present&&isOwnedGuardian(config[KEY]);
|
|
93
|
+
if(action==='status')return {enabled:valid,conflict:present&&!valid,default_enabled:false,
|
|
94
|
+
no_recurring_hook_when_disabled:!present,automatic_compaction:false};
|
|
95
|
+
if(present&&!valid)throw Error('Guardian key is managed by another configuration; refusing to overwrite');
|
|
96
|
+
if(action==='enable'){
|
|
97
|
+
const expected=owned();
|
|
98
|
+
// Explicit re-enable refreshes stale NVM Node binaries, including legacy PATH-based commands.
|
|
99
|
+
if(!present||JSON.stringify(config[KEY])!==JSON.stringify(expected)){
|
|
100
|
+
config[KEY]=expected;saveManifest(config,previous);
|
|
101
|
+
}
|
|
102
|
+
return {enabled:true,automatic_compaction:false,restart_ide_recommended:true,
|
|
103
|
+
note:'Opt-in PreInvocation advisory only; no active context-window token measurement.'};
|
|
104
|
+
}
|
|
105
|
+
if(present){delete config[KEY];saveManifest(config,previous)}
|
|
106
|
+
return {enabled:false,automatic_compaction:false,restart_ide_recommended:true};
|
|
107
|
+
}
|
|
108
|
+
function readStdin(max=128*1024){
|
|
109
|
+
const buffer=Buffer.alloc(8192),parts=[];let bytes=0;
|
|
110
|
+
while(true){
|
|
111
|
+
const n=fs.readSync(0,buffer,0,buffer.length,null);if(n===0)break;
|
|
112
|
+
bytes+=n;if(bytes>max)throw Error('Hook input too large');
|
|
113
|
+
parts.push(Buffer.from(buffer.subarray(0,n)));
|
|
114
|
+
}
|
|
115
|
+
return Buffer.concat(parts).toString('utf8');
|
|
116
|
+
}
|
|
117
|
+
function main(){
|
|
118
|
+
const arg=process.argv[2]||'status';
|
|
119
|
+
if(arg==='hook'){
|
|
120
|
+
try{const parsed=JSON.parse(readStdin()||'{}');process.stdout.write(JSON.stringify(adviseInvocation(parsed))+'\n')}
|
|
121
|
+
catch{process.stdout.write('{}\n')}
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
try{
|
|
125
|
+
if(process.argv.length>3)throw Error('Unexpected extra arguments');
|
|
126
|
+
process.stdout.write(JSON.stringify(configureGuardian(arg))+'\n');
|
|
127
|
+
}catch(e){
|
|
128
|
+
process.stderr.write('Context guardian: '+String(e.message||'error').replaceAll(getHomeDir(),'<home>')+'\n');
|
|
129
|
+
process.exitCode=1;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if(process.argv[1]&&path.resolve(process.argv[1])===SCRIPT)main();
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Release eligibility review from independently signed machine evidence.
|
|
3
|
+
// Signature proves possession of a pinned reviewer key, NOT correctness of executed tests.
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import crypto from 'node:crypto';
|
|
7
|
+
import {fileURLToPath} from 'node:url';
|
|
8
|
+
import {readSafeJsonFile} from '../src/security.mjs';
|
|
9
|
+
const isObj=v=>v!==null&&typeof v==='object'&&!Array.isArray(v);
|
|
10
|
+
const check=(v,m)=>{if(!v)throw new Error(m)};
|
|
11
|
+
const statuses=new Set(['passed','failed','partial','blocked','not-tested']);
|
|
12
|
+
const types=new Set(['junit','tap','browser','security','performance','accessibility','manual','integration']);
|
|
13
|
+
const digest=v=>typeof v==='string'&&/^[0-9a-f]{64}$/i.test(v);
|
|
14
|
+
export function attestationPayload({revision,scenarioId,evidence}){
|
|
15
|
+
return JSON.stringify({schema:'a2a-attestation-v2',revision,scenario_id:scenarioId,outcome:evidence.outcome,type:evidence.type,reference:evidence.reference,checked_at:evidence.checked_at,artifact_sha256:evidence.artifact_sha256,assertion_count:evidence.assertion_count});
|
|
16
|
+
}
|
|
17
|
+
export function validateEvidenceSignature({revision,scenarioId,evidence,trustKeys={}}){
|
|
18
|
+
if(!isObj(evidence)||evidence.outcome!=='passed'||evidence.revision!==revision||!types.has(evidence.type)||!digest(evidence.artifact_sha256)||!Number.isSafeInteger(evidence.assertion_count)||evidence.assertion_count<1||typeof evidence.reference!=='string'||!evidence.reference.trim()||typeof evidence.checked_at!=='string'||Number.isNaN(Date.parse(evidence.checked_at)))return false;
|
|
19
|
+
const key=typeof evidence.key_id==='string'&&Object.hasOwn(trustKeys,evidence.key_id)?trustKeys[evidence.key_id]:null;
|
|
20
|
+
if(typeof key!=='string'||typeof evidence.signature!=='string'||evidence.signature.length>1024||!/^[A-Za-z0-9+/]+=*$/.test(evidence.signature))return false;
|
|
21
|
+
try{
|
|
22
|
+
const parsed=crypto.createPublicKey(key);
|
|
23
|
+
if(parsed.asymmetricKeyType!=='ed25519')return false;
|
|
24
|
+
const bytes=Buffer.from(evidence.signature,'base64');
|
|
25
|
+
return bytes.length===64&&crypto.verify(null,Buffer.from(attestationPayload({revision,scenarioId,evidence}),'utf8'),parsed,bytes);
|
|
26
|
+
}catch{return false}
|
|
27
|
+
}
|
|
28
|
+
export function assessRelease(input,{trustKeys={},requiredScenarios=null}={}){
|
|
29
|
+
check(isObj(input)&&Array.isArray(input.scenarios)&&input.scenarios.length>0&&input.scenarios.length<=100,'Expected 1-100 scenarios');
|
|
30
|
+
check(isObj(input.evaluator)&&input.evaluator.independent===true&&typeof input.evaluator.name==='string'&&input.evaluator.name.trim(),'Explicit independent evaluator required');
|
|
31
|
+
check(typeof input.revision==='string'&&input.revision.trim(),'Code revision is required');
|
|
32
|
+
check(isObj(trustKeys),'Trusted keys must be explicitly configured outside implementation inputs');
|
|
33
|
+
const ids=new Set(),results=[],blockers=[];
|
|
34
|
+
for(const s of input.scenarios){
|
|
35
|
+
check(isObj(s)&&typeof s.id==='string'&&/^[a-zA-Z0-9_.:-]{1,100}$/.test(s.id)&&!ids.has(s.id),'Invalid or duplicate scenario ID');
|
|
36
|
+
ids.add(s.id);
|
|
37
|
+
check(typeof s.requirement==='string'&&s.requirement.trim()&&statuses.has(s.verdict),'Scenario requires description and valid verdict');
|
|
38
|
+
check(typeof s.critical==='boolean','critical must be explicit');
|
|
39
|
+
check(Array.isArray(s.evidence)&&s.evidence.length<=40,'Every scenario needs a bounded evidence array');
|
|
40
|
+
const verified=s.evidence.filter(e=>validateEvidenceSignature({revision:input.revision,scenarioId:s.id,evidence:e,trustKeys}));
|
|
41
|
+
let note=null,verdict=s.verdict;
|
|
42
|
+
if(verdict==='passed'){
|
|
43
|
+
if(verified.length===0){verdict='not-tested';note='No independently key-verified machine evidence for this revision and scenario';}
|
|
44
|
+
else if(Array.isArray(s.required_evidence_types)&&s.required_evidence_types.some(t=>!verified.some(e=>e.type===t))){
|
|
45
|
+
verdict='partial';note='Missing independently verified required evidence type(s)';
|
|
46
|
+
}
|
|
47
|
+
else if(s.critical&&verified.every(e=>e.type==='manual')){
|
|
48
|
+
verdict='partial';note='Critical machine scenario cannot be verified by manual prose alone';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const row={id:s.id,requirement_sha256:crypto.createHash('sha256').update(s.requirement).digest('hex'),critical:s.critical,verdict,evidence_count:s.evidence.length,signature_verified_evidence:verified.length,...(note?{note}:{})};results.push(row);
|
|
52
|
+
if(s.critical&&verdict!=='passed')blockers.push({scenario_id:s.id,verdict,reason:note||'Critical scenario not verified'});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// The project-under-test cannot choose its own complete acceptance scope.
|
|
56
|
+
// An absent or malformed independently pinned registry fails closed.
|
|
57
|
+
let scopeVerified=false;
|
|
58
|
+
if(Array.isArray(requiredScenarios)&&requiredScenarios.length>0&&requiredScenarios.length<=100){
|
|
59
|
+
const requiredIds=new Set();
|
|
60
|
+
scopeVerified=true;
|
|
61
|
+
for(const expected of requiredScenarios){
|
|
62
|
+
if(!isObj(expected)||typeof expected.id!=='string'||requiredIds.has(expected.id)||
|
|
63
|
+
!digest(expected.requirement_sha256)||typeof expected.critical!=='boolean'||
|
|
64
|
+
!Array.isArray(expected.required_evidence_types)||expected.required_evidence_types.some(t=>!types.has(t))){
|
|
65
|
+
scopeVerified=false;break;
|
|
66
|
+
}
|
|
67
|
+
requiredIds.add(expected.id);
|
|
68
|
+
const found=input.scenarios.find(s=>s.id===expected.id);
|
|
69
|
+
const reqHash=found&&typeof found.requirement==='string'?crypto.createHash('sha256').update(found.requirement).digest('hex'):null;
|
|
70
|
+
if(!found||reqHash!==expected.requirement_sha256||found.critical!==expected.critical||
|
|
71
|
+
expected.required_evidence_types.some(t=>!Array.isArray(found.required_evidence_types)||!found.required_evidence_types.includes(t))){
|
|
72
|
+
scopeVerified=false;blockers.push({scenario_id:expected.id,reason:'Frozen acceptance requirement missing or modified'});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if(input.scenarios.length!==requiredIds.size){scopeVerified=false;blockers.push({reason:'Manifest scenario set differs from independently pinned acceptance registry'});}
|
|
76
|
+
}
|
|
77
|
+
if(!scopeVerified)blockers.push({reason:'Independent frozen acceptance registry absent, invalid, or not fully matched'});
|
|
78
|
+
|
|
79
|
+
check(Array.isArray(input.critical_defects),'Explicit critical_defects inventory is required (use [] only after independent review)');
|
|
80
|
+
const defects=input.critical_defects;
|
|
81
|
+
for(const d of defects){check(isObj(d)&&typeof d.id==='string'&&d.id.trim(),'Invalid critical defect record');if(d.status!=='resolved-and-retested')blockers.push({defect_id:d.id,reason:'Unresolved or unverified critical defect'});}
|
|
82
|
+
const passed=results.filter(x=>x.verdict==='passed').length;
|
|
83
|
+
const release_ready=scopeVerified&&passed===results.length&&blockers.length===0;
|
|
84
|
+
return {schema:'a2a-release-gate-v2',revision:input.revision,verdict:release_ready?'eligible-for-review':'blocked',release_ready,scope_verified:scopeVerified,scenarios:{passed,total:results.length,results},blockers,limits:['Key verification attests the claimed issuer, not that tests were executed honestly','An independent assessor must review runner provenance, scenario semantics, browser/build identity and hidden dependencies','Missing or untrusted evidence never counts as passed','Independent frozen acceptance registry must be pinned outside the implementation repository','An eligible-for-review result is NOT production security certification']};
|
|
85
|
+
}
|
|
86
|
+
export function assessFile(file,{trustKeyFile=null,requiredScenarioFile=null}={}){
|
|
87
|
+
const evidence=readSafeJsonFile(file,{maxBytes:1024*1024});
|
|
88
|
+
check(evidence.ok,'Unsafe or invalid evaluation file');
|
|
89
|
+
let keys={};
|
|
90
|
+
if(trustKeyFile){
|
|
91
|
+
const trust=readSafeJsonFile(trustKeyFile,{maxBytes:64*1024});
|
|
92
|
+
check(trust.ok,'Unsafe or invalid public-key trust configuration');
|
|
93
|
+
keys=trust.value;
|
|
94
|
+
check(isObj(keys)&&Object.keys(keys).length<=20,'Invalid public-key trust config');
|
|
95
|
+
}
|
|
96
|
+
let requiredScenarios=null;
|
|
97
|
+
if(requiredScenarioFile){
|
|
98
|
+
const registry=readSafeJsonFile(requiredScenarioFile,{maxBytes:64*1024});
|
|
99
|
+
check(registry.ok,'Unsafe or invalid pinned acceptance registry');
|
|
100
|
+
const pinned=registry.value;
|
|
101
|
+
check(isObj(pinned)&&pinned.schema==='a2a-acceptance-registry-v1'&&Array.isArray(pinned.scenarios),'Invalid frozen acceptance registry');
|
|
102
|
+
requiredScenarios=pinned.scenarios;
|
|
103
|
+
}
|
|
104
|
+
return assessRelease(evidence.value,{trustKeys:keys,requiredScenarios});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url)){
|
|
108
|
+
try{check(process.argv.length>=3&&process.argv.length<=5,'Usage: node scripts/evaluate-acceptance.mjs <evidence.json> [trusted-public-keys.json] [pinned-requirements.json]');process.stdout.write(JSON.stringify(assessFile(process.argv[2],{trustKeyFile:process.argv[3],requiredScenarioFile:process.argv[4]}),null,2)+'\n')}
|
|
109
|
+
catch(e){process.stderr.write('Acceptance evaluation failed: '+e.message+'\n');process.exitCode=1}
|
|
110
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Allowlist-based local export: raw prompts, paths, tokens, cookies and transcripts never copied.
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import {fileURLToPath} from 'node:url';
|
|
6
|
+
const variants=new Set(['native','a2a-on-demand','a2a-always-on','native-subagent','a2a-subagent','native-swarm','a2a-swarm','native-teamwork','a2a-teamwork']);
|
|
7
|
+
const statuses=new Set(['SUCCESS','ERROR','CANCELED','INTERRUPTED','WAITING','INVALID','RUNNING','UNKNOWN']);
|
|
8
|
+
const numeric=v=>typeof v==='number'&&Number.isFinite(v)&&v>=0&&v<=1e15?v:null;
|
|
9
|
+
const check=(v,msg)=>{if(!v)throw new Error(msg)};
|
|
10
|
+
export function safeBenchmarkExport(report){
|
|
11
|
+
check(report&&typeof report==='object'&&!Array.isArray(report),'Expected parsed benchmark report');
|
|
12
|
+
check(report.schema==='a2a-ab-evaluation-v1','Only the known benchmark schema is supported');
|
|
13
|
+
check(Array.isArray(report.runs)&&report.runs.length<=300,'Invalid or oversized runs');
|
|
14
|
+
const result=[];
|
|
15
|
+
for(let i=0;i<report.runs.length;i++){
|
|
16
|
+
const r=report.runs[i];
|
|
17
|
+
check(r&&variants.has(r.variant),'Unknown benchmark variant');
|
|
18
|
+
const run={run_index:i+1,variant:r.variant,status:statuses.has(r.status)?r.status:'UNKNOWN',reported_tokens:numeric(r.usage?.total_tokens),cache_read_tokens:numeric(r.usage?.cache_read_tokens),duration_seconds:numeric(r.duration_seconds),model_turns:numeric(r.num_turns),tool_calls:numeric(r.tool_calls),accepted_scenarios:numeric(r.acceptance_passed),total_scenarios:numeric(r.acceptance_total)};
|
|
19
|
+
result.push(run);
|
|
20
|
+
}
|
|
21
|
+
const clean={schema:'a2a-sanitized-benchmark-v1',source_kind:'a2a-ab-evaluation-v1',runs:result,summary:{runs:result.length,variants:[...new Set(result.map(x=>x.variant))],measured_causal_savings:false},review:{safe_by_default_metadata_only:true,user_review_required:true,auto_uploaded:false,share_authorized:false},warnings:['Source transcript and workspace content intentionally omitted','No free-tier quota or cost claims; official usage records require provider validation','Review this file before sharing; source applications, prompts and raw agent traces must never be attached automatically']};
|
|
22
|
+
return clean;
|
|
23
|
+
}
|
|
24
|
+
if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url)){
|
|
25
|
+
try{
|
|
26
|
+
check(process.argv.length===3,'Usage: node scripts/export-benchmark.mjs local-aggregated-report.json');
|
|
27
|
+
const stat=fs.statSync(process.argv[2]);check(stat.isFile()&&stat.size<=8*1024*1024,'Expected input <=8 MiB');
|
|
28
|
+
const input=JSON.parse(fs.readFileSync(process.argv[2],'utf8'));
|
|
29
|
+
process.stdout.write(JSON.stringify(safeBenchmarkExport(input),null,2)+'\n');
|
|
30
|
+
}catch(e){process.stderr.write('Sanitized export failed: '+e.message+'\n');process.exitCode=1}
|
|
31
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import {TOOLS} from '../src/tools.mjs';
|
|
4
|
+
const target=new URL('../schemas/mcp-tools.json',import.meta.url);
|
|
5
|
+
fs.writeFileSync(target,JSON.stringify({schema_version:'1.0.0',tools:TOOLS},null,2)+'\n');
|
|
6
|
+
console.log('Wrote schemas/mcp-tools.json');
|