ttsc 0.31.0 → 0.31.2
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/cmd/platform/main.go +2 -2
- package/internal/sourceprocess/contain_windows.go +10 -13
- package/internal/sourceprocess/started_windows.go +41 -0
- package/internal/sourceprocess/windows_started_publication_distinguishes_pending_from_refusal_test.go +76 -0
- package/internal/watchhelper/run.go +30 -20
- package/internal/watchhelper/run_other.go +4 -4
- package/internal/watchhelper/run_windows.go +471 -0
- package/internal/watchhelper/watchhelper.go +8 -2
- package/internal/watchhelper/windows_notifications_preserve_mutations_without_access_noise_test.go +506 -0
- package/lib/compiler/internal/build/BuildExecution.d.ts +4 -2
- package/lib/compiler/internal/build/BuildExecution.js +40 -12
- package/lib/compiler/internal/build/BuildExecution.js.map +1 -1
- package/lib/compiler/internal/startResidentTransform.js +5 -4
- package/lib/compiler/internal/startResidentTransform.js.map +1 -1
- package/lib/compiler/internal/transformProjectInMemory.js +9 -7
- package/lib/compiler/internal/transformProjectInMemory.js.map +1 -1
- package/lib/internal/javascriptRuntimeCapabilities.d.ts +13 -4
- package/lib/internal/javascriptRuntimeCapabilities.js +56 -6
- package/lib/internal/javascriptRuntimeCapabilities.js.map +1 -1
- package/lib/internal/nativeBinary.d.ts +3 -3
- package/lib/internal/nativeBinary.js +3 -3
- package/lib/internal/pluginSource.d.ts +1 -0
- package/lib/internal/pluginSource.js +1 -0
- package/lib/internal/pluginSource.js.map +1 -1
- package/lib/internal/resolveNodeBinary.d.ts +6 -1
- package/lib/internal/resolveNodeBinary.js +6 -2
- package/lib/internal/resolveNodeBinary.js.map +1 -1
- package/lib/internal/runtimeExecutableIdentity.d.ts +22 -13
- package/lib/internal/runtimeExecutableIdentity.js +192 -102
- package/lib/internal/runtimeExecutableIdentity.js.map +1 -1
- package/lib/launcher/internal/runtime/installRuntimeHooks.js +58 -4
- package/lib/launcher/internal/runtime/installRuntimeHooks.js.map +1 -1
- package/lib/launcher/internal/ttscserver/captureLSPPluginSelectionInputs.d.ts +5 -1
- package/lib/launcher/internal/ttscserver/captureLSPPluginSelectionInputs.js +7 -2
- package/lib/launcher/internal/ttscserver/captureLSPPluginSelectionInputs.js.map +1 -1
- package/lib/launcher/internal/ttscserver/runTtscserver.js +8 -1
- package/lib/launcher/internal/ttscserver/runTtscserver.js.map +1 -1
- package/lib/plugin/internal/CapabilityResolutionFormat.d.ts +21 -62
- package/lib/plugin/internal/CapabilityResolutionFormat.js +15 -106
- package/lib/plugin/internal/CapabilityResolutionFormat.js.map +1 -1
- package/lib/plugin/internal/load/PluginDescriptorEvaluationCache.d.ts +6 -0
- package/lib/plugin/internal/load/PluginDescriptorEvaluationCache.js +4 -4
- package/lib/plugin/internal/load/PluginDescriptorEvaluationCache.js.map +1 -1
- package/lib/plugin/internal/load/loadProjectPlugins.d.ts +24 -14
- package/lib/plugin/internal/load/loadProjectPlugins.js +141 -56
- package/lib/plugin/internal/load/loadProjectPlugins.js.map +1 -1
- package/lib/plugin/internal/readCapabilityResolution.d.ts +6 -0
- package/lib/plugin/internal/readCapabilityResolution.js +8 -5
- package/lib/plugin/internal/readCapabilityResolution.js.map +1 -1
- package/lib/plugin/internal/source/GoEnvironmentReading.d.ts +48 -0
- package/lib/plugin/internal/source/GoEnvironmentReading.js +156 -0
- package/lib/plugin/internal/source/GoEnvironmentReading.js.map +1 -0
- package/lib/plugin/internal/source/NativeSourcePackages.d.ts +51 -13
- package/lib/plugin/internal/source/NativeSourcePackages.js +182 -27
- package/lib/plugin/internal/source/NativeSourcePackages.js.map +1 -1
- package/lib/plugin/internal/source/PluginBuildEnvironmentReadings.d.ts +42 -3
- package/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js +68 -7
- package/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js.map +1 -1
- package/lib/plugin/internal/source/PluginBuildEnvironmentWitness.d.ts +5 -3
- package/lib/plugin/internal/source/PluginBuildEnvironmentWitness.js +14 -8
- package/lib/plugin/internal/source/PluginBuildEnvironmentWitness.js.map +1 -1
- package/lib/plugin/internal/source/PluginContentIdentities.d.ts +265 -0
- package/lib/plugin/internal/source/PluginContentIdentities.js +452 -0
- package/lib/plugin/internal/source/PluginContentIdentities.js.map +1 -0
- package/lib/plugin/internal/source/PluginLoadAnswers.d.ts +63 -0
- package/lib/plugin/internal/source/PluginLoadAnswers.js +128 -0
- package/lib/plugin/internal/source/PluginLoadAnswers.js.map +1 -0
- package/lib/plugin/internal/source/SourceBuildCacheLayout.d.ts +10 -0
- package/lib/plugin/internal/source/SourceBuildCacheLayout.js +12 -0
- package/lib/plugin/internal/source/SourceBuildCacheLayout.js.map +1 -1
- package/lib/plugin/internal/source/SourcePluginWorkspace.d.ts +53 -19
- package/lib/plugin/internal/source/SourcePluginWorkspace.js +111 -22
- package/lib/plugin/internal/source/SourcePluginWorkspace.js.map +1 -1
- package/lib/plugin/internal/source/buildSourcePlugin.d.ts +34 -18
- package/lib/plugin/internal/source/buildSourcePlugin.js +52 -24
- package/lib/plugin/internal/source/buildSourcePlugin.js.map +1 -1
- package/lib/plugin/internal/source/computeCacheKey.d.ts +25 -7
- package/lib/plugin/internal/source/computeCacheKey.js +85 -34
- package/lib/plugin/internal/source/computeCacheKey.js.map +1 -1
- package/lib/plugin/internal/source/hashPluginBuildEnvironment.d.ts +7 -3
- package/lib/plugin/internal/source/hashPluginBuildEnvironment.js +75 -102
- package/lib/plugin/internal/source/hashPluginBuildEnvironment.js.map +1 -1
- package/lib/plugin/internal/source/pluginBuildEnvironment.d.ts +8 -3
- package/lib/plugin/internal/source/pluginBuildEnvironment.js +8 -4
- package/lib/plugin/internal/source/pluginBuildEnvironment.js.map +1 -1
- package/lib/plugin/internal/source/pluginBuildEnvironmentWorker.js +12 -2
- package/lib/plugin/internal/source/pluginBuildEnvironmentWorker.js.map +1 -1
- package/lib/plugin/internal/source/pluginBuildVersions.d.ts +2 -2
- package/lib/plugin/internal/source/pluginBuildVersions.js +4 -17
- package/lib/plugin/internal/source/pluginBuildVersions.js.map +1 -1
- package/lib/plugin/internal/source/pluginModuleReplaceDirectories.d.ts +6 -5
- package/lib/plugin/internal/source/pluginModuleReplaceDirectories.js +10 -17
- package/lib/plugin/internal/source/pluginModuleReplaceDirectories.js.map +1 -1
- package/lib/plugin/internal/source/pluginSourceState.d.ts +6 -2
- package/lib/plugin/internal/source/pluginSourceState.js +20 -8
- package/lib/plugin/internal/source/pluginSourceState.js.map +1 -1
- package/lib/plugin/internal/source/pluginSourceStateHolds.d.ts +7 -2
- package/lib/plugin/internal/source/pluginSourceStateHolds.js +12 -7
- package/lib/plugin/internal/source/pluginSourceStateHolds.js.map +1 -1
- package/lib/plugin/internal/source/processPluginBuildEnvironment.d.ts +7 -2
- package/lib/plugin/internal/source/processPluginBuildEnvironment.js +8 -3
- package/lib/plugin/internal/source/processPluginBuildEnvironment.js.map +1 -1
- package/lib/plugin/internal/source/provenPluginSourceDigest.d.ts +28 -0
- package/lib/plugin/internal/source/provenPluginSourceDigest.js +41 -0
- package/lib/plugin/internal/source/provenPluginSourceDigest.js.map +1 -0
- package/lib/plugin/internal/source/pruneCacheFileRoot.d.ts +3 -2
- package/lib/plugin/internal/source/pruneCacheFileRoot.js +3 -2
- package/lib/plugin/internal/source/pruneCacheFileRoot.js.map +1 -1
- package/lib/plugin/internal/source/ttscPackageVersion.d.ts +26 -0
- package/lib/plugin/internal/source/ttscPackageVersion.js +47 -0
- package/lib/plugin/internal/source/ttscPackageVersion.js.map +1 -0
- package/lib/plugin/internal/writeCapabilityResolution.d.ts +6 -0
- package/lib/plugin/internal/writeCapabilityResolution.js +11 -7
- package/lib/plugin/internal/writeCapabilityResolution.js.map +1 -1
- package/lib/plugin/resolveCapabilityPlugins.js +67 -15
- package/lib/plugin/resolveCapabilityPlugins.js.map +1 -1
- package/package.json +8 -8
- package/src/compiler/internal/build/BuildExecution.ts +46 -13
- package/src/compiler/internal/startResidentTransform.ts +12 -3
- package/src/compiler/internal/transformProjectInMemory.ts +10 -2
- package/src/internal/javascriptRuntimeCapabilities.ts +71 -5
- package/src/internal/nativeBinary.ts +3 -3
- package/src/internal/pluginSource.ts +1 -0
- package/src/internal/resolveNodeBinary.ts +12 -1
- package/src/internal/runtimeExecutableIdentity.ts +227 -141
- package/src/launcher/internal/runtime/installRuntimeHooks.ts +68 -3
- package/src/launcher/internal/ttscserver/captureLSPPluginSelectionInputs.ts +11 -2
- package/src/launcher/internal/ttscserver/runTtscserver.ts +18 -1
- package/src/plugin/internal/CapabilityResolutionFormat.ts +23 -107
- package/src/plugin/internal/load/PluginDescriptorEvaluationCache.ts +14 -4
- package/src/plugin/internal/load/loadProjectPlugins.ts +421 -211
- package/src/plugin/internal/readCapabilityResolution.ts +17 -6
- package/src/plugin/internal/source/GoEnvironmentReading.ts +178 -0
- package/src/plugin/internal/source/NativeSourcePackages.ts +365 -48
- package/src/plugin/internal/source/PluginBuildEnvironmentReadings.ts +83 -5
- package/src/plugin/internal/source/PluginBuildEnvironmentWitness.ts +18 -8
- package/src/plugin/internal/source/PluginContentIdentities.ts +563 -0
- package/src/plugin/internal/source/PluginLoadAnswers.ts +151 -0
- package/src/plugin/internal/source/SourceBuildCacheLayout.ts +14 -0
- package/src/plugin/internal/source/SourcePluginWorkspace.ts +148 -25
- package/src/plugin/internal/source/buildSourcePlugin.ts +104 -36
- package/src/plugin/internal/source/computeCacheKey.ts +129 -55
- package/src/plugin/internal/source/hashPluginBuildEnvironment.ts +152 -105
- package/src/plugin/internal/source/pluginBuildEnvironment.ts +9 -2
- package/src/plugin/internal/source/pluginBuildEnvironmentWorker.ts +18 -2
- package/src/plugin/internal/source/pluginBuildVersions.ts +5 -26
- package/src/plugin/internal/source/pluginModuleReplaceDirectories.ts +13 -25
- package/src/plugin/internal/source/pluginSourceState.ts +28 -12
- package/src/plugin/internal/source/pluginSourceStateHolds.ts +15 -8
- package/src/plugin/internal/source/processPluginBuildEnvironment.ts +8 -2
- package/src/plugin/internal/source/provenPluginSourceDigest.ts +45 -0
- package/src/plugin/internal/source/pruneCacheFileRoot.ts +3 -2
- package/src/plugin/internal/source/ttscPackageVersion.ts +45 -0
- package/src/plugin/internal/writeCapabilityResolution.ts +29 -8
- package/src/plugin/resolveCapabilityPlugins.ts +87 -13
|
@@ -1,20 +1,29 @@
|
|
|
1
|
+
import { PluginContentIdentities } from "../plugin/internal/source/PluginContentIdentities";
|
|
1
2
|
/**
|
|
2
3
|
* Fingerprint an absolute executable's spelling, target and actual bytes.
|
|
3
4
|
*
|
|
4
5
|
* A changed link, file, or read failure yields no reusable identity. Metadata
|
|
5
|
-
* brackets the streamed read
|
|
6
|
-
*
|
|
7
|
-
* snapshot guarantee.
|
|
6
|
+
* brackets the streamed read. Concurrent writes that evade every filesystem
|
|
7
|
+
* observation remain outside this snapshot guarantee.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
9
|
+
* With a record store, the bytes of an unchanged executable are proven from its
|
|
10
|
+
* metadata instead of streamed again (`PluginContentIdentities`, #1723): the
|
|
11
|
+
* recorded digest stands only while the physical file's identity, size and both
|
|
12
|
+
* stamps match the record and its modification stamp is separable from a
|
|
13
|
+
* reference the store minted. A plugin load asks for this identity several
|
|
14
|
+
* times, and every launch is a new process, so streaming an 85 MB runtime each
|
|
15
|
+
* time cost about 0.9 s per launch. Without a store, or when that proof is
|
|
16
|
+
* unavailable, the file is streamed as before.
|
|
17
17
|
*
|
|
18
|
-
* @
|
|
18
|
+
* @param runtime The executable, absolute.
|
|
19
|
+
* @param identities Optional record store of the caller's plugin cache.
|
|
20
|
+
* @evidence contracts/common.md#principled-implementation The identity joins lexical-link metadata, the selected physical file metadata and the SHA-256 of that file's bytes, streamed under metadata brackets or proven by a record whose separable signature still matches; descriptor and pathname observations must still agree after a read.
|
|
21
|
+
* @evidence contracts/common.md#clear-and-simple-design This one native owner supplies the same identity to runtime capability and plugin caches; the record store owns metadata reuse and a private helper owns the bracketed stream.
|
|
22
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Metadata alone never stands for bytes: reuse needs a record written under unchanged separable metadata around an actual read, which a same-tick rewrite or restored timestamps cannot satisfy because change time and the minted reference move.
|
|
23
|
+
* @evidence contracts/common.md#meaningful-documentation Native prose explains absolute-path scope, failure meaning, the record proof and the remaining concurrent-mutation limitation, with separate prose and tags.
|
|
24
|
+
* @evidence contracts/portability.md#os-neutral-implementation Node native realpath and bigint stat preserve link/target identity on supported hosts; absolute paths use native platform semantics, and unreadable or non-regular targets cannot be reused.
|
|
25
|
+
* @evidence contracts/performance.md#efficient-algorithms A proven record costs three stats and one small file read; otherwise a sequential read hashes B bytes with one 64 KiB buffer instead of a complete executable allocation. Native path/realpath/stat observations and serialized metadata add text/lookup costs.
|
|
26
|
+
* @evidence contracts/performance.md#reuse-equivalent-work Processes share an executable digest only through the record store's separable-signature proof; without a store every call streams the file.
|
|
27
|
+
* @evidence contracts/performance.md#bound-retention-and-release-resources One descriptor and one fixed buffer belong to a streamed read; finally attempts closure after read/observation failures as well as success. A close failure returns no identity but cannot confirm native release. Opt-in opened/closed/close-failed observations carry one trace-only call id and actual descriptor, PID/thread and already observed physical identity. Records belong to the single-file collector.
|
|
19
28
|
*/
|
|
20
|
-
export declare function runtimeExecutableIdentity(runtime: string): string | undefined;
|
|
29
|
+
export declare function runtimeExecutableIdentity(runtime: string, identities?: PluginContentIdentities.Store): string | undefined;
|
|
@@ -8,55 +8,41 @@ const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
|
8
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
10
|
const node_worker_threads_1 = require("node:worker_threads");
|
|
11
|
+
const PluginContentIdentities_1 = require("../plugin/internal/source/PluginContentIdentities");
|
|
11
12
|
const E2ETrace_1 = require("./E2ETrace");
|
|
12
13
|
/**
|
|
13
14
|
* Fingerprint an absolute executable's spelling, target and actual bytes.
|
|
14
15
|
*
|
|
15
16
|
* A changed link, file, or read failure yields no reusable identity. Metadata
|
|
16
|
-
* brackets the streamed read
|
|
17
|
-
*
|
|
18
|
-
* snapshot guarantee.
|
|
17
|
+
* brackets the streamed read. Concurrent writes that evade every filesystem
|
|
18
|
+
* observation remain outside this snapshot guarantee.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
20
|
+
* With a record store, the bytes of an unchanged executable are proven from its
|
|
21
|
+
* metadata instead of streamed again (`PluginContentIdentities`, #1723): the
|
|
22
|
+
* recorded digest stands only while the physical file's identity, size and both
|
|
23
|
+
* stamps match the record and its modification stamp is separable from a
|
|
24
|
+
* reference the store minted. A plugin load asks for this identity several
|
|
25
|
+
* times, and every launch is a new process, so streaming an 85 MB runtime each
|
|
26
|
+
* time cost about 0.9 s per launch. Without a store, or when that proof is
|
|
27
|
+
* unavailable, the file is streamed as before.
|
|
28
28
|
*
|
|
29
|
-
* @
|
|
29
|
+
* @param runtime The executable, absolute.
|
|
30
|
+
* @param identities Optional record store of the caller's plugin cache.
|
|
31
|
+
* @evidence contracts/common.md#principled-implementation The identity joins lexical-link metadata, the selected physical file metadata and the SHA-256 of that file's bytes, streamed under metadata brackets or proven by a record whose separable signature still matches; descriptor and pathname observations must still agree after a read.
|
|
32
|
+
* @evidence contracts/common.md#clear-and-simple-design This one native owner supplies the same identity to runtime capability and plugin caches; the record store owns metadata reuse and a private helper owns the bracketed stream.
|
|
33
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Metadata alone never stands for bytes: reuse needs a record written under unchanged separable metadata around an actual read, which a same-tick rewrite or restored timestamps cannot satisfy because change time and the minted reference move.
|
|
34
|
+
* @evidence contracts/common.md#meaningful-documentation Native prose explains absolute-path scope, failure meaning, the record proof and the remaining concurrent-mutation limitation, with separate prose and tags.
|
|
35
|
+
* @evidence contracts/portability.md#os-neutral-implementation Node native realpath and bigint stat preserve link/target identity on supported hosts; absolute paths use native platform semantics, and unreadable or non-regular targets cannot be reused.
|
|
36
|
+
* @evidence contracts/performance.md#efficient-algorithms A proven record costs three stats and one small file read; otherwise a sequential read hashes B bytes with one 64 KiB buffer instead of a complete executable allocation. Native path/realpath/stat observations and serialized metadata add text/lookup costs.
|
|
37
|
+
* @evidence contracts/performance.md#reuse-equivalent-work Processes share an executable digest only through the record store's separable-signature proof; without a store every call streams the file.
|
|
38
|
+
* @evidence contracts/performance.md#bound-retention-and-release-resources One descriptor and one fixed buffer belong to a streamed read; finally attempts closure after read/observation failures as well as success. A close failure returns no identity but cannot confirm native release. Opt-in opened/closed/close-failed observations carry one trace-only call id and actual descriptor, PID/thread and already observed physical identity. Records belong to the single-file collector.
|
|
30
39
|
*/
|
|
31
|
-
function runtimeExecutableIdentity(runtime) {
|
|
40
|
+
function runtimeExecutableIdentity(runtime, identities) {
|
|
32
41
|
if (!node_path_1.default.isAbsolute(runtime))
|
|
33
42
|
return undefined;
|
|
34
43
|
const startedAt = new Date().toISOString();
|
|
35
|
-
let descriptor;
|
|
36
|
-
let traceLease;
|
|
37
44
|
let stage = "lexical-stat";
|
|
38
|
-
|
|
39
|
-
E2ETrace_1.E2ETrace.capabilityResolution("runtime-executable-identity-unavailable", {
|
|
40
|
-
runtime,
|
|
41
|
-
stage,
|
|
42
|
-
reason,
|
|
43
|
-
expected,
|
|
44
|
-
observed,
|
|
45
|
-
expectedAtimeNs: observations === undefined
|
|
46
|
-
? undefined
|
|
47
|
-
: String(observations.before.atimeNs),
|
|
48
|
-
observedAtimeNs: observations === undefined
|
|
49
|
-
? undefined
|
|
50
|
-
: String(observations.after.atimeNs),
|
|
51
|
-
expectedBirthtimeNs: observations === undefined
|
|
52
|
-
? undefined
|
|
53
|
-
: String(observations.before.birthtimeNs),
|
|
54
|
-
observedBirthtimeNs: observations === undefined
|
|
55
|
-
? undefined
|
|
56
|
-
: String(observations.after.birthtimeNs),
|
|
57
|
-
});
|
|
58
|
-
return undefined;
|
|
59
|
-
};
|
|
45
|
+
let refused;
|
|
60
46
|
try {
|
|
61
47
|
const lexical = node_fs_1.default.lstatSync(runtime, { bigint: true });
|
|
62
48
|
stage = "physical-realpath";
|
|
@@ -64,68 +50,23 @@ function runtimeExecutableIdentity(runtime) {
|
|
|
64
50
|
stage = "physical-stat";
|
|
65
51
|
const physical = node_fs_1.default.statSync(physicalPath, { bigint: true });
|
|
66
52
|
if (!physical.isFile())
|
|
67
|
-
return unavailable(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const opened = node_fs_1.default.fstatSync(descriptor, { bigint: true });
|
|
85
|
-
if (fileIdentity(opened) !== fileIdentity(physical))
|
|
86
|
-
return unavailable("opened-file-changed", fileIdentity(physical), fileIdentity(opened));
|
|
87
|
-
const hash = node_crypto_1.default.createHash("sha256");
|
|
88
|
-
const buffer = Buffer.allocUnsafe(64 * 1024);
|
|
89
|
-
let remaining = opened.size;
|
|
90
|
-
stage = "read";
|
|
91
|
-
while (remaining > 0n) {
|
|
92
|
-
const requested = remaining > BigInt(buffer.length) ? buffer.length : Number(remaining);
|
|
93
|
-
const length = node_fs_1.default.readSync(descriptor, buffer, 0, requested, null);
|
|
94
|
-
if (length === 0)
|
|
95
|
-
return unavailable("premature-eof", String(opened.size), String(opened.size - remaining));
|
|
96
|
-
hash.update(buffer.subarray(0, length));
|
|
97
|
-
remaining -= BigInt(length);
|
|
98
|
-
}
|
|
99
|
-
stage = "post-read-opened-stat";
|
|
100
|
-
const afterOpened = node_fs_1.default.fstatSync(descriptor, { bigint: true });
|
|
101
|
-
if (fileIdentity(afterOpened) !== fileIdentity(opened))
|
|
102
|
-
return unavailable("opened-file-changed-during-read", fileIdentity(opened), fileIdentity(afterOpened), { before: opened, after: afterOpened });
|
|
103
|
-
stage = "post-read-realpath";
|
|
104
|
-
const afterPath = node_fs_1.default.realpathSync.native(runtime);
|
|
105
|
-
if (afterPath !== physicalPath)
|
|
106
|
-
return unavailable("physical-target-changed", physicalPath, afterPath);
|
|
107
|
-
stage = "post-read-lexical-stat";
|
|
108
|
-
const afterLexical = node_fs_1.default.lstatSync(runtime, { bigint: true });
|
|
109
|
-
if (fileIdentity(afterLexical) !== fileIdentity(lexical))
|
|
110
|
-
return unavailable("lexical-file-changed-during-read", fileIdentity(lexical), fileIdentity(afterLexical));
|
|
111
|
-
stage = "post-read-physical-stat";
|
|
112
|
-
const afterPhysical = node_fs_1.default.statSync(physicalPath, { bigint: true });
|
|
113
|
-
if (fileIdentity(afterPhysical) !== fileIdentity(physical))
|
|
114
|
-
return unavailable("physical-file-changed-during-read", fileIdentity(physical), fileIdentity(afterPhysical));
|
|
115
|
-
const digest = hash.digest("hex");
|
|
116
|
-
E2ETrace_1.E2ETrace.capabilityResolution("runtime-executable-identity-observed", {
|
|
117
|
-
runtime,
|
|
118
|
-
physicalPath,
|
|
119
|
-
startedAt,
|
|
120
|
-
finishedAt: new Date().toISOString(),
|
|
121
|
-
lexical: fileIdentity(lexical),
|
|
122
|
-
physical: fileIdentity(physical),
|
|
123
|
-
digest,
|
|
124
|
-
openedAtimeNs: String(opened.atimeNs),
|
|
125
|
-
afterOpenedAtimeNs: String(afterOpened.atimeNs),
|
|
126
|
-
openedBirthtimeNs: String(opened.birthtimeNs),
|
|
127
|
-
afterOpenedBirthtimeNs: String(afterOpened.birthtimeNs),
|
|
128
|
-
});
|
|
53
|
+
return unavailable(runtime, {
|
|
54
|
+
stage,
|
|
55
|
+
reason: "not-regular",
|
|
56
|
+
observed: fileIdentity(physical),
|
|
57
|
+
});
|
|
58
|
+
const read = () => {
|
|
59
|
+
const streamed = streamDigest(runtime, physicalPath, physical, lexical, {
|
|
60
|
+
startedAt,
|
|
61
|
+
});
|
|
62
|
+
if (typeof streamed === "string")
|
|
63
|
+
return streamed;
|
|
64
|
+
refused = streamed;
|
|
65
|
+
throw new Error(streamed.reason);
|
|
66
|
+
};
|
|
67
|
+
const digest = identities === undefined
|
|
68
|
+
? read()
|
|
69
|
+
: PluginContentIdentities_1.PluginContentIdentities.digest(identities, "executable", physicalPath, (references) => PluginContentIdentities_1.PluginContentIdentities.fileObservation(references, physicalPath), read);
|
|
129
70
|
return [
|
|
130
71
|
physicalPath,
|
|
131
72
|
fileIdentity(lexical),
|
|
@@ -134,7 +75,48 @@ function runtimeExecutableIdentity(runtime) {
|
|
|
134
75
|
].join("\0");
|
|
135
76
|
}
|
|
136
77
|
catch (error) {
|
|
137
|
-
return unavailable(
|
|
78
|
+
return unavailable(runtime, refused ?? {
|
|
79
|
+
stage,
|
|
80
|
+
reason: "filesystem-error",
|
|
81
|
+
observed: error instanceof Error ? error.message : String(error),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function unavailable(runtime, failure) {
|
|
86
|
+
E2ETrace_1.E2ETrace.capabilityResolution("runtime-executable-identity-unavailable", {
|
|
87
|
+
runtime,
|
|
88
|
+
stage: failure.stage,
|
|
89
|
+
reason: failure.reason,
|
|
90
|
+
expected: failure.expected,
|
|
91
|
+
observed: failure.observed,
|
|
92
|
+
expectedAtimeNs: failure.observations === undefined
|
|
93
|
+
? undefined
|
|
94
|
+
: String(failure.observations.before.atimeNs),
|
|
95
|
+
observedAtimeNs: failure.observations === undefined
|
|
96
|
+
? undefined
|
|
97
|
+
: String(failure.observations.after.atimeNs),
|
|
98
|
+
expectedBirthtimeNs: failure.observations === undefined
|
|
99
|
+
? undefined
|
|
100
|
+
: String(failure.observations.before.birthtimeNs),
|
|
101
|
+
observedBirthtimeNs: failure.observations === undefined
|
|
102
|
+
? undefined
|
|
103
|
+
: String(failure.observations.after.birthtimeNs),
|
|
104
|
+
});
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Stream the physical file's bytes between metadata observations of the open
|
|
109
|
+
* descriptor, the physical path and the lexical spelling, returning the digest
|
|
110
|
+
* or what moved. The descriptor is closed in finally; a failed close refuses
|
|
111
|
+
* the identity.
|
|
112
|
+
*/
|
|
113
|
+
function streamDigest(runtime, physicalPath, physical, lexical, timing) {
|
|
114
|
+
let stage = "open";
|
|
115
|
+
let descriptor;
|
|
116
|
+
let traceLease;
|
|
117
|
+
let result;
|
|
118
|
+
try {
|
|
119
|
+
result = observe();
|
|
138
120
|
}
|
|
139
121
|
finally {
|
|
140
122
|
if (descriptor !== undefined) {
|
|
@@ -149,11 +131,119 @@ function runtimeExecutableIdentity(runtime) {
|
|
|
149
131
|
...traceLease,
|
|
150
132
|
error: error instanceof Error ? error.message : String(error),
|
|
151
133
|
});
|
|
152
|
-
|
|
153
|
-
|
|
134
|
+
// A digest whose descriptor could not be closed is refused, as before.
|
|
135
|
+
result = {
|
|
136
|
+
stage: "close",
|
|
137
|
+
reason: "descriptor-close-error",
|
|
138
|
+
observed: error instanceof Error ? error.message : String(error),
|
|
139
|
+
};
|
|
154
140
|
}
|
|
155
141
|
}
|
|
156
142
|
}
|
|
143
|
+
return result;
|
|
144
|
+
function observe() {
|
|
145
|
+
try {
|
|
146
|
+
descriptor = node_fs_1.default.openSync(physicalPath, "r");
|
|
147
|
+
if (process.env.TTSC_E2E_TRACE) {
|
|
148
|
+
traceLease = {
|
|
149
|
+
callId: String(++identityTraceOrdinal),
|
|
150
|
+
runtime,
|
|
151
|
+
physicalPath,
|
|
152
|
+
descriptor,
|
|
153
|
+
pid: process.pid,
|
|
154
|
+
threadId: node_worker_threads_1.threadId,
|
|
155
|
+
dev: String(physical.dev),
|
|
156
|
+
ino: String(physical.ino),
|
|
157
|
+
};
|
|
158
|
+
E2ETrace_1.E2ETrace.capabilityResolution("runtime-executable-identity-opened", traceLease);
|
|
159
|
+
}
|
|
160
|
+
stage = "opened-stat";
|
|
161
|
+
const opened = node_fs_1.default.fstatSync(descriptor, { bigint: true });
|
|
162
|
+
if (fileIdentity(opened) !== fileIdentity(physical))
|
|
163
|
+
return {
|
|
164
|
+
stage,
|
|
165
|
+
reason: "opened-file-changed",
|
|
166
|
+
expected: fileIdentity(physical),
|
|
167
|
+
observed: fileIdentity(opened),
|
|
168
|
+
};
|
|
169
|
+
const hash = node_crypto_1.default.createHash("sha256");
|
|
170
|
+
const buffer = Buffer.allocUnsafe(64 * 1024);
|
|
171
|
+
let remaining = opened.size;
|
|
172
|
+
stage = "read";
|
|
173
|
+
while (remaining > 0n) {
|
|
174
|
+
const requested = remaining > BigInt(buffer.length) ? buffer.length : Number(remaining);
|
|
175
|
+
const length = node_fs_1.default.readSync(descriptor, buffer, 0, requested, null);
|
|
176
|
+
if (length === 0)
|
|
177
|
+
return {
|
|
178
|
+
stage,
|
|
179
|
+
reason: "premature-eof",
|
|
180
|
+
expected: String(opened.size),
|
|
181
|
+
observed: String(opened.size - remaining),
|
|
182
|
+
};
|
|
183
|
+
hash.update(buffer.subarray(0, length));
|
|
184
|
+
remaining -= BigInt(length);
|
|
185
|
+
}
|
|
186
|
+
stage = "post-read-opened-stat";
|
|
187
|
+
const afterOpened = node_fs_1.default.fstatSync(descriptor, { bigint: true });
|
|
188
|
+
if (fileIdentity(afterOpened) !== fileIdentity(opened))
|
|
189
|
+
return {
|
|
190
|
+
stage,
|
|
191
|
+
reason: "opened-file-changed-during-read",
|
|
192
|
+
expected: fileIdentity(opened),
|
|
193
|
+
observed: fileIdentity(afterOpened),
|
|
194
|
+
observations: { before: opened, after: afterOpened },
|
|
195
|
+
};
|
|
196
|
+
stage = "post-read-realpath";
|
|
197
|
+
const afterPath = node_fs_1.default.realpathSync.native(runtime);
|
|
198
|
+
if (afterPath !== physicalPath)
|
|
199
|
+
return {
|
|
200
|
+
stage,
|
|
201
|
+
reason: "physical-target-changed",
|
|
202
|
+
expected: physicalPath,
|
|
203
|
+
observed: afterPath,
|
|
204
|
+
};
|
|
205
|
+
stage = "post-read-lexical-stat";
|
|
206
|
+
const afterLexical = node_fs_1.default.lstatSync(runtime, { bigint: true });
|
|
207
|
+
if (fileIdentity(afterLexical) !== fileIdentity(lexical))
|
|
208
|
+
return {
|
|
209
|
+
stage,
|
|
210
|
+
reason: "lexical-file-changed-during-read",
|
|
211
|
+
expected: fileIdentity(lexical),
|
|
212
|
+
observed: fileIdentity(afterLexical),
|
|
213
|
+
};
|
|
214
|
+
stage = "post-read-physical-stat";
|
|
215
|
+
const afterPhysical = node_fs_1.default.statSync(physicalPath, { bigint: true });
|
|
216
|
+
if (fileIdentity(afterPhysical) !== fileIdentity(physical))
|
|
217
|
+
return {
|
|
218
|
+
stage,
|
|
219
|
+
reason: "physical-file-changed-during-read",
|
|
220
|
+
expected: fileIdentity(physical),
|
|
221
|
+
observed: fileIdentity(afterPhysical),
|
|
222
|
+
};
|
|
223
|
+
const digest = hash.digest("hex");
|
|
224
|
+
E2ETrace_1.E2ETrace.capabilityResolution("runtime-executable-identity-observed", {
|
|
225
|
+
runtime,
|
|
226
|
+
physicalPath,
|
|
227
|
+
startedAt: timing.startedAt,
|
|
228
|
+
finishedAt: new Date().toISOString(),
|
|
229
|
+
lexical: fileIdentity(lexical),
|
|
230
|
+
physical: fileIdentity(physical),
|
|
231
|
+
digest,
|
|
232
|
+
openedAtimeNs: String(opened.atimeNs),
|
|
233
|
+
afterOpenedAtimeNs: String(afterOpened.atimeNs),
|
|
234
|
+
openedBirthtimeNs: String(opened.birthtimeNs),
|
|
235
|
+
afterOpenedBirthtimeNs: String(afterOpened.birthtimeNs),
|
|
236
|
+
});
|
|
237
|
+
return digest;
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
return {
|
|
241
|
+
stage,
|
|
242
|
+
reason: "filesystem-error",
|
|
243
|
+
observed: error instanceof Error ? error.message : String(error),
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
}
|
|
157
247
|
}
|
|
158
248
|
// Trace-only ordinal distinguishes sequential uses of a reused descriptor.
|
|
159
249
|
let identityTraceOrdinal = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeExecutableIdentity.js","sourceRoot":"","sources":["../../src/internal/runtimeExecutableIdentity.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAiC;AACjC,sDAAyB;AACzB,0DAA6B;AAC7B,6DAA+C;AAE/C,yCAAsC;AAEtC
|
|
1
|
+
{"version":3,"file":"runtimeExecutableIdentity.js","sourceRoot":"","sources":["../../src/internal/runtimeExecutableIdentity.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAiC;AACjC,sDAAyB;AACzB,0DAA6B;AAC7B,6DAA+C;AAE/C,+FAA4F;AAC5F,yCAAsC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,mCACE,OAAe,EACf,UAA0C;IAE1C,IAAI,CAAC,mBAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IAChD,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3C,IAAI,KAAK,GAAG,cAAc,CAAC;IAC3B,IAAI,OAAiC,CAAC;IACtC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,iBAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACxD,KAAK,GAAG,mBAAmB,CAAC;QAC5B,MAAM,YAAY,GAAG,iBAAE,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACrD,KAAK,GAAG,eAAe,CAAC;QACxB,MAAM,QAAQ,GAAG,iBAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7D,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;YACpB,OAAO,WAAW,CAAC,OAAO,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AAC,OAAO;KACb,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -15,11 +15,13 @@ const runBuild_1 = require("../../../compiler/internal/build/runBuild");
|
|
|
15
15
|
const readProjectConfig_1 = require("../../../compiler/internal/project/readProjectConfig");
|
|
16
16
|
const resolveOwningProjectConfig_1 = require("../../../compiler/internal/project/resolveOwningProjectConfig");
|
|
17
17
|
const resolveTsgo_1 = require("../../../compiler/internal/resolveTsgo");
|
|
18
|
+
const SidecarEnvironment_1 = require("../../../compiler/internal/sharedHost/SidecarEnvironment");
|
|
18
19
|
const spawnNative_1 = require("../../../compiler/internal/spawnNative");
|
|
19
20
|
const E2ETrace_1 = require("../../../internal/E2ETrace");
|
|
20
21
|
const createCanonicalTempDirectory_1 = require("../../../internal/createCanonicalTempDirectory");
|
|
21
22
|
const runtimeExecutableIdentity_1 = require("../../../internal/runtimeExecutableIdentity");
|
|
22
23
|
const moduleResolutionBaseSelects_1 = require("../../../plugin/internal/load/moduleResolutionBaseSelects");
|
|
24
|
+
const PluginContentIdentities_1 = require("../../../plugin/internal/source/PluginContentIdentities");
|
|
23
25
|
const recordCacheFileUse_1 = require("../../../plugin/internal/source/recordCacheFileUse");
|
|
24
26
|
const buildSingleRootProject_1 = require("../buildSingleRootProject");
|
|
25
27
|
const inlineServedSourceMap_1 = require("../inlineServedSourceMap");
|
|
@@ -547,6 +549,17 @@ function observePluginDescriptorInputOnce(record) {
|
|
|
547
549
|
(record.hash !== undefined && record.hash !== observedHash) ||
|
|
548
550
|
(record.realpath !== undefined && record.realpath !== observedRealpath) ||
|
|
549
551
|
(record.signature !== undefined && record.signature !== afterSignature);
|
|
552
|
+
// A missing path's signature is its nearest existing ancestor's metadata,
|
|
553
|
+
// so a write anywhere in that ancestor refuses the proof; the trace names
|
|
554
|
+
// which observation moved.
|
|
555
|
+
if (unstable)
|
|
556
|
+
E2ETrace_1.E2ETrace.capabilityResolution("plugin-descriptor-input-unstable", {
|
|
557
|
+
resolved: record.resolved,
|
|
558
|
+
recordedSignature: record.signature,
|
|
559
|
+
beforeSignature,
|
|
560
|
+
afterSignature,
|
|
561
|
+
hashChanged: record.hash !== undefined && record.hash !== observedHash,
|
|
562
|
+
});
|
|
550
563
|
return `${JSON.stringify({
|
|
551
564
|
...record,
|
|
552
565
|
hash: observedHash,
|
|
@@ -1189,11 +1202,52 @@ function orphanCacheRoot() {
|
|
|
1189
1202
|
* Read afresh at every use, never remembered by path: a long-lived process can
|
|
1190
1203
|
* lower orphans before and after the compiler at that path is replaced, and an
|
|
1191
1204
|
* entry lowered by the new one must not be recorded under the old one's key for
|
|
1192
|
-
* a later process to adopt.
|
|
1205
|
+
* a later process to adopt. A fresh use proves an unchanged compiler from the
|
|
1206
|
+
* run's plugin cache records (`runtimeRecordStore`), which observe its metadata
|
|
1207
|
+
* again each time.
|
|
1193
1208
|
*/
|
|
1194
1209
|
function compilerIdentity(binary) {
|
|
1195
|
-
return (0, runtimeExecutableIdentity_1.runtimeExecutableIdentity)(binary) ??
|
|
1210
|
+
return ((0, runtimeExecutableIdentity_1.runtimeExecutableIdentity)(binary, runtimeRecordStore()) ??
|
|
1211
|
+
node_crypto_1.default.randomUUID());
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* The record store of this run's plugin cache root, or `undefined` without one.
|
|
1215
|
+
*
|
|
1216
|
+
* WARNING (#1726): every ttsx process and every descriptor evaluation streamed
|
|
1217
|
+
* the whole compiler executable (24.5 MB) to key its orphan and dependency
|
|
1218
|
+
* builds, although the bytes had not changed since the last process. The root
|
|
1219
|
+
* is the one a descriptor evaluator's parent load selected
|
|
1220
|
+
* (`TTSC_PLUGIN_RECORD_ROOT`), or the cache root of this run's manifest; a
|
|
1221
|
+
* process with neither streams as before and never selects a root itself.
|
|
1222
|
+
*/
|
|
1223
|
+
function runtimeRecordStore() {
|
|
1224
|
+
const descriptorRoot = process.env.TTSC_PLUGIN_DESCRIPTOR_LOAD === "1"
|
|
1225
|
+
? SidecarEnvironment_1.SidecarEnvironment.read(process.env, "TTSC_PLUGIN_RECORD_ROOT")
|
|
1226
|
+
: undefined;
|
|
1227
|
+
const owner = RuntimeManifestRegistry_1.RuntimeManifestRegistry.runtimeManifests().find((candidate) => typeof candidate.orphanCacheDir === "string" &&
|
|
1228
|
+
candidate.orphanCacheDir.length !== 0);
|
|
1229
|
+
const root = descriptorRoot !== undefined && node_path_1.default.isAbsolute(descriptorRoot)
|
|
1230
|
+
? descriptorRoot
|
|
1231
|
+
: owner === undefined
|
|
1232
|
+
? undefined
|
|
1233
|
+
: node_path_1.default.dirname(owner.orphanCacheDir);
|
|
1234
|
+
if (root === undefined)
|
|
1235
|
+
return undefined;
|
|
1236
|
+
// One store per root serves the process: its references only grow older,
|
|
1237
|
+
// which can make fewer stamps separable but never more, and each identity
|
|
1238
|
+
// still observes the compiler's metadata afresh.
|
|
1239
|
+
if (runtimeStore?.root !== root)
|
|
1240
|
+
runtimeStore = {
|
|
1241
|
+
root,
|
|
1242
|
+
store: PluginContentIdentities_1.PluginContentIdentities.open({
|
|
1243
|
+
projectRoot: root,
|
|
1244
|
+
cacheDir: root,
|
|
1245
|
+
env: process.env,
|
|
1246
|
+
}),
|
|
1247
|
+
};
|
|
1248
|
+
return runtimeStore.store;
|
|
1196
1249
|
}
|
|
1250
|
+
let runtimeStore;
|
|
1197
1251
|
/** The version of this ttsc package, which owns the orphan post-processing. */
|
|
1198
1252
|
function ownPackageVersion() {
|
|
1199
1253
|
if (ownPackageVersionCache === undefined) {
|
|
@@ -1627,7 +1681,7 @@ const failedProjects = new Map();
|
|
|
1627
1681
|
function dependencyCachePaths(tsconfig, rootSource) {
|
|
1628
1682
|
let compilerProof;
|
|
1629
1683
|
try {
|
|
1630
|
-
compilerProof = (0, runtimeExecutableIdentity_1.runtimeExecutableIdentity)((0, resolveTsgo_1.resolveTsgo)({ cwd: node_path_1.default.dirname(tsconfig) }).binary);
|
|
1684
|
+
compilerProof = (0, runtimeExecutableIdentity_1.runtimeExecutableIdentity)((0, resolveTsgo_1.resolveTsgo)({ cwd: node_path_1.default.dirname(tsconfig) }).binary, runtimeRecordStore());
|
|
1631
1685
|
}
|
|
1632
1686
|
catch {
|
|
1633
1687
|
// An unobservable executable gets a unique, non-reusable generation key.
|
|
@@ -1653,7 +1707,7 @@ function assertCompilerStillCurrent(tsconfig, proof) {
|
|
|
1653
1707
|
if (proof === undefined)
|
|
1654
1708
|
return;
|
|
1655
1709
|
const binary = (0, resolveTsgo_1.resolveTsgo)({ cwd: node_path_1.default.dirname(tsconfig) }).binary;
|
|
1656
|
-
const current = (0, runtimeExecutableIdentity_1.runtimeExecutableIdentity)(binary);
|
|
1710
|
+
const current = (0, runtimeExecutableIdentity_1.runtimeExecutableIdentity)(binary, runtimeRecordStore());
|
|
1657
1711
|
if (current !== proof) {
|
|
1658
1712
|
E2ETrace_1.E2ETrace.capabilityResolution("runtime-compiler-publication-refused", {
|
|
1659
1713
|
tsconfig,
|