Skip to content

docs(issues): add specification for #2195 - #2196

Closed
da2ce7 wants to merge 5 commits into
torrust:developfrom
da2ce7:2195-merge-wrapper-python-port-spec
Closed

da2ce7 wants to merge 5 commits into
torrust:developfrom
da2ce7:2195-merge-wrapper-python-port-spec

Conversation

@da2ce7

@da2ce7 da2ce7 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Related to #2195

Summary

This pull request adds the reviewed specification for issue #2195 and contains no implementation, so it does not resolve the issue.

The specification replaces contrib/dev-tools/git/merge-pull-request.sh with contrib/dev-tools/git/merge-pull-request.py, a repository-neutral program beside the vendored engine that performs the same preflight and the same delegation. The engine already reads every repository fact from Git configuration; the wrapper does not, holding EXPECTED_REPOSITORY="torrust/torrust-tracker", TARGET_BRANCH="develop" and SYMLINK_DECLARATION=".symlinks.json" as constants and refusing to run anywhere else. The concrete cost is torrust/torrust-index, which carries the symbolic link that made the declaration mechanism necessary but ships no copy of contrib/dev-tools/git, so a maintainer there invokes the engine directly and loses the argument check, the clean-tree check, the current-branch check, the repository-local signing message, the terminal guard, --dry-run, and the --symlinks argument without which no declaration is processed at all.

What the specification decides

The repository is validated by shape, never by value: githubmerge.repository is required and must match <owner>/<repo>, and AD2 states why the equality check that is given up was never a safety property, since the engine builds its fetch remote from the same locally configured value and displays the merge details before anything is signed.

The target branch comes from githubmerge.branch with a documented default of develop, and the declaration path from githubmerge.symlinks with a documented default of .symlinks.json, validated with the rule the engine applies to --symlinks and passed unconditionally, because an off switch would let a repository lift a refusal by editing configuration instead of by committing a reviewed declaration.

Delegation uses os.execv on sys.executable, so the engine's exit code remains the command's exit code and the engine runs under the interpreter that just executed the preflight. The interpreter-on-PATH check becomes a documented and program-checked minimum version, and the bash suite's script(1) probe disappears with its dependency once the pseudo-terminal comes from pty.openpty().

The bash suite is replaced by contrib/dev-tools/git/tests/test-merge-pull-request.py in the conventions of the existing engine suite, and a behavior mapping table accounts for every behavior of the shell wrapper and every one of its thirteen cases, marking exactly two as dropped with the reason each stops existing and exactly one as deliberately changed.

The specification also plans an ignore rule for __pycache__/, which .gitignore carries for no Python file today: a cache written beside the program leaves an untracked directory in contrib/dev-tools/git/, and the wrapper's own clean-tree check refuses a tree that carries one.

Files touched

Only docs/issues/ and project-words.txt. Against develop the branch adds one document, docs/issues/open/2195-merge-wrapper-python-port/ISSUE.md, and three dictionary entries, execv, openpty and pycache; no source, test, workflow or manifest is changed here. The port itself follows in a separate implementation pull request from the reserved 2195-merge-wrapper-python-port branch.

Validation performed

Six documentation gates were run at the branch tip 00a4bfe8, all green: linter markdown (5.8 s), linter cspell (8.7 s), linter yaml (0.4 s), linter toml (0.1 s), linter shellcheck (1.4 s), and lychee --offline over the new document (0.05 s). The branch changes no Rust, so clippy and rustfmt have nothing to report on it and were not run.

The document moved from docs/issues/drafts/merge-wrapper-python-port/ to docs/issues/open/2195-merge-wrapper-python-port/, which is the same directory depth, so its two relative links, to contrib/dev-tools/git/README-github-merge.md and to the merge-pull-request skill, are unchanged and still resolve; lychee confirms this independently. git diff --check over the branch range against develop reports no whitespace defects.

Copilot AI lite review requested due to automatic review settings September 10, 2026 14:05

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Adds a reviewed, implementation-free specification for issue #2195 describing a repository-neutral Python rewrite of the maintainer merge wrapper.

Changes:

  • Added an issue specification document detailing goals, architectural decisions, behavior mapping, and acceptance criteria for the port.
  • Extended the project dictionary to include new technical terms used by the spec.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
docs/issues/open/2195-merge-wrapper-python-port/ISSUE.md New spec document defining the planned Python port, behavior parity, and verification plan for #2195.
project-words.txt Adds spellcheck allowlist entries referenced by the new spec.

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

Comment on lines +37 to +39
The vendored engine `contrib/dev-tools/git/github-merge.py` bakes in no repository identity. It reads `githubmerge.repository` (line 543), `githubmerge.host` (line 544), `githubmerge.branch` (line 545), `githubmerge.merge-author-email` (line 546), `githubmerge.testcmd` (line 547), `user.ghtoken` (line 548) and `user.signingkey` (line 549) from Git configuration, and its own help text (lines 513-522) documents them as the configuration surface. Its one Torrust-named constant, `SYMLINK_DECLARATION_NAMESPACE` (line 240), names the declaration format rather than a repository, which the comment above it and the format documentation both state; every repository adopting the workflow carries the same value. The engine is configuration-driven all the way down.

The wrapper is not. `merge-pull-request.sh` holds `EXPECTED_REPOSITORY="torrust/torrust-tracker"` (line 11), `TARGET_BRANCH="develop"` (line 12) and `SYMLINK_DECLARATION=".symlinks.json"` (line 13), and `require_repository_configuration` (lines 38-50) exits unless `githubmerge.repository` is exactly equal to the first of them. The same string is asserted in the wrapper's own test suite (`contrib/dev-tools/git/tests/test-merge-pull-request.sh` lines 44, 65, 109, 134, 271), in the sibling engine suite's fixture (`contrib/dev-tools/git/tests/test-github-merge-symlinks.py` line 30), in `contrib/dev-tools/git/README-github-merge.md` (lines 4-6) and in `.github/skills/dev/git-workflow/merge-pull-request/SKILL.md` (lines 21-22, 63, 70).
Comment on lines +139 to +142
| ID | Status | Task | Notes / Expected Output |
| --- | ------ | ---- | ----------------------- |
| T1 | TODO | Establish the program skeleton and its first slice | `merge-pull-request.py` with the command line, the interpreter-version floor, the `git` helper and one configuration read, plus the test module that exercises them. Reviewed before the remaining behaviors are ported. |
| T2 | TODO | Port argument handling | `--dry-run`, `-h`/`--help`, and a pull-request argument accepted only in the shape the shell wrapper accepts, with the current message text and exit code `2`. |
Copilot stopped reviewing on behalf of da2ce7 due to an error September 10, 2026 14:26
@josecelano

Copy link
Copy Markdown
Member

I've commented on #2195 (comment). If you are using the script in Torrust Index, you should consider build it there and we can copy it later to the Torrust Tracker repo. But I totally discourage using bash or python if not temporarily or justified.

@da2ce7

da2ce7 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Closing without merge: #2195 is deferred until the post-4.0.0 Rust automation work under #2003 decides where the merge-workflow preflight lives. The behaviour table and configuration design in this specification are language-independent and remain available on this branch for that port.

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.

3 participants