@@ -1458,6 +1458,7 @@ const PUBLIC_STATUS_TEXT_VALUES = new Set([
14581458 "completed_exact_review_lifecycles" ,
14591459 "completed_review_journeys" ,
14601460 "durable_exact_review_lifecycles" ,
1461+ "verified_final_review_receipts" ,
14611462 "degraded" ,
14621463 "exact-review" ,
14631464 "6h" ,
@@ -1531,6 +1532,7 @@ const PUBLIC_STATUS_TEXT_VALUES = new Set([
15311532
15321533const PUBLIC_STATUS_TEXT_FIELDS = new Set ( [
15331534 "conclusion" ,
1535+ "completion_source" ,
15341536 "mode" ,
15351537 "outcome" ,
15361538 "reason" ,
@@ -1548,6 +1550,7 @@ const PUBLIC_STATUS_TEXT_FIELDS = new Set([
15481550const PUBLIC_STATUS_TIME_FIELDS = new Set ( [
15491551 "at" ,
15501552 "completed_at" ,
1553+ "ended_at" ,
15511554 "generated_at" ,
15521555 "observed_at" ,
15531556 "oldest_at" ,
@@ -1686,6 +1689,8 @@ const PUBLIC_STATUS_COUNT_FIELDS = new Set([
16861689 "longest_duration_ms" ,
16871690 "maximum_age_ms" ,
16881691 "median_ms" ,
1692+ "journey_duration_ms" ,
1693+ "bucket_minutes" ,
16891694 "oldest_age_seconds" ,
16901695 "oldest_dispatching_age_seconds" ,
16911696 "oldest_leased_age_seconds" ,
@@ -1765,6 +1770,8 @@ const PUBLIC_STATUS_CONTAINER_FIELDS = new Set([
17651770 "timeline" ,
17661771 "ci" ,
17671772 "timings" ,
1773+ "history" ,
1774+ "points" ,
17681775 "overall" ,
17691776 "terminal_buffer" ,
17701777 "recently_washed" ,
@@ -2195,6 +2202,7 @@ function publicBayTerminalOutcome(value, allowedRepositories: ReadonlySet<string
21952202 if ( ! PUBLIC_BAY_OUTCOMES . has ( outcome ) ) return null ;
21962203 const explicitRepository = typeof source . repository === "string" ? source . repository . trim ( ) : "" ;
21972204 const explicitNumber = source . item_number ?? source . number ;
2205+ const journeyDuration = source . journey_duration_ms ;
21982206 const itemKey = typeof source . item_key === "string" ? source . item_key . trim ( ) : "" ;
21992207 const keyMatch = itemKey . match ( / ^ ( [ A - Z a - z 0 - 9 _ . - ] + \/ [ A - Z a - z 0 - 9 _ . - ] + ) # ( \d + ) $ / ) ;
22002208 const repository = explicitRepository || keyMatch ?. [ 1 ] || "" ;
@@ -2212,6 +2220,13 @@ function publicBayTerminalOutcome(value, allowedRepositories: ReadonlySet<string
22122220 ) {
22132221 const canonicalRepository = repository . toLowerCase ( ) ;
22142222 if ( allowedRepositories . has ( canonicalRepository ) ) {
2223+ if (
2224+ ! Number . isSafeInteger ( journeyDuration ) ||
2225+ journeyDuration < 0 ||
2226+ journeyDuration > 24 * 60 * 60 * 1000
2227+ ) {
2228+ return { outcome } ;
2229+ }
22152230 const action = publicBayActionFromWorker (
22162231 { ...source , status : "completed" , run_url : source . run_url ?? source . job_url } ,
22172232 allowedRepositories ,
@@ -2220,6 +2235,7 @@ function publicBayTerminalOutcome(value, allowedRepositories: ReadonlySet<string
22202235 repository : canonicalRepository ,
22212236 item_number : itemNumber ,
22222237 outcome,
2238+ journey_duration_ms : journeyDuration ,
22232239 ...( action ? { action } : { } ) ,
22242240 } ;
22252241 }
@@ -5208,7 +5224,7 @@ async function exactReviewBayLifecycleMetricsSnapshot(env) {
52085224 if ( ! response . ok ) return null ;
52095225 const source = objectValue ( body . bay_lifecycle_metrics ) ;
52105226 const collection = objectValue ( source . collection ) ;
5211- if ( source . version !== 1 || collection . state !== "complete" ) return null ;
5227+ if ( source . version !== 2 || collection . state !== "complete" ) return null ;
52125228 const coverage = objectValue ( source . coverage ) ;
52135229 const timings = objectValue ( source . timings ) ;
52145230 const terminal = objectValue ( source . terminal ) ;
@@ -5218,15 +5234,12 @@ async function exactReviewBayLifecycleMetricsSnapshot(env) {
52185234 const windowMinutes = publicQueueCount ( timings . window_minutes , 24 * 60 ) ;
52195235 const sampleLimit = publicQueueCount ( timings . sample_limit , 100_000 ) ;
52205236 const overall = objectValue ( timings . overall ) ;
5237+ const history = bayLifecycleTimingHistory ( timings . history ) ;
52215238 const samples = publicQueueCount ( overall . samples , 100_000 ) ;
52225239 const average =
5223- overall . average_ms === null
5224- ? null
5225- : publicQueueCount ( overall . average_ms , 31 * 24 * 60 * 60 * 1000 ) ;
5240+ overall . average_ms === null ? null : publicQueueCount ( overall . average_ms , 24 * 60 * 60 * 1000 ) ;
52265241 const median =
5227- overall . median_ms === null
5228- ? null
5229- : publicQueueCount ( overall . median_ms , 31 * 24 * 60 * 60 * 1000 ) ;
5242+ overall . median_ms === null ? null : publicQueueCount ( overall . median_ms , 24 * 60 * 60 * 1000 ) ;
52305243 const invalidTimingAggregate =
52315244 samples === null ||
52325245 ( samples === 0 ? average !== null || median !== null : average === null || median === null ) ;
@@ -5240,10 +5253,11 @@ async function exactReviewBayLifecycleMetricsSnapshot(env) {
52405253 if (
52415254 ! startedAt ||
52425255 typeof timingComplete !== "boolean" ||
5243- sampleKind !== "completed_exact_review_lifecycles " ||
5256+ sampleKind !== "completed_final_review_journeys " ||
52445257 windowMinutes !== 60 ||
52455258 sampleLimit === null ||
52465259 invalidTimingAggregate ||
5260+ ! history ||
52475261 terminalCount === null ||
52485262 tideThreshold !== 20 ||
52495263 tideGeneration === null ||
@@ -5261,11 +5275,13 @@ async function exactReviewBayLifecycleMetricsSnapshot(env) {
52615275 timings : {
52625276 window_minutes : windowMinutes ,
52635277 // `sample_kind` is a v1 public enum. Preserve its established spelling for
5264- // strict clients, and expose the durable replacement provenance additively.
5278+ // strict clients, and expose end-to-end final-review provenance additively.
52655279 sample_kind : "completed_review_journeys" ,
52665280 source : "durable_exact_review_lifecycles" ,
5281+ completion_source : "verified_final_review_receipts" ,
52675282 sample_limit : sampleLimit ,
52685283 overall : { average_ms : average , median_ms : median , samples } ,
5284+ history,
52695285 } ,
52705286 terminal_count : terminalCount ,
52715287 tide_threshold : tideThreshold ,
@@ -5284,18 +5300,55 @@ function bayLifecycleTerminalRows(value) {
52845300 const itemKey = String ( row . item_key || "" ) . toLowerCase ( ) ;
52855301 const outcome = String ( row . outcome || "" ) ;
52865302 const completedAt = publicQueueTimestamp ( row . completed_at ) ;
5303+ const journeyDuration = publicQueueCount ( row . journey_duration_ms , 24 * 60 * 60 * 1000 ) ;
52875304 if (
52885305 ! / ^ [ a - z 0 - 9 _ . - ] + \/ [ a - z 0 - 9 _ . - ] + # [ 1 - 9 ] \d * $ / . test ( itemKey ) ||
52895306 ! [ "success" , "failure" , "cancelled" ] . includes ( outcome ) ||
5290- ! completedAt
5307+ ! completedAt ||
5308+ journeyDuration === null
52915309 ) {
52925310 return null ;
52935311 }
5294- rows . push ( { item_key : itemKey , outcome, completed_at : completedAt } ) ;
5312+ rows . push ( {
5313+ item_key : itemKey ,
5314+ outcome,
5315+ completed_at : completedAt ,
5316+ journey_duration_ms : journeyDuration ,
5317+ } ) ;
52955318 }
52965319 return rows ;
52975320}
52985321
5322+ function bayLifecycleTimingHistory ( value ) {
5323+ const source = objectValue ( value ) ;
5324+ const points = source && Array . isArray ( source . points ) ? source . points : null ;
5325+ if ( ! source || source . bucket_minutes !== 5 || ! points || points . length > 12 ) return null ;
5326+ const result = [ ] ;
5327+ let previousEndedAt = 0 ;
5328+ for ( const point of points ) {
5329+ const row = objectValue ( point ) ;
5330+ const endedAt = row && publicQueueTimestamp ( row . ended_at ) ;
5331+ const average = row && publicQueueCount ( row . average_ms , 24 * 60 * 60 * 1000 ) ;
5332+ const median = row && publicQueueCount ( row . median_ms , 24 * 60 * 60 * 1000 ) ;
5333+ const samples = row && publicQueueCount ( row . samples , 100_000 ) ;
5334+ const endedAtMs = endedAt ? Date . parse ( endedAt ) : Number . NaN ;
5335+ if (
5336+ ! endedAt ||
5337+ ! Number . isFinite ( endedAtMs ) ||
5338+ endedAtMs <= previousEndedAt ||
5339+ average === null ||
5340+ median === null ||
5341+ samples === null ||
5342+ samples < 1
5343+ ) {
5344+ return null ;
5345+ }
5346+ previousEndedAt = endedAtMs ;
5347+ result . push ( { ended_at : endedAt , average_ms : average , median_ms : median , samples } ) ;
5348+ }
5349+ return { bucket_minutes : 5 , points : result } ;
5350+ }
5351+
52995352async function authenticatedExactReviewEnqueue ( request , env ) {
53005353 const secret = stringEnv ( env . CLAWSWEEPER_WEBHOOK_SECRET ) ;
53015354 if ( ! secret ) return json ( { error : "webhook_not_configured" } , 503 ) ;
@@ -6149,6 +6202,7 @@ async function statusSnapshot(env) {
61496202 if (
61506203 cachedTimings . sample_kind === "completed_review_journeys" &&
61516204 cachedTimings . source === "durable_exact_review_lifecycles" &&
6205+ cachedTimings . completion_source === "verified_final_review_receipts" &&
61526206 scopedCached === cached
61536207 ) {
61546208 return cachedProjection ;
@@ -6375,8 +6429,10 @@ async function statusSnapshot(env) {
63756429 window_minutes : BAY_TIMING_WINDOW_MS / 60_000 ,
63766430 sample_kind : "completed_review_journeys" ,
63776431 source : "durable_exact_review_lifecycles" ,
6432+ completion_source : "verified_final_review_receipts" ,
63786433 sample_limit : 0 ,
63796434 overall : { average_ms : null , median_ms : null , samples : 0 } ,
6435+ history : { bucket_minutes : 5 , points : [ ] } ,
63806436 } ,
63816437 } ;
63826438 const { recent_attempts : _recentAttempts , ...publicWorkerHealth } = workerHealth ;
0 commit comments