Skip to content

feat(rebase-pr): port resolve-branch-conflict command as /uf.rebase-pr - #857

Merged
jflowers merged 7 commits into
unbound-force:mainfrom
jflowers:opsx/port-uf-rebase-pr
Oct 29, 2026
Merged

jflowers merged 7 commits into
unbound-force:mainfrom
jflowers:opsx/port-uf-rebase-pr

Conversation

@jflowers

Copy link
Copy Markdown
Contributor

Summary

Ports the verified personal global command resolve-branch-conflict.md into
the UF command set as /uf.rebase-pr <PR_NUMBER> — a slash command that
rebases a conflicted PR's head branch onto its base branch and force-pushes
with lease, so the PR can be merged with a rebase once approved.

  • New .opencode/commands/uf.rebase-pr.md: full port following
    uf.review-pr.md conventions — YAML frontmatter, <protect> block,
    session-resume guard, ^[1-9][0-9]*$ argument validation before any tool
    call, six execution phases (prerequisites, PR fetch/gating, checkout and
    rebase, conflict resolution, push, verify), and a nine-rule guardrails
    section.
  • Gates on PR state (stops for CLOSED/MERGED or already conflict-free PRs);
    fork-aware BASE_REMOTE/HEAD_REMOTE resolution by matching git remote -v
    URLs against the PR's base/head repos — never assumes origin.
  • Prefers the deterministic git plugin tools (git_fetch, git_rebase,
    git_rebase_abort, git_push_force_with_lease) per determinism pack
    DE-001; resolves only flagged conflicts while preserving the PR author's
    intent (fail-closed on ambiguity, rebase-abort off-ramp); pushes only to
    the head branch with --force-with-lease; re-verifies mergeability via
    gh; never merges, approves, or closes the PR.
  • Ships a byte-identical scaffold mirror at
    internal/scaffold/assets/opencode/commands/uf.rebase-pr.md with
    expectedAssetPaths registration so uf init deploys the command to every
    scaffolded repo (drift tests green).
  • Documents across AGENTS.md (PR Review Commands row; command count
    32 → 33), docs/usage.md, docs/architecture.md, and CHANGELOG.md;
    docs-gate issues docs: /uf.rebase-pr ported command (port-uf-rebase-pr) #856 (per-surface dispositions) and
    docs: sync /uf.rebase-pr command reference (port-uf-rebase-pr) website#340 (website sync) filed before merge.

Reviews: spec review APPROVE WITH ADVISORIES (iteration 2); code review
APPROVE WITH ADVISORIES (4 of 5 personas, divisor-adversary excluded per
RD-FR-025).

Closes #851

How to Test

Verification status: make check green at implement HEAD 3d0cf6d7
(pre-rebase; the rebase onto latest main had zero file overlap) — lint
clean (go vet + golangci-lint), Go tests with -race -count=1, build,
scope-based coverage gate, TypeScript plugin suite 1263 tests at 95.35%
statements (94% floor). CI on this PR re-validates at the rebased head.

  1. Command file: open .opencode/commands/uf.rebase-pr.md — confirm the
    frontmatter description, protect block, session-resume guard, the
    ^[1-9][0-9]*$ argument pre-validation, the six phases, and the
    nine-rule guardrails.
  2. Scaffold mirror parity: go test -race -count=1 ./internal/scaffold/...
    — drift detection asserts the mirror is byte-identical to the canonical
    command and expectedAssetPaths lists the new asset.
  3. Full local CI parity: make check.
  4. Live behavior (acceptance scenario): in a scaffolded repo, run
    /uf.rebase-pr <PR_NUMBER> against an open PR whose base has moved — it
    fetches PR metadata via gh, stops if the PR is CLOSED/MERGED or already
    MERGEABLE + CLEAN, checks out the head branch, resolves
    BASE_REMOTE/HEAD_REMOTE from git remote -v, rebases onto
    <BASE_REMOTE>/<BASE_BRANCH>, walks only flagged conflicts (STOP +
    git rebase --abort off-ramp on ambiguity), pushes --force-with-lease
    to the head branch only, and reports the re-checked
    mergeable/mergeStateStatus without merging or approving.

How to Demo

In a scaffolded repo with an open PR whose base branch has moved ahead,
run /uf.rebase-pr <PR_NUMBER>: the command validates the argument, checks
prerequisites, fetches and gates on PR state, checks out the head branch,
resolves the base/head remotes from git remote -v, rebases onto the base,
walks any flagged conflicts (fail-closed with an abort off-ramp),
force-pushes with lease to the head branch only, and reports the
re-checked mergeability — it never merges, approves, or closes the PR.

