@@ -67,6 +67,7 @@ type ApplySkipNextAction = {
6767 bucket :
6868 | "review_refresh"
6969 | "close_coverage_proof"
70+ | "conversation_unlock"
7071 | "maintainer_review"
7172 | "stable_skip"
7273 | "report_quality_repair"
@@ -81,6 +82,8 @@ type ApplySkipNextAction = {
8182 summary : string ;
8283 next_step : string ;
8384} ;
85+
86+ type ApplySkipNextActionDetail = Omit < ApplySkipNextAction , "reason" | "count" > ;
8487const args = parseArgs ( process . argv . slice ( 2 ) ) ;
8588
8689function runCli ( ) : void {
@@ -490,151 +493,155 @@ function applyNextActionBucketRank(bucket: ApplySkipNextAction["bucket"]): numbe
490493 "close_coverage_proof" ,
491494 "report_quality_repair" ,
492495 "defer_until_closing_pr" ,
496+ "conversation_unlock" ,
493497 "maintainer_review" ,
494498 "stable_skip" ,
495499 "already_resolved" ,
496500 "inspect" ,
497501 ] . indexOf ( bucket ) ;
498502}
499503
504+ const APPLY_SKIP_NEXT_ACTION_DETAILS : Record < string , ApplySkipNextActionDetail > = {
505+ skipped_changed_since_review : {
506+ bucket : "review_refresh" ,
507+ owner : "clawsweeper" ,
508+ retryable : true ,
509+ label : "Refresh review" ,
510+ summary : "The item changed after the review that proposed closing it." ,
511+ next_step : "Queue a fresh ClawSweeper review before any close retry." ,
512+ } ,
513+ skipped_stale_review_comment_sync : {
514+ bucket : "review_refresh" ,
515+ owner : "clawsweeper" ,
516+ retryable : true ,
517+ label : "Refresh review state" ,
518+ summary : "The durable review comment is newer than the local review report." ,
519+ next_step : "Queue a fresh review instead of overwriting the newer durable comment." ,
520+ } ,
521+ skipped_pr_close_coverage_proof : {
522+ bucket : "close_coverage_proof" ,
523+ owner : "clawsweeper" ,
524+ retryable : true ,
525+ label : "Add close proof" ,
526+ summary : "The PR close proposal needs positive coverage proof before apply can close it." ,
527+ next_step : "Run or refresh close-coverage proof for the canonical and covered PR pair." ,
528+ } ,
529+ retry_pr_close_coverage_proof : {
530+ bucket : "close_coverage_proof" ,
531+ owner : "clawsweeper" ,
532+ retryable : true ,
533+ label : "Retry close proof" ,
534+ summary : "The close-coverage proof check failed transiently before reaching a decision." ,
535+ next_step : "Inspect the proof failure, then retry after model and GitHub access recover." ,
536+ } ,
537+ skipped_protected_label : maintainerDecisionAction ( ) ,
538+ skipped_policy_exempt : maintainerDecisionAction ( ) ,
539+ skipped_maintainer_authored : {
540+ bucket : "maintainer_review" ,
541+ owner : "maintainer" ,
542+ retryable : false ,
543+ label : "Maintainer-authored" ,
544+ summary : "Automation does not close maintainer-authored items without human judgement." ,
545+ next_step : "Route to maintainer review or close manually if the owner agrees." ,
546+ } ,
547+ skipped_locked_conversation : {
548+ bucket : "conversation_unlock" ,
549+ owner : "maintainer" ,
550+ retryable : false ,
551+ label : "Conversation locked" ,
552+ summary : "GitHub blocked the durable comment write because the conversation is locked." ,
553+ next_step : "Unlock the conversation before retrying comment sync, or leave it unchanged." ,
554+ } ,
555+ skipped_same_author_pair : {
556+ bucket : "stable_skip" ,
557+ owner : "none" ,
558+ retryable : false ,
559+ label : "Stable skip" ,
560+ summary :
561+ "The source and canonical items have the same author, so automated duplicate close is intentionally conservative." ,
562+ next_step : "Leave as a stable skip unless maintainers change the same-author close policy." ,
563+ } ,
564+ skipped_invalid_decision : reportRepairAction ( ) ,
565+ skipped_missing_record : reportRepairAction ( ) ,
566+ skipped_open_closing_pr : {
567+ bucket : "defer_until_closing_pr" ,
568+ owner : "github" ,
569+ retryable : false ,
570+ label : "Wait for closing PR" ,
571+ summary : "The item appears covered by a pull request that is still open." ,
572+ next_step : "Defer until the linked closing PR merges, closes, or changes state." ,
573+ } ,
574+ skipped_runtime_budget : {
575+ bucket : "run_budget" ,
576+ owner : "clawsweeper" ,
577+ retryable : true ,
578+ label : "Runtime budget" ,
579+ summary : "The apply lane stopped because it reached its bounded runtime." ,
580+ next_step : "Let the next scheduled run continue; tune runtime or batch size if this repeats." ,
581+ } ,
582+ skipped_live_fetch_failed : {
583+ bucket : "live_state_recovery" ,
584+ owner : "github" ,
585+ retryable : true ,
586+ label : "Recover live check" ,
587+ summary : "ClawSweeper could not confirm live GitHub state before mutating." ,
588+ next_step : "Inspect auth, API, or rate-limit failures and retry after live checks recover." ,
589+ } ,
590+ skipped_comment_auth : {
591+ bucket : "live_state_recovery" ,
592+ owner : "clawsweeper" ,
593+ retryable : true ,
594+ label : "Repair comment auth" ,
595+ summary : "GitHub rejected the durable review comment write as unauthenticated." ,
596+ next_step : "Repair the GitHub App write token before retrying comment sync." ,
597+ } ,
598+ skipped_not_open : alreadyResolvedAction ( ) ,
599+ skipped_already_closed : alreadyResolvedAction ( ) ,
600+ skipped_closed : alreadyResolvedAction ( ) ,
601+ } ;
602+
500603function applySkipNextAction ( reason : string , count : number ) : ApplySkipNextAction {
501- if ( reason === "skipped_changed_since_review" ) {
502- return {
503- reason,
504- count,
505- bucket : "review_refresh" ,
506- owner : "clawsweeper" ,
507- retryable : true ,
508- label : "Refresh review" ,
509- summary : "The item changed after the review that proposed closing it." ,
510- next_step : "Queue a fresh ClawSweeper review before any close retry." ,
511- } ;
512- }
513- if ( reason === "skipped_pr_close_coverage_proof" ) {
514- return {
515- reason,
516- count,
517- bucket : "close_coverage_proof" ,
518- owner : "clawsweeper" ,
519- retryable : true ,
520- label : "Add close proof" ,
521- summary : "The PR close proposal needs coverage proof before it can be applied." ,
522- next_step : "Run or refresh close-coverage proof for the canonical/covered PR pair." ,
523- } ;
524- }
525- if ( reason === "skipped_protected_label" || reason === "skipped_policy_exempt" ) {
526- return {
527- reason,
528- count,
529- bucket : "maintainer_review" ,
530- owner : "maintainer" ,
531- retryable : false ,
532- label : "Maintainer decision" ,
533- summary : "A protected label or policy exemption blocks automated pruning." ,
534- next_step : "Have a maintainer confirm the label/policy should remain or close manually." ,
535- } ;
536- }
537- if ( reason === "skipped_maintainer_authored" ) {
538- return {
539- reason,
540- count,
541- bucket : "maintainer_review" ,
542- owner : "maintainer" ,
543- retryable : false ,
544- label : "Maintainer-authored" ,
545- summary : "Automation does not close maintainer-authored items without human judgement." ,
546- next_step : "Route to maintainer review or close manually if the owner agrees." ,
547- } ;
548- }
549- if ( reason === "skipped_same_author_pair" ) {
550- return {
551- reason,
552- count,
553- bucket : "stable_skip" ,
554- owner : "none" ,
555- retryable : false ,
556- label : "Stable skip" ,
557- summary :
558- "The source and canonical items have the same author, so automated duplicate close is intentionally conservative." ,
559- next_step : "Leave as a stable skip unless maintainers change the same-author close policy." ,
560- } ;
561- }
562- if ( reason === "skipped_invalid_decision" ) {
563- return {
564- reason,
565- count,
566- bucket : "report_quality_repair" ,
567- owner : "clawsweeper" ,
568- retryable : true ,
569- label : "Repair review report" ,
570- summary : "The durable review decision was incomplete or invalid for apply." ,
571- next_step : "Queue report-quality repair or re-review so the close decision becomes valid." ,
572- } ;
573- }
574- if ( reason === "skipped_open_closing_pr" ) {
575- return {
576- reason,
577- count,
578- bucket : "defer_until_closing_pr" ,
579- owner : "github" ,
580- retryable : false ,
581- label : "Wait for closing PR" ,
582- summary : "The item appears covered by a pull request that is still open." ,
583- next_step : "Defer until the linked closing PR merges, closes, or changes state." ,
584- } ;
585- }
586- if ( reason === "skipped_runtime_budget" ) {
587- return {
588- reason,
589- count,
590- bucket : "run_budget" ,
591- owner : "clawsweeper" ,
592- retryable : true ,
593- label : "Runtime budget" ,
594- summary : "The apply lane stopped because it reached its bounded runtime." ,
595- next_step : "Let the next scheduled run continue; tune runtime or batch size if this repeats." ,
596- } ;
597- }
598- if ( reason === "skipped_live_fetch_failed" ) {
599- return {
600- reason,
601- count,
602- bucket : "live_state_recovery" ,
603- owner : "github" ,
604- retryable : true ,
605- label : "Recover live check" ,
606- summary : "ClawSweeper could not confirm live GitHub state before mutating." ,
607- next_step :
608- "Inspect auth, API, or rate-limit failures and retry only after live checks recover." ,
609- } ;
610- }
611- if (
612- reason === "skipped_not_open" ||
613- reason === "skipped_already_closed" ||
614- reason === "skipped_closed"
615- ) {
616- return {
617- reason,
618- count,
619- bucket : "already_resolved" ,
620- owner : "none" ,
621- retryable : false ,
622- label : "Already resolved" ,
623- summary : "The item was not open by the time apply checked it." ,
624- next_step :
625- "No action is normally needed; investigate only if this bucket dominates repeated runs." ,
626- } ;
627- }
628- return {
629- reason,
630- count,
604+ const detail = APPLY_SKIP_NEXT_ACTION_DETAILS [ reason ] ?? {
631605 bucket : "inspect" ,
632606 owner : "maintainer" ,
633607 retryable : false ,
634608 label : "Inspect skip" ,
635609 summary : "Apply reported an unmapped skip bucket." ,
636- next_step :
637- "Inspect the workflow run and add a deterministic next-action mapping if this repeats." ,
610+ next_step : "Inspect the workflow run and add a deterministic mapping if this repeats." ,
611+ } ;
612+ return { reason, count, ...detail } ;
613+ }
614+
615+ function maintainerDecisionAction ( ) : ApplySkipNextActionDetail {
616+ return {
617+ bucket : "maintainer_review" ,
618+ owner : "maintainer" ,
619+ retryable : false ,
620+ label : "Maintainer decision" ,
621+ summary : "A protected label or policy exemption blocks automated pruning." ,
622+ next_step : "Confirm the policy should remain, or close manually if it should not." ,
623+ } ;
624+ }
625+
626+ function reportRepairAction ( ) : ApplySkipNextActionDetail {
627+ return {
628+ bucket : "report_quality_repair" ,
629+ owner : "clawsweeper" ,
630+ retryable : true ,
631+ label : "Repair review report" ,
632+ summary : "The durable review record is missing or invalid for apply." ,
633+ next_step : "Queue a fresh review so apply receives a complete, valid decision." ,
634+ } ;
635+ }
636+
637+ function alreadyResolvedAction ( ) : ApplySkipNextActionDetail {
638+ return {
639+ bucket : "already_resolved" ,
640+ owner : "none" ,
641+ retryable : false ,
642+ label : "Already resolved" ,
643+ summary : "The item was not open by the time apply checked it." ,
644+ next_step : "No action is needed unless this bucket dominates repeated runs." ,
638645 } ;
639646}
640647function applyReportHealthSummary ( options : {
0 commit comments