@agent-teams/engineering-foundation 0.19.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/assets/windows-managed-process/WindowsManagedProcess.cs +497 -0
- package/assets/windows-managed-process/bootstrap.ps1 +24 -0
- package/dist/capabilities/quality-gate-runner/adapters/inbound/cli/node-signal-cancellation-source.d.ts +5 -0
- package/dist/capabilities/quality-gate-runner/adapters/inbound/cli/node-signal-cancellation-source.d.ts.map +1 -0
- package/dist/capabilities/quality-gate-runner/adapters/inbound/cli/node-signal-cancellation-source.js +13 -0
- package/dist/capabilities/quality-gate-runner/adapters/inbound/cli/node-signal-cancellation-source.js.map +1 -0
- package/dist/capabilities/quality-gate-runner/adapters/inbound/cli/quality-gate-cli.d.ts +13 -0
- package/dist/capabilities/quality-gate-runner/adapters/inbound/cli/quality-gate-cli.d.ts.map +1 -0
- package/dist/capabilities/quality-gate-runner/adapters/inbound/cli/quality-gate-cli.js +55 -0
- package/dist/capabilities/quality-gate-runner/adapters/inbound/cli/quality-gate-cli.js.map +1 -0
- package/dist/capabilities/quality-gate-runner/adapters/outbound/pnpm/pnpm-package-script-executor.d.ts +11 -1
- package/dist/capabilities/quality-gate-runner/adapters/outbound/pnpm/pnpm-package-script-executor.d.ts.map +1 -1
- package/dist/capabilities/quality-gate-runner/adapters/outbound/pnpm/pnpm-package-script-executor.js +15 -8
- package/dist/capabilities/quality-gate-runner/adapters/outbound/pnpm/pnpm-package-script-executor.js.map +1 -1
- package/dist/capabilities/quality-gate-runner/application/ports/package-script-executor.d.ts +7 -0
- package/dist/capabilities/quality-gate-runner/application/ports/package-script-executor.d.ts.map +1 -1
- package/dist/capabilities/quality-gate-runner/application/ports/package-script-executor.js +10 -0
- package/dist/capabilities/quality-gate-runner/application/ports/package-script-executor.js.map +1 -1
- package/dist/capabilities/quality-gate-runner/application/use-cases/run-quality-gate-profile.d.ts.map +1 -1
- package/dist/capabilities/quality-gate-runner/application/use-cases/run-quality-gate-profile.js +22 -10
- package/dist/capabilities/quality-gate-runner/application/use-cases/run-quality-gate-profile.js.map +1 -1
- package/dist/capabilities/quality-gate-runner/contract/config.d.ts +1 -0
- package/dist/capabilities/quality-gate-runner/contract/config.d.ts.map +1 -1
- package/dist/capabilities/quality-gate-runner/contract/config.js.map +1 -1
- package/dist/capabilities/quality-gate-runner/gate-command.d.ts +19 -6
- package/dist/capabilities/quality-gate-runner/gate-command.d.ts.map +1 -1
- package/dist/capabilities/quality-gate-runner/gate-command.js +43 -54
- package/dist/capabilities/quality-gate-runner/gate-command.js.map +1 -1
- package/dist/capabilities/repository-agent-workflow/application/policies/evaluate-repository-agent-workflow.d.ts.map +1 -1
- package/dist/capabilities/repository-agent-workflow/application/policies/evaluate-repository-agent-workflow.js +5 -2
- package/dist/capabilities/repository-agent-workflow/application/policies/evaluate-repository-agent-workflow.js.map +1 -1
- package/dist/capabilities/repository-agent-workflow/application/rules.js +1 -1
- package/dist/capabilities/repository-agent-workflow/application/rules.js.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/document-authoring/adapters/node/load-validated-document-authoring-profile-v2.d.ts +29 -3
- package/dist/document-authoring/adapters/node/load-validated-document-authoring-profile-v2.d.ts.map +1 -1
- package/dist/document-authoring/adapters/node/load-validated-document-authoring-profile-v2.js +38 -9
- package/dist/document-authoring/adapters/node/load-validated-document-authoring-profile-v2.js.map +1 -1
- package/dist/document-authoring/adapters/node/node-authoring-profile-reader-v2.d.ts.map +1 -1
- package/dist/document-authoring/adapters/node/node-authoring-profile-reader-v2.js +5 -4
- package/dist/document-authoring/adapters/node/node-authoring-profile-reader-v2.js.map +1 -1
- package/dist/document-authoring/adapters/node/node-document-planning-profile-reader.d.ts.map +1 -1
- package/dist/document-authoring/adapters/node/node-document-planning-profile-reader.js +9 -7
- package/dist/document-authoring/adapters/node/node-document-planning-profile-reader.js.map +1 -1
- package/dist/document-authoring/application/model/document-authoring-profile-description.d.ts +4 -0
- package/dist/document-authoring/application/model/document-authoring-profile-description.d.ts.map +1 -1
- package/dist/document-authoring/application/model/document-planning.d.ts +1 -1
- package/dist/document-authoring/application/model/document-planning.d.ts.map +1 -1
- package/dist/document-authoring/application/policies/assert-v2-planning-profile.js +2 -2
- package/dist/document-authoring/application/policies/assert-v2-planning-profile.js.map +1 -1
- package/dist/document-authoring/application/policies/document-authoring-semantic-digests.d.ts +2 -1
- package/dist/document-authoring/application/policies/document-authoring-semantic-digests.d.ts.map +1 -1
- package/dist/document-authoring/application/policies/document-authoring-semantic-digests.js +8 -2
- package/dist/document-authoring/application/policies/document-authoring-semantic-digests.js.map +1 -1
- package/dist/document-authoring/application/ports/authoring-profile-reader.d.ts +1 -1
- package/dist/document-authoring/application/ports/authoring-profile-reader.d.ts.map +1 -1
- package/dist/document-authoring/application/use-cases/build-documentation-catalog.js +3 -3
- package/dist/document-authoring/application/use-cases/build-documentation-catalog.js.map +1 -1
- package/dist/document-authoring/application/use-cases/load-v2-profile-description.d.ts +8 -3
- package/dist/document-authoring/application/use-cases/load-v2-profile-description.d.ts.map +1 -1
- package/dist/document-authoring/application/use-cases/load-v2-profile-description.js +4 -2
- package/dist/document-authoring/application/use-cases/load-v2-profile-description.js.map +1 -1
- package/dist/document-authoring/composition/describe-document-authoring-profile-v2.d.ts +7 -1
- package/dist/document-authoring/composition/describe-document-authoring-profile-v2.d.ts.map +1 -1
- package/dist/document-authoring/composition/describe-document-authoring-profile-v2.js +54 -17
- package/dist/document-authoring/composition/describe-document-authoring-profile-v2.js.map +1 -1
- package/dist/document-authoring/composition/node-document-planning.d.ts.map +1 -1
- package/dist/document-authoring/composition/node-document-planning.js +4 -3
- package/dist/document-authoring/composition/node-document-planning.js.map +1 -1
- package/dist/document-authoring/index.d.ts +4 -3
- package/dist/document-authoring/index.d.ts.map +1 -1
- package/dist/document-authoring/index.js +2 -1
- package/dist/document-authoring/index.js.map +1 -1
- package/dist/local-mode/process-runner.d.ts +4 -1
- package/dist/local-mode/process-runner.d.ts.map +1 -1
- package/dist/local-mode/process-runner.js +9 -1
- package/dist/local-mode/process-runner.js.map +1 -1
- package/dist/package-self-check.d.ts +2 -2
- package/dist/package-self-check.d.ts.map +1 -1
- package/dist/package-self-check.js +5 -1
- package/dist/package-self-check.js.map +1 -1
- package/dist/process-execution/node-process-runner.d.ts +14 -0
- package/dist/process-execution/node-process-runner.d.ts.map +1 -1
- package/dist/process-execution/node-process-runner.js +129 -57
- package/dist/process-execution/node-process-runner.js.map +1 -1
- package/dist/process-execution/windows-managed-process.d.ts +12 -3
- package/dist/process-execution/windows-managed-process.d.ts.map +1 -1
- package/dist/process-execution/windows-managed-process.js +299 -357
- package/dist/process-execution/windows-managed-process.js.map +1 -1
- package/dist/process-execution/windows-process-host.js +17 -3
- package/dist/process-execution/windows-process-host.js.map +1 -1
- package/dist/quality-gate-cli-command.d.ts +11 -0
- package/dist/quality-gate-cli-command.d.ts.map +1 -1
- package/dist/quality-gate-cli-command.js +76 -30
- package/dist/quality-gate-cli-command.js.map +1 -1
- package/dist/scaffolding/adapters/node/filesystem-authority-recovery.d.ts +6 -0
- package/dist/scaffolding/adapters/node/filesystem-authority-recovery.d.ts.map +1 -0
- package/dist/scaffolding/adapters/node/filesystem-authority-recovery.js +47 -0
- package/dist/scaffolding/adapters/node/filesystem-authority-recovery.js.map +1 -0
- package/dist/scaffolding/adapters/node/filesystem-authority-workspace.d.ts +20 -3
- package/dist/scaffolding/adapters/node/filesystem-authority-workspace.d.ts.map +1 -1
- package/dist/scaffolding/adapters/node/filesystem-authority-workspace.js +18 -40
- package/dist/scaffolding/adapters/node/filesystem-authority-workspace.js.map +1 -1
- package/dist/scaffolding/canonical-api.d.ts +2 -1
- package/dist/scaffolding/canonical-api.d.ts.map +1 -1
- package/dist/scaffolding/canonical-api.js +12 -3
- package/dist/scaffolding/canonical-api.js.map +1 -1
- package/dist/scaffolding/contract/scaffold-contract.d.ts +3 -1
- package/dist/scaffolding/contract/scaffold-contract.d.ts.map +1 -1
- package/dist/scaffolding/contract/types.d.ts +7 -0
- package/dist/scaffolding/contract/types.d.ts.map +1 -1
- package/dist/scaffolding/index.d.ts +2 -2
- package/dist/scaffolding/index.d.ts.map +1 -1
- package/dist/scaffolding/index.js.map +1 -1
- package/dist/scaffolding/kernel/recovery-scope.d.ts +5 -0
- package/dist/scaffolding/kernel/recovery-scope.d.ts.map +1 -0
- package/dist/scaffolding/kernel/recovery-scope.js +94 -0
- package/dist/scaffolding/kernel/recovery-scope.js.map +1 -0
- package/dist/schema-catalog.d.ts.map +1 -1
- package/dist/schema-catalog.js +1 -0
- package/dist/schema-catalog.js.map +1 -1
- package/dist/schema-ids.d.ts +1 -1
- package/dist/schema-ids.d.ts.map +1 -1
- package/dist/schema-ids.js +1 -0
- package/dist/schema-ids.js.map +1 -1
- package/package.json +4 -1
- package/schemas/document-authoring-profile/v3.schema.json +200 -0
- package/dist/capabilities/quality-gate-runner/adapters/inbound/cli/report-renderer.d.ts +0 -3
- package/dist/capabilities/quality-gate-runner/adapters/inbound/cli/report-renderer.d.ts.map +0 -1
- package/dist/capabilities/quality-gate-runner/adapters/inbound/cli/report-renderer.js +0 -17
- package/dist/capabilities/quality-gate-runner/adapters/inbound/cli/report-renderer.js.map +0 -1
package/README.md
CHANGED
|
@@ -165,6 +165,14 @@ agent-teams-foundation scaffold-apply plans/example.json --consumer /repo --json
|
|
|
165
165
|
agent-teams-foundation scaffold-recover --consumer /repo --json
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
+
Programmatic callers may bind mutation to expected consumer descriptors with
|
|
169
|
+
`recoverFilesystemScaffold(consumerRoot, { projectId, configPath,
|
|
170
|
+
targetCatalogPath, compositionId })`. Foundation snapshots the immutable v1
|
|
171
|
+
value, validates paths against the published v1 schema exactly, and requires
|
|
172
|
+
exact string agreement with the stored journal before reading authority or
|
|
173
|
+
continuing recovery. The one-argument API and CLI are unchanged;
|
|
174
|
+
`inspectFoundationTransactionAwareMode` remains the read-only advisory preflight.
|
|
175
|
+
|
|
168
176
|
The current built-in Composition is a testing-only conformance fixture. Product
|
|
169
177
|
package and feature recipes, structured updates, and Nx integration require
|
|
170
178
|
separate qualification before they become available.
|
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.ComponentModel;
|
|
3
|
+
using System.Diagnostics;
|
|
4
|
+
using System.IO;
|
|
5
|
+
using System.Runtime.InteropServices;
|
|
6
|
+
using System.Text;
|
|
7
|
+
using System.Threading;
|
|
8
|
+
|
|
9
|
+
namespace AgentTeams.Foundation
|
|
10
|
+
{
|
|
11
|
+
public static class WindowsManagedProcess
|
|
12
|
+
{
|
|
13
|
+
private const uint CREATE_SUSPENDED = 0x00000004;
|
|
14
|
+
private const uint CREATE_UNICODE_ENVIRONMENT = 0x00000400;
|
|
15
|
+
private const uint EXTENDED_STARTUPINFO_PRESENT = 0x00080000;
|
|
16
|
+
private const uint STARTF_USESTDHANDLES = 0x00000100;
|
|
17
|
+
private const uint JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE = 0x00002000;
|
|
18
|
+
private const uint WAIT_OBJECT_0 = 0;
|
|
19
|
+
private const uint WAIT_FAILED = 0xffffffff;
|
|
20
|
+
private const int JobObjectBasicAccountingInformation = 1;
|
|
21
|
+
private const int JobObjectExtendedLimitInformation = 9;
|
|
22
|
+
private const int STD_INPUT_HANDLE = -10;
|
|
23
|
+
private const int STD_OUTPUT_HANDLE = -11;
|
|
24
|
+
private const int STD_ERROR_HANDLE = -12;
|
|
25
|
+
private const int MAX_COMMAND_LINE_CHARACTERS = 32766;
|
|
26
|
+
private static readonly IntPtr PROC_THREAD_ATTRIBUTE_JOB_LIST =
|
|
27
|
+
new IntPtr(0x0002000D);
|
|
28
|
+
|
|
29
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
30
|
+
private struct PROCESS_INFORMATION
|
|
31
|
+
{
|
|
32
|
+
public IntPtr hProcess;
|
|
33
|
+
public IntPtr hThread;
|
|
34
|
+
public uint dwProcessId;
|
|
35
|
+
public uint dwThreadId;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
|
39
|
+
private struct STARTUPINFO
|
|
40
|
+
{
|
|
41
|
+
public uint cb;
|
|
42
|
+
public string lpReserved;
|
|
43
|
+
public string lpDesktop;
|
|
44
|
+
public string lpTitle;
|
|
45
|
+
public uint dwX;
|
|
46
|
+
public uint dwY;
|
|
47
|
+
public uint dwXSize;
|
|
48
|
+
public uint dwYSize;
|
|
49
|
+
public uint dwXCountChars;
|
|
50
|
+
public uint dwYCountChars;
|
|
51
|
+
public uint dwFillAttribute;
|
|
52
|
+
public uint dwFlags;
|
|
53
|
+
public ushort wShowWindow;
|
|
54
|
+
public ushort cbReserved2;
|
|
55
|
+
public IntPtr lpReserved2;
|
|
56
|
+
public IntPtr hStdInput;
|
|
57
|
+
public IntPtr hStdOutput;
|
|
58
|
+
public IntPtr hStdError;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
62
|
+
private struct STARTUPINFOEX
|
|
63
|
+
{
|
|
64
|
+
public STARTUPINFO StartupInfo;
|
|
65
|
+
public IntPtr lpAttributeList;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
69
|
+
private struct JOBOBJECT_BASIC_LIMIT_INFORMATION
|
|
70
|
+
{
|
|
71
|
+
public long PerProcessUserTimeLimit;
|
|
72
|
+
public long PerJobUserTimeLimit;
|
|
73
|
+
public uint LimitFlags;
|
|
74
|
+
public UIntPtr MinimumWorkingSetSize;
|
|
75
|
+
public UIntPtr MaximumWorkingSetSize;
|
|
76
|
+
public uint ActiveProcessLimit;
|
|
77
|
+
public UIntPtr Affinity;
|
|
78
|
+
public uint PriorityClass;
|
|
79
|
+
public uint SchedulingClass;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
83
|
+
private struct JOBOBJECT_BASIC_ACCOUNTING_INFORMATION
|
|
84
|
+
{
|
|
85
|
+
public long TotalUserTime;
|
|
86
|
+
public long TotalKernelTime;
|
|
87
|
+
public long ThisPeriodTotalUserTime;
|
|
88
|
+
public long ThisPeriodTotalKernelTime;
|
|
89
|
+
public uint TotalPageFaultCount;
|
|
90
|
+
public uint TotalProcesses;
|
|
91
|
+
public uint ActiveProcesses;
|
|
92
|
+
public uint TotalTerminatedProcesses;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
96
|
+
private struct IO_COUNTERS
|
|
97
|
+
{
|
|
98
|
+
public ulong ReadOperationCount;
|
|
99
|
+
public ulong WriteOperationCount;
|
|
100
|
+
public ulong OtherOperationCount;
|
|
101
|
+
public ulong ReadTransferCount;
|
|
102
|
+
public ulong WriteTransferCount;
|
|
103
|
+
public ulong OtherTransferCount;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
107
|
+
private struct JOBOBJECT_EXTENDED_LIMIT_INFORMATION
|
|
108
|
+
{
|
|
109
|
+
public JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation;
|
|
110
|
+
public IO_COUNTERS IoInfo;
|
|
111
|
+
public UIntPtr ProcessMemoryLimit;
|
|
112
|
+
public UIntPtr JobMemoryLimit;
|
|
113
|
+
public UIntPtr PeakProcessMemoryUsed;
|
|
114
|
+
public UIntPtr PeakJobMemoryUsed;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
|
118
|
+
private static extern IntPtr CreateJobObject(IntPtr attributes, string name);
|
|
119
|
+
|
|
120
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
|
121
|
+
private static extern bool SetInformationJobObject(
|
|
122
|
+
IntPtr job, int informationClass, IntPtr information, uint informationLength);
|
|
123
|
+
|
|
124
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
|
125
|
+
private static extern bool QueryInformationJobObject(
|
|
126
|
+
IntPtr job, int informationClass, IntPtr information,
|
|
127
|
+
uint informationLength, IntPtr returnLength);
|
|
128
|
+
|
|
129
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
|
130
|
+
private static extern bool TerminateJobObject(IntPtr job, uint exitCode);
|
|
131
|
+
|
|
132
|
+
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
|
133
|
+
private static extern bool CreateProcess(
|
|
134
|
+
string applicationName, StringBuilder commandLine,
|
|
135
|
+
IntPtr processAttributes, IntPtr threadAttributes, bool inheritHandles,
|
|
136
|
+
uint creationFlags, IntPtr environment, string currentDirectory,
|
|
137
|
+
ref STARTUPINFOEX startupInfo, out PROCESS_INFORMATION processInformation);
|
|
138
|
+
|
|
139
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
|
140
|
+
private static extern bool InitializeProcThreadAttributeList(
|
|
141
|
+
IntPtr attributeList, int attributeCount, uint flags, ref IntPtr size);
|
|
142
|
+
|
|
143
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
|
144
|
+
private static extern bool UpdateProcThreadAttribute(
|
|
145
|
+
IntPtr attributeList, uint flags, IntPtr attribute, IntPtr value,
|
|
146
|
+
UIntPtr size, IntPtr previousValue, IntPtr returnSize);
|
|
147
|
+
|
|
148
|
+
[DllImport("kernel32.dll")]
|
|
149
|
+
private static extern void DeleteProcThreadAttributeList(IntPtr attributeList);
|
|
150
|
+
|
|
151
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
|
152
|
+
private static extern uint ResumeThread(IntPtr thread);
|
|
153
|
+
|
|
154
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
|
155
|
+
private static extern uint WaitForSingleObject(IntPtr handle, uint milliseconds);
|
|
156
|
+
|
|
157
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
|
158
|
+
private static extern bool GetExitCodeProcess(IntPtr process, out uint exitCode);
|
|
159
|
+
|
|
160
|
+
[DllImport("kernel32.dll")]
|
|
161
|
+
private static extern IntPtr GetStdHandle(int standardHandle);
|
|
162
|
+
|
|
163
|
+
[DllImport("kernel32.dll")]
|
|
164
|
+
private static extern bool CloseHandle(IntPtr handle);
|
|
165
|
+
|
|
166
|
+
private static string Quote(string value)
|
|
167
|
+
{
|
|
168
|
+
if (value.Length > 0 && value.IndexOfAny(new[] { ' ', '\t', '"' }) < 0)
|
|
169
|
+
{
|
|
170
|
+
return value;
|
|
171
|
+
}
|
|
172
|
+
var output = new StringBuilder("\"");
|
|
173
|
+
var slashes = 0;
|
|
174
|
+
foreach (var character in value)
|
|
175
|
+
{
|
|
176
|
+
if (character == '\\')
|
|
177
|
+
{
|
|
178
|
+
slashes += 1;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (character == '"')
|
|
182
|
+
{
|
|
183
|
+
output.Append('\\', slashes * 2 + 1);
|
|
184
|
+
output.Append(character);
|
|
185
|
+
slashes = 0;
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
output.Append('\\', slashes);
|
|
189
|
+
slashes = 0;
|
|
190
|
+
output.Append(character);
|
|
191
|
+
}
|
|
192
|
+
output.Append('\\', slashes * 2);
|
|
193
|
+
output.Append('"');
|
|
194
|
+
return output.ToString();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private static StringBuilder BuildCommandLine(string executable, string[] arguments)
|
|
198
|
+
{
|
|
199
|
+
var commandLine = new StringBuilder(Quote(executable));
|
|
200
|
+
foreach (var argument in arguments)
|
|
201
|
+
{
|
|
202
|
+
commandLine.Append(' ').Append(Quote(argument));
|
|
203
|
+
}
|
|
204
|
+
if (commandLine.Length > MAX_COMMAND_LINE_CHARACTERS)
|
|
205
|
+
{
|
|
206
|
+
throw new ArgumentException(
|
|
207
|
+
"The managed Windows process bootstrap command line exceeds " +
|
|
208
|
+
MAX_COMMAND_LINE_CHARACTERS + " characters.");
|
|
209
|
+
}
|
|
210
|
+
return commandLine;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
private static IntPtr BuildEnvironmentBlock(string[] entries)
|
|
214
|
+
{
|
|
215
|
+
var copy = entries == null ? new string[0] : (string[])entries.Clone();
|
|
216
|
+
Array.Sort(copy, StringComparer.OrdinalIgnoreCase);
|
|
217
|
+
string previousName = null;
|
|
218
|
+
foreach (var entry in copy)
|
|
219
|
+
{
|
|
220
|
+
var separator = entry == null ? -1 : entry.IndexOf('=');
|
|
221
|
+
if (separator <= 0 || entry.IndexOf('\0') >= 0)
|
|
222
|
+
{
|
|
223
|
+
throw new ArgumentException(
|
|
224
|
+
"The managed Windows process environment contains an invalid entry.");
|
|
225
|
+
}
|
|
226
|
+
var name = entry.Substring(0, separator);
|
|
227
|
+
if (previousName != null &&
|
|
228
|
+
StringComparer.OrdinalIgnoreCase.Equals(previousName, name))
|
|
229
|
+
{
|
|
230
|
+
throw new ArgumentException(
|
|
231
|
+
"The managed Windows process environment contains a duplicate name.");
|
|
232
|
+
}
|
|
233
|
+
previousName = name;
|
|
234
|
+
}
|
|
235
|
+
return Marshal.StringToHGlobalUni(string.Join("\0", copy) + "\0\0");
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
private static uint ActiveProcessCount(IntPtr job)
|
|
239
|
+
{
|
|
240
|
+
var accounting = new JOBOBJECT_BASIC_ACCOUNTING_INFORMATION();
|
|
241
|
+
var length = Marshal.SizeOf(accounting);
|
|
242
|
+
var pointer = Marshal.AllocHGlobal(length);
|
|
243
|
+
try
|
|
244
|
+
{
|
|
245
|
+
if (!QueryInformationJobObject(
|
|
246
|
+
job, JobObjectBasicAccountingInformation,
|
|
247
|
+
pointer, (uint)length, IntPtr.Zero))
|
|
248
|
+
{
|
|
249
|
+
throw new Win32Exception(
|
|
250
|
+
Marshal.GetLastWin32Error(), "QueryInformationJobObject failed");
|
|
251
|
+
}
|
|
252
|
+
accounting = (JOBOBJECT_BASIC_ACCOUNTING_INFORMATION)
|
|
253
|
+
Marshal.PtrToStructure(
|
|
254
|
+
pointer, typeof(JOBOBJECT_BASIC_ACCOUNTING_INFORMATION));
|
|
255
|
+
return accounting.ActiveProcesses;
|
|
256
|
+
}
|
|
257
|
+
finally
|
|
258
|
+
{
|
|
259
|
+
Marshal.FreeHGlobal(pointer);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
private static void TerminateRemainingProcessesAndWait(IntPtr job)
|
|
264
|
+
{
|
|
265
|
+
if (ActiveProcessCount(job) > 0 && !TerminateJobObject(job, 1))
|
|
266
|
+
{
|
|
267
|
+
throw new Win32Exception(
|
|
268
|
+
Marshal.GetLastWin32Error(), "TerminateJobObject failed");
|
|
269
|
+
}
|
|
270
|
+
var stopwatch = Stopwatch.StartNew();
|
|
271
|
+
while (ActiveProcessCount(job) > 0)
|
|
272
|
+
{
|
|
273
|
+
if (stopwatch.ElapsedMilliseconds >= 5000)
|
|
274
|
+
{
|
|
275
|
+
throw new TimeoutException(
|
|
276
|
+
"Windows Job Object descendants did not terminate within 5000 ms");
|
|
277
|
+
}
|
|
278
|
+
Thread.Sleep(10);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
private static void ConfirmContainment(string confirmationPath)
|
|
283
|
+
{
|
|
284
|
+
var temporaryPath = confirmationPath + ".tmp";
|
|
285
|
+
File.WriteAllText(temporaryPath, "CONTAINED", new UTF8Encoding(false));
|
|
286
|
+
File.Move(temporaryPath, confirmationPath);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
private static bool CancelAssignedIfRequested(
|
|
290
|
+
string cancellationPath, string confirmationPath, IntPtr job)
|
|
291
|
+
{
|
|
292
|
+
if (!File.Exists(cancellationPath))
|
|
293
|
+
{
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
TerminateRemainingProcessesAndWait(job);
|
|
297
|
+
ConfirmContainment(confirmationPath);
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
private static bool LaunchSucceeded(string launchPath)
|
|
302
|
+
{
|
|
303
|
+
try
|
|
304
|
+
{
|
|
305
|
+
return File.Exists(launchPath) &&
|
|
306
|
+
File.ReadAllText(launchPath) == "STARTED";
|
|
307
|
+
}
|
|
308
|
+
catch (IOException)
|
|
309
|
+
{
|
|
310
|
+
// The host publishes the marker atomically enough for durability,
|
|
311
|
+
// but Windows may briefly deny a concurrent read while it closes.
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
private static void ConfigureKillOnClose(IntPtr job)
|
|
317
|
+
{
|
|
318
|
+
var limits = new JOBOBJECT_EXTENDED_LIMIT_INFORMATION();
|
|
319
|
+
limits.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
|
|
320
|
+
var length = Marshal.SizeOf(limits);
|
|
321
|
+
var pointer = Marshal.AllocHGlobal(length);
|
|
322
|
+
try
|
|
323
|
+
{
|
|
324
|
+
Marshal.StructureToPtr(limits, pointer, false);
|
|
325
|
+
if (!SetInformationJobObject(
|
|
326
|
+
job, JobObjectExtendedLimitInformation, pointer, (uint)length))
|
|
327
|
+
{
|
|
328
|
+
throw new Win32Exception(
|
|
329
|
+
Marshal.GetLastWin32Error(), "SetInformationJobObject failed");
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
finally
|
|
333
|
+
{
|
|
334
|
+
Marshal.FreeHGlobal(pointer);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
public static int Run(
|
|
339
|
+
string executable, string hostPath, string encodedRequest,
|
|
340
|
+
string currentDirectory,
|
|
341
|
+
string[] environmentEntries,
|
|
342
|
+
string cancellationPath, string confirmationPath, string launchPath)
|
|
343
|
+
{
|
|
344
|
+
var commandLine = BuildCommandLine(
|
|
345
|
+
executable, new[] { hostPath, encodedRequest });
|
|
346
|
+
var job = IntPtr.Zero;
|
|
347
|
+
var environmentBlock = IntPtr.Zero;
|
|
348
|
+
var attributeList = IntPtr.Zero;
|
|
349
|
+
var jobHandleValue = IntPtr.Zero;
|
|
350
|
+
var attributeListInitialized = false;
|
|
351
|
+
var assigned = false;
|
|
352
|
+
var process = new PROCESS_INFORMATION();
|
|
353
|
+
try
|
|
354
|
+
{
|
|
355
|
+
job = CreateJobObject(IntPtr.Zero, null);
|
|
356
|
+
if (job == IntPtr.Zero)
|
|
357
|
+
{
|
|
358
|
+
throw new Win32Exception(
|
|
359
|
+
Marshal.GetLastWin32Error(), "CreateJobObject failed");
|
|
360
|
+
}
|
|
361
|
+
ConfigureKillOnClose(job);
|
|
362
|
+
|
|
363
|
+
var attributeListSize = IntPtr.Zero;
|
|
364
|
+
InitializeProcThreadAttributeList(
|
|
365
|
+
IntPtr.Zero, 1, 0, ref attributeListSize);
|
|
366
|
+
attributeList = Marshal.AllocHGlobal(attributeListSize);
|
|
367
|
+
if (!InitializeProcThreadAttributeList(
|
|
368
|
+
attributeList, 1, 0, ref attributeListSize))
|
|
369
|
+
{
|
|
370
|
+
throw new Win32Exception(
|
|
371
|
+
Marshal.GetLastWin32Error(),
|
|
372
|
+
"InitializeProcThreadAttributeList failed");
|
|
373
|
+
}
|
|
374
|
+
attributeListInitialized = true;
|
|
375
|
+
jobHandleValue = Marshal.AllocHGlobal(IntPtr.Size);
|
|
376
|
+
Marshal.WriteIntPtr(jobHandleValue, job);
|
|
377
|
+
if (!UpdateProcThreadAttribute(
|
|
378
|
+
attributeList, 0, PROC_THREAD_ATTRIBUTE_JOB_LIST,
|
|
379
|
+
jobHandleValue, new UIntPtr((uint)IntPtr.Size),
|
|
380
|
+
IntPtr.Zero, IntPtr.Zero))
|
|
381
|
+
{
|
|
382
|
+
throw new Win32Exception(
|
|
383
|
+
Marshal.GetLastWin32Error(),
|
|
384
|
+
"UpdateProcThreadAttribute JOB_LIST failed");
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
var startup = new STARTUPINFOEX();
|
|
388
|
+
startup.StartupInfo.cb = (uint)Marshal.SizeOf(startup);
|
|
389
|
+
startup.StartupInfo.dwFlags = STARTF_USESTDHANDLES;
|
|
390
|
+
startup.StartupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
|
|
391
|
+
startup.StartupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
392
|
+
startup.StartupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
|
393
|
+
startup.lpAttributeList = attributeList;
|
|
394
|
+
environmentBlock = BuildEnvironmentBlock(environmentEntries);
|
|
395
|
+
if (!CreateProcess(
|
|
396
|
+
executable, commandLine, IntPtr.Zero, IntPtr.Zero, true,
|
|
397
|
+
CREATE_SUSPENDED | CREATE_UNICODE_ENVIRONMENT | EXTENDED_STARTUPINFO_PRESENT,
|
|
398
|
+
environmentBlock, currentDirectory, ref startup, out process))
|
|
399
|
+
{
|
|
400
|
+
throw new Win32Exception(
|
|
401
|
+
Marshal.GetLastWin32Error(), "CreateProcess failed");
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// PROC_THREAD_ATTRIBUTE_JOB_LIST makes Job Object membership an
|
|
405
|
+
// atomic property of successful process creation. From here on,
|
|
406
|
+
// closing or terminating the job contains every possible child.
|
|
407
|
+
assigned = true;
|
|
408
|
+
|
|
409
|
+
if (ResumeThread(process.hThread) == WAIT_FAILED)
|
|
410
|
+
{
|
|
411
|
+
throw new Win32Exception(
|
|
412
|
+
Marshal.GetLastWin32Error(), "ResumeThread failed");
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
while (true)
|
|
416
|
+
{
|
|
417
|
+
var waitResult = WaitForSingleObject(process.hProcess, 10);
|
|
418
|
+
if (waitResult == WAIT_OBJECT_0)
|
|
419
|
+
{
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
if (waitResult == WAIT_FAILED)
|
|
423
|
+
{
|
|
424
|
+
throw new Win32Exception(
|
|
425
|
+
Marshal.GetLastWin32Error(), "WaitForSingleObject failed");
|
|
426
|
+
}
|
|
427
|
+
// Once the trusted host has attempted the requested launch,
|
|
428
|
+
// an already observed host failure outranks cancellation.
|
|
429
|
+
if (LaunchSucceeded(launchPath) &&
|
|
430
|
+
CancelAssignedIfRequested(cancellationPath, confirmationPath, job))
|
|
431
|
+
{
|
|
432
|
+
return 0;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
uint exitCode;
|
|
437
|
+
if (!GetExitCodeProcess(process.hProcess, out exitCode))
|
|
438
|
+
{
|
|
439
|
+
throw new Win32Exception(
|
|
440
|
+
Marshal.GetLastWin32Error(), "GetExitCodeProcess failed");
|
|
441
|
+
}
|
|
442
|
+
TerminateRemainingProcessesAndWait(job);
|
|
443
|
+
ConfirmContainment(confirmationPath);
|
|
444
|
+
return unchecked((int)exitCode);
|
|
445
|
+
}
|
|
446
|
+
catch (Exception executionError)
|
|
447
|
+
{
|
|
448
|
+
try
|
|
449
|
+
{
|
|
450
|
+
if (assigned)
|
|
451
|
+
{
|
|
452
|
+
TerminateRemainingProcessesAndWait(job);
|
|
453
|
+
}
|
|
454
|
+
ConfirmContainment(confirmationPath);
|
|
455
|
+
}
|
|
456
|
+
catch (Exception containmentError)
|
|
457
|
+
{
|
|
458
|
+
throw new AggregateException(
|
|
459
|
+
"Windows process execution and containment both failed",
|
|
460
|
+
executionError, containmentError);
|
|
461
|
+
}
|
|
462
|
+
throw;
|
|
463
|
+
}
|
|
464
|
+
finally
|
|
465
|
+
{
|
|
466
|
+
if (process.hThread != IntPtr.Zero)
|
|
467
|
+
{
|
|
468
|
+
CloseHandle(process.hThread);
|
|
469
|
+
}
|
|
470
|
+
if (process.hProcess != IntPtr.Zero)
|
|
471
|
+
{
|
|
472
|
+
CloseHandle(process.hProcess);
|
|
473
|
+
}
|
|
474
|
+
if (jobHandleValue != IntPtr.Zero)
|
|
475
|
+
{
|
|
476
|
+
Marshal.FreeHGlobal(jobHandleValue);
|
|
477
|
+
}
|
|
478
|
+
if (environmentBlock != IntPtr.Zero)
|
|
479
|
+
{
|
|
480
|
+
Marshal.FreeHGlobal(environmentBlock);
|
|
481
|
+
}
|
|
482
|
+
if (attributeListInitialized)
|
|
483
|
+
{
|
|
484
|
+
DeleteProcThreadAttributeList(attributeList);
|
|
485
|
+
}
|
|
486
|
+
if (attributeList != IntPtr.Zero)
|
|
487
|
+
{
|
|
488
|
+
Marshal.FreeHGlobal(attributeList);
|
|
489
|
+
}
|
|
490
|
+
if (job != IntPtr.Zero)
|
|
491
|
+
{
|
|
492
|
+
CloseHandle(job);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
$ErrorActionPreference = "Stop"
|
|
2
|
+
$ProgressPreference = "SilentlyContinue"
|
|
3
|
+
|
|
4
|
+
try {
|
|
5
|
+
Add-Type -Path (Join-Path $PSScriptRoot "WindowsManagedProcess.cs")
|
|
6
|
+
$bootstrapRequest = [Console]::In.ReadToEnd() | ConvertFrom-Json
|
|
7
|
+
if ([int]$bootstrapRequest.schemaVersion -ne 1) {
|
|
8
|
+
throw "Unsupported Windows managed-process bootstrap schema."
|
|
9
|
+
}
|
|
10
|
+
$exitCode = [AgentTeams.Foundation.WindowsManagedProcess]::Run(
|
|
11
|
+
[string]$bootstrapRequest.nodeExecutable,
|
|
12
|
+
[string]$bootstrapRequest.processHostPath,
|
|
13
|
+
[string]$bootstrapRequest.encodedRequest,
|
|
14
|
+
[string]$bootstrapRequest.cwd,
|
|
15
|
+
[string[]]$bootstrapRequest.environmentEntries,
|
|
16
|
+
[string]$bootstrapRequest.cancellationPath,
|
|
17
|
+
[string]$bootstrapRequest.confirmationPath,
|
|
18
|
+
[string]$bootstrapRequest.launchPath)
|
|
19
|
+
exit $exitCode
|
|
20
|
+
} catch {
|
|
21
|
+
[Console]::Error.WriteLine(
|
|
22
|
+
"Windows Job Object runner failed: " + $_.Exception.Message)
|
|
23
|
+
exit 1
|
|
24
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { QualityGateCancellationSource, QualityGateOperatorCancellation } from "./quality-gate-cli.js";
|
|
2
|
+
export declare class NodeSignalQualityGateCancellationSource implements QualityGateCancellationSource {
|
|
3
|
+
subscribe(onCancellation: (cancellation: QualityGateOperatorCancellation) => void): () => void;
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=node-signal-cancellation-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-signal-cancellation-source.d.ts","sourceRoot":"","sources":["../../../../../../src/capabilities/quality-gate-runner/adapters/inbound/cli/node-signal-cancellation-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,+BAA+B,EAChC,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,uCACb,YAAW,6BAA6B;IACtC,SAAS,CACP,cAAc,EAAE,CAAC,YAAY,EAAE,+BAA+B,KAAK,IAAI,GACtE,MAAM,IAAI,CASZ;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class NodeSignalQualityGateCancellationSource {
|
|
2
|
+
subscribe(onCancellation) {
|
|
3
|
+
const onInterrupt = () => { onCancellation("interrupt"); };
|
|
4
|
+
const onTerminate = () => { onCancellation("terminate"); };
|
|
5
|
+
process.on("SIGINT", onInterrupt);
|
|
6
|
+
process.on("SIGTERM", onTerminate);
|
|
7
|
+
return () => {
|
|
8
|
+
process.removeListener("SIGINT", onInterrupt);
|
|
9
|
+
process.removeListener("SIGTERM", onTerminate);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=node-signal-cancellation-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-signal-cancellation-source.js","sourceRoot":"","sources":["../../../../../../src/capabilities/quality-gate-runner/adapters/inbound/cli/node-signal-cancellation-source.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,uCAAuC;IAElD,SAAS,CACP,cAAuE;QAEvE,MAAM,WAAW,GAAG,GAAG,EAAE,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3D,MAAM,WAAW,GAAG,GAAG,EAAE,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3D,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAClC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QACnC,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;YAC9C,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QACjD,CAAC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { QualityGateRunReport } from "../../../application/model/quality-gate-report.js";
|
|
2
|
+
export type QualityGateOperatorCancellation = "interrupt" | "terminate";
|
|
3
|
+
export interface QualityGateCancellationSource {
|
|
4
|
+
subscribe(onCancellation: (cancellation: QualityGateOperatorCancellation) => void): () => void;
|
|
5
|
+
}
|
|
6
|
+
export interface QualityGateCliProjection {
|
|
7
|
+
readonly exitCode: number;
|
|
8
|
+
readonly stderr: string;
|
|
9
|
+
readonly stdout: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function projectQualityGateSetupCancellation(format: "json" | "text", cancellation: QualityGateOperatorCancellation, canonicalFailureJson: string): QualityGateCliProjection;
|
|
12
|
+
export declare function projectQualityGateRun(report: QualityGateRunReport, format: "json" | "text", cancellation: QualityGateOperatorCancellation | undefined): QualityGateCliProjection;
|
|
13
|
+
//# sourceMappingURL=quality-gate-cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quality-gate-cli.d.ts","sourceRoot":"","sources":["../../../../../../src/capabilities/quality-gate-runner/adapters/inbound/cli/quality-gate-cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AAE9F,MAAM,MAAM,+BAA+B,GAAG,WAAW,GAAG,WAAW,CAAC;AAExE,MAAM,WAAW,6BAA6B;IAC5C,SAAS,CACP,cAAc,EAAE,CAAC,YAAY,EAAE,+BAA+B,KAAK,IAAI,GACtE,MAAM,IAAI,CAAC;CACf;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAgDD,wBAAgB,mCAAmC,CACjD,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,YAAY,EAAE,+BAA+B,EAC7C,oBAAoB,EAAE,MAAM,GAC3B,wBAAwB,CAQ1B;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,YAAY,EAAE,+BAA+B,GAAG,SAAS,GACxD,wBAAwB,CAQ1B"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
function cancellationExitCode(cancellation) {
|
|
2
|
+
return cancellation === "terminate" ? 143 : 130;
|
|
3
|
+
}
|
|
4
|
+
function exitCodeForQualityGateRun(report, cancellation) {
|
|
5
|
+
if (cancellation !== undefined && report.outcome !== "failed") {
|
|
6
|
+
return cancellationExitCode(cancellation);
|
|
7
|
+
}
|
|
8
|
+
if (report.outcome === "passed") {
|
|
9
|
+
return 0;
|
|
10
|
+
}
|
|
11
|
+
for (const task of report.tasks) {
|
|
12
|
+
if (task.outcome === "timed-out") {
|
|
13
|
+
return 124;
|
|
14
|
+
}
|
|
15
|
+
if (task.outcome === "failed") {
|
|
16
|
+
return task.exitCode === null || task.exitCode === 0 ? 1 : task.exitCode;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return cancellation === undefined ? 130 : cancellationExitCode(cancellation);
|
|
20
|
+
}
|
|
21
|
+
function renderQualityGateRunReport(report) {
|
|
22
|
+
const lines = [
|
|
23
|
+
`Quality gate profile: ${report.profileId}`,
|
|
24
|
+
`Outcome: ${report.outcome}`,
|
|
25
|
+
`Duration: ${report.durationMs}ms`
|
|
26
|
+
];
|
|
27
|
+
for (const task of report.tasks) {
|
|
28
|
+
const exit = task.exitCode === null ? "" : ` exit=${task.exitCode}`;
|
|
29
|
+
const signal = task.signal === null ? "" : ` signal=${task.signal}`;
|
|
30
|
+
lines.push(`- ${task.id}: ${task.outcome} (${task.durationMs}ms)${exit}${signal}`);
|
|
31
|
+
if (task.failureTail.length > 0) {
|
|
32
|
+
lines.push(task.failureTail);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return `${lines.join("\n")}\n`;
|
|
36
|
+
}
|
|
37
|
+
export function projectQualityGateSetupCancellation(format, cancellation, canonicalFailureJson) {
|
|
38
|
+
return Object.freeze({
|
|
39
|
+
exitCode: cancellationExitCode(cancellation),
|
|
40
|
+
stderr: format === "text" ? "Quality gate execution was cancelled.\n" : "",
|
|
41
|
+
stdout: format === "json"
|
|
42
|
+
? `${canonicalFailureJson}\n`
|
|
43
|
+
: ""
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export function projectQualityGateRun(report, format, cancellation) {
|
|
47
|
+
return Object.freeze({
|
|
48
|
+
exitCode: exitCodeForQualityGateRun(report, cancellation),
|
|
49
|
+
stderr: "",
|
|
50
|
+
stdout: format === "json"
|
|
51
|
+
? `${JSON.stringify(report, null, 2)}\n`
|
|
52
|
+
: renderQualityGateRunReport(report)
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=quality-gate-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quality-gate-cli.js","sourceRoot":"","sources":["../../../../../../src/capabilities/quality-gate-runner/adapters/inbound/cli/quality-gate-cli.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
+
import type { ManagedProcessResult, ProcessRequest } from "../../../../../process-execution/types.js";
|
|
1
2
|
import { type PackageScriptExecutor } from "../../../application/ports/package-script-executor.js";
|
|
2
3
|
export interface QualityGatePnpmEnvironment {
|
|
4
|
+
readonly childEnvironment: Readonly<NodeJS.ProcessEnv>;
|
|
3
5
|
readonly npmExecPath?: string;
|
|
4
6
|
readonly pnpmHome?: string;
|
|
5
7
|
readonly pathValue?: string;
|
|
6
8
|
}
|
|
9
|
+
interface QualityGateManagedProcessRequest extends ProcessRequest {
|
|
10
|
+
readonly environment: Readonly<NodeJS.ProcessEnv>;
|
|
11
|
+
}
|
|
12
|
+
export interface QualityGateManagedProcessExecutor {
|
|
13
|
+
run(request: QualityGateManagedProcessRequest): Promise<ManagedProcessResult>;
|
|
14
|
+
}
|
|
7
15
|
export declare class PnpmQualityGateScriptExecutor implements PackageScriptExecutor {
|
|
8
16
|
private readonly environment;
|
|
9
|
-
|
|
17
|
+
private readonly processExecutor;
|
|
18
|
+
constructor(environment: QualityGatePnpmEnvironment, processExecutor?: QualityGateManagedProcessExecutor);
|
|
10
19
|
run(input: {
|
|
11
20
|
readonly consumerRoot: string;
|
|
12
21
|
readonly scriptId: string;
|
|
@@ -19,4 +28,5 @@ export declare class PnpmQualityGateScriptExecutor implements PackageScriptExecu
|
|
|
19
28
|
exitCode: number | null;
|
|
20
29
|
}>;
|
|
21
30
|
}
|
|
31
|
+
export {};
|
|
22
32
|
//# sourceMappingURL=pnpm-package-script-executor.d.ts.map
|