Key Files Changed

  • .opencode/commands/uf.rebase-pr.md (+235) — the ported command
  • internal/scaffold/assets/opencode/commands/uf.rebase-pr.md (+235) —
    byte-identical scaffold mirror, registered in expectedAssetPaths
  • internal/scaffold/scaffold_test.go, cmd/unbound-force/main_test.go —
    drift/registration tests and embedded-asset-count updates
  • openspec/changes/port-uf-rebase-pr/ — proposal, design, delta spec,
    tasks, .openspec.yaml (originating_issue: 851)
  • AGENTS.md, docs/usage.md, docs/architecture.md, CHANGELOG.md —
    documentation surfaces
  • .uf/dewey/learnings/ — 11 learnings captured during the workflow
    (spec review, code review, retrospective)

24 files changed, +1700/−7.

Known Issues

Code review returned APPROVE WITH ADVISORIES — six non-blocking advisories
(full text in .uf/artifacts/dispatch/1750f856-4d75-4d45-9ec0-8eca8355ef0c.json):

  • [MEDIUM] Determinism DE-001: the ported command carries mechanical prose
    (argument-validation regex, BASE_REMOTE/HEAD_REMOTE URL matching,
    which gh checks, fixed git_fetch → git_rebase sequence) not yet
    extracted into executable tools — accepted trade-off (verified-source
    fidelity, YAGNI on single-call-site tools), no bounding trigger recorded.
  • [MEDIUM] Delta spec/task 3.4 pin the CHANGELOG closing reference without
    the Fixes: #851 element; the shipped entry correctly carries it per
    repo convention.
  • [LOW] The Fixes: #851 element exists in the shipped CHANGELOG entry but
    is not prescribed in the change's own spec artifacts.
  • [LOW] proposal.md Impact → Files omits cmd/unbound-force/main_test.go
    (modified mechanically for the 76th embedded asset).
  • [LOW] CHANGELOG/tasks attribute the ^[1-9][0-9]*$ pre-validation to
    "uf.review-pr.md conventions"; that regex is not literally present in
    uf.review-pr.md.
  • [LOW] No test pins the command file's content structure/safety phrases
    (registration, mirror parity, and deployment count are tested).

This PR was generated by /uf.finale (AI-assisted).

@jflowers
jflowers requested a review from a team as a code owner October 28, 2026 20:39
@jflowers jflowers self-assigned this Oct 28, 2026
Port the verified personal global command resolve-branch-conflict into
the UF command set as /uf.rebase-pr per issue unbound-force#851. Spec review council
approved at iteration 2 (APPROVE WITH ADVISORIES, 3 recorded advisories
honored during implementation). openspec validate passes.

