Skip to content

fix(wiki): split the reap loop's delete and probe budgets [poller, docs, tests] - #199

Merged
liplus-lin-lay merged 2 commits into
mainfrom
197-specwiki-a-withheld-reap-candidate-consumes-a-delete-slot-and-can-starve-real-deletions
Aug 2, 2026
Merged

fix(wiki): split the reap loop's delete and probe budgets [poller, docs, tests]#199
liplus-lin-lay merged 2 commits into
mainfrom
197-specwiki-a-withheld-reap-candidate-consumes-a-delete-slot-and-can-starve-real-deletions

Conversation

@liplus-lin-lay

Copy link
Copy Markdown
Member

Closes #197

孤児削除で保留(withheld)になった候補が削除枠を消費していたため、安定ソートされた候補リストの先頭を保留が占め続ける間、その後ろに並ぶ「本当に削除された page」が列挙の回復まで到達すらされなかった。削除枠と probe 枠を分け、保留は probe 枠だけを消費するようにした。

  • MAX_WIKI_REAP_PROBES_PER_REPO_PER_RUN(15 = 削除枠 5 の 3 倍)を新設
  • reap ループは orphans.slice(0, deleteBudget) をやめて候補リスト全体を走査し、removed >= deleteBudget || probes >= probeBudget で break
  • orphansDeferred を「この run で到達しなかった候補数」に合わせた(到達した上での保留は従来どおり orphansWithheld
  • probe コストの上限は 15 × extension 2 = 30 subrequest。walk の fetch 予算とは別枠のまま

… [poller, docs, tests]

Split the reap loop's per-run budget in two: deletes stay on
MAX_WIKI_DELETIONS_PER_REPO_PER_RUN (5), probes move to the new
MAX_WIKI_REAP_PROBES_PER_REPO_PER_RUN (15). The loop now walks the whole
orphan candidate list and breaks on whichever budget runs out first, and
orphansDeferred reports the candidates it never reached instead of the
overflow past the delete cap.

孤児リストは安定ソートされているため、列挙が短いままだと同じ保留候補が毎 run
削除枠を埋め、その後ろに並ぶ「本当に削除された page」が列挙の回復まで到達すら
されなかった。枠を分けたことで保留は probe 枠だけを消費する。probe 上限 15 =
最大 30 subrequest で、walk の fetch 予算とは別枠のまま。

Closes #197
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 2, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
github-rag-mcp 9cd72cb Aug 02 2026, 07:19 AM

…ld-reap-candidate-consumes-a-delete-slot-and-can-starve-real-deletions

# Conflicts:
#	docs/installation.ja.md
#	docs/installation.md

@liplus-lin-lay liplus-lin-lay left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review (auto mode, parent agent)

受け入れ条件

  • 保留候補が先頭を占めた状態で、後ろの実削除が同一 run で行われる — 満たす。追加テスト 1 本目が live 5 件を z-really-deleted の前に並べ、removed: 1 / orphansWithheld: 5 / orphansDeferred: 0 を固定。旧実装ではこの構成が毎 run removed: 0 を返していた
  • per-run の probe 回数に上限があり、テストで固定されている — 満たす。2 本目が live 20 件に対し wire 上の probe request をちょうど 15 に固定
  • orphansWithheld とログの内容が従来どおり — 保留 1 件ごとの warn(alive / inconclusive の出し分け)は無変更。サマリ側の warn は文面が変わっているが、これは orphansDeferred の意味変更に追随した必然の変更で、旧文面のままだと「deferred」の語がログと実態でずれる。受け入れ条件 4 と両立させる唯一の形なので逸脱とは見なさない
  • orphansDeferred が「この run で到達しなかった候補数」を表す — 満たす。orphans.length - probesprobes++probeWikiPageAlive 呼び出しの直前に無条件で置かれているので、到達した候補は必ず probe を 1 消費する = probe 数が到達数に一致する

制約

  • gone 以外は削除しない(#187 — 判定部は無変更
  • probe の per-run 上限MAX_WIKI_REAP_PROBES_PER_REPO_PER_RUN = 15。probe は 1 候補あたり最大 2 subrequest なので上限 30、削除の fan-out が最大 5 × 約 4 = 20。walk の fetch 予算とは別枠で、invocation あたり 1000 に対して十分内側
  • 保留の可視性orphansWithheld と per-candidate ログは維持

実装の確認

ループ全体を走査して removed >= deleteBudget || probes >= probeBudget で break する形になっており、保留が削除枠を消費しない。候補リストを全部消化した場合は probes === orphans.length なので orphansDeferred は 0 に落ちる。

既知の境界(欠陥ではない)

probeBudgetWikiPollOptions に露出していない。現状 deleteBudget を上書きする呼び出し元が無いため実害は無いが、将来 deleteBudget > 15 を渡す呼び出しが出た場合、probe 枠が実効上限になる。その時点で option 化を判断すればよく、本 PR で先回りする必要はない。

scope からの逸脱

なし。PR #198 が同じ 6 ファイルを触った状態で main に入ったため origin/main を branch へ merge して解消しているが、衝突は installation docs の隣接する箇条書き 2 本のみで、両方を残す形で解決されている。src/poller.ts は自動マージ。

次のステップ

auto mode につき human gate なし。self-review pass → merge。

@liplus-lin-lay
liplus-lin-lay merged commit c549fd2 into main Aug 2, 2026
3 checks passed
@liplus-lin-lay
liplus-lin-lay deleted the 197-specwiki-a-withheld-reap-candidate-consumes-a-delete-slot-and-can-starve-real-deletions branch August 2, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spec(wiki): a withheld reap candidate consumes a delete slot and can starve real deletions

1 participant