Skip to content

feat(deploy-gate): reusable deploy gate with the claims check from the last successful deployment - #23

Merged
cerebral-work[bot] merged 3 commits into
mainfrom
feat/deploy-gate
Nov 20, 2026
Merged

cerebral-work[bot] merged 3 commits into
mainfrom
feat/deploy-gate

Conversation

@todie

@todie todie commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The estate has no shared deploy function. Approval is configured per repo: environments cortex-prod, hotkeys-web-prod and vespertin-prod with required reviewer todie, plus sovereign's deploy number on paas promote PRs. No deploy runs the claims check. Christian, 2026-11-20 10:22:28Z: "add agent jury claims check and deployment approval to estate standard deployment functions". TASK-0823 settled the approval binding: option A, a GitHub environment <unit>-prod with required reviewer todie.

Change

  • deploy-gate.yml, a new reusable workflow:

    • It resolves the range from the newest successful deployment of the caller's environment (GET /deployments, then each deployment's latest status) to the checked-out commit.
    • It runs the claims check on that range, enforce only, with no claims_mode input.
    • It writes the effective settings to the step summary and outputs sha and base.
    • It fails closed in four cases: no deployment and no base_sha; an API refusal (it names the deployments: read permission); a base outside the history; or an unsafe environment name.
  • Approval: the environment on the caller's deploy job, needs: gate. The reviewer approves the job that holds the credentials, after the gate has run in the same run. That is one approval per deploy, and a workflow edit cannot remove it. An approval on the gate job instead would mean either two approvals, or deploy credentials in an environment without a reviewer.

  • scripts/claims_job.sh: the claims step moves here from agent-jury.yml, so both workflows run one file. There are three edits:

    • an empty BASE_REF skips the origin/<ref> attempt, in the diff and for the evidence base;
    • CLAIMS_SUBJECT replaces "PR #n" in the model prompt;
    • PR_NUMBER may be unset.

    diff against the inline block on main shows only these lines.

  • Docs: a README section and a CHANGELOG entry.

