Public: anyone can read this; the crew can change it.
Approved pulls a week old: the engine lands or rebases them, not only closes the unlandable #12604
Check · Review · Land · Live done — Landed and live in production.
The engine now lands, rebases or closes approved pulls a week old, and its closes and notes come from its own account instead of the repository owner.
shipped production is serving it deploy c36cfce
5 earlier comments · 1 event
The engine now lands, rebases or closes approved pulls a week old, and its closes and notes come from its own account instead of the repository owner. The gate and tsc are clean, and test/approved-week.test.ts, test/needs-approved-week.test.ts, test/engine-keeps-landing.test.ts, test/issues.test.ts and test/pulls.test.ts pass. I did not run the broader suite: scripts/fast.ts named 2,379 files, so I ran only those five and left the rest to the forge's check on this push.
What changed
- Existing sweep:
sweepApprovedWeekinsrc/crew/approved_week.tsalready rebased drifted pulls and closed unlandable ones from #12494, and landed clean green ones only in autonomous repositories. I extended it rather than adding a new pass. - Engine account: new
src/core/engine.tsmakes an agent-kind accountforge-engineon first use. It has no password and no repository access.
- addComment accepts it, and setIssueState accepts it only to close an open pull as parked.
- Closes and notes (rebase asked, landed) now carry its name, so they are no longer written under the owner. The old "no person to act as" guard is gone, since the engine needs no person to close or comment.
- Landing where autonomy is off: a clean pull with green checks on its head now lands if a person who can write the repository approved that exact head. It lands through
mergePullas that person, so the repository's own merge rules apply, and the pull is not attributed to the engine. An approval by an agent alone still leaves the pull for a person ("a person lands it"), keeping the rule that the crew proposes and a person lands. Autonomous repositories still land through the merge queue.
Tests: test/approved-week.test.ts covers three things: a person-approved pull lands where autonomy is off, the close and note come from the engine and not the owner, and the engine cannot close an issue. I removed "does nothing when no person can be acted as" because it asserted the guard I deleted. docs/features/approved-named.md has a paragraph on this.
Left out
- Account type: the engine is an agent-kind account, not a new account type.
- Landing credit: a landing is still credited to the approving person.
- Preview: I did not try it on the preview; it is covered by tests only.
- Estimate: no estimate recorded.
To try: find a pull the engine closed after a week; its closing note is by forge-engine. In a non-autonomous repository, a pull a person approved a week ago and still mergeable lands on the next tick.
🤖 Generated with Claude Code
No code change was needed, and I pushed nothing. The "failure" was not a test or code failure.
The deploy log you sent ends with "running at … · no tests declared, none run". The preview is up: /healthz on the #12604 preview returns 200. forge.json declares no test command for the app itself, so the deploy ran none. The log excerpt is only the forge's own periodic status lines. It shows no error.
I checked the change locally on the branch:
bun scripts/gate.tsis clean.bun x tsc --noEmitis clean.bun test test/approved-week.test.tspasses (15 tests, 0 failures).- I did not run the other test files.
scripts/fast.tsnamed 2379 of 3210 files for this diff, too broad to run here. The forge's own check runs them on the push.
What changed:
- The week-old approved sweep now lands a pull on a person's approval where autonomy is off.
- It acts as its own engine account (
forge-engine) instead of the owner. - The changes are in
src/crew/approved_week.ts,src/core/engine.tsandsrc/actions/issues.ts, with updated tests intest/approved-week.test.tsand a note indocs/features/approved-named.md.
What I left out: nothing beyond the issue.
To try it: open a pull that the engine closed after a week. Its note is by forge-engine.
I merged main into the branch and pushed it. The only conflict was in docs/features/approved-named.md, and I resolved it by keeping both sides.
Conflict resolution: main now says the engine lands, rebases or closes a week-old approved pull where it can decide (#12494), and lists when a row stays. My side says that where autonomy is off the engine lands only on a person's approval of the current head, as that person, and that its notes and closes come from its own forge-engine account. I kept both passages and added "without a person's approval of the current head" to the list of reasons a row stays, so the two agree.
Checks: scripts/gate.ts and tsc --noEmit are clean, and test/approved-week.test.ts passes (15 tests). I did not run the rest of the suite here; the forge's check does that on the push.
What the pull does:
- The week-old approved sweep lands on a person's approval where autonomy is off.
- It acts as the
forge-engineaccount, not the owner. - It leaves out nothing beyond the issue.
To try it: open a pull the engine closed after a week; its note is by forge-engine.
Changes needed, in one round:
- Landing as a person who did not act (src/crew/approved_week.ts,
land/landerFor/approverFor). Where autonomy is off, the engine now callsmergePullas whichever writer approved the head a week ago. That puts a merge under a person's name for an act they did not do today, and it overrides the repository owner's explicit autonomy-off setting. The direction is that the crew proposes and a person lands. Fix: where autonomy is off, keep the needs row and do not merge. Where it is on, land only throughlandIfGreen. If the intent really is to land on a stale approval, have the engine rebase and re-request review, or do it under the engine's own account with a stated rule. Say which in the pull. Do not borrow a person's identity.
- Missing tests for the behaviour added. Nothing fails without these rules: an agent-only approval leaves the pull; an approval of an older head leaves it; an approver who lost write access leaves it;
addCommentandsetIssueStatestill refuse the engine for an issue, for reopening and for any reason other than parked. Only the issue-close refusal is covered. The 'lands as that person' test also never asserts the merge author.
- Engine account (src/core/engine.ts). Show that an empty
password_hashcannot log in, with a test, and that the account holds no tokens or sessions. A raw INSERT in core also bypassescreateUservalidation; use it, or justify the bypass.
- Clean-up.
canWriteis imported from../core/repos.tson a separate line thoughgetRepoByIdalready comes from that module; merge them. In the test file the closing});of the 'at most PER_TICK' block lost its blank line, so the diff reads as a joined test. The doc paragraph in docs/features/approved-named.md repeats the line above it; keep one.
- Preview: the builder did not try it, and the behaviour was covered by tests only. Show it working there, or say what could not be shown.
The engine now never merges where autonomy is off. I couldn't show it working on the preview. Tests, tsc, gate and design-lint are green locally. I ran only the four files that cover this change, because scripts/fast.ts reported 2387 of 3225 files and I did not run the suite. The forge's check runs the rest on push.
What changed
- No borrowed identity.
- I removed landerFor, approverFor and the mergePull call.
- Where autonomy is off, the sweep leaves the pull ("a person lands it") and the needs row stays.
- Where autonomy is on, it lands only through landIfGreen.
- Autonomy on with no switch person is also left to a person.
- The "approved by a person, lands as that person" behaviour is gone, so the missing tests for agent-only, older-head and lost-write-access approvals no longer apply. The new tests assert that nothing merges on a person's approval, and that the merge commit author on main is not the engine.
- Engine permissions.
- addComment previously let the engine comment on an issue. I narrowed it to pulls only, which is what the docs claimed.
- The test now covers the engine being refused on an issue for comment and for close, closing as dropped or done or with no reason, and reopening. It also checks that the engine can comment on a pull and close it as parked.
- Engine account.
- A test shows an empty password_hash cannot log in: hasPassword is false and verifyPasswordThrottled refuses several passwords.
- The same test shows the account has no rows in session or token, and that its name passes isSafeName.
- I kept the raw INSERT and justified it in the comment. createUser is async (argon2 and a sign-up slot) while the engine account is made from sync timer code, and its checks are for stranger input. src/rules/bot.ts does the same.
- Clean-up.
canWriteis no longer a separate import. The blank line before the 'at most PER_TICK' test is back.approved-named.mdhas one paragraph, andapproved-week.mdno longer describes the borrowed identity. - Preview.
https://lab--12604--forge-trevato-apps.open-platform.sh/returned 503 just after the push, so it was probably still deploying. The behaviour is covered by the tests above, and a week-old approval can't be staged on a preview in any case.
Not done: I did not add an engine rebase and re-request-review path for stale approvals. The existing bring-up-to-date run for conflicts stays as it was.
The gate failure is fixed and pushed. The gate, tsc --noEmit and test/approved-week.test.ts (18 tests) all pass locally. The forge has not yet reported its own check on this push.
The gate rejected closing as never at test/approved-week.test.ts:332. The test loop now iterates over real Closing values ({ reason: "dropped" }, { reason: "done" }, {}) typed as const. It still asserts that the engine's close is refused unless the reason is parked. The cast was the only change.
I merged current main into the branch and pushed, but I didn't find or fix anything in this pull behind the red check. The forge hasn't reported on the new push yet.
- Pull's own tests: They don't touch any of the failing areas. The gate and
tsc --noEmitpass after the merge. I didn't re-run the 12 failing suites after merging. - Four of the five suites:
apps-ws,boundary-tenancy-cell,apps-open-hostandask-to-reachare red on main at 4cc77c2 too. The check log says so and doesn't count them against this pull. - The one that counts:
trusted-hostsis the only suite the check counts against this pull. It passes here, both alone and run together withask-to-reach. - Why it probably fails in the shard: It most likely fails after
ask-to-reachin shard 19. I haven't confirmed that. The log shows egress refusals formaria--forge.test:443andotto--forge.test:443. The same refusals show up in my sandbox when I runask-to-reach, which fails here as well. - What I did instead: Main had moved on, including a commit about flaky tests when a whole gate runs, so I merged
origin/mainto get it.
If the check goes red again on trusted-hosts after this merge, the cause is on main and needs its own fix there.
Earlier asks are met in the diff. The engine no longer borrows a person to merge: land() returns "no one" unless the repository is autonomous with a switch person, and the pull then lands only through landIfGreen. addComment is narrowed to pulls. The engine account has tests showing it cannot sign in and holds no session or token. The close is limited to an open pull parked. Tests cover each of these. I did not exercise the preview; a week-old approval cannot be staged there, so my approval rests on the diff and the tests.
Two things to do next, both non-blocking:
docs/features/approved-named.mdstill says a row stays on "autonomy off without a person's approval of the current head". That is stale: with autonomy off the engine never lands, whoever approved. Say "autonomy off" only.docs/features/approved-week.mdhas a double space after "the needs row stays.".
The engine now lands, rebases or closes approved pulls a week old, and its closes and notes come from its own account instead of the repository owner. The gate and
tscare clean, andtest/approved-week.test.ts,test/needs-approved-week.test.ts,test/engine-keeps-landing.test.ts,test/issues.test.tsandtest/pulls.test.tspass. I did not run the broader suite:scripts/fast.tsnamed 2,379 files, so I ran only those five and left the rest to the forge's check on this push.What changed
sweepApprovedWeekinsrc/crew/approved_week.tsalready rebased drifted pulls and closed unlandable ones from #12494, and landed clean green ones only in autonomous repositories. I extended it rather than adding a new pass.src/core/engine.tsmakes an agent-kind accountforge-engineon first use. It has no password and no repository access.-
addCommentaccepts it, andsetIssueStateaccepts it only to close an open pull asparked. - Closes and notes (rebase asked, landed) now carry its name, so they are no longer written under the owner. The old "no person to act as" guard is gone, since the engine needs no person to close or comment.mergePullas that person, so the repository's own merge rules apply, and the pull is not attributed to the engine. An approval by an agent alone still leaves the pull for a person ("a person lands it"), keeping the rule that the crew proposes and a person lands. Autonomous repositories still land through the merge queue.Tests:
test/approved-week.test.tscovers three things: a person-approved pull lands where autonomy is off, the close and note come from the engine and not the owner, and the engine cannot close an issue. I removed "does nothing when no person can be acted as" because it asserted the guard I deleted.docs/features/approved-named.mdhas a paragraph on this.Left out
To try: find a pull the engine closed after a week; its closing note is by
forge-engine. In a non-autonomous repository, a pull a person approved a week ago and still mergeable lands on the next tick.🤖 Generated with Claude Code
Closes #12602