@smoothbricks/nx-plugin 0.7.18 → 0.7.19
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 +160 -99
- package/dist/.build-inputs.json +35 -29
- package/dist/built-output-packages.js +1 -1
- package/dist/cargo-closure-input.js +1 -1
- package/dist/cargo-source-hash.d.ts +3 -21
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +4 -91
- package/dist/cargo-toolchain-paths.d.ts +2 -2
- package/dist/cargo-toolchain-paths.js +2 -2
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +2 -1
- package/dist/executors/bounded-exec/admission-queue.d.ts +3 -1
- package/dist/executors/bounded-exec/admission-queue.d.ts.map +1 -1
- package/dist/executors/bounded-exec/admission-queue.js +9 -10
- package/dist/executors/bounded-exec/awake-clock.d.ts +5 -0
- package/dist/executors/bounded-exec/awake-clock.d.ts.map +1 -0
- package/dist/executors/bounded-exec/awake-clock.js +22 -0
- package/dist/executors/bounded-exec/bounds.d.ts +7 -5
- package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
- package/dist/executors/bounded-exec/bounds.js +14 -11
- package/dist/executors/bounded-exec/case-gate.d.ts +114 -0
- package/dist/executors/bounded-exec/case-gate.d.ts.map +1 -0
- package/dist/executors/bounded-exec/case-gate.js +342 -0
- package/dist/executors/bounded-exec/cpu-pool-thread.d.ts +1 -0
- package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool-thread.js +2 -2
- package/dist/executors/bounded-exec/cpu-pool.d.ts +28 -1
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +102 -16
- package/dist/executors/bounded-exec/endpoint-life.d.ts +146 -0
- package/dist/executors/bounded-exec/endpoint-life.d.ts.map +1 -0
- package/dist/executors/bounded-exec/endpoint-life.js +228 -0
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +207 -69
- package/dist/executors/bounded-exec/gateway-lease.d.ts +1 -1
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
- package/dist/executors/bounded-exec/gateway-lease.js +8 -1
- package/dist/executors/bounded-exec/go-run-summary.d.ts +51 -0
- package/dist/executors/bounded-exec/go-run-summary.d.ts.map +1 -0
- package/dist/executors/bounded-exec/go-run-summary.js +98 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +3 -3
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
- package/dist/executors/bounded-exec/hang-diagnostics.js +66 -48
- package/dist/executors/bounded-exec/lease-wait.d.ts +1 -0
- package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -1
- package/dist/executors/bounded-exec/lease-wait.js +1 -0
- package/dist/executors/bounded-exec/mbx-pool.d.ts +28 -7
- package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-pool.js +30 -9
- package/dist/executors/bounded-exec/mbx-reservations.d.ts +8 -5
- package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-reservations.js +187 -283
- package/dist/executors/bounded-exec/parent-grant.d.ts +2 -0
- package/dist/executors/bounded-exec/parent-grant.d.ts.map +1 -1
- package/dist/executors/bounded-exec/parent-grant.js +1 -0
- package/dist/executors/bounded-exec/pool-admission.d.ts +29 -3
- package/dist/executors/bounded-exec/pool-admission.d.ts.map +1 -1
- package/dist/executors/bounded-exec/pool-admission.js +47 -1
- package/dist/executors/bounded-exec/progress.d.ts +3 -0
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
- package/dist/executors/bounded-exec/progress.js +31 -1
- package/dist/executors/bounded-exec/reservation-connection.d.ts +90 -0
- package/dist/executors/bounded-exec/reservation-connection.d.ts.map +1 -0
- package/dist/executors/bounded-exec/reservation-connection.js +248 -0
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/run-cpu-pool.js +3 -0
- package/dist/executors/bounded-exec/runner-sizing.d.ts +9 -5
- package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-sizing.js +13 -9
- package/dist/executors/bounded-exec/schema.d.ts +2 -2
- package/dist/executors/bounded-exec/suite-minimum.d.ts +21 -0
- package/dist/executors/bounded-exec/suite-minimum.d.ts.map +1 -0
- package/dist/executors/bounded-exec/suite-minimum.js +85 -0
- package/dist/executors/bounded-exec/test-result-writer.d.ts +2 -0
- package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -1
- package/dist/executors/bounded-exec/test-result-writer.js +1 -0
- package/dist/executors/bounded-exec/test-results.d.ts +5 -0
- package/dist/executors/bounded-exec/test-results.d.ts.map +1 -1
- package/dist/executors/bounded-exec/test-results.js +2 -2
- package/dist/executors/bounded-exec/verdict.d.ts +26 -4
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +26 -5
- package/dist/executors/cargo-zigbuild/executor.d.ts +10 -8
- package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
- package/dist/executors/cargo-zigbuild/executor.js +32 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +105 -73
- package/dist/managed-files/ci-workflow.d.ts +4 -1
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +9 -14
- package/dist/managed-files/files.d.ts +3 -3
- package/dist/managed-files/files.js +3 -3
- package/dist/task-results.js +2 -1
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +135 -42
- package/executors.json +2 -0
- package/managed/raw/envrc +24 -0
- package/managed/raw/patches/nx@24.0.3.patch +1179 -133
- package/managed/raw/patches/ttsc@0.37.1.patch +1055 -0
- package/managed/raw/tooling/direnv/developer-links.ts +105 -11
- package/managed/raw/tooling/direnv/devenv.smoo.nix +20 -19
- package/package.json +67 -11
- package/runtime/nx-publish/.build-inputs.json +2 -2
- package/runtime/nx-publish/cache_adapter.js +293 -3
- package/runtime/nx-publish/nx_publish.js +36 -14
- package/src/built-output-packages.ts +1 -1
- package/src/cargo-closure-input.ts +1 -1
- package/src/cargo-source-hash.ts +16 -132
- package/src/cargo-toolchain-paths.ts +2 -2
- package/src/cargo-workspace.ts +1 -2
- package/src/executors/bounded-exec/admission-queue.ts +11 -10
- package/src/executors/bounded-exec/awake-clock.ts +20 -0
- package/src/executors/bounded-exec/bounds.ts +28 -15
- package/src/executors/bounded-exec/case-gate.ts +365 -0
- package/src/executors/bounded-exec/cpu-pool-thread.ts +3 -3
- package/src/executors/bounded-exec/cpu-pool.ts +139 -12
- package/src/executors/bounded-exec/endpoint-life.ts +279 -0
- package/src/executors/bounded-exec/executor.ts +280 -106
- package/src/executors/bounded-exec/gateway-lease.ts +6 -0
- package/src/executors/bounded-exec/go-run-summary.ts +137 -0
- package/src/executors/bounded-exec/hang-diagnostics.ts +70 -52
- package/src/executors/bounded-exec/lease-wait.ts +1 -0
- package/src/executors/bounded-exec/mbx-pool.ts +36 -9
- package/src/executors/bounded-exec/mbx-reservations.ts +213 -182
- package/src/executors/bounded-exec/parent-grant.ts +3 -0
- package/src/executors/bounded-exec/pool-admission.ts +59 -2
- package/src/executors/bounded-exec/progress.ts +37 -2
- package/src/executors/bounded-exec/reservation-connection.ts +221 -0
- package/src/executors/bounded-exec/run-cpu-pool.ts +2 -0
- package/src/executors/bounded-exec/runner-sizing.ts +13 -8
- package/src/executors/bounded-exec/schema.json +1 -1
- package/src/executors/bounded-exec/schema.ts +2 -2
- package/src/executors/bounded-exec/suite-minimum.ts +81 -0
- package/src/executors/bounded-exec/test-result-writer.ts +3 -0
- package/src/executors/bounded-exec/test-results.ts +5 -0
- package/src/executors/bounded-exec/verdict.ts +39 -6
- package/src/executors/cargo-zigbuild/executor.ts +30 -19
- package/src/index.ts +112 -78
- package/src/managed-files/ci-workflow.ts +13 -17
- package/src/managed-files/files.ts +3 -3
- package/src/workspace-config-policy.ts +161 -43
- package/test-timings.json +157 -147
- package/managed/raw/patches/ttsc@0.36.3.patch +0 -1660
|
@@ -1,1660 +0,0 @@
|
|
|
1
|
-
diff --git a/cmd/ttsc/api_transform.go b/cmd/ttsc/api_transform.go
|
|
2
|
-
index 4434cf69ea3b5128987c9216f871db13f827d7a4..681f59ebef551e99853737f28f1eff6f77f61262 100644
|
|
3
|
-
--- a/cmd/ttsc/api_transform.go
|
|
4
|
-
+++ b/cmd/ttsc/api_transform.go
|
|
5
|
-
@@ -55,6 +55,12 @@ type apiTransformResult struct {
|
|
6
|
-
// Null means absence; omitted keys leave symlink or junction identity unknown.
|
|
7
|
-
HostInputRealpaths map[string]*string `json:"hostInputRealpaths,omitempty"`
|
|
8
|
-
|
|
9
|
-
+ // EnvironmentInputs maps each environment variable a linked hook read
|
|
10
|
-
+ // through PluginContext.Env to the value it read; null means unset.
|
|
11
|
-
+ // Omitted when no hook read one. Names only identify inputs; values can be
|
|
12
|
-
+ // secrets and belong to the consumer's reuse check, not to logs.
|
|
13
|
-
+ EnvironmentInputs map[string]*string `json:"environmentInputs,omitempty"`
|
|
14
|
-
+
|
|
15
|
-
// ObservationsComplete is false only for an explicit unsupported observation
|
|
16
|
-
// boundary reported by a linked hook. Absence does not prove completeness.
|
|
17
|
-
ObservationsComplete *bool `json:"observationsComplete,omitempty"`
|
|
18
|
-
@@ -115,6 +121,7 @@ func writeTransformedProgramResponse(prog *driver.Program, diags []driver.Diagno
|
|
19
|
-
var hostInputs []string
|
|
20
|
-
var hostInputHashes map[string]*string
|
|
21
|
-
var hostInputRealpaths map[string]*string
|
|
22
|
-
+ var environmentInputs map[string]*string
|
|
23
|
-
var observationsComplete *bool
|
|
24
|
-
if prog == nil {
|
|
25
|
-
unavailable := false
|
|
26
|
-
@@ -134,6 +141,7 @@ func writeTransformedProgramResponse(prog *driver.Program, diags []driver.Diagno
|
|
27
|
-
hostInputs = prog.PluginHostInputs()
|
|
28
|
-
hostInputHashes = prog.PluginHostInputHashes()
|
|
29
|
-
hostInputRealpaths = prog.PluginHostInputRealpaths()
|
|
30
|
-
+ environmentInputs = prog.PluginEnvironmentInputs()
|
|
31
|
-
if prog.PluginObservationsIncomplete() {
|
|
32
|
-
incomplete := false
|
|
33
|
-
observationsComplete = &incomplete
|
|
34
|
-
@@ -148,6 +156,7 @@ func writeTransformedProgramResponse(prog *driver.Program, diags []driver.Diagno
|
|
35
|
-
HostInputs: hostInputs,
|
|
36
|
-
HostInputHashes: hostInputHashes,
|
|
37
|
-
HostInputRealpaths: hostInputRealpaths,
|
|
38
|
-
+ EnvironmentInputs: environmentInputs,
|
|
39
|
-
ObservationsComplete: observationsComplete,
|
|
40
|
-
TypeScript: typescript,
|
|
41
|
-
}
|
|
42
|
-
diff --git a/cmd/ttsc/build.go b/cmd/ttsc/build.go
|
|
43
|
-
index 3140699bdd3f26f8513f95d8750ed632a99fc425..f7b39f13238a59cefa2716d61ee978a73c369bbf 100644
|
|
44
|
-
--- a/cmd/ttsc/build.go
|
|
45
|
-
+++ b/cmd/ttsc/build.go
|
|
46
|
-
@@ -137,6 +137,7 @@ func writeBuildProgramResponse(prog *driver.Program, diags []driver.Diagnostic,
|
|
47
|
-
}
|
|
48
|
-
fmt.Fprintln(stdout, " +", rel)
|
|
49
|
-
}
|
|
50
|
-
+ driver.WriteEnvironmentInputsSummary(stdout, "// ttsc: ", prog)
|
|
51
|
-
}
|
|
52
|
-
if request.manifestPath != "" {
|
|
53
|
-
// The manifest is intentionally just the emitted file list. Higher
|
|
54
|
-
diff --git a/driver/check_observations.go b/driver/check_observations.go
|
|
55
|
-
index ef50afa6c3f02f80951c4ebd367c670a842aa0db..8e48e460fcff160c3e7e8f77abc211ff060e766f 100644
|
|
56
|
-
--- a/driver/check_observations.go
|
|
57
|
-
+++ b/driver/check_observations.go
|
|
58
|
-
@@ -19,6 +19,8 @@ import (
|
|
59
|
-
// the population complete or repair missing or conflicting individual proofs.
|
|
60
|
-
// The caller owns a fresh result path, its parent directory and eventual artifact
|
|
61
|
-
// removal. Publication occurs only after a temporary write and close succeed.
|
|
62
|
-
+// Environment variables the hooks read through PluginContext.Env travel in
|
|
63
|
-
+// environmentInputs with their recorded values, omitted when none was read.
|
|
64
|
-
//
|
|
65
|
-
// @evidence contracts/common.md#principled-implementation The same loaded Program supplies recorded input names and consistent supplied content and physical-path reports; missing generation authority is explicitly incomplete, while diagnostics and individual conflicts retain their independent meanings.
|
|
66
|
-
// @evidence contracts/common.md#clear-and-simple-design One typed wire object keeps hook observations separate from human diagnostic streams and never reloads a second compiler generation to reconstruct them.
|
|
67
|
-
@@ -52,6 +54,7 @@ func WriteCheckRecoveryObservationsJSON(fileName string, program *Program, recov
|
|
68
|
-
inputs := []string{}
|
|
69
|
-
hashes := map[string]*string{}
|
|
70
|
-
realpaths := map[string]*string{}
|
|
71
|
-
+ var environment map[string]*string
|
|
72
|
-
var complete *bool
|
|
73
|
-
var graph *TransformGraph
|
|
74
|
-
if program == nil {
|
|
75
|
-
@@ -74,14 +77,16 @@ func WriteCheckRecoveryObservationsJSON(fileName string, program *Program, recov
|
|
76
|
-
if recorded := program.PluginHostInputRealpaths(); recorded != nil {
|
|
77
|
-
realpaths = recorded
|
|
78
|
-
}
|
|
79
|
-
+ environment = program.PluginEnvironmentInputs()
|
|
80
|
-
}
|
|
81
|
-
data, err := json.Marshal(struct {
|
|
82
|
-
Graph *TransformGraph `json:"graph,omitempty"`
|
|
83
|
-
HostInputs []string `json:"hostInputs"`
|
|
84
|
-
HostInputHashes map[string]*string `json:"hostInputHashes"`
|
|
85
|
-
HostInputRealpaths map[string]*string `json:"hostInputRealpaths"`
|
|
86
|
-
+ EnvironmentInputs map[string]*string `json:"environmentInputs,omitempty"`
|
|
87
|
-
ObservationsComplete *bool `json:"observationsComplete,omitempty"`
|
|
88
|
-
- }{graph, inputs, hashes, realpaths, complete})
|
|
89
|
-
+ }{graph, inputs, hashes, realpaths, environment, complete})
|
|
90
|
-
if err != nil {
|
|
91
|
-
return err
|
|
92
|
-
}
|
|
93
|
-
diff --git a/driver/emit_plugin.go b/driver/emit_plugin.go
|
|
94
|
-
index 3793b3a406c2bf2643567a755d34e66a26eac5c8..3c690ac3d9a99be7914ad9aed76e5890d236ea9b 100644
|
|
95
|
-
--- a/driver/emit_plugin.go
|
|
96
|
-
+++ b/driver/emit_plugin.go
|
|
97
|
-
@@ -427,7 +427,13 @@ func (p *Program) EmitWithPluginTransformers(transforms []PluginTransform, write
|
|
98
|
-
return diagnostics, err
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
- return diagnostics, output.flush()
|
|
102
|
-
+ if err := output.flush(); err != nil {
|
|
103
|
-
+ return diagnostics, err
|
|
104
|
-
+ }
|
|
105
|
-
+ // Files linked plugins reported writing beside these outputs follow them
|
|
106
|
-
+ // through the host's writer, so the host lists them too (ReportHostOutput).
|
|
107
|
-
+ _, err = p.writeHostOutputs(writeFile)
|
|
108
|
-
+ return diagnostics, err
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// writePluginEmitOutput writes one artifact of the hand-assembled emit, passing
|
|
112
|
-
diff --git a/driver/environment_inputs.go b/driver/environment_inputs.go
|
|
113
|
-
new file mode 100644
|
|
114
|
-
index 0000000000000000000000000000000000000000..4dcac95a1ea40978bba81e3e2ab9c5775b3c5b64
|
|
115
|
-
--- /dev/null
|
|
116
|
-
+++ b/driver/environment_inputs.go
|
|
117
|
-
@@ -0,0 +1,42 @@
|
|
118
|
-
+package driver
|
|
119
|
-
+
|
|
120
|
-
+import (
|
|
121
|
-
+ "encoding/json"
|
|
122
|
-
+ "fmt"
|
|
123
|
-
+ "io"
|
|
124
|
-
+ "sort"
|
|
125
|
-
+)
|
|
126
|
-
+
|
|
127
|
-
+// WriteEnvironmentInputsSummary writes the build summary line naming the
|
|
128
|
-
+// environment variables the Program's linked hooks read through
|
|
129
|
-
+// PluginContext.Env, as `<prefix>environment inputs=<sorted JSON array>`. It
|
|
130
|
-
+// writes nothing when no hook read one, so builds of plugins that read no
|
|
131
|
-
+// environment print the same summary as before. Only names are printed:
|
|
132
|
-
+// values can be secrets, and the envelope carries them to the consumers that
|
|
133
|
-
+// compare them. Like the summary lines around it, the write is best-effort.
|
|
134
|
-
+//
|
|
135
|
-
+// @evidence contracts/common.md#principled-implementation The names come from the same generation ledger the envelopes publish, sorted so the line is deterministic.
|
|
136
|
-
+// @evidence contracts/common.md#clear-and-simple-design One writer owns the line's format for every build lane; each lane supplies its own summary prefix.
|
|
137
|
-
+// @evidence contracts/common.md#prohibited-implementation-shortcuts Values never reach the output stream, and an empty ledger prints nothing rather than an empty list.
|
|
138
|
-
+// @evidence contracts/common.md#meaningful-documentation Native prose states the line format, the empty case, why values are withheld and the best-effort write following the documentation skill.
|
|
139
|
-
+// @evidenceExclude contracts/portability.md#os-neutral-implementation The writer formats recorded names and performs no native path or process operation.
|
|
140
|
-
+// @evidence contracts/performance.md#efficient-algorithms One ledger copy, an O(n log n) sort of the distinct names and one JSON encoding.
|
|
141
|
-
+// @evidenceExclude contracts/performance.md#reuse-equivalent-work Formatting a summary coordinates no shared computation.
|
|
142
|
-
+// @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The name list and encoding are call-local; the caller owns the writer.
|
|
143
|
-
+func WriteEnvironmentInputsSummary(w io.Writer, prefix string, p *Program) {
|
|
144
|
-
+ inputs := p.PluginEnvironmentInputs()
|
|
145
|
-
+ if len(inputs) == 0 {
|
|
146
|
-
+ return
|
|
147
|
-
+ }
|
|
148
|
-
+ names := make([]string, 0, len(inputs))
|
|
149
|
-
+ for name := range inputs {
|
|
150
|
-
+ names = append(names, name)
|
|
151
|
-
+ }
|
|
152
|
-
+ sort.Strings(names)
|
|
153
|
-
+ encoded, err := json.Marshal(names)
|
|
154
|
-
+ if err != nil {
|
|
155
|
-
+ // encoding/json cannot fail on a []string.
|
|
156
|
-
+ panic(err)
|
|
157
|
-
+ }
|
|
158
|
-
+ fmt.Fprintf(w, "%senvironment inputs=%s\n", prefix, encoded)
|
|
159
|
-
+}
|
|
160
|
-
diff --git a/driver/force_emit_analysis_options_test.go b/driver/force_emit_analysis_options_test.go
|
|
161
|
-
new file mode 100644
|
|
162
|
-
index 0000000000000000000000000000000000000000..97d1522f7979b488dc62b86cc1d78d72f1913cb5
|
|
163
|
-
--- /dev/null
|
|
164
|
-
+++ b/driver/force_emit_analysis_options_test.go
|
|
165
|
-
@@ -0,0 +1,69 @@
|
|
166
|
-
+package driver
|
|
167
|
-
+
|
|
168
|
-
+import (
|
|
169
|
-
+ "os"
|
|
170
|
-
+ "path/filepath"
|
|
171
|
-
+ "strings"
|
|
172
|
-
+ "testing"
|
|
173
|
-
+
|
|
174
|
-
+ shimast "github.com/microsoft/typescript-go/shim/ast"
|
|
175
|
-
+ shimcompiler "github.com/microsoft/typescript-go/shim/compiler"
|
|
176
|
-
+ shimprinter "github.com/microsoft/typescript-go/shim/printer"
|
|
177
|
-
+)
|
|
178
|
-
+
|
|
179
|
-
+func TestForceEmitRewritesAnalysisOnlyImports(t *testing.T) {
|
|
180
|
-
+ root, err := filepath.EvalSymlinks(t.TempDir())
|
|
181
|
-
+ if err != nil {
|
|
182
|
-
+ t.Fatal(err)
|
|
183
|
-
+ }
|
|
184
|
-
+ files := map[string]string{
|
|
185
|
-
+ "tsconfig.json": `{"compilerOptions":{"target":"ES2022","module":"ESNext","moduleResolution":"Bundler","types":[],"strict":true,"noEmit":true,"noEmitOnError":true,"allowImportingTsExtensions":true,"outDir":"out"},"files":["index.ts","dependency.ts"]}`,
|
|
186
|
-
+ "dependency.ts": `export const value = 7;`,
|
|
187
|
-
+ "index.ts": `import { value } from "./dependency.ts"; export const result = value;`,
|
|
188
|
-
+ }
|
|
189
|
-
+ for name, text := range files {
|
|
190
|
-
+ if err := os.WriteFile(filepath.Join(root, name), []byte(text), 0o644); err != nil {
|
|
191
|
-
+ t.Fatal(err)
|
|
192
|
-
+ }
|
|
193
|
-
+ }
|
|
194
|
-
+ analysis, diagnostics, err := LoadProgram(root, "tsconfig.json", LoadProgramOptions{})
|
|
195
|
-
+ if err != nil || CountErrors(diagnostics) != 0 {
|
|
196
|
-
+ t.Fatalf("analysis load failed: %v; %v", err, diagnostics)
|
|
197
|
-
+ }
|
|
198
|
-
+ defer analysis.Close()
|
|
199
|
-
+ if diagnostics := analysis.Diagnostics(); CountErrors(diagnostics) != 0 {
|
|
200
|
-
+ t.Fatalf("valid analysis-only imports failed checking: %v", diagnostics)
|
|
201
|
-
+ }
|
|
202
|
-
+ diagnostics, err = analysis.EmitWithPluginTransformer(
|
|
203
|
-
+ func(_ *shimprinter.EmitContext, source *shimast.SourceFile) *shimast.SourceFile {
|
|
204
|
-
+ t.Fatal("analysis-only program ran a JavaScript emit hook")
|
|
205
|
-
+ return source
|
|
206
|
-
+ },
|
|
207
|
-
+ func(name, text string, _ *shimcompiler.WriteFileData) error {
|
|
208
|
-
+ t.Fatalf("analysis-only program wrote %s", name)
|
|
209
|
-
+ return nil
|
|
210
|
-
+ },
|
|
211
|
-
+ )
|
|
212
|
-
+ if err != nil || CountErrors(diagnostics) != 0 {
|
|
213
|
-
+ t.Fatalf("analysis-only emit failed: %v; %v", err, diagnostics)
|
|
214
|
-
+ }
|
|
215
|
-
+ emitting, diagnostics, err := LoadProgram(root, "tsconfig.json", LoadProgramOptions{ForceEmit: true})
|
|
216
|
-
+ if err != nil || CountErrors(diagnostics) != 0 {
|
|
217
|
-
+ t.Fatalf("forced emit load failed: %v; %v", err, diagnostics)
|
|
218
|
-
+ }
|
|
219
|
-
+ defer emitting.Close()
|
|
220
|
-
+ output := make(map[string]string)
|
|
221
|
-
+ diagnostics, err = emitting.EmitWithPluginTransformer(
|
|
222
|
-
+ func(_ *shimprinter.EmitContext, source *shimast.SourceFile) *shimast.SourceFile { return source },
|
|
223
|
-
+ func(name, text string, _ *shimcompiler.WriteFileData) error {
|
|
224
|
-
+ output[filepath.Base(name)] = text
|
|
225
|
-
+ return nil
|
|
226
|
-
+ },
|
|
227
|
-
+ )
|
|
228
|
-
+ if err != nil || CountErrors(diagnostics) != 0 {
|
|
229
|
-
+ t.Fatalf("forced emit rejected analysis-only imports: %v; %v", err, diagnostics)
|
|
230
|
-
+ }
|
|
231
|
-
+ if !strings.Contains(output["index.js"], `from "./dependency.js"`) {
|
|
232
|
-
+ t.Fatalf("forced emit did not rewrite the runtime import: %s", output["index.js"])
|
|
233
|
-
+ }
|
|
234
|
-
+}
|
|
235
|
-
diff --git a/driver/plugins.go b/driver/plugins.go
|
|
236
|
-
index 1778e250d80d1316e108f1f36b6e1a38724922d5..f5997531e4142526bd8764c6db15aa393fb9781a 100644
|
|
237
|
-
--- a/driver/plugins.go
|
|
238
|
-
+++ b/driver/plugins.go
|
|
239
|
-
@@ -8,6 +8,8 @@ import (
|
|
240
|
-
"sort"
|
|
241
|
-
"strings"
|
|
242
|
-
"sync"
|
|
243
|
-
+
|
|
244
|
-
+ "github.com/microsoft/typescript-go/shim/ast"
|
|
245
|
-
)
|
|
246
|
-
|
|
247
|
-
// LinkedPluginsEnv is the environment variable ttsc sets to pass the JSON
|
|
248
|
-
@@ -169,6 +171,8 @@ type PluginContext struct {
|
|
249
|
-
reportFileDependencyRejected func(string)
|
|
250
|
-
reportFileComplete func(string)
|
|
251
|
-
reportEveryFileComplete func()
|
|
252
|
-
+ readEnvironment func(string) (string, bool)
|
|
253
|
-
+ reportHostOutput func(string)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// ReportObservationIncomplete declares that this hook's input population could
|
|
257
|
-
@@ -195,6 +199,60 @@ func (ctx PluginContext) ReportObservationIncomplete() {
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
+// ReportHostOutput declares a file this hook wrote beside the compiler's
|
|
262
|
-
+// outputs, such as a census or a manifest in outDir. A later emit of this
|
|
263
|
-
+// generation hands the file's bytes as they are then to the host's writer,
|
|
264
|
-
+// after the compiler's own outputs, so every host lists it with them: a caller
|
|
265
|
-
+// that keeps exactly the files an emit lists (a build that prunes its outDir by
|
|
266
|
-
+// that list) keeps it too. A relative file is resolved against Cwd. An emit
|
|
267
|
-
+// fails when a reported file cannot be read. A context without a driver
|
|
268
|
-
+// callback ignores the report.
|
|
269
|
-
+func (ctx PluginContext) ReportHostOutput(file string) {
|
|
270
|
-
+ if ctx.reportHostOutput == nil || strings.TrimSpace(file) == "" {
|
|
271
|
-
+ return
|
|
272
|
-
+ }
|
|
273
|
-
+ if !filepath.IsAbs(file) {
|
|
274
|
-
+ file = filepath.Join(ctx.Cwd, file)
|
|
275
|
-
+ }
|
|
276
|
-
+ ctx.reportHostOutput(filepath.Clean(file))
|
|
277
|
-
+}
|
|
278
|
-
+
|
|
279
|
-
+// Env returns the value of the environment variable name, like os.LookupEnv,
|
|
280
|
-
+// and records the read as an input of this compiler generation. A plugin whose
|
|
281
|
-
+// output depends on a variable reads it here instead of calling os.Getenv, so
|
|
282
|
-
+// the envelope's environmentInputs names it and persistent hosts withdraw
|
|
283
|
-
+// output compiled under another value. The first read of a name fixes its
|
|
284
|
-
+// value for the whole generation: a later read returns the recorded value even
|
|
285
|
-
+// if the process environment changed in between, so the output never depends
|
|
286
|
-
+// on a value the record does not carry. ok is false for an unset variable, and
|
|
287
|
-
+// that absence is recorded too.
|
|
288
|
-
+//
|
|
289
|
-
+// A name that cannot name a variable (empty, or containing '=' or NUL) reads
|
|
290
|
-
+// as unset and is not recorded. A context without a driver callback reads the
|
|
291
|
-
+// process environment without recording it.
|
|
292
|
-
+//
|
|
293
|
-
+// The precedents are Rust's proc_macro::tracked_env::var, Cargo's
|
|
294
|
-
+// rerun-if-env-changed, and Racket's register-external-file: the read site
|
|
295
|
-
+// itself declares the dependency, so no tool keeps a list of variables.
|
|
296
|
-
+//
|
|
297
|
-
+// @evidence contracts/common.md#principled-implementation The read site records the exact name and value or absence it returned, and the generation ledger returns the first recorded value for every later read, so output and record cannot disagree.
|
|
298
|
-
+// @evidence contracts/common.md#clear-and-simple-design One callback delegates to the generation ledger; name validation precedes it and the uncallbacked context falls back to os.LookupEnv.
|
|
299
|
-
+// @evidence contracts/common.md#prohibited-implementation-shortcuts No static variable list, prefix rule or intercepted os.Getenv replaces the explicit read; values are not hashed or redacted, so equality checks compare what the plugin saw.
|
|
300
|
-
+// @evidence contracts/common.md#meaningful-documentation Native paragraphs state the lookup semantics, first-read fixing, absence recording, invalid names and the precedents following the documentation skill.
|
|
301
|
-
+// @evidence contracts/portability.md#os-neutral-implementation os.LookupEnv supplies the platform's own name matching, including Windows case-insensitivity; the recorded name keeps the caller's spelling and consumers compare it under their platform's environment rule.
|
|
302
|
-
+// @evidence contracts/performance.md#bound-retention-and-release-resources The ledger retains one name and value copy per distinct name read for the generation's lifetime; repeated reads add nothing. No handle is acquired and no cap is imposed.
|
|
303
|
-
+// @evidence contracts/performance.md#efficient-algorithms Name validation scans the name once; the ledger takes one lock and one map lookup, plus one os.LookupEnv on the first read of a name.
|
|
304
|
-
+// @evidenceExclude contracts/performance.md#reuse-equivalent-work Recording an input coordinates no completed or in-flight computation; consumers decide reuse from the record.
|
|
305
|
-
+func (ctx PluginContext) Env(name string) (string, bool) {
|
|
306
|
-
+ if name == "" || strings.ContainsAny(name, "=\x00") {
|
|
307
|
-
+ return "", false
|
|
308
|
-
+ }
|
|
309
|
-
+ if ctx.readEnvironment == nil {
|
|
310
|
-
+ return os.LookupEnv(name)
|
|
311
|
-
+ }
|
|
312
|
-
+ return ctx.readEnvironment(name)
|
|
313
|
-
+}
|
|
314
|
-
+
|
|
315
|
-
// ReportHostInputHash declares the exact file state consumed by a native
|
|
316
|
-
// plugin. hash is a lowercase SHA-256 digest for an observed file and nil for
|
|
317
|
-
// a missing candidate. Conflicting observations are retained as host inputs
|
|
318
|
-
@@ -506,11 +564,29 @@ type EmitTransformPlugin interface {
|
|
319
|
-
EmitTransform(PluginContext) (PluginTransform, error)
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
+// DiagnosticPlugin is a linked plugin whose ProgramPlugin lowers a construct
|
|
323
|
-
+// the stock checker refuses, a dialect its compiles admit: a source spelling
|
|
324
|
-
+// the plugin rewrites before emit or a transform's output, which TypeScript has
|
|
325
|
-
+// no grammar for. The checker judges the parse tree before any ProgramPlugin
|
|
326
|
-
+// applies, so its refusal of such a construct names nothing the output holds,
|
|
327
|
-
+// and every lane that gates on the program's diagnostics (check, emit, a
|
|
328
|
-
+// transform) would refuse the dialect it was built to compile.
|
|
329
|
-
+// LoweredDiagnostics names those refusals among the diagnostics it is given;
|
|
330
|
-
+// the driver drops exactly the ones it names that it gave, and reports every
|
|
331
|
-
+// other diagnostic as it would without the plugin.
|
|
332
|
-
+type DiagnosticPlugin interface {
|
|
333
|
-
+ // LoweredDiagnostics returns the diagnostics, among those given, whose cause
|
|
334
|
-
+ // this plugin's ProgramPlugin removes. It reads the parse tree the checker
|
|
335
|
-
+ // judged, before any ProgramPlugin applies.
|
|
336
|
-
+ LoweredDiagnostics(*Program, PluginContext, []*ast.Diagnostic) []*ast.Diagnostic
|
|
337
|
-
+}
|
|
338
|
-
+
|
|
339
|
-
type linkedPluginState struct {
|
|
340
|
-
cwd string
|
|
341
|
-
declarations *pluginFileDeclarations
|
|
342
|
-
entries []PluginEntry
|
|
343
|
-
inputs *pluginHostInputScopes
|
|
344
|
-
+ outputs *pluginHostOutputs
|
|
345
|
-
tsconfig string
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
@@ -518,9 +594,57 @@ type linkedPluginState struct {
|
|
349
|
-
// one hook cannot prove another hook's same-file dependency when that hook only
|
|
350
|
-
// reported the path, while ReportHostInput followed by ReportHostInputHash in
|
|
351
|
-
// one hook remains one complete observation.
|
|
352
|
-
+//
|
|
353
|
-
+// Environment reads are kept once per generation instead: a value is a
|
|
354
|
-
+// complete observation by itself, and every hook must see the value the
|
|
355
|
-
+// generation records, so the first read of a name fixes it for all of them.
|
|
356
|
-
type pluginHostInputScopes struct {
|
|
357
|
-
- mu sync.Mutex
|
|
358
|
-
- scopes []*pluginHostInputs
|
|
359
|
-
+ mu sync.Mutex
|
|
360
|
-
+ scopes []*pluginHostInputs
|
|
361
|
-
+ environment map[string]*string
|
|
362
|
-
+}
|
|
363
|
-
+
|
|
364
|
-
+// readEnvironment returns the generation's recorded value of name, reading and
|
|
365
|
-
+// recording the process environment on the first read. A nil ledger records
|
|
366
|
-
+// nothing.
|
|
367
|
-
+func (inputs *pluginHostInputScopes) readEnvironment(name string) (string, bool) {
|
|
368
|
-
+ if inputs == nil {
|
|
369
|
-
+ return os.LookupEnv(name)
|
|
370
|
-
+ }
|
|
371
|
-
+ inputs.mu.Lock()
|
|
372
|
-
+ defer inputs.mu.Unlock()
|
|
373
|
-
+ recorded, exists := inputs.environment[name]
|
|
374
|
-
+ if !exists {
|
|
375
|
-
+ if value, ok := os.LookupEnv(name); ok {
|
|
376
|
-
+ recorded = &value
|
|
377
|
-
+ }
|
|
378
|
-
+ if inputs.environment == nil {
|
|
379
|
-
+ inputs.environment = map[string]*string{}
|
|
380
|
-
+ }
|
|
381
|
-
+ inputs.environment[name] = recorded
|
|
382
|
-
+ }
|
|
383
|
-
+ if recorded == nil {
|
|
384
|
-
+ return "", false
|
|
385
|
-
+ }
|
|
386
|
-
+ return *recorded, true
|
|
387
|
-
+}
|
|
388
|
-
+
|
|
389
|
-
+// environmentList copies the recorded environment reads, or returns nil when
|
|
390
|
-
+// no hook read one.
|
|
391
|
-
+func (inputs *pluginHostInputScopes) environmentList() map[string]*string {
|
|
392
|
-
+ if inputs == nil {
|
|
393
|
-
+ return nil
|
|
394
|
-
+ }
|
|
395
|
-
+ inputs.mu.Lock()
|
|
396
|
-
+ defer inputs.mu.Unlock()
|
|
397
|
-
+ if len(inputs.environment) == 0 {
|
|
398
|
-
+ return nil
|
|
399
|
-
+ }
|
|
400
|
-
+ environment := make(map[string]*string, len(inputs.environment))
|
|
401
|
-
+ for name, value := range inputs.environment {
|
|
402
|
-
+ environment[name] = cloneStringPointer(value)
|
|
403
|
-
+ }
|
|
404
|
-
+ return environment
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
type pluginHostInputs struct {
|
|
408
|
-
@@ -800,6 +924,7 @@ func loadLinkedPluginState(cwd, tsconfigPath string) (linkedPluginState, error)
|
|
409
|
-
cwd: cwd,
|
|
410
|
-
declarations: newPluginFileDeclarations(),
|
|
411
|
-
inputs: newPluginHostInputScopes(),
|
|
412
|
-
+ outputs: newPluginHostOutputs(),
|
|
413
|
-
tsconfig: tsconfigPath,
|
|
414
|
-
}, nil
|
|
415
|
-
}
|
|
416
|
-
@@ -812,6 +937,7 @@ func loadLinkedPluginState(cwd, tsconfigPath string) (linkedPluginState, error)
|
|
417
|
-
declarations: newPluginFileDeclarations(),
|
|
418
|
-
entries: entries,
|
|
419
|
-
inputs: newPluginHostInputScopes(),
|
|
420
|
-
+ outputs: newPluginHostOutputs(),
|
|
421
|
-
tsconfig: tsconfigPath,
|
|
422
|
-
}, nil
|
|
423
|
-
}
|
|
424
|
-
@@ -896,6 +1022,42 @@ func (state linkedPluginState) emitTransforms() ([]PluginTransform, error) {
|
|
425
|
-
return out, nil
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
+// dropLoweredDiagnostics removes from in every diagnostic a registered
|
|
429
|
-
+// DiagnosticPlugin names as lowered. Each plugin is asked, in registration
|
|
430
|
-
+// order, about what the plugins before it kept; a diagnostic it names that it
|
|
431
|
-
+// was not given is ignored, so a plugin can only withdraw a diagnostic, never
|
|
432
|
-
+// add one. An entry with no registration is skipped here: apply reports it.
|
|
433
|
-
+func (state linkedPluginState) dropLoweredDiagnostics(prog *Program, in []*ast.Diagnostic) []*ast.Diagnostic {
|
|
434
|
-
+ for index, entry := range state.entries {
|
|
435
|
-
+ if len(in) == 0 {
|
|
436
|
-
+ return in
|
|
437
|
-
+ }
|
|
438
|
-
+ plugin, ok := registeredPlugin(index)
|
|
439
|
-
+ if !ok {
|
|
440
|
-
+ continue
|
|
441
|
-
+ }
|
|
442
|
-
+ judge, ok := plugin.(DiagnosticPlugin)
|
|
443
|
-
+ if !ok {
|
|
444
|
-
+ continue
|
|
445
|
-
+ }
|
|
446
|
-
+ lowered := map[*ast.Diagnostic]struct{}{}
|
|
447
|
-
+ for _, diagnostic := range judge.LoweredDiagnostics(prog, state.contextAt(index, entry), in) {
|
|
448
|
-
+ lowered[diagnostic] = struct{}{}
|
|
449
|
-
+ }
|
|
450
|
-
+ if len(lowered) == 0 {
|
|
451
|
-
+ continue
|
|
452
|
-
+ }
|
|
453
|
-
+ kept := make([]*ast.Diagnostic, 0, len(in))
|
|
454
|
-
+ for _, diagnostic := range in {
|
|
455
|
-
+ if _, drop := lowered[diagnostic]; !drop {
|
|
456
|
-
+ kept = append(kept, diagnostic)
|
|
457
|
-
+ }
|
|
458
|
-
+ }
|
|
459
|
-
+ in = kept
|
|
460
|
-
+ }
|
|
461
|
-
+ return in
|
|
462
|
-
+}
|
|
463
|
-
+
|
|
464
|
-
// registeredPlugin returns the plugin registered at position index, or
|
|
465
|
-
// (nil, false) when the index is out of range. Registration order matches
|
|
466
|
-
// the order of linked Go init() calls.
|
|
467
|
-
@@ -913,7 +1075,8 @@ func registeredPlugin(index int) (any, bool) {
|
|
468
|
-
// declarations are scoped per plugin instead: completeness is a claim about
|
|
469
|
-
// everything one plugin contributes to a file, so the claims of its preamble
|
|
470
|
-
// and program hooks are the same plugin's claim and must not be attributed
|
|
471
|
-
-// separately.
|
|
472
|
-
+// separately. Environment reads go to the generation ledger, which fixes one
|
|
473
|
-
+// value per name for every hook.
|
|
474
|
-
func (state linkedPluginState) contextAt(index int, entry PluginEntry) PluginContext {
|
|
475
|
-
inputs := state.inputs.newScope()
|
|
476
|
-
declaration := state.declarations.forPlugin(index)
|
|
477
|
-
@@ -931,7 +1094,44 @@ func (state linkedPluginState) contextAt(index int, entry PluginEntry) PluginCon
|
|
478
|
-
reportFileDependencyRejected: declaration.rejectDependency,
|
|
479
|
-
reportFileComplete: declaration.addComplete,
|
|
480
|
-
reportEveryFileComplete: declaration.completeEveryFile,
|
|
481
|
-
+ readEnvironment: state.inputs.readEnvironment,
|
|
482
|
-
+ reportHostOutput: state.outputs.add,
|
|
483
|
-
+ }
|
|
484
|
-
+}
|
|
485
|
-
+
|
|
486
|
-
+// pluginHostOutputs keeps the files linked plugins reported writing beside the
|
|
487
|
-
+// compiler's outputs in this generation (ReportHostOutput), each once, in the
|
|
488
|
-
+// order first reported.
|
|
489
|
-
+type pluginHostOutputs struct {
|
|
490
|
-
+ mu sync.Mutex
|
|
491
|
-
+ seen map[string]struct{}
|
|
492
|
-
+ files []string
|
|
493
|
-
+}
|
|
494
|
-
+
|
|
495
|
-
+func newPluginHostOutputs() *pluginHostOutputs {
|
|
496
|
-
+ return &pluginHostOutputs{seen: map[string]struct{}{}}
|
|
497
|
-
+}
|
|
498
|
-
+
|
|
499
|
-
+func (outputs *pluginHostOutputs) add(file string) {
|
|
500
|
-
+ if outputs == nil {
|
|
501
|
-
+ return
|
|
502
|
-
+ }
|
|
503
|
-
+ outputs.mu.Lock()
|
|
504
|
-
+ defer outputs.mu.Unlock()
|
|
505
|
-
+ if _, ok := outputs.seen[file]; ok {
|
|
506
|
-
+ return
|
|
507
|
-
}
|
|
508
|
-
+ outputs.seen[file] = struct{}{}
|
|
509
|
-
+ outputs.files = append(outputs.files, file)
|
|
510
|
-
+}
|
|
511
|
-
+
|
|
512
|
-
+func (outputs *pluginHostOutputs) list() []string {
|
|
513
|
-
+ if outputs == nil {
|
|
514
|
-
+ return nil
|
|
515
|
-
+ }
|
|
516
|
-
+ outputs.mu.Lock()
|
|
517
|
-
+ defer outputs.mu.Unlock()
|
|
518
|
-
+ return append([]string(nil), outputs.files...)
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
// hostInputs returns the exact native configuration inputs reported in this
|
|
522
|
-
@@ -947,3 +1147,7 @@ func (state linkedPluginState) hostInputHashes() map[string]*string {
|
|
523
|
-
func (state linkedPluginState) hostInputRealpaths() map[string]*string {
|
|
524
|
-
return state.inputs.realpathList()
|
|
525
|
-
}
|
|
526
|
-
+
|
|
527
|
-
+func (state linkedPluginState) environmentInputs() map[string]*string {
|
|
528
|
-
+ return state.inputs.environmentList()
|
|
529
|
-
+}
|
|
530
|
-
diff --git a/driver/program.go b/driver/program.go
|
|
531
|
-
index 3a061b06bb7d1fa8ff5a8f7454634c158a6848a4..c5330185a700ac39c5ec87d7630d6cf4eb7ac953 100644
|
|
532
|
-
--- a/driver/program.go
|
|
533
|
-
+++ b/driver/program.go
|
|
534
|
-
@@ -792,6 +792,12 @@ func forceEmit(parsed *tsoptions.ParsedCommandLine) {
|
|
535
|
-
options := parsed.ParsedConfig.CompilerOptions
|
|
536
|
-
options.NoEmit = core.TSFalse
|
|
537
|
-
options.EmitDeclarationOnly = core.TSFalse
|
|
538
|
-
+ // Match the CLI's --emit override: TypeScript-extension imports must become
|
|
539
|
-
+ // JavaScript-extension imports when an analysis-only program is emitted,
|
|
540
|
-
+ // including private plugin traversals whose caller discards the output.
|
|
541
|
-
+ if options.AllowImportingTsExtensions.IsTrue() {
|
|
542
|
-
+ options.RewriteRelativeImportExtensions = core.TSTrue
|
|
543
|
-
+ }
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
// forceNoEmit sets noEmit so the program type-checks without writing files.
|
|
547
|
-
@@ -1069,6 +1075,28 @@ func (p *Program) PluginHostInputRealpaths() map[string]*string {
|
|
548
|
-
return p.plugins.hostInputRealpaths()
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
+// PluginEnvironmentInputs returns every environment variable a linked hook
|
|
552
|
-
+// read through PluginContext.Env while this Program was loaded or transformed,
|
|
553
|
-
+// keyed by the name the hook passed, with the value the generation recorded
|
|
554
|
-
+// for it. A nil value records that the variable was unset. The result is nil
|
|
555
|
-
+// when no hook read one, so a plugin that reads no environment leaves every
|
|
556
|
-
+// envelope unchanged. It does not run a pending ProgramPlugin hook.
|
|
557
|
-
+//
|
|
558
|
-
+// @evidence contracts/common.md#principled-implementation The ledger keeps the first value each name returned, so the reported value is the one every hook's output was computed from.
|
|
559
|
-
+// @evidence contracts/common.md#clear-and-simple-design One generation ledger owns the reads; this accessor copies it beside the host-input accessors.
|
|
560
|
-
+// @evidence contracts/common.md#prohibited-implementation-shortcuts Nothing is read from the process environment here; an unrecorded variable is never added after the fact.
|
|
561
|
-
+// @evidence contracts/common.md#meaningful-documentation Native prose defines keys, values, nil absence, the empty result and hook timing following the documentation skill.
|
|
562
|
-
+// @evidenceExclude contracts/portability.md#os-neutral-implementation Recorded names and values are returned without native environment access or name normalization.
|
|
563
|
-
+// @evidence contracts/performance.md#efficient-algorithms One lock and one copy of the recorded names and values; cost is linear in distinct names read.
|
|
564
|
-
+// @evidenceExclude contracts/performance.md#reuse-equivalent-work This accessor exposes recorded inputs without deciding reuse.
|
|
565
|
-
+// @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The returned copy is caller-owned and no additional state is retained.
|
|
566
|
-
+func (p *Program) PluginEnvironmentInputs() map[string]*string {
|
|
567
|
-
+ if p == nil {
|
|
568
|
-
+ return nil
|
|
569
|
-
+ }
|
|
570
|
-
+ return p.plugins.environmentInputs()
|
|
571
|
-
+}
|
|
572
|
-
+
|
|
573
|
-
// PluginObservationsIncomplete reports whether any linked hook explicitly
|
|
574
|
-
// declared that its supported public API could not observe the input population
|
|
575
|
-
// for this generation. False means no such declaration, not completeness proof.
|
|
576
|
-
@@ -1181,6 +1209,10 @@ func (p *Program) diagnostics(files []*ast.SourceFile) []Diagnostic {
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
raw = filterDiagnostics(raw)
|
|
580
|
-
+ // A linked DiagnosticPlugin withdraws the checker's refusals of the dialect
|
|
581
|
-
+ // its ProgramPlugin lowers. It asks about the tree the checker judged, which
|
|
582
|
-
+ // the hooks have not mutated yet on every lane that gates on diagnostics.
|
|
583
|
-
+ raw = p.plugins.dropLoweredDiagnostics(p, raw)
|
|
584
|
-
// filterDiagnostics runs first because it resolves a node from the position
|
|
585
|
-
// tsgo recorded, which only makes sense against the tree tsgo parsed. The
|
|
586
|
-
// preamble correction happens inside convertProgramDiagnostics, once the
|
|
587
|
-
diff --git a/driver/rewrite.go b/driver/rewrite.go
|
|
588
|
-
index 79be74d24e879da216ad680d23ecfeb5f11a29db..6db9dddba05bd50e13ed92535ca442c3a4f0b28a 100644
|
|
589
|
-
--- a/driver/rewrite.go
|
|
590
|
-
+++ b/driver/rewrite.go
|
|
591
|
-
@@ -204,6 +204,9 @@ func (p *Program) EmitAllRaw(writeFile shimcompiler.WriteFile) (*shimcompiler.Em
|
|
592
|
-
result := p.emitProgram(shimcompiler.EmitOptions{
|
|
593
|
-
WriteFile: wf,
|
|
594
|
-
})
|
|
595
|
-
+ if err := p.listHostOutputs(result, writeFile); err != nil {
|
|
596
|
-
+ return result, p.convertProgramDiagnostics(result.Diagnostics), err
|
|
597
|
-
+ }
|
|
598
|
-
return result, p.convertProgramDiagnostics(result.Diagnostics), nil
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
@@ -271,9 +274,52 @@ func (p *Program) emit(rs *RewriteSet, target *ast.SourceFile, writeFile shimcom
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
result := p.emitProgram(shimcompiler.TargetedEmitOptions(target, wf))
|
|
605
|
-
+ if target == nil {
|
|
606
|
-
+ if err := p.listHostOutputs(result, writeFile); err != nil {
|
|
607
|
-
+ return result, p.convertProgramDiagnostics(result.Diagnostics), err
|
|
608
|
-
+ }
|
|
609
|
-
+ }
|
|
610
|
-
return result, p.convertProgramDiagnostics(result.Diagnostics), nil
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
+// listHostOutputs hands the files linked plugins reported writing beside a
|
|
614
|
-
+// whole-program emit's outputs to writeFile and lists them among the result's
|
|
615
|
-
+// EmittedFiles, unless the emit wrote nothing (noEmit, or noEmitOnError
|
|
616
|
-
+// withholding a failed program).
|
|
617
|
-
+func (p *Program) listHostOutputs(result *shimcompiler.EmitResult, writeFile shimcompiler.WriteFile) error {
|
|
618
|
-
+ if result == nil || result.EmitSkipped || p.TSProgram.Options().NoEmit.IsTrue() {
|
|
619
|
-
+ return nil
|
|
620
|
-
+ }
|
|
621
|
-
+ handed, err := p.writeHostOutputs(writeFile)
|
|
622
|
-
+ result.EmittedFiles = append(result.EmittedFiles, handed...)
|
|
623
|
-
+ return err
|
|
624
|
-
+}
|
|
625
|
-
+
|
|
626
|
-
+// writeHostOutputs hands each file a linked plugin reported writing beside the
|
|
627
|
-
+// compiler's outputs (PluginContext.ReportHostOutput) to writeFile, with its
|
|
628
|
-
+// bytes as they are now, after the compiler's own outputs, so a host lists it
|
|
629
|
-
+// with them. It answers the files handed, and fails on one it cannot read: a
|
|
630
|
-
+// plugin reported an output it did not leave.
|
|
631
|
-
+func (p *Program) writeHostOutputs(writeFile shimcompiler.WriteFile) ([]string, error) {
|
|
632
|
-
+ var handed []string
|
|
633
|
-
+ for _, file := range p.plugins.outputs.list() {
|
|
634
|
-
+ text, err := os.ReadFile(file)
|
|
635
|
-
+ if err != nil {
|
|
636
|
-
+ return handed, fmt.Errorf("ttsc driver: a linked plugin reported the host output %s, which cannot be read: %w", file, err)
|
|
637
|
-
+ }
|
|
638
|
-
+ if writeFile != nil {
|
|
639
|
-
+ err = writeFile(shimtspath.RootedFilePathFromAbsolute(file), string(text), nil)
|
|
640
|
-
+ } else {
|
|
641
|
-
+ err = DefaultWriteFile(file, string(text))
|
|
642
|
-
+ }
|
|
643
|
-
+ if err != nil {
|
|
644
|
-
+ return handed, err
|
|
645
|
-
+ }
|
|
646
|
-
+ handed = append(handed, file)
|
|
647
|
-
+ }
|
|
648
|
-
+ return handed, nil
|
|
649
|
-
+}
|
|
650
|
-
+
|
|
651
|
-
// emitProgram runs one whole-program or single-file emit, taking tsgo's
|
|
652
|
-
// incremental lane when the resolved compiler options ask for build
|
|
653
|
-
// information.
|
|
654
|
-
@@ -317,22 +363,28 @@ func (p *Program) emitsBuildInfo() bool {
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
// DefaultWriteFile is the default disk writer used when EmitAll's caller does not
|
|
658
|
-
-// supply a custom WriteFile callback. Existing files are normally truncated; a
|
|
659
|
-
-// watch child setting TTSC_WATCH_WRITE_IF_CHANGED=1 preserves byte-identical
|
|
660
|
-
-// regular output files instead. A failed write can leave partial output.
|
|
661
|
-
-// Requested creation modes are subject to the native platform and umask, and
|
|
662
|
-
-// do not replace existing file permissions.
|
|
663
|
-
+// supply a custom WriteFile callback. Existing files are normally truncated,
|
|
664
|
-
+// which a caller that finds stale outputs by file identity relies on: one that
|
|
665
|
-
+// removes each outDir file the emit did not touch (smoo's typescript-emit
|
|
666
|
-
+// executor through nx-plugin 0.7.9) would otherwise remove every unchanged
|
|
667
|
-
+// output. A watch child setting TTSC_WATCH_WRITE_IF_CHANGED=1, or a caller that
|
|
668
|
-
+// prunes its outDir by the emitted-file list and sets TTSC_WRITE_IF_CHANGED=1,
|
|
669
|
-
+// preserves byte-identical regular output files instead, inode and mtime
|
|
670
|
-
+// included: rewriting identical bytes is file churn every copy-on-write clone of
|
|
671
|
-
+// the output pays for. A failed write can leave partial output. Requested
|
|
672
|
-
+// creation modes are subject to the native platform and umask, and do not
|
|
673
|
-
+// replace existing file permissions.
|
|
674
|
-
//
|
|
675
|
-
-// @evidence contracts/common.md#principled-implementation The watch-only opt-in compares an existing writable regular output before deciding whether native writing is needed; all other writes use the original directory and file operations.
|
|
676
|
-
+// @evidence contracts/common.md#principled-implementation An opted-in emit compares an existing writable regular output before deciding whether native writing is needed; all other writes use the original directory and file operations.
|
|
677
|
-
// @evidence contracts/common.md#clear-and-simple-design One opt-in decision selects the unchanged-output check or the original writer.
|
|
678
|
-
// @evidence contracts/common.md#prohibited-implementation-shortcuts Native file identity and bytes decide whether to skip; unknown state falls back to the original writer and its errors.
|
|
679
|
-
-// @evidence contracts/common.md#meaningful-documentation Native prose states normal truncation, watch opt-in, partial failure and permission behavior.
|
|
680
|
-
+// @evidence contracts/common.md#meaningful-documentation Native prose states normal truncation, who relies on it, both opt-ins, partial failure and permission behavior.
|
|
681
|
-
// @evidence contracts/portability.md#os-neutral-implementation filepath.Dir, os.MkdirAll and os.WriteFile preserve native path and permission behavior; the optional check uses native file identity rather than path spelling.
|
|
682
|
-
-// @evidence contracts/performance.md#efficient-algorithms Normal writes retain one directory creation and file write. Watch writes add metadata and streamed comparison of up to the existing output size, then write only when content differs or safe comparison fails; no prior-output cache is retained.
|
|
683
|
-
+// @evidence contracts/performance.md#efficient-algorithms Normal writes retain one directory creation and file write. Opted-in writes add metadata and streamed comparison of up to the existing output size, then write only when content differs or safe comparison fails; no prior-output cache is retained.
|
|
684
|
-
// @evidenceExclude contracts/performance.md#reuse-equivalent-work Each emit write is requested independently; this writer owns no cross-emit reuse coordinator.
|
|
685
|
-
// @evidence contracts/performance.md#bound-retention-and-release-resources The optional comparison closes its one read/write handle before return or fallback; os.WriteFile owns and closes the later write handle. No output buffer or handle survives this call, while created directories and partial or completed files remain on disk.
|
|
686
|
-
func DefaultWriteFile(fileName, text string) error {
|
|
687
|
-
- return writeFileWithWatchMode(fileName, text, os.Getenv("TTSC_WATCH_WRITE_IF_CHANGED") == "1")
|
|
688
|
-
+ return writeFileWithWatchMode(fileName, text, os.Getenv("TTSC_WATCH_WRITE_IF_CHANGED") == "1" || os.Getenv("TTSC_WRITE_IF_CHANGED") == "1")
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
func defaultWriteFile(fileName, text string) error {
|
|
692
|
-
diff --git a/lib/compiler/internal/build/RuntimeBuildInputs.js b/lib/compiler/internal/build/RuntimeBuildInputs.js
|
|
693
|
-
index 855c4b3fbcda8e55dac89e568405766864bf7139..858c6df808b105098372a8d46eea02ecdf8fa581 100644
|
|
694
|
-
--- a/lib/compiler/internal/build/RuntimeBuildInputs.js
|
|
695
|
-
+++ b/lib/compiler/internal/build/RuntimeBuildInputs.js
|
|
696
|
-
@@ -375,7 +375,9 @@ var RuntimeBuildInputs;
|
|
697
|
-
});
|
|
698
|
-
return false;
|
|
699
|
-
}
|
|
700
|
-
- const accepted = RuntimeInputProof_1.RuntimeInputProof.holds(result, execution.projectRoot, emitDir);
|
|
701
|
-
+ // The plugins of this build would run under env, so a recorded
|
|
702
|
-
+ // environment read must still hold there.
|
|
703
|
-
+ const accepted = RuntimeInputProof_1.RuntimeInputProof.holds(result, execution.projectRoot, emitDir, env);
|
|
704
|
-
if (!accepted)
|
|
705
|
-
RuntimeBuildExplanation_1.RuntimeBuildExplanation.report({
|
|
706
|
-
outcome: "rejected",
|
|
707
|
-
diff --git a/lib/compiler/internal/build/RuntimeInputProof.js b/lib/compiler/internal/build/RuntimeInputProof.js
|
|
708
|
-
index b64e043c810ad0834e98a441d012208a06d8aa81..35d3fef74ad87ad06e9677e5d46ea9364f59da58 100644
|
|
709
|
-
--- a/lib/compiler/internal/build/RuntimeInputProof.js
|
|
710
|
-
+++ b/lib/compiler/internal/build/RuntimeInputProof.js
|
|
711
|
-
@@ -7,6 +7,7 @@ exports.RuntimeInputProof = void 0;
|
|
712
|
-
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
713
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
714
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
715
|
-
+const SidecarEnvironment_1 = require("../sharedHost/SidecarEnvironment");
|
|
716
|
-
/**
|
|
717
|
-
* Replay the compiler and native input witnesses of a completed runtime build.
|
|
718
|
-
* Read predicates keep their original text or raw-byte codec; absence, entry
|
|
719
|
-
@@ -27,21 +28,26 @@ var RuntimeInputProof;
|
|
720
|
-
/**
|
|
721
|
-
* Validate result-level host witnesses and every reported compiler predicate.
|
|
722
|
-
* The caller independently proves the selected compiler, project membership
|
|
723
|
-
- * and plugin selection; an absent graph alone grants no completeness.
|
|
724
|
-
+ * and plugin selection; an absent graph alone grants no completeness. Every
|
|
725
|
-
+ * recorded environment read must still have its value, or remain unset, in
|
|
726
|
-
+ * `environment`, the environment the build would spawn its plugins under.
|
|
727
|
-
*
|
|
728
|
-
- * @evidence contracts/common.md#principled-implementation Explicit incomplete observations and any graph failure reject reuse; host paths require both content and physical witnesses, and rich compiler predicates are replayed under their own codec.
|
|
729
|
-
+ * @evidence contracts/common.md#principled-implementation Explicit incomplete observations and any graph failure reject reuse; host paths require both content and physical witnesses, recorded environment reads require their exact value or absence, and rich compiler predicates are replayed under their own codec.
|
|
730
|
-
* @evidence contracts/common.md#clear-and-simple-design One admission pass delegates individual compiler observations and native codecs.
|
|
731
|
-
- * @evidence contracts/common.md#prohibited-implementation-shortcuts Missing witness fields never become an empty successful observation, and only the caller-owned private output subtree is excluded.
|
|
732
|
-
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Missing witness fields never become an empty successful observation, a changed environment value is a changed input, and only the caller-owned private output subtree is excluded.
|
|
733
|
-
* @evidence contracts/common.md#meaningful-documentation Native prose identifies result admission and the caller's separate completeness obligations.
|
|
734
|
-
- * @evidence contracts/portability.md#os-neutral-implementation Native path resolution anchors producer-relative graph keys, and current physical paths come from native realpath.
|
|
735
|
-
+ * @evidence contracts/portability.md#os-neutral-implementation Native path resolution anchors producer-relative graph keys, current physical paths come from native realpath, and SidecarEnvironment.read applies Windows' case-insensitive variable names.
|
|
736
|
-
* @evidence contracts/performance.md#efficient-algorithms Input and predicate populations drive replay; each read hashes its actual bytes and directories sort immediate entry records.
|
|
737
|
-
* @evidence contracts/performance.md#reuse-equivalent-work Generation witnesses, rather than an identity-key match, decide whether a completed build remains reusable.
|
|
738
|
-
* @evidence contracts/performance.md#bound-retention-and-release-resources Temporary path and predicate records are invocation-owned without retained handles or history.
|
|
739
|
-
*/
|
|
740
|
-
- function holds(result, projectRoot, emitDir) {
|
|
741
|
-
+ function holds(result, projectRoot, emitDir, environment) {
|
|
742
|
-
if (result.observationsComplete === false ||
|
|
743
|
-
Object.keys(result.graph?.inputProofFailures ?? {}).length !== 0)
|
|
744
|
-
return false;
|
|
745
|
-
+ for (const [name, recorded] of Object.entries(result.environmentInputs ?? {}))
|
|
746
|
-
+ if ((SidecarEnvironment_1.SidecarEnvironment.read(environment, name) ?? null) !== recorded)
|
|
747
|
-
+ return false;
|
|
748
|
-
try {
|
|
749
|
-
for (const file of result.hostInputs ?? []) {
|
|
750
|
-
const [currentPhysical, hash] = observeHostInput(file);
|
|
751
|
-
diff --git a/lib/compiler/internal/build/appendBuildOutput.js b/lib/compiler/internal/build/appendBuildOutput.js
|
|
752
|
-
index 17a19b74c4e7ba08c6cc77c31bcfff596ec9e30f..a9212bf6fc0d344d2ce068363faaa645eb74a76c 100644
|
|
753
|
-
--- a/lib/compiler/internal/build/appendBuildOutput.js
|
|
754
|
-
+++ b/lib/compiler/internal/build/appendBuildOutput.js
|
|
755
|
-
@@ -2,6 +2,7 @@
|
|
756
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
757
|
-
exports.appendBuildOutput = appendBuildOutput;
|
|
758
|
-
exports.mergeCheckGraphs = mergeCheckGraphs;
|
|
759
|
-
+const mergeEnvironmentInputs_1 = require("./mergeEnvironmentInputs");
|
|
760
|
-
const normalizeBuildOutput_1 = require("./normalizeBuildOutput");
|
|
761
|
-
/**
|
|
762
|
-
* Merge two `TtscBuildResult` values into one.
|
|
763
|
-
@@ -15,6 +16,8 @@ const normalizeBuildOutput_1 = require("./normalizeBuildOutput");
|
|
764
|
-
* - Check inputs are unioned; independently compatible content and physical
|
|
765
|
-
* witnesses survive. A lost witness cannot be restored by a later phase.
|
|
766
|
-
* Explicit observation incompleteness is sticky.
|
|
767
|
-
+ * - `environmentInputs`: unioned; two phases that recorded different values for
|
|
768
|
-
+ * one name withdraw reuse through `observationsComplete: false`.
|
|
769
|
-
*
|
|
770
|
-
* The shared normalizer moves combined stdout to stderr when the merged result
|
|
771
|
-
* failed and stderr is blank, preserving visibility for stderr-only consumers.
|
|
772
|
-
@@ -47,6 +50,7 @@ function appendBuildOutput(left, right) {
|
|
773
|
-
hostInputHashes: mergeInputWitnesses(left, right, "hostInputHashes", hostInputs),
|
|
774
|
-
hostInputRealpaths: mergeInputWitnesses(left, right, "hostInputRealpaths", hostInputs),
|
|
775
|
-
}),
|
|
776
|
-
+ ...(0, mergeEnvironmentInputs_1.mergeEnvironmentInputs)(left.environmentInputs, right.environmentInputs),
|
|
777
|
-
...(left.observationsComplete === false ||
|
|
778
|
-
right.observationsComplete === false
|
|
779
|
-
? { observationsComplete: false }
|
|
780
|
-
diff --git a/lib/compiler/internal/build/mergeEnvironmentInputs.js b/lib/compiler/internal/build/mergeEnvironmentInputs.js
|
|
781
|
-
new file mode 100644
|
|
782
|
-
index 0000000000000000000000000000000000000000..17010bfbaedc7a28e821d676af7a350f22112877
|
|
783
|
-
--- /dev/null
|
|
784
|
-
+++ b/lib/compiler/internal/build/mergeEnvironmentInputs.js
|
|
785
|
-
@@ -0,0 +1,47 @@
|
|
786
|
-
+"use strict";
|
|
787
|
-
+Object.defineProperty(exports, "__esModule", { value: true });
|
|
788
|
-
+exports.mergeEnvironmentInputs = mergeEnvironmentInputs;
|
|
789
|
-
+/**
|
|
790
|
-
+ * Union the environment reads of the native generations behind one result.
|
|
791
|
-
+ *
|
|
792
|
-
+ * Every phase of one compile spawns its plugins under the same environment, so
|
|
793
|
-
+ * a name normally carries one value across phases. If two phases recorded
|
|
794
|
-
+ * different values for a name, no single environment reproduces the result: the
|
|
795
|
-
+ * first value is kept and `observationsComplete: false` withdraws reuse, the
|
|
796
|
-
+ * same refusal an explicitly incomplete producer causes. The returned object
|
|
797
|
-
+ * spreads into a result and adds nothing when no phase read a variable.
|
|
798
|
-
+ *
|
|
799
|
-
+ * @evidence contracts/common.md#principled-implementation A name is an input of the merged result if any phase read it; contradictory values cannot be satisfied by one environment, so they withdraw reuse instead of picking a winner silently.
|
|
800
|
-
+ * @evidence contracts/common.md#clear-and-simple-design One merger serves phase composition and the transform router; the existing sticky observation marker carries a conflict rather than a new proof state.
|
|
801
|
-
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts No current environment value is read to repair a conflict, and a conflicting name is not dropped, which would hide an input.
|
|
802
|
-
+ * @evidence contracts/common.md#meaningful-documentation Native prose explains why values normally agree, the conflict policy and the spreadable empty result.
|
|
803
|
-
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Recorded names and values are compared literally as producer data; native environment name rules belong to the consumers that look them up.
|
|
804
|
-
+ * @evidence contracts/performance.md#efficient-algorithms One pass over every group's entries with own-key lookups; linear in recorded names.
|
|
805
|
-
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work Combining supplied records coordinates no shared production.
|
|
806
|
-
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The returned record transfers to the caller; nothing is retained.
|
|
807
|
-
+ */
|
|
808
|
-
+function mergeEnvironmentInputs(...groups) {
|
|
809
|
-
+ const merged = {};
|
|
810
|
-
+ let conflicting = false;
|
|
811
|
-
+ for (const group of groups) {
|
|
812
|
-
+ for (const [name, value] of Object.entries(group ?? {})) {
|
|
813
|
-
+ if (Object.hasOwn(merged, name)) {
|
|
814
|
-
+ if (merged[name] !== value)
|
|
815
|
-
+ conflicting = true;
|
|
816
|
-
+ continue;
|
|
817
|
-
+ }
|
|
818
|
-
+ // A literal wire name must not reach an inherited setter.
|
|
819
|
-
+ Object.defineProperty(merged, name, {
|
|
820
|
-
+ configurable: true,
|
|
821
|
-
+ enumerable: true,
|
|
822
|
-
+ value,
|
|
823
|
-
+ writable: true,
|
|
824
|
-
+ });
|
|
825
|
-
+ }
|
|
826
|
-
+ }
|
|
827
|
-
+ return {
|
|
828
|
-
+ ...(Object.keys(merged).length === 0 ? {} : { environmentInputs: merged }),
|
|
829
|
-
+ ...(conflicting ? { observationsComplete: false } : {}),
|
|
830
|
-
+ };
|
|
831
|
-
+}
|
|
832
|
-
+//# sourceMappingURL=mergeEnvironmentInputs.js.map
|
|
833
|
-
|
|
834
|
-
diff --git a/lib/compiler/internal/parseEnvironmentInputs.js b/lib/compiler/internal/parseEnvironmentInputs.js
|
|
835
|
-
new file mode 100644
|
|
836
|
-
index 0000000000000000000000000000000000000000..cfba66dc36b5250461e07d0cddf1c0666541d4bb
|
|
837
|
-
--- /dev/null
|
|
838
|
-
+++ b/lib/compiler/internal/parseEnvironmentInputs.js
|
|
839
|
-
@@ -0,0 +1,43 @@
|
|
840
|
-
+"use strict";
|
|
841
|
-
+Object.defineProperty(exports, "__esModule", { value: true });
|
|
842
|
-
+exports.parseEnvironmentInputs = parseEnvironmentInputs;
|
|
843
|
-
+/**
|
|
844
|
-
+ * Decode a native `environmentInputs` section: variable names to the value a
|
|
845
|
-
+ * plugin read through `ctx.Env`, or null for an unset variable.
|
|
846
|
-
+ *
|
|
847
|
-
+ * Each entry is a dependency of the whole generation, so a malformed section
|
|
848
|
-
+ * throws instead of dropping an entry, which would hide an input and let a
|
|
849
|
-
+ * consumer reuse output computed under another value. An absent or empty
|
|
850
|
-
+ * section decodes to `undefined`.
|
|
851
|
-
+ *
|
|
852
|
-
+ * @evidence contracts/common.md#principled-implementation Names must be non-empty strings and values strings or null; anything else fails the response rather than weakening the input record.
|
|
853
|
-
+ * @evidence contracts/common.md#clear-and-simple-design One decoder serves the transform envelope and the check/emit observation sidecar, which carry the same field.
|
|
854
|
-
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts No value is read from the current environment and no malformed entry is silently discarded.
|
|
855
|
-
+ * @evidence contracts/common.md#meaningful-documentation Native prose states the wire shape, the failure policy and why it is strict.
|
|
856
|
-
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Names and values are retained as producer data; environment name rules belong to the consumers that look them up.
|
|
857
|
-
+ * @evidence contracts/performance.md#efficient-algorithms One pass over the section's entries; linear in names and value bytes.
|
|
858
|
-
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work Each response is decoded independently.
|
|
859
|
-
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The decoded record transfers to the caller; nothing is retained.
|
|
860
|
-
+ */
|
|
861
|
-
+function parseEnvironmentInputs(value) {
|
|
862
|
-
+ if (value === undefined)
|
|
863
|
-
+ return undefined;
|
|
864
|
-
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
865
|
-
+ throw new Error("ttsc: invalid native environment input record");
|
|
866
|
-
+ }
|
|
867
|
-
+ const output = {};
|
|
868
|
-
+ for (const [name, recorded] of Object.entries(value)) {
|
|
869
|
-
+ if (name.length === 0 ||
|
|
870
|
-
+ (recorded !== null && typeof recorded !== "string"))
|
|
871
|
-
+ throw new Error("ttsc: invalid native environment input entry");
|
|
872
|
-
+ // A literal wire name must not reach an inherited setter.
|
|
873
|
-
+ Object.defineProperty(output, name, {
|
|
874
|
-
+ configurable: true,
|
|
875
|
-
+ enumerable: true,
|
|
876
|
-
+ value: recorded,
|
|
877
|
-
+ writable: true,
|
|
878
|
-
+ });
|
|
879
|
-
+ }
|
|
880
|
-
+ return Object.keys(output).length === 0 ? undefined : output;
|
|
881
|
-
+}
|
|
882
|
-
+//# sourceMappingURL=parseEnvironmentInputs.js.map
|
|
883
|
-
|
|
884
|
-
diff --git a/lib/compiler/internal/parseNativeTransformOutput.js b/lib/compiler/internal/parseNativeTransformOutput.js
|
|
885
|
-
index 56f9c61c7048af48686cbbab8dc9367cb3461b0d..2ff9f8dbacccacb6412526e5a534b7c711797040 100644
|
|
886
|
-
--- a/lib/compiler/internal/parseNativeTransformOutput.js
|
|
887
|
-
+++ b/lib/compiler/internal/parseNativeTransformOutput.js
|
|
888
|
-
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
889
|
-
exports.parseNativeTransformOutput = parseNativeTransformOutput;
|
|
890
|
-
exports.parseReferenceGraph = parseReferenceGraph;
|
|
891
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
892
|
-
+const parseEnvironmentInputs_1 = require("./parseEnvironmentInputs");
|
|
893
|
-
/**
|
|
894
|
-
* Parse the JSON envelope written by the native transform host to stdout.
|
|
895
|
-
*
|
|
896
|
-
@@ -29,7 +30,9 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
897
|
-
* Observation limits have a stricter protocol: completeness is only explicit
|
|
898
|
-
* false, and per-input reasons require absolute native paths and the supported
|
|
899
|
-
* unavailable reason. Invalid limit metadata fails instead of becoming an
|
|
900
|
-
- * exemption; omission asserts no completeness.
|
|
901
|
-
+ * exemption; omission asserts no completeness. Recorded environment reads are
|
|
902
|
-
+ * strict too: dropping a malformed entry would hide an input, so a malformed
|
|
903
|
-
+ * `environmentInputs` section fails the response.
|
|
904
|
-
*
|
|
905
|
-
* @evidence contracts/common.md#principled-implementation Required source output is decoded as an object of strings; advisory members are retained only by their declared shape with literal source keys stored as own data properties, while malformed observation exemptions fail rather than authorize reuse.
|
|
906
|
-
* @evidence contracts/common.md#clear-and-simple-design This decoder owns the wire shape independently of process execution and proof revalidation; private helpers validate the distinct optional sections.
|
|
907
|
-
@@ -61,6 +64,7 @@ stderr) {
|
|
908
|
-
const dependencies = parseDependencyLists(parsed.dependencies);
|
|
909
|
-
const dependenciesComplete = parseFileList(parsed.dependenciesComplete);
|
|
910
|
-
const graph = parseReferenceGraph(parsed.graph);
|
|
911
|
-
+ const environmentInputs = (0, parseEnvironmentInputs_1.parseEnvironmentInputs)(parsed.environmentInputs);
|
|
912
|
-
const hostInputHashes = parseHostInputHashes(parsed.hostInputHashes);
|
|
913
|
-
const hostInputRealpaths = parseHostInputRealpaths(parsed.hostInputRealpaths);
|
|
914
|
-
const hostInputs = parseFileList(parsed.hostInputs);
|
|
915
|
-
@@ -69,6 +73,7 @@ stderr) {
|
|
916
|
-
return {
|
|
917
|
-
...(dependencies === undefined ? {} : { dependencies }),
|
|
918
|
-
...(dependenciesComplete === undefined ? {} : { dependenciesComplete }),
|
|
919
|
-
+ ...(environmentInputs === undefined ? {} : { environmentInputs }),
|
|
920
|
-
...(graph === undefined ? {} : { graph }),
|
|
921
|
-
...(hostInputHashes === undefined ? {} : { hostInputHashes }),
|
|
922
|
-
...(hostInputRealpaths === undefined ? {} : { hostInputRealpaths }),
|
|
923
|
-
diff --git a/lib/compiler/internal/runNativeCheckWithObservations.js b/lib/compiler/internal/runNativeCheckWithObservations.js
|
|
924
|
-
index 6fd2b52ccdb5f81fe3c2fb317a1713cd4db15f37..a5ddfe21a1bba502985c6cea16d7b063b58f9666 100644
|
|
925
|
-
--- a/lib/compiler/internal/runNativeCheckWithObservations.js
|
|
926
|
-
+++ b/lib/compiler/internal/runNativeCheckWithObservations.js
|
|
927
|
-
@@ -7,6 +7,7 @@ exports.runNativeCheckWithObservations = runNativeCheckWithObservations;
|
|
928
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
929
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
930
|
-
const createCanonicalTempDirectory_1 = require("../../internal/createCanonicalTempDirectory");
|
|
931
|
-
+const parseEnvironmentInputs_1 = require("./parseEnvironmentInputs");
|
|
932
|
-
const parseNativeTransformOutput_1 = require("./parseNativeTransformOutput");
|
|
933
|
-
/**
|
|
934
|
-
* Execute a check or opted-in build with same-generation input observations,
|
|
935
|
-
@@ -168,7 +169,9 @@ function parseObservations(value) {
|
|
936
|
-
graph.inputObservations === undefined &&
|
|
937
|
-
graph.inputRealpaths === undefined &&
|
|
938
|
-
graph.inputProofFailures === undefined);
|
|
939
|
-
+ const environmentInputs = (0, parseEnvironmentInputs_1.parseEnvironmentInputs)(value.environmentInputs);
|
|
940
|
-
return {
|
|
941
|
-
+ ...(environmentInputs === undefined ? {} : { environmentInputs }),
|
|
942
|
-
...(graph === undefined ? {} : { graph }),
|
|
943
|
-
...(graphUnavailable ? { observationsComplete: false } : {}),
|
|
944
|
-
hostInputs: [...inputs],
|
|
945
|
-
diff --git a/lib/compiler/internal/transformProjectInMemory.js b/lib/compiler/internal/transformProjectInMemory.js
|
|
946
|
-
index 999805a36b0a7f55bfcb421805ceba8fdd8da778..e1de410793dbefa35054f16308130423997eab2a 100644
|
|
947
|
-
--- a/lib/compiler/internal/transformProjectInMemory.js
|
|
948
|
-
+++ b/lib/compiler/internal/transformProjectInMemory.js
|
|
949
|
-
@@ -12,6 +12,7 @@ const loadProjectPlugins_1 = require("../../plugin/internal/load/loadProjectPlug
|
|
950
|
-
const realpathHostInputPaths_1 = require("../../plugin/internal/load/realpathHostInputPaths");
|
|
951
|
-
const CompilationSnapshot_1 = require("./CompilationSnapshot");
|
|
952
|
-
const appendBuildOutput_1 = require("./build/appendBuildOutput");
|
|
953
|
-
+const mergeEnvironmentInputs_1 = require("./build/mergeEnvironmentInputs");
|
|
954
|
-
const normalizeBuildOutput_1 = require("./build/normalizeBuildOutput");
|
|
955
|
-
const buildNativeCompiler_1 = require("./buildNativeCompiler");
|
|
956
|
-
const outputText_1 = require("./outputText");
|
|
957
|
-
@@ -46,11 +47,13 @@ const spawnNative_1 = require("./spawnNative");
|
|
958
|
-
* Explicit unavailable-observation reports survive every lane so consumers can
|
|
959
|
-
* use a fresh successful result while withholding reuse. They cannot excuse a
|
|
960
|
-
* content or physical witness that changed or conflicted across stages.
|
|
961
|
-
- * Opted-in checks supply their same-generation observations through a private
|
|
962
|
-
- * sidecar on failure as well as success. A later transform cannot restore a
|
|
963
|
-
- * check's rejected proof or replace it with an unavailable-input exemption.
|
|
964
|
-
- * Other check hosts retain their existing descriptor and declared-input
|
|
965
|
-
- * observation contract rather than inheriting the driver's protocol.
|
|
966
|
-
+ * Environment variables read by the check and transform stages are unioned into
|
|
967
|
-
+ * `environmentInputs`. Opted-in checks supply their same-generation
|
|
968
|
-
+ * observations through a private sidecar on failure as well as success. A later
|
|
969
|
-
+ * transform cannot restore a check's rejected proof or replace it with an
|
|
970
|
-
+ * unavailable-input exemption. Other check hosts retain their existing
|
|
971
|
-
+ * descriptor and declared-input observation contract rather than inheriting the
|
|
972
|
-
+ * driver's protocol.
|
|
973
|
-
*
|
|
974
|
-
* @returns A `{ result, typescript }` pair where `typescript` maps output paths
|
|
975
|
-
* to their transformed TypeScript source text, and `pluginSources` the state
|
|
976
|
-
@@ -140,6 +143,7 @@ function transformProjectWithNativeHost(options, project, baseline) {
|
|
977
|
-
const hostInputRealpaths = mergeCompatibleHostInputHashes(finalObservedHostInputRealpaths, finalOutputHostInputRealpaths, observedHostInputs, output.hostInputs);
|
|
978
|
-
return {
|
|
979
|
-
...envelopeSideChannels(output),
|
|
980
|
-
+ ...(0, mergeEnvironmentInputs_1.mergeEnvironmentInputs)(output.environmentInputs),
|
|
981
|
-
...observationLimitations([
|
|
982
|
-
baseline,
|
|
983
|
-
{
|
|
984
|
-
@@ -184,6 +188,7 @@ function transformProjectWithPlugins(options, loaded) {
|
|
985
|
-
if (checked.status !== 0) {
|
|
986
|
-
return {
|
|
987
|
-
...(checked.graph === undefined ? {} : { graph: checked.graph }),
|
|
988
|
-
+ ...(0, mergeEnvironmentInputs_1.mergeEnvironmentInputs)(checked.environmentInputs),
|
|
989
|
-
...observationLimitations([loaded, checked], checkedHostInputHashes, checkedHostInputRealpaths, unprovenCheckInputs),
|
|
990
|
-
...(checked.graph === undefined
|
|
991
|
-
? { observationsComplete: false }
|
|
992
|
-
@@ -203,6 +208,7 @@ function transformProjectWithPlugins(options, loaded) {
|
|
993
|
-
const hostInputRealpaths = mergeCompatibleHostInputHashes(finalLoadedHostInputRealpaths, transformed.hostInputRealpaths, checkedHostInputs, transformed.hostInputs);
|
|
994
|
-
return {
|
|
995
|
-
...envelopeSideChannels(transformed),
|
|
996
|
-
+ ...(0, mergeEnvironmentInputs_1.mergeEnvironmentInputs)(checked.environmentInputs, transformed.environmentInputs),
|
|
997
|
-
graph: mergeTransformGraphs(checked.graph, transformed.graph, checks.length),
|
|
998
|
-
...observationLimitations([loaded, checked, transformed], hostInputHashes, hostInputRealpaths, unprovenCheckInputs),
|
|
999
|
-
hostInputHashes,
|
|
1000
|
-
@@ -236,6 +242,7 @@ function transformProjectWithPlugins(options, loaded) {
|
|
1001
|
-
const hostInputRealpaths = mergeCompatibleHostInputHashes(finalLoadedHostInputRealpaths, finalOutputHostInputRealpaths, checkedHostInputs, output.hostInputs, deferredTransformInputs);
|
|
1002
|
-
return {
|
|
1003
|
-
...envelopeSideChannels(output),
|
|
1004
|
-
+ ...(0, mergeEnvironmentInputs_1.mergeEnvironmentInputs)(checked.environmentInputs, output.environmentInputs),
|
|
1005
|
-
graph: mergeTransformGraphs(checked.graph, output.graph, checks.length),
|
|
1006
|
-
...observationLimitations([loaded, checked, output], hostInputHashes, hostInputRealpaths, unprovenCheckInputs),
|
|
1007
|
-
hostInputHashes,
|
|
1008
|
-
diff --git a/lib/internal/CompilerResultAdapter.js b/lib/internal/CompilerResultAdapter.js
|
|
1009
|
-
index 7ff885f63d081b950730bd303aeeed70aada8067..a43778c1fe3711da0db4743b3f00b903fd22e01d 100644
|
|
1010
|
-
--- a/lib/internal/CompilerResultAdapter.js
|
|
1011
|
-
+++ b/lib/internal/CompilerResultAdapter.js
|
|
1012
|
-
@@ -179,7 +179,7 @@ function toCompilerResult(project) {
|
|
1013
|
-
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources Returned source/advisory objects remain reachable under caller ownership; this operation owns no process, lease or historical registry.
|
|
1014
|
-
*/
|
|
1015
|
-
function toCompilerTransformation(project) {
|
|
1016
|
-
- const { dependencies: reportedDependencies, dependenciesComplete, graph, hostInputHashes, hostInputProofFailures, hostInputRealpaths, hostInputs, observationsComplete, pluginSources, result, sourceMaps, typescript, volatile, } = project;
|
|
1017
|
-
+ const { dependencies: reportedDependencies, dependenciesComplete, environmentInputs, graph, hostInputHashes, hostInputProofFailures, hostInputRealpaths, hostInputs, observationsComplete, pluginSources, result, sourceMaps, typescript, volatile, } = project;
|
|
1018
|
-
let dependencies = reportedDependencies;
|
|
1019
|
-
if (graph?.contentMapperInputs?.length) {
|
|
1020
|
-
const keys = new Set([
|
|
1021
|
-
@@ -204,6 +204,7 @@ function toCompilerTransformation(project) {
|
|
1022
|
-
const advisoryFields = {
|
|
1023
|
-
...(dependencies === undefined ? {} : { dependencies }),
|
|
1024
|
-
...(dependenciesComplete === undefined ? {} : { dependenciesComplete }),
|
|
1025
|
-
+ ...(environmentInputs === undefined ? {} : { environmentInputs }),
|
|
1026
|
-
...(graph === undefined ? {} : { graph }),
|
|
1027
|
-
...(hostInputHashes === undefined ? {} : { hostInputHashes }),
|
|
1028
|
-
...(hostInputProofFailures === undefined ? {} : { hostInputProofFailures }),
|
|
1029
|
-
diff --git a/lib/internal/javascriptRuntimeCapabilities.js b/lib/internal/javascriptRuntimeCapabilities.js
|
|
1030
|
-
index 53dc81d7ae8b6eac246306ad8f94b01f2594689a..d6ad694d69deca3661f5b89b491a48f282b34d42 100644
|
|
1031
|
-
--- a/lib/internal/javascriptRuntimeCapabilities.js
|
|
1032
|
-
+++ b/lib/internal/javascriptRuntimeCapabilities.js
|
|
1033
|
-
@@ -43,6 +43,19 @@ const spawnSyncWithLowDescriptors_1 = require("./spawnSyncWithLowDescriptors");
|
|
1034
|
-
* @evidence contracts/performance.md#bound-retention-and-release-resources The synchronous probe owns child completion and fallback captures; finally attempts capture close/removal, whose helper suppresses cleanup failures, so native/file release is unconfirmed on failure. Capability entries retain absolute spellings and path/identity text with no eviction quota; failed identity validation can remove an entry. Returned capability copies transfer to callers.
|
|
1035
|
-
*/
|
|
1036
|
-
function javascriptRuntimeCapabilities(runtime, env, cwd, identities) {
|
|
1037
|
-
+ // The running process answers for itself. Under Bun, process.execPath names
|
|
1038
|
-
+ // Bun (pluginDescriptorRuntimeBinary), and a probe of it can fail for reasons
|
|
1039
|
-
+ // that say nothing about the executable: its 30 s timeout under load, or a
|
|
1040
|
-
+ // spawn the host refused. Read as "not Bun", that failure handed Bun Node's
|
|
1041
|
-
+ // `--input-type ""`, which Bun runs as an empty `bun run` script, so the
|
|
1042
|
-
+ // plugin descriptor produced no output. This process knows what it is.
|
|
1043
|
-
+ if (node_path_1.default.isAbsolute(runtime) && sameRuntimeExecutable(runtime, process.execPath)) {
|
|
1044
|
-
+ return {
|
|
1045
|
-
+ bun: typeof globalThis.Bun === "object",
|
|
1046
|
-
+ executable: process.execPath,
|
|
1047
|
-
+ registerHooks: typeof require("node:module").registerHooks === "function",
|
|
1048
|
-
+ };
|
|
1049
|
-
+ }
|
|
1050
|
-
// Inside a ttsx run this is the user's NODE_OPTIONS, not ttsx's preloads,
|
|
1051
|
-
// which would refuse the cache and run in the probe (#1740).
|
|
1052
|
-
const effectiveEnv = TtsxNodeOptions_1.TtsxNodeOptions.forHelpers(SidecarEnvironment_1.SidecarEnvironment.merge(process.env, env));
|
|
1053
|
-
diff --git a/lib/plugin/internal/load/loadProjectPlugins.js b/lib/plugin/internal/load/loadProjectPlugins.js
|
|
1054
|
-
index b833157164e2125551debbd5c4eda35dd9d223fd..0e03aa37a66a08b3546a4edf0c3338a0083eaa7c 100644
|
|
1055
|
-
--- a/lib/plugin/internal/load/loadProjectPlugins.js
|
|
1056
|
-
+++ b/lib/plugin/internal/load/loadProjectPlugins.js
|
|
1057
|
-
@@ -275,10 +275,14 @@ function loadProjectPlugins(options) {
|
|
1058
|
-
// With the witness of each such reading, so a build of a directory package
|
|
1059
|
-
// selection already read keys on that reading instead of probing Go again.
|
|
1060
|
-
const environmentWitnesses = new Map();
|
|
1061
|
-
+ // And one walk of each SDK those readings key on, shared while the load runs
|
|
1062
|
-
+ // synchronously. A watch delivery ends that batch: the owner may await, and
|
|
1063
|
-
+ // time and edits pass, so the readings after it walk again.
|
|
1064
|
-
const readings = {
|
|
1065
|
-
sources: sourceDigests,
|
|
1066
|
-
environments: environmentDigests,
|
|
1067
|
-
witnesses: environmentWitnesses,
|
|
1068
|
-
+ goRoots: new Map(),
|
|
1069
|
-
};
|
|
1070
|
-
// Records describing sources must never land inside one, so the store is
|
|
1071
|
-
// admitted for source proofs only once every source of the load is known.
|
|
1072
|
-
@@ -314,6 +318,7 @@ function loadProjectPlugins(options) {
|
|
1073
|
-
// A worker owns the watch baseline now. Complete this handoff before Go
|
|
1074
|
-
// metadata or source proof consumes the roots, preserving #1728 (#1758).
|
|
1075
|
-
yield options.onWatchInputs([...interests].sort(), sourceIdentities);
|
|
1076
|
-
+ readings.goRoots.clear();
|
|
1077
|
-
const initialSize = interests.size;
|
|
1078
|
-
for (const candidate of candidates) {
|
|
1079
|
-
// Nested source-only proposals replace the outer root manifests. Do not
|
|
1080
|
-
@@ -324,8 +329,10 @@ function loadProjectPlugins(options) {
|
|
1081
|
-
if (reportsPluginSource(directory))
|
|
1082
|
-
interests.add(directory);
|
|
1083
|
-
}
|
|
1084
|
-
- if (interests.size !== initialSize)
|
|
1085
|
-
+ if (interests.size !== initialSize) {
|
|
1086
|
-
yield options.onWatchInputs([...interests].sort(), sourceIdentities);
|
|
1087
|
-
+ readings.goRoots.clear();
|
|
1088
|
-
+ }
|
|
1089
|
-
}
|
|
1090
|
-
const proposals = NativeSourcePackages_1.NativeSourcePackages.propose(candidates.map((candidate) => ({
|
|
1091
|
-
...candidate,
|
|
1092
|
-
@@ -370,6 +377,8 @@ function loadProjectPlugins(options) {
|
|
1093
|
-
// Admission can now narrow the provisional interests without restamping the
|
|
1094
|
-
// retained package/module baselines. Final host errors still keep these roots.
|
|
1095
|
-
yield options.onWatchInputs?.(buildDirectories, sourceIdentities);
|
|
1096
|
-
+ if (options.onWatchInputs !== undefined)
|
|
1097
|
-
+ readings.goRoots.clear();
|
|
1098
|
-
const keyedDirectories = new Set(buildDirectories);
|
|
1099
|
-
const linkedContributors = records
|
|
1100
|
-
.filter((record) => record.stage === "transform")
|
|
1101
|
-
@@ -565,7 +574,7 @@ function loadProjectPlugins(options) {
|
|
1102
|
-
env: effectiveEnv,
|
|
1103
|
-
sourceDigest,
|
|
1104
|
-
environment: environmentDigests.get(directory) ??
|
|
1105
|
-
- (0, pluginBuildEnvironment_1.pluginBuildEnvironment)(directory, effectiveEnv, undefined, sourceIdentities),
|
|
1106
|
-
+ (0, pluginBuildEnvironment_1.pluginBuildEnvironment)(directory, effectiveEnv, undefined, sourceIdentities, readings.goRoots),
|
|
1107
|
-
}),
|
|
1108
|
-
])),
|
|
1109
|
-
project,
|
|
1110
|
-
diff --git a/lib/plugin/internal/source/GoSourceInputs.js b/lib/plugin/internal/source/GoSourceInputs.js
|
|
1111
|
-
index 6bf30f65eb6f046eb2b9d505f6838b330a444df4..abc3485a35c4e380dc6e4c07fbacf2553ff2e21a 100644
|
|
1112
|
-
--- a/lib/plugin/internal/source/GoSourceInputs.js
|
|
1113
|
-
+++ b/lib/plugin/internal/source/GoSourceInputs.js
|
|
1114
|
-
@@ -73,6 +73,16 @@ var GoSourceInputs;
|
|
1115
|
-
function goBuildEnv(goBinary, goBuildCacheRoot, effectiveEnv = process.env) {
|
|
1116
|
-
const env = { ...effectiveEnv };
|
|
1117
|
-
env.GOWORK = "auto";
|
|
1118
|
-
+ // GOWORK=auto puts go in workspace mode wherever a go.work lies (typia's
|
|
1119
|
-
+ // native plugin ships one), where go accepts only -mod=readonly or
|
|
1120
|
-
+ // -mod=vendor. A caller's GOFLAGS -mod=mod, a host shell's say, failed
|
|
1121
|
-
+ // every invocation; ttsc owns the workspace, so it drops that flag and
|
|
1122
|
-
+ // keeps the caller's others.
|
|
1123
|
-
+ if (env.GOFLAGS) {
|
|
1124
|
-
+ env.GOFLAGS = env.GOFLAGS.split(/\s+/)
|
|
1125
|
-
+ .filter((flag) => flag !== "" && !/^--?mod=/.test(flag))
|
|
1126
|
-
+ .join(" ");
|
|
1127
|
-
+ }
|
|
1128
|
-
// Only the actual `go build` needs ttsc's GOCACHE; read-only metadata spawns
|
|
1129
|
-
// (`go mod edit`, `go env`, `go version`) call goBuildEnv with no cache root
|
|
1130
|
-
// and inherit ambient GOCACHE rather than receiving the managed build
|
|
1131
|
-
diff --git a/lib/plugin/internal/source/NativeSourcePackages.d.ts b/lib/plugin/internal/source/NativeSourcePackages.d.ts
|
|
1132
|
-
index 898f9333ddee1701d1f8af9b19c64c4f1263b9a4..037129fdcc7cf778c8f0eb4e7dd3da01f790864d 100644
|
|
1133
|
-
--- a/lib/plugin/internal/source/NativeSourcePackages.d.ts
|
|
1134
|
-
+++ b/lib/plugin/internal/source/NativeSourcePackages.d.ts
|
|
1135
|
-
@@ -1,5 +1,6 @@
|
|
1136
|
-
import { PluginBuildEnvironmentWitness } from "./PluginBuildEnvironmentWitness";
|
|
1137
|
-
import { PluginContentIdentities } from "./PluginContentIdentities";
|
|
1138
|
-
+import type { GoRootBatch } from "./hashPluginBuildEnvironment";
|
|
1139
|
-
import { SourcePluginWorkspace } from "./SourcePluginWorkspace";
|
|
1140
|
-
/**
|
|
1141
|
-
* Observe Go-selected packages under the native builder's workspace policy.
|
|
1142
|
-
@@ -68,6 +69,11 @@ export declare namespace NativeSourcePackages {
|
|
1143
|
-
* directory keys on that reading instead of probing Go again.
|
|
1144
|
-
*/
|
|
1145
|
-
witnesses?: Map<string, PluginBuildEnvironmentWitness.Record>;
|
|
1146
|
-
+ /**
|
|
1147
|
-
+ * The load's synchronous batch of SDK observations
|
|
1148
|
-
+ * (`hashPluginBuildEnvironment`), cleared at each watch delivery.
|
|
1149
|
-
+ */
|
|
1150
|
-
+ goRoots?: GoRootBatch;
|
|
1151
|
-
}
|
|
1152
|
-
/**
|
|
1153
|
-
* Observe entries together in a private module layout for their context.
|
|
1154
|
-
diff --git a/lib/plugin/internal/source/NativeSourcePackages.js b/lib/plugin/internal/source/NativeSourcePackages.js
|
|
1155
|
-
index 47a28235462559085e2cd4849d5920f2ae48395f..05ffe792a0e10a380c71a77bfa7533e103fccb1c 100644
|
|
1156
|
-
--- a/lib/plugin/internal/source/NativeSourcePackages.js
|
|
1157
|
-
+++ b/lib/plugin/internal/source/NativeSourcePackages.js
|
|
1158
|
-
@@ -391,7 +391,7 @@ function selectionIdentity(opts, moduleRoot, goBinary, env, identities) {
|
|
1159
|
-
if (environment === undefined) {
|
|
1160
|
-
const hash = node_crypto_1.default.createHash("sha256");
|
|
1161
|
-
const witness = new Map();
|
|
1162
|
-
- (0, hashPluginBuildEnvironment_1.hashPluginBuildEnvironment)(hash, goBinary, moduleRoot, env, { readFile: (location) => node_fs_1.default.readFileSync(location) }, witness, identities);
|
|
1163
|
-
+ (0, hashPluginBuildEnvironment_1.hashPluginBuildEnvironment)(hash, goBinary, moduleRoot, env, { readFile: (location) => node_fs_1.default.readFileSync(location) }, witness, identities, readings.goRoots);
|
|
1164
|
-
environment = hash.digest("hex");
|
|
1165
|
-
readings.environments?.set(resolvedRoot, environment);
|
|
1166
|
-
readings.witnesses?.set(resolvedRoot, witness);
|
|
1167
|
-
diff --git a/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js b/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js
|
|
1168
|
-
index da585c3ce22340d4a7d3c2b2793ae5c951958372..63c842daefa4c15cbc17b778dd382ac038eed69a 100644
|
|
1169
|
-
--- a/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js
|
|
1170
|
-
+++ b/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js
|
|
1171
|
-
@@ -20,10 +20,10 @@ const pluginBuildEnvironment_1 = require("./pluginBuildEnvironment");
|
|
1172
|
-
* Cold asynchronous reads run in an exclusively owned worker. Its complete
|
|
1173
|
-
* environment snapshot is passed explicitly to the native reader. Publication
|
|
1174
|
-
* rechecks both current host variables and external witnesses after transfer.
|
|
1175
|
-
- * The worker reads the parent's shared environment for native fallback rules;
|
|
1176
|
-
- * neither it nor this owner writes that environment. Explicit reader inputs
|
|
1177
|
-
- * still use the request snapshot and publication still qualifies that
|
|
1178
|
-
- * snapshot.
|
|
1179
|
-
+ * The worker keeps the environment copy it started with, never SHARE_ENV:
|
|
1180
|
-
+ * Bun replaces the parent's process.env object for SHARE_ENV, stranding every
|
|
1181
|
-
+ * module that captured the old one (node:os tmpdir() among them). Explicit
|
|
1182
|
-
+ * reader inputs use the request snapshot, which publication qualifies.
|
|
1183
|
-
*
|
|
1184
|
-
* @evidence contracts/common.md#principled-implementation Readings pair complete environment identity with the producer's native pre-read witness; cached reuse validates that witness and asynchronous publication rechecks variables/witness after transfer. Synchronous fresh reads publish their paired observations without an extra post-read holds call here; native metadata distinguishability remains a premise.
|
|
1185
|
-
* @evidence contracts/common.md#clear-and-simple-design One owner shares observation records across synchronous reads, cache-only proof and asynchronous preparation.
|
|
1186
|
-
@@ -253,7 +253,7 @@ var PluginBuildEnvironmentReadings;
|
|
1187
|
-
function acquireWorker() {
|
|
1188
|
-
if (worker !== undefined)
|
|
1189
|
-
return worker;
|
|
1190
|
-
- const created = new node_worker_threads_1.Worker((0, workerModuleUrl_1.workerModuleUrl)(node_path_1.default.join(__dirname, `pluginBuildEnvironmentWorker${node_path_1.default.extname(__filename)}`)), { env: node_worker_threads_1.SHARE_ENV });
|
|
1191
|
-
+ const created = new node_worker_threads_1.Worker((0, workerModuleUrl_1.workerModuleUrl)(node_path_1.default.join(__dirname, `pluginBuildEnvironmentWorker${node_path_1.default.extname(__filename)}`)), {});
|
|
1192
|
-
worker = created;
|
|
1193
|
-
const retire = () => {
|
|
1194
|
-
if (worker === created)
|
|
1195
|
-
diff --git a/lib/plugin/internal/source/collectPluginSourceFiles.d.ts b/lib/plugin/internal/source/collectPluginSourceFiles.d.ts
|
|
1196
|
-
index 596a3ef69b0dca254e16d30ab2787ec9342f2b0c..296d6ac8e79ddd8ba3bb825fb2b065ffa4e262ec 100644
|
|
1197
|
-
--- a/lib/plugin/internal/source/collectPluginSourceFiles.d.ts
|
|
1198
|
-
+++ b/lib/plugin/internal/source/collectPluginSourceFiles.d.ts
|
|
1199
|
-
@@ -21,7 +21,11 @@
|
|
1200
|
-
* A link (a symbolic link or a Windows junction) outside those directories is
|
|
1201
|
-
* refused rather than skipped. The build would compile what it names, which
|
|
1202
|
-
* neither this list nor anything keyed on it covers; a Go module zip excludes
|
|
1203
|
-
- * links from a module's content for the same reason.
|
|
1204
|
-
+ * links from a module's content for the same reason. A link at or below a name
|
|
1205
|
-
+ * the go tool passes over (one beginning with `.` or `_`, or `testdata`; `go
|
|
1206
|
-
+ * help packages`) is skipped like one in an excluded directory: Go neither
|
|
1207
|
-
+ * compiles it nor embeds a link. Tools keep links there, as cowshed does for a
|
|
1208
|
-
+ * package's `.cache/lmao`, and refusing one cost the module its source identity.
|
|
1209
|
-
*
|
|
1210
|
-
* @param root The source directory: a plugin's Go module root, an overlay
|
|
1211
|
-
* module, a contributor's source, or a `replace` target outside the module.
|
|
1212
|
-
diff --git a/lib/plugin/internal/source/collectPluginSourceFiles.js b/lib/plugin/internal/source/collectPluginSourceFiles.js
|
|
1213
|
-
index a658d747d126ef367b1d2e984131447cc3f71010..2919c93daa252715add66be29b449df327c18e5b 100644
|
|
1214
|
-
--- a/lib/plugin/internal/source/collectPluginSourceFiles.js
|
|
1215
|
-
+++ b/lib/plugin/internal/source/collectPluginSourceFiles.js
|
|
1216
|
-
@@ -30,7 +30,11 @@ const GoSourceInputs_1 = require("./GoSourceInputs");
|
|
1217
|
-
* A link (a symbolic link or a Windows junction) outside those directories is
|
|
1218
|
-
* refused rather than skipped. The build would compile what it names, which
|
|
1219
|
-
* neither this list nor anything keyed on it covers; a Go module zip excludes
|
|
1220
|
-
- * links from a module's content for the same reason.
|
|
1221
|
-
+ * links from a module's content for the same reason. A link at or below a name
|
|
1222
|
-
+ * the go tool passes over (one beginning with `.` or `_`, or `testdata`; `go
|
|
1223
|
-
+ * help packages`) is skipped like one in an excluded directory: Go neither
|
|
1224
|
-
+ * compiles it nor embeds a link. Tools keep links there, as cowshed does for a
|
|
1225
|
-
+ * package's `.cache/lmao`, and refusing one cost the module its source identity.
|
|
1226
|
-
*
|
|
1227
|
-
* @param root The source directory: a plugin's Go module root, an overlay
|
|
1228
|
-
* module, a contributor's source, or a `replace` target outside the module.
|
|
1229
|
-
@@ -72,7 +76,8 @@ function walk(root, dir, out) {
|
|
1230
|
-
// list, the key, nor a watch covers, and a copy of the module cannot
|
|
1231
|
-
// recreate a link without the symlink privilege on Windows.
|
|
1232
|
-
if (GoSourceInputs_1.GoSourceInputs.shouldPruneDirectory(entry.name) ||
|
|
1233
|
-
- GoSourceInputs_1.GoSourceInputs.shouldOmitSourceFile(entry.name))
|
|
1234
|
-
+ GoSourceInputs_1.GoSourceInputs.shouldOmitSourceFile(entry.name) ||
|
|
1235
|
-
+ goToolIgnores(root, full))
|
|
1236
|
-
continue;
|
|
1237
|
-
throw new Error(`ttsc: plugin source ${root} contains a link at ${full}. A plugin's Go ` +
|
|
1238
|
-
`sources are its own files, as a Go module zip holds them: replace the ` +
|
|
1239
|
-
@@ -92,4 +97,15 @@ function walk(root, dir, out) {
|
|
1240
|
-
out.push(full);
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
+/**
|
|
1244
|
-
+ * Whether the go tool passes over `full`: it ignores every directory and file
|
|
1245
|
-
+ * whose name begins with "." or "_", and directories named "testdata" (`go help
|
|
1246
|
-
+ * packages`), so nothing at or below such a name is compiled.
|
|
1247
|
-
+ */
|
|
1248
|
-
+function goToolIgnores(root, full) {
|
|
1249
|
-
+ return node_path_1.default
|
|
1250
|
-
+ .relative(root, full)
|
|
1251
|
-
+ .split(node_path_1.default.sep)
|
|
1252
|
-
+ .some((name) => name.startsWith(".") || name.startsWith("_") || name === "testdata");
|
|
1253
|
-
+}
|
|
1254
|
-
//# sourceMappingURL=collectPluginSourceFiles.js.map
|
|
1255
|
-
|
|
1256
|
-
diff --git a/lib/plugin/internal/source/hashPluginBuildEnvironment.d.ts b/lib/plugin/internal/source/hashPluginBuildEnvironment.d.ts
|
|
1257
|
-
index b8475fb40b83ea29d631368bc3273936ba94aec9..7464692c67e560ff9dc37c65381e4babeb3ee276 100644
|
|
1258
|
-
--- a/lib/plugin/internal/source/hashPluginBuildEnvironment.d.ts
|
|
1259
|
-
+++ b/lib/plugin/internal/source/hashPluginBuildEnvironment.d.ts
|
|
1260
|
-
@@ -37,6 +37,10 @@ import type { SourceBuildFilesystemOperations } from "./SourceBuildFilesystemOpe
|
|
1261
|
-
* @param identities Record store that lets a new process prove the GOROOT
|
|
1262
|
-
* corpus and executable bytes from their metadata (`PluginContentIdentities`,
|
|
1263
|
-
* #1722); without it every process reads them.
|
|
1264
|
-
+ * @param goRoots The caller's synchronous batch of SDK observations, by
|
|
1265
|
-
+ * resolved GOROOT: readings passed the same map walk each SDK once and take
|
|
1266
|
-
+ * its witness entries from that walk. The caller clears it at any await,
|
|
1267
|
-
+ * delivery or publication boundary; without it the SDK is walked fresh.
|
|
1268
|
-
* @evidence contracts/common.md#principled-implementation Fixed artifact flags, observed compiler bytes/version, selected reported-or-fallback build values, named command executables and selected SDK files enter the same framed identity used by source-state reporting. Fallback values and metadata-qualified reuse are explicit premises, not complete observation of arbitrary toolchain inputs. GOFLAGS enters without ttsc's own compiler-target tag, so the caller's environment reproduces a 7.1 load's digest; targets are separated by their overlay modules in the build key.
|
|
1269
|
-
* @evidence contracts/common.md#clear-and-simple-design Private helpers separate compiler identity, Go-reported settings, external variables and SDK content while sharing one hash sink and optional pre-read witness.
|
|
1270
|
-
* @evidence contracts/common.md#prohibited-implementation-shortcuts Cache signatures include real identity/change metadata and effective invocation context; failed SDK witnessing refuses reuse rather than accepting a VERSION-only proxy.
|
|
1271
|
-
@@ -48,4 +52,18 @@ import type { SourceBuildFilesystemOperations } from "./SourceBuildFilesystemOpe
|
|
1272
|
-
*/
|
|
1273
|
-
export declare function hashPluginBuildEnvironment(hash: {
|
|
1274
|
-
update(data: string): unknown;
|
|
1275
|
-
-}, goBinary: string | undefined, directory: string, env: NodeJS.ProcessEnv, filesystem: SourceBuildFilesystemOperations, witness?: PluginBuildEnvironmentWitness.Record, identities?: PluginContentIdentities.Store): void;
|
|
1276
|
-
+}, goBinary: string | undefined, directory: string, env: NodeJS.ProcessEnv, filesystem: SourceBuildFilesystemOperations, witness?: PluginBuildEnvironmentWitness.Record, identities?: PluginContentIdentities.Store, goRoots?: GoRootBatch): void;
|
|
1277
|
-
+/** One synchronous batch's SDK observations, by resolved GOROOT (`hashPluginBuildEnvironment`). */
|
|
1278
|
-
+export type GoRootBatch = Map<string, GoRootObservation>;
|
|
1279
|
-
+/** One SDK walk: the store references it was judged against, its witness entries and its snapshot. */
|
|
1280
|
-
+export interface GoRootObservation {
|
|
1281
|
-
+ readonly references: ReadonlyMap<bigint, bigint> | undefined;
|
|
1282
|
-
+ readonly observations: PluginBuildEnvironmentWitness.Record;
|
|
1283
|
-
+ readonly snapshot: {
|
|
1284
|
-
+ readonly complete: boolean;
|
|
1285
|
-
+ readonly files: readonly string[];
|
|
1286
|
-
+ readonly topology: readonly string[];
|
|
1287
|
-
+ readonly signature: string;
|
|
1288
|
-
+ readonly separable: boolean;
|
|
1289
|
-
+ };
|
|
1290
|
-
+}
|
|
1291
|
-
diff --git a/lib/plugin/internal/source/hashPluginBuildEnvironment.js b/lib/plugin/internal/source/hashPluginBuildEnvironment.js
|
|
1292
|
-
index 9a33d59cedb86a4e8228cbfe1034cd1001aa338c..d7ad8c6e97e7ba4e5990d3a6b9b8264145d54627 100644
|
|
1293
|
-
--- a/lib/plugin/internal/source/hashPluginBuildEnvironment.js
|
|
1294
|
-
+++ b/lib/plugin/internal/source/hashPluginBuildEnvironment.js
|
|
1295
|
-
@@ -50,6 +50,10 @@ const spawnGoTool_1 = require("./spawnGoTool");
|
|
1296
|
-
* @param identities Record store that lets a new process prove the GOROOT
|
|
1297
|
-
* corpus and executable bytes from their metadata (`PluginContentIdentities`,
|
|
1298
|
-
* #1722); without it every process reads them.
|
|
1299
|
-
+ * @param goRoots The caller's synchronous batch of SDK observations, by
|
|
1300
|
-
+ * resolved GOROOT: readings passed the same map walk each SDK once and take
|
|
1301
|
-
+ * its witness entries from that walk. The caller clears it at any await,
|
|
1302
|
-
+ * delivery or publication boundary; without it the SDK is walked fresh.
|
|
1303
|
-
* @evidence contracts/common.md#principled-implementation Fixed artifact flags, observed compiler bytes/version, selected reported-or-fallback build values, named command executables and selected SDK files enter the same framed identity used by source-state reporting. Fallback values and metadata-qualified reuse are explicit premises, not complete observation of arbitrary toolchain inputs. GOFLAGS enters without ttsc's own compiler-target tag, so the caller's environment reproduces a 7.1 load's digest; targets are separated by their overlay modules in the build key.
|
|
1304
|
-
* @evidence contracts/common.md#clear-and-simple-design Private helpers separate compiler identity, Go-reported settings, external variables and SDK content while sharing one hash sink and optional pre-read witness.
|
|
1305
|
-
* @evidence contracts/common.md#prohibited-implementation-shortcuts Cache signatures include real identity/change metadata and effective invocation context; failed SDK witnessing refuses reuse rather than accepting a VERSION-only proxy.
|
|
1306
|
-
@@ -59,7 +63,7 @@ const spawnGoTool_1 = require("./spawnGoTool");
|
|
1307
|
-
* @evidence contracts/performance.md#reuse-equivalent-work Compiler memo identity includes selected path/file metadata and invocation cwd/environment; SDK aggregate reuse requires matching complete ordered metadata/topology. With a record store, a new process reuses the SDK aggregate and executable digests only while their signatures match the recorded ones and every stamp is separable from a freshly minted reference (#1722); `go version` and `go env` stay live because they report toolchain selection no file metadata shows. All of this relies on native metadata distinguishability and sequential observation premises. Physical directories expand once per selection policy while aliases retain edges; optional caller witnesses receive reached selected dependencies.
|
|
1308
|
-
* @evidence contracts/performance.md#bound-retention-and-release-resources Compiler, Go-environment-path and SDK maps retain historical distinct tool/context/root keys without eviction; persisted records belong to the single-file collector. SDK population/topology and full individual file reads contribute transient bytes; synchronous probes delegate process/capture lifetime to their owner and do not certify arbitrary descendants are gone. No independent entry/record/file/output byte ceiling is imposed here.
|
|
1309
|
-
*/
|
|
1310
|
-
-function hashPluginBuildEnvironment(hash, goBinary, directory, env, filesystem, witness, identities) {
|
|
1311
|
-
+function hashPluginBuildEnvironment(hash, goBinary, directory, env, filesystem, witness, identities, goRoots) {
|
|
1312
|
-
// Fixed artifact policy must invalidate binaries and reported source states
|
|
1313
|
-
// together, including binaries cached before this policy was introduced.
|
|
1314
|
-
hash.update(JSON.stringify(["source-build-flags", GoSourceInputs_1.GoSourceInputs.BUILD_FLAGS]));
|
|
1315
|
-
@@ -69,7 +73,7 @@ function hashPluginBuildEnvironment(hash, goBinary, directory, env, filesystem,
|
|
1316
|
-
resolveGoCompilerIdentity(goBinary, env, directory, witness, identities),
|
|
1317
|
-
]));
|
|
1318
|
-
}
|
|
1319
|
-
- hashGoBuildEnvironment(hash, goBinary, directory, env, filesystem, witness, identities);
|
|
1320
|
-
+ hashGoBuildEnvironment(hash, goBinary, directory, env, filesystem, witness, identities, goRoots);
|
|
1321
|
-
hashExternalGoBuildEnvironment(hash, env);
|
|
1322
|
-
}
|
|
1323
|
-
// Go build environment values that can change the produced binary or decide
|
|
1324
|
-
@@ -296,8 +300,8 @@ function hashFile(file) {
|
|
1325
|
-
hash.update(node_fs_1.default.readFileSync(file));
|
|
1326
|
-
return hash.digest("hex");
|
|
1327
|
-
}
|
|
1328
|
-
-function hashGoBuildEnvironment(hash, goBinary, cwd, env, filesystem, witness, identities) {
|
|
1329
|
-
- const values = resolveGoBuildEnvironment(goBinary, cwd, env, filesystem, witness, identities);
|
|
1330
|
-
+function hashGoBuildEnvironment(hash, goBinary, cwd, env, filesystem, witness, identities, goRoots) {
|
|
1331
|
-
+ const values = resolveGoBuildEnvironment(goBinary, cwd, env, filesystem, witness, identities, goRoots);
|
|
1332
|
-
for (const key of GO_BUILD_ENV_KEYS) {
|
|
1333
|
-
const value = values.get(key);
|
|
1334
|
-
if (value !== undefined && value !== "") {
|
|
1335
|
-
@@ -305,7 +309,7 @@ function hashGoBuildEnvironment(hash, goBinary, cwd, env, filesystem, witness, i
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
-function resolveGoBuildEnvironment(goBinary, cwd, env, filesystem, witness, identities) {
|
|
1340
|
-
+function resolveGoBuildEnvironment(goBinary, cwd, env, filesystem, witness, identities, goRoots) {
|
|
1341
|
-
const values = new Map();
|
|
1342
|
-
if (goBinary !== undefined) {
|
|
1343
|
-
const parsed = GoEnvironmentReading_1.GoEnvironmentReading.read(goBinary, cwd, env, GO_BUILD_ENV_KEYS, witness, identities);
|
|
1344
|
-
@@ -314,7 +318,7 @@ function resolveGoBuildEnvironment(goBinary, cwd, env, filesystem, witness, iden
|
|
1345
|
-
for (const key of GO_BUILD_ENV_KEYS) {
|
|
1346
|
-
const raw = parsed[key];
|
|
1347
|
-
if (typeof raw === "string" && raw !== "") {
|
|
1348
|
-
- values.set(key, normalizeGoBuildEnvValue(key, raw, env, filesystem, witness, identities));
|
|
1349
|
-
+ values.set(key, normalizeGoBuildEnvValue(key, raw, env, filesystem, witness, identities, goRoots));
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
@@ -329,19 +333,19 @@ function resolveGoBuildEnvironment(goBinary, cwd, env, filesystem, witness, iden
|
|
1354
|
-
continue;
|
|
1355
|
-
const value = env[key];
|
|
1356
|
-
if (value !== undefined && value !== "") {
|
|
1357
|
-
- values.set(key, normalizeGoBuildEnvValue(key, value, env, filesystem, witness, identities));
|
|
1358
|
-
+ values.set(key, normalizeGoBuildEnvValue(key, value, env, filesystem, witness, identities, goRoots));
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
return values;
|
|
1362
|
-
}
|
|
1363
|
-
-function normalizeGoBuildEnvValue(key, value, env, filesystem, witness, identities) {
|
|
1364
|
-
+function normalizeGoBuildEnvValue(key, value, env, filesystem, witness, identities, goRoots) {
|
|
1365
|
-
if (key === "GOROOT") {
|
|
1366
|
-
// Root/version observations also cover a missing SDK. The complete SDK
|
|
1367
|
-
// manifest below witnesses contributing files and directories, including
|
|
1368
|
-
// nested content changes that do not move the root or VERSION metadata.
|
|
1369
|
-
PluginBuildEnvironmentWitness_1.PluginBuildEnvironmentWitness.add(witness, value);
|
|
1370
|
-
PluginBuildEnvironmentWitness_1.PluginBuildEnvironmentWitness.add(witness, node_path_1.default.join(value, "VERSION"));
|
|
1371
|
-
- return resolveGoRootCacheIdentity(value, filesystem, witness, identities);
|
|
1372
|
-
+ return resolveGoRootCacheIdentity(value, filesystem, witness, identities, goRoots);
|
|
1373
|
-
}
|
|
1374
|
-
if (key === "GOFLAGS") {
|
|
1375
|
-
// ttsc's compiler-target tag is not the caller's Go environment. Omitting
|
|
1376
|
-
@@ -445,10 +449,12 @@ function hashExternalGoBuildEnvironment(hash, env) {
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
// GOROOT is usually stable but its selected source/tool payloads contribute to
|
|
1380
|
-
-// every plugin key. Retain only the final aggregate
|
|
1381
|
-
-// identity, guarded by a fresh metadata/topology manifest on every call. A
|
|
1382
|
-
-// changed or incomplete manifest falls through to the record store, then to a
|
|
1383
|
-
-// full content read.
|
|
1384
|
-
+// every plugin key. Retain only the final aggregate identity, guarded by a
|
|
1385
|
-
+// metadata/topology manifest observed once per synchronous batch: a caller's
|
|
1386
|
-
+// `goRoots` map (one load between its watch deliveries, cleared at each) shares
|
|
1387
|
-
+// one walk and its witness entries across the batch's readings, and a call with
|
|
1388
|
-
+// no batch walks fresh. A changed or incomplete manifest falls through to the
|
|
1389
|
-
+// record store, then to a full content read.
|
|
1390
|
-
//
|
|
1391
|
-
// WARNING (#1186, #1722): this map lives only as long as the process. #1186
|
|
1392
|
-
// stopped at it, so every CLI launch, worker and bundler restart still read the
|
|
1393
|
-
@@ -456,12 +462,12 @@ function hashExternalGoBuildEnvironment(hash, env) {
|
|
1394
|
-
// below is what carries the identity across processes; never drop it in favor
|
|
1395
|
-
// of this memo alone.
|
|
1396
|
-
const goRootIdentityCache = new Map();
|
|
1397
|
-
-function resolveGoRootCacheIdentity(goRoot, filesystem, witness, identities) {
|
|
1398
|
-
+function resolveGoRootCacheIdentity(goRoot, filesystem, witness, identities, goRoots) {
|
|
1399
|
-
const resolved = resolveRealPath(goRoot);
|
|
1400
|
-
if (!node_fs_1.default.existsSync(resolved)) {
|
|
1401
|
-
return `missing:${goRoot}`;
|
|
1402
|
-
}
|
|
1403
|
-
- const snapshot = collectGoRootIdentitySnapshot(resolved, witness, identities?.references);
|
|
1404
|
-
+ const snapshot = observeGoRoot(resolved, witness, identities?.references, goRoots);
|
|
1405
|
-
if (!snapshot.complete)
|
|
1406
|
-
PluginBuildEnvironmentWitness_1.PluginBuildEnvironmentWitness.refuse(witness, resolved);
|
|
1407
|
-
if (snapshot.complete) {
|
|
1408
|
-
@@ -502,6 +508,29 @@ function resolveGoRootCacheIdentity(goRoot, filesystem, witness, identities) {
|
|
1409
|
-
}
|
|
1410
|
-
return identity;
|
|
1411
|
-
}
|
|
1412
|
-
+// One SDK walk per synchronous batch. A reading the batch already walked this
|
|
1413
|
-
+// root for takes that walk's snapshot and its first-observed witness entries,
|
|
1414
|
-
+// which a later holds() compares against current metadata as it would its own.
|
|
1415
|
-
+// A different record store's references make another walk.
|
|
1416
|
-
+function observeGoRoot(resolved, witness, references, goRoots) {
|
|
1417
|
-
+ let observed = goRoots?.get(resolved);
|
|
1418
|
-
+ if (observed === undefined || observed.references !== references) {
|
|
1419
|
-
+ if (goRoots === undefined)
|
|
1420
|
-
+ return collectGoRootIdentitySnapshot(resolved, witness, references);
|
|
1421
|
-
+ const observations = new Map();
|
|
1422
|
-
+ observed = {
|
|
1423
|
-
+ observations,
|
|
1424
|
-
+ references,
|
|
1425
|
-
+ snapshot: collectGoRootIdentitySnapshot(resolved, observations, references),
|
|
1426
|
-
+ };
|
|
1427
|
-
+ goRoots.set(resolved, observed);
|
|
1428
|
-
+ }
|
|
1429
|
-
+ if (witness !== undefined)
|
|
1430
|
-
+ for (const [key, signature] of observed.observations)
|
|
1431
|
-
+ if (!witness.has(key))
|
|
1432
|
-
+ witness.set(key, signature);
|
|
1433
|
-
+ return observed.snapshot;
|
|
1434
|
-
+}
|
|
1435
|
-
function collectGoRootIdentitySnapshot(root, witness, references) {
|
|
1436
|
-
const out = [];
|
|
1437
|
-
const state = { complete: true, separable: references !== undefined };
|
|
1438
|
-
diff --git a/lib/plugin/internal/source/inspectPluginBuildLock.js b/lib/plugin/internal/source/inspectPluginBuildLock.js
|
|
1439
|
-
index 1d9fba4c59143dc68efff3dba52499121f727b66..63d7ba0a344119dad76df5fdc2477c69dccb7ba9 100644
|
|
1440
|
-
--- a/lib/plugin/internal/source/inspectPluginBuildLock.js
|
|
1441
|
-
+++ b/lib/plugin/internal/source/inspectPluginBuildLock.js
|
|
1442
|
-
@@ -65,9 +65,16 @@ function inspectPluginBuildLock(lockDir) {
|
|
1443
|
-
const PLUGIN_BUILD_LOCK_OBSERVER = node_crypto_1.default.randomBytes(16).toString("hex");
|
|
1444
|
-
function inspectV3PluginBuildLock(lockDir) {
|
|
1445
|
-
const generationDir = node_path_1.default.join(lockDir, PluginBuildLockProtocol_1.PluginBuildLockProtocol.PLUGIN_BUILD_LOCK_CURRENT_DIR);
|
|
1446
|
-
+ // `current` changes only by whole-directory renames: a holder retires it
|
|
1447
|
-
+ // onto its tombstone, and the next holder publishes a directory that
|
|
1448
|
-
+ // already holds its generation. A read that finds no valid generation
|
|
1449
|
-
+ // proves the lock malformed only when the same directory was `current`
|
|
1450
|
-
+ // before and after it. Otherwise the read straddled a handoff of the key,
|
|
1451
|
-
+ // and a handoff is a release: the caller observes the key again.
|
|
1452
|
-
+ const observed = pluginBuildLockDirectoryIdentity(generationDir);
|
|
1453
|
-
const generation = readPluginBuildLockGeneration(generationDir);
|
|
1454
|
-
if (generation === null) {
|
|
1455
|
-
- if (pluginBuildLockPathMissing(generationDir)) {
|
|
1456
|
-
+ if (observed === null || observed !== pluginBuildLockDirectoryIdentity(generationDir)) {
|
|
1457
|
-
return { state: "released" };
|
|
1458
|
-
}
|
|
1459
|
-
throw new Error(`ttsc plugin build lock has no valid ${PluginBuildLockProtocol_1.PluginBuildLockProtocol.PLUGIN_BUILD_LOCK_GENERATION_FILE}: ${generationDir}`);
|
|
1460
|
-
@@ -269,6 +276,22 @@ function readPluginBuildLockGeneration(generationDir) {
|
|
1461
|
-
return null;
|
|
1462
|
-
}
|
|
1463
|
-
}
|
|
1464
|
-
+/**
|
|
1465
|
-
+ * The device and inode of a lock directory, or null when a lookup proves it
|
|
1466
|
-
+ * absent. A permission or sharing failure proves nothing and propagates.
|
|
1467
|
-
+ */
|
|
1468
|
-
+function pluginBuildLockDirectoryIdentity(directory) {
|
|
1469
|
-
+ try {
|
|
1470
|
-
+ const stat = node_fs_1.default.statSync(directory, { bigint: true });
|
|
1471
|
-
+ return `${stat.dev}:${stat.ino}`;
|
|
1472
|
-
+ }
|
|
1473
|
-
+ catch (error) {
|
|
1474
|
-
+ if (PluginBuildLockProtocol_1.PluginBuildLockProtocol.isMissingPathError(error)) {
|
|
1475
|
-
+ return null;
|
|
1476
|
-
+ }
|
|
1477
|
-
+ throw error;
|
|
1478
|
-
+ }
|
|
1479
|
-
+}
|
|
1480
|
-
/**
|
|
1481
|
-
* Whether a path lookup proves absence. Permission and sharing failures are
|
|
1482
|
-
* inconclusive, never evidence of a released or old abandoned generation.
|
|
1483
|
-
diff --git a/lib/plugin/internal/source/pluginBuildEnvironment.d.ts b/lib/plugin/internal/source/pluginBuildEnvironment.d.ts
|
|
1484
|
-
index fa3512f0805d2ae0feccc90b7b0a6bce9a1db2f3..7817e88063e6d5b7851ca587dc808d9411fc25d3 100644
|
|
1485
|
-
--- a/lib/plugin/internal/source/pluginBuildEnvironment.d.ts
|
|
1486
|
-
+++ b/lib/plugin/internal/source/pluginBuildEnvironment.d.ts
|
|
1487
|
-
@@ -1,5 +1,6 @@
|
|
1488
|
-
import type { PluginBuildEnvironmentWitness } from "./PluginBuildEnvironmentWitness";
|
|
1489
|
-
import type { PluginContentIdentities } from "./PluginContentIdentities";
|
|
1490
|
-
+import type { GoRootBatch } from "./hashPluginBuildEnvironment";
|
|
1491
|
-
/**
|
|
1492
|
-
* The digest of the environment a plugin build in `directory` is keyed on: the
|
|
1493
|
-
* Go compiler the build resolves there, the Go build environment `go env`
|
|
1494
|
-
@@ -23,6 +24,8 @@ import type { PluginContentIdentities } from "./PluginContentIdentities";
|
|
1495
|
-
* carries (`hashPluginBuildEnvironment`).
|
|
1496
|
-
* @param identities Record store that lets a new process prove the SDK and
|
|
1497
|
-
* executables from metadata (#1722).
|
|
1498
|
-
+ * @param goRoots The caller's synchronous batch of SDK observations
|
|
1499
|
-
+ * (`hashPluginBuildEnvironment`), or `undefined` to walk the SDK fresh.
|
|
1500
|
-
* @evidence contracts/common.md#principled-implementation The digest uses the same resolved compiler and environment serializer as the binary key, so reported toolchain state denotes the inputs actually used by the build.
|
|
1501
|
-
* @evidence contracts/common.md#clear-and-simple-design Compiler selection, executable resolution and hashing each stay with their owning helper; this function only composes one environment reading.
|
|
1502
|
-
* @evidence contracts/common.md#prohibited-implementation-shortcuts The result comes from real Go/environment inputs, not a fixed compiler version or a caller-specific substitute.
|
|
1503
|
-
@@ -30,7 +33,7 @@ import type { PluginContentIdentities } from "./PluginContentIdentities";
|
|
1504
|
-
* @evidence contracts/portability.md#os-neutral-implementation Executable identity is resolved before probing, and Node filesystem/process boundaries implement native spelling rather than assuming Windows or POSIX paths are interchangeable.
|
|
1505
|
-
* @evidence contracts/performance.md#efficient-algorithms The wrapper resolves the compiler/tool under the supplied environment before delegating full environment hashing. Native resolution/probes, SDK metadata/name/path sorting and changed-manifest full content reads contribute cost; the final hash output is fixed-width but streamed identity/input text and full-file buffers are not. No independent duplicate source-directory digest scan is added here.
|
|
1506
|
-
*
|
|
1507
|
-
- * @evidence contracts/performance.md#reuse-equivalent-work This is the fresh-reading boundary required by builds: the Go probes run on every call. Content digests of the SDK and executables are shared across processes only through the supplied record store's separable-signature proof; processPluginBuildEnvironment owns reuse of the whole reading when a consumer permits it.
|
|
1508
|
-
+ * @evidence contracts/performance.md#reuse-equivalent-work This is the fresh-reading boundary required by builds: the Go probes run on every call. The SDK walk is fresh too, except inside the caller's synchronous batch (`goRoots`: one load between its watch deliveries, cleared at each), whose readings share one SDK observation as the witness contract allows. Content digests of the SDK and executables are shared across processes only through the supplied record store's separable-signature proof; processPluginBuildEnvironment owns reuse of the whole reading when a consumer permits it.
|
|
1509
|
-
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources Its digest and filesystem adapter are call-local; retained compiler/content memo ownership belongs to the hasher.
|
|
1510
|
-
*/
|
|
1511
|
-
-export declare function pluginBuildEnvironment(directory: string, env?: NodeJS.ProcessEnv, witness?: PluginBuildEnvironmentWitness.Record, identities?: PluginContentIdentities.Store): string;
|
|
1512
|
-
+export declare function pluginBuildEnvironment(directory: string, env?: NodeJS.ProcessEnv, witness?: PluginBuildEnvironmentWitness.Record, identities?: PluginContentIdentities.Store, goRoots?: GoRootBatch): string;
|
|
1513
|
-
diff --git a/lib/plugin/internal/source/pluginBuildEnvironment.js b/lib/plugin/internal/source/pluginBuildEnvironment.js
|
|
1514
|
-
index 63041fd3831d6d51faebc61df12db26b5f852383..fb2694b9b12ba3029fd873b28e5dfb0492fb0a6f 100644
|
|
1515
|
-
--- a/lib/plugin/internal/source/pluginBuildEnvironment.js
|
|
1516
|
-
+++ b/lib/plugin/internal/source/pluginBuildEnvironment.js
|
|
1517
|
-
@@ -32,6 +32,8 @@ const resolveGoCompiler_1 = require("./resolveGoCompiler");
|
|
1518
|
-
* carries (`hashPluginBuildEnvironment`).
|
|
1519
|
-
* @param identities Record store that lets a new process prove the SDK and
|
|
1520
|
-
* executables from metadata (#1722).
|
|
1521
|
-
+ * @param goRoots The caller's synchronous batch of SDK observations
|
|
1522
|
-
+ * (`hashPluginBuildEnvironment`), or `undefined` to walk the SDK fresh.
|
|
1523
|
-
* @evidence contracts/common.md#principled-implementation The digest uses the same resolved compiler and environment serializer as the binary key, so reported toolchain state denotes the inputs actually used by the build.
|
|
1524
|
-
* @evidence contracts/common.md#clear-and-simple-design Compiler selection, executable resolution and hashing each stay with their owning helper; this function only composes one environment reading.
|
|
1525
|
-
* @evidence contracts/common.md#prohibited-implementation-shortcuts The result comes from real Go/environment inputs, not a fixed compiler version or a caller-specific substitute.
|
|
1526
|
-
@@ -39,13 +41,13 @@ const resolveGoCompiler_1 = require("./resolveGoCompiler");
|
|
1527
|
-
* @evidence contracts/portability.md#os-neutral-implementation Executable identity is resolved before probing, and Node filesystem/process boundaries implement native spelling rather than assuming Windows or POSIX paths are interchangeable.
|
|
1528
|
-
* @evidence contracts/performance.md#efficient-algorithms The wrapper resolves the compiler/tool under the supplied environment before delegating full environment hashing. Native resolution/probes, SDK metadata/name/path sorting and changed-manifest full content reads contribute cost; the final hash output is fixed-width but streamed identity/input text and full-file buffers are not. No independent duplicate source-directory digest scan is added here.
|
|
1529
|
-
*
|
|
1530
|
-
- * @evidence contracts/performance.md#reuse-equivalent-work This is the fresh-reading boundary required by builds: the Go probes run on every call. Content digests of the SDK and executables are shared across processes only through the supplied record store's separable-signature proof; processPluginBuildEnvironment owns reuse of the whole reading when a consumer permits it.
|
|
1531
|
-
+ * @evidence contracts/performance.md#reuse-equivalent-work This is the fresh-reading boundary required by builds: the Go probes run on every call. The SDK walk is fresh too, except inside the caller's synchronous batch (`goRoots`: one load between its watch deliveries, cleared at each), whose readings share one SDK observation as the witness contract allows. Content digests of the SDK and executables are shared across processes only through the supplied record store's separable-signature proof; processPluginBuildEnvironment owns reuse of the whole reading when a consumer permits it.
|
|
1532
|
-
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources Its digest and filesystem adapter are call-local; retained compiler/content memo ownership belongs to the hasher.
|
|
1533
|
-
*/
|
|
1534
|
-
-function pluginBuildEnvironment(directory, env = process.env, witness, identities) {
|
|
1535
|
-
+function pluginBuildEnvironment(directory, env = process.env, witness, identities, goRoots) {
|
|
1536
|
-
const goBinary = GoToolResolution_1.GoToolResolution.resolveGoToolForBuild((0, resolveGoCompiler_1.resolveGoCompiler)(env).binary, env, directory, witness);
|
|
1537
|
-
const hash = node_crypto_1.default.createHash("sha256");
|
|
1538
|
-
- (0, hashPluginBuildEnvironment_1.hashPluginBuildEnvironment)(hash, goBinary, directory, env, { readFile: (location) => node_fs_1.default.readFileSync(location) }, witness, identities);
|
|
1539
|
-
+ (0, hashPluginBuildEnvironment_1.hashPluginBuildEnvironment)(hash, goBinary, directory, env, { readFile: (location) => node_fs_1.default.readFileSync(location) }, witness, identities, goRoots);
|
|
1540
|
-
return hash.digest("hex");
|
|
1541
|
-
}
|
|
1542
|
-
//# sourceMappingURL=pluginBuildEnvironment.js.map
|
|
1543
|
-
|
|
1544
|
-
diff --git a/lib/plugin/internal/source/waitForPluginBinary.js b/lib/plugin/internal/source/waitForPluginBinary.js
|
|
1545
|
-
index 191b99ea9f36da615f82f921d40c185a56737bbd..a741af5a3e5d401f1827d896774d89bf7e2bd0c5 100644
|
|
1546
|
-
--- a/lib/plugin/internal/source/waitForPluginBinary.js
|
|
1547
|
-
+++ b/lib/plugin/internal/source/waitForPluginBinary.js
|
|
1548
|
-
@@ -25,6 +25,12 @@ const inspectPluginBuildLock_1 = require("./inspectPluginBuildLock");
|
|
1549
|
-
* run. An opted-in synchronous owner can cancel observation or interrupt a
|
|
1550
|
-
* polling sleep; cancellation never retires the holder's generation.
|
|
1551
|
-
*
|
|
1552
|
-
+ * A published binary is not admission: the caller registers as its reader
|
|
1553
|
-
+ * under the key, which only release or retirement frees. Each poll therefore
|
|
1554
|
-
+ * inspects the lock before it reports publication, so a holder that died
|
|
1555
|
-
+ * holding the key after its binary was published is reported abandoned
|
|
1556
|
-
+ * instead of outwaiting the admission budget.
|
|
1557
|
-
+ *
|
|
1558
|
-
* @evidence contracts/common.md#principled-implementation Polling first refuses unknown/malformed native guards, suppresses publication while pending and rechecks after observed release; actual abandoned-owner observations retain their exact generation, while budget expiry fails without revoking a possibly active payload task.
|
|
1559
|
-
* @evidence contracts/common.md#clear-and-simple-design The loop separates publication, release, retirement and periodic status reporting; generation interpretation belongs to inspectPluginBuildLock.
|
|
1560
|
-
* @evidence contracts/common.md#prohibited-implementation-shortcuts Budget expiry throws instead of retiring a live-looking generation and compensating for concurrent callbacks; status output never substitutes for ownership evidence.
|
|
1561
|
-
@@ -43,22 +49,9 @@ function waitForPluginBinary(opts) {
|
|
1562
|
-
OwnedSynchronousProcess_1.OwnedSynchronousProcess.checkpoint();
|
|
1563
|
-
SourceNativeRetirement_1.SourceNativeRetirement.assertAvailable(protocolDir);
|
|
1564
|
-
const protectedNativeInputs = SourceNativeRetirement_1.SourceNativeRetirement.isProtected(protocolDir);
|
|
1565
|
-
- if (!protectedNativeInputs && node_fs_1.default.existsSync(opts.binaryPath)) {
|
|
1566
|
-
- OwnedSynchronousProcess_1.OwnedSynchronousProcess.checkpoint();
|
|
1567
|
-
- return { outcome: "published" };
|
|
1568
|
-
- }
|
|
1569
|
-
const clock = performance.now();
|
|
1570
|
-
const lock = (0, inspectPluginBuildLock_1.inspectPluginBuildLock)(opts.lockDir);
|
|
1571
|
-
OwnedSynchronousProcess_1.OwnedSynchronousProcess.checkpoint();
|
|
1572
|
-
- if (lock.state === "released") {
|
|
1573
|
-
- // The holder retired its generation between the binary check above and
|
|
1574
|
-
- // this observation. That is a normal release, not abandonment: prefer the
|
|
1575
|
-
- // binary when it landed inside that window, otherwise hand the free key
|
|
1576
|
-
- // back to the caller.
|
|
1577
|
-
- return !protectedNativeInputs && node_fs_1.default.existsSync(opts.binaryPath)
|
|
1578
|
-
- ? { outcome: "published" }
|
|
1579
|
-
- : { outcome: "released" };
|
|
1580
|
-
- }
|
|
1581
|
-
if (lock.state === "abandoned") {
|
|
1582
|
-
return {
|
|
1583
|
-
outcome: "abandoned",
|
|
1584
|
-
@@ -66,6 +59,12 @@ function waitForPluginBinary(opts) {
|
|
1585
|
-
fence: lock.fence,
|
|
1586
|
-
};
|
|
1587
|
-
}
|
|
1588
|
-
+ if (!protectedNativeInputs && node_fs_1.default.existsSync(opts.binaryPath)) {
|
|
1589
|
-
+ return { outcome: "published" };
|
|
1590
|
-
+ }
|
|
1591
|
-
+ if (lock.state === "released") {
|
|
1592
|
-
+ return { outcome: "released" };
|
|
1593
|
-
+ }
|
|
1594
|
-
if (clock - startedAt >= opts.timeoutMs) {
|
|
1595
|
-
throw new Error(`ttsc: timed out after ${(0, formatDuration_1.formatDuration)(clock - startedAt)} waiting for ` +
|
|
1596
|
-
`${opts.lockInfo.label} "${opts.lockInfo.pluginName}" at ${opts.lockDir}; ` +
|
|
1597
|
-
diff --git a/utility/host.go b/utility/host.go
|
|
1598
|
-
index 5db2b9af70ee7b971659670bbe09d186ea90ada9..dcd04ca94c0900896b0e1bc04e9ed53e7da47b65 100644
|
|
1599
|
-
--- a/utility/host.go
|
|
1600
|
-
+++ b/utility/host.go
|
|
1601
|
-
@@ -7,6 +7,7 @@ import (
|
|
1602
|
-
"io"
|
|
1603
|
-
"os"
|
|
1604
|
-
"path/filepath"
|
|
1605
|
-
+ "sort"
|
|
1606
|
-
"strings"
|
|
1607
|
-
|
|
1608
|
-
shimcompiler "github.com/microsoft/typescript-go/shim/compiler"
|
|
1609
|
-
@@ -79,6 +80,11 @@ type transformResult struct {
|
|
1610
|
-
HostInputHashes map[string]*string `json:"hostInputHashes,omitempty"`
|
|
1611
|
-
HostInputRealpaths map[string]*string `json:"hostInputRealpaths,omitempty"`
|
|
1612
|
-
|
|
1613
|
-
+ // EnvironmentInputs maps each environment variable a linked hook read
|
|
1614
|
-
+ // through PluginContext.Env to the value it read; null means unset.
|
|
1615
|
-
+ // Omitted when no hook read one.
|
|
1616
|
-
+ EnvironmentInputs map[string]*string `json:"environmentInputs,omitempty"`
|
|
1617
|
-
+
|
|
1618
|
-
// ObservationsComplete is present only as false when a linked hook explicitly
|
|
1619
|
-
// could not observe its input population. Absence is not completeness proof.
|
|
1620
|
-
ObservationsComplete *bool `json:"observationsComplete,omitempty"`
|
|
1621
|
-
@@ -255,7 +261,10 @@ func RunBuildWithIO(args []string, stdout, stderr io.Writer) int {
|
|
1622
|
-
opts.quiet = false // --verbose overrides the default --quiet=true
|
|
1623
|
-
}
|
|
1624
|
-
if !opts.quiet {
|
|
1625
|
-
- fmt.Fprintf(opts.stdout, "// ttsc utility: plugins=%d emit=%v\n", len(entries), !opts.noEmit)
|
|
1626
|
-
+ // The header and the " + <path>" list below are the summary shape ttsc's
|
|
1627
|
-
+ // build lane (cmd/ttsc/build.go) and ttsc-typia print, so a caller that
|
|
1628
|
-
+ // reads the emitted files from --verbose reads this lane the same way.
|
|
1629
|
-
+ fmt.Fprintf(opts.stdout, "// ttsc utility: tsconfig=%s cwd=%s emit=%v plugins=%d\n", opts.tsconfig, opts.cwd, !opts.noEmit, len(entries))
|
|
1630
|
-
}
|
|
1631
|
-
writeFile, finishPreamble := makeSourcePreambleWriteFile(prog)
|
|
1632
|
-
var snapshot func() map[string][]string
|
|
1633
|
-
@@ -305,6 +314,19 @@ func RunBuildWithIO(args []string, stdout, stderr io.Writer) int {
|
|
1634
|
-
}
|
|
1635
|
-
if !opts.quiet {
|
|
1636
|
-
fmt.Fprintf(opts.stdout, "// ttsc utility: emitted=%d files\n", len(emittedFiles))
|
|
1637
|
-
+ listed := make([]string, 0, len(emittedFiles))
|
|
1638
|
-
+ for fileName := range emittedFiles {
|
|
1639
|
-
+ listed = append(listed, fileName)
|
|
1640
|
-
+ }
|
|
1641
|
-
+ sort.Strings(listed)
|
|
1642
|
-
+ for _, fileName := range listed {
|
|
1643
|
-
+ rel := fileName
|
|
1644
|
-
+ if relative, err := filepath.Rel(opts.cwd, fileName); err == nil {
|
|
1645
|
-
+ rel = relative
|
|
1646
|
-
+ }
|
|
1647
|
-
+ fmt.Fprintln(opts.stdout, " +", rel)
|
|
1648
|
-
+ }
|
|
1649
|
-
+ driver.WriteEnvironmentInputsSummary(opts.stdout, "// ttsc utility: ", prog)
|
|
1650
|
-
}
|
|
1651
|
-
return 0
|
|
1652
|
-
}
|
|
1653
|
-
@@ -398,6 +420,7 @@ func RunTransformWithIO(args []string, stdout, stderr io.Writer) int {
|
|
1654
|
-
out.HostInputs = prog.PluginHostInputs()
|
|
1655
|
-
out.HostInputHashes = prog.PluginHostInputHashes()
|
|
1656
|
-
out.HostInputRealpaths = prog.PluginHostInputRealpaths()
|
|
1657
|
-
+ out.EnvironmentInputs = prog.PluginEnvironmentInputs()
|
|
1658
|
-
if prog.PluginObservationsIncomplete() {
|
|
1659
|
-
incomplete := false
|
|
1660
|
-
out.ObservationsComplete = &incomplete
|