Skip to content

Enroll the rolling-custody candidate: merge-approval envelope and an operable merge-master approval for it (act A4) - #735

Merged
brettheap merged 2 commits into
mainfrom
feat/merge-approval-envelope-custody
Sep 7, 2026
Merged

brettheap merged 2 commits into
mainfrom
feat/merge-approval-envelope-custody

Conversation

@brettheap

Copy link
Copy Markdown
Contributor

Lane: openxfactory-4-opendox-extraction (formerly openxfactory-opendox)

Act A4 on openxFactory #656. Brett Heap, 2026-09-06: "author the envelope PR now as a narrow first candidate."

What this asks for, stated plainly

Your merge word on this pull request is the grant, and it is a grant for exactly one candidate class. Nothing here widens beyond intent-rolling-custody. The Gate-Rules Council's 2026-08-28 unanimous refusal stands for the class it refused — a class over openspec/changes/**, refused because its admitted surface lies wholly inside the canonical GATE_INTEGRITY_FLOOR and so can never convene — and add-substantive-review-lane task 3.2 stays OPEN beyond this candidate. This PR is not that grant and does not pretend to be.

What lands

1. .github/merge-approval-envelope.yml — one candidate, intent-rolling-custody

field value
target_repos opensoft/openxFactory
expected_author openxfactory[bot] (verified: gh api repos/opensoft/openxFactory/pulls/176 --jq .user.login)
expected_head_ref intents/rolling (exact, never a pattern)
expected_base_ref main
path_allowlist ideation/dashboard/intents/**, ideation/dashboard/gate-records/**
require_all_checks true
check_exclusions merge-master-approval (self-reference deadlock)
revert_suffices true

Both prefixes were read out of scripts/ideation_dashboard/intent_apply_lane.py rather than assumed: DEFAULT_INTENTS_DIR = "ideation/dashboard/intents/" and gate_console.DEFAULT_RECORDS_DIR = "ideation/dashboard/gate-records/". _write_intent never overwrites an existing intent, so both trees are append-only. The apply lane commits with git add -A, so any delivery that touches a governed artifact outside those two trees falls outside the allowlist and parks for the human gate — that is what makes this narrow, and it is the same operator note xFactory's doc-health-nightly carries after the council's own R5 narrowing of 2026-08-26.

The envelope's header records the grant (who, when, on which issue) and that no other class is enrolled. .github/CODEOWNERS now routes the file to @brettheap: .github/workflows/ was owned, but that entry does not cover a file beside the workflows directory, and widening the grant must be a reviewed human act.

2. .github/workflows/merge-master-approval.yml — operable for envelope candidates

Mirrors xFactory's implementation, which has run this candidate shape since 2026-07-28. Same job id (merge-master-approval), so no required-check context moves and no ruleset is touched. The advisory repository_gate_floor verdict still runs on every pull request, unchanged.

How an approval is gated — all of these, conjunctively:

  • The envelope and the decision core are both read from the base branch. pull_request_target resolves the workflow definition and the base checkout from main; no step checks out or executes head content. A PR cannot alter the rules that govern its own approval, and a PR that edits the envelope lands outside the envelope's own allowlist.
  • Not enrolled → skip, with no facts gathered at all. The head ref is tested against the envelope's own governed set first.
  • The floor is composed over the envelope. A candidate touching any never-clearable path parks before the envelope is consulted (FLOOR_MATCHED != 0, where an empty value from a skipped or failed floor step also refuses). The allowlist and the floor are disjoint today, so this can only fire on a future widening.
  • Every fact is gathered provably complete or the candidate parks — the changed-path set against the PR resource's own changed_files, the check-run and commit-status listings against their own total_count, both paginated, with a total_count that moves between pages parking rather than mixing snapshots. No || echo '[]' anywhere: a failed read is an unobtained fact, never an empty one.
  • The decision is the pinned core's, opensoft/codexFactory@ad15a898's scripts/merge_master/envelope.py, at the commit contracts/review-lane-pin.yaml already pins. This repository re-implements none of it.
  • The output emitter is fail-closed. reason comes out of the core carrying externally-supplied check-run and status names; $GITHUB_OUTPUT is key=value and the last write wins, so one newline in a reason could otherwise publish decision=approve. Unrenderable values are refused outright, and decision is one of four literals.
  • One door. steps.envelope.outputs.decision == 'approve' is the sole condition on which any review is submitted, and it is written by nothing but the core's exit code.
  • The workflow's own GITHUB_TOKEN stays read-only (contents/pull-requests/checks/statuses, all read). The only write authority is a per-run App token minted from MERGE_MASTER_APP_ID / MERGE_MASTER_APP_KEY after the core decides, scoped permission-pull-requests: write on this repository alone. That is stricter than xFactory's caller, which carries pull-requests: write on its own token.
  • Anything else parks fail-closed: no review, one sticky comment saying why, and a green job.
  • No merge, ever. No merge call, no auto-merge enablement — the aggregation's intent-apply lane arms auto-merge on its own side (ruling D-3). The test still refuses every merge-shaped string in the file.

The workflow_dispatch path now resolves its candidate from the envelope's governed head refs, because that is what the aggregation actually dispatches: gh workflow run merge-master-approval.yml --repo opensoft/openxFactory --ref main, with no inputs (xFactory .github/workflows/intent-apply.yml, PR #304). Its enrollment preflight — "openxFactory carries no merge-approval envelope … so no dispatch" — goes live by itself the moment this lands.

3. tests/review_lane_pin/test_review_lane_caller.py — the amendment

The module used to assert an absence: no App token, no review submission, no envelope file. The reason for that absence is kept in the docstring rather than deleted, because it is still in force for the class it covers. What the module now asserts instead is that the approval exists behind exactly one door and that the door is this narrow: exactly one candidate with that author, head ref, base and those two path prefixes; require_all_checks: true; a refused-ground check that fails if the allowlist ever reaches openspec/, contracts/, governance/, .github/, scripts/, health/ or the wallet; the review-submitting step gated on the envelope decision; every step wiring the approver credential gated on it too; the mint scoped to pull-requests; no write scope on the workflow token; the closed-world decision shape; the floor composition; and the continued absence of every merge-shaped step. Six new negative controls make each of those one mutation from failing.

Authority and design

Verification

  • actionlint clean on the workflow.
  • bash -n and set -euo pipefail on all twelve embedded shell blocks (asserted by test).
  • python3 -m pytest -q tests/review_lane_pin — 146 passed, 2 skipped (the pre-existing cross-repository freshness skips), 48 subtests passed.
  • The envelope was validated by the pinned core itself, and its decisions exercised against the real facts of openxFactory Applied intents (rolling custody) #176: it matches the class as intent-rolling-custody with author, base, allowlist and both completeness proofs holding, and parks required_check_not_green because that head presently carries zero check-runs — absence is never greenness. Synthetic variants confirm approve on a green head, path_allowlist park on an openspec/specs/** path, expected_author park on a human author, and candidate_class skip on a foreign head ref.

Refs #656

Offered for Brett Heap's word.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MDVAo41VtZqJQpuawwJeYC

…able for it (act A4)

Brett Heap, 2026-09-06 on #656: "author the envelope PR now as a narrow
first candidate." His merge word on this pull request is the grant, for
the ONE class enrolled here and for nothing else. The Gate-Rules
Council's 2026-08-28 unanimous refusal stands for the class it refused
(a class over openspec/changes/**, whose admitted surface lies wholly
inside the canonical GATE_INTEGRITY_FLOOR and so can never convene), and
add-substantive-review-lane task 3.2 stays OPEN beyond this candidate.

.github/merge-approval-envelope.yml enrols exactly one candidate,
`intent-rolling-custody`: author openxfactory[bot], exact head ref
intents/rolling, base main, path allowlist
ideation/dashboard/intents/** plus ideation/dashboard/gate-records/**,
require_all_checks true, self-excluding check name. Both prefixes are
what scripts/ideation_dashboard/intent_apply_lane.py actually writes
(DEFAULT_INTENTS_DIR and gate_console.DEFAULT_RECORDS_DIR); the lane
commits with `git add -A`, so any delivery touching anything else falls
outside the allowlist and parks for the human gate, which is what makes
this narrow. .github/CODEOWNERS routes the file to a human owner —
.github/workflows/ was owned, but that entry does not cover a file
beside the workflows directory, and widening a grant must be reviewed.

.github/workflows/merge-master-approval.yml keeps its job id (so no
required-check context moves) and its advisory floor verdict, and gains
the approval path xFactory's caller has run since 2026-07-28. Config and
core both come from the base branch; an unenrolled head ref reaches
`skip` before any fact is gathered; the repository gate floor is
composed OVER the envelope, so a never-clearable path refuses whatever
the envelope says; every fact set is gathered provably complete or the
candidate parks; the decision is the pinned core's; the output emitter
refuses an unrenderable reason rather than escaping it, because one
newline could otherwise publish decision=approve. The workflow's own
GITHUB_TOKEN stays READ-ONLY: the only write authority is a per-run App
token minted after the core decides, scoped permission-pull-requests
write on this repository alone. No merge call and no auto-merge — the
aggregation's intent-apply lane arms that on its side (ruling D-3).

The dispatch path resolves its candidate from the envelope's governed
head refs, because that is what the aggregation dispatches: `gh workflow
run merge-master-approval.yml --repo opensoft/openxFactory --ref main`,
with no inputs (xFactory PR #304). Its enrollment preflight goes live by
itself when this lands.

tests/review_lane_pin/test_review_lane_caller.py asserted an ABSENCE.
The reason for that absence is kept in the docstring rather than
deleted, because it still holds for the class it covers; what the module
asserts now is the narrow grant and the single door — one candidate with
those exact fields, a refused-ground check over the allowlist, the
review submission and every credential-wiring step gated on
steps.envelope.outputs.decision, the mint scoped to pull-requests, no
write scope on the workflow token, the closed-world decision shape, the
floor composition, and the continued absence of every merge-shaped step.
Six new negative controls put each one mutation from failing.

Verified: actionlint clean; bash -n and strict mode on all twelve shell
blocks; pytest tests/review_lane_pin 146 passed, 2 skipped. The envelope
was validated by the pinned core itself and exercised against the real
facts of #176 — matched as intent-rolling-custody, parked
required_check_not_green because that head carries zero check-runs.

Refs #656

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MDVAo41VtZqJQpuawwJeYC
Copilot AI lite review requested due to automatic review settings September 6, 2026 23:31

@sourcery-ai sourcery-ai 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.

Hi @brettheap! 👋

Your private repo does not have access to Sourcery.

Please upgrade to continue using Sourcery ✨

Copilot AI 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.

🟡 Changes recommended

The workflow currently mints an App token without issues: write while later calling Issues comment endpoints, and it masks dispatch candidate-resolution API failures as a no-op, both of which break stated/expected lane behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR enrolls a single, narrowly-scoped merge-approval candidate (intent-rolling-custody) by introducing a base-branch merge-approval envelope and updating the merge-master-approval workflow to evaluate that envelope and (only when approved) submit an approving review via a GitHub App token; the accompanying tests and CODEOWNERS rules pin the grant’s exact shape and guard against widening or adding merge authority.

Changes:

  • Add .github/merge-approval-envelope.yml defining exactly one enrolled candidate class and its allowlisted surface.
  • Extend .github/workflows/merge-master-approval.yml to evaluate the envelope (fail-closed) and submit an APPROVE review when the envelope decision is approve.
  • Update tests/review_lane_pin/test_review_lane_caller.py and .github/CODEOWNERS to pin the envelope/workflow invariants and require human review of envelope edits.
File summaries
File Description
tests/review_lane_pin/test_review_lane_caller.py Replaces “approval must be impossible” assertions with “approval is possible through exactly one narrow door” invariants and negative controls.
.github/workflows/merge-master-approval.yml Adds envelope evaluation, gated App-token minting, gated approval submission, and sticky PR outcome reporting.
.github/merge-approval-envelope.yml Introduces the single enrolled intent-rolling-custody candidate class with strict author/head/base/path/check constraints.
.github/CODEOWNERS Adds explicit ownership for the envelope file to force reviewed human changes for any widening.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

…he candidate's key set

Redo of the security verifier for PR #735 (act A4), plus the three open
Copilot review threads:

- The merge-master App token minted only pull-requests: write, but the
  sticky-comment step posts through the Issues Comments API (what a pull
  request's conversation thread actually is), which pull_requests does not
  gate. Add permission-issues: write to the mint and correct the three
  comment blocks that claimed otherwise.
- The workflow_dispatch candidate-resolution loop masked a failed
  `gh pr list` with `|| true`, contradicting this file's own stated
  fail-closed posture ("a fact that cannot be obtained is not a fact that
  is empty"). A failed listing now aborts the run with a named error
  instead of silently falling through to "nothing to evaluate".
- NegativeControls.setUpClass read its three source files unconditionally,
  so a missing one surfaced as a bare FileNotFoundError rather than a clear
  assertion; it now names the missing file. Covered by a new test that
  mocks ENVELOPE to a missing path.
- Governance verifier's low finding: pin the enrolled candidate's key set
  by asserting the absence of open_finding_title_prefixes and
  open_finding_labels, so either key silently reappearing (as xFactory's
  own doc-health-nightly candidate carries) would break a test.

Verified live: the review-submission gate and the refused-ground allowlist
check were each mutated and confirmed red, then restored and confirmed
green; actionlint is clean on the workflow.

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CHAHvr9zFHRd4kWVnZLK9k
Copilot AI review requested due to automatic review settings September 7, 2026 00:00

Copilot AI 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.

🔵 Needs a closer look

A small gap in the new negative-control denylist can miss --auto when it appears without a trailing space, weakening the intended structural guard against auto-merge enablement.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

tests/review_lane_pin/test_review_lane_caller.py:161

  • MERGE_SHAPED includes the needle "--auto " (with a trailing space). That will miss a gh pr merge --auto invocation if --auto appears at end-of-line or before a newline (no trailing space), weakening the intended structural guard against auto-merge enablement.
  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@brettheap
brettheap merged commit 6d3237e into main Sep 7, 2026
10 checks passed
brettheap added a commit that referenced this pull request Sep 9, 2026
…1/5.2 ticked on the D-2 evidence) (#832)

Path A PR-5, the last of the 2026-09-06 plan memo's sequence, on Brett Heap's word "merge pr-5 when green" (2026-09-09). Authority: his ruling of 2026-09-05T23:38Z "rule path A, 4.5 is a deferred successor" (#656) and ruling D-2 (the live exercise).

- tasks.md: § 4.4 / § 5.1 / § 5.2 ticked on the D-2 evidence (three `- [ ]` heads removed, every ratified sentence kept byte-identical); § 4.5 untouched as a DEFERRED SUCCESSOR (#714 → 3d1b8cc).
- Archived WITH promotion via `scripts/proposal-support.py . archive --date 2026-09-09` under the pinned @fission-ai/[email protected] (never a bare `openspec archive`); origin retained (declaration unchanged since da1b0e9); six frozen files R100.
- Promoted: `openspec/specs/ideation-intent-plane/spec.md` NEW (7 requirements / 11 scenarios, every block byte-identical to the archived delta) and `openspec/specs/document-lifecycle/spec.md` 18 → 19 requirements ("Gates happen on main"); the new capability's `## Purpose` written by this act (no SHALL; replaces the CLI's TBD stub). openspec/specs 60 → 61; floor regeneration OWED (GRACED covered-pending 1, `created_by_candidate`), `contracts/review-lane-floor-snapshot.yaml` deliberately not edited here.
- README OpenSpec Records row → archived; sweep-ledger row re-seeded with the tool (`--seed-ledger --moved-by '#832'`, one line moved); no thirteenth archive-date disposition.
- Evidence (merged + green): #718 d179cc0, #727 07624d5, #735 6d3237e, xFactory #304 b2db7e47, #313 ddd19650, #345 90435875, #781 450bb60, #808 2ef7d8c, #814 c991c0f, #816 8924230, xFactory #362 119280a8, #830 202c170, xFactory #369 c2313277; D-2 live exercise: act B refusal 36d07ec, act A apply e970dfe, first autonomous merge #176 → 7681e40 (codexfactory[bot] APPROVED 2026-09-09T06:37:22Z).
- Copilot round 1: one factual finding taken (a missing "where" in Purpose); two wording findings answered and resolved.

Refs #656 (stays OPEN). Rule 6 LANDING window observed.

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_012LiNG5Ume1boEfxSNeCmpu
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.

2 participants