Skip to content

Commit 90e376e

Browse files
committed
test(p1): add verified native GUI lifecycle fixture
1 parent b9a420a commit 90e376e

4 files changed

Lines changed: 270 additions & 2 deletions

File tree

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"schemaVersion": 1,
3+
"component": "Windows native GUI lifecycle fixture",
4+
"source": "tests/fixtures/processes/WindowsGuiLifecycle.c",
5+
"sourceSha": "082061812D383B8401A2B16B2E3BC8FC85C9F90B90877AEC0AE71402CDE9C3F0",
6+
"nativePeSha": "A10121A89DA1A325780EED228C99ABE8A2D99389BF1D05B5DC7231E4849D7A6B",
7+
"controllerDllSha": "5729C8E134B297A9892A57B9A036FFFC5A8F1269B57D4636D6C2A8547E707B8F",
8+
"frozenScopeSha": "0DA47E8E5FAD334FE9F6B052139FFDA5E90BF78E395449F44E9B8C7447D8E08F",
9+
"tiny": 1,
10+
"lifecycleExecuted": 8,
11+
"lifecycleDenominator": 8,
12+
"lifecyclePassed": true,
13+
"caseResults": [
14+
{
15+
"id": "natural-exit",
16+
"accepted": true,
17+
"rootPid": 13780,
18+
"jobTotal": 1,
19+
"finalActive": 0,
20+
"cleanupErrors": 0
21+
},
22+
{
23+
"id": "exception-exit",
24+
"accepted": true,
25+
"rootPid": 61912,
26+
"jobTotal": 1,
27+
"finalActive": 0,
28+
"cleanupErrors": 0
29+
},
30+
{
31+
"id": "timeout",
32+
"accepted": true,
33+
"rootPid": 65564,
34+
"jobTotal": 1,
35+
"finalActive": 0,
36+
"cleanupErrors": 0
37+
},
38+
{
39+
"id": "cancellation",
40+
"accepted": true,
41+
"rootPid": 52832,
42+
"jobTotal": 1,
43+
"finalActive": 0,
44+
"cleanupErrors": 0
45+
},
46+
{
47+
"id": "descendants-survive-root",
48+
"accepted": true,
49+
"rootPid": 22424,
50+
"jobTotal": 2,
51+
"finalActive": 0,
52+
"cleanupErrors": 0
53+
},
54+
{
55+
"id": "nested-grandchild",
56+
"accepted": true,
57+
"rootPid": 9452,
58+
"jobTotal": 3,
59+
"finalActive": 0,
60+
"cleanupErrors": 0
61+
},
62+
{
63+
"id": "assignment-or-capability-failure",
64+
"accepted": true,
65+
"rootPid": 61044,
66+
"jobTotal": 0,
67+
"finalActive": 0,
68+
"cleanupErrors": 0
69+
},
70+
{
71+
"id": "identity-reuse-rejection",
72+
"accepted": true,
73+
"rootPid": 13380,
74+
"jobTotal": 0,
75+
"finalActive": 0,
76+
"cleanupErrors": 0
77+
}
78+
],
79+
"rawSuite": "artifacts/p1-supervision/descendant-containment-draft-v6/lifecycle-root-result.json",
80+
"rawSuiteSha": "D52CEEC031E0063CC0F30303342C7CA0E7BA64ED4B84789D29ACF7F6FBEE4D32",
81+
"compilerHistoryComplete": false,
82+
"stdoutCompilerCapture": false,
83+
"ownedBuildCleanupPending": true,
84+
"originalCancel6Accepted": false,
85+
"originalRetention2Accepted": false,
86+
"formalJoint12Accepted": false,
87+
"fullP1Closure": false,
88+
"fullP2Closure": false
89+
}

‎docs/roadmap/P2-HANDOFF.md‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,29 @@
22

33
English | [简体中文](P2-HANDOFF_zh.md) | [P2 contract](P2.md)
44

