Skip to content

Commit 894be1b

Browse files
committed
fix(tooling): reject exhausted parser budget from one clock sample
1 parent f213c3a commit 894be1b

5 files changed

Lines changed: 190 additions & 3 deletions

File tree

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
"schemaVersion": 1,
3+
"evidenceKind": "p2-formatter-deadline-race-repair-acceptance",
4+
"candidateSha": "0004e750d80900d2881d7ea680ce9a1b26228aec",
5+
"candidateTreeSha": "8c0e49054af4bff4da25c3a880ea19450744e68e",
6+
"compilerSourceInputCount": 707,
7+
"sourceHashes": [
8+
{
9+
"path": "src/RustSharp.Syntax/RustFormatter.cs",
10+
"sha256": "8B6606EFD87CFD381451B5EA6E9E462C804B87E58870BCB7CDB71F5B00201CD3",
11+
"snapshotMatched": true
12+
},
13+
{
14+
"path": "tests/RustSharp.Tests/P2FormatterTests.cs",
15+
"sha256": "CABAF78A72FE6650BDDFE47595234B0FFB3BE70004522E83C57402F0470B9B75",
16+
"snapshotMatched": true
17+
}
18+
],
19+
"reports": [
20+
{
21+
"path": "artifacts/p2-supervision/formatter-budget-root-v1/source-snapshot.json",
22+
"sha256": "9103C59E456FDD18ACDFF7D0E3F47D1B681552EFB7151DFC37BE70A5AEAF6F15"
23+
},
24+
{
25+
"path": "artifacts/p2-supervision/formatter-budget-root-v1/release-build.json",
26+
"sha256": "178E9CED881C05511BD949195980F004D6BB64AEF2F59D2E3A6887D1866C501D"
27+
},
28+
{
29+
"path": "artifacts/p2-supervision/formatter-budget-root-v1/tiny-harness.json",
30+
"sha256": "44B316256B6353076C3DC2D6158DF5BE998D3A4B56E43556AF44EC797EE2889D"
31+
},
32+
{
33+
"path": "artifacts/p2-supervision/formatter-budget-root-v1/formatter-harness.json",
34+
"sha256": "44F3C18AD55345D5B534A3E1111F9A2B5C31DD31F4E2BADC0635C197A6095A9C"
35+
},
36+
{
37+
"path": "artifacts/p2-supervision/formatter-budget-root-v1/linux-tiny-harness.json",
38+
"sha256": "967DBEB723FBF515815E60FE977C1753274C12E3E3EB7EA7B0297164F41EC4ED"
39+
},
40+
{
41+
"path": "artifacts/p2-supervision/formatter-budget-root-v1/linux-formatter-harness.json",
42+
"sha256": "D0FCCBE2D22D07FD0F504A5B02024E6458A7C492B678BE3C98B301DDEEAA6BAC"
43+
},
44+
{
45+
"path": "artifacts/p2-supervision/formatter-budget-root-v1/mir-or-diagnostic-harness.json",
46+
"sha256": "497E1228600F478543CD8E99BF8433A38FDC7731FFB3395BC66359A5CA4EA59B"
47+
},
48+
{
49+
"path": "artifacts/p2-supervision/formatter-budget-root-v1/windows-resource-review.json",
50+
"sha256": "FF44241AE8430F2D31F922F7168640DED8F64DA05C09BC5EF6EC9C6B0E65CBCC"
51+
},
52+
{
53+
"path": "artifacts/p2-supervision/formatter-budget-root-v1/linux-resource-review.json",
54+
"sha256": "006C704CCB13316A351032419253593414FB63DBC6567C217E78029C3D5EB639"
55+
}
56+
],
57+
"release": {
58+
"sdkVersion": "10.0.401",
59+
"warnings": 0,
60+
"errors": 0,
61+
"registeredDenominator": 1203
62+
},
63+
"windows": {
64+
"tinyBudgetCase": 1,
65+
"formatterCases": 59,
66+
"mirOrDiagnosticOnly": 1,
67+
"recordedIdentitiesAbsent": 70
68+
},
69+
"ubuntu": {
70+
"tinyBudgetCase": 1,
71+
"formatterCases": 59,
72+
"recordedIdentitiesAbsent": 62,
73+
"portableAssemblyBuiltOn": "windows",
74+
"nativeCiEvidence": false
75+
},
76+
"budget": {
77+
"subTickAssertions": 32,
78+
"fixedFormatterDenominator": 59,
79+
"fixedParentDenominator": 91,
80+
"limitsRelaxed": false,
81+
"invalidParserBudgetsRejected": true
82+
},
83+
"priorCi": {
84+
"sha": "4d3333472af9b9c37a43df620fa209a7f4f30bae",
85+
"runId": "37702329159",
86+
"linuxPassed": 1202,
87+
"linuxDenominator": 1203,
88+
"linuxFailure": "P2-08.02 format-budget",
89+
"windowsPassed": 1202,
90+
"windowsDenominator": 1203,
91+
"windowsFailure": "MIR v2 binding or-patterns select consistent locals",
92+
"windowsFailureFixed": false,
93+
"review": "artifacts/p1-supervision/ci-followup-v15/"
94+
},
95+
"descendantContainmentVerified": false,
96+
"windowsDirectedCancellationPassed": false,
97+
"actualAsyncIoInterruptionPassed": false,
98+
"p2LeafClosed": false,
99+
"fullP1Closure": false,
100+
"fullP2Closure": false
101+
}

