Skip to content

Commit 602d4a8

Browse files
PhysShellclaude
andcommitted
docs(evidence): N3 pilot G1/G2 runs; PoC v2 brings D3b in line with §3
PoC v1 counted a call to a void same-class method as D3b and took an await inside a nested lambda as the callee's first await (3 extra warnings on DotNetCloud#43). v2 requires a Task-returning callee and the callee's own first await, as §3 states; it also records the capture line. Control C15 added for this case (controls may be added). G1: mars-vista-api#26 (S1xD3b), DotNetCloud#43 (S3xD1, capture line removed by the fix), DFY-BE#35 (S3xD3a) report on base and are silent on the code each fix touches. Reported-only: Vendorea#49 caught (S4xD1); microting#1669 (transient holder) and escalated#162 (DbContext registered by the consumer app) silent by rule. G2: C1-C15 silent. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TFkNAFFQz9KoTzpPws8vYG
1 parent 66d1480 commit 602d4a8

8 files changed

Lines changed: 127 additions & 10 deletions

File tree

‎docs/evidence/n3-pilot-2026-10/controls/N3NegativeControls.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,16 @@ public void C11_HttpClientFactory()
151151

152152
public void C14_AccessorInsideWork() { _ = Task.Run(() => Log(0, _accessor.HttpContext?.TraceIdentifier)); }
153153

154+
// C15 (added after the first pair run, PoC v1 bug): a void same-class call is not D3b, and an await
155+
// inside a nested lambda is not the callee's own first await.
156+
public void C15_VoidSameClassNestedAwait() { KickOff(); }
157+
158+
private void KickOff()
159+
{
160+
Func<Task> f = async () => { await Task.Delay(1); _db.Orders.Count(); };
161+
f().Wait();
162+
}
163+
154164
// ---- positive samples: must be reported ----
155165