5-
## Current checkpoint — 2026-10-08 10:53
5+
## Current checkpoint — 2026-10-08 11:20
6+
7+
Windows containment v6 native GUI fixture is ✅ Complete for its component:
8+
actual tiny1 and all eight frozen lifecycle controls pass, with exact1/2/3
9+
member counts and separate held unassigned-root negative controls. The fixture
10+
has no CLR/CRT/console imports. Archive: `docs/evidence/p1/windows-gui-lifecycle-v6.json`;
11+
tracked source: `tests/fixtures/processes/WindowsGuiLifecycle.c`. Compiler Jobs
12+
reach zero; historical compiler identity/capture limitations and pending owned
13+
build-directory cleanup remain explicit. Original cancellation6, retention2,
14+
Linux delegation and formal joint12 remain open.
15+
16+
Both large Drop ZIPs are now fully downloaded and reconstructed from exact
17+
HTTP206 ranges. Windows317 files/401 hashes reconcile3242/3250 checks; eight
18+
ISO timestamp precision differences still await independent tick reconciliation.
19+
Linux ZIP remains unextracted. No downloaded program was executed. Formatter
20+
v6 sole tiny fails before Helper/CLI execution because its in-process compiler
21+
used a random private assembly name. v7 uses two fixed SDK compilers, has
22+
correct private AssemblyDef/Ref closure and a frozen17-file package; runtime0,
23+
CTRL+C and pending asynchronous-I/O evidence remain open. P2 stays8/101 complete
24+
leaves; no P1 gate, P2 parent or phase closes. Resume from
25+
`artifacts/p1-supervision/resume-root-v2/resumption.json`; heartbeat stays ACTIVE.
26+
27+
## Historical checkpoint — 2026-10-08 10:53
628

