rvlib-shipkit 2.11.0 → 2.13.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.
- package/CHANGELOG.md +56 -12
- package/README.md +1 -1
- package/package.json +4 -2
- package/src/agent-time/store.ts +2 -2
- package/src/check.ts +1 -1
- package/src/checks/SK001-package-json-shape.check.ts +4 -0
- package/src/checks/SK003-claude-md-shape.check.ts +1 -1
- package/src/checks/SK004-gitignore-policy.check.ts +27 -2
- package/src/checks/SK005-rvlib-versions.check.ts +1 -1
- package/src/checks/SK008-reviewer-agent.check.ts +2 -2
- package/src/checks/SK012-config-barrel-import.check.ts +1 -1
- package/src/checks/SK015-nested-repo.check.ts +1 -1
- package/src/checks/SK035-public-clean.check.ts +46 -0
- package/src/checks/SK036-draft-media-size.check.ts +28 -0
- package/src/cli/cmd_Backup.ts +152 -0
- package/src/cli/cmd_Ci.ts +8 -11
- package/src/cli/cmd_Drill.ts +145 -0
- package/src/cli/cmd_Home.ts +50 -3
- package/src/cli/cmd_Media.ts +96 -5
- package/src/cli/cmd_Review.ts +8 -2
- package/src/cli/cmd_Shot.ts +5 -2
- package/src/cli/cmd_Smoke.ts +4 -1
- package/src/cli/cmd_Social.ts +226 -0
- package/src/cli/cmd_Start.ts +1 -1
- package/src/cli/cmd_Time.ts +1 -1
- package/src/cli/cmd_Trailer.ts +9 -2
- package/src/cli/cmd_Veille.ts +173 -0
- package/src/cli/family-pages.ts +3 -0
- package/src/cli/registry.ts +13 -2
- package/src/cli.ts +5 -2
- package/src/collections/actions.ts +1 -49
- package/src/collections/checks.ts +2 -1
- package/src/collections/collection-types.ts +11 -2
- package/src/collections/providers.ts +4 -4
- package/src/collections/review.ts +2 -1
- package/src/collections/tests.ts +19 -8
- package/src/contracts/apply-contracts.ts +1 -3
- package/src/contracts/contract-manifests.ts +2 -3
- package/src/contracts/contract-types.ts +0 -1
- package/src/contracts/contracts-engine.ts +0 -3
- package/src/core/app-icon.ts +9 -3
- package/src/core/bun-builtins.ts +2 -2
- package/src/core/discover-checks.ts +37 -5
- package/src/core/fix-scope.ts +4 -2
- package/src/core/floor-resolve.ts +68 -48
- package/src/core/floor.ts +9 -0
- package/src/core/git-root.ts +24 -0
- package/src/core/last-good.ts +3 -1
- package/src/core/layout.ts +8 -0
- package/src/core/log-stamp.ts +36 -0
- package/src/core/loop-watch.ts +93 -0
- package/src/core/machine-link.ts +134 -0
- package/src/core/memory-watch.ts +41 -0
- package/src/core/one-way-in-policy.ts +27 -19
- package/src/core/run-ci.ts +6 -8
- package/src/core/run-fixers.ts +9 -9
- package/src/core/slots.ts +21 -0
- package/src/core/tree-rev.ts +60 -0
- package/src/core/unit-files.ts +42 -0
- package/src/drill/render.ts +140 -0
- package/src/drill/run.ts +269 -0
- package/src/fleet/scan-fleet.ts +6 -5
- package/src/home/daemon-jobs.ts +201 -0
- package/src/home/global-context.ts +34 -1
- package/src/home/home-routes.ts +22 -15
- package/src/home/hubs.ts +10 -3
- package/src/home/inbox-shape.ts +61 -6
- package/src/home/inbox.ts +75 -4
- package/src/home/lib-watch.ts +10 -3
- package/src/home/machine-stores.ts +15 -29
- package/src/home/run-daemon.ts +15 -18
- package/src/home/run-pm.ts +2 -0
- package/src/home/serve-daemon.ts +4 -3
- package/src/home/serve-web.ts +110 -1
- package/src/hooks/commit-message.ts +28 -19
- package/src/hooks/leak-guard.ts +10 -3
- package/src/hooks/run-hooks.ts +2 -6
- package/src/identities/identities.ts +334 -0
- package/src/identities/machine-route.ts +126 -0
- package/src/identities/machine.ts +62 -0
- package/src/init-repo.ts +1 -1
- package/src/ledger/check-stats.ts +10 -9
- package/src/ledger/gate-checks.ts +32 -1
- package/src/ledger/record-kept.ts +112 -0
- package/src/ledger/repo-view.ts +10 -0
- package/src/ledger/run-log.ts +17 -12
- package/src/ledger/run-timeline.ts +8 -4
- package/src/ledger/store.ts +7 -0
- package/src/ledger/suite-log.ts +17 -13
- package/src/media-kinds.ts +9 -1
- package/src/media-store/backup/daemon.ts +73 -0
- package/src/media-store/backup/keys.ts +25 -0
- package/src/media-store/backup/manifest.ts +193 -0
- package/src/media-store/backup/restore.ts +192 -0
- package/src/media-store/backup/run.ts +278 -0
- package/src/media-store/backup/secret.ts +86 -0
- package/src/media-store/backup/snapshot.ts +64 -0
- package/src/media-store/backup/sources.ts +199 -0
- package/src/media-store/content.ts +11 -1
- package/src/media-store/daemon.ts +56 -70
- package/src/media-store/hand.ts +58 -0
- package/src/media-store/put.ts +122 -0
- package/src/media-store/space.ts +73 -11
- package/src/pages/forward.ts +35 -0
- package/src/pages/frame-client.ts +118 -0
- package/src/pages/routes.ts +29 -0
- package/src/pages/unit.ts +92 -0
- package/src/plan/planner.ts +12 -0
- package/src/plan/repo-source.ts +19 -5
- package/src/reflect/transcript.ts +35 -10
- package/src/release/public-clean.ts +301 -0
- package/src/release/published-here.ts +22 -0
- package/src/release/run-bump.ts +2 -1
- package/src/release/run-release.ts +4 -1
- package/src/repo-config.ts +53 -2
- package/src/review/http.ts +16 -2
- package/src/review/media-kind.ts +3 -3
- package/src/review/media-read.ts +3 -3
- package/src/review/model.ts +24 -5
- package/src/review/notes.ts +77 -0
- package/src/review/project.ts +6 -38
- package/src/review/routes.ts +8 -13
- package/src/review/store.ts +46 -4
- package/src/review/trailer-media.ts +24 -3
- package/src/review/trailer-shots.ts +106 -0
- package/src/review/unit.ts +1 -1
- package/src/scaffold/files/agent-handoff.md +3 -0
- package/src/scaffold/files/agent-index.md +4 -12
- package/src/scaffold/project-scaffold.ts +5 -4
- package/src/serve/embed.ts +1 -1
- package/src/serve/hub-app/col-card.tsx +3 -17
- package/src/serve/hub-app/col-tables-view.tsx +2 -1
- package/src/serve/hub-app/cols-svc.ts +12 -14
- package/src/serve/hub-app/dock-st.ts +4 -2
- package/src/serve/hub-app/dock-view.tsx +2 -0
- package/src/serve/hub-app/frames-st.ts +35 -0
- package/src/serve/hub-app/hash-route.ts +64 -1
- package/src/serve/hub-app/home-st.ts +31 -7
- package/src/serve/hub-app/home-strip.css +9 -1
- package/src/serve/hub-app/home-strip.tsx +7 -6
- package/src/serve/hub-app/home.html +5 -0
- package/src/serve/hub-app/hub-app.tsx +49 -5
- package/src/serve/hub-app/hub.css +29 -11
- package/src/serve/hub-app/icons.tsx +16 -1
- package/src/serve/hub-app/identities-st.ts +210 -0
- package/src/serve/hub-app/identities-view.tsx +352 -0
- package/src/serve/hub-app/identities.css +48 -0
- package/src/serve/hub-app/identity-address.ts +52 -0
- package/src/serve/hub-app/inbox-st.ts +59 -6
- package/src/serve/hub-app/inbox-view.tsx +48 -6
- package/src/serve/hub-app/inbox.css +12 -1
- package/src/serve/hub-app/index.html +3 -0
- package/src/serve/hub-app/keys.ts +10 -2
- package/src/serve/hub-app/list-walk.ts +89 -0
- package/src/serve/hub-app/machine-st.ts +12 -0
- package/src/serve/hub-app/media-view.tsx +2 -1
- package/src/serve/hub-app/pages-frames.tsx +134 -0
- package/src/serve/hub-app/pages-svc.ts +111 -0
- package/src/serve/hub-app/palette-st.ts +18 -3
- package/src/serve/hub-app/palette-view.tsx +9 -2
- package/src/serve/hub-app/planned-view.tsx +2 -1
- package/src/serve/hub-app/project-list.css +18 -14
- package/src/serve/hub-app/project-list.tsx +88 -49
- package/src/serve/hub-app/projects-svc.ts +33 -3
- package/src/serve/hub-app/repo-sections.ts +19 -2
- package/src/serve/hub-app/repo-st.ts +75 -19
- package/src/serve/hub-app/review/review-cells.tsx +3 -3
- package/src/serve/hub-app/review/review-kit.ts +30 -7
- package/src/serve/hub-app/review/review-page.tsx +1 -1
- package/src/serve/hub-app/review/review-st.ts +33 -11
- package/src/serve/hub-app/review/review-thread.tsx +11 -9
- package/src/serve/hub-app/review/review-views.tsx +84 -19
- package/src/serve/hub-app/review/thread-st.ts +1 -10
- package/src/serve/hub-app/review/trailer-page.tsx +2 -1
- package/src/serve/hub-app/review.css +17 -8
- package/src/serve/hub-app/site/site-part.tsx +173 -0
- package/src/serve/hub-app/site/site-st.ts +157 -0
- package/src/serve/hub-app/site.css +35 -0
- package/src/serve/hub-app/social/calendar.tsx +182 -0
- package/src/serve/hub-app/social/comms-page.tsx +306 -0
- package/src/serve/hub-app/social/kit.tsx +244 -0
- package/src/serve/hub-app/social/post-card.tsx +456 -0
- package/src/serve/hub-app/social/problems.tsx +60 -0
- package/src/serve/hub-app/social/social-model.ts +154 -0
- package/src/serve/hub-app/social/social-page.tsx +674 -0
- package/src/serve/hub-app/social/social-st.ts +986 -0
- package/src/serve/hub-app/social.css +289 -0
- package/src/serve/hub-app/stores/stores-page.tsx +311 -0
- package/src/serve/hub-app/stores/stores-st.ts +286 -0
- package/src/serve/hub-app/stores.css +54 -0
- package/src/serve/hub-app/test-view.tsx +9 -2
- package/src/serve/hub-app/tests-svc.ts +16 -1
- package/src/serve/hub-app/timeline-geometry.ts +1 -1
- package/src/serve/hub-app/timeline-view.tsx +3 -2
- package/src/serve/hub-app/tree-build.ts +6 -0
- package/src/serve/hub-app/tree-row.tsx +27 -4
- package/src/serve/hub-app/tree-svc.ts +18 -49
- package/src/serve/hub-app/veille/veille-page.tsx +514 -0
- package/src/serve/hub-app/veille/veille-st.ts +443 -0
- package/src/serve/hub-app/veille.css +84 -0
- package/src/serve/hub-runtime.ts +14 -9
- package/src/serve/project-gutter-route.ts +44 -12
- package/src/serve/resources-wire.ts +48 -0
- package/src/serve/run-lanes.ts +7 -4
- package/src/serve/same-origin.ts +1 -1
- package/src/serve/serve-hub.ts +27 -18
- package/src/serve/tracked-watch.ts +24 -3
- package/src/serve/warm-cell.ts +5 -1
- package/src/shipkit-files.ts +15 -4
- package/src/shipkit.ts +0 -1
- package/src/shot/box.ts +162 -0
- package/src/shot/browser-slot.ts +62 -0
- package/src/shot/client.ts +43 -7
- package/src/shot/clip-encoder.ts +93 -12
- package/src/shot/film-box.ts +188 -0
- package/src/shot/shooter.ts +50 -15
- package/src/shot/shot-ask.ts +10 -2
- package/src/shot/stepped-clip.ts +5 -4
- package/src/site/desk.ts +242 -0
- package/src/site/routes.ts +66 -0
- package/src/site/unit.ts +62 -0
- package/src/social/brands.ts +22 -0
- package/src/social/compose.ts +97 -0
- package/src/social/desk-index.ts +123 -0
- package/src/social/desk-wire.ts +64 -0
- package/src/social/drafts.ts +183 -0
- package/src/social/house.ts +24 -0
- package/src/social/load.ts +319 -0
- package/src/social/md.ts +70 -0
- package/src/social/media-facts.ts +53 -0
- package/src/social/media-kind.ts +189 -0
- package/src/social/media-limit.ts +42 -0
- package/src/social/media-of.ts +30 -0
- package/src/social/migrate.ts +123 -0
- package/src/social/open.ts +17 -0
- package/src/social/post-url.ts +158 -0
- package/src/social/presence.ts +332 -0
- package/src/social/public-read.ts +53 -0
- package/src/social/publish/bluesky.ts +168 -0
- package/src/social/publish/discord.ts +76 -0
- package/src/social/publish/index.ts +24 -0
- package/src/social/publish/secret.ts +13 -0
- package/src/social/push.ts +31 -0
- package/src/social/richtext.ts +37 -0
- package/src/social/routes.ts +180 -0
- package/src/social/stats.ts +134 -0
- package/src/social/text.ts +267 -0
- package/src/social/tracker-route.ts +39 -0
- package/src/social/tracker.ts +255 -0
- package/src/social/unit.ts +53 -0
- package/src/social/writes.ts +130 -0
- package/src/start-repo.ts +14 -9
- package/src/stores/collection.ts +27 -0
- package/src/stores/desk.ts +336 -0
- package/src/stores/model.ts +187 -0
- package/src/stores/routes.ts +126 -0
- package/src/stores/unit.ts +57 -0
- package/src/suite/calibrate.ts +127 -0
- package/src/suite/core-counters.ts +91 -0
- package/src/suite/judge-suites.ts +94 -34
- package/src/suite/suite-cli.ts +44 -10
- package/src/suite/suite-cpu-preload.ts +34 -9
- package/src/trailer/adapter.ts +4 -0
- package/src/trailer/build.ts +42 -11
- package/src/trailer/ffmpeg.ts +11 -0
- package/src/trailer/footage.ts +30 -13
- package/src/trailer/grammar.ts +18 -2
- package/src/trailer/graph.ts +28 -6
- package/src/trailer/passage.ts +21 -6
- package/src/trailer/plan.ts +74 -3
- package/src/trailer/shelf.ts +16 -0
- package/src/trailer/stitch.ts +67 -26
- package/src/trailer/url.ts +1 -1
- package/src/trailer/versions.ts +24 -0
- package/src/ts/gate-typecheck.ts +32 -0
- package/src/ts/typecheck-cli.ts +9 -11
- package/src/tui/tui-app.tsx +0 -1
- package/src/veille/asks.ts +155 -0
- package/src/veille/auto.ts +31 -0
- package/src/veille/batch.ts +27 -0
- package/src/veille/chrome.ts +127 -0
- package/src/veille/collection.ts +28 -0
- package/src/veille/desk.ts +242 -0
- package/src/veille/identity.ts +80 -0
- package/src/veille/import.ts +68 -0
- package/src/veille/log.ts +183 -0
- package/src/veille/platforms.ts +118 -0
- package/src/veille/reads.ts +66 -0
- package/src/veille/replied.ts +110 -0
- package/src/veille/routes.ts +185 -0
- package/src/veille/service.ts +81 -0
- package/src/veille/watch.ts +116 -0
- package/src/veille/worth.ts +46 -0
- package/src/wiki/scan-md.ts +18 -0
- package/src/collections/posts.ts +0 -142
- package/src/contracts/manifests/social.contract.ts +0 -20
- package/src/scaffold/files/agent-coding.md +0 -35
- package/src/ts/typecheck-cache.ts +0 -11
|
@@ -205,8 +205,11 @@ export function judgeSuites(p: { timings: Record<string, number>; tests: TestsCo
|
|
|
205
205
|
|
|
206
206
|
/** one suspect's run alone, in its own `bun test` process. cpuMs is user plus
|
|
207
207
|
* system time of that process and every child it reaped, null when the
|
|
208
|
-
* runtime reports none
|
|
209
|
-
|
|
208
|
+
* runtime reports none. coreMs is its CPU as if its main thread ran on a
|
|
209
|
+
* performance core (coreMs), null where the counters are missing, and
|
|
210
|
+
* childCpuMs and otherCpuMs the parts of it that are the CPU of its children
|
|
211
|
+
* and of its process's other threads, charged as measured */
|
|
212
|
+
export type AloneRun = { wallMs: number; cpuMs: number | null; coreMs?: number | null; childCpuMs?: number; otherCpuMs?: number }
|
|
210
213
|
/** the 1 minute load average against the core count, read before a suspect runs */
|
|
211
214
|
export type MachineLoad = { load1: number; cores: number }
|
|
212
215
|
/** how far past the budget a suite must WAIT on an idle machine before its
|
|
@@ -235,15 +238,44 @@ export const waitAllowance = (budgetMs: number, load: MachineLoad): number => {
|
|
|
235
238
|
const free = 1 - loadShare(load) ** 2
|
|
236
239
|
return free <= 0 ? Infinity : (budgetMs * WAIT_FACTOR) / free
|
|
237
240
|
}
|
|
238
|
-
|
|
239
|
-
|
|
241
|
+
|
|
242
|
+
/** what a suite did, read by suite-cpu-preload.ts: its main thread's retired
|
|
243
|
+
* instructions and CPU ms, each with the part the performance cores ran, the
|
|
244
|
+
* CPU of the process's other threads (a Worker, bun's native pool, the GC
|
|
245
|
+
* and JIT), and the CPU of the children it reaped. The last two have no count */
|
|
246
|
+
export type SuiteWork = { instructions: number; pInstructions: number; cpuMs: number; pCpuMs: number; otherCpuMs: number; childCpuMs: number }
|
|
247
|
+
/** the main thread's own rate needs this much time on a performance core */
|
|
248
|
+
export const OWN_RATE_MIN_MS = 20
|
|
249
|
+
/** a suite's CPU as if its main thread ran on a performance core: its time
|
|
250
|
+
* there, plus what it retired on an efficiency core converted at the rate
|
|
251
|
+
* it ran on a performance core when it ran long enough there, never faster
|
|
252
|
+
* than `instrPerMs` (calibrate.ts conversionRate, the low end of real
|
|
253
|
+
* suites), and never more than the main thread's own CPU. The other threads
|
|
254
|
+
* and the children are charged their CPU as it is: a reaped child or an
|
|
255
|
+
* ended thread has no count left to read, so a suite that spawns keeps the
|
|
256
|
+
* CPU of what it spawned, and a lone run whose figure is mostly its
|
|
257
|
+
* children's runs once more (retryAlone). null when the main thread needs
|
|
258
|
+
* the machine's rate and there is none */
|
|
259
|
+
export function coreMs(w: SuiteWork, instrPerMs: number | null): number | null {
|
|
260
|
+
const eInstructions = Math.max(0, w.instructions - w.pInstructions)
|
|
261
|
+
const own = w.pCpuMs >= OWN_RATE_MIN_MS ? w.pInstructions / w.pCpuMs : null
|
|
262
|
+
const rate = own != null && instrPerMs != null ? Math.min(own, instrPerMs) : own ?? instrPerMs
|
|
263
|
+
if (eInstructions > 0 && (rate == null || rate <= 0)) return null
|
|
264
|
+
const main = eInstructions === 0 ? w.pCpuMs : Math.min(w.pCpuMs + eInstructions / rate!, w.cpuMs)
|
|
265
|
+
return main + w.otherCpuMs + w.childCpuMs
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** `ms` is the time the verdict used: the core figure, cpu, or wall for a
|
|
269
|
+
* wait or when no cpu figure exists */
|
|
270
|
+
export type Confirmed = { file: string; ms: number; wallMs: number; cpuMs: number | null; coreMs?: number | null; over: 'core' | 'cpu' | 'wait' | 'wall' | null }
|
|
240
271
|
|
|
241
272
|
/** the verdict on each suspect once it ran alone, continuous in the load.
|
|
242
273
|
* A wall time carries the load of every other process on the machine, so
|
|
243
274
|
* the budget judges CPU, against an allowance that grows with the load share
|
|
244
|
-
* (cpuAllowance).
|
|
245
|
-
*
|
|
246
|
-
* or children running side by side,
|
|
275
|
+
* (cpuAllowance). The CPU is the core figure where the run has one (coreMs),
|
|
276
|
+
* else the process's. A suite is charged the SMALLER of that and its wall:
|
|
277
|
+
* CPU above the wall is threads or children running side by side, and the
|
|
278
|
+
* gate never waits longer than the wall. A wall past its
|
|
247
279
|
* wait allowance fails as a wait (waitAllowance), never on a busy machine */
|
|
248
280
|
export function confirmOver(suspects: Timed[], alone: Record<string, AloneRun>, budgetMs: number, load: MachineLoad): { over: Confirmed[]; cleared: Confirmed[] } {
|
|
249
281
|
const byFile = new Map(Object.entries(alone).map(([f, run]) => [normSuitePath(f), run]))
|
|
@@ -251,6 +283,13 @@ export function confirmOver(suspects: Timed[], alone: Record<string, AloneRun>,
|
|
|
251
283
|
const run = byFile.get(t.file)
|
|
252
284
|
const wallMs = run?.wallMs ?? t.ms
|
|
253
285
|
const cpuMs = run?.cpuMs ?? null
|
|
286
|
+
const core = run?.coreMs ?? null
|
|
287
|
+
if (core != null) {
|
|
288
|
+
const charged = Math.min(core, wallMs)
|
|
289
|
+
if (charged > cpuAllowance(budgetMs, load)) return { file: t.file, ms: charged, wallMs, cpuMs, coreMs: core, over: 'core' }
|
|
290
|
+
if (wallMs > waitAllowance(budgetMs, load)) return { file: t.file, ms: wallMs, wallMs, cpuMs, coreMs: core, over: 'wait' }
|
|
291
|
+
return { file: t.file, ms: charged, wallMs, cpuMs, coreMs: core, over: null }
|
|
292
|
+
}
|
|
254
293
|
if (cpuMs == null) return { file: t.file, ms: wallMs, wallMs, cpuMs, over: wallMs > budgetMs ? 'wall' : null }
|
|
255
294
|
const charged = Math.min(cpuMs, wallMs)
|
|
256
295
|
if (charged > cpuAllowance(budgetMs, load)) return { file: t.file, ms: charged, wallMs, cpuMs, over: 'cpu' }
|
|
@@ -260,17 +299,24 @@ export function confirmOver(suspects: Timed[], alone: Record<string, AloneRun>,
|
|
|
260
299
|
return { over: judged.filter((c) => c.over != null), cleared: judged.filter((c) => c.over == null) }
|
|
261
300
|
}
|
|
262
301
|
|
|
302
|
+
/** a core figure that is more than this share CPU charged as measured (children, other threads) moves with the load like CPU does */
|
|
303
|
+
export const MEASURED_SHARE = 0.25
|
|
304
|
+
|
|
263
305
|
/** a lone run over the budget on CPU runs once more. Under load the
|
|
264
306
|
* scheduler can spill a lone run onto the efficiency cores, where the same
|
|
265
307
|
* retired instructions cost up to 4x the CPU time (measured on Apple
|
|
266
|
-
* silicon), and a spill only ever raises the figure. A
|
|
267
|
-
*
|
|
268
|
-
|
|
269
|
-
|
|
308
|
+
* silicon), and a spill only ever raises the figure. A core figure converts
|
|
309
|
+
* its main thread's spill, so it keeps its one run, unless much of it is
|
|
310
|
+
* CPU charged as measured: children and other threads. A wait or a wall
|
|
311
|
+
* verdict is not CPU either */
|
|
312
|
+
export function retryAlone(t: Timed, run: AloneRun, budgetMs: number, load: MachineLoad): boolean {
|
|
313
|
+
const over = confirmOver([t], { [t.file]: run }, budgetMs, load).over[0]?.over
|
|
314
|
+
return over === 'cpu' || (over === 'core' && (run.childCpuMs ?? 0) + (run.otherCpuMs ?? 0) > MEASURED_SHARE * (run.coreMs ?? 0))
|
|
315
|
+
}
|
|
270
316
|
|
|
271
|
-
/** the run charged less, as confirmOver charges it: the smaller of CPU and wall */
|
|
317
|
+
/** the run charged less, as confirmOver charges it: the smaller of its core figure (else its CPU) and its wall */
|
|
272
318
|
export const smallerRun = (a: AloneRun, b: AloneRun): AloneRun => {
|
|
273
|
-
const charge = (r: AloneRun): number => Math.min(r.cpuMs ?? r.wallMs, r.wallMs)
|
|
319
|
+
const charge = (r: AloneRun): number => Math.min(r.coreMs ?? r.cpuMs ?? r.wallMs, r.wallMs)
|
|
274
320
|
return charge(b) < charge(a) ? b : a
|
|
275
321
|
}
|
|
276
322
|
|
|
@@ -278,9 +324,10 @@ const secs = (ms: number): string => `${(ms / 1000).toFixed(1)}s`
|
|
|
278
324
|
|
|
279
325
|
/** the line a confirmed suite fails with */
|
|
280
326
|
export const overWords = (c: Confirmed, load: MachineLoad, budgetMs: number = DEFAULT_BUDGET_MS): string =>
|
|
281
|
-
c.over === '
|
|
282
|
-
: c.over === '
|
|
283
|
-
: `${c.file} ${secs(c.wallMs)} wall (
|
|
327
|
+
c.over === 'core' ? `${c.file} ${secs(c.coreMs ?? c.ms)} of CPU on a performance core (${c.cpuMs != null ? `${secs(c.cpuMs)} of process CPU, ` : ''}${secs(c.wallMs)} wall)`
|
|
328
|
+
: c.over === 'cpu' ? `${c.file} ${secs(c.cpuMs ?? c.ms)} of CPU (${secs(c.wallMs)} wall)`
|
|
329
|
+
: c.over === 'wait' ? `${c.file} ${secs(c.wallMs)} wall at load ${load.load1.toFixed(1)} on ${load.cores} cores, past its ${secs(waitAllowance(budgetMs, load))} wait allowance, with ${secs(c.coreMs ?? c.cpuMs ?? 0)} of CPU: it waits (a timer, a sleep, a poll)`
|
|
330
|
+
: `${c.file} ${secs(c.wallMs)} wall (no CPU figure)`
|
|
284
331
|
|
|
285
332
|
/** how the parallel phase's workers hand the runner the CPU of each suite
|
|
286
333
|
* (suite-cpu-preload.ts writes it, readPhaseCpu reads it) */
|
|
@@ -288,44 +335,57 @@ export const SUITE_CPU_ENV = 'SHIPKIT_SUITE_CPU'
|
|
|
288
335
|
|
|
289
336
|
/** what the workers wrote, keyed like the timings: relative to the run's cwd.
|
|
290
337
|
* `ran` is every suite that finished in the phase, `cpu` the own CPU of the
|
|
291
|
-
* ones whose figure can be trusted (suite-cpu-preload.ts)
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
|
|
338
|
+
* ones whose figure can be trusted (suite-cpu-preload.ts), `work` their main
|
|
339
|
+
* thread's counts, their other threads' and their children's CPU where the
|
|
340
|
+
* counters exist.
|
|
341
|
+
* A file bun ran twice keeps its larger figure, and none at all once one of
|
|
342
|
+
* its runs could not be trusted */
|
|
343
|
+
export function readPhaseCpu(text: string, cwd: string): { ran: string[]; cpu: Record<string, number>; work: Record<string, SuiteWork> } {
|
|
295
344
|
const ran = new Set<string>()
|
|
296
345
|
const unsure = new Set<string>()
|
|
297
346
|
const cpu: Record<string, number> = {}
|
|
347
|
+
const work: Record<string, SuiteWork> = {}
|
|
298
348
|
const base = cwd.replace(/\\/g, '/')
|
|
299
349
|
for (const line of text.split('\n')) {
|
|
300
|
-
const [file, ms] = line.split('\t')
|
|
350
|
+
const [file, ms, ...fields] = line.split('\t')
|
|
301
351
|
if (file == null || file === '' || ms == null) continue
|
|
302
352
|
const rel = normSuitePath(posix.relative(base, file.replace(/\\/g, '/')))
|
|
303
353
|
if (ms === '-') { ran.add(rel); unsure.add(rel); continue }
|
|
304
354
|
if (!/^\d+$/.test(ms)) continue
|
|
305
355
|
ran.add(rel)
|
|
306
356
|
cpu[rel] = Math.max(cpu[rel] ?? 0, Number(ms))
|
|
357
|
+
const nums = fields.map(Number)
|
|
358
|
+
if (fields.length === 5 && nums.every((n) => Number.isFinite(n) && n >= 0)) {
|
|
359
|
+
const [instructions, pInstructions, mainMs, pCpuMs, childCpuMs] = nums as [number, number, number, number, number]
|
|
360
|
+
// the line's CPU is the whole process's and its children's: past the main thread and the children, its other threads'
|
|
361
|
+
const w = { instructions, pInstructions, cpuMs: mainMs, pCpuMs, otherCpuMs: Math.max(0, Number(ms) - mainMs - childCpuMs), childCpuMs }
|
|
362
|
+
const had = work[rel]
|
|
363
|
+
if (had == null || had.cpuMs + had.otherCpuMs + had.childCpuMs < w.cpuMs + w.otherCpuMs + w.childCpuMs) work[rel] = w
|
|
364
|
+
}
|
|
307
365
|
}
|
|
308
|
-
for (const f of unsure) delete cpu[f]
|
|
309
|
-
return { ran: [...ran].sort(), cpu }
|
|
366
|
+
for (const f of unsure) { delete cpu[f]; delete work[f] }
|
|
367
|
+
return { ran: [...ran].sort(), cpu, work }
|
|
310
368
|
}
|
|
311
369
|
|
|
312
370
|
/** which suspects still need their alone run. A suspect is judged on its OWN
|
|
313
|
-
* CPU in the parallel phase,
|
|
314
|
-
* (confirmOver): the load it suffered there only
|
|
315
|
-
* inside the allowance is cleared. What the earlier files of its worker
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
export function aloneRunsNeeded(suspects: Timed[], parallelCpu: Record<string, number>, budgetMs: number, load: MachineLoad): { rerun: Timed[]; cleared: Confirmed[] } {
|
|
371
|
+
* CPU in the parallel phase, its core figure where it has one, charged and
|
|
372
|
+
* allowed as a lone run is (confirmOver): the load it suffered there only
|
|
373
|
+
* raised that figure, so one inside the allowance is cleared. What the earlier files of its worker burned is never
|
|
374
|
+
* its cost, a module they loaded or a memo they filled included: the first
|
|
375
|
+
* suite of a worker that needs shared work pays for it. A suspect with no
|
|
376
|
+
* figure (a child not yet reaped) or over its allowance runs alone, and only
|
|
377
|
+
* the alone run can see a WAIT, so a suite whose wall is past its wait
|
|
378
|
+
* allowance still gets it */
|
|
379
|
+
export function aloneRunsNeeded(suspects: Timed[], parallelCpu: Record<string, number>, budgetMs: number, load: MachineLoad, parallelCore: Record<string, number> = {}): { rerun: Timed[]; cleared: Confirmed[] } {
|
|
322
380
|
const rerun: Timed[] = []
|
|
323
381
|
const cleared: Confirmed[] = []
|
|
324
382
|
for (const t of suspects) {
|
|
325
383
|
const cpuMs = parallelCpu[t.file]
|
|
384
|
+
const core = parallelCore[t.file]
|
|
326
385
|
const mayWait = t.ms > waitAllowance(budgetMs, load)
|
|
327
|
-
const
|
|
328
|
-
|
|
386
|
+
const figure = core ?? cpuMs
|
|
387
|
+
const charged = figure == null ? null : Math.min(figure, t.ms)
|
|
388
|
+
if (charged != null && charged <= cpuAllowance(budgetMs, load) && !mayWait) cleared.push({ file: t.file, ms: charged, wallMs: t.ms, cpuMs: cpuMs ?? null, ...(core != null ? { coreMs: core } : {}), over: null })
|
|
329
389
|
else rerun.push(t)
|
|
330
390
|
}
|
|
331
391
|
return { rerun, cleared }
|
package/src/suite/suite-cli.ts
CHANGED
|
@@ -19,8 +19,10 @@ import { keepTimings, seedTimings, timingsHome } from './kept-timings.ts'
|
|
|
19
19
|
import { SUITE_READS_ENV, SUITE_ROOT_ENV, SUITE_SELECT_ENV } from './reads-env.ts'
|
|
20
20
|
import { changedKeys, dropStaticEdges, extras, isBunSuite, envFilesOf, foldReads, loadErrorModules, loadState, preloadsOf, saveState, selectStatePath, selectSuites, snapshot, suiteFiles, taintedSuites, walkGraph, type GraphEntry, type Selection, type SelectState } from './select.ts'
|
|
21
21
|
import { gitRoot } from '../core/git-root.ts'
|
|
22
|
+
import { runReaches, type TestRun } from './test-units.ts'
|
|
22
23
|
import { loadConfig } from '../ts/config.ts'
|
|
23
|
-
import {
|
|
24
|
+
import { conversionRate, machineRate } from './calibrate.ts'
|
|
25
|
+
import { aloneRunsNeeded, bunfigTest, coreMs, cpuAllowance, loadShare, type SuiteWork, type BunfigTest, readPhaseCpu, SUITE_CPU_ENV, type AloneRun, type Confirmed, confirmOver, crashedWorkers, interruptedSuites, overWords, ranAs, retryAlone, smallerRun, stallWords, DEFAULT_BUDGET_MS, FULL_CEILING_MS, failedSuites, failLines, judgeSuites, normSuitePath, parseSuiteFlags, planPhases, QUICK_CEILING_MS, poolWorkers, redWords } from './judge-suites.ts'
|
|
24
26
|
|
|
25
27
|
type Phase = { code: number; signal: string | null; stalled: boolean; out: string; timings: Record<string, number>; cpuMs: number | null }
|
|
26
28
|
|
|
@@ -151,6 +153,22 @@ async function runSuites(argv: string[], ctx: SelectCtx): Promise<number> {
|
|
|
151
153
|
// the load BEFORE this run: read after it, the one minute average
|
|
152
154
|
// carries this run's own parallel phase, which is no other process
|
|
153
155
|
const load = machineLoad()
|
|
156
|
+
// the core figure needs the counters, and the machine's rate to
|
|
157
|
+
// convert a main thread's efficiency core part; without them the
|
|
158
|
+
// budget judges the process's CPU, and says so
|
|
159
|
+
const cal = cpuFile != null ? machineRate({ loadShare: loadShare(load) }) : null
|
|
160
|
+
const counted = cal != null && !('reason' in cal && cal.counters === false)
|
|
161
|
+
const instrPerMs = cal != null && !('reason' in cal) ? conversionRate(cal) : null
|
|
162
|
+
if (cal != null && 'reason' in cal && !counted) notes.push(`note: the suite budget judges the CPU of the whole process in this run, its time on efficiency cores included: ${cal.reason}`)
|
|
163
|
+
const noRate = cal != null && 'reason' in cal ? cal.reason : ''
|
|
164
|
+
// a suite judged on its process CPU where the run has counters: why, said once per suite
|
|
165
|
+
const fallbacks = new Map<string, string>()
|
|
166
|
+
const toCore = (file: string, w: SuiteWork | undefined): number | null => {
|
|
167
|
+
if (!counted || w == null) return null
|
|
168
|
+
const ms = coreMs(w, instrPerMs)
|
|
169
|
+
if (ms == null) fallbacks.set(file, `its main thread barely ran on a performance core, and this machine has no rate to convert the rest (${noRate})`)
|
|
170
|
+
return ms
|
|
171
|
+
}
|
|
154
172
|
const picked = prepareSelection({ tests, tier, rawArgs, bunfig, unit, plan })
|
|
155
173
|
if (typeof picked === 'string') notes.push(picked)
|
|
156
174
|
else {
|
|
@@ -177,11 +195,15 @@ async function runSuites(argv: string[], ctx: SelectCtx): Promise<number> {
|
|
|
177
195
|
// bun merges what it read into what it writes, so a suite deleted since
|
|
178
196
|
// the last run is judged and kept only if the workers say it ran here
|
|
179
197
|
// or it is still on disk. On disk alone is the floor: a suite whose
|
|
180
|
-
// line went missing is never dropped from the judgment
|
|
181
|
-
|
|
198
|
+
// line went missing is never dropped from the judgment. A suite this
|
|
199
|
+
// run's ignores exclude (bunfig plus command line) is dropped even on
|
|
200
|
+
// disk: a run that once collected it must not keep it judged forever
|
|
201
|
+
const phaseCpu: ReturnType<typeof readPhaseCpu> = cpuFile != null && existsSync(cpuFile) ? readPhaseCpu(readFileSync(cpuFile, 'utf8'), process.cwd()) : { ran: [], cpu: {}, work: {} }
|
|
182
202
|
if (kept != null) {
|
|
183
203
|
const ranHere = new Set(phaseCpu.ran)
|
|
184
|
-
|
|
204
|
+
const discovery: TestRun = { args: parallelArgs, bunfig, extraIgnores: [] }
|
|
205
|
+
const ignored = (f: string): boolean => { const r = runReaches(f, discovery); return r != null && !r.runs && 'ignoredBy' in r }
|
|
206
|
+
p1.timings = Object.fromEntries(Object.entries(p1.timings).filter(([f]) => !ignored(f) && (ranHere.has(normSuitePath(f)) || existsSync(f))))
|
|
185
207
|
if (!p1.stalled && p1.signal == null) {
|
|
186
208
|
writeFileSync(join(dir, 'parallel.json'), JSON.stringify({ version: 1, files: p1.timings }))
|
|
187
209
|
keepTimings(join(dir, 'parallel.json'), kept)
|
|
@@ -209,12 +231,18 @@ async function runSuites(argv: string[], ctx: SelectCtx): Promise<number> {
|
|
|
209
231
|
// side each burned about 40% more CPU than one alone (8 cores)
|
|
210
232
|
const aloneRuns: Record<string, AloneRun> = {}
|
|
211
233
|
const parallelCpu = phaseCpu.cpu
|
|
212
|
-
const
|
|
234
|
+
const parallelCore = Object.fromEntries(judged.over.map((t) => [t.file, toCore(t.file, phaseCpu.work[t.file])]).filter(([, ms]) => ms != null)) as Record<string, number>
|
|
235
|
+
const { rerun, cleared: clearedInPhase } = aloneRunsNeeded(judged.over, parallelCpu, budget, load, parallelCore)
|
|
213
236
|
const aloneAt = Date.now()
|
|
214
237
|
const runAlone = async (t: { file: string }, name: string): Promise<AloneRun | null> => {
|
|
215
|
-
const
|
|
238
|
+
const lines = counted ? join(dir, `${name}.tsv`) : null
|
|
239
|
+
const run = await runPhase([...plan.alone, t.file], join(dir, `${name}.json`), ceilingMs, tmp, false, lines, rec)
|
|
216
240
|
const wallMs = Object.entries(run.timings).find(([f]) => normSuitePath(f) === t.file)?.[1]
|
|
217
|
-
|
|
241
|
+
if (wallMs == null) return null
|
|
242
|
+
const work = lines != null && existsSync(lines) ? readPhaseCpu(readFileSync(lines, 'utf8'), process.cwd()).work[t.file] : undefined
|
|
243
|
+
if (counted && work == null) fallbacks.set(t.file, 'its lone run wrote no counts (a child still alive when it ended, or no line at all)')
|
|
244
|
+
const core = toCore(t.file, work)
|
|
245
|
+
return { wallMs, cpuMs: run.cpuMs, ...(core != null ? { coreMs: core, childCpuMs: work!.childCpuMs, otherCpuMs: work!.otherCpuMs } : {}) }
|
|
218
246
|
}
|
|
219
247
|
for (const [i, t] of rerun.entries()) {
|
|
220
248
|
const first = await runAlone(t, `alone-${i}`)
|
|
@@ -224,12 +252,18 @@ async function runSuites(argv: string[], ctx: SelectCtx): Promise<number> {
|
|
|
224
252
|
const second = await runAlone(t, `alone-${i}-again`)
|
|
225
253
|
if (second == null) continue
|
|
226
254
|
aloneRuns[t.file] = smallerRun(first, second)
|
|
227
|
-
|
|
255
|
+
const charge = (r: AloneRun): string => secs(r.coreMs ?? r.cpuMs ?? r.wallMs)
|
|
256
|
+
notes.push(`note: ${t.file} ran alone twice, ${charge(first)} then ${charge(second)} of CPU${first.coreMs != null ? ', much of it its children\'s or its other threads\'' : ''}, and the smaller stands: a lone run the scheduler spills onto slower cores burns more CPU for the same work`)
|
|
228
257
|
}
|
|
229
258
|
const aloneMs = Date.now() - aloneAt
|
|
230
259
|
const { over, cleared } = rerun.length > 0 ? confirmOver(rerun, aloneRuns, budget, load) : { over: [], cleared: [] }
|
|
231
|
-
|
|
232
|
-
|
|
260
|
+
const did = (c: Confirmed, own: string): string => (c.coreMs != null
|
|
261
|
+
? `burned ${secs(c.coreMs)} of ${own}CPU on a performance core${c.cpuMs != null ? ` (${secs(c.cpuMs)} of process CPU)` : ''}`
|
|
262
|
+
: `burned ${c.cpuMs != null ? secs(c.cpuMs) : '?'} of ${own}CPU`) + (c.ms < (c.coreMs ?? c.cpuMs ?? 0) ? `, charged its ${secs(c.wallMs)} wall, the smaller` : '')
|
|
263
|
+
const inside = `inside its ${secs(cpuAllowance(budget, load))} allowance (the ${budget}ms budget at load ${load.load1.toFixed(1)} on ${load.cores} cores)`
|
|
264
|
+
for (const c of clearedInPhase) notes.push(`note: ${c.file} took ${secs(c.wallMs)} in the parallel run but ${did(c, 'its own ')} there, ${inside}, so it did not run again alone`)
|
|
265
|
+
for (const c of cleared) notes.push(`note: ${c.file} took ${secs(c.wallMs)} alone but ${did(c, '')}, ${inside}`)
|
|
266
|
+
for (const [f, why] of fallbacks) if (aloneRuns[f]?.coreMs == null) notes.push(`note: ${f} is judged on the CPU of its process: ${why}`)
|
|
233
267
|
|
|
234
268
|
// a ceiling kill makes bun report every worker it held as crashed, and
|
|
235
269
|
// those are the suites that never finished, not an outside kill
|
|
@@ -14,19 +14,30 @@
|
|
|
14
14
|
// nobody counted yet, so that suite's line says `-` and it runs alone if it is
|
|
15
15
|
// a suspect. The lines also say which suites ran at all.
|
|
16
16
|
//
|
|
17
|
+
// Five more fields where the machine counts instructions per core type
|
|
18
|
+
// (core-counters.ts): the main thread's instructions, those on a performance
|
|
19
|
+
// core, its CPU ms, those on a performance core, and the children's CPU ms.
|
|
20
|
+
// The process's other threads are the first figure less those two CPUs. The
|
|
21
|
+
// runner turns them into the CPU the suite would burn with its main thread on
|
|
22
|
+
// a performance core (judge-suites.ts coreMs).
|
|
23
|
+
//
|
|
17
24
|
// It needs `--parallel`: without it bun runs a preload's hooks once for the
|
|
18
|
-
// whole run, not once per suite
|
|
25
|
+
// whole run, not once per suite, which a lone run of one suite uses: its line
|
|
26
|
+
// counts from this preload's load, so bun's start and the preloads before
|
|
27
|
+
// this one stay out of it as they do in the parallel phase. The wall bun
|
|
28
|
+
// times for a file leaves them out too. Children come from getrusage(RUSAGE_CHILDREN)
|
|
19
29
|
// through bun:ffi: Bun's own resourceUsage() is the process alone, and a gate
|
|
20
30
|
// heavy suite burns most of its CPU in git. A runtime where either call cannot
|
|
21
31
|
// be made records nothing, and every suspect then runs alone as before.
|
|
22
32
|
import { appendFileSync, readdirSync, readFileSync } from 'fs'
|
|
23
33
|
import { afterAll } from 'bun:test'
|
|
34
|
+
import { coreCounters } from './core-counters.ts'
|
|
24
35
|
import { SUITE_CPU_ENV } from './judge-suites.ts'
|
|
25
36
|
|
|
26
37
|
const RUSAGE_SELF = 0
|
|
27
38
|
const RUSAGE_CHILDREN = -1
|
|
28
39
|
|
|
29
|
-
type Probes = { cpu: () => number; liveChildren: () => number }
|
|
40
|
+
type Probes = { cpu: () => number; children: () => number; liveChildren: () => number }
|
|
30
41
|
|
|
31
42
|
/** user plus system ms of this process and of its reaped children, and how
|
|
32
43
|
* many children it has that are alive or not yet reaped. null when the
|
|
@@ -65,7 +76,7 @@ function probes(): Probes | null {
|
|
|
65
76
|
return n
|
|
66
77
|
}
|
|
67
78
|
liveChildren()
|
|
68
|
-
return { cpu: () => one(RUSAGE_SELF) + one(RUSAGE_CHILDREN), liveChildren }
|
|
79
|
+
return { cpu: () => one(RUSAGE_SELF) + one(RUSAGE_CHILDREN), children: () => one(RUSAGE_CHILDREN), liveChildren }
|
|
69
80
|
} catch {
|
|
70
81
|
return null
|
|
71
82
|
}
|
|
@@ -74,15 +85,29 @@ function probes(): Probes | null {
|
|
|
74
85
|
const out = process.env[SUITE_CPU_ENV]
|
|
75
86
|
const p = out != null && out !== '' ? probes() : null
|
|
76
87
|
if (out != null && p != null) {
|
|
77
|
-
|
|
88
|
+
const counters = coreCounters()
|
|
89
|
+
const main = 'reason' in counters ? null : counters.thread
|
|
90
|
+
const zero = { instructions: 0, pInstructions: 0, cpuMs: 0, pCpuMs: 0 }
|
|
91
|
+
const read = (): { cpu: number; children: number; main: typeof zero } => ({ cpu: p.cpu(), children: p.children(), main: main?.() ?? zero })
|
|
92
|
+
// null once a read threw: the next suite's figure would carry this one's
|
|
93
|
+
let ended: ReturnType<typeof read> | null = null
|
|
94
|
+
try { ended = read() } catch { /* the first suite says `-` */ }
|
|
78
95
|
afterAll(() => {
|
|
79
|
-
const now = p.cpu()
|
|
80
96
|
// every suite gets a line, since the line is also how the runner knows
|
|
81
97
|
// it ran; a suite whose figure cannot be trusted says `-`
|
|
98
|
+
let figure = '-'
|
|
82
99
|
try {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
100
|
+
const now = read()
|
|
101
|
+
if (ended != null && p.liveChildren() === 0) {
|
|
102
|
+
const was = ended
|
|
103
|
+
const d = (k: keyof typeof zero): number => Math.max(0, Math.round(now.main[k] - was.main[k]))
|
|
104
|
+
const work = main == null ? '' : `\t${d('instructions')}\t${d('pInstructions')}\t${d('cpuMs')}\t${d('pCpuMs')}\t${Math.round(now.children - was.children)}`
|
|
105
|
+
figure = `${Math.round(now.cpu - was.cpu)}${work}`
|
|
106
|
+
}
|
|
107
|
+
ended = now
|
|
108
|
+
} catch {
|
|
109
|
+
ended = null
|
|
110
|
+
}
|
|
111
|
+
try { appendFileSync(out, `${Bun.main}\t${figure}\n`) } catch { /* no line: the suite runs alone if it is a suspect */ }
|
|
87
112
|
})
|
|
88
113
|
}
|
package/src/trailer/adapter.ts
CHANGED
|
@@ -81,6 +81,9 @@ export interface TrailerDef {
|
|
|
81
81
|
sound?: TrailerSounds
|
|
82
82
|
/** the paths a take's world is (`['src', 'public']`); default the whole tree, trailer/ and .shipkit/ left out */
|
|
83
83
|
stamp?: string[]
|
|
84
|
+
/** the commit a take's world is read at, the one the filmed page serves (`main`, or a served worktree's own HEAD,
|
|
85
|
+
* `worktrees/<name>/HEAD`): an uncommitted edit moves nothing; default the working tree */
|
|
86
|
+
ref?: string
|
|
84
87
|
/** in process, before filming, in a few ms: the content the language cannot know */
|
|
85
88
|
check?(c: TrailerCheckInput): TrailerFinding[] | Promise<TrailerFinding[]>
|
|
86
89
|
/** one film line's take, when its words change what its row says */
|
|
@@ -103,5 +106,6 @@ export function trailer(d: TrailerDef): TrailerUnit {
|
|
|
103
106
|
if (why !== null) throw new Error(`trailer: ${why}`)
|
|
104
107
|
}
|
|
105
108
|
if (d.stamp !== undefined && (!Array.isArray(d.stamp) || d.stamp.some((p) => typeof p !== 'string' || p === '' || p.startsWith('/')))) throw new Error('trailer: stamp is a list of repo relative paths')
|
|
109
|
+
if (d.ref !== undefined && (typeof d.ref !== 'string' || !/^[^\s:-][^\s:]*$/.test(d.ref))) throw new Error('trailer: ref is a commit, a branch or a tag (main, HEAD, v1.2), never a tree path')
|
|
106
110
|
return { ...d, kind: 'trailer' }
|
|
107
111
|
}
|
package/src/trailer/build.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { SoundRequest, TrailerCheckInput, TrailerUnit } from './adapter.ts'
|
|
|
6
6
|
import { type FilmVerb, type Film, gridCells, namedStyles, parseTrailer, placeOf, resolveStyles, type Title, type SoundGen, type SoundRun, SCORE, SCORE_LEAD, type Shot, starts, total, type Trailer, type TrailerError, musicCues, NO_MUSIC } from './grammar.ts'
|
|
7
7
|
import { filmLineOf, type Recipe, takesOf, trailerCache } from './footage.ts'
|
|
8
8
|
import type { BrandLike, TrailerLook } from './look.ts'
|
|
9
|
-
import { fresh, isTake, type Refilm, recipeWords, type Take, takeIsStill, takesToFilm, type World, worldFor } from './plan.ts'
|
|
9
|
+
import { fresh, isTake, movedParts, type Refilm, recipeWords, type Take, takeIsStill, takesToFilm, type World, type WorldState, worldFor } from './plan.ts'
|
|
10
10
|
import { decodeStates, edgeChanges } from './states.ts'
|
|
11
11
|
import { type CompiledScore, compileScore } from './score/score.ts'
|
|
12
12
|
import { GROW_RES, type Source, titleMotions } from './graph.ts'
|
|
@@ -181,15 +181,17 @@ export function checkInput(l: Loaded): TrailerCheckInput {
|
|
|
181
181
|
/** every take of the cut, its spec read through the repo's unit */
|
|
182
182
|
export const takesOfLoaded = (l: Loaded): Take[] => takesOf(l.t, l.root, l)
|
|
183
183
|
|
|
184
|
-
/** the world each take shows: its row's `stamp` paths, else the unit's `stamp`, else the whole repo
|
|
185
|
-
|
|
184
|
+
/** the world each take shows: its row's `stamp` paths, else the unit's `stamp`, else the whole repo, at the unit's
|
|
185
|
+
* `ref` or in the working tree; each measured once */
|
|
186
|
+
export async function worldOf(l: Pick<Loaded, 'root' | 'unit'>): Promise<(tk: Take) => WorldState> {
|
|
186
187
|
const { worldStamp } = await import('./footage.ts')
|
|
187
|
-
const seen = new Map<string,
|
|
188
|
+
const seen = new Map<string, WorldState>()
|
|
189
|
+
const ref = l.unit?.ref
|
|
188
190
|
return (tk) => {
|
|
189
191
|
const paths = tk.spec.stamp ?? l.unit?.stamp
|
|
190
192
|
const k = JSON.stringify(paths ?? null)
|
|
191
193
|
let w = seen.get(k)
|
|
192
|
-
if (w === undefined) seen.set(k, (w = worldStamp(l.root, paths)))
|
|
194
|
+
if (w === undefined) seen.set(k, (w = worldStamp(l.root, paths, ref)))
|
|
193
195
|
return w
|
|
194
196
|
}
|
|
195
197
|
}
|
|
@@ -402,7 +404,7 @@ export function timeline(l: Loaded, takes: readonly Take[], world: World | null,
|
|
|
402
404
|
? 'NOT FILMED'
|
|
403
405
|
: world === null || fresh(tk.stamp, worldFor(world, tk))
|
|
404
406
|
? 'filmed'
|
|
405
|
-
: `filmed on an older world, ${ago(tk.stamp.filmedAt)} (--refilm ${s.name})`
|
|
407
|
+
: `filmed on an older world, ${ago(tk.stamp.filmedAt)}${movedText(movedParts(tk.stamp, worldFor(world, tk)))} (--refilm ${s.name})`
|
|
406
408
|
const held = tk?.stamp && !takeIsStill(tk.film) && tk.stamp.seconds - s.from < s.length - 0.05 ? `, its last frame held ${(s.length - (tk.stamp.seconds - s.from)).toFixed(2)} s` : ''
|
|
407
409
|
const edges = tk ? edgesOf(s, tk, l.t.fps, l.unit?.states) : ''
|
|
408
410
|
const sec = s.section ? ` [section ${s.section.name} at ${+s.section.at.toFixed(3)} s]` : ''
|
|
@@ -416,6 +418,13 @@ export function timeline(l: Loaded, takes: readonly Take[], world: World | null,
|
|
|
416
418
|
return out
|
|
417
419
|
}
|
|
418
420
|
|
|
421
|
+
/** the parts of the world that moved, as the timeline says them; nothing when the stamp kept no parts */
|
|
422
|
+
function movedText(parts: string[] | null): string {
|
|
423
|
+
if (parts === null || parts.length === 0) return ''
|
|
424
|
+
const shown = parts.slice(0, 4).join(', ')
|
|
425
|
+
return `: ${shown}${parts.length > 4 ? ` and ${parts.length - 4} more` : ''} moved`
|
|
426
|
+
}
|
|
427
|
+
|
|
419
428
|
function secs(x: number): string {
|
|
420
429
|
return `${+x.toFixed(2)} s`
|
|
421
430
|
}
|
|
@@ -458,7 +467,14 @@ function withCells(l: Loaded, names: Iterable<string>): Set<string> {
|
|
|
458
467
|
return out
|
|
459
468
|
}
|
|
460
469
|
|
|
461
|
-
/**
|
|
470
|
+
/** how many takes film at once: the repo's browser cap (repo.config.ts browsers.max) */
|
|
471
|
+
async function browserLanes(root: string): Promise<number> {
|
|
472
|
+
const [{ browserCap }, { DEFAULT_BROWSERS }] = await Promise.all([import('../shot/browser-slot.ts'), import('../core/slots.ts')])
|
|
473
|
+
return (await browserCap(root))?.cap ?? DEFAULT_BROWSERS
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/** film the takes missing (and what --refilm names), as many at once as the repo's browser cap; every shot is tried,
|
|
477
|
+
* the failures said together */
|
|
462
478
|
async function filmAll(l: Loaded, world: World, refilm: Refilm, say: Say, only?: ReadonlySet<string>): Promise<Take[]> {
|
|
463
479
|
const { filmTake } = await import('./footage.ts')
|
|
464
480
|
const takes = takesOfLoaded(l)
|
|
@@ -477,8 +493,17 @@ async function filmAll(l: Loaded, world: World, refilm: Refilm, say: Say, only?:
|
|
|
477
493
|
}
|
|
478
494
|
}
|
|
479
495
|
}
|
|
480
|
-
|
|
496
|
+
const filmed = ask.flat()
|
|
497
|
+
// each take's own browser holds the repo's slot (shot/browser-slot.ts), so the lanes only count up to the cap
|
|
498
|
+
const lanes = ask.length === 0 ? 0 : await browserLanes(l.root)
|
|
499
|
+
await Promise.all(Array.from({ length: lanes }, lane))
|
|
481
500
|
if (failed.length > 0) throw new Refused(`${failed.length} shot(s) did not film:\n${failed.join('\n')}`)
|
|
501
|
+
// a commit landing while a take films: the page may have served either world, the stamp names the one before
|
|
502
|
+
if (filmed.length > 0) {
|
|
503
|
+
const after = await worldOf(l)
|
|
504
|
+
const moved = filmed.filter((tk) => !tk.spec.world && worldFor(world, tk).id !== after(tk).id).map((tk) => tk.shot.name)
|
|
505
|
+
if (moved.length > 0) say(`WARN the world moved while ${moved.join(', ')} filmed: the page may have shown either one (--refilm ${moved.join(',')})`)
|
|
506
|
+
}
|
|
482
507
|
return takes
|
|
483
508
|
}
|
|
484
509
|
|
|
@@ -599,7 +624,9 @@ async function finishVertical(l: Loaded, input: { look: TrailerLook; brand: Bran
|
|
|
599
624
|
encoder: final ? ('final' as const) : ('draft' as const),
|
|
600
625
|
}
|
|
601
626
|
const clipStat = clip ? [statSync(clip).size, statSync(clip).mtimeMs] : null
|
|
602
|
-
|
|
627
|
+
// keyed on what the cut is (its pieces' and mix's keys), never on the cut's name: another cut of the same pieces
|
|
628
|
+
// takes this finish
|
|
629
|
+
const key = new Bun.CryptoHasher('sha1').update(JSON.stringify([finishArgs({ ...a, cut: 'cut.mp4' }, 'out.mp4'), done.pieces.map((p) => p.key), done.mixKey, clipStat])).digest('hex').slice(0, 16)
|
|
603
630
|
const { files, made } = await cachedAs(join(trailerCache(l.root, 'pieces'), 'vertical'), `${l.t.name}-vertical`, key, ['mp4'], ([o]) => finishArgs(a, o!))
|
|
604
631
|
copyFileSync(files[0]!, out)
|
|
605
632
|
return { note: made ? 'the vertical finished' : 'the vertical cached', seconds: finishSeconds(a) }
|
|
@@ -674,9 +701,13 @@ export async function build(l: Loaded, o: BuildOptions): Promise<string> {
|
|
|
674
701
|
if (heard) {
|
|
675
702
|
const [{ loudness, loudnessKept }, { MIX_TRUE_PEAK }] = await Promise.all([import('./ffmpeg.ts'), import('./graph.ts')])
|
|
676
703
|
const { lufs, truePeak } = await (finished ? loudness(heard) : loudnessKept(heard))
|
|
677
|
-
const
|
|
704
|
+
const { master } = l.t
|
|
705
|
+
const line = `the mix: ${lufs.toFixed(1)} LUFS integrated${master === null ? '' : ` (master ${master})`}, true peak ${truePeak.toFixed(1)} dBTP`
|
|
678
706
|
if (truePeak > 0) refuse(`${line}, past 0 dBTP: it clips on a player. ${out} is written; lower the loudest sounds (a score's volume, a sfx or voice volume)`)
|
|
679
|
-
|
|
707
|
+
const off = master === null ? 0 : lufs - master
|
|
708
|
+
if (truePeak > MIX_TRUE_PEAK) o.say(`WARN ${line}, past the limiter's ${MIX_TRUE_PEAK} dBTP`)
|
|
709
|
+
else if (Math.abs(off) > 0.5) o.say(`WARN ${line}, ${Math.abs(off).toFixed(1)} LU ${off < 0 ? 'under' : 'over'} its master, past what one gain into the ${MIX_TRUE_PEAK} dBTP limiter reaches (its loudest sound held down while the rest stays quiet)`)
|
|
710
|
+
else o.say(`ok: ${line}`)
|
|
680
711
|
}
|
|
681
712
|
await pruneAfter(l.root, o.say)
|
|
682
713
|
return out
|
package/src/trailer/ffmpeg.ts
CHANGED
|
@@ -38,6 +38,17 @@ export function duration(file: string): number {
|
|
|
38
38
|
return d
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/** one ffprobe of a media file: its length and its video stream's size, null when it has none */
|
|
42
|
+
export function probeMedia(file: string): { duration: number; video: { width: number; height: number } | null } {
|
|
43
|
+
const r = Bun.spawnSync([FFPROBE, '-v', 'error', '-show_entries', 'stream=codec_type,width,height:format=duration', '-of', 'json', file], { stdout: 'pipe', stderr: 'pipe' })
|
|
44
|
+
if (r.exitCode !== 0) throw new Error(`ffprobe ${file}: ${r.stderr.toString().trim() || `exit ${r.exitCode}`}`)
|
|
45
|
+
const j = JSON.parse(r.stdout.toString()) as { streams?: { codec_type?: string; width?: number; height?: number }[]; format?: { duration?: string } }
|
|
46
|
+
const d = Number(j.format?.duration)
|
|
47
|
+
if (!(d > 0)) throw new Error(`ffprobe ${file}: no length`)
|
|
48
|
+
const v = j.streams?.find((s) => s.codec_type === 'video')
|
|
49
|
+
return { duration: d, video: v?.width && v.height ? { width: v.width, height: v.height } : null }
|
|
50
|
+
}
|
|
51
|
+
|
|
41
52
|
const probed = new Map<string, Promise<number>>()
|
|
42
53
|
|
|
43
54
|
/** a media file's length like `duration`, probed once per file and state in this process, the probes side by side: a
|