nish 0.39.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +190 -555
  2. package/docs/AI.md +112 -33
  3. package/docs/INSTALL.md +79 -133
  4. package/llms.txt +2 -9
  5. package/package.json +17 -19
  6. package/runtime/nish.d.ts +21 -17
  7. package/runtime/nish.h +10 -0
  8. package/runtime/page-frame.d.ts +123 -0
  9. package/runtime/page-frame.mjs +736 -0
  10. package/runtime/page-game.d.ts +132 -0
  11. package/runtime/page-game.mjs +738 -0
  12. package/runtime/runtime-aes.c +85 -8
  13. package/runtime/runtime-bytes.c +88 -4
  14. package/runtime/runtime-net.c +32 -0
  15. package/runtime/runtime-sandbox.c +55 -28
  16. package/runtime/runtime-uring.c +1194 -0
  17. package/runtime/runtime-wasm.c +422 -0
  18. package/runtime/vite.mjs +1 -1
  19. package/scripts/build.sh +22 -6
  20. package/std/README.md +74 -87
  21. package/std/array.ts +36 -3
  22. package/std/collections.ts +51 -0
  23. package/std/crypto/hmac.ts +37 -10
  24. package/std/crypto/p256.ts +1388 -2664
  25. package/std/crypto/pki.ts +116 -4
  26. package/std/crypto/sha256.ts +34 -6
  27. package/std/crypto/x509.ts +7 -0
  28. package/std/host/game.ts +273 -0
  29. package/std/input.ts +56 -0
  30. package/std/json-tokenizer.ts +325 -112
  31. package/std/json-typed.ts +43 -8
  32. package/std/json-value.ts +144 -3
  33. package/std/json.ts +63 -8
  34. package/std/net/fetch.ts +22 -4
  35. package/std/net/http-server.ts +3382 -0
  36. package/std/net/http1-client-codec.ts +6 -2
  37. package/std/net/http1-codec.ts +137 -12
  38. package/std/net/http1-server.ts +83 -29
  39. package/std/net/http2.ts +47 -14
  40. package/std/net/http3-server.ts +29 -3
  41. package/std/net/http3.ts +180 -7
  42. package/std/net/prefork.ts +49 -13
  43. package/std/net/quic-recovery.ts +240 -9
  44. package/std/net/quic-stream.ts +21 -1
  45. package/std/net/quic.ts +98 -4
  46. package/std/net/router.ts +378 -31
  47. package/std/net/serve.ts +873 -65
  48. package/std/net/tls/verify.ts +19 -1
  49. package/std/net/url.ts +83 -35
  50. package/std/net/websocket.ts +74 -1
  51. package/std/net/webtransport.ts +7 -1
  52. package/std/raster.ts +837 -0
  53. package/std/release.ts +593 -0
  54. package/std/synth.ts +143 -0
  55. package/std/temporal.ts +3091 -0
  56. package/std/threads.ts +298 -0
  57. package/std/yaml-json.ts +368 -28
  58. package/std/yaml.ts +122 -27
  59. package/scripts/bootstrap.sh +0 -375
  60. package/scripts/build-id-smoke.sh +0 -28
  61. package/scripts/changelog-gen.mjs +0 -649
  62. package/scripts/changelog-section.sh +0 -28
  63. package/scripts/check-hardening.mjs +0 -202
  64. package/scripts/ci-profile.mjs +0 -200
  65. package/scripts/codes-registry.js +0 -85
  66. package/scripts/fuzz.sh +0 -280
  67. package/scripts/gen-diagnostic-codes.mjs +0 -243
  68. package/scripts/gen-json-pow5.mjs +0 -130
  69. package/scripts/gen-p256-table.mjs +0 -177
  70. package/scripts/gen-pow10-table.py +0 -80
  71. package/scripts/gen-regex-unicode.mjs +0 -822
  72. package/scripts/gen-union-scale.mjs +0 -294
  73. package/scripts/nish-compiler.sh +0 -19
  74. package/scripts/platform-package.mjs +0 -93
  75. package/scripts/security-scope.mjs +0 -139
  76. package/scripts/shard-costs.mjs +0 -429
  77. package/scripts/size-report.sh +0 -84
  78. package/scripts/smoke.sh +0 -105
  79. package/scripts/std-module-paths.mjs +0 -25
  80. package/scripts/undocumented.txt +0 -14
  81. package/scripts/verify-binaries.sh +0 -214
@@ -1,214 +0,0 @@
1
- #!/usr/bin/env bash
2
- # `stage3 == stage2`: the last of the equalities `scripts/bootstrap.sh --verify`
3
- # asserts, as a script of its own.
4
- #
5
- # scripts/verify-binaries.sh <stage2> <stage3>
6
- #
7
- # Exit 0 and one or more lines on stdout saying what was compared; exit 1 and
8
- # the reason on stderr when the two binaries are not the same compiler.
9
- #
10
- # It is a file rather than a block inside bootstrap.sh for the reason
11
- # .github/seed-matrix.sh is one: it is a gate, it has arms that only one
12
- # operating system reaches, and a gate nothing can run is a gate nothing
13
- # checks. `tests/run.js` drives this script with fabricated files and
14
- # `NISH_UNAME_S` set, so every arm is reached from whatever machine the suite
15
- # runs on. Read the caveat under WHAT THE TESTS PROVE before trusting that
16
- # sentence further than it goes.
17
- #
18
- # THE COMPARISON. Two links of the same input produce the same bytes on ELF,
19
- # and that is the strongest form of "stage2 reproduces itself": it is asserted
20
- # there and nothing here relaxes it.
21
- #
22
- # On Mach-O they did not, and that was measured rather than expected: on
23
- # macos-latest (2026-09-13, WP19 R2) stage3 and stage2 differed at identical
24
- # size -- 597,048 bytes both -- while every IR equality in bootstrap.sh passed.
25
- # Same size, differing bytes: something small and fixed-width was not
26
- # reproducible, and it was the linker's rather than the compiler's.
27
- #
28
- # WHAT THAT SOMETHING WAS is now measured, and an earlier version of this
29
- # header first claimed it wrongly and then said, correctly, that nobody had run
30
- # it on a mac. Somebody has: a throwaway workflow ran release.yml's `binaries`
31
- # steps on both darwin rows on 2026-09-19 and attributed every differing byte
32
- # to the load command, section or linkedit blob it falls inside.
33
- #
34
- # x86_64-darwin 649,808 bytes both, 16 differing, all at 0x468..0x478:
35
- # (macos-15-intel) LC_UUID's sixteen bytes of UUID, and nothing else in the
36
- # file. `otool -l` diffed to the one `uuid` line.
37
- #
38
- # aarch64-darwin 646,696 bytes both, 48 differing: the same sixteen at
39
- # (macos-latest) 0x468, plus 33 in the LC_CODE_SIGNATURE blob at 0x9ca81 --
40
- # one SHA-256 code-directory slot. ld64 ad-hoc signs arm64
41
- # (`codesign -dvvv`: adhoc,linker-signed) and that slot is
42
- # the page hash of the page LC_UUID sits on, so the
43
- # signature is the consequence and the UUID the cause. The
44
- # Intel row, which ld64 does not sign at all, is the control
45
- # for that claim.
46
- #
47
- # So LC_UUID it was, as this header had guessed. The remedy it proposed was
48
- # wrong, and that is measured too: `-Wl,-no_uuid` does make the two files
49
- # identical, and dyld on arm64 then refuses to load either of them -- `missing
50
- # LC_UUID load command`, then SIGABRT -- so the stage links and will not start.
51
- # An unloadable compiler is worse than any reproducibility. ELF needs no such
52
- # remedy: its twin of LC_UUID, the build-id note, is linked as
53
- # `--build-id=sha1` (scripts/build.sh), a hash of the output's own bytes.
54
- #
55
- # WHAT SETTLED IT was one more measurement. Three links of one input by one
56
- # compiler, on both rows -- twice to the same output path, once to a different
57
- # one -- and what came back is that the UUID is STABLE ACROSS TWO LINKS TO ONE
58
- # PATH and DIFFERS ON A LINK TO ANOTHER, with nothing else in the file moving.
59
- # It is not a hash of the output's own content, then, which is what ld64
60
- # classic did and what would have made any two links of one input agree.
61
- #
62
- # The output path is the leading explanation and it is not the only one the
63
- # probe leaves standing. The two same-path links were invocations 1 and 2 and
64
- # the differing-path link was invocation 3, and the probe never went back to
65
- # the first path -- so path-identity and invocation-order are confounded, and
66
- # anything that had changed by the third link (a coarse clock tick, a
67
- # per-session counter, an intermediate name derived from the path rather than
68
- # equal to it) fits the same numbers. A fourth link back to the first path,
69
- # expected to reproduce the FIRST UUID, is the one line that would tell them
70
- # apart, and it was not run.
71
- #
72
- # The remedy holds either way, which is why this is left as it is rather than
73
- # guessed at: run 4 measured it end to end, with a real `bootstrap.sh --verify`
74
- # on both darwin rows, and got byte-identical stages. Whatever LC_UUID is a
75
- # function of, two stages linked at one path agree.
76
- #
77
- # That makes the failure the harness's rather than the toolchain's:
78
- # `scripts/bootstrap.sh` linked stage2 at `$work/stage2` and stage3 at
79
- # `$work/stage3`, so two compilers that agreed about every other byte were
80
- # guaranteed two different UUIDs. It links both at `$work/stage` now and moves
81
- # each into place afterwards, and both darwin rows reach the `cmp -s` above and
82
- # stop at it. Nothing below was relaxed to get there.
83
- #
84
- # The debug map, which an even earlier version of this header named, was never
85
- # it: bootstrap.sh defaults to `--profile speed` and never passes `-g`, so
86
- # there is no DWARF in the .o files for ld64 to build a map from, and build.sh
87
- # already dropped the local symbols at the link.
88
- #
89
- # WHAT IS ASSERTED ON DARWIN is therefore a net under a byte comparison that
90
- # now holds, rather than the arm that decides a darwin row. It costs nothing
91
- # while the two files are identical, and it is narrower than raw bytes and
92
- # wider than nothing when some future toolchain starts varying something else:
93
- #
94
- # * the two files are the same SIZE. The measurement above is that they were,
95
- # exactly, while differing -- so a difference in generated code, which is
96
- # what this comparison exists to catch, has to keep the byte count to get
97
- # past it. This is the assertion doing the work.
98
- # * they are identical once debug information is stripped, where a tool on
99
- # PATH can strip it. At `--profile speed` that is expected to remove
100
- # nothing, per the debug-map paragraph above; it is kept because it costs
101
- # nothing and because `--profile debug` does put DWARF in the .o files.
102
- #
103
- # A pair that is the same size and still differs after that is reported as
104
- # **unattributed** and fails. It fails because the alternative is a blanket
105
- # exemption that would accept a stage3 that is a different compiler, which is
106
- # the one thing this comparison is for; and it says "unattributed" rather than
107
- # "the code differs" because the one thing ld64 was measured to vary is already
108
- # accounted for by the shared link path, so what is left is unknown rather than
109
- # damning. The message carries the next step.
110
- #
111
- # WHAT THE TESTS PROVE. `tests/run.js` reaches every branch here, and for the
112
- # Darwin branches it does so two ways: with ELF pairs, which establish the
113
- # control flow only -- `NISH_UNAME_S=Darwin` changes which branch runs, not
114
- # what format the files are -- and with a fabricated minimal Mach-O pair
115
- # differing only in LC_UUID, which is the real format and the real field. That
116
- # second one is what says the unattributed arm is reachable with a benign pair,
117
- # and it is asserted as a known limitation rather than as a pass. It stays a
118
- # limitation of this script, and it has stopped describing what a bootstrap
119
- # produces: the stages still carry an LC_UUID each, and bootstrap.sh links them
120
- # at one path, so the two agree and there is no such pair to forgive.
121
- set -euo pipefail
122
-
123
- if [ $# -ne 2 ]; then
124
- echo "usage: scripts/verify-binaries.sh <stage2> <stage3>" >&2
125
- exit 2
126
- fi
127
- a="$1"
128
- b="$2"
129
- for f in "$a" "$b"; do
130
- [ -f "$f" ] || { echo "verify-binaries: $f does not exist" >&2; exit 2; }
131
- done
132
-
133
- # Overridden by tests/run.js so both platforms' branches can be driven from one
134
- # machine. Announced when set, because a release build that had this in its
135
- # environment would assert a different equality and the log should say so.
136
- uname_s="$(uname -s)"
137
- if [ -n "${NISH_UNAME_S:-}" ] && [ "${NISH_UNAME_S}" != "$uname_s" ]; then
138
- echo "verify-binaries: NISH_UNAME_S=$NISH_UNAME_S overrides the real platform ($uname_s); this is a test hook" >&2
139
- uname_s="$NISH_UNAME_S"
140
- fi
141
-
142
- if cmp -s "$a" "$b"; then
143
- echo "stage3 == stage2: byte-identical binaries"
144
- exit 0
145
- fi
146
-
147
- if [ "$uname_s" != "Darwin" ]; then
148
- echo "bootstrap: stage3 is not byte-identical to stage2" >&2
149
- exit 1
150
- fi
151
-
152
- size_a=$(wc -c < "$a" | tr -d ' ')
153
- size_b=$(wc -c < "$b" | tr -d ' ')
154
- if [ "$size_a" != "$size_b" ]; then
155
- {
156
- echo "bootstrap: stage3 differs from stage2 and the two are not even the same size"
157
- echo "bootstrap: ($size_a vs $size_b bytes). Whatever is not reproducible about ld64 is"
158
- echo "bootstrap: small and fixed-width -- the size is not it. This is a difference in"
159
- echo "bootstrap: what the compiler emitted (docs/wp10-ci.md#ci-matrix)."
160
- } >&2
161
- exit 1
162
- fi
163
-
164
- # A scratch directory of its own, so this never writes next to the binaries it
165
- # was handed -- bootstrap.sh's work directory is also where the next stage gets
166
- # built, and tests/run.js hands it files in a fixture it then compares.
167
- tmp="$(mktemp -d)"
168
- trap 'rm -rf "$tmp"' EXIT
169
- stripped=0
170
- for tool in llvm-objcopy objcopy; do
171
- if command -v "$tool" >/dev/null 2>&1 &&
172
- "$tool" --strip-debug "$a" "$tmp/a" 2>/dev/null &&
173
- "$tool" --strip-debug "$b" "$tmp/b" 2>/dev/null; then
174
- stripped=1
175
- break
176
- fi
177
- done
178
- if [ "$stripped" -eq 0 ] && command -v strip >/dev/null 2>&1; then
179
- cp "$a" "$tmp/a"
180
- cp "$b" "$tmp/b"
181
- if strip -x "$tmp/a" 2>/dev/null && strip -x "$tmp/b" 2>/dev/null; then
182
- stripped=1
183
- fi
184
- fi
185
-
186
- if [ "$stripped" -eq 1 ] && cmp -s "$tmp/a" "$tmp/b"; then
187
- echo "stage3 == stage2: same size ($size_a bytes) and identical once debug information"
188
- echo "was stripped; the raw bytes differ, which is ld64 and not the compiler"
189
- exit 0
190
- fi
191
-
192
- {
193
- echo "bootstrap: stage3 and stage2 are the same size ($size_a bytes) and still differ."
194
- if [ "$stripped" -eq 1 ]; then
195
- echo "bootstrap: Stripping debug information did not account for it -- which at"
196
- echo "bootstrap: --profile speed is expected, because nothing put DWARF in the .o files"
197
- echo "bootstrap: and build.sh already linked with -Wl,-x."
198
- else
199
- echo "bootstrap: No llvm-objcopy, objcopy or strip on PATH could strip either file, so"
200
- echo "bootstrap: that half of the comparison did not run."
201
- fi
202
- echo "bootstrap:"
203
- echo "bootstrap: This difference is UNATTRIBUTED. It is a failure rather than a warning,"
204
- echo "bootstrap: because the alternative accepts a stage3 that is a different compiler."
205
- echo "bootstrap: The one thing ld64 was measured to vary here is LC_UUID -- and on arm64"
206
- echo "bootstrap: the code-directory slot that hashes the page it sits on. It was stable"
207
- echo "bootstrap: across two links to one path, which is why scripts/bootstrap.sh links"
208
- echo "bootstrap: every comparable stage at one path, and that was measured to hold end to"
209
- echo "bootstrap: end. So either these two were not built that way, which \`otool -l\` will"
210
- echo "bootstrap: show by disagreeing about the uuid, or ld64 is varying something new."
211
- echo "bootstrap: Attribute the differing bytes before changing anything, the way the"
212
- echo "bootstrap: first measurement was made (docs/wp10-ci.md#ci-matrix)."
213
- } >&2
214
- exit 1