Spec: openspec/changes/port-uf-rebase-pr/
Full port of the verified personal global command into the UF command
set per openspec/changes/port-uf-rebase-pr (issue unbound-force#851): six phases,
^[1-9][0-9]*$ argument validation, nine guardrails, D2 git plugin
tool mapping (git_fetch/git_rebase/git_rebase_abort), and the D3
upstream-verified force-push-with-lease strategy. Marks phase 1 tasks
complete in tasks.md.
- Copy canonical .opencode/commands/uf.rebase-pr.md to the scaffold
  assets (byte-identical, tool-owned) per task 2.1
- Register opencode/commands/uf.rebase-pr.md in expectedAssetPaths,
  commands count comment 11 -> 12, per task 2.2
- Shift TestRunInit_FreshDir count range [70-74] -> [71-75] (76
  embedded assets after registration); drift detection green
  (go test -race -count=1 ./internal/scaffold/...) and full make
  check green
- AGENTS.md: PR Review Commands table row and Project Structure
  slash-commands count 32 -> 33 (task 3.1)
- docs/usage.md: Quick Reference row (task 3.2)
- docs/architecture.md: Review Commands row (task 3.3)
- CHANGELOG.md: Unreleased -> Added port-uf-rebase-pr entry with
  (Spec: openspec/changes/port-uf-rebase-pr/, Fixes: unbound-force#851) per
  spec-review advisory (task 3.4)

Docs-line references to be appended once task 4.4 files the
documentation-gate issues.
Task 4.2: make check green (lint, go test -race -count=1, build,
coverage-gate, plugin-test 1263 tests / 95.35% statements).
Task 4.3: confirmed .local-sources/ is git-excluded and appears
in no commit, artifact, or scaffold mirror (design D9).
Task 4.4: filed the documentation-gate issues —
unbound-force#856 (per-surface dispositions;
tutorial unbound-force#855) and unbound-force/website#340 (website sync) —
and recorded both numbers in the CHANGELOG entry and
proposal.md Impact section.

Spec: openspec/changes/port-uf-rebase-pr/
@jflowers
jflowers force-pushed the opsx/port-uf-rebase-pr branch from ef457dc to 8134c16 Compare October 29, 2026 00:16

@jflowers jflowers left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review: APPROVE WITH ADVISORIES

The review council ran 5 personas: 4 succeeded (architect, curator, guard, testing — each returning APPROVE WITH ADVISORIES) and 1 failed (adversary — child session error, excluded per RD-FR-025). All 17 CI checks pass, skip, or report neutral; none fail.

Advisories

1. Stale CHANGELOG-format pins — MEDIUM (architect, curator, guard)
The delta spec's Documentation-updates requirement (spec.md:397), tasks.md task 3.4, and proposal.md's Impact bullet pin the CHANGELOG closing line as (Spec: …) + (Docs: #856, unbound-force/website#340) without Fixes: #851, while the shipped CHANGELOG.md entry correctly includes all three elements. .openspec.yaml records originating_issue: 851, and five shipped precedents carry Fixes: #NNN in the pinned closing line when an originating issue exists. Design D1 designates the delta spec as the sanctioned fallback for re-deriving the entry, so the stale pin re-seeds the format iteration 2 corrected. Recommended: add Fixes: #851 to all three pin texts before archive.

2. No content-presence tests for safety-critical command phrases — MEDIUM (testing) + LOW (architect)
The command's regression protection consists of mirror parity, asset registration, and deployment counts. None assert content presence, so symmetric degradation — dropping guardrail text from both the canonical command and its scaffold mirror — passes every gate. The command bounds destructive git operations (force-push history rewrite), the risk class the repo's stronger same-file precedent covers (TestSpecReviewPerFindingGateContracts and siblings pin site-unique phrases via assetContent() + strings.Contains). Spec Requirements 8-10 currently lack executable verification. Recommended: pin tests for the load-bearing phrases (--force-with-lease never --force; never push to base/protected branches; no-merge/no-approve; ^[1-9][0-9]*$ validation; <protect> delimiters; session-resume guard; git_rebase_abort off-ramp).

3. DE-001 deferral revisit condition recorded as prose only — LOW (architect, guard)
Design D2 bounds the remaining raw-bash prose with a revisit condition that has no owner, trigger, or tracked follow-up issue, and no issue number appears anywhere in the change. The deferral itself is sanctioned; the revisit path is the gap. Proposal Principle VI reads an unqualified PASS without counting the concession. Recommended: file or reference a tracked follow-up issue and cite it in design D2.

Inline comments carry the per-file details.

This review was generated by /uf.review-pr (AI-assisted).

`docs/architecture.md` Review Commands table, and a
`port-uf-rebase-pr:` entry in `CHANGELOG.md` under
"## Unreleased" → "### Added" carrying
"(Spec: openspec/changes/port-uf-rebase-pr/)" and, once

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This requirement pins the CHANGELOG closing line as (Spec: openspec/changes/port-uf-rebase-pr/) + (Docs: #856, unbound-force/website#340) only, but the shipped CHANGELOG.md entry closes with Fixes: #851 included. .openspec.yaml records originating_issue: 851, and five shipped precedents (review-voice-pack #657, spec-review-per-finding-gate #777, ts-plugin-coverage-gate #780, spawn-subtask-classification-params #830, fix-review-dispatch-correlation-release #794) pin Fixes: #NNN in the closing line when an originating issue exists. The same stale pin appears in tasks.md task 3.4 and proposal.md's Impact bullet. Design D1 designates this delta spec as the sanctioned fallback for re-deriving the CHANGELOG entry, so the incomplete pin re-seeds the format that spec-review iteration 2 corrected — and after archive the spec becomes canonical precedent. MEDIUM — cross-artifact-consistency (divisor-architect). Recommended: add Fixes: #851 to all three pin texts before archive.

`docs/architecture.md` Review Commands table, and a
`port-uf-rebase-pr:` entry in `CHANGELOG.md` under
"## Unreleased" → "### Added" carrying
"(Spec: openspec/changes/port-uf-rebase-pr/)" and, once

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The pin here and its siblings (tasks.md task 3.4, lines 86-88; proposal.md Impact bullet, lines 117-118) describe a two-element closing line, while the shipped CHANGELOG.md entry carries all three elements. A search for Fixes across the change directory returns zero matches. The change's own learnings (.uf/dewey/learnings/spec-authoring-20261028T202231-jay-flowers.md, …T202238-jay-flowers.md) document this defect class and prescribe correcting the pins before archive. MEDIUM — documentation-completeness (divisor-curator). Recommended: align the three pin texts with the shipped entry.

`docs/architecture.md` Review Commands table, and a
`port-uf-rebase-pr:` entry in `CHANGELOG.md` under
"## Unreleased" → "### Added" carrying
"(Spec: openspec/changes/port-uf-rebase-pr/)" and, once

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Iteration 2 corrected the shipped CHANGELOG entry, but the correction does not reach the pin artifacts: this requirement, tasks.md task 3.4 (tasks.md:86), and proposal.md:118 ("with Spec and Docs issue references"). MEDIUM — cross-artifact-consistency (divisor-guard). Recommended: add Fixes: #<originating_issue> to all three pin texts in this PR so the archived spec does not carry the incomplete format forward as canonical precedent.

"opencode/commands/uf.constitution-check.md",
"opencode/commands/uf.finale.md",
"opencode/commands/uf.init.md",
"opencode/commands/uf.rebase-pr.md",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This registration is the deepest content check the new command receives: mirror parity (TestEmbeddedAssets_MatchSource), list membership here, and deployment counts. None assert content presence, so dropping safety-critical guardrail text from both the canonical command and its scaffold mirror passes every gate. The command bounds destructive git operations — force-push history rewrite to PR head branches — and this file carries stronger precedent for exactly that risk class: TestSpecReviewPerFindingGateContracts (scaffold_test.go:163), TestUnleashCommand_ToolRoutingContracts (:325), TestDivisorGuard_DelegationDisciplineSpawnParameters (:3826), and TestDeterminismPack_DE008SpawnToolParameters (:3879) pin site-unique phrases via assetContent() + strings.Contains subtests. Spec Requirements 8-10 (bounded force-push, post-push verification, command file conventions) have no executable verification while the mechanism exists in this file. MEDIUM — regression-protection (divisor-testing). Recommended: pin tests asserting the load-bearing phrases — --force-with-lease, never --force; MUST NOT push to BASE_REMOTE/main/protected branches; no-merge/no-approve; the ^[1-9][0-9]*$ validation contract; the <protect> delimiters; the session-resume guard; the git_rebase_abort off-ramp.

`git status`, staging, `git rebase --continue`, and the
checkout fallback — no plugin tools exist for those, and
adding them is out of scope (Non-Goal). The exception is
bounded by a revisit condition: extraction is revisited

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

D2 bounds the remaining raw-bash prose (argument validation, remote-URL matching, gh existence checks) with a revisit condition — extraction when a second command needs the same remote-resolution or conflict-staging seam — but the condition lives only in this prose, with no owner, trigger, or tracked issue. The command ships as a tool-owned scaffold asset, so the deferral deploys to every uf init repo. The deferral itself is sanctioned (it matches the uf.review-pr.md command shape, and plugin tools are an explicit Non-Goal); the revisit path is the gap. LOW — determinism-debt (divisor-architect). Recommended: record the revisit condition as a tracked follow-up issue cited here.

`git status`, staging, `git rebase --continue`, and the
checkout fallback — no plugin tools exist for those, and
adding them is out of scope (Non-Goal). The exception is
bounded by a revisit condition: extraction is revisited

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The DE-001 deferral's revisit condition has no trigger, owner, or tracked follow-up issue, and no issue number appears anywhere in the change. The repo's determinism pattern requires deferrals recorded as a named follow-up change or tracked issue, and requires the Constitution Alignment section to count each prose-procedure concession — proposal Principle VI currently reads an unqualified PASS. LOW — determinism-governance (divisor-guard). Recommended: file or reference a tracked follow-up issue and cite it in D2; optionally qualify Principle VI with the counted concession.

Do NOT merge, approve, or close the PR. This command only makes the
PR ready to merge with a rebase once it is approved.

## Guardrails

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The Guardrails section's load-bearing phrases — <protect> delimiters, session-resume guard, ^[1-9][0-9]*$ validation contract, --force-with-lease never --force, never-push-base, no-merge/no-approve — receive only drift-parity and registration protection, which verifies canonical/mirror equality rather than content presence. Symmetric degradation (dropping guardrail text from both copies) passes every test. The repo carries a stronger sanctioned precedent for pinning site-unique phrases in command markdown; this command bounds destructive git operations, the case that precedent targets. LOW — structural-protection (divisor-architect). Recommended: see the testing reviewer's comment on scaffold_test.go — the same-file pin-test precedent applies here.

@jflowers
jflowers merged commit a7e8268 into unbound-force:main Oct 29, 2026
17 checks passed
@jflowers
jflowers deleted the opsx/port-uf-rebase-pr branch November 15, 2026 21:37
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.

uf.rebase-pr: port global resolve-branch-conflict command (rebase conflicted PR head onto base)

1 participant