‎docs/p2-formatter-budget-v1.md‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Formatter parser budget race repair
2+
3+
English | [简体中文](p2-formatter-budget-v1_zh.md)
4+
5+
## Delivery
6+
7+
✅ Complete for the deadline race repair. When a formatter budget expired between
8+
two clock samples, the first check could succeed and the second sample could
9+
produce a nonpositive parser timeout. CI run `37702329159` at `4d33334` exposed
10+
this in Linux `P2-08.02 format-budget`. Remaining now checks cancellation,
11+
calculates the budget from one elapsed sample and rejects that same value when
12+
it is nonpositive. The existing timeout handler returns RSTF0001 and preserves
13+
the original source. Parser option validation and all timing limits remain intact.
14+
15+
## Acceptance
16+
17+
Candidate `0004e750d80900d2881d7ea680ce9a1b26228aec`, tree
18+
`8c0e49054af4bff4da25c3a880ea19450744e68e`, binds 707 compiler inputs. Fresh
19+
SDK 10.0.401 Release passes with zero warnings/errors. Windows passes tiny1,
20+
formatter59 and a separate MIR or-pattern diagnostic1. Ubuntu passes tiny1 and
21+
formatter59 using the portable assembly built on Windows; this is local Ubuntu
22+
runtime verification, not native Linux CI build evidence. The existing budget
23+
case includes 32 bounded one-tick timeout assertions, without changing the
24+
formatter59 or parent91 denominators. Registration remains 1203.
25+
26+
The [acceptance archive](evidence/p2/formatter-budget-v1-archive.json) retains
27+
source/report hashes. Root checked 70 recorded Windows identities and 62 Ubuntu
28+
identities absent. These checks cover recorded launchers and workers; they do
29+
not establish trusted containment of every descendant.
30+
31+
## Remaining closure
32+
33+
🚧 In progress for P2-08.02: real Windows directed cancellation, actual async
34+
I/O interruption and complete same-pushed-SHA acceptance remain required. P2
35+
remains 8/101 ✅ Complete leaves; no P1 gate, parent or phase closes.
36+
37+
The old CI run failed both expanded jobs at 1202/1203 with zero unexecuted
38+
cases. Windows formatter59 passed; its separate MIR binding or-pattern test
39+
failed with a type-analysis work/nesting/time-limit diagnostic after 6.0166s.
40+
The fresh local diagnostic1 passes, but no Windows CI failure repair or cause
41+
is claimed. Preserve the failed reports and follow up on the new SHA.

