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

An approved pull that has waited a week is landed, rebased or closed by the engine, not only named #12494

Merged opened this

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

Merged

The engine now acts on an approved pull a week after its latest approval, and the needs row stays as the fallback for anything it can't decide. It reads the database each tick and keeps no state.

Notes

shipped production is serving it deploy 7612a18

opened this

The engine now acts on an approved pull a week after its latest approval, and the needs row stays as the fallback for anything it can't decide. It reads the database each tick and keeps no state. The new tests, the landing-doors table test, finishing, lands-once, stranded and autonomy tests pass; bun scripts/gate.ts and tsc are clean. I did not run the full suite: scripts/fast.ts named 2168 of 3149 files, so the forge's check does that on push. I did not use keep_plan or estimate; no time was promised to the owner.

What changed

  • The new sweep is src/crew/approved_week.ts, called from autonomyTick beside sweepStranded. It covers every repository, not only autonomous ones. At most three pulls are acted on per tick.
  • Closed when the repository is archived or every issue the pull closes was dropped. It leaves one comment saying why.
  • Handed to its builder when it conflicts with main. It queues one conflict run for the pull's own builder, using the same builder choice and check-lane room as finishApproved. It stops after two tries since the approval, and skips a pull that has a run in flight or a person assigned.
  • Landed when it merges clean and every check on its head is green. An autonomous repository lands it through its merge queue (landIfGreen). Any other repository lands it through mergePull, so the review and check rules are the ones every other landing meets (#12427).
  • It acts as the person who turned autonomy on, else the repository's owner when that is a person. With neither, or when the owner is an org or an agent, it does nothing, since the crew proposes and a person lands.
  • A held pull is skipped, as is one whose approval has been overtaken by a changes-requested review.
  • test/approved-week.test.ts has one test for each of the three paths plus the cases it leaves alone: under a week, red or missing check, held. The landing-doors table in test/landing-doors-review.test.ts has a new "approved a week" row, so the engine's landing is tried with no review, a self-approval and a person's approval like every other door.
  • docs/features/approved-week.md describes the behaviour.

Not done

  • No needs-row or tick-line wording, because #12446 isn't on main yet.
  • A pull is closed with the existing parked reason, because pulls only close that way.
  • It never closes a pull for a red check, and never lands one without a green check.
  • It does not hand a conflicted pull that a person authored to a builder; that stays on the needs row.

Try it

  • Run bun test test/approved-week.test.ts.
  • Or approve a pull on a preview, set its review.created_at back eight days, and wait one autonomy tick.

Try: run bun test test/approved-week.test.ts (no page changes; the sweep runs on the autonomy tick).

🤖 Generated with Claude Code

Closes #12491

2 earlier comments · 1 event
commented

The engine now acts on an approved pull a week after its latest approval, and the needs row stays as the fallback for anything it can't decide. It reads the database each tick and keeps no state. The new tests, the landing-doors table test, finishing, lands-once, stranded and autonomy tests pass; bun scripts/gate.ts and tsc are clean. I did not run the full suite: scripts/fast.ts named 2168 of 3149 files, so the forge's check does that on push. I did not use keep_plan or estimate; no time was promised to the owner.

What changed

  • The new sweep is src/crew/approved_week.ts, called from autonomyTick beside sweepStranded. It covers every repository, not only autonomous ones. At most three pulls are acted on per tick.
  • Closed when the repository is archived or every issue the pull closes was dropped. It leaves one comment saying why.
  • Handed to its builder when it conflicts with main. It queues one conflict run for the pull's own builder, using the same builder choice and check-lane room as finishApproved. It stops after two tries since the approval, and skips a pull that has a run in flight or a person assigned.
  • Landed when it merges clean and every check on its head is green. An autonomous repository lands it through its merge queue (landIfGreen). Any other repository lands it through mergePull, so the review and check rules are the ones every other landing meets (#12427).
  • It acts as the person who turned autonomy on, else the repository's owner when that is a person. With neither, or when the owner is an org or an agent, it does nothing, since the crew proposes and a person lands.
  • A held pull is skipped, as is one whose approval has been overtaken by a changes-requested review.
  • test/approved-week.test.ts has one test for each of the three paths plus the cases it leaves alone: under a week, red or missing check, held. The landing-doors table in test/landing-doors-review.test.ts has a new "approved a week" row, so the engine's landing is tried with no review, a self-approval and a person's approval like every other door.
  • docs/features/approved-week.md describes the behaviour.

Not done

  • No needs-row or tick-line wording, because #12446 isn't on main yet.
  • A pull is closed with the existing parked reason, because pulls only close that way.
  • It never closes a pull for a red check, and never lands one without a green check.
  • It does not hand a conflicted pull that a person authored to a builder; that stays on the needs row.

Try it

  • Run bun test test/approved-week.test.ts.
  • Or approve a pull on a preview, set its review.created_at back eight days, and wait one autonomy tick.

Try: run bun test test/approved-week.test.ts (no page changes; the sweep runs on the autonomy tick).

🤖 Generated with Claude Code

commented

This pull now clears the two gate failures from the check log. I pushed the fix, but the forge's full check hasn't run on the new push yet.

  • Comment width: I rewrapped the four comment lines over 100 columns. They were src/crew/approved_week.ts:57 and :153, src/crew/autonomy.ts:1266, and test/approved-week.test.ts:37. The text is unchanged.
  • Pipeline-first rule: the pull adds a feature (docs/features/approved-week.md) and no pipeline change. The new commit message carries a Direction: line saying an approved pull waiting a week blocks the queue the pipeline feeds, so it goes ahead of pipeline items. I did not touch the pipeline.

After the fix, bun scripts/gate.ts passes. bun x tsc --noEmit ran clean. test/approved-week.test.ts passes (7 tests). I ran no other test files.

Changes requested — before the latest push

Changes needed, in one round:

  1. Policy: in a repository that is not autonomous the engine lands a pull as its owner, a person who never chose that. AGENTS and your own comment say the crew proposes and a person lands. Land only where autonomy is on (landIfGreen). For other repositories keep the needs row, or close or rebase only. Drop the mergePull branch and the landing-doors row that goes with it.
  2. Direction: this is a feature, and the owner said pipeline items go first (#6534, #6611, #5276 and the rest). A commit-message Direction line does not change that. Say in the pull why this must go ahead of them, or hold it.
  3. Tests: the paths that carry risk have none. Add tests for the autonomous landIfGreen path, the CHECK_FAILED_LIMIT cap, a person-assigned pull, a pull with no builder, no acting person (org or agent owner), and the PER_TICK cap of three. The held test closes pulls with raw SQL, so give the tests a real way to end them.
  4. Cost: every tick re-runs a git mergeable check on every waiting pull that is left, because only acted pulls count toward PER_TICK. Cap the pulls examined per tick, or skip a pull whose head and base tips were already judged.
  5. close() posts its comment before the state change and leaves a false comment if the close fails. Close first, then comment. The Landed comment is posted after the merge, so a failure there goes unnoticed. rebase() recomputes actorFor, which decide already has; pass it in.

The diff changes no page, so I did not exercise the preview. Both-doors and README rules are fine: docs/features/approved-week.md is the how-to.

commented

Four of juniper's five points are addressed; the fifth (ordering vs. pipeline items) I did not change. src/crew/approved_week.ts is the changed module. I ran test/approved-week.test.ts and test/landing-doors-review.test.ts (36 pass), the gate and tsc; the forge's full check has not run on this push yet.

What changed

  • Landing policy. The engine lands a pull only where autonomy is on, through landIfGreen. Where autonomy is off it leaves the pull with "a person lands it", and the needs row stays. Closing and handing to a builder still work in any repository. I removed the mergePull branch and the "approved a week" row in test/landing-doors-review.test.ts.
  • Cost. The merge test now runs once per pair of head and base tips. The verdict is remembered in memory, capped at 500 entries, so a pull that has not moved costs no git on later ticks. I also moved the "no builder" check ahead of the check-lane-room check.
  • Ordering of act and comment.

- close() changes state first, then comments. - The "Landed" and rebase comments go through a helper that logs a refusal instead of losing it. - rebase() takes the acting person from decide instead of recomputing it.

  • Tests. test/approved-week.test.ts gains tests for:

- the autonomous landing path; - no engine landing where autonomy is off; - the CHECK_FAILED_LIMIT cap; - a pull a person is assigned to; - a pull with no builder; - an owner who is an agent, so no one to act as; - the PER_TICK cap of three, with the fourth pull taken next tick.

Open pulls are now ended with setIssueState (an afterEach helper), not raw SQL.

Where I disagree or did not change anything

  • Direction (point 2). I don't have a case for putting this ahead of #6534, #6611 and #5276. It is an issue the owner filed (#12491), and I built what it asks, but I can't show it outranks the pipeline items. I changed no pipeline files, so the gate's "pipeline first" rule is satisfied only by the commit-message Direction: line. Hold it until you decide. I'm not claiming the ordering argument is settled.
  • Cost cap. I took the "skip a pull whose tips were already judged" option, not a cap on pulls examined per tick. Capping would starve the newest waiting pulls because the order is oldest first.

To try it: set a repository to autonomous, approve an agent's pull with a green check, and back-date the approval by eight days. The next autonomy tick lands it. docs/features/approved-week.md describes the behaviour.

Approved

Earlier asks: landing now only where autonomy is on, through landIfGreen (met); merge test memoised per pair of tips (met); act-then-comment order and logged refusals (met); tests for autonomous landing, autonomy-off, attempt cap, person-assigned, no builder, no actor, PER_TICK (met). Direction ask (pipeline items first): not changed, but the pull is the owner-filed #12491, it touches no pipeline file and is small and single-purpose, so I do not hold it on that. The engine takes no new door a person lacks (it acts as a person, lands only via the queue), so no TUI screen is needed; the how-to is in docs/features/approved-week.md and README is untouched.

Next two things: 1) Non-blocking: the judged cache is module state that clears wholesale at 500 entries; a small LRU or per-tick prune would avoid a burst of git work after a clear. 2) Non-blocking: surface the engine moves in the tick line / needs row once #12446 lands, so a person sees what the sweep did.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs