bitboss-ui 3.0.0-beta.73 → 3.0.0-beta.74
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 +4 -2
- package/bin/bitboss-ui-mcp.mjs +101 -3
- package/bin/bitboss-ui.mjs +6 -1
- package/bin/cli.mjs +31 -5
- package/dist/ai/BbBadge.md +4 -4
- package/dist/ai/BbCalendar.md +4 -3
- package/dist/ai/BbColorPalette.md +8 -9
- package/dist/ai/BbConfirmPortal.md +1 -1
- package/dist/ai/BbDatePicker.md +4 -3
- package/dist/ai/BbDialog.md +14 -4
- package/dist/ai/BbDropdown.md +23 -10
- package/dist/ai/BbDropdownButton.md +2 -2
- package/dist/ai/BbForm.md +4 -1
- package/dist/ai/BbHoverCardPortal.md +1 -1
- package/dist/ai/BbNumberInput.md +5 -3
- package/dist/ai/BbPopoverPortal.md +1 -1
- package/dist/ai/BbTable.md +43 -19
- package/dist/ai/BbTimePicker.md +4 -3
- package/dist/ai/BbToastPortal.md +1 -1
- package/dist/ai/changelog.json +56 -4
- package/dist/ai/components.json +54 -18
- package/dist/ai/guides/design-tokens.md +20 -0
- package/dist/ai/guides/eslint-rules.md +1 -1
- package/dist/ai/guides/inertia-helpers.md +613 -53
- package/dist/ai/guides/migration/adoption-checklist.md +5 -5
- package/dist/ai/guides/migration/v2-to-v3.md +24 -0
- package/dist/ai/guides/migration/v3-beta-tooling.md +3 -0
- package/dist/ai/guides/preset-components.md +15 -2
- package/dist/ai/guides/reporting.md +49 -0
- package/dist/ai/helpers/inertia/manifest.json +33 -38
- package/dist/ai/helpers/inertia/useHasChanged.ts +25 -37
- package/dist/ai/helpers/inertia/useQuery.ts +24 -6
- package/dist/ai/helpers/inertia/utils.ts +552 -3
- package/dist/ai/index.md +1 -0
- package/dist/ai/manifest/components/BbAlert.tree.json +1 -1
- package/dist/ai/manifest/components/BbCalendar.json +2 -2
- package/dist/ai/manifest/components/BbColorPalette.json +3 -3
- package/dist/ai/manifest/components/BbConfirmPortal.json +1 -1
- package/dist/ai/manifest/components/BbDatePicker.json +3 -3
- package/dist/ai/manifest/components/BbDialog.tree.json +5 -1
- package/dist/ai/manifest/components/BbDropdown.json +3 -3
- package/dist/ai/manifest/components/BbDropdown.tree.json +3 -2
- package/dist/ai/manifest/components/BbDropdownButton.json +2 -2
- package/dist/ai/manifest/components/BbForm.json +1 -1
- package/dist/ai/manifest/components/BbHoverCard.json +1 -1
- package/dist/ai/manifest/components/BbHoverCardPortal.json +1 -1
- package/dist/ai/manifest/components/BbNumberInput.json +1 -1
- package/dist/ai/manifest/components/BbPopover.json +1 -1
- package/dist/ai/manifest/components/BbPopoverPortal.json +1 -1
- package/dist/ai/manifest/components/BbSelectPopover.json +1 -1
- package/dist/ai/manifest/components/BbTable.tree.json +12 -6
- package/dist/ai/manifest/components/BbTimePicker.json +3 -3
- package/dist/ai/manifest/components/BbToastPortal.json +1 -1
- package/dist/ai/manifest/components/CommonPopover.json +1 -1
- package/dist/ai/manifest/index.json +2 -2
- package/dist/ai/manifest/meta.json +36 -0
- package/dist/ai/manifest/types.advanced.json +81 -80
- package/dist/ai/manifest/types.api.json +66 -65
- package/dist/ai/manifest/types.wrapper.json +155 -118
- package/dist/ai/recipes/inertia/layout-scaffold.md +3 -1
- package/dist/ai/recipes/nuxt/layout-scaffold.md +3 -1
- package/dist/ai/recipes/vue/layout-scaffold.md +3 -1
- package/dist/ai/source/BbAlert.md +16 -4
- package/dist/ai/source/BbAvatar.md +2 -0
- package/dist/ai/source/BbBreadcrumbs.md +4 -1
- package/dist/ai/source/BbCalendar.md +22 -12
- package/dist/ai/source/BbColorPalette.md +41 -12
- package/dist/ai/source/BbConfirm.md +7 -0
- package/dist/ai/source/BbConfirmPortal.md +9 -4
- package/dist/ai/source/BbDatePicker.md +53 -22
- package/dist/ai/source/BbDatePickerInput.md +32 -8
- package/dist/ai/source/BbDialog.md +31 -1
- package/dist/ai/source/BbDropdown.md +52 -24
- package/dist/ai/source/BbDropdownGroup.md +17 -21
- package/dist/ai/source/BbForm.md +73 -6
- package/dist/ai/source/BbHoverCard.md +7 -0
- package/dist/ai/source/BbHoverCardPortal.md +9 -5
- package/dist/ai/source/BbNumberInput.md +5 -6
- package/dist/ai/source/BbOffCanvas.md +34 -1
- package/dist/ai/source/BbPopover.md +7 -0
- package/dist/ai/source/BbPopoverPortal.md +9 -5
- package/dist/ai/source/BbRadio.md +4 -3
- package/dist/ai/source/BbRadioGroup.md +7 -5
- package/dist/ai/source/BbTable.md +54 -6
- package/dist/ai/source/BbTag.md +10 -3
- package/dist/ai/source/BbTimePicker.md +50 -15
- package/dist/ai/source/BbTimePickerInput.md +30 -7
- package/dist/ai/source/BbToast.md +14 -0
- package/dist/ai/source/BbToastPortal.md +16 -4
- package/dist/ai/source/CommonFieldInput.md +11 -5
- package/dist/ai/source/CommonPopover.md +4 -1
- package/dist/components/BbAlert/BbAlert.vue_vue_type_script_setup_true_lang.js +31 -26
- package/dist/components/BbBreadcrumbs/BbBreadcrumbs.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/BbCalendar/BbCalendar.vue.d.ts +1 -1
- package/dist/components/BbCalendar/BbCalendar.vue_vue_type_script_setup_true_lang.js +235 -234
- package/dist/components/BbCalendar/types.d.ts +2 -2
- package/dist/components/BbCalendar/useDayjsLocale.js +11 -8
- package/dist/components/BbColorPalette/BbColorPalette.vue_vue_type_script_setup_true_lang.js +197 -192
- package/dist/components/BbColorPalette/types.d.ts +1 -1
- package/dist/components/BbConfirm/BbConfirmPortal.vue.d.ts +2 -4
- package/dist/components/BbConfirm/types.d.ts +5 -0
- package/dist/components/BbDatePicker/BbDatePicker.vue.d.ts +1 -1
- package/dist/components/BbDatePicker/BbDatePicker.vue_vue_type_script_setup_true_lang.js +145 -139
- package/dist/components/BbDatePicker/types.d.ts +2 -2
- package/dist/components/BbDatePickerInput/BbDatePickerInput.vue_vue_type_script_setup_true_lang.js +337 -335
- package/dist/components/BbDialog/BbDialog.vue_vue_type_script_setup_true_lang.js +253 -245
- package/dist/components/BbDialog/leaveGhost.js +33 -0
- package/dist/components/BbDialog/overlayActions.js +34 -20
- package/dist/components/BbDropdown/BbDropdown.vue_vue_type_script_setup_true_lang.js +11 -3
- package/dist/components/BbDropdown/BbDropdownList.vue_vue_type_script_setup_true_lang.js +4 -4
- package/dist/components/BbDropdown/DropdownPipelineResolver.vue_vue_type_script_setup_true_lang.js +119 -120
- package/dist/components/BbDropdown/types.d.ts +8 -17
- package/dist/components/BbForm/BbForm.vue.d.ts +2 -21
- package/dist/components/BbForm/BbForm.vue_vue_type_script_setup_true_lang.js +229 -227
- package/dist/components/BbForm/types.d.ts +31 -0
- package/dist/components/BbHoverCard/BbHoverCardPortal.vue.d.ts +2 -5
- package/dist/components/BbHoverCard/types.d.ts +5 -0
- package/dist/components/BbNumberInput/BbNumberInput.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/BbNumberInput/numberDisplay.js +102 -106
- package/dist/components/BbNumberInput/types.d.ts +4 -3
- package/dist/components/BbOffCanvas/BbOffCanvas.vue_vue_type_script_setup_true_lang.js +385 -377
- package/dist/components/BbPopover/BbPopoverPortal.vue.d.ts +2 -5
- package/dist/components/BbPopover/types.d.ts +5 -0
- package/dist/components/BbRadio/types.d.ts +4 -3
- package/dist/components/BbRadioGroup/BbRadioGroup.vue_vue_type_script_setup_true_lang.js +10 -12
- package/dist/components/BbTable/BbTable.vue_vue_type_script_setup_true_lang.js +231 -231
- package/dist/components/BbTable/BbTableDataRow.js +96 -96
- package/dist/components/BbTag/BbTag.vue_vue_type_script_setup_true_lang.js +9 -3
- package/dist/components/BbTimePicker/BbTimePicker.vue.d.ts +1 -1
- package/dist/components/BbTimePicker/BbTimePicker.vue_vue_type_script_setup_true_lang.js +106 -100
- package/dist/components/BbTimePicker/types.d.ts +2 -2
- package/dist/components/BbTimePickerInput/BbTimePickerInput.vue_vue_type_script_setup_true_lang.js +214 -213
- package/dist/components/BbToast/BbToastPortal.vue.d.ts +2 -4
- package/dist/components/BbToast/types.d.ts +5 -0
- package/dist/components/CommonFieldInput/CommonFieldInput.vue_vue_type_script_setup_true_lang.js +36 -36
- package/dist/components/CommonPopover/CommonPopover.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/CommonTimeSelector/useMeridiem.js +6 -6
- package/dist/composables/formSubmitLock.js +2 -1
- package/dist/composables/overlayRegistry.js +52 -42
- package/dist/composables/useActiveInactiveState.js +8 -4
- package/dist/composables/useBbDialog.js +5 -5
- package/dist/composables/useOwnModel.js +16 -0
- package/dist/composables/useSegmentedFields.js +31 -20
- package/dist/i18n/currencyDigits.js +58 -0
- package/dist/i18n/regionDates.js +250 -0
- package/dist/i18n/regionHints.js +30 -41
- package/dist/index.d.ts +34 -30
- package/dist/llms-full.txt +860 -129
- package/dist/llms.txt +3 -1
- package/dist/styles.css +2 -2
- package/dist/types/ActionButton.d.ts +3 -1
- package/dist/types/CommonProps.d.ts +8 -0
- package/dist/utilities/functions/hash.js +97 -64
- package/dist/utilities/functions/isEqual.js +33 -25
- package/dist/utils/versionCheck.js +1 -1
- package/dist/vite-plugin.d.ts +2 -1
- package/dist/vite.js +8 -4
- package/llms.txt +3 -1
- package/package.json +1 -2
- package/scripts/README.md +1 -1
- package/scripts/lib/adoption-checklist.json +6 -5
- package/scripts/lib/agent-manifest.mjs +33 -6
- package/scripts/lib/agent-setup.mjs +54 -6
- package/scripts/lib/cldr-pins.ts +182 -0
- package/scripts/lib/engines-include.d.mts +5 -0
- package/scripts/lib/engines-include.mjs +40 -0
- package/scripts/lib/eslint-plugin.mjs +8 -2
- package/scripts/lib/hidden-label-placeholder.mjs +25 -5
- package/scripts/lib/idiom-scan.mjs +30 -3
- package/scripts/lib/legacy-agent-files.json +152 -0
- package/scripts/lib/mcp-config.mjs +74 -7
- package/scripts/lib/portal-names.mjs +78 -8
- package/scripts/lib/release-results.mjs +5 -2
- package/scripts/lib/report.mjs +340 -0
- package/scripts/lib/run-beat.mjs +14 -0
- package/scripts/lib/run-records.mjs +313 -0
- package/scripts/lib/selector-log.mjs +98 -0
- package/scripts/lib/ticket-beat.mjs +30 -0
- package/scripts/lib/validate-bb-markup.mjs +17 -2
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The run log: what every gate, wall and release run spent its time on,
|
|
3
|
+
* written as it happens, for the measurement that prices the test suite.
|
|
4
|
+
* Nothing here changes what a run does; every write is best-effort and never
|
|
5
|
+
* throws into the run it records.
|
|
6
|
+
*
|
|
7
|
+
* ONE FILE, beside the wall histories:
|
|
8
|
+
* <git-common-dir>/bb-gate/results/runs.jsonl (BB_RESULTS_DIR moves it)
|
|
9
|
+
* one JSON line per event, each with `runId` and `at` (ISO). The history
|
|
10
|
+
* record a run writes at its end carries the same `runId`. Lines:
|
|
11
|
+
* start { kind, mode, sha, pid, cwd, load1, memMB }
|
|
12
|
+
* the run began. A start without its history record (or without an
|
|
13
|
+
* `end`) is a run that was killed: those write no history.
|
|
14
|
+
* beat { load1, memMB } every BEAT_MS while the run lives
|
|
15
|
+
* gone { } the run's process died without writing `end`
|
|
16
|
+
* end { ok, seconds }
|
|
17
|
+
* files { step, where, attempt, exit, killed?, ms, before, after, files }
|
|
18
|
+
* one vitest invocation: `files` is [path, ms, status] per test
|
|
19
|
+
* file, from Vitest's JSON report (`ms` = endTime − startTime);
|
|
20
|
+
* `before` / `after` are { load1, memMB } samples around it
|
|
21
|
+
* wait { step?, lock, label, ms, reason } time spent waiting for a
|
|
22
|
+
* machine-wide lock: 'browser-tier', 'memory', 'memory-pause',
|
|
23
|
+
* 'timing-window' (another run's timing files hold it), 'timing-claim'
|
|
24
|
+
* (taking it), 'browser-drain' (other browser runs finishing)
|
|
25
|
+
*
|
|
26
|
+
* HOW IT REACHES THE RUNNERS: the top-level run (gate.mjs, release-check.mjs,
|
|
27
|
+
* release-local.mjs) calls startRun(), which exports BB_RUN_ID and
|
|
28
|
+
* BB_RUN_LOG; each step's environment adds BB_RUN_STEP (its name, nested
|
|
29
|
+
* with ` › ` under release:local). Every vitest runner and every Vitest
|
|
30
|
+
* process below inherits them and appends with recordRun(). A run started
|
|
31
|
+
* inside another (release:check under release:local) joins the outer run.
|
|
32
|
+
* Without BB_RUN_LOG (CI, a direct `npx vitest`), nothing is written.
|
|
33
|
+
*
|
|
34
|
+
* THE HEARTBEAT is a small detached process (run-beat.mjs): the gates run
|
|
35
|
+
* their steps with spawnSync, which blocks the parent's own timers.
|
|
36
|
+
*/
|
|
37
|
+
import { spawn } from 'node:child_process';
|
|
38
|
+
import { randomBytes } from 'node:crypto';
|
|
39
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync } from 'node:fs';
|
|
40
|
+
import os from 'node:os';
|
|
41
|
+
import path from 'node:path';
|
|
42
|
+
import { fileURLToPath } from 'node:url';
|
|
43
|
+
import { memorySignal } from './heavy-admission.mjs';
|
|
44
|
+
|
|
45
|
+
export const RUN_ID_ENV = 'BB_RUN_ID';
|
|
46
|
+
export const RUN_LOG_ENV = 'BB_RUN_LOG';
|
|
47
|
+
export const RUN_STEP_ENV = 'BB_RUN_STEP';
|
|
48
|
+
export const RUN_LOG_NAME = 'runs.jsonl';
|
|
49
|
+
export const BEAT_MS = 30_000;
|
|
50
|
+
|
|
51
|
+
/** { load1, memMB }: the 1-minute load average and the memory available. */
|
|
52
|
+
export function machineSample({
|
|
53
|
+
loadavg = os.loadavg,
|
|
54
|
+
signal = () => memorySignal(),
|
|
55
|
+
} = {}) {
|
|
56
|
+
let memMB = null;
|
|
57
|
+
try {
|
|
58
|
+
memMB = signal()?.availableMB ?? null;
|
|
59
|
+
} catch {
|
|
60
|
+
memMB = null;
|
|
61
|
+
}
|
|
62
|
+
return { load1: Math.round(loadavg()[0] * 100) / 100, memMB };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Append one line to the run log (no-op outside a recorded run). The step
|
|
67
|
+
* comes from BB_RUN_STEP unless the line names one.
|
|
68
|
+
*/
|
|
69
|
+
export function recordRun(line, env = process.env) {
|
|
70
|
+
const log = env[RUN_LOG_ENV];
|
|
71
|
+
const runId = env[RUN_ID_ENV];
|
|
72
|
+
if (!log || !runId) return;
|
|
73
|
+
const step = env[RUN_STEP_ENV];
|
|
74
|
+
try {
|
|
75
|
+
appendFileSync(
|
|
76
|
+
log,
|
|
77
|
+
`${JSON.stringify({
|
|
78
|
+
runId,
|
|
79
|
+
at: new Date().toISOString(),
|
|
80
|
+
...(step ? { step } : {}),
|
|
81
|
+
...line,
|
|
82
|
+
})}\n`
|
|
83
|
+
);
|
|
84
|
+
} catch {
|
|
85
|
+
// recording never fails a run
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** A nested step name: `outer › inner`, or `inner` at the top. */
|
|
90
|
+
export const stepName = (name, env = process.env) =>
|
|
91
|
+
env[RUN_STEP_ENV] ? `${env[RUN_STEP_ENV]} › ${name}` : name;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Per-file [path, ms, status] from a Vitest JSON report, paths relative to
|
|
95
|
+
* `cwd`; [] when there is no readable report (a crash, a kill).
|
|
96
|
+
*/
|
|
97
|
+
export function fileTimes(jsonPath, cwd = process.cwd()) {
|
|
98
|
+
if (!jsonPath || !existsSync(jsonPath)) return [];
|
|
99
|
+
try {
|
|
100
|
+
const report = JSON.parse(readFileSync(jsonPath, 'utf8'));
|
|
101
|
+
return (report?.testResults ?? []).map((r) => [
|
|
102
|
+
path.relative(cwd, r.name),
|
|
103
|
+
Number.isFinite(r.endTime - r.startTime)
|
|
104
|
+
? Math.round(r.endTime - r.startTime)
|
|
105
|
+
: null,
|
|
106
|
+
r.status,
|
|
107
|
+
]);
|
|
108
|
+
} catch {
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Record one vitest invocation: call `begin()` before it and the returned
|
|
115
|
+
* function after it, with its report.
|
|
116
|
+
*/
|
|
117
|
+
export function recordFiles({
|
|
118
|
+
where,
|
|
119
|
+
attempt = 1,
|
|
120
|
+
env = process.env,
|
|
121
|
+
sample = machineSample,
|
|
122
|
+
now = Date.now,
|
|
123
|
+
}) {
|
|
124
|
+
if (!env[RUN_LOG_ENV]) return () => {};
|
|
125
|
+
const before = sample();
|
|
126
|
+
const start = now();
|
|
127
|
+
return ({ report, exit = null, killed = false, cwd = process.cwd() }) =>
|
|
128
|
+
recordRun(
|
|
129
|
+
{
|
|
130
|
+
type: 'files',
|
|
131
|
+
where,
|
|
132
|
+
attempt,
|
|
133
|
+
exit,
|
|
134
|
+
...(killed ? { killed: true } : {}),
|
|
135
|
+
ms: now() - start,
|
|
136
|
+
before,
|
|
137
|
+
after: sample(),
|
|
138
|
+
files: fileTimes(report, cwd),
|
|
139
|
+
},
|
|
140
|
+
env
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Record a wait for a machine-wide lock, from what the waiting function
|
|
146
|
+
* returned. Nothing for a lock that was skipped (off, CI) or already held
|
|
147
|
+
* by the run; `always: false` drops a zero wait (the per-chunk pause).
|
|
148
|
+
*/
|
|
149
|
+
export function recordWait(
|
|
150
|
+
lock,
|
|
151
|
+
label,
|
|
152
|
+
result,
|
|
153
|
+
{ env = process.env, always = true } = {}
|
|
154
|
+
) {
|
|
155
|
+
if (!result || result.skipped || result.nested || result.inside) return;
|
|
156
|
+
const ms = result.waitedMs ?? 0;
|
|
157
|
+
if (!always && ms <= 0) return;
|
|
158
|
+
recordRun(
|
|
159
|
+
{
|
|
160
|
+
type: 'wait',
|
|
161
|
+
lock,
|
|
162
|
+
label,
|
|
163
|
+
ms,
|
|
164
|
+
reason: result.reason ?? null,
|
|
165
|
+
...(result.gaveUp ? { gaveUp: true } : {}),
|
|
166
|
+
},
|
|
167
|
+
env
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** The run log's path in a results directory. */
|
|
172
|
+
export const runLogPath = (dir) => path.join(dir, RUN_LOG_NAME);
|
|
173
|
+
|
|
174
|
+
const BEAT_SCRIPT = path.join(
|
|
175
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
176
|
+
'run-beat.mjs'
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Open a recorded run: write its `start` line, export BB_RUN_ID / BB_RUN_LOG
|
|
181
|
+
* into `env` (its children inherit them) and start the heartbeat. Inside a
|
|
182
|
+
* run that is already recorded (BB_RUN_ID set), joins it: no new start line.
|
|
183
|
+
* Returns { runId, nested, end({ ok, seconds }) }.
|
|
184
|
+
*/
|
|
185
|
+
export function startRun({
|
|
186
|
+
kind,
|
|
187
|
+
mode = null,
|
|
188
|
+
sha = null,
|
|
189
|
+
dir,
|
|
190
|
+
env = process.env,
|
|
191
|
+
pid = process.pid,
|
|
192
|
+
cwd = process.cwd(),
|
|
193
|
+
beat = (log, runId) => {
|
|
194
|
+
const child = spawn(
|
|
195
|
+
process.execPath,
|
|
196
|
+
[BEAT_SCRIPT, log, runId, String(pid)],
|
|
197
|
+
{ detached: true, stdio: 'ignore' }
|
|
198
|
+
);
|
|
199
|
+
child.unref();
|
|
200
|
+
return () => {
|
|
201
|
+
try {
|
|
202
|
+
child.kill();
|
|
203
|
+
} catch {
|
|
204
|
+
// already gone
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
},
|
|
208
|
+
sample = machineSample,
|
|
209
|
+
}) {
|
|
210
|
+
if (env[RUN_ID_ENV] && env[RUN_LOG_ENV])
|
|
211
|
+
return { runId: env[RUN_ID_ENV], nested: true, end() {} };
|
|
212
|
+
const runId = `${kind}-${Date.now().toString(36)}-${randomBytes(3).toString('hex')}`;
|
|
213
|
+
let log;
|
|
214
|
+
try {
|
|
215
|
+
mkdirSync(dir, { recursive: true });
|
|
216
|
+
log = runLogPath(dir);
|
|
217
|
+
} catch {
|
|
218
|
+
return { runId, nested: false, end() {} };
|
|
219
|
+
}
|
|
220
|
+
env[RUN_ID_ENV] = runId;
|
|
221
|
+
env[RUN_LOG_ENV] = log;
|
|
222
|
+
const top = { ...env, [RUN_STEP_ENV]: '' };
|
|
223
|
+
recordRun({ type: 'start', kind, mode, sha, pid, cwd, ...sample() }, top);
|
|
224
|
+
let stop = () => {};
|
|
225
|
+
try {
|
|
226
|
+
stop = beat(log, runId);
|
|
227
|
+
} catch {
|
|
228
|
+
// no heartbeat: the start and end lines still bound the run
|
|
229
|
+
}
|
|
230
|
+
let ended = false;
|
|
231
|
+
return {
|
|
232
|
+
runId,
|
|
233
|
+
nested: false,
|
|
234
|
+
end({ ok, seconds }) {
|
|
235
|
+
if (ended) return;
|
|
236
|
+
ended = true;
|
|
237
|
+
stop();
|
|
238
|
+
recordRun({ type: 'end', ok, seconds }, top);
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const parentAlive = (pid) => {
|
|
244
|
+
try {
|
|
245
|
+
process.kill(pid, 0);
|
|
246
|
+
return true;
|
|
247
|
+
} catch (e) {
|
|
248
|
+
return e.code === 'EPERM';
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* The heartbeat loop (run-beat.mjs): every `checkMs` look at the parent;
|
|
254
|
+
* every `beatMs` append a `beat` sample; once the parent is gone append
|
|
255
|
+
* `gone` and stop. Returns the stop function.
|
|
256
|
+
*/
|
|
257
|
+
export function beatLoop({
|
|
258
|
+
env,
|
|
259
|
+
pid,
|
|
260
|
+
alive = parentAlive,
|
|
261
|
+
sample = machineSample,
|
|
262
|
+
checkMs = 5_000,
|
|
263
|
+
beatMs = BEAT_MS,
|
|
264
|
+
every = setInterval,
|
|
265
|
+
cancel = clearInterval,
|
|
266
|
+
}) {
|
|
267
|
+
let since = 0;
|
|
268
|
+
const timer = every(() => {
|
|
269
|
+
if (!alive(pid)) {
|
|
270
|
+
recordRun({ type: 'gone' }, env);
|
|
271
|
+
cancel(timer);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
since += checkMs;
|
|
275
|
+
if (since < beatMs) return;
|
|
276
|
+
since = 0;
|
|
277
|
+
recordRun({ type: 'beat', ...sample() }, env);
|
|
278
|
+
}, checkMs);
|
|
279
|
+
return () => cancel(timer);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** Every line of a run log, oldest first (torn lines skipped). */
|
|
283
|
+
export function readRunLog(dir) {
|
|
284
|
+
const file = runLogPath(dir);
|
|
285
|
+
if (!existsSync(file)) return [];
|
|
286
|
+
return readFileSync(file, 'utf8')
|
|
287
|
+
.split('\n')
|
|
288
|
+
.filter(Boolean)
|
|
289
|
+
.flatMap((line) => {
|
|
290
|
+
try {
|
|
291
|
+
return [JSON.parse(line)];
|
|
292
|
+
} catch {
|
|
293
|
+
return [];
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Waits by lock over `lines` (from readRunLog) at or after `since`:
|
|
300
|
+
* [{ lock, count, ms, max }], the most waited first.
|
|
301
|
+
*/
|
|
302
|
+
export function waitsByLock(lines, { since } = {}) {
|
|
303
|
+
const by = new Map();
|
|
304
|
+
for (const l of lines) {
|
|
305
|
+
if (l.type !== 'wait' || (since && l.at < since)) continue;
|
|
306
|
+
const e = by.get(l.lock) ?? { lock: l.lock, count: 0, ms: 0, max: 0 };
|
|
307
|
+
e.count += 1;
|
|
308
|
+
e.ms += l.ms ?? 0;
|
|
309
|
+
e.max = Math.max(e.max, l.ms ?? 0);
|
|
310
|
+
by.set(l.lock, e);
|
|
311
|
+
}
|
|
312
|
+
return [...by.values()].sort((a, b) => b.ms - a.ms);
|
|
313
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The selector log: what the reverse selector would pick for
|
|
3
|
+
* this tree, recorded on every gate next to the scope the gate really used.
|
|
4
|
+
* Logging only: nothing reads it for a verdict.
|
|
5
|
+
*
|
|
6
|
+
* The selector measures from the lane's FORK POINT (the merge-base with v3),
|
|
7
|
+
* not from the last full pass the scoped gate measures from, and records the
|
|
8
|
+
* module graph's pick at HEAD together with the reasons today's rules would
|
|
9
|
+
* widen it. So a record answers "how many browser files does this lane
|
|
10
|
+
* really reach, and which rule turns that into the full tier?".
|
|
11
|
+
*
|
|
12
|
+
* Record shape (the gate history's `selector` field):
|
|
13
|
+
* v SELECTOR_LOG_VERSION
|
|
14
|
+
* base fork-point sha, or null
|
|
15
|
+
* changed number of changed paths since the fork point (working copy)
|
|
16
|
+
* class changeClass(changed): 'src' | 'test' | 'scripts' | 'other'
|
|
17
|
+
* pre { kind, reasons }: classifyChange, recorded, not applied
|
|
18
|
+
* everything true when the graph alone already means the full tier
|
|
19
|
+
* why the graph's reasons for that (planBrowserScope), [] if none
|
|
20
|
+
* affected the browser test files the graph picks (sorted)
|
|
21
|
+
* files affected.length
|
|
22
|
+
* guides how many of them are guide tests
|
|
23
|
+
* timing how many are time-sensitive files
|
|
24
|
+
* chunks chunks those files touch (folder-packed, as the runner packs)
|
|
25
|
+
* totalChunks chunks in the full run
|
|
26
|
+
* listing browser test files at HEAD
|
|
27
|
+
* graphMs wall milliseconds of the whole selector run
|
|
28
|
+
* cpuMs CPU milliseconds of its graph process (user + system), null
|
|
29
|
+
* when unknown
|
|
30
|
+
* nice the CPU priority offset the graph process ran at
|
|
31
|
+
* error set instead of the pick when the selector could not run
|
|
32
|
+
*/
|
|
33
|
+
import { changeClass, isTimingFile } from './scope-plan.mjs';
|
|
34
|
+
|
|
35
|
+
export const SELECTOR_LOG_VERSION = 1;
|
|
36
|
+
|
|
37
|
+
/** The graph process runs this much below normal CPU priority. */
|
|
38
|
+
export const SELECTOR_NICE = 10;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Facts → one record. `plan` is planBrowserScope's result over the HEAD
|
|
42
|
+
* graph alone; `chunks` the full run's chunk plan; `listing` HEAD's browser
|
|
43
|
+
* test files.
|
|
44
|
+
*/
|
|
45
|
+
export function selectorRecord({
|
|
46
|
+
base = null,
|
|
47
|
+
changed = [],
|
|
48
|
+
pre = null,
|
|
49
|
+
plan = null,
|
|
50
|
+
chunks = [],
|
|
51
|
+
listing = [],
|
|
52
|
+
graphMs = 0,
|
|
53
|
+
cpuMs = null,
|
|
54
|
+
nice = 0,
|
|
55
|
+
error = null,
|
|
56
|
+
}) {
|
|
57
|
+
const head = {
|
|
58
|
+
v: SELECTOR_LOG_VERSION,
|
|
59
|
+
base,
|
|
60
|
+
changed: changed.length,
|
|
61
|
+
class: changeClass(changed),
|
|
62
|
+
pre: pre ? { kind: pre.kind, reasons: pre.reasons } : null,
|
|
63
|
+
};
|
|
64
|
+
if (error || !plan)
|
|
65
|
+
return { ...head, error: error ?? 'no plan', graphMs, cpuMs, nice };
|
|
66
|
+
const affected = [...plan.affected].sort();
|
|
67
|
+
const picked = new Set(affected);
|
|
68
|
+
return {
|
|
69
|
+
...head,
|
|
70
|
+
everything: plan.reasons.length > 0,
|
|
71
|
+
why: plan.reasons,
|
|
72
|
+
affected,
|
|
73
|
+
files: affected.length,
|
|
74
|
+
guides: affected.filter((f) => f.endsWith('.guide.test.ts')).length,
|
|
75
|
+
timing: affected.filter(isTimingFile).length,
|
|
76
|
+
chunks: chunks.filter((c) => c.some((f) => picked.has(f))).length,
|
|
77
|
+
totalChunks: chunks.length,
|
|
78
|
+
listing: listing.length,
|
|
79
|
+
graphMs,
|
|
80
|
+
cpuMs,
|
|
81
|
+
nice,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** One line for the gate's summary. */
|
|
86
|
+
export function describeSelector(r) {
|
|
87
|
+
const at = String(r.base ?? '—').slice(0, 10);
|
|
88
|
+
const cpu = r.cpuMs == null ? '' : `, ${(r.cpuMs / 1000).toFixed(1)}s CPU`;
|
|
89
|
+
const secs = `${(r.graphMs / 1000).toFixed(1)}s${cpu}`;
|
|
90
|
+
if (r.error)
|
|
91
|
+
return `selector (log only): not computed from fork point ${at} — ${r.error} (${secs})`;
|
|
92
|
+
const pre = r.pre ? `; today's rules: ${r.pre.kind}` : '';
|
|
93
|
+
const why = r.everything ? `; FULL by the graph: ${r.why.join('; ')}` : '';
|
|
94
|
+
return (
|
|
95
|
+
`selector (log only): ${r.files} of ${r.listing} browser file(s) in ${r.chunks} of ${r.totalChunks} chunk(s) ` +
|
|
96
|
+
`from fork point ${at}, ${r.changed} changed (${r.class})${pre}${why} (${secs})`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The heartbeat of one memory-ledger ticket (heavy-admission.mjs
|
|
3
|
+
* ticketHeartbeat), as its own detached process: the ticket's holder runs
|
|
4
|
+
* vitest with spawnSync, which stalls its timers for a whole chunk. Every
|
|
5
|
+
* `everyMs` it touches the ticket file; it stops once the holder's pid is
|
|
6
|
+
* gone or the ticket file is (released, or reaped).
|
|
7
|
+
*
|
|
8
|
+
* Usage: node scripts/lib/ticket-beat.mjs <ticket file> <holder pid> <everyMs>
|
|
9
|
+
*/
|
|
10
|
+
import { utimesSync } from 'node:fs';
|
|
11
|
+
|
|
12
|
+
const [file, pid, everyMs] = process.argv.slice(2);
|
|
13
|
+
const alive = () => {
|
|
14
|
+
try {
|
|
15
|
+
process.kill(Number(pid), 0);
|
|
16
|
+
return true;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return e.code === 'EPERM';
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const timer = setInterval(() => {
|
|
22
|
+
try {
|
|
23
|
+
if (!alive()) throw new Error('holder gone');
|
|
24
|
+
const t = new Date();
|
|
25
|
+
utimesSync(file, t, t);
|
|
26
|
+
} catch {
|
|
27
|
+
clearInterval(timer);
|
|
28
|
+
}
|
|
29
|
+
}, Number(everyMs));
|
|
30
|
+
process.on('SIGTERM', () => process.exit(0));
|
|
@@ -2585,15 +2585,18 @@ const hasIdentifierBeyond = (root, name, except) => {
|
|
|
2585
2585
|
* fetch replaces, or a typed array whose later rows come from elsewhere, is
|
|
2586
2586
|
* never sealed: no write scan can prove such an array is the final data.
|
|
2587
2587
|
* @param {string} code
|
|
2588
|
-
*
|
|
2588
|
+
* `map.slotKeyed`: the consts whose initializer calls
|
|
2589
|
+
* `slotKey(…)`, a list of slot names already normalized.
|
|
2590
|
+
* @returns {Map<string, any> & { mutated: Set<string>, sealed: Set<string>, slotKeyed: Set<string> }}
|
|
2589
2591
|
*/
|
|
2590
2592
|
export function scriptSetupArrayConsts(code) {
|
|
2591
2593
|
const map =
|
|
2592
|
-
/** @type {Map<string, any> & { mutated: Set<string>, sealed: Set<string> }} */ (
|
|
2594
|
+
/** @type {Map<string, any> & { mutated: Set<string>, sealed: Set<string>, slotKeyed: Set<string> }} */ (
|
|
2593
2595
|
new Map()
|
|
2594
2596
|
);
|
|
2595
2597
|
map.mutated = new Set();
|
|
2596
2598
|
map.sealed = new Set();
|
|
2599
|
+
map.slotKeyed = new Set();
|
|
2597
2600
|
const match = /<script\b[^>]*\bsetup\b[^>]*>([\s\S]*?)<\/script>/i.exec(code);
|
|
2598
2601
|
if (!match) return map;
|
|
2599
2602
|
let program;
|
|
@@ -2618,6 +2621,14 @@ export function scriptSetupArrayConsts(code) {
|
|
|
2618
2621
|
if (decl?.type !== 'VariableDeclaration' || decl.kind !== 'const') continue;
|
|
2619
2622
|
for (const declarator of decl.declarations) {
|
|
2620
2623
|
if (declarator.id.type !== 'Identifier') continue;
|
|
2624
|
+
// a list of slot names built through `slotKey(…)`.
|
|
2625
|
+
if (
|
|
2626
|
+
declarator.init &&
|
|
2627
|
+
/\bslotKey\s*\(/.test(
|
|
2628
|
+
match[1].slice(declarator.init.start, declarator.init.end)
|
|
2629
|
+
)
|
|
2630
|
+
)
|
|
2631
|
+
map.slotKeyed.add(declarator.id.name);
|
|
2621
2632
|
if (
|
|
2622
2633
|
statement.type !== 'ExportNamedDeclaration' &&
|
|
2623
2634
|
!declarator.id.typeAnnotation &&
|
|
@@ -3550,6 +3561,10 @@ export function computedSlotKeyWarning(name, surface, template, arrays) {
|
|
|
3550
3561
|
return null;
|
|
3551
3562
|
const source = /\s(?:in|of)\s+([^]+)$/.exec(loop ?? '')?.[1] ?? '';
|
|
3552
3563
|
if (/\$slots\b|\buseSlots\s*\(|\bslots\b/.test(source)) return null;
|
|
3564
|
+
// `v-for="name in appendSlots" #[name]` over a same-file
|
|
3565
|
+
// const built with `slotKey(…)`: the names are normalized already.
|
|
3566
|
+
const list = /^\s*([A-Za-z_$][\w$]*)(?:\.value)?\s*$/.exec(source)?.[1];
|
|
3567
|
+
if (list && arrays?.slotKeyed?.has(list)) return null;
|
|
3553
3568
|
const compact = (text) => text.replace(/\s+/g, '');
|
|
3554
3569
|
if (forwards.some((f) => compact(f) === compact(slot))) return null;
|
|
3555
3570
|
if (computedSlotKeys(slot, loop, arrays)) return null;
|