Skip to content

feat(lastcode): post a required status from the guarded merge - #781

Merged
lastobelus merged 1 commit into
lastcode/mainfrom
lastcode/require-guarded-merge-status
Nov 20, 2026
Merged

lastobelus merged 1 commit into
lastcode/mainfrom
lastcode/require-guarded-merge-status

Conversation

@lastobelus

@lastobelus lastobelus commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

A plain merge into lastcode/main (a UI click or gh pr merge) skips the carry trailers and retained source ref that only pnpm lastcode:merge writes, and that breaks the carry check and the next checkpoint. The docs already said not to do it, but nothing enforced it, and every writer, including the plain merge that caused this, runs as the same account, which bypasses "Protect lastcode/main".

Fix. The guarded merge and the checkpoint publisher now post a successful lastcode:merge commit status on the commit they are about to write, while holding the main-write lock. A second ruleset with no bypass actors can then require that status. GitHub combines the rules of every ruleset that targets a branch, and a bypass applies only to its own ruleset, so the owner's bypass on "Protect lastcode/main" does not skip it.

  • lastcode:merge posts the status on the PR head after every other check, waits for GitHub to report CLEAN, then merges. If anything fails after the status is posted, it resets the status to failure; if that reset fails too, the error says so. Before posting, it accepts BLOCKED only when the base requires the status. A failed post is fatal only once the status is required.
  • Checkpoint promotion first pushes the commit to refs/lastcode/main-write-candidate (GitHub can only attach a status to a commit it already has), then posts the status and pushes main. A failed post only warns, so promotion keeps working until the ruleset exists. If the push is rejected and main isn't the candidate, it resets the status to failure.
  • lastcode:pr-gates treats BLOCKED as "waiting for the guarded merge" only for PRs into lastcode/main whose base requires the status. Stacked PRs are unchanged.
  • docs/lastcode/nightly-workflow.md and the lastcode-pr skill now describe what GitHub refuses, and give a step-by-step manual repair path.

Ruleset to apply after this merges

This PR doesn't change any repository settings. Create this ruleset with gh api --method POST repos/lastobelus/lastCode/rulesets --input require-guarded-merge.json:

{
  "name": "Require guarded merge",
  "target": "branch",
  "enforcement": "active",
  "conditions": { "ref_name": { "include": ["refs/heads/lastcode/main"], "exclude": [] } },
  "bypass_actors": [],
  "rules": [
    {
      "type": "required_status_checks",
      "parameters": {
        "strict_required_status_checks_policy": false,
        "do_not_enforce_on_create": false,
        "required_status_checks": [{ "context": "lastcode:merge" }]
      }
    }
  ]
}

Order:

  1. Merge this PR with lastcode:merge. The merge posts lastcode:merge on this PR's head, the first live proof that posting works.
  2. Confirm that every machine that publishes checkpoints has gh signed in with permission to write commit statuses (gh auth status). Promotion warns "Could not approve … for promotion" otherwise.
  3. Apply the ruleset.
  4. Check: a plain gh pr merge on a throwaway PR is refused with "Required status check "lastcode:merge" is expected", lastcode:merge still merges, and the next checkpoint still promotes.

To roll back, delete the "Require guarded merge" ruleset.

Proof

  • Merge-lifecycle tests run the real merge script against a fake gh that behaves like GitHub with the ruleset on: the PR shows BLOCKED and pr merge is refused until the status is posted. The new ruleset row fails against the old script ("not cleanly mergeable (MERGEABLE/BLOCKED)") and passes with this change. Another row (the status can't be posted and no ruleset requires it yet) fails on the round-2 code and passes now.
  • Main-write-lock tests: a merge that fails or can't be confirmed resets the status to failure, and a failed reset shows up in the error. A promoted commit is pushed to the candidate ref before its status is posted; this test routes a GitHub push URL to a local remote. A local, non-GitHub remote posts nothing.
  • Checkpoint publication test: with a GitHub push URL routed to a local remote, a promotion rejected by a concurrent main update posts success on the staged candidate and then failure. The test fails without the reset.
  • The merge, pr-gates, GitHub CI and all checkpoint test files pass (245 tests), and vp run check:changed origin/lastcode/main passes.
  • Not proven: that GitHub really refuses a plain merge and a push by a bypass actor once the ruleset exists. That rests on GitHub's ruleset-layering docs until step 4 above runs.

Follow-ups are noted in the merge report: reset the status after a successful merge, avoid the misleading reset message when nothing was posted, and read the branch rules once per run.

Local review: 3 rounds with GPT-6.1 Terra (xhigh), not clean (round 3's should fixed; churn-gate judge verdict MEDIUM, no cuts).

Built with Claude Opus 5.5 in Claude Code (T3 Code harness).

🤖 Generated with Claude Code

@lastobelus
lastobelus force-pushed the lastcode/require-guarded-merge-status branch from 892d3c0 to 047a411 Compare November 20, 2026 07:40
@lastobelus
lastobelus marked this pull request as ready for review November 20, 2026 07:40
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T08:05:31.079847Z 175d3fa Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 047a411ea8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/lastcode-checkpoint.ts Resolved
A plain merge into lastcode/main skips the carry trailers and retained source
ref that checkpoints replay. Guidance alone did not stop one. The guarded merge
and checkpoint publisher now post a successful `lastcode:merge` commit status on
the commit they write, under the main-write lock, so a ruleset without bypass
actors can require it and GitHub refuses every other merge or push.

Carry-Group: incubator
Co-Authored-By: Claude <[email protected]>
@lastobelus
lastobelus force-pushed the lastcode/require-guarded-merge-status branch from 047a411 to 175d3fa Compare November 20, 2026 08:02
@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 175d3fa058

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lastobelus
lastobelus merged commit 5a4d006 into lastcode/main Nov 20, 2026
32 checks passed
@lastobelus
lastobelus deleted the lastcode/require-guarded-merge-status branch November 20, 2026 08:12
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.

1 participant