@@ -4961,13 +4961,14 @@ jobs:
49614961 stale_min_age_days="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.apply_stale_min_age_days || '60' }}"
49624962 close_delay_ms="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.apply_close_delay_ms || '2000' }}"
49634963 checkpoint_size="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.apply_checkpoint_size || '40' }}"
4964- comment_sync_processed_limit=1000
4964+ comment_sync_processed_limit=40
49654965 base_close_processed_limit=600
49664966 close_processed_limit="$base_close_processed_limit"
49674967 adaptive_apply_scan_reason="base_window"
49684968 sync_batch_size="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.apply_limit || '25' }}"
49694969 item_numbers="${{ github.event_name == 'repository_dispatch' && github.event.client_payload.item_number || github.event.inputs.apply_item_numbers || '' }}"
4970- sync_open_pr_batch="${{ github.event_name == 'schedule' && github.event.schedule == '6,21,36,51 * * * *' && 'true' || 'false' }}"
4970+ scheduled_comment_sync="${{ github.event_name == 'schedule' && github.event.schedule == '6,21,36,51 * * * *' && 'true' || 'false' }}"
4971+ sync_open_pr_batch="$scheduled_comment_sync"
49714972 if [ "$item_numbers" = "__cursor__" ]; then
49724973 sync_open_pr_batch="true"
49734974 item_numbers=""
@@ -5011,11 +5012,8 @@ jobs:
50115012 candidate_counts_json=""
50125013 cursor_advance_count=""
50135014 coverage_proof_item_numbers=""
5014- if [ "$sync_open_pr_batch" = "true" ]; then
5015- sync_comments_only="true"
5016- apply_kind="pull_request"
5017- comment_sync_min_age_days="0"
5018- fi
5015+ normalize_comment_sync_mode
5016+ prepare_comment_sync_batch
50195017 sync_comments_arg=()
50205018 if [ "$sync_comments_only" = "true" ]; then
50215019 sync_comments_arg=(--sync-comments-only)
@@ -5047,6 +5045,8 @@ jobs:
50475045 item_numbers="$(awk -F= '$1 == "item_numbers" { print $2 }' "$batch_env")"
50485046 next_cursor="$(awk -F= '$1 == "next_cursor" { print $2 }' "$batch_env")"
50495047 batch_count="$(awk -F= '$1 == "count" { print $2 }' "$batch_env")"
5048+ trim_comment_sync_cycle_batch
5049+ [ -n "$item_numbers" ] || batch_count=0
50505050 if [ "${batch_count:-0}" -eq 0 ]; then
50515051 pnpm run status -- \
50525052 --target-repo "$TARGET_REPO" \
@@ -5123,18 +5123,16 @@ jobs:
51235123 --close-delay-ms "$close_delay_ms" \
51245124 --progress-every "$progress_every" \
51255125 --processed-limit "$comment_sync_processed_limit" \
5126+ --max-runtime-ms 300000 \
5127+ --cursor-trace ".artifacts/comment-sync-trace-$checkpoint.json" \
51265128 --comment-sync-min-age-days "$comment_sync_min_age_days" \
51275129 "${item_numbers_arg[@]}" \
51285130 "${sync_comments_arg[@]}"
51295131 cp apply-report.json ".artifacts/apply-reports/apply-report-$checkpoint.json"
51305132 result_count="$(pnpm run --silent workflow -- count-report --report ".artifacts/apply-reports/apply-report-$checkpoint.json")"
51315133 synced_count="$(pnpm run --silent workflow -- count-actions --report ".artifacts/apply-reports/apply-report-$checkpoint.json" --action review_comment_synced)"
5132- if [ "$sync_open_pr_batch" = "true" ]; then
5133- pnpm run workflow -- write-comment-sync-cursor \
5134- --cursor-path "$cursor_path" \
5135- --next-cursor "$next_cursor" \
5136- --target-repo "$TARGET_REPO"
5137- fi
5134+ comment_sync_checkpoint_items="$item_numbers"
5135+ complete_comment_sync_batch ".artifacts/apply-reports/apply-report-$checkpoint.json" ".artifacts/comment-sync-trace-$checkpoint.json"
51385136 publish_changes "chore: sync sweep review comments checkpoint $checkpoint" records apply-report.json results/comment-sync-cursors
51395137 comment_sync_health_cursor_path=""
51405138 comment_sync_health_cursor_required="false"
@@ -5144,11 +5142,11 @@ jobs:
51445142 comment_sync_health_cursor_required="true"
51455143 comment_sync_health_processed_limit="$sync_batch_size"
51465144 fi
5147- write_apply_health ".artifacts/apply-reports/apply-report-$checkpoint.json" ".artifacts/apply-health-$checkpoint.json" "comment_sync" "$comment_sync_health_processed_limit" "$comment_sync_health_cursor_path" "$comment_sync_health_cursor_required" "" "" " "
5145+ write_comment_sync_health ".artifacts/apply-reports/apply-report-$checkpoint.json" ".artifacts/apply-health-$checkpoint.json"
51485146 pnpm run status -- \
51495147 --target-repo "$TARGET_REPO" \
51505148 --state "Apply comments synced" \
5151- --detail "Comment-only apply checkpoint $checkpoint finished. Synced durable review comments: $synced_count. Result records: $result_count. Item numbers: ${item_numbers :-all}. Next cursor: ${next_cursor:-none}." \
5149+ --detail "Comment-only apply checkpoint $checkpoint finished. Synced durable review comments: $synced_count. Result records: $result_count. Item numbers: ${comment_sync_checkpoint_items :-all}. Next cursor: ${next_cursor:-none}." \
51525150 --run-url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
51535151 --apply-health-file ".artifacts/apply-health-$checkpoint.json"
51545152 publish_status "chore: update sweep comment sync status"
@@ -5281,6 +5279,7 @@ jobs:
52815279 final_health_cursor_path="$cursor_path"
52825280 final_health_cursor_required="true"
52835281 final_health_processed_limit="$sync_batch_size"
5282+ final_health_cursor_advance_count="$comment_sync_cursor_advance_count"
52845283 fi
52855284 fi
52865285 write_apply_health "apply-report.json" ".artifacts/apply-health-final.json" "$final_health_mode" "$final_health_processed_limit" "$final_health_cursor_path" "$final_health_cursor_required" "$final_health_candidate_count" "$final_health_scheduled_interval_minutes" "$final_health_cursor_advance_count" "$final_health_candidate_counts_json"
@@ -5397,11 +5396,6 @@ jobs:
53975396 echo "Apply checkpoint has no continuation work; not queueing another apply run."
53985397 exit 0
53995398 fi
5400- if [ "${APPLY_SYNC_COMMENTS_ONLY:-false}" = "true" ]; then
5401- echo "Comment-only apply run finished; not queueing another apply run."
5402- exit 0
5403- fi
5404-
54055399 can_share_apply_continuation=false
54065400 if [ "${APPLY_AUTO_SELECTED_BATCH:-false}" = "true" ] &&
54075401 [ -z "${APPLY_ITEM_NUMBERS:-}" ] &&
0 commit comments