729
CI run [37710305713](https://github.com/IoTSharp/RustSharp/actions/runs/37710305713)
830
at exact pushed `afb0988bb74e698a685adde93bacdd2b82b8c932` is ✅ Complete

‎docs/roadmap/P2-HANDOFF_zh.md‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,24 @@
22

33
[English](P2-HANDOFF.md) | 简体中文 | [P2 契约](P2_zh.md)
44

5-
## 当前检查点 — 2026-10-08 10:53
5+
## 当前检查点 — 2026-10-08 11:20
6+
7+
Windows隔离v6原生GUI夹具在其组件范围为 ✅ 已完成:真实tiny1及全部八项固定
8+
生命周期控制通过,严格1/2/3成员计数,并独立证明未分配挂起root负控制退出。
9+
夹具无CLR/CRT/console imports。归档:`docs/evidence/p1/windows-gui-lifecycle-v6.json`;
10+
已跟踪源码:`tests/fixtures/processes/WindowsGuiLifecycle.c`。Compiler Jobs归零;
11+
历史compiler身份/捕获限制及独占构建目录待回收仍明确保留。原取消6、保留2、
12+
Linux委派及正式joint12仍开放。
13+
14+
双方大型Drop ZIP现已完整下载,按准确HTTP206 Range重组。Windows317文件/401哈希
15+
核对3242/3250项;八项ISO时间精度差异仍待独立tick对账。Linux ZIP仍未解包。
16+
未执行任何下载程序。Formatter v6唯一tiny在Helper/CLI执行前失败,因为内置编译器
17+
使用随机私有程序集名。v7改用两轮固定SDK编译器,私有AssemblyDef/Ref闭包正确,
18+
冻结17文件包;runtime0,CTRL+C及待完成异步I/O证据仍开放。P2仍为8/101个完成
19+
叶项;没有关闭P1门禁、P2父项或阶段。从
20+
`artifacts/p1-supervision/resume-root-v2/resumption.json`接续;心跳保持ACTIVE。
21+
22+
## 历史检查点 — 2026-10-08 10:53
623

724
CI run [37710305713](https://github.com/IoTSharp/RustSharp/actions/runs/37710305713)
825
准确绑定已推送 `afb0988bb74e698a685adde93bacdd2b82b8c932`,全部八个作业
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/* Windows GUI / no CRT / no CLR; only kernel32. No console/shell/breakaway.
2+
* /GS- /Zl /W4 /WX; /NODEFAULTLIB /ENTRY:TinyEntry /SUBSYSTEM:WINDOWS.
3+
* Exact Job membership/identity is independently proved by the controller.
4+
*/
5+
#define WIN32_LEAN_AND_MEAN
6+
#include <Windows.h>
7+
static BOOL Eq(const WCHAR* left,const WCHAR* right)
8+
{
9+
DWORD index; ULONGLONG start=GetTickCount64();
10+
for(index=0;index<1024 && GetTickCount64()-start<1000;index++) {
11+
if(left[index]!=right[index]) return FALSE;
12+
if(left[index]==0) return TRUE;
13+
}
14+
return FALSE;
15+
}
16+
static void Zero(void* memory,SIZE_T bytes)
17+
{
18+
SIZE_T index;volatile BYTE* target=(volatile BYTE*)memory;ULONGLONG start=GetTickCount64();
19+
if(bytes>4096) ExitProcess(81);
20+
for(index=0;index<bytes && index<4096 && GetTickCount64()-start<1000;index++) target[index]=0;
21+
if(index!=bytes) ExitProcess(81);
22+
}
23+
static BOOL Append(WCHAR* target,DWORD* length,const WCHAR* value)
24+
{
25+
DWORD index;ULONGLONG start=GetTickCount64();
26+
for(index=0;index<1024 && GetTickCount64()-start<1000;index++) {
27+
if(value[index]==0) return TRUE;
28+
if(*length>=4095) return FALSE;
29+
target[(*length)++]=value[index];target[*length]=0;
30+
}
31+
return FALSE;
32+
}
33+
static BOOL WriteBytes(HANDLE stream,const BYTE* bytes,DWORD count)
34+
{
35+
DWORD written=0;
36+
return stream && stream!=INVALID_HANDLE_VALUE && GetFileType(stream)==FILE_TYPE_PIPE && WriteFile(stream,bytes,count,&written,NULL) && written==count;
37+
}
38+
static DWORD Parse(WCHAR values[4][1024])
39+
{
40+
const WCHAR* command=GetCommandLineW();DWORD argc=0,pos=0,index;BOOL quoted;ULONGLONG start=GetTickCount64();
41+
for(index=0;index<4 && pos<4096 && GetTickCount64()-start<1000;index++) {
42+
DWORD length=0;
43+
for(;pos<4096 && command[pos]==L' ' && GetTickCount64()-start<1000;pos++) {}
44+
if(pos>=4096 || GetTickCount64()-start>=1000) return 0;
45+
if(command[pos]==0) return argc;
46+
quoted=command[pos]==L'"';if(quoted) pos++;
47+
for(;pos<4096 && length<1023 && GetTickCount64()-start<1000;pos++) {
48+
WCHAR ch=command[pos];
49+
if((quoted && ch==L'"') || (!quoted && (ch==L' ' || ch==0))) break;
50+
if(ch==0 || ch==L'"') return 0;
51+
values[argc][length++]=ch;
52+
}
53+
if(pos>=4096 || length>=1023 || GetTickCount64()-start>=1000) return 0;
54+
values[argc][length]=0;argc++;
55+
if(quoted){if(command[pos]!=L'"') return 0;pos++;}
56+
if(command[pos]!=0 && command[pos]!=L' ') return 0;
57+
}
58+
for(index=0;index<4096 && pos<4096 && command[pos]==L' ' && GetTickCount64()-start<1000;index++,pos++) {}
59+
return pos<4096 && command[pos]==0 && GetTickCount64()-start<1000?argc:0;
60+
}
61+
static BOOL Ready(HANDLE reader)
62+
{
63+
DWORD check,available=0,read=0;BYTE bytes[6];ULONGLONG start=GetTickCount64();
64+
for(check=0;check<100 && GetTickCount64()-start<2000;check++) {
65+
if(!PeekNamedPipe(reader,NULL,0,NULL,&available,NULL)) return FALSE;
66+
if(available>=6) {
67+
/* Sole reader; exactly six already available bytes, not an unbounded read. */
68+
if(!ReadFile(reader,bytes,6,&read,NULL) || read!=6 || GetTickCount64()-start>=2000) return FALSE;
69+
return bytes[0]=='R' && bytes[1]=='E' && bytes[2]=='A' && bytes[3]=='D' && bytes[4]=='Y' && bytes[5]=='\n';
70+
}
71+
Sleep(20);
72+
}
73+
return FALSE;
74+
}
75+
static BOOL StartChild(const WCHAR* role,const WCHAR* id)
76+
{
77+
/* Static fixed buffers avoid compiler __chkstk/CRT helpers. One spawn per role/process. */
78+
static WCHAR image[1024],command[4096];DWORD imageLength,length=0;BOOL ok=FALSE,initialized=FALSE,created=FALSE;
79+
HANDLE reader=NULL,writer=NULL;HANDLE handles[3];SECURITY_ATTRIBUTES security;
80+
STARTUPINFOEXW startup;PROCESS_INFORMATION process;SIZE_T size=0;void* attributes=NULL;HANDLE heap=GetProcessHeap();BOOL inJob=FALSE;
81+
ULONGLONG start=GetTickCount64();DWORD cleanupErrors=0;
82+
Zero(&startup,sizeof(startup));Zero(&process,sizeof(process));command[0]=0;
83+
imageLength=GetModuleFileNameW(NULL,image,1024);
84+
if(imageLength==0 || imageLength>=1024) goto done;
85+
if(!Append(command,&length,L"\"") || !Append(command,&length,image) || !Append(command,&length,L"\" \"--fixture\" \"") || !Append(command,&length,role) || !Append(command,&length,L"\" \"") || !Append(command,&length,id) || !Append(command,&length,L"\"")) goto done;
86+
security.nLength=sizeof(security);security.lpSecurityDescriptor=NULL;security.bInheritHandle=TRUE;
87+
if(!CreatePipe(&reader,&writer,&security,0) || !SetHandleInformation(reader,HANDLE_FLAG_INHERIT,0)) goto done;
88+
handles[0]=GetStdHandle(STD_INPUT_HANDLE);handles[1]=writer;handles[2]=GetStdHandle(STD_ERROR_HANDLE);
89+
if(handles[0]==NULL || handles[0]==INVALID_HANDLE_VALUE || handles[2]==NULL || handles[2]==INVALID_HANDLE_VALUE) goto done;
90+
if(InitializeProcThreadAttributeList(NULL,1,0,&size) || GetLastError()!=ERROR_INSUFFICIENT_BUFFER || size==0 || size>4096) goto done;
91+
attributes=HeapAlloc(heap,0,size);if(!attributes) goto done;
92+
if(!InitializeProcThreadAttributeList(attributes,1,0,&size)) goto done;initialized=TRUE;
93+
if(!UpdateProcThreadAttribute(attributes,0,PROC_THREAD_ATTRIBUTE_HANDLE_LIST,handles,sizeof(handles),NULL,NULL)) goto done;
94+
startup.StartupInfo.cb=sizeof(startup);startup.StartupInfo.dwFlags=STARTF_USESTDHANDLES;
95+
startup.StartupInfo.hStdInput=handles[0];startup.StartupInfo.hStdOutput=writer;startup.StartupInfo.hStdError=handles[2];startup.lpAttributeList=attributes;
96+
if(GetTickCount64()-start>=2000) goto done;
97+
if(!CreateProcessW(image,command,NULL,NULL,TRUE,EXTENDED_STARTUPINFO_PRESENT|CREATE_SUSPENDED,NULL,NULL,&startup.StartupInfo,&process)) goto done;
98+
created=TRUE;
99+
if(!IsProcessInJob(process.hProcess,NULL,&inJob) || !inJob || ResumeThread(process.hThread)!=1) goto done;
100+
if(!CloseHandle(writer)){cleanupErrors++;goto done;}writer=NULL;
101+
if(!Ready(reader) || GetTickCount64()-start>=2500) goto done;
102+
ok=TRUE;
103+
done:
104+
/* Exact controller Job owns all child lifetimes; never kill a PID here. */
105+
if(created){if(!CloseHandle(process.hThread)) cleanupErrors++;if(!CloseHandle(process.hProcess)) cleanupErrors++;}
106+
if(initialized) DeleteProcThreadAttributeList(attributes);
107+
if(attributes && !HeapFree(heap,0,attributes)) cleanupErrors++;
108+
if(writer && !CloseHandle(writer)) cleanupErrors++;
109+
if(reader && !CloseHandle(reader)) cleanupErrors++;
110+
return ok && cleanupErrors==0;
111+
}
112+
static void BoundedHold(void)
113+
{
114+
DWORD index;ULONGLONG start=GetTickCount64();
115+
for(index=0;index<600 && GetTickCount64()-start<12000;index++) Sleep(20);
116+
}
117+
__declspec(noreturn) void WINAPI TinyEntry(void)
118+
{
119+
static WCHAR values[4][1024];DWORD argc=Parse(values);BOOL member=FALSE;
120+
static const BYTE tiny[11]={'t','i','n','y',' ','r','o','o','t','\r','\n'};
121+
static const BYTE ready[6]={'R','E','A','D','Y','\n'};
122+
static const BYTE natural[17]={'c','o','n','t','r','o','l','l','e','d',' ','r','o','o','t','\r','\n'};
123+
static const BYTE error[19]={'c','o','n','t','r','o','l','l','e','d',' ','e','x','i','t',' ','1','7','\n'};
124+
if(!IsProcessInJob(GetCurrentProcess(),NULL,&member) || !member) ExitProcess(82);
125+
if(argc==1){if(!WriteBytes(GetStdHandle(STD_OUTPUT_HANDLE),tiny,11)) ExitProcess(73);ExitProcess(0);}
126+
if(argc!=4 || !Eq(values[1],L"--fixture")) ExitProcess(83);
127+
if(!Eq(values[3],L"natural-exit") && !Eq(values[3],L"exception-exit") && !Eq(values[3],L"timeout") && !Eq(values[3],L"cancellation") && !Eq(values[3],L"descendants-survive-root") && !Eq(values[3],L"nested-grandchild") && !Eq(values[3],L"assignment-or-capability-failure") && !Eq(values[3],L"identity-reuse-rejection")) ExitProcess(84);
128+
if(Eq(values[2],L"root")) {
129+
if(Eq(values[3],L"exception-exit")){if(!WriteBytes(GetStdHandle(STD_ERROR_HANDLE),error,19)) ExitProcess(73);ExitProcess(17);}
130+
if(Eq(values[3],L"timeout") || Eq(values[3],L"cancellation")){BoundedHold();ExitProcess(0);}
131+
if(Eq(values[3],L"descendants-survive-root") || Eq(values[3],L"nested-grandchild")){if(!StartChild(L"child",values[3])) ExitProcess(85);ExitProcess(0);}
132+
if(!WriteBytes(GetStdHandle(STD_OUTPUT_HANDLE),natural,17)) ExitProcess(73);ExitProcess(0);
133+
}
134+
if(Eq(values[2],L"child") && (Eq(values[3],L"descendants-survive-root") || Eq(values[3],L"nested-grandchild"))) {
135+
if(Eq(values[3],L"nested-grandchild") && !StartChild(L"grandchild",values[3])) ExitProcess(85);
136+
if(!WriteBytes(GetStdHandle(STD_OUTPUT_HANDLE),ready,6)) ExitProcess(73);BoundedHold();ExitProcess(0);
137+
}
138+
if(Eq(values[2],L"grandchild") && Eq(values[3],L"nested-grandchild")){if(!WriteBytes(GetStdHandle(STD_OUTPUT_HANDLE),ready,6)) ExitProcess(73);BoundedHold();ExitProcess(0);}
139+
ExitProcess(86);
140+
}

0 commit comments

Comments
 (0)