‎docs/p2-formatter-budget-v1_zh.md‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Formatter parser 预算竞态修复
2+
3+
[English](p2-formatter-budget-v1.md) | 简体中文
4+
5+
## 交付
6+
7+
✅ 已完成时限竞态修复。formatter 预算在两次时钟采样之间耗尽时,首次检查可能通过,
8+
而第二次采样产生非正的 parser 超时。候选 `4d33334` 的 CI run `37702329159`
9+
在 Linux `P2-08.02 format-budget` 中暴露了这一问题。Remaining 现在先检查取消,
10+
从单次 elapsed 采样计算剩余预算,并在该值非正时拒绝。既有超时处理返回 RSTF0001
11+
并保留原始源码。parser 选项验证和全部时限均保持原有标准。
12+
13+
## 验收
14+
15+
候选 `0004e750d80900d2881d7ea680ce9a1b26228aec`、tree
16+
`8c0e49054af4bff4da25c3a880ea19450744e68e` 绑定 707 个编译器输入。新鲜
17+
SDK 10.0.401 Release 构建通过,零警告/错误。Windows 通过 tiny1、formatter59
18+
及独立的 MIR or-pattern 诊断1。Ubuntu 使用 Windows 构建的可移植程序集通过
19+
tiny1 和 formatter59;这是本地 Ubuntu 运行验证,不是原生 Linux CI 构建证据。
20+
既有预算案例包含 32 次有界的单 tick 超时断言,未改变 formatter59 或 parent91
21+
分母。注册数仍为 1203。
22+
23+
[验收归档](evidence/p2/formatter-budget-v1-archive.json) 保留源码/报告哈希。
24+
主监督者检查 70 个已记录的 Windows 身份和 62 个 Ubuntu 身份均已不存在。
25+
这些检查覆盖已记录的启动进程和 worker,不能证明全部后代均被可信隔离。
26+
27+
## 剩余闭环
28+
29+
P2-08.02 为 🚧 进行中:仍需真实 Windows 定向取消、实际异步 I/O 中断及完整的
30+
同一已推送 SHA 验收。P2 仍为 8/101 ✅ 已完成叶项;不关闭任何 P1 门禁、父项
31+
或阶段。
32+
33+
旧 CI 的两个 expanded job 均为 1202/1203,未执行案例为零。Windows formatter59
34+
通过;其独立 MIR binding or-pattern 测试运行 6.0166 秒后以类型分析工作量/嵌套/
35+
时限诊断失败。新鲜本地诊断1通过,但不据此宣称 Windows CI 故障已修复或原因已确定。
36+
保留失败报告,继续跟踪新 SHA。

‎src/RustSharp.Syntax/RustFormatter.cs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ void Guard()
2525
}
2626
TimeSpan Remaining()
2727
{
28-
Guard();
29-
return options.Timeout - clock.Elapsed;
28+
cancellationToken.ThrowIfCancellationRequested();
29+
// Validate the same elapsed sample used to construct the parser budget.
30+
TimeSpan remaining = options.Timeout - clock.Elapsed;
31+
if (remaining <= TimeSpan.Zero)
32+
throw new TimeoutException("Formatting exceeded its shared wall-clock budget.");
33+
return remaining;
3034
}
3135
try
3236
{

‎tests/RustSharp.Tests/P2FormatterTests.cs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,12 @@ private static Task BudgetAsync()
210210
int outputBytes = Encoding.UTF8.GetByteCount(Accepted(unicodeSource).FormattedSource);
211211
AssertEx.True(RustFormatter.Format(unicodeSource, "budget.rs", new FormatterOptions { MaximumOutputBytes = outputBytes }).Success, "At-limit UTF-8 output bytes must succeed.");
212212
AssertBudgetFailure(unicodeSource, RustFormatter.Format(unicodeSource, "budget.rs", new FormatterOptions { MaximumOutputBytes = outputBytes - 1 }));
213-
AssertBudgetFailure(source, RustFormatter.Format(source, "budget.rs", new FormatterOptions { Timeout = TimeSpan.FromTicks(1) }));
213+
for (int attempt = 0; attempt < 32; attempt++)
214+
{
215+
Guard(clock);
216+
AssertBudgetFailure(source, RustFormatter.Format(source, "budget.rs",
217+
new FormatterOptions { Timeout = TimeSpan.FromTicks(1) }));
218+
}
214219
// First output may expand, but must remain acceptable to a default second pass.
215220
string expansion = "fn f(){/*" + new string('x', 999981) + "*/}";
216221
AssertEx.True(expansion.Length < 1_000_000, "Expansion input stays below the frozen source ceiling.");

0 commit comments

Comments
 (0)