156166
// S1 HttpContext
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
file line class method S D object holder capture_line snippet test_project path_regex
2+
N3NegativeControls.cs 167 ControlsController P_S1_D1_HttpContextInTaskRun S1 D1 HttpContext R1 167 Task.Run(() => Log(0, HttpContext.TraceIdentifier)) - -
3+
N3NegativeControls.cs 171 ControlsController P_S1_D2_HttpContextInQueue S1 D2 HttpContext R1 171 _queue.QueueBackgroundWorkItem(async ct => { await Task.Delay(1, ct); Log(0, HttpContext.TraceIdentifier); }) - -
4+
N3NegativeControls.cs 174 ControlsController P_S1_D3a_HttpContextReceiver S1 D3a HttpContext R1 174 HttpContext.Response.WriteAsync("late") - -
5+
N3NegativeControls.cs 176 ControlsController P_S1_D3b_HttpContextSameClass S1 D3b ctx R1 181 LogLaterAsync(HttpContext) - -
6+
N3NegativeControls.cs 185 ControlsController P_S2_D1_DbInTaskRun S2 D1 _db R1 185 Task.Run(() => _db.Orders.Count()) - -
7+
N3NegativeControls.cs 187 ControlsController P_S2_D2_DbInQueue S2 D2 _db R1 187 _queue.QueueBackgroundWorkItem(async ct => await _db.SaveChangesAsync(ct)) - -
8+
N3NegativeControls.cs 189 ControlsController P_S2_D3a_DbReceiver S2 D3a _db R1 189 _db.SaveChangesAsync() - -
9+
N3NegativeControls.cs 191 ControlsController P_S2_D3b_DbSameClass S2 D3b _db R1 196 SaveAfterAwaitAsync() - -
10+
N3NegativeControls.cs 200 ControlsController P_S3_D1_ScopedInTaskRun S3 D1 _orders R1 200 Task.Run(() => _orders.NotifyAsync(1)) - -
11+
N3NegativeControls.cs 202 ControlsController P_S3_D2_ScopedInQueue S3 D2 _orders R1 202 _queue.QueueBackgroundWorkItem(ct => _orders.NotifyAsync(2)) - -
12+
N3NegativeControls.cs 204 ControlsController P_S3_D3a_ScopedReceiver S3 D3a _orders R1 204 _orders.NotifyAsync(3) - -
13+
N3NegativeControls.cs 206 ControlsController P_S3_D3b_ScopedSameClass S3 D3b _orders R1 211 NotifyLaterAsync() - -
14+
N3NegativeControls.cs 215 ControlsController P_S4_D1_ScopeProviderInTaskRun S4 D1 _sp R1 215 Task.Run(() => _sp.GetRequiredService<IOrderService>()) - -
15+
N3NegativeControls.cs 219 ControlsController P_S4_D2_ScopeProviderInQueue S4 D2 _sp R1 219 _queue.QueueBackgroundWorkItem(ct => _sp.GetRequiredService<IOrderService>().NotifyAsync(5)) - -
16+
N3NegativeControls.cs 224 ControlsController P_S4_D3b_ScopeProviderSameClass S4 D3b _sp R1 229 ResolveLaterAsync() - -
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
james-langridge_mars-vista-api__26 james-langridge/mars-vista-api 8f6c0061e7cb0ec8adeba47cc7f5142a42ebcd01 a4e0467f25d64484c48177d1991bf3a3cd9e65b0 119acfa6e49da175abf935e4a1ea00c416ceba76 true 2026-07-11T22:35:41Z
2+
LLabmik_DotNetCloud__43 LLabmik/DotNetCloud 3157aa0fc179e97cffcfbce8007a13e826b71da1 c6167429dde92add341d079bad1edab8209f7ef5 e42397840d7f086bd36f0a1dd109524da7b6c4b5 true 2026-07-18T04:14:10Z
3+
DoForYou-ZA_DFY-BE__35 DoForYou-ZA/DFY-BE 64143d1365c205ebba99e277382925024a64c9d1 08fa5735309986e288f7086be9575a9b5f321c80 d7e2e7a82330fa1a27bb7cf573751f604ca57852 true 2026-10-09T05:05:50Z
4+
ASADRAJA_Vendorea.PartnerConnect__49 ASADRAJA/Vendorea.PartnerConnect 0247153bdbcdacb18fc1014e9aa239ad1fcdfda1 5ce2bd36dc284ba620eb3dd437b0a387f97c1949 468d8f9517a135e5f021d005eafd4bf714058303 true 2026-07-04T17:34:51Z
5+
microting_eform-angular-timeplanning-plugin__1669 microting/eform-angular-timeplanning-plugin 5df52a98ae2bd907a2a96d9fb18165bdec929124 33be1a7c842a79d0dfb0ff11fc15f2e14846b64e 4b3a169fc5d6e4d37ec77b83c1972de686b260a7 true 2026-08-02T07:01:58Z
6+
escalated-dev_escalated-dotnet__162 escalated-dev/escalated-dotnet 8c50a00a92758e5c0060370b4f37235d4d962d73 bcda1895a01c3325a3000a74818ce71acabc42e5 faad721122e3c84f369aca56e9924b5e0dfc0c6d true 2026-09-13T22:19:53Z
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ASADRAJA_Vendorea.PartnerConnect__49 src/Vendorea.PartnerConnect.API/Controllers/Admin/AdminFtpIngestionController.cs:272 capture 276 call=untouched capture=TOUCHED S4xD1 using var scope = _serviceProvider.CreateScope();
2+
DoForYou-ZA_DFY-BE__35 Controllers/AuthController.cs:70 capture 70 call=TOUCHED capture=TOUCHED S3xD3a _ = _notificationService.NotifyAdminsAsync(
3+
LLabmik_DotNetCloud__43 src/Modules/Video/DotNetCloud.Modules.Video.Data/Services/VideoIndexingCallback.cs:366 capture 371 call=untouched capture=TOUCHED S3xD1 await _seriesService.EnrichSeriesAsync(seriesId);
4+
LLabmik_DotNetCloud__43 src/Modules/Video/DotNetCloud.Modules.Video.Host/Controllers/VideoController.cs:838 capture 838 call=untouched capture=untouched S3xD3a _ = _videoService.UpdateDurationAsync(videoId, probeDuration, HttpCont
5+
LLabmik_DotNetCloud__43 src/Modules/Video/DotNetCloud.Modules.Video.Host/Controllers/VideoController.cs:1462 capture 1469 call=untouched capture=untouched S3xD1 var job = _transcodingService.GetProgress(jobId);
6+
fix-warning LLabmik_DotNetCloud__43 src/Modules/Video/DotNetCloud.Modules.Video.Host/Controllers/VideoController.cs:838 S3xD3a
7+
fix-warning LLabmik_DotNetCloud__43 src/Modules/Video/DotNetCloud.Modules.Video.Host/Controllers/VideoController.cs:1462 S3xD1
8+
james-langridge_mars-vista-api__26 src/MarsVista.Api/Middleware/UsageTrackingMiddleware.cs:63 capture 175 call=TOUCHED capture=TOUCHED S1xD3b _logger.LogError(ex, "Failed to track usage event for {Path}", context
9+
james-langridge_mars-vista-api__26 src/MarsVista.Api/Middleware/UserApiKeyAuthenticationMiddleware.cs:153 capture 157 call=untouched capture=untouched S1xD1 using var scope = context.RequestServices.CreateScope();
10+
fix-warning james-langridge_mars-vista-api__26 src/MarsVista.Api/Middleware/UserApiKeyAuthenticationMiddleware.cs:153 S1xD1
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ASADRAJA_Vendorea.PartnerConnect__49 base src/Vendorea.PartnerConnect.API/Controllers/Admin/AdminFtpIngestionController.cs 272 AdminFtpIngestionController RunIngestion S4 D1 _serviceProvider R1 Task.Run(async () => { try { using var scope = _serviceProvider.CreateScope(); var bgRunRepository = scope.ServiceProvider.GetRequiredService<IFtpIngestionRunRe… - -
2+
DoForYou-ZA_DFY-BE__35 base Controllers/AuthController.cs 70 AuthController Register S3 D3a _notificationService R1 _notificationService.NotifyAdminsAsync( "new_user", "New User Registered", $"{user.FirstName} {user.LastName} ({user.Email}) joined as {user.UserType ?? "user"}… - -
3+
LLabmik_DotNetCloud__43 base src/Modules/Video/DotNetCloud.Modules.Video.Data/Services/VideoIndexingCallback.cs 263 VideoIndexingCallback AutoDetectSeriesAsync S3 D3b _seriesService R3 EnrichSeriesInBackground(Guid.Parse(series.Id.ToString()), caller.UserId) - -
4+
LLabmik_DotNetCloud__43 base src/Modules/Video/DotNetCloud.Modules.Video.Data/Services/VideoIndexingCallback.cs 318 VideoIndexingCallback AutoDetectSeriesAsync S3 D3b _seriesService R3 EnrichSeriesInBackground(Guid.Parse(series.Id.ToString()), caller.UserId) - -
5+
LLabmik_DotNetCloud__43 base src/Modules/Video/DotNetCloud.Modules.Video.Data/Services/VideoIndexingCallback.cs 348 VideoIndexingCallback AutoDetectSeriesAsync S3 D3b _seriesService R3 EnrichSeriesInBackground(Guid.Parse(seriesDto.Id.ToString()), caller.UserId) - -
6+
LLabmik_DotNetCloud__43 base src/Modules/Video/DotNetCloud.Modules.Video.Data/Services/VideoIndexingCallback.cs 366 VideoIndexingCallback EnrichSeriesInBackground S3 D1 _seriesService R3 Task.Run(async () => { await _seriesEnrichmentThrottle.WaitAsync(); try { await _seriesService.EnrichSeriesAsync(seriesId); } catch (Exception ex) { _logger.Log… - -
7+
LLabmik_DotNetCloud__43 base src/Modules/Video/DotNetCloud.Modules.Video.Host/Controllers/VideoController.cs 838 VideoController StreamVideo S3 D3a _videoService R1 _videoService.UpdateDurationAsync(videoId, probeDuration, HttpContext.RequestAborted) - -
8+
LLabmik_DotNetCloud__43 base src/Modules/Video/DotNetCloud.Modules.Video.Host/Controllers/VideoController.cs 1462 VideoController WaitForHlsReadyAsync S3 D1 _transcodingService R1 Task.Run(async () => { try { while (!linkedCts.IsCancellationRequested) { await Task.Delay(500, linkedCts.Token); var job = _transcodingService.GetProgress(jobI… - -
9+
LLabmik_DotNetCloud__43 fix src/Modules/Video/DotNetCloud.Modules.Video.Host/Controllers/VideoController.cs 838 VideoController StreamVideo S3 D3a _videoService R1 _videoService.UpdateDurationAsync(videoId, probeDuration, HttpContext.RequestAborted) - -
10+
LLabmik_DotNetCloud__43 fix src/Modules/Video/DotNetCloud.Modules.Video.Host/Controllers/VideoController.cs 1462 VideoController WaitForHlsReadyAsync S3 D1 _transcodingService R1 Task.Run(async () => { try { while (!linkedCts.IsCancellationRequested) { await Task.Delay(500, linkedCts.Token); var job = _transcodingService.GetProgress(jobI… - -
11+
james-langridge_mars-vista-api__26 base src/MarsVista.Api/Middleware/UsageTrackingMiddleware.cs 63 UsageTrackingMiddleware InvokeAsync S1 D3b context R2 TrackUsageAsync(context, stopwatch.ElapsedMilliseconds, errorDetail) - -
12+
james-langridge_mars-vista-api__26 base src/MarsVista.Api/Middleware/UserApiKeyAuthenticationMiddleware.cs 153 UserApiKeyAuthenticationMiddleware InvokeAsync S1 D1 context R2 Task.Run(async () => { try { using var scope = context.RequestServices.CreateScope(); var db = scope.ServiceProvider.GetRequiredService<MarsVistaDbContext>(); v… - -
13+
james-langridge_mars-vista-api__26 fix src/MarsVista.Api/Middleware/UserApiKeyAuthenticationMiddleware.cs 153 UserApiKeyAuthenticationMiddleware InvokeAsync S1 D1 context R2 Task.Run(async () => { try { using var scope = context.RequestServices.CreateScope(); var db = scope.ServiceProvider.GetRequiredService<MarsVistaDbContext>(); v… - -
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ASADRAJA_Vendorea.PartnerConnect__49 base src/Vendorea.PartnerConnect.API/Controllers/Admin/AdminFtpIngestionController.cs 272 AdminFtpIngestionController RunIngestion S4 D1 _serviceProvider R1 276 Task.Run(async () => { try { using var scope = _serviceProvider.CreateScope(); var bgRunRepository = scope.ServiceProvider.GetRequiredService<IFtpIngestionRunRe… - -
2+
DoForYou-ZA_DFY-BE__35 base Controllers/AuthController.cs 70 AuthController Register S3 D3a _notificationService R1 70 _notificationService.NotifyAdminsAsync( "new_user", "New User Registered", $"{user.FirstName} {user.LastName} ({user.Email}) joined as {user.UserType ?? "user"}… - -
3+
LLabmik_DotNetCloud__43 base src/Modules/Video/DotNetCloud.Modules.Video.Data/Services/VideoIndexingCallback.cs 366 VideoIndexingCallback EnrichSeriesInBackground S3 D1 _seriesService R3 371 Task.Run(async () => { await _seriesEnrichmentThrottle.WaitAsync(); try { await _seriesService.EnrichSeriesAsync(seriesId); } catch (Exception ex) { _logger.Log… - -
4+
LLabmik_DotNetCloud__43 base src/Modules/Video/DotNetCloud.Modules.Video.Host/Controllers/VideoController.cs 838 VideoController StreamVideo S3 D3a _videoService R1 838 _videoService.UpdateDurationAsync(videoId, probeDuration, HttpContext.RequestAborted) - -
5+
LLabmik_DotNetCloud__43 base src/Modules/Video/DotNetCloud.Modules.Video.Host/Controllers/VideoController.cs 1462 VideoController WaitForHlsReadyAsync S3 D1 _transcodingService R1 1469 Task.Run(async () => { try { while (!linkedCts.IsCancellationRequested) { await Task.Delay(500, linkedCts.Token); var job = _transcodingService.GetProgress(jobI… - -
6+
LLabmik_DotNetCloud__43 fix src/Modules/Video/DotNetCloud.Modules.Video.Host/Controllers/VideoController.cs 838 VideoController StreamVideo S3 D3a _videoService R1 838 _videoService.UpdateDurationAsync(videoId, probeDuration, HttpContext.RequestAborted) - -
7+
LLabmik_DotNetCloud__43 fix src/Modules/Video/DotNetCloud.Modules.Video.Host/Controllers/VideoController.cs 1462 VideoController WaitForHlsReadyAsync S3 D1 _transcodingService R1 1469 Task.Run(async () => { try { while (!linkedCts.IsCancellationRequested) { await Task.Delay(500, linkedCts.Token); var job = _transcodingService.GetProgress(jobI… - -
8+
james-langridge_mars-vista-api__26 base src/MarsVista.Api/Middleware/UsageTrackingMiddleware.cs 63 UsageTrackingMiddleware InvokeAsync S1 D3b context R2 175 TrackUsageAsync(context, stopwatch.ElapsedMilliseconds, errorDetail) - -
9+
james-langridge_mars-vista-api__26 base src/MarsVista.Api/Middleware/UserApiKeyAuthenticationMiddleware.cs 153 UserApiKeyAuthenticationMiddleware InvokeAsync S1 D1 context R2 157 Task.Run(async () => { try { using var scope = context.RequestServices.CreateScope(); var db = scope.ServiceProvider.GetRequiredService<MarsVistaDbContext>(); v… - -
10+
james-langridge_mars-vista-api__26 fix src/MarsVista.Api/Middleware/UserApiKeyAuthenticationMiddleware.cs 153 UserApiKeyAuthenticationMiddleware InvokeAsync S1 D1 context R2 157 Task.Run(async () => { try { using var scope = context.RequestServices.CreateScope(); var db = scope.ServiceProvider.GetRequiredService<MarsVistaDbContext>(); v… - -

‎docs/evidence/n3-pilot-2026-10/poc/Program.cs‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@
5858
foreach (var t in trees) scan.Run(t);
5959

6060
using var w = outPath is null ? Console.Out : new StreamWriter(outPath, false, new System.Text.UTF8Encoding(false));
61-
w.WriteLine("file\tline\tclass\tmethod\tS\tD\tobject\tholder\tsnippet");
61+
w.WriteLine("file\tline\tclass\tmethod\tS\tD\tobject\tholder\tcapture_line\tsnippet");
6262
foreach (var r in scan.Warnings.OrderBy(r => r.File, StringComparer.Ordinal).ThenBy(r => r.Line).ThenBy(r => r.Object))
63-
w.WriteLine(string.Join('\t', r.File, r.Line, r.Class, r.Method, r.S, r.D, r.Object, r.Holder, r.Snippet));
63+
w.WriteLine(string.Join('\t', r.File, r.Line, r.Class, r.Method, r.S, r.D, r.Object, r.Holder, r.CaptureLine, r.Snippet));
6464
Console.Error.WriteLine($"n3poc: {files.Count} files, {scan.Warnings.Count} warnings, " +
6565
$"{scan.RequestBoundTypes} request-bound types, {scan.DetachedSites} detached sites, " +
6666
$"{scan.UnknownSites} detached sites using only unknown-ownership fields");
6767
return 0;
6868

6969
sealed record Warning(string File, int Line, string Class, string Method, string S, string D, string Object,
70-
string Holder, string Snippet);
70+
string Holder, int CaptureLine, string Snippet);
7171

7272
sealed class Lifetimes
7373
{
@@ -341,7 +341,7 @@ void ScanBody(Ctx c, SyntaxNode body, string method, Dictionary<ISymbol, (string
341341
{
342342
// D3b: one hop into a same-class method; uses after its first await
343343
DetachedSites++;
344-
if (UseAfterFirstAwait(c, inv, callee, locals) is { } u) Add(c, inv, method, u.S, "D3b", u.Name);
344+
if (UseAfterFirstAwait(c, inv, callee, locals) is { } u) Add(c, inv, method, u.S, "D3b", u.Name, u.Line);
345345
}
346346
}
347347
}
@@ -447,16 +447,20 @@ static bool IsCompleted(string e) => e is "Task.CompletedTask" or "default" or "
447447
var sym = c.Sm.GetSymbolInfo(target).Symbol as IMethodSymbol
448448
?? c.Sm.GetSymbolInfo(target).CandidateSymbols.OfType<IMethodSymbol>().FirstOrDefault();
449449
if (sym is null || c.Type is null || !SymbolEqualityComparer.Default.Equals(sym.ContainingType, c.Type)) return null;
450+
// §3 D3b is a discarded *Task* call (`_ = MAsync(…)`): a void callee is not detached work by itself
451+
if (sym.ReturnType.Name is not ("Task" or "ValueTask")) return null;
450452
return sym.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).OfType<MethodDeclarationSyntax>()
451453
.FirstOrDefault(md => md.Body is not null || md.ExpressionBody is not null);
452454
}
453455

454-
(string S, string Name)? UseAfterFirstAwait(Ctx c, InvocationExpressionSyntax call, MethodDeclarationSyntax callee,
456+
(string S, string Name, int Line)? UseAfterFirstAwait(Ctx c, InvocationExpressionSyntax call, MethodDeclarationSyntax callee,
455457
Dictionary<ISymbol, (string S, string Type)> callerLocals)
456458
{
457459
var body = (SyntaxNode?)callee.Body ?? callee.ExpressionBody;
458460
if (body is null) return null;
459-
var firstAwait = body.DescendantNodes().OfType<AwaitExpressionSyntax>().FirstOrDefault();
461+
// the callee's own first await: one inside a nested lambda or local function does not suspend the callee
462+
var firstAwait = body.DescendantNodes(n => n == body || n is not (AnonymousFunctionExpressionSyntax or LocalFunctionStatementSyntax))
463+
.OfType<AwaitExpressionSyntax>().FirstOrDefault();
460464
if (firstAwait is null) return null;
461465
// parameters bound to scope-owned arguments at this call site
462466
var calleeSm = comp.GetSemanticModel(callee.SyntaxTree);
@@ -471,7 +475,7 @@ static bool IsCompleted(string e) => e is "Task.CompletedTask" or "default" or "
471475
{
472476
if (id.SpanStart <= firstAwait.Span.End) continue;
473477
if (id.Parent is MemberAccessExpressionSyntax ma && ma.Name == id && ma.Expression is not ThisExpressionSyntax) continue;
474-
if (OwnedName(cc, id, paramOwn, null) is { } u) return u;
478+
if (OwnedName(cc, id, paramOwn, null) is { } u) return (u.S, u.Name, Syn.Line(id));
475479
}
476480
return null;
477481
}
@@ -486,15 +490,17 @@ void ReportUses(Ctx c, ExpressionSyntax lam, string method, string d, Dictionary
486490
if (id.Parent is MemberBindingExpressionSyntax) continue;
487491
if (OwnedName(c, id, locals, lam) is not { } o) continue;
488492
any = true;
489-
Add(c, lam.Parent?.Parent?.Parent ?? lam, method, o.S, d, o.Name);
493+
Add(c, lam.Parent?.Parent?.Parent ?? lam, method, o.S, d, o.Name, Syn.Line(id));
490494
}
491495
if (!any) UnknownSites++;
492496
}
493497

494-
void Add(Ctx c, SyntaxNode site, string method, string s, string d, string obj)
498+
// `captureLine`: where the scope-owned object is used (D1/D2/D3b) or the call itself (D3a)
499+
void Add(Ctx c, SyntaxNode site, string method, string s, string d, string obj, int captureLine = 0)
495500
{
496501
var line = Syn.Line(site);
497502
if (!_seen.Add((c.Tree.FilePath, line, obj))) return;
498-
Warnings.Add(new Warning(c.Tree.FilePath, line, c.Type?.Name ?? "?", method, s, d, obj, c.Holder, Syn.Snip(site)));
503+
Warnings.Add(new Warning(c.Tree.FilePath, line, c.Type?.Name ?? "?", method, s, d, obj, c.Holder,
504+
captureLine == 0 ? line : captureLine, Syn.Snip(site)));
499505
}
500506
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"""N3 pilot G1: is a buggy-tree warning's call or capture line changed or removed by the fix?
2+
3+
usage: python -I g1_touched.py <root with src/<slug>/{base,fix} and <run>/<slug>/{base,fix}> [run]
4+
"""
5+
6+
import difflib
7+
import os
8+
import sys
9+
10+
11+
def rows(root: str, run: str, slug: str, side: str) -> list[list[str]]:
12+
p = os.path.join(root, run, slug, side, "warnings.tsv")
13+
return [r.split("\t") for r in open(p, encoding="utf-8").read().splitlines()[1:]]
14+
15+
16+
def lines(path: str) -> list[str]:
17+
if not os.path.exists(path):
18+
return []
19+
return open(path, encoding="utf-8", errors="replace").read().splitlines()
20+
21+
22+
def main() -> int:
23+
root = sys.argv[1]
24+
run = sys.argv[2] if len(sys.argv) > 2 else "run"
25+
for slug in sorted(os.listdir(os.path.join(root, run))):
26+
for c in rows(root, run, slug, "base"):
27+
f, line, cap = c[0], int(c[1]), int(c[8])
28+
a = lines(os.path.join(root, "src", slug, "base", f))
29+
b = lines(os.path.join(root, "src", slug, "fix", f))
30+
touched: set[int] = set()
31+
ops = difflib.SequenceMatcher(None, a, b, autojunk=False).get_opcodes()
32+
for op, i1, i2, _j1, _j2 in ops:
33+
if op in ("replace", "delete"):
34+
touched.update(range(i1 + 1, i2 + 1))
35+
call = "TOUCHED" if line in touched else "untouched"
36+
capture = "TOUCHED" if cap in touched else "untouched"
37+
text = a[cap - 1].strip()[:70]
38+
site = f"{slug}\t{f}:{line}\tcapture {cap}"
39+
print(f"{site}\tcall={call}\tcapture={capture}\t{c[4]}x{c[5]}\t{text}")
40+
for c in rows(root, run, slug, "fix"):
41+
print(f" fix-warning\t{slug}\t{c[0]}:{c[1]}\t{c[4]}x{c[5]}")
42+
return 0
43+
44+
45+
if __name__ == "__main__":
46+
raise SystemExit(main())

0 commit comments

Comments
 (0)