11// Standard scheduled-lane artifact envelope (#1430) for the concurrency torture
2- // lane (#1416). #1430 requires every scheduled lane to emit a machine-readable
3- // envelope — schema version, commit SHA, tool/config hashes, seed range,
4- // duration, and result — so the observatory can detect a lane going dark or
5- // stale. Written when TORTURE_ENVELOPE names an output path (set by the nightly
6- // workflow, which uploads it as an artifact); a no-op otherwise.
2+ // lane (#1416). Builds the shared `LaneEnvelope` from scripts/lib/lane-envelope.ts
3+ // so the #1430 health watcher parses one dialect, not a lane-local one; the
4+ // lane's seed range / run count ride in the typed `data` payload, and the lane
5+ // source hash maps onto the generic `configHash`. Written when TORTURE_ENVELOPE
6+ // names an output path (set by the nightly workflow, which uploads it as an
7+ // artifact); a no-op otherwise.
78
89import crypto from 'node:crypto' ;
910import fs from 'node:fs' ;
1011import path from 'node:path' ;
1112import { fileURLToPath } from 'node:url' ;
13+ import {
14+ laneEnvelope ,
15+ type LaneEnvelope ,
16+ type LaneResult ,
17+ } from '../../../../scripts/lib/lane-envelope.ts' ;
1218
13- const ENVELOPE_SCHEMA_VERSION = 1 ;
19+ const LANE_ID = 'concurrency-torture' ;
1420
15- export type LaneEnvelope = {
16- schemaVersion : number ;
17- lane : string ;
21+ export type TortureEnvelopeData = {
1822 issue : number ;
19- commitSha : string | null ;
20- tool : { node : string } ;
21- sourceHash : string ;
2223 seedRange : { start : number ; end : number } ;
2324 runs : number ;
24- durationMs : number ;
25- result : 'pass' | 'fail' ;
2625} ;
2726
27+ export type TortureEnvelope = LaneEnvelope < TortureEnvelopeData > ;
28+
2829/** Content hash of the lane's own source, so config/tool drift is visible. */
2930function laneSourceHash ( ) : string {
3031 const dir = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
@@ -46,25 +47,28 @@ function laneSourceHash(): string {
4647export function buildEnvelope ( params : {
4748 seedStart : number ;
4849 runs : number ;
49- durationMs : number ;
50- result : 'pass' | 'fail' ;
51- } ) : LaneEnvelope {
52- return {
53- schemaVersion : ENVELOPE_SCHEMA_VERSION ,
54- lane : 'concurrency-torture' ,
55- issue : 1416 ,
56- commitSha : process . env . GITHUB_SHA ?. trim ( ) || null ,
50+ startedAtMs : number ;
51+ result : LaneResult ;
52+ } ) : TortureEnvelope {
53+ const end = params . seedStart + params . runs ;
54+ return laneEnvelope < TortureEnvelopeData > ( {
55+ lane : LANE_ID ,
56+ commit : process . env . GITHUB_SHA ?. trim ( ) || '' ,
5757 tool : { node : process . version } ,
58- sourceHash : laneSourceHash ( ) ,
59- seedRange : { start : params . seedStart , end : params . seedStart + params . runs } ,
60- runs : params . runs ,
61- durationMs : params . durationMs ,
58+ configHash : laneSourceHash ( ) ,
59+ seed : `${ params . seedStart } -${ end - 1 } ` ,
60+ startedAtMs : params . startedAtMs ,
6261 result : params . result ,
63- } ;
62+ data : {
63+ issue : 1416 ,
64+ seedRange : { start : params . seedStart , end } ,
65+ runs : params . runs ,
66+ } ,
67+ } ) ;
6468}
6569
6670/** Write the envelope to TORTURE_ENVELOPE when set; returns the path or null. */
67- export function writeEnvelopeIfRequested ( envelope : LaneEnvelope ) : string | null {
71+ export function writeEnvelopeIfRequested ( envelope : TortureEnvelope ) : string | null {
6872 const target = process . env . TORTURE_ENVELOPE ?. trim ( ) ;
6973 if ( ! target ) return null ;
7074 fs . mkdirSync ( path . dirname ( target ) , { recursive : true } ) ;
0 commit comments