@tracecode/harness 0.16.4 → 0.16.5
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/CHANGELOG.md +28 -0
- package/README.md +6 -4
- package/dist/{browser-runtime-provider-OGJQLGXU.js → browser-runtime-provider-POTAJULA.js} +5 -5
- package/dist/{chunk-DTLDQQHA.js → chunk-5KH5ABPQ.js} +72 -1
- package/dist/{chunk-RCOPAMVR.js → chunk-GX4SGR3L.js} +56 -36
- package/dist/{chunk-AAKNIYV6.js → chunk-I2JLGVMT.js} +3 -3
- package/dist/{chunk-M7SNEZDR.js → chunk-JPDVJCVS.js} +3 -3
- package/dist/{chunk-Y72C46GE.js → chunk-NHGF353L.js} +20 -11
- package/dist/{chunk-5RT5IT4I.js → chunk-OXFBZTWZ.js} +15 -31
- package/dist/{chunk-6LE4KEMZ.js → chunk-P5FQOYM4.js} +489 -3
- package/dist/core.cjs +19 -10
- package/dist/core.js +1 -1
- package/dist/cpp-worker-client-SKBOLX5Q.js +12 -0
- package/dist/{csharp-worker-client-ARGMOB3M.js → csharp-worker-client-GAUCDYVS.js} +4 -4
- package/dist/internal/browser.cjs +72 -0
- package/dist/internal/browser.d.cts +19 -1
- package/dist/internal/browser.d.ts +19 -1
- package/dist/internal/browser.js +3 -1
- package/dist/internal/tracekernel-workspace.cjs +19 -10
- package/dist/internal/tracekernel-workspace.js +1 -1
- package/dist/{java-project-JB5TUIFU.js → java-project-ASCLR77F.js} +2 -2
- package/dist/judge.cjs +884 -89
- package/dist/judge.d.cts +4 -0
- package/dist/judge.d.ts +4 -0
- package/dist/judge.js +236 -23
- package/dist/{project-browser-S4KLCZV7.js → project-browser-7MVLDAHN.js} +2 -2
- package/dist/{project-browser-3S2FWEAP.js → project-browser-DKMZFGCJ.js} +2 -2
- package/dist/{project-browser-HCQCXAYC.js → project-browser-VSLHVOH4.js} +2 -2
- package/dist/{project-browser-WDUWUGLZ.js → project-browser-XKQ2MNK3.js} +2 -2
- package/dist/{project-browser-QN7YOJQQ.js → project-browser-YUBOA2Q4.js} +2 -2
- package/dist/{python-worker-client-EX6Q2W4L.js → python-worker-client-R7K7HDO7.js} +4 -4
- package/dist/tracekernel.cjs +650 -68
- package/dist/tracekernel.js +4 -4
- package/package.json +14 -5
- package/runtime-assets.lock.json +77 -70
- package/workers/cpp/cpp-worker.js +53 -43
- package/workers/csharp/csharp-worker.js +150 -1
- package/workers/javascript/javascript-project-worker.js +18 -9
- package/workers/python/python-worker.js +121 -1
- package/workers/vendor/csharp/_framework/TraceCode.CSharpHost.wasm +0 -0
- package/workers/vendor/csharp/_framework/TraceCode.CSharpJudgeRuntime.wasm +0 -0
- package/workers/vendor/csharp/_framework/TraceCode.TraceClrWire.wasm +0 -0
- package/workers/vendor/csharp/_framework/dotnet.boot.js +11 -6
- package/workers/vendor/csharp/_framework/dotnet.native.wasm +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/TraceCode.CSharpHost.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/TraceCode.CSharpJudgeRuntime.dll +0 -0
- package/workers/vendor/csharp-runner/_framework/assemblies-02.pack +0 -0
- package/workers/vendor/csharp-runner/_framework/assemblies-03.pack +0 -0
- package/workers/vendor/csharp-runner/_framework/dotnet.boot.js +65 -65
- package/dist/cpp-worker-client-HV7RO2P5.js +0 -12
|
@@ -5,6 +5,8 @@ let executeExport = null;
|
|
|
5
5
|
let prepareExport = null;
|
|
6
6
|
let executePreparedExport = null;
|
|
7
7
|
let executePreparedUtf8Export = null;
|
|
8
|
+
let executeAlgorithmPreparedExport = null;
|
|
9
|
+
let executeAlgorithmPreparedTraceExport = null;
|
|
8
10
|
let disposePreparedArtifactExport = null;
|
|
9
11
|
let executeProjectExport = null;
|
|
10
12
|
let getCompiledArtifactKeyExport = null;
|
|
@@ -3194,6 +3196,11 @@ function runCompilerPrime() {
|
|
|
3194
3196
|
compiledArtifactKey: result.compiledArtifactKey,
|
|
3195
3197
|
compiledArtifactBase64: result.compiledArtifactBase64,
|
|
3196
3198
|
compiledArtifactSha256: result.compiledArtifactSha256,
|
|
3199
|
+
preparedRunnerTier: result.preparedRunnerTier,
|
|
3200
|
+
preparedRunnerReason: result.preparedRunnerReason,
|
|
3201
|
+
...(result.traceClrWireContract
|
|
3202
|
+
? { traceClrWireContract: result.traceClrWireContract }
|
|
3203
|
+
: {}),
|
|
3197
3204
|
},
|
|
3198
3205
|
};
|
|
3199
3206
|
}
|
|
@@ -3208,6 +3215,8 @@ function requiredExportsForRole() {
|
|
|
3208
3215
|
if (configuredRuntimeRole === 'runner') {
|
|
3209
3216
|
return [
|
|
3210
3217
|
['ExecutePrepared', executePreparedExport],
|
|
3218
|
+
['ExecuteAlgorithmPrepared', executeAlgorithmPreparedExport],
|
|
3219
|
+
['ExecuteAlgorithmPreparedTrace', executeAlgorithmPreparedTraceExport],
|
|
3211
3220
|
['DisposePreparedArtifact', disposePreparedArtifactExport],
|
|
3212
3221
|
];
|
|
3213
3222
|
}
|
|
@@ -3590,6 +3599,8 @@ async function loadRuntime(assetBaseUrl) {
|
|
|
3590
3599
|
prepareExport = exports?.TraceCode?.CSharpHost?.CompilerHost?.Prepare;
|
|
3591
3600
|
const preparedExecutionHost =
|
|
3592
3601
|
exports?.TraceCode?.CSharpHost?.PreparedExecutionHost;
|
|
3602
|
+
const algorithmExecutionHost =
|
|
3603
|
+
exports?.TraceCode?.CSharpHost?.AlgorithmExecutionHost;
|
|
3593
3604
|
executePreparedExport =
|
|
3594
3605
|
configuredRuntimeRole === 'runner'
|
|
3595
3606
|
? preparedExecutionHost?.ExecutePrepared
|
|
@@ -3598,6 +3609,14 @@ async function loadRuntime(assetBaseUrl) {
|
|
|
3598
3609
|
configuredRuntimeRole === 'runner'
|
|
3599
3610
|
? preparedExecutionHost?.ExecutePreparedUtf8
|
|
3600
3611
|
: null;
|
|
3612
|
+
executeAlgorithmPreparedExport =
|
|
3613
|
+
configuredRuntimeRole === 'runner'
|
|
3614
|
+
? algorithmExecutionHost?.ExecutePrepared
|
|
3615
|
+
: null;
|
|
3616
|
+
executeAlgorithmPreparedTraceExport =
|
|
3617
|
+
configuredRuntimeRole === 'runner'
|
|
3618
|
+
? algorithmExecutionHost?.ExecutePreparedTrace
|
|
3619
|
+
: null;
|
|
3601
3620
|
disposePreparedArtifactExport =
|
|
3602
3621
|
configuredRuntimeRole === 'runner'
|
|
3603
3622
|
? preparedExecutionHost?.DisposePreparedArtifact
|
|
@@ -3620,6 +3639,8 @@ async function loadRuntime(assetBaseUrl) {
|
|
|
3620
3639
|
prepareExport = null;
|
|
3621
3640
|
executePreparedExport = null;
|
|
3622
3641
|
executePreparedUtf8Export = null;
|
|
3642
|
+
executeAlgorithmPreparedExport = null;
|
|
3643
|
+
executeAlgorithmPreparedTraceExport = null;
|
|
3623
3644
|
disposePreparedArtifactExport = null;
|
|
3624
3645
|
executeProjectExport = null;
|
|
3625
3646
|
getCompiledArtifactKeyExport = null;
|
|
@@ -3912,6 +3933,7 @@ async function prepareCSharpProgram(message) {
|
|
|
3912
3933
|
maxPathDepth: payload.traceOptions?.maxPathDepth,
|
|
3913
3934
|
minimalTrace: payload.traceOptions?.minimalTrace,
|
|
3914
3935
|
preparedProgram: true,
|
|
3936
|
+
allowAlgorithmFast: configuredRuntimeRole === 'compiler',
|
|
3915
3937
|
};
|
|
3916
3938
|
const runtimeStartedAt = now();
|
|
3917
3939
|
const runtimeResult = await loadRuntime(payload.assetBaseUrl);
|
|
@@ -3929,7 +3951,14 @@ async function prepareCSharpProgram(message) {
|
|
|
3929
3951
|
typeof result.compiledArtifactBase64 !== 'string' ||
|
|
3930
3952
|
!result.compiledArtifactBase64 ||
|
|
3931
3953
|
typeof result.compiledArtifactSha256 !== 'string' ||
|
|
3932
|
-
!/^[0-9a-f]{64}$/.test(result.compiledArtifactSha256)
|
|
3954
|
+
!/^[0-9a-f]{64}$/.test(result.compiledArtifactSha256) ||
|
|
3955
|
+
!['algorithm-fast', 'compatibility'].includes(
|
|
3956
|
+
result.preparedRunnerTier
|
|
3957
|
+
) ||
|
|
3958
|
+
typeof result.preparedRunnerReason !== 'string' ||
|
|
3959
|
+
!result.preparedRunnerReason ||
|
|
3960
|
+
(result.preparedRunnerTier === 'algorithm-fast' &&
|
|
3961
|
+
!result.traceClrWireContract)
|
|
3933
3962
|
)
|
|
3934
3963
|
) {
|
|
3935
3964
|
return {
|
|
@@ -3995,10 +4024,130 @@ async function executePreparedCSharpProgram(message) {
|
|
|
3995
4024
|
compiledArtifactKey: prepared.compiledArtifactKey,
|
|
3996
4025
|
compiledArtifactBase64: prepared.compiledArtifactBase64,
|
|
3997
4026
|
compiledArtifactSha256: prepared.compiledArtifactSha256,
|
|
4027
|
+
preparedRunnerTier: prepared.preparedRunnerTier ?? 'compatibility',
|
|
3998
4028
|
};
|
|
3999
4029
|
const runtimeStartedAt = now();
|
|
4000
4030
|
const runtimeResult = await loadRuntime(payload.assetBaseUrl);
|
|
4001
4031
|
const initMs = elapsedMs(runtimeStartedAt) || runtimeResult.timings?.initMs || 0;
|
|
4032
|
+
if (request.preparedRunnerTier === 'algorithm-fast') {
|
|
4033
|
+
if (
|
|
4034
|
+
configuredRuntimeRole !== 'runner' ||
|
|
4035
|
+
typeof executeAlgorithmPreparedExport !== 'function'
|
|
4036
|
+
) {
|
|
4037
|
+
return {
|
|
4038
|
+
success: false,
|
|
4039
|
+
error: 'The prepared C# program requires an algorithm-fast runner.',
|
|
4040
|
+
consoleOutput: [],
|
|
4041
|
+
timings: {
|
|
4042
|
+
initMs,
|
|
4043
|
+
totalMs: elapsedMs(startedAt),
|
|
4044
|
+
preparedRunnerTier: 'algorithm-fast',
|
|
4045
|
+
},
|
|
4046
|
+
};
|
|
4047
|
+
}
|
|
4048
|
+
if (!(payload.inputBytes instanceof Uint8Array)) {
|
|
4049
|
+
return {
|
|
4050
|
+
success: false,
|
|
4051
|
+
error: 'The algorithm-fast C# runner requires a binary input payload.',
|
|
4052
|
+
consoleOutput: [],
|
|
4053
|
+
timings: {
|
|
4054
|
+
initMs,
|
|
4055
|
+
totalMs: elapsedMs(startedAt),
|
|
4056
|
+
preparedRunnerTier: 'algorithm-fast',
|
|
4057
|
+
},
|
|
4058
|
+
};
|
|
4059
|
+
}
|
|
4060
|
+
const hostCallStartedAt = now();
|
|
4061
|
+
try {
|
|
4062
|
+
if (request.trace) {
|
|
4063
|
+
const exportedJson = await withCSharpUserAuthorityLockdown(() =>
|
|
4064
|
+
executeAlgorithmPreparedTraceExport(
|
|
4065
|
+
request.compiledArtifactBase64,
|
|
4066
|
+
request.compiledArtifactSha256,
|
|
4067
|
+
payload.inputBytes,
|
|
4068
|
+
request.source,
|
|
4069
|
+
request.timeoutMs ?? 5_000,
|
|
4070
|
+
request.maxTraceSteps ?? 0,
|
|
4071
|
+
request.maxLineEvents ?? 0,
|
|
4072
|
+
request.maxSingleLineHits ?? 0,
|
|
4073
|
+
request.maxStoredEvents ?? 0,
|
|
4074
|
+
request.minimalTrace === true,
|
|
4075
|
+
request.recordTrace === true
|
|
4076
|
+
)
|
|
4077
|
+
);
|
|
4078
|
+
const parsed = JSON.parse(exportedJson);
|
|
4079
|
+
const outputBytes = typeof parsed.outputBytes === 'string'
|
|
4080
|
+
? Uint8Array.from(
|
|
4081
|
+
atob(parsed.outputBytes),
|
|
4082
|
+
(character) => character.charCodeAt(0)
|
|
4083
|
+
)
|
|
4084
|
+
: undefined;
|
|
4085
|
+
const result = normalizeCSharpResult(
|
|
4086
|
+
{ ...parsed, outputBytes },
|
|
4087
|
+
request
|
|
4088
|
+
);
|
|
4089
|
+
return {
|
|
4090
|
+
...result,
|
|
4091
|
+
consoleOutput: [],
|
|
4092
|
+
timings: {
|
|
4093
|
+
initMs,
|
|
4094
|
+
hostCallMs: elapsedMs(hostCallStartedAt),
|
|
4095
|
+
runMs: elapsedMs(hostCallStartedAt),
|
|
4096
|
+
executionRealm: 'disposable-worker',
|
|
4097
|
+
compileCacheHit: true,
|
|
4098
|
+
artifactCacheHit: true,
|
|
4099
|
+
preparedRunnerTier: 'algorithm-fast',
|
|
4100
|
+
...runtimeMemoryTimings(),
|
|
4101
|
+
totalMs: elapsedMs(startedAt),
|
|
4102
|
+
},
|
|
4103
|
+
};
|
|
4104
|
+
}
|
|
4105
|
+
const outputBytes = await withCSharpUserAuthorityLockdown(() =>
|
|
4106
|
+
executeAlgorithmPreparedExport(
|
|
4107
|
+
request.compiledArtifactBase64,
|
|
4108
|
+
request.compiledArtifactSha256,
|
|
4109
|
+
payload.inputBytes
|
|
4110
|
+
)
|
|
4111
|
+
);
|
|
4112
|
+
return {
|
|
4113
|
+
success: true,
|
|
4114
|
+
outputBytes,
|
|
4115
|
+
consoleOutput: [],
|
|
4116
|
+
timings: {
|
|
4117
|
+
initMs,
|
|
4118
|
+
hostCallMs: elapsedMs(hostCallStartedAt),
|
|
4119
|
+
runMs: elapsedMs(hostCallStartedAt),
|
|
4120
|
+
executionRealm: 'disposable-worker',
|
|
4121
|
+
compileCacheHit: true,
|
|
4122
|
+
artifactCacheHit: true,
|
|
4123
|
+
preparedRunnerTier: 'algorithm-fast',
|
|
4124
|
+
...runtimeMemoryTimings(),
|
|
4125
|
+
totalMs: elapsedMs(startedAt),
|
|
4126
|
+
},
|
|
4127
|
+
};
|
|
4128
|
+
} catch (error) {
|
|
4129
|
+
const message = formatCSharpWorkerError(error);
|
|
4130
|
+
const invalidArtifact = message.includes('Prepared TraceCLR artifact');
|
|
4131
|
+
return {
|
|
4132
|
+
success: false,
|
|
4133
|
+
error: invalidArtifact
|
|
4134
|
+
? 'Prepared C# artifact is unavailable or invalid.'
|
|
4135
|
+
: message,
|
|
4136
|
+
consoleOutput: [],
|
|
4137
|
+
timings: {
|
|
4138
|
+
initMs,
|
|
4139
|
+
hostCallMs: elapsedMs(hostCallStartedAt),
|
|
4140
|
+
runMs: elapsedMs(hostCallStartedAt),
|
|
4141
|
+
executionRealm: 'disposable-worker',
|
|
4142
|
+
compileCacheHit: !invalidArtifact,
|
|
4143
|
+
artifactCacheHit: !invalidArtifact,
|
|
4144
|
+
preparedRunnerTier: 'algorithm-fast',
|
|
4145
|
+
...runtimeMemoryTimings(),
|
|
4146
|
+
totalMs: elapsedMs(startedAt),
|
|
4147
|
+
},
|
|
4148
|
+
};
|
|
4149
|
+
}
|
|
4150
|
+
}
|
|
4002
4151
|
const hostCallStartedAt = now();
|
|
4003
4152
|
const result = await withCSharpUserAuthorityLockdown(() => {
|
|
4004
4153
|
const requestJson = JSON.stringify(request);
|
|
@@ -1621,7 +1621,7 @@ var TraceKernelRuntimeFileClient = class {
|
|
|
1621
1621
|
// package.json
|
|
1622
1622
|
var package_default = {
|
|
1623
1623
|
name: "@tracecode/harness",
|
|
1624
|
-
version: "0.16.
|
|
1624
|
+
version: "0.16.5",
|
|
1625
1625
|
license: "AGPL-3.0-only",
|
|
1626
1626
|
homepage: "https://tracecode.app",
|
|
1627
1627
|
repository: {
|
|
@@ -1689,6 +1689,15 @@ var package_default = {
|
|
|
1689
1689
|
"build:browser-host": "pnpm exec tsup --config tsup.browser-host.config.ts",
|
|
1690
1690
|
"build:tracekernel": "pnpm exec tsup --config tsup.tracekernel.config.ts",
|
|
1691
1691
|
"generate:runtime-info": "pnpm exec tsx --tsconfig tsconfig.base.json scripts/generate-runtime-language-info.ts",
|
|
1692
|
+
"generate:traceclr-profile": "node scripts/generate-traceclr-algorithm-profile.mjs",
|
|
1693
|
+
"audit:traceclr-corpus": "node scripts/audit-traceclr-corpus.mjs",
|
|
1694
|
+
"build:traceclr-product-corpus": "node scripts/create-traceclr-product-corpus.mjs",
|
|
1695
|
+
"check:traceclr-profile": "node --test tests/test-traceclr-algorithm-profile.mjs tests/test-traceclr-profile-policy.mjs && node --import tsx tests/test-traceclr-wire-codec.ts",
|
|
1696
|
+
"check:traceclr-product-profile": "node scripts/generate-traceclr-algorithm-profile.mjs --check && pnpm check:traceclr-profile",
|
|
1697
|
+
"build:traceclr-wire-probe": "dotnet build tools/TraceCode.TraceClrWireProbe/TraceCode.TraceClrWireProbe.csproj -c Release && dotnet build tools/TraceCode.TraceClrHostileProbe/TraceCode.TraceClrHostileProbe.csproj -c Release && dotnet publish packages/runtime-csharp/dotnet/TraceCode.CSharpAlgorithmRunner/TraceCode.CSharpAlgorithmRunner.csproj -c Release",
|
|
1698
|
+
"test:traceclr-wire-browser": "pnpm build:traceclr-wire-probe && TRACECODE_TRACECLR_BROWSER_ENGINE=chromium node --import tsx tests/test-traceclr-wire-runner-browser.ts && TRACECODE_TRACECLR_BROWSER_ENGINE=firefox node --import tsx tests/test-traceclr-wire-runner-browser.ts && TRACECODE_TRACECLR_BROWSER_ENGINE=webkit node --import tsx tests/test-traceclr-wire-runner-browser.ts",
|
|
1699
|
+
"bench:traceclr-tiers": "pnpm build:traceclr-wire-probe && pnpm materialize:csharp-role-assets && node --import tsx scripts/benchmark-traceclr-runtime-tiers.ts",
|
|
1700
|
+
"bench:traceclr-tiers:matrix": "pnpm build:traceclr-wire-probe && pnpm materialize:csharp-role-assets && for engine in chromium firefox webkit; do TRACECODE_TRACECLR_BROWSER_ENGINE=$engine node --import tsx scripts/benchmark-traceclr-runtime-tiers.ts || exit; done",
|
|
1692
1701
|
"generate:runtime-open-source-info": "pnpm exec tsx --tsconfig tsconfig.base.json scripts/generate-runtime-open-source-info.ts",
|
|
1693
1702
|
"generate:python-harness": "pnpm exec tsx --tsconfig tsconfig.base.json scripts/generate-python-harness-artifacts.ts",
|
|
1694
1703
|
"generate:runtime-assets-lock": "node --import tsx scripts/generate-runtime-assets-lock.mjs",
|
|
@@ -1752,10 +1761,10 @@ var package_default = {
|
|
|
1752
1761
|
"test:java-runtime": "pnpm exec tsx --tsconfig tsconfig.base.json tests/test-java-runtime.ts && pnpm exec tsx --tsconfig tsconfig.base.json tests/test-java-project-filesystem.ts && node --import tsx --test tests/test-java-jar-manifest.ts && pnpm exec tsx --tsconfig tsconfig.base.json tests/test-java-project-provider.ts && TSX_TSCONFIG_PATH=tsconfig.base.json node --import tsx --test tests/test-java-prepared-provider.ts",
|
|
1753
1762
|
"test:java-prepared-provider": "TSX_TSCONFIG_PATH=tsconfig.base.json node --import tsx --test tests/test-java-prepared-provider.ts && pnpm exec tsx --tsconfig tsconfig.base.json tests/test-java-prepared-provider-browser.ts",
|
|
1754
1763
|
"test:tracejvm-semantic-trace": "node --import tsx tests/test-tracejvm-semantic-trace-matrix.ts",
|
|
1755
|
-
"test:csharp-runtime": "pnpm exec tsx --tsconfig tsconfig.base.json scripts/validate-csharp-runtime-role-assets.ts && TSX_TSCONFIG_PATH=tsconfig.base.json node --import tsx --test tests/test-csharp-role-artifacts.ts tests/test-csharp-managed-assembly-packs.ts && pnpm exec tsx --tsconfig tsconfig.base.json tests/test-csharp-runtime.ts && TSX_TSCONFIG_PATH=tsconfig.base.json node --import tsx --test tests/test-csharp-prepared-provider.ts && pnpm exec tsx --tsconfig tsconfig.base.json tests/test-csharp-project-fs-parity.ts",
|
|
1764
|
+
"test:csharp-runtime": "pnpm check:traceclr-profile && pnpm exec tsx --tsconfig tsconfig.base.json scripts/validate-csharp-runtime-role-assets.ts && TSX_TSCONFIG_PATH=tsconfig.base.json node --import tsx --test tests/test-csharp-role-artifacts.ts tests/test-csharp-managed-assembly-packs.ts && pnpm exec tsx --tsconfig tsconfig.base.json tests/test-csharp-runtime.ts && TSX_TSCONFIG_PATH=tsconfig.base.json node --import tsx --test tests/test-csharp-prepared-provider.ts && pnpm exec tsx --tsconfig tsconfig.base.json tests/test-csharp-project-fs-parity.ts",
|
|
1756
1765
|
"test:csharp-role-assets": "pnpm materialize:csharp-role-assets && TSX_TSCONFIG_PATH=tsconfig.base.json node --import tsx --test tests/test-csharp-role-artifacts.ts tests/test-csharp-managed-assembly-packs.ts && pnpm exec tsx --tsconfig tsconfig.base.json scripts/validate-csharp-runtime-role-assets.ts",
|
|
1757
1766
|
"test:csharp-worker-browser": "pnpm materialize:csharp-role-assets && pnpm exec tsx --tsconfig tsconfig.base.json tests/test-csharp-worker-client-http.ts && pnpm exec tsx --tsconfig tsconfig.base.json tests/test-csharp-worker-browser.ts && pnpm exec tsx --tsconfig tsconfig.base.json tests/test-csharp-worker-lifecycle-browser.ts && pnpm exec tsx --tsconfig tsconfig.base.json tests/test-csharp-prepared-boundary-browser.ts",
|
|
1758
|
-
"test:csharp-worker-browser-matrix": "pnpm materialize:csharp-role-assets &&
|
|
1767
|
+
"test:csharp-worker-browser-matrix": "pnpm materialize:csharp-role-assets && for engine in chromium firefox webkit; do TSX_TSCONFIG_PATH=tsconfig.base.json TRACECODE_CSHARP_BROWSER_SMOKE=1 TRACECODE_CSHARP_BROWSER_ENGINE=$engine node --import tsx tests/test-csharp-worker-browser.ts && TSX_TSCONFIG_PATH=tsconfig.base.json TRACECODE_CSHARP_BROWSER_ENGINE=$engine node --import tsx tests/test-csharp-prepared-boundary-browser.ts || exit; done",
|
|
1759
1768
|
"test:cpp-runtime": "pnpm exec tsx --tsconfig tsconfig.base.json tests/test-cpp-runtime.ts",
|
|
1760
1769
|
"test:cpp-conformance": "pnpm exec tsx --tsconfig tsconfig.base.json tests/test-cpp-conformance.ts",
|
|
1761
1770
|
"test:cpp-script-lambda-trace": "pnpm exec tsx --tsconfig tsconfig.base.json tests/test-cpp-script-lambda-trace.ts",
|
|
@@ -1878,7 +1887,7 @@ var LANGUAGE_RUNTIME_INFOS = Object.freeze(
|
|
|
1878
1887
|
"versionLabel": "Python 3.13.2",
|
|
1879
1888
|
"executionPlatform": {
|
|
1880
1889
|
"name": "TraceKernel",
|
|
1881
|
-
"version": "0.16.
|
|
1890
|
+
"version": "0.16.5"
|
|
1882
1891
|
},
|
|
1883
1892
|
"description": "Python 3.13.2 runs in TraceKernel's isolated Python runtime.\n\nCommon algorithm helpers are imported automatically, including array, bisect, collections, functools, heapq, itertools. Other standard-library modules can be imported normally.\n\nOptional third-party packages are consumer-owned runtime assets and are available only when declared by the TraceKernel runtime manifest.",
|
|
1884
1893
|
"runtime": {
|
|
@@ -1905,7 +1914,7 @@ var LANGUAGE_RUNTIME_INFOS = Object.freeze(
|
|
|
1905
1914
|
"versionLabel": "JavaScript (ECMAScript 2023)",
|
|
1906
1915
|
"executionPlatform": {
|
|
1907
1916
|
"name": "TraceKernel",
|
|
1908
|
-
"version": "0.16.
|
|
1917
|
+
"version": "0.16.5"
|
|
1909
1918
|
},
|
|
1910
1919
|
"runtime": {
|
|
1911
1920
|
"name": "TraceKernel JavaScript runtime",
|
|
@@ -1997,7 +2006,7 @@ Binary Search Tree, Trie, and Graph are bundled too, but are not exposed globall
|
|
|
1997
2006
|
"versionLabel": "TypeScript 5.9.3",
|
|
1998
2007
|
"executionPlatform": {
|
|
1999
2008
|
"name": "TraceKernel",
|
|
2000
|
-
"version": "0.16.
|
|
2009
|
+
"version": "0.16.5"
|
|
2001
2010
|
},
|
|
2002
2011
|
"description": `TypeScript 5.9.3 is compiled with the TypeScript compiler and executed by TraceKernel's JavaScript runtime.
|
|
2003
2012
|
|
|
@@ -2097,7 +2106,7 @@ The compiled output runs on the same TraceKernel execution lane as JavaScript su
|
|
|
2097
2106
|
"versionLabel": "Java 23",
|
|
2098
2107
|
"executionPlatform": {
|
|
2099
2108
|
"name": "TraceKernel",
|
|
2100
|
-
"version": "0.16.
|
|
2109
|
+
"version": "0.16.5"
|
|
2101
2110
|
},
|
|
2102
2111
|
"description": "Java 23 is compiled with javac 23 and executed by the Java runtime on TraceKernel.\n\nCommon imports are added automatically: java.util.*, java.io.*, java.math.*, java.util.stream.*, javafx.util.Pair.",
|
|
2103
2112
|
"runtime": {
|
|
@@ -2134,7 +2143,7 @@ The compiled output runs on the same TraceKernel execution lane as JavaScript su
|
|
|
2134
2143
|
"versionLabel": "C# 14",
|
|
2135
2144
|
"executionPlatform": {
|
|
2136
2145
|
"name": "TraceKernel",
|
|
2137
|
-
"version": "0.16.
|
|
2146
|
+
"version": "0.16.5"
|
|
2138
2147
|
},
|
|
2139
2148
|
"description": "C# 14 source is compiled and executed by TraceKernel's isolated C# runtime.\n\nCommon namespaces are imported automatically: System, System.Collections, System.Collections.Generic, System.IO, System.Linq, System.Numerics, System.Text, System.Text.RegularExpressions.",
|
|
2140
2149
|
"runtime": {
|
|
@@ -2163,7 +2172,7 @@ The compiled output runs on the same TraceKernel execution lane as JavaScript su
|
|
|
2163
2172
|
"versionLabel": "C++23",
|
|
2164
2173
|
"executionPlatform": {
|
|
2165
2174
|
"name": "TraceKernel",
|
|
2166
|
-
"version": "0.16.
|
|
2175
|
+
"version": "0.16.5"
|
|
2167
2176
|
},
|
|
2168
2177
|
"description": "C++ source is compiled using the C++23 standard.\n\nSubmissions compile to WebAssembly and run in TraceKernel's WASI execution lane. The compiler currently uses -O0 and -fno-exceptions, with a fixed program stack size.\n\nCommon standard library headers are included automatically, including <algorithm>, <array>, <bitset>, <climits>, <cmath>, <cstdint>, <functional>, <limits>, <numeric>, <sstream>, <tuple>, <vector>, <unordered_map>, <unordered_set> and more.",
|
|
2169
2178
|
"runtime": {
|
|
@@ -40,6 +40,16 @@ const DECLARED_PYTHON_WORKER_FORMAT = (() => {
|
|
|
40
40
|
return 'classic';
|
|
41
41
|
}
|
|
42
42
|
})();
|
|
43
|
+
const DECLARED_PYTHON_WORKER_ROLE = (() => {
|
|
44
|
+
try {
|
|
45
|
+
const search = typeof self.location?.search === 'string' ? self.location.search : '';
|
|
46
|
+
return new URLSearchParams(search).get('tracecodePythonRole') === 'runtime-image'
|
|
47
|
+
? 'runtime-image'
|
|
48
|
+
: 'execution';
|
|
49
|
+
} catch {
|
|
50
|
+
return 'execution';
|
|
51
|
+
}
|
|
52
|
+
})();
|
|
43
53
|
const CONFIGURED_PYTHON_SNIPPETS_BOOTSTRAP_URL = (() => {
|
|
44
54
|
try {
|
|
45
55
|
const search = typeof self.location?.search === 'string' ? self.location.search : '';
|
|
@@ -127,6 +137,79 @@ function configurePythonRuntimeImage(value) {
|
|
|
127
137
|
};
|
|
128
138
|
}
|
|
129
139
|
|
|
140
|
+
function assertPythonRuntimeImageAssetDescriptor(name, value) {
|
|
141
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
142
|
+
throw new Error(`Python runtime image ${name} descriptor is required.`);
|
|
143
|
+
}
|
|
144
|
+
if (typeof value.url !== 'string' || !value.url.trim()) {
|
|
145
|
+
throw new Error(`Python runtime image ${name} URL is required.`);
|
|
146
|
+
}
|
|
147
|
+
if (typeof value.integrity !== 'string' || !value.integrity.startsWith('sha256-')) {
|
|
148
|
+
throw new Error(`Python runtime image ${name} requires SHA-256 integrity.`);
|
|
149
|
+
}
|
|
150
|
+
if (!Number.isSafeInteger(value.size) || value.size <= 0) {
|
|
151
|
+
throw new Error(`Python runtime image ${name} requires a positive decoded size.`);
|
|
152
|
+
}
|
|
153
|
+
return value;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async function fetchPythonRuntimeImageBytes(name, descriptor) {
|
|
157
|
+
const response = await fetch(descriptor.url, {
|
|
158
|
+
cache: 'force-cache',
|
|
159
|
+
credentials: 'omit',
|
|
160
|
+
redirect: 'error',
|
|
161
|
+
integrity: descriptor.integrity,
|
|
162
|
+
});
|
|
163
|
+
if (!response.ok || response.type === 'opaque') {
|
|
164
|
+
throw new Error(
|
|
165
|
+
`Python runtime image ${name} request returned HTTP ${response.status}.`
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
169
|
+
if (bytes.byteLength !== descriptor.size) {
|
|
170
|
+
throw new Error(
|
|
171
|
+
`Python runtime image ${name} decoded size ${bytes.byteLength} did not match declared size ${descriptor.size}.`
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
return bytes;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async function buildPythonRuntimeImageInWorker(payload) {
|
|
178
|
+
if (payload?.source !== 'tracecode-python-runtime-image-v1') {
|
|
179
|
+
throw new Error(
|
|
180
|
+
'Python runtime-image bootstrap only accepts the fixed image protocol.'
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
const descriptor = payload?.descriptor;
|
|
184
|
+
if (
|
|
185
|
+
!descriptor ||
|
|
186
|
+
descriptor.protocolVersion !== PYTHON_RUNTIME_IMAGE_PROTOCOL_VERSION ||
|
|
187
|
+
typeof descriptor.pythonHashSeed !== 'string' ||
|
|
188
|
+
!descriptor.pythonHashSeed.trim()
|
|
189
|
+
) {
|
|
190
|
+
throw new Error('Python runtime-image bootstrap descriptor is invalid.');
|
|
191
|
+
}
|
|
192
|
+
const wasmDescriptor = assertPythonRuntimeImageAssetDescriptor(
|
|
193
|
+
'Wasm',
|
|
194
|
+
descriptor.wasm
|
|
195
|
+
);
|
|
196
|
+
const snapshotDescriptor = assertPythonRuntimeImageAssetDescriptor(
|
|
197
|
+
'snapshot',
|
|
198
|
+
descriptor.snapshot
|
|
199
|
+
);
|
|
200
|
+
const [wasmBytes, snapshot] = await Promise.all([
|
|
201
|
+
fetchPythonRuntimeImageBytes('Wasm', wasmDescriptor),
|
|
202
|
+
fetchPythonRuntimeImageBytes('snapshot', snapshotDescriptor),
|
|
203
|
+
]);
|
|
204
|
+
const compiledModule = await WebAssembly.compile(wasmBytes);
|
|
205
|
+
return {
|
|
206
|
+
protocolVersion: PYTHON_RUNTIME_IMAGE_PROTOCOL_VERSION,
|
|
207
|
+
compiledModule,
|
|
208
|
+
snapshot,
|
|
209
|
+
pythonHashSeed: descriptor.pythonHashSeed,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
130
213
|
function pyodideInitializationOptions(indexURL) {
|
|
131
214
|
if (!configuredPythonRuntimeImage) return { indexURL };
|
|
132
215
|
const advertisedProtocol = DECLARED_PYTHON_WORKER_FORMAT === 'module'
|
|
@@ -510,7 +593,11 @@ async function ensurePythonLibraryPackages(runtime) {
|
|
|
510
593
|
|
|
511
594
|
// Load generated shared harness snippets when available. Keep worker startup
|
|
512
595
|
// resilient by falling back to embedded implementations if this import fails.
|
|
513
|
-
if (
|
|
596
|
+
if (
|
|
597
|
+
DECLARED_PYTHON_WORKER_ROLE === 'execution' &&
|
|
598
|
+
DECLARED_PYTHON_WORKER_FORMAT === 'classic' &&
|
|
599
|
+
typeof importScripts === 'function'
|
|
600
|
+
) {
|
|
514
601
|
for (const scriptPath of SHARED_KERNEL_POLICY_CLASSIC_PATHS) {
|
|
515
602
|
try {
|
|
516
603
|
importScripts(scriptPath);
|
|
@@ -9159,7 +9246,40 @@ async function processMessage(data) {
|
|
|
9159
9246
|
trustedPythonWorkerPostMessage({ id, type: 'error', payload: { error: 'Missing Python worker protocol token.' } });
|
|
9160
9247
|
return;
|
|
9161
9248
|
}
|
|
9249
|
+
if (
|
|
9250
|
+
(DECLARED_PYTHON_WORKER_ROLE === 'runtime-image' &&
|
|
9251
|
+
type !== 'build-runtime-image') ||
|
|
9252
|
+
(DECLARED_PYTHON_WORKER_ROLE !== 'runtime-image' &&
|
|
9253
|
+
type === 'build-runtime-image')
|
|
9254
|
+
) {
|
|
9255
|
+
trustedPythonWorkerPostMessage({
|
|
9256
|
+
id,
|
|
9257
|
+
type: 'error',
|
|
9258
|
+
protocolToken,
|
|
9259
|
+
payload: {
|
|
9260
|
+
error:
|
|
9261
|
+
DECLARED_PYTHON_WORKER_ROLE === 'runtime-image'
|
|
9262
|
+
? 'The Python runtime-image Worker accepts only image bootstrap requests.'
|
|
9263
|
+
: 'Python runtime-image bootstrap is unavailable in an execution Worker.',
|
|
9264
|
+
},
|
|
9265
|
+
});
|
|
9266
|
+
return;
|
|
9267
|
+
}
|
|
9162
9268
|
switch (type) {
|
|
9269
|
+
case 'build-runtime-image': {
|
|
9270
|
+
const runtimeImage = await buildPythonRuntimeImageInWorker(payload);
|
|
9271
|
+
trustedPythonWorkerPostMessage(
|
|
9272
|
+
{
|
|
9273
|
+
id,
|
|
9274
|
+
type: 'runtime-image-result',
|
|
9275
|
+
protocolToken,
|
|
9276
|
+
payload: { runtimeImage },
|
|
9277
|
+
},
|
|
9278
|
+
[runtimeImage.snapshot.buffer]
|
|
9279
|
+
);
|
|
9280
|
+
break;
|
|
9281
|
+
}
|
|
9282
|
+
|
|
9163
9283
|
case 'init': {
|
|
9164
9284
|
const startTime = performance.now();
|
|
9165
9285
|
configurePythonWorkerOptions(payload);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const config = /*json-start*/{
|
|
2
2
|
"mainAssemblyName": "TraceCode.CSharpHost.dll",
|
|
3
3
|
"resources": {
|
|
4
|
-
"hash": "sha256-
|
|
4
|
+
"hash": "sha256-Kw2FMB19FvABlNLVv6KqAlHYkPVaBRF0jG/MoEaKoDo=",
|
|
5
5
|
"jsModuleNative": [
|
|
6
6
|
{
|
|
7
7
|
"name": "dotnet.native.js"
|
|
@@ -15,7 +15,7 @@ export const config = /*json-start*/{
|
|
|
15
15
|
"wasmNative": [
|
|
16
16
|
{
|
|
17
17
|
"name": "dotnet.native.wasm",
|
|
18
|
-
"hash": "sha256-
|
|
18
|
+
"hash": "sha256-xcjLc6kDkucP0cMD+FynBGi3+5QMHy+ApdTGpKlcgYQ="
|
|
19
19
|
}
|
|
20
20
|
],
|
|
21
21
|
"coreAssembly": [
|
|
@@ -789,12 +789,17 @@ export const config = /*json-start*/{
|
|
|
789
789
|
{
|
|
790
790
|
"virtualPath": "TraceCode.CSharpHost.wasm",
|
|
791
791
|
"name": "TraceCode.CSharpHost.wasm",
|
|
792
|
-
"hash": "sha256-
|
|
792
|
+
"hash": "sha256-JvnUmwedjuxVor9Y0+t5GBud3LCTmy6IkA5p2Vv+E0M="
|
|
793
793
|
},
|
|
794
794
|
{
|
|
795
795
|
"virtualPath": "TraceCode.CSharpJudgeRuntime.wasm",
|
|
796
796
|
"name": "TraceCode.CSharpJudgeRuntime.wasm",
|
|
797
|
-
"hash": "sha256
|
|
797
|
+
"hash": "sha256-+pDto6rULeu51Nc/RGPNR7fdFHcFjE4/nTkuHnsbwic="
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
"virtualPath": "TraceCode.TraceClrWire.wasm",
|
|
801
|
+
"name": "TraceCode.TraceClrWire.wasm",
|
|
802
|
+
"hash": "sha256-vDzfH2k5CYsHM7r2yMsC1OOe+vjAk13dRlfiURR4Z6E="
|
|
798
803
|
},
|
|
799
804
|
{
|
|
800
805
|
"virtualPath": "WindowsBase.wasm",
|
|
@@ -964,12 +969,12 @@ export const config = /*json-start*/{
|
|
|
964
969
|
{
|
|
965
970
|
"virtualPath": "/tracecode-refs/TraceCode.CSharpHost.dll",
|
|
966
971
|
"name": "supportFiles/TraceCode.CSharpHost.dll",
|
|
967
|
-
"hash": "sha256-
|
|
972
|
+
"hash": "sha256-DU4TTAiIuFKgGVG636CPUH4otbZPKdnxYWjhiFSAM/o="
|
|
968
973
|
},
|
|
969
974
|
{
|
|
970
975
|
"virtualPath": "/tracecode-refs/TraceCode.CSharpJudgeRuntime.dll",
|
|
971
976
|
"name": "supportFiles/TraceCode.CSharpJudgeRuntime.dll",
|
|
972
|
-
"hash": "sha256-
|
|
977
|
+
"hash": "sha256-plkGKRDvn5suekHRYiOQiqXsj2OYFZfPqXxOj57aVMQ="
|
|
973
978
|
},
|
|
974
979
|
{
|
|
975
980
|
"virtualPath": "/tracecode-refs/Microsoft.CSharp.dll",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|