Verification

  • Red first: 3ff234c adds tests/test_deploy_gate.py and points the job-shell tests at the script file. It errors with 6 errors, because neither file exists.

  • Green: 123 tests pass on 9656686.

  • Mutation checks:

    • Dropping the success status check fails 3 range tests.
    • Dropping the environment-name validation fails the bad-name test.
  • Range tests: the real Resolve the deploy range block, run by bash against a real git repo and a local HTTP server that answers the two GitHub endpoints.

  • Lint: actionlint 1.7.12 (shellcheck off) reports nothing beyond the known job.workflow_* schema gap. shellcheck -S warning is clean on scripts/claims_job.sh and on the range block.

  • End-to-end canary on cerebral-work/vilicus, pinned to 9656686:

    • The caller ran on pushes to the branch canary/deploy-gate, with a throwaway environment jury-gate-canary that had no reviewer and no secrets. The deploy job only echoed.
    • The branch and the environment are deleted.
    Run Commit Range (from the job's BASE_SHA env) Gate Deploy
    44740715775 70443e1d, first deploy, input base_sha = main 33af9e1a 33af9e1a..70443e1d success success, deployment 7942289545
    44740903495 6ac28a9f, no base_sha, adds We guarantee 100% uptime for every customer. 70443e1d..6ac28a9f, read from the deployment failure: "3 unverified claim, guarantee or liability" skipped, no deployment
    44741032502 cad69a61, copy replaced by a definition and a negation 70443e1d..cad69a61: the failed run did not move the base success success, deployment 7942335282
    44741241572 863676d2, workflow comment only cad69a61..863676d2: a success moves the base success success, deployment 7942364868
  • Jury canary, cerebral-work/vilicus#295 (closed, never landed): run 44741719179 ran bash -e .jury-tools/scripts/claims_job.sh from 9656686 and failed the uncited claim.

  • Not verified: the approval wait. It needs todie's click, so it is proven on the first reverie deploy (CER-4035), as the CER-4034 acceptance states.

References

no XERJ hit. Queries:

  • xerj search on the prefixes vespertin-site, cortex and canary: "environment deployment approval required reviewer deploy job needs";
  • xerj code cygnus-gitops: "github actions deployment gate environment approval last deployed sha".

House pattern: cerebral-work/vespertin .github/workflows/atlas-deploy.yml. The deploy job holds the environment, and the environment holds the token and allows only main. GitHub REST: deployments and deployment statuses (GET /repos/{owner}/{repo}/deployments?environment=, GET .../deployments/{id}/statuses).

Linear

CER-4034. Searched open and done issues for "deploy gate" and "deployment approval"; CER-4034 is the ticket, filed today.

@todie todie added the train the merge train lands this PR label Nov 20, 2026
cerebral-work Bot and others added 3 commits November 20, 2026 13:15
…and one claims script

Co-authored-by: Christian M. Todie <chris@todie.io>
Train-Original-Commit: 3ff234c
Train-Batch: afbf04c-fed0fe17
Train-Base: afbf04c
Train-Prs: 23
…e last successful deployment; both workflows share scripts/claims_job.sh

Co-authored-by: Christian M. Todie <chris@todie.io>
Train-Original-Commit: 7263f83
Train-Batch: afbf04c-fed0fe17
Train-Base: afbf04c
Train-Prs: 23
Co-authored-by: Christian M. Todie <chris@todie.io>
Train-Original-Commit: 9656686
Train-Batch: afbf04c-fed0fe17
Train-Base: afbf04c
Train-Prs: 23
Train-Original-Head: 9656686
@cerebral-work

cerebral-work Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Train batch afbf04c2-fed0fe17: replayed onto main afbf04c2 as 1/1; your branch was rewritten (original saved at train/orig/23). Tip 4233b65b25d65b19e61ac1380b1961efde9b6ef3.

@todie

todie commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Adversarial test of head 9656686. I ran the real "Resolve the deploy range" block under bash -e in temp git repos against a fake GitHub API, and claims_job.sh against a fake model. I created nothing on GitHub. Tests: 110 OK for test_deploy_gate + test_claims_check, 123 OK for the whole suite.

Result: HELD 12, BROKE 2, UNPROVEN 4.

Area Result
Base: uppercase, 39-hex, tree object, missing, not in history, non-hex deployment sha HELD, fail closed
Base: no deployment and no base_sha; success only at #91; API 403/404/429/odd JSON HELD, fail closed
Base: pages 2 and 3, failure then success, inactive HELD
Base: side branch (three-dot uses merge-base, claim still found); shallow checkout HELD
Injection: no ${{ }} in any run:; environment name charset checked HELD
Fail-open: no `
claims_job.sh vs 4ea6597: 3 edits only, four guards kept, no way to set report mode HELD
base_sha == HEAD, or a descendant of HEAD, gives an empty diff and exit 0 BROKE (B1)
A non-deploy actor mints a success deployment BROKE on the docs reading (B2)

B1 (cheap). base_sha always wins over the deployment lookup, with no ancestor check. Repro: BASE_INPUT=$(git rev-parse HEAD) gives exit 0 with base=sha, then claims_job.sh prints "empty diff, nothing to check" and exits 0 with an uncited claim at HEAD. Any caller that wires base_sha from a dispatch input has no claims check. Fix: use base_sha only when the lookup finds no successful deployment, and fail if base equals HEAD or git merge-base --is-ancestor "$BASE" HEAD fails.

B2 (not cheap). The gate filters deployments by environment name only: no creator, ref or workflow filter. Docs: "Create a deployment" (docs.github.com/en/rest/deployments/deployments) takes any branch, tag or SHA, needs Deployments: write, and with no required_contexts "will always succeed"; "Create a deployment status" says "Users with push access can create deployment statuses". Neither page says protection rules apply to API-created deployments. So a branch workflow with deployments: write can post a later sha as a success and move the base past an uncited claim. This differs from the listed "any successful deployment moves the base". Partial fix: require .ref to be the default branch and tie the deployment to a run of the caller's deploy workflow. Not run live, because the brief forbids creating deployments.

UNPROVEN, need a live run:

  • newest-first order of both the deployments list and the statuses list, which the docs I read do not state;
  • the 90-day deployment-status retention (docs.github.com/en/rest/deployments/statuses): an old deployment may list no statuses, which fails closed and pushes the operator to base_sha, the B1 path;
  • the second checkout into .jury-tools when the caller repo already tracks that path;
  • B2 on a live repo.

Controls. Negative: an uncited "guarantee 100% uptime" line in README.md in the range gives exit 1. Positive: plain copy gives exit 0, "Model not called".

Full report: scratchpad cer4034-falsification.md (not committed).

@cerebral-work
cerebral-work Bot merged commit 4233b65 into main Nov 20, 2026
4 checks passed
@cerebral-work

cerebral-work Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Landed in train batch afbf04c2-fed0fe17 at 4233b65b25d65b19e61ac1380b1961efde9b6ef3.

cerebral-work Bot added a commit that referenced this pull request Nov 20, 2026
Train-Original-Head: 9656686
Train-Pr: 23
Train-Batch: afbf04c-fed0fe17
Train-Landed: 4233b65
@cerebral-work
cerebral-work Bot deleted the feat/deploy-gate branch November 20, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

train the merge train lands this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant