File size: 6,739 Bytes
b67a1e9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | #!/usr/bin/env python3
import json, re
from pathlib import Path
from datetime import datetime, timezone
ROOT=Path(__file__).resolve().parents[1]
TRIAGE=ROOT/'triage'
OUT=ROOT/'verifier_creation'
PLANS=OUT/'plans'
SCRIPTS=OUT/'scripts'
JOBS=ROOT/'jobs/pending'
for d in [OUT,PLANS,SCRIPTS,JOBS]: d.mkdir(parents=True,exist_ok=True)
MAX_PROJECTS=20
def load(p): return json.loads(Path(p).read_text(encoding='utf-8'))
def slug(s): return re.sub(r'[^A-Za-z0-9_.-]+','_',s.replace('/home/smlflg/',''))[:100]
def infer(row):
tech=(row.get('tech') or '').lower(); path=row['path']
if 'python' in tech:
return {'kind':'python','cmd':'python -m compileall -q . && pytest -q','script':'verify_python_project.py'}
if 'node' in tech or 'javascript' in tech or 'typescript' in tech:
return {'kind':'node','cmd':'node --version && npm test','script':'verify_node_project.py'}
if 'rust' in tech:
return {'kind':'rust','cmd':'cargo test','script':'verify_rust_project.py'}
if 'go' in tech:
return {'kind':'go','cmd':'go test ./...','script':'verify_go_project.py'}
return {'kind':'generic','cmd':'git status --short && test -e README.md || test -e README','script':'verify_generic_project.py'}
def plan(row, spec):
return f"""# VERIFIER_CREATION Plan — {row['name']}
Project: `{row['path']}`
Categories: {', '.join(row['categories'])}
Tech: {row.get('tech')}
Score: {row['score']}
Dirty: {row['dirty_count']}
## Mode
READ_ONLY_VERIFIER_CREATION.
Do not modify source project files. Create a verifier script artifact under ProjectIntakeTower first.
## Objective
Create one project-specific verifier that answers: "Does this project still basically work?"
## Candidate verifier command
```bash
cd {row['path']}
{spec['cmd']}
```
## Required behavior
The verifier must:
1. Be non-destructive.
2. Avoid dependency installs.
3. Print JSON with status, checks, failures, warnings, project_path.
4. Exit 0 only if core smoke checks pass.
5. Mark dependency/tool absence as needs_human, not silently passed.
6. Never commit/push/create issues.
## Output
Script artifact:
`ProjectIntakeTower/verifier_creation/scripts/{slug(row['path'])}_verifier.py`
Run record:
`ProjectIntakeTower/verifier_creation/results/{slug(row['path'])}_result.json`
"""
def script(row, spec):
path=row['path']; s=slug(path)
return f'''#!/usr/bin/env python3
import json, subprocess, shutil
from pathlib import Path
PROJECT=Path({path!r})
COMMAND={spec['cmd']!r}
def run(cmd, timeout=60):
try:
p=subprocess.run(cmd, cwd=PROJECT, shell=True, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=timeout)
return {{'cmd':cmd,'exit_code':p.returncode,'stdout':p.stdout[-4000:],'stderr':p.stderr[-4000:]}}
except Exception as e:
return {{'cmd':cmd,'exit_code':124,'stdout':'','stderr':str(e)}}
def main():
checks=[]; failures=[]; warnings=[]
if not PROJECT.exists():
failures.append('project path missing')
if not (PROJECT/'.git').exists():
warnings.append('no .git marker')
checks.append(run('git status --short', timeout=20))
# Main smoke command. Non-destructive; no install.
checks.append(run(COMMAND, timeout=90))
status='passed'
for c in checks:
if c['exit_code'] not in (0,):
status='needs_human' if 'not found' in (c.get('stderr','')+c.get('stdout','')).lower() else 'failed'
failures.append(f"{{c['cmd']}} exit={{c['exit_code']}}")
result={{'status':status,'project_path':str(PROJECT),'verifier_kind':{spec['kind']!r},'checks':checks,'failures':failures,'warnings':warnings,'next_action':'If failed/needs_human, inspect stderr and decide dependency/test setup.'}}
print(json.dumps(result,indent=2))
raise SystemExit(0 if status=='passed' else 1)
if __name__=='__main__': main()
'''
def main():
pri=load(TRIAGE/'PROJECT_PRIORITIZATION.json')
selected=[]; seen=set()
for cat in ['KEEP','URGENT','MERGE','TOKEN_BURN_CANDIDATE']:
for r in pri['categories'].get(cat,[]):
if r['path'] in seen: continue
if 'ARCHIVE' in r['categories'] and 'KEEP' not in r['categories']: continue
selected.append(r); seen.add(r['path'])
if len(selected)>=MAX_PROJECTS: break
if len(selected)>=MAX_PROJECTS: break
index=['# VERIFIER_CREATION','',f'Generated: {datetime.now(timezone.utc).isoformat()}','',f'Projects selected: {len(selected)}','', 'Mode: READ_ONLY_VERIFIER_CREATION — script artifacts only; no source edits.', '']
jobs=[]
for i,row in enumerate(selected,1):
s=slug(row['path']); spec=infer(row)
plan_path=PLANS/f'{i:02d}_{s}.md'
script_path=SCRIPTS/f'{i:02d}_{s}_verifier.py'
plan_path.write_text(plan(row,spec),encoding='utf-8')
script_path.write_text(script(row,spec),encoding='utf-8')
script_path.chmod(0o755)
job={
'job_id':f'verifiercreate-2026-05-04-{i:02d}-{s.lower()}',
'project_name':row['name'], 'project_path':row['path'], 'mode':'review_only',
'allowed_actions':['read files','inspect manifests/tests','write ProjectIntakeTower verifier artifact only','run non-destructive smoke checks'],
'forbidden_actions':['modify source project files','commit','push','merge','delete files','install dependencies','create GitHub issues','print secrets'],
'allowed_files':[f'{row["path"]} read-only','ProjectIntakeTower/verifier_creation write scope'],
'expected_artifacts':[str(plan_path),str(script_path)],
'verifier_commands':['python3 ProjectIntakeTower/verifier/verify_verifier_creation.py'],
'stop_conditions':['dependency install required','source edit required','destructive verifier needed','credentials required'],
'objective':f'Create/read-review a non-destructive verifier for {row["name"]}.',
'candidate_command':spec['cmd']
}
jp=JOBS/f'verifiercreate_{i:02d}_{s}.json'; jp.write_text(json.dumps(job,indent=2,ensure_ascii=False),encoding='utf-8'); jobs.append(str(jp))
index += [f'## {i}. {row["name"]}',f'Path: `{row["path"]}`',f'Plan: `{plan_path}`',f'Script: `{script_path}`',f'Candidate: `{spec["cmd"]}`','']
result={'status':'succeeded','mode':'READ_ONLY_VERIFIER_CREATION','projects':len(selected),'plans':len(list(PLANS.glob('*.md'))),'scripts':len(list(SCRIPTS.glob('*_verifier.py'))),'jobs_created':len(jobs),'jobs':jobs}
(OUT/'VERIFIER_CREATION.md').write_text('\n'.join(index),encoding='utf-8')
(OUT/'result.json').write_text(json.dumps(result,indent=2,ensure_ascii=False),encoding='utf-8')
print(json.dumps(result,indent=2))
if __name__=='__main__': main()
|