Skip to content

Commit b8a112f

Browse files
committed
ownership-lab H-25: census-only await-wrapped acquire seam (OWEN_H25_CENSUS=<path>: one JSON line per await-shaped write of a disposable local with the resolved callable, return kind, logical result, trusted row, sync twin, nesting, disposal context) and ReOracle.HasRow; fixture classification and OFF byte identity; census runner
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Am9eQwzNfbugH72eVKetC2
1 parent 52fc2c7 commit b8a112f

6 files changed

Lines changed: 225 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"ownir_version": 0,
3+
"module": "Extracted",
4+
"components": [],
5+
"services": [],
6+
"functions": [
7+
{
8+
"name": "Hostile.HW1_deferred_await",
9+
"file": "../../../tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs",
10+
"sig": "",
11+
"body": [
12+
{
13+
"op": "acquire",
14+
"var": "task",
15+
"line": 25,
16+
"column": 57,
17+
"kind": "disposable"
18+
}
19+
]
20+
}
21+
],
22+
"stats": {
23+
"methods_with_local": 1,
24+
"methods_flow_analysed": 1,
25+
"methods_skipped_unmodelled": 0
26+
}
27+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":10,"local":"x","local_type":"RLibA.R","member":"AW1_task_assignment","form":"assignment","declared_using":false,"declared_await_using":false,"awaited":"invocation","configure_await":false,"callable":"RLibA.FA.FactoryAsync/0","callable_assembly":"RLibA","first_party":false,"return_kind":"Task\u003CT\u003E","logical_result":"RLibA.R","logical_disposable":true,"trusted_row":true,"sync_twin_row":true,"nesting":[],"in_try":false,"initializer":"null","disposed_somewhere":true,"disposed_in_finally":false}
2+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":12,"local":"x","local_type":"RLibA.R","member":"AW2_configure_await","form":"assignment","declared_using":false,"declared_await_using":false,"awaited":"invocation","configure_await":true,"callable":"RLibA.FA.FactoryAsync/0","callable_assembly":"RLibA","first_party":false,"return_kind":"Task\u003CT\u003E","logical_result":"RLibA.R","logical_disposable":true,"trusted_row":true,"sync_twin_row":true,"nesting":[],"in_try":false,"initializer":"null","disposed_somewhere":true,"disposed_in_finally":false}
3+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":14,"local":"x","local_type":"RLibA.R","member":"AW3_valuetask","form":"assignment","declared_using":false,"declared_await_using":false,"awaited":"invocation","configure_await":false,"callable":"RLibA.FA.FactoryValueTaskAsync/0","callable_assembly":"RLibA","first_party":false,"return_kind":"ValueTask\u003CT\u003E","logical_result":"RLibA.R","logical_disposable":true,"trusted_row":true,"sync_twin_row":false,"nesting":[],"in_try":false,"initializer":"null","disposed_somewhere":true,"disposed_in_finally":false}
4+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":16,"local":"x","local_type":"RLibA.R","member":"AW4_declaration","form":"declaration","declared_using":false,"declared_await_using":false,"awaited":"invocation","configure_await":false,"callable":"RLibA.FA.FactoryAsync/0","callable_assembly":"RLibA","first_party":false,"return_kind":"Task\u003CT\u003E","logical_result":"RLibA.R","logical_disposable":true,"trusted_row":true,"sync_twin_row":true,"nesting":[],"in_try":false,"initializer":"value","disposed_somewhere":true,"disposed_in_finally":false}
5+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":18,"local":"x","local_type":"RLibA.R","member":"AW5_declaration_configure_await","form":"declaration","declared_using":false,"declared_await_using":false,"awaited":"invocation","configure_await":true,"callable":"RLibA.FA.FactoryAsync/0","callable_assembly":"RLibA","first_party":false,"return_kind":"Task\u003CT\u003E","logical_result":"RLibA.R","logical_disposable":true,"trusted_row":true,"sync_twin_row":true,"nesting":[],"in_try":false,"initializer":"value","disposed_somewhere":false,"disposed_in_finally":false}
6+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":20,"local":"x","local_type":"RLibA.R","member":"AW6_try_finally","form":"assignment","declared_using":false,"declared_await_using":false,"awaited":"invocation","configure_await":false,"callable":"RLibA.FA.FactoryAsync/0","callable_assembly":"RLibA","first_party":false,"return_kind":"Task\u003CT\u003E","logical_result":"RLibA.R","logical_disposable":true,"trusted_row":true,"sync_twin_row":true,"nesting":["Block","TryStatement"],"in_try":true,"initializer":"null","disposed_somewhere":true,"disposed_in_finally":true}
7+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":25,"local":"x","local_type":"RLibA.R","member":"HW1_deferred_await","form":"declaration","declared_using":false,"declared_await_using":false,"awaited":"local_or_name","configure_await":false,"callable":null,"callable_assembly":null,"first_party":false,"return_kind":"none","logical_result":null,"logical_disposable":false,"trusted_row":false,"sync_twin_row":null,"nesting":[],"in_try":false,"initializer":"value","disposed_somewhere":false,"disposed_in_finally":false}
8+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":27,"local":"x","local_type":"RLibA.R","member":"HW2_borrowed","form":"assignment","declared_using":false,"declared_await_using":false,"awaited":"invocation","configure_await":false,"callable":"RLibA.FA.BorrowedAsync/0","callable_assembly":"RLibA","first_party":false,"return_kind":"Task\u003CT\u003E","logical_result":"RLibA.R","logical_disposable":true,"trusted_row":false,"sync_twin_row":false,"nesting":[],"in_try":false,"initializer":"null","disposed_somewhere":false,"disposed_in_finally":false}
9+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":29,"local":"x","local_type":"RLibA.R","member":"HW3_cached","form":"assignment","declared_using":false,"declared_await_using":false,"awaited":"invocation","configure_await":false,"callable":"RLibA.FA.CachedAsync/0","callable_assembly":"RLibA","first_party":false,"return_kind":"Task\u003CT\u003E","logical_result":"RLibA.R","logical_disposable":true,"trusted_row":false,"sync_twin_row":false,"nesting":[],"in_try":false,"initializer":"null","disposed_somewhere":false,"disposed_in_finally":false}
10+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":33,"local":"x","local_type":"RLibA.R","member":"HW5_unknown","form":"assignment","declared_using":false,"declared_await_using":false,"awaited":"invocation","configure_await":false,"callable":"RLibA.FA.UnknownAsync/0","callable_assembly":"RLibA","first_party":false,"return_kind":"Task\u003CT\u003E","logical_result":"RLibA.R","logical_disposable":true,"trusted_row":false,"sync_twin_row":false,"nesting":[],"in_try":false,"initializer":"null","disposed_somewhere":false,"disposed_in_finally":false}
11+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":35,"local":"x","local_type":"RLibA.R","member":"HW6_name_twin","form":"assignment","declared_using":false,"declared_await_using":false,"awaited":"invocation","configure_await":false,"callable":"RLibA.FA.BorrowedTwinAsync/0","callable_assembly":"RLibA","first_party":false,"return_kind":"Task\u003CT\u003E","logical_result":"RLibA.R","logical_disposable":true,"trusted_row":false,"sync_twin_row":false,"nesting":[],"in_try":false,"initializer":"null","disposed_somewhere":false,"disposed_in_finally":false}
12+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":40,"local":"x","local_type":"RLibA.R","member":"HW8_using_declaration","form":"declaration","declared_using":true,"declared_await_using":false,"awaited":"invocation","configure_await":false,"callable":"RLibA.FA.FactoryAsync/0","callable_assembly":"RLibA","first_party":false,"return_kind":"Task\u003CT\u003E","logical_result":"RLibA.R","logical_disposable":true,"trusted_row":true,"sync_twin_row":true,"nesting":[],"in_try":false,"initializer":"value","disposed_somewhere":false,"disposed_in_finally":false}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":10,"column":76,"end_line":10,"end_column":93,"callable":"RLibA.FA.FactoryAsync","arity":0,"effect":"return_fresh_owned","assembly":"RLibA","shape":"await"}
2+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":12,"column":76,"end_line":12,"end_column":93,"callable":"RLibA.FA.FactoryAsync","arity":0,"effect":"return_fresh_owned","assembly":"RLibA","shape":"await"}
3+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":14,"column":70,"end_line":14,"end_column":96,"callable":"RLibA.FA.FactoryValueTaskAsync","arity":0,"effect":"return_fresh_owned","assembly":"RLibA","shape":"await"}
4+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":16,"column":64,"end_line":16,"end_column":81,"callable":"RLibA.FA.FactoryAsync","arity":0,"effect":"return_fresh_owned","assembly":"RLibA","shape":"await"}
5+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":18,"column":80,"end_line":18,"end_column":97,"callable":"RLibA.FA.FactoryAsync","arity":0,"effect":"return_fresh_owned","assembly":"RLibA","shape":"await"}
6+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":20,"column":78,"end_line":20,"end_column":95,"callable":"RLibA.FA.FactoryAsync","arity":0,"effect":"return_fresh_owned","assembly":"RLibA","shape":"await"}
7+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":25,"column":64,"end_line":25,"end_column":81,"callable":"RLibA.FA.FactoryAsync","arity":0,"effect":"return_fresh_owned","assembly":"RLibA","shape":"declaration"}
8+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":25,"column":64,"end_line":25,"end_column":81,"callable":"RLibA.FA.FactoryAsync","arity":0,"effect":"return_fresh_owned","assembly":"RLibA","shape":"declaration"}
9+
{"file":"/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad/lab/h25/fx/Await.cs","line":40,"column":76,"end_line":40,"end_column":93,"callable":"RLibA.FA.FactoryAsync","arity":0,"effect":"return_fresh_owned","assembly":"RLibA","shape":"await"}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"""H-25 await-wrapped acquire census (derived from the H-24 runner; harness invariant 0: the corrected environment is the default) over the kept H-23A scan clones (e3h23/<tag>): the SAME project/TFM units, reference
2+
directories and trusted row files the OFF/ON scans used; runs the extractor once per unit with OWEN_RE_ORACLE=<unit
3+
rows> and OWEN_H24_CENSUS=<unit>/h24.jsonl (census only, no engines), then aggregates one record per disposable local
4+
with nested writes. usage: h24census.py <repo> [<repo> ...]"""
5+
import json, os, sys, subprocess, glob, re, hashlib, time, collections
6+
S='/tmp/claude-0/-home-user/8a9da608-aa27-5449-8306-1fae9426f9b9/scratchpad'; R='/home/user/Own.NET'; E=f'{S}/lab/sc/e3h23'; E2=f'{S}/lab/sc/e2h23'
7+
FIX=os.environ.get('H25_FIX_ENV','1')=='1' # corrected compilation environment: SDK implicit global usings + the ASP.NET Core ref pack (erratum 2)
8+
XD={'net8':f'{S}/ext8a/ownsharp-extract.dll','net10':f'{S}/ext10a/ownsharp-extract.dll'}
9+
OUT=f'{S}/lab/h25/census' if FIX else f'{S}/lab/h25/census-asis'; os.makedirs(OUT,exist_ok=True)
10+
sys.path.insert(0,f'{S}/lab/h24'); from implicit_usings import implicit_usings
11+
def aspnet_ref(major):
12+
c=sorted(glob.glob(f'/root/.dotnet/packs/Microsoft.AspNetCore.App.Ref/{major}.*/ref/net{major}.0'))
13+
return c[-1] if c else None
14+
env={**os.environ,'PATH':'/root/.dotnet:'+os.environ['PATH'],'DOTNET_NOLOGO':'1','DOTNET_CLI_TELEMETRY_OPTOUT':'1','DOTNET_SKIP_FIRST_TIME_EXPERIENCE':'1'}
15+
for k in ('OWEN_RE_ORACLE','OWEN_H23A','OWEN_RE_BODY','OWEN_RE_MINTED_RETURN','OWEN_RE_MIXED_RETURN','OWEN_LAB_THROWEXIT','OWEN_LAB_NULLINIT','OWEN_LAB_NULLGUARD','OWEN_P037X_GUARDED','OWEN_P037X_RELATIONAL','OWEN_RE_ORACLE_HITLOG','OWEN_H24_CENSUS','OWEN_H25_CENSUS'): env.pop(k,None)
16+
EXCL=re.compile(r'(^|/)(tests?|testing|samples?|benchmarks?|examples?|docs?|demo)(/|\.|$)',re.I)
17+
TESTP=re.compile(r'(test|tests|testing|benchmark|bench|sample|samples|example|examples|demo|playground)',re.I)
18+
def assets_of(p,W):
19+
c=os.path.join(os.path.dirname(p),'obj','project.assets.json')
20+
if os.path.exists(c): return c
21+
pn=os.path.splitext(os.path.basename(p))[0]
22+
for c in glob.glob(f'{W}/**/artifacts/obj/{pn}/project.assets.json',recursive=True): return c
23+
return None
24+
for repo in sys.argv[1:]:
25+
tag=repo.replace('/','__'); W=f'{E}/{tag}'; t0=time.time()
26+
e2=json.load(open(f'{E2}/{tag}.e2.json'))
27+
projs=sorted(p for p in glob.glob(f'{W}/**/*.csproj',recursive=True)); prod=[p for p in projs if not EXCL.search(os.path.relpath(p,W))]
28+
units=0; recs=[]; fails=0
29+
for p in prod:
30+
rel=os.path.relpath(p,W); assets=assets_of(p,W)
31+
if not assets or rel not in e2['per_project'] or 'targets' not in e2['per_project'][rel]: continue
32+
a=json.load(open(assets))
33+
for tfm in a['targets']:
34+
tfm0=tfm.split('/')[0]
35+
if tfm0 not in e2['per_project'][rel]['targets']: continue
36+
refdir=f'{W}/.refs/{hashlib.sha256((rel+tfm).encode()).hexdigest()[:10]}'; keyf=f'{refdir}/rows.json'
37+
if not os.path.exists(keyf): continue
38+
srcs=sorted(x for x in glob.glob(os.path.join(os.path.dirname(p),'**','*.cs'),recursive=True) if '/obj/' not in x and '/bin/' not in x)
39+
if not srcs: continue
40+
m=re.match(r'net(\d+)\.',tfm0); major=int(m.group(1)) if m else 0; xd=XD['net10'] if major>=9 else XD['net8']
41+
sfx='h25' if FIX else 'h25asis'; out=f'{refdir}/{sfx}.jsonl'; open(out,'w').close(); hits=f'{refdir}/{sfx}hits.jsonl'; open(hits,'w').close()
42+
e={**env,'OWEN_RE_ORACLE':keyf,'OWEN_H25_CENSUS':out,'OWEN_RE_ORACLE_HITLOG':hits}; extra=[]
43+
if FIX:
44+
ns=implicit_usings(p) or []
45+
if ns:
46+
gu=f'{refdir}/GlobalUsings.g.cs'; open(gu,'w').write(''.join(f'global using {n};\n' for n in ns)); extra.append(gu)
47+
ar=aspnet_ref(major if major else 8)
48+
if ar: e['OWN_EXTRA_REF_DIRS']=ar
49+
try: pr=subprocess.run(['dotnet',xd,'--flow-locals',*srcs,*extra,'--ref-dir',refdir,'-o',f'{refdir}/{sfx}.facts.json'],cwd=R,capture_output=True,text=True,env=e,timeout=1500); rc=pr.returncode
50+
except subprocess.TimeoutExpired: rc='timeout'
51+
if rc!=0: fails+=1
52+
units+=1
53+
for l in open(out):
54+
if not l.strip(): continue
55+
j=json.loads(l); j['project']=rel; j['tfm']=tfm0; j['kind']='test' if TESTP.search(os.path.basename(rel)) or TESTP.search(os.path.relpath(j['file'],W) if j['file'].startswith(W) else j['file']) else 'production'
56+
j['file']=os.path.relpath(j['file'],W) if j['file'].startswith(W) else j['file']; recs.append(j)
57+
json.dump({'repo':repo,'sha':e2['sha'],'units':units,'extractor_failures':fails,'seconds':round(time.time()-t0),'environment':'corrected (implicit usings + aspnet ref pack)' if FIX else 'as-is','records':recs},open(f'{OUT}/{tag}.h25.json','w'),indent=1)
58+
c=collections.Counter((r['kind'],r['awaited'],bool(r['trusted_row'])) for r in recs)
59+
print('H25_DONE',repo,'units',units,'fails',fails,'await writes',len(recs),'by kind/awaited/trusted',dict(c),'production trusted',sum(1 for r in recs if r['kind']=='production' and r['trusted_row']),flush=True)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""SDK implicit global usings for a project (what the build would generate into obj/<Project>.GlobalUsings.g.cs):
2+
Microsoft.NET.Sdk: System, System.Collections.Generic, System.IO, System.Linq, System.Net.Http, System.Threading,
3+
System.Threading.Tasks; Microsoft.NET.Sdk.Web adds the ASP.NET Core / Microsoft.Extensions namespaces;
4+
Microsoft.NET.Sdk.Worker adds Microsoft.Extensions.*; plus <Using Include="..."/> and minus <Using Remove="..."/> items
5+
from the project file and every Directory.Build.props above it; nothing when ImplicitUsings is not enabled."""
6+
import os, re, xml.etree.ElementTree as ET
7+
BASE=['System','System.Collections.Generic','System.IO','System.Linq','System.Net.Http','System.Threading','System.Threading.Tasks']
8+
WEB=['Microsoft.AspNetCore.Builder','Microsoft.AspNetCore.Hosting','Microsoft.AspNetCore.Http','Microsoft.AspNetCore.Routing','Microsoft.Extensions.Configuration','Microsoft.Extensions.DependencyInjection','Microsoft.Extensions.Hosting','Microsoft.Extensions.Logging']
9+
WORKER=['Microsoft.Extensions.Configuration','Microsoft.Extensions.DependencyInjection','Microsoft.Extensions.Hosting','Microsoft.Extensions.Logging']
10+
def props_chain(csproj):
11+
out=[]; d=os.path.dirname(os.path.abspath(csproj))
12+
while True:
13+
p=os.path.join(d,'Directory.Build.props')
14+
if os.path.exists(p): out.append(p)
15+
if d==os.path.dirname(d): break
16+
d=os.path.dirname(d)
17+
return out[::-1] # outermost first
18+
def implicit_usings(csproj):
19+
try: root=ET.parse(csproj).getroot()
20+
except Exception: return None
21+
sdk=(root.attrib.get('Sdk') or '')
22+
enabled=None; add=[]; rem=[]
23+
for f in props_chain(csproj)+[csproj]:
24+
try: r=ET.parse(f).getroot()
25+
except Exception: continue
26+
for e in r.iter():
27+
tag=e.tag.split('}')[-1]
28+
if tag=='ImplicitUsings' and (e.text or '').strip().lower() in ('enable','true'): enabled=True
29+
if tag=='ImplicitUsings' and (e.text or '').strip().lower() in ('disable','false'): enabled=False
30+
if tag=='Using' and e.attrib.get('Include'): add.append(e.attrib['Include'].strip())
31+
if tag=='Using' and e.attrib.get('Remove'): rem.append(e.attrib['Remove'].strip())
32+
if not enabled: return []
33+
ns=list(BASE)
34+
if sdk.startswith('Microsoft.NET.Sdk.Web'): ns+=WEB
35+
elif sdk.startswith('Microsoft.NET.Sdk.Worker'): ns+=WORKER
36+
ns+= [a for a in add if not a.startswith('static ') and '=' not in a]
37+
return [n for n in dict.fromkeys(ns) if n not in rem]
38+
if __name__=='__main__':
39+
import sys
40+
for p in sys.argv[1:]: print(p, implicit_usings(p))

0 commit comments

Comments
 (0)