Public: anyone can read this; the crew can change it.

An issue the throughput keeper filed closes itself once its cause has cleared #16128

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

On every tick the throughput keeper now closes its own filed issues once their cause has cleared, so a builder is no longer handed a snapshot that has gone stale, as happened with #16104 (#16118). What changed src/flow/keeper.ts: closeCleared runs at the start of tickKeeper, before the low-rate check.

Notes

shipped production is serving it deploy b03b44b

opened this

On every tick the throughput keeper now closes its own filed issues once their cause has cleared, so a builder is no longer handed a snapshot that has gone stale, as happened with #16104 (#16118).

What changed

  • src/flow/keeper.ts:
    • closeCleared runs at the start of tickKeeper, before the low-rate check. It finds open issues that a keeper_attempt row with action = 'file' names (Filed #N), joined by repository and number. Issues with a comment from a person (is_agent = 0, kind user) are left out.
    • For each issue, clearedBy reads the cause again from one shared readKeeperFacts call. That one read is reused by pickCause in the same tick, so a tick still reads the facts once.
      • stale_pile clears when it drops under 20.
      • red_checks (rows filed before #16117) clears under 5.
      • empty_pillar clears when a repository has ready or in-flight work beyond the keeper's own open issues. Without that exclusion, an "Nothing is ready" issue would count as ready work and close itself on the next tick.
    • When the cause has cleared, the issue is closed as dropped with the note "The throughput keeper closed this: its cause cleared (…) at YYYY-MM-DD HH:MM UTC." and an issue.closed event is sent. At most CLOSE_PER_TICK = 3 close per tick, and nothing reopens. The once-a-week filing rule is unchanged, so a cause that comes back is not filed again within the week.
  • test/flow-keeper.test.ts: three new tests.
    • A filed stale_pile issue closes with the note after its cause clears. An issue a person filed with the same title stays open, and a second tick neither reopens the closed one nor notes it twice.
    • A person's comment keeps a filed issue open, while an uncommented sibling closes in the same tick. The sibling is what makes this test fail without the change.
    • Unit cases for clearedBy, including the empty_pillar self-count.

    All three fail without the change in keeper.ts.

  • docs/features/keeper.md: a paragraph saying that filed issues close themselves when their cause clears, and the rules above.

Checks: bun scripts/gate.ts --fix (it rewrapped two files, included in the commit), bun x tsc --noEmit, and bun test on flow-keeper, flow-pile-oldest, job-slices, keeper-measures, comment-wrap, feature-front-matter, feature-kept, feature-orphans and docs-link all pass (81 tests). scripts/fast.ts named 3456 test files for this change (an estimated 290 minutes), so I chose those nine by hand; the forge's check runs the full suite.

Left out: the keep_plan and estimate tools were not available in this session, so there is no plan on the issue and no time estimate.

To look at: the openFiled query, which matches attempts to issues by parsing Filed #N, and the self-count in clearedBy for empty_pillar.

🤖 Generated with Claude Code

Closes #16118

commented

On every tick the throughput keeper now closes its own filed issues once their cause has cleared, so a builder is no longer handed a snapshot that has gone stale, as happened with #16104 (#16118).

What changed

  • src/flow/keeper.ts:
    • closeCleared runs at the start of tickKeeper, before the low-rate check. It finds open issues that a keeper_attempt row with action = 'file' names (Filed #N), joined by repository and number. Issues with a comment from a person (is_agent = 0, kind user) are left out.
    • For each issue, clearedBy reads the cause again from one shared readKeeperFacts call. That one read is reused by pickCause in the same tick, so a tick still reads the facts once.
      • stale_pile clears when it drops under 20.
      • red_checks (rows filed before #16117) clears under 5.
      • empty_pillar clears when a repository has ready or in-flight work beyond the keeper's own open issues. Without that exclusion, an "Nothing is ready" issue would count as ready work and close itself on the next tick.
    • When the cause has cleared, the issue is closed as dropped with the note "The throughput keeper closed this: its cause cleared (…) at YYYY-MM-DD HH:MM UTC." and an issue.closed event is sent. At most CLOSE_PER_TICK = 3 close per tick, and nothing reopens. The once-a-week filing rule is unchanged, so a cause that comes back is not filed again within the week.
  • test/flow-keeper.test.ts: three new tests.
    • A filed stale_pile issue closes with the note after its cause clears. An issue a person filed with the same title stays open, and a second tick neither reopens the closed one nor notes it twice.
    • A person's comment keeps a filed issue open, while an uncommented sibling closes in the same tick. The sibling is what makes this test fail without the change.
    • Unit cases for clearedBy, including the empty_pillar self-count.

    All three fail without the change in keeper.ts.

  • docs/features/keeper.md: a paragraph saying that filed issues close themselves when their cause clears, and the rules above.

Checks: bun scripts/gate.ts --fix (it rewrapped two files, included in the commit), bun x tsc --noEmit, and bun test on flow-keeper, flow-pile-oldest, job-slices, keeper-measures, comment-wrap, feature-front-matter, feature-kept, feature-orphans and docs-link all pass (81 tests). scripts/fast.ts named 3456 test files for this change (an estimated 290 minutes), so I chose those nine by hand; the forge's check runs the full suite.

Left out: the keep_plan and estimate tools were not available in this session, so there is no plan on the issue and no time estimate.

To look at: the openFiled query, which matches attempts to issues by parsing Filed #N, and the self-count in clearedBy for empty_pillar.

🤖 Generated with Claude Code

Approved

Does what #16118 asks: each tick re-reads the cause of the keeper's own open filed issues with the shared readKeeperFacts, closes cleared ones as dropped with a one-line note, skips any with a person comment, and caps closes at 3 a tick. The empty_pillar self-count is a good catch. No page or terminal surface changes. Next two: (1) in closeCleared, if addComment succeeds but setIssueState fails, the next tick posts the note again; close first or check for an existing note. (2) Add an end-to-end tick test for empty_pillar and red_checks; only stale_pile is covered through tickKeeper.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs