Repository navigation
fix(deps): parse repository names ending in .git characters - #3767
Daniel Meppiel (danielmeppiel) merged 9 commits into
Conversation
`part.rstrip(".git")` stripped a character set, so repository names
such as git/git, jonas/tig or owner/gitit were emptied and rejected in
shorthand form, and URL-form installs persisted an unparseable apm.yml
entry. Use removesuffix, and fix the same bug class in marketplace
pluginRoot subtraction (`lstrip("./")` ate the dot of ./.hidden).
Reject repository path segments made only of dots in the canonical
final validator: Windows drops trailing dots, so `owner/...` would alias
its owner directory on disk.
Add the contracts-tooling-strip-charset architecture guard (Ruff B005
cannot see unique-character literals) with an allowlist of deliberate
character sets, a MutationCase, and a parse/serialize round-trip
property test.
apm-spec-waiver: parser bug fix restoring accepted repository names; no spec requirement changes
Co-authored-by: goranai <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: goranai <[email protected]> Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Accepted repository references do not round-trip safely through manifest serialization, potentially causing later installs to target a different repository or reject the saved reference.
1 open issue
What changed in this PR
Addresses #3715 by correcting literal suffix handling in dependency parsing and prefix handling in marketplace paths. It also adds all-dot repository path validation and regression guards against character-set stripping mistakes.
Changes:
- Accepts repository names such as
git/gitandjonas/tig, with parsing and manifest round-trip tests. - Preserves hidden plugin source paths and rejects repository segments made entirely of dots.
- Registers an architecture guard for multi-character strip literals, with mutation coverage.
| File | Description |
|---|---|
tests/unit/scripts/test_architecture_runner.py |
Adds the new guard to the expected rule inventory. |
tests/unit/models/test_dependency_reference_git_suffix.py |
Tests repository names, all-dot rejection, and manifest round-trips. |
tests/unit/marketplace/test_builder_security.py |
Tests preservation of hidden plugin paths. |
tests/integration/test_architecture_owner_rule_mutations.py |
Adds a mutation that restores the faulty suffix stripping. |
src/apm_cli/utils/path_security.py |
Adds optional all-dot segment rejection. |
src/apm_cli/models/dependency/reference.py |
Uses literal suffix removal and enables all-dot validation. |
src/apm_cli/marketplace/output_mappers.py |
Removes only the literal ./ prefix. |
scripts/architecture_linter/checks/contracts_test_taxonomy.py |
Registers the strip-literal guard. |
scripts/architecture_linter/checks/contracts_strip_charset.py |
Detects multi-character strip literals outside an allowlist. |
CHANGELOG.md |
Documents the parsing and marketplace fixes. |
.apm/architecture/owners/contracts-tooling.json |
Registers ownership and guard metadata for literal affix removal. |
Review effort: Balanced
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Supply Chain Security Expert | 0 | 0 | 0 | removesuffix fix and all-dots rejection are sound; all parse paths converge at the final validator; the lint closes the bug class; no identity confusion or path-aliasing regressions. |
| Python Architect | 0 | 0 | 0 | AST guard, owner registry entry, MutationCase and rule wiring are sound; no selector collision, no false-negative gap, no split authority. |
| Test Coverage Expert | 0 | 2 | 0 | Parse regression traps are strong; round-trip through apm.yml is unasserted for non-HTTPS forms despite Done-when requiring it. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 2 follow-ups
- [Test Coverage Expert] Add a round-trip assertion (parse ->
to_apm_yml_entry-> re-parse) for shorthand, FQDN, ADO and SCP forms intest_names_ending_in_git_characters_parse. -- Directly traps a Done-when item; the hypothesis round-trip covers HTTPS only. - [Test Coverage Expert] Add
tests/unit/scripts/test_contracts_strip_charset.pycovering allowlist pass-through, bytes-literal flagging andscripts/scope scanning. -- The MutationCase proves the guard fires for the target mutation, but allowlisted literals, bytes constants and thescripts/tree are untrapped.
Recommendation
The code is correct per all three specialists and the author's targeted, mutation and regression validation. Fold the two test-coverage follow-ups in-PR (both are inside the approved scope and mechanical): round-trip assertion first, guard unit tests second.
Full per-persona findings
Python Architect
No findings.
Supply Chain Security Expert
No findings.
Test Coverage Expert
- [recommended] Parametrized parse test does not assert round-trip through
to_apm_yml_entryfor shorthand, FQDN, ADO and SCP forms attests/unit/models/test_dependency_reference_git_suffix.py:38
Done-when requires the six names to parse AND round-trip through apm.yml. The hypothesis round-trip is https-only; the parametrized test only asserts repo_url.
Suggested: Extend the parametrized test to re-parseto_apm_yml_entry()and assert repo_url/host stability.
Proof (passed):tests/unit/models/test_dependency_reference_git_suffix.py::test_names_ending_in_git_characters_parse-- proves: names ending in .git characters parse in every form, but round-trip is not asserted for non-HTTPS forms. [portability-by-manifest,devx] - [recommended] Strip-charset AST guard has no direct unit tests for allowlist pass-through, bytes literals or
scripts/scope scanning atscripts/architecture_linter/checks/contracts_strip_charset.py
The MutationCase proves the guard fires for removesuffix -> rstrip in src/apm_cli/, but allowlist pass-through, bytes violations and the scripts/ prefix are untrapped.
Suggested: Add unit cases: single-char ok, allowlisted[]ok,.gitflagged,b".git"flagged, scripts/ path scanned.
Proof (missing at):tests/unit/scripts/test_contracts_strip_charset.py-- proves: allowlisted multi-char strip literals pass while non-allowlisted ones (incl. bytes, scripts/) are flagged. [governed-by-policy,secure-by-default]
This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.
Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.
|
Thanks for taking this forward and for the credit. I checked out af1e695 and it looks good to me.
The Copilot note reproduces: |
Parsing removes exactly one ".git" transport suffix. A name such as owner/git.git.git therefore became owner/git.git, whose apm.yml entry reparsed as owner/git (and to_clone_url fetched owner/git), and owner/.git.git serialized to the rejected owner/.git. The canonical final repository validator now rejects a repository name that still ends in ".git", for every form (shorthand, FQDN, HTTPS, SCP, ADO). Also traps the remaining Done-when items: the parametrized cases now round-trip through to_apm_yml_entry in every form, and the strip-charset guard gets direct unit tests (allowlist pass-through, bytes literals, src/apm_cli/ and scripts/ scope, tests/ excluded). Addresses Copilot inline on src/apm_cli/models/dependency/reference.py:1526 and panel follow-ups 1-2 on #3767. apm-spec-waiver: dependency-reference parsing fix with no OpenAPM requirement change Co-authored-by: goranai <[email protected]> Co-authored-by: Copilot App <[email protected]>
Adds the RT4 real-CLI lifecycle for repository names that end in git letters (install, manifest replay, audit, uninstall across GitHub, GitLab FQDN, ADO and URL forms; older bricked manifests; dot-only and double .git names rejected without writes; marketplace ./.hidden sources) with its SkillSelectionWorld helper. The final-name check now decodes the non-ADO segment with path_security.decode_url_path_segments instead of a raw unquote (transport-platform-url-path-security), so an encoded owner/git%2Egit.git is rejected too. apm-spec-waiver: dependency-reference parsing fix with no OpenAPM requirement change Co-authored-by: goranai <[email protected]> Co-authored-by: Copilot App <[email protected]>
Co-authored-by: goranai <[email protected]> Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Supply Chain Security Expert | 0 | 0 | 0 | Reject-on-residual-.git is the correct identity-safety primitive; encoded, ADO and all parse forms covered; no lockfile breakage risk. |
| Test Coverage Expert | 0 | 0 | 0 | Both prior follow-ups trapped; double-.git rejection covered at unit and real-CLI tiers; lifecycle test hermetic and meaningful. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Recommendation
All prior follow-ups are folded and verified, both panelists return zero findings, CI is green at d43dae2 (5d87627 plus a clean merge of main), and the reporter agrees with the rejection approach. No remaining items to track; merge at maintainer discretion.
Folded in this run
- (copilot) Reject repository names that still end in
.gitonce the single.gitsuffix is removed, in the canonical final validator for every form (encoded names are decoded with the path_security decoder) -- resolved in 2be567b, 8b874d0. - (panel) Round-trip parse ->
to_apm_yml_entry-> parse asserted for shorthand, FQDN, ADO, HTTPS and SCP -- resolved in 2be567b. - (panel) Direct unit tests for the strip-charset guard -- resolved in 2be567b.
- (captain) Red-team real-CLI lifecycle folded, plus an
owner/git.git.gitrejection case; CHANGELOG states the narrowing -- resolved in 8b874d0, 5d87627.
Copilot signals reviewed
src/apm_cli/models/dependency/reference.py:1526-- LEGIT: round-trip is a Done-when item; fixed by rejection becauseto_clone_url()does not append.git(resolved in 2be567b). Thread resolved.
Regression-trap evidence (mutation-break gate)
tests/unit/models/test_dependency_reference_git_suffix.py-- deleted the final-name.gitreject calls; 6 cases FAILED as expected; guard restored.tests/unit/scripts/test_contracts_strip_charset.py-- deletedscripts/from the scan scope, then bytes support; each FAILED as expected; guard restored.tests/integration/test_architecture_owner_rule_mutations.py-- MutationCaseremovesuffix(".git")->rstrip(".git")is caught bycontracts-tooling-strip-charset.
Lint contract
At d43dae2: uvx [email protected] check and format --check silent; pylint R0801 10.00/10; scripts/lint-auth-signals.sh clean; bash scripts/lint-architecture-boundaries.sh exit 0.
CI
All checks green at d43dae2: CI, Merge Gate, Spec conformance, CodeQL, NOTICE Drift. One CI fix iteration: Windows Native Symlink Acceptance failed at 5d87627 during runner profile cleanup (infra); the rerun was green.
Mergeability status
| PR | head SHA | CEO stance | iters | folds | defers | Copilot rounds | CI | mergeable | mergeStateStatus | notes |
|---|---|---|---|---|---|---|---|---|---|---|
| #3767 | d43dae2 | ship_now | 1 | 4 | 0 | 2 | green | MERGEABLE | BLOCKED | pending required review |
Full per-persona findings
Supply Chain Security Expert
No findings.
Test Coverage Expert
No findings.
This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.
Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.
…piel-t4-pr-3767-review-merge
…piel-t4-pr-3767-review-merge # Conflicts: # tests/utils/skill_selection_world.py
…piel-t4-pr-3767-review-merge
…piel-t4-pr-3767-review-merge

Description
Repository names whose last characters are in
.git(for examplegit/git,jonas/tig,owner/gitit) were rejected in shorthand form becausepart.rstrip(".git")strips a character set, not a suffix. URL-form installs of such repos also wrote anapm.ymlentry that could not be parsed back. Before:apm install git/gitfailed with "Invalid repository path component: git". After: it parses in every form (shorthand, FQDN shorthand, ADO, HTTPS, SCP) and round-trips throughapm.yml.Changes:
models/dependency/reference.py:removesuffix(".git")(a bare.gitsegment is still rejected).marketplace/output_mappers.py: the same bug class,lstrip("./"), removed the leading dot of./.hidden/...plugin sources underpluginRoot: ./or.; nowremoveprefix("./")..gitafter the single.gittransport suffix is removed (owner/git.git.git,owner/.git.git, encodedgit%2Egit.git): such a name was written back toapm.ymlas a different repository, andto_clone_url()would fetch the shorter name. GitHub and GitLab do not allow repository names that end in.git.utils/path_security.py+ the canonical final repository validator: reject path segments made only of dots (owner/..., including percent-encoded). GitHub already refuses.and..as repository names; Windows drops trailing dots from names (https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file: "Do not end a file or directory name with a space or a period"), soowner/...would aliasapm_modules/owneron disk.contracts-tooling-strip-charset(ownerliteral-affix-removal): Ruff B005 only flags strip literals with duplicate characters, so it cannot see.gitor./. The guard rejects any multi-characterstrip/lstrip/rstripliteral undersrc/apm_cli/andscripts/unless it is an allowlisted deliberate character set. Today's inventory: exactly the 3 bug sites fixed here; 12 allowlisted literals..gitcase above, which already produced anapm.ymlentry naming a different repository.tests/integration/test_git_named_repository_lifecycle.py(folded from the 0.36.1 red team).Co-authored with Goran (@goranai), who reported the bug and proposed the
removesuffixfix and test cases. Thank you!Issue and approved scope
Issue: Fixes #3715
Human scope-approval comment: #3715 (comment)
Completes the issue. Not in scope: consolidating every
.gitsuffix idiom into one helper.Type of change
Testing
Validation evidence: see the merge-worker update below for the current head. Original evidence (head 564ecf5, base main 2769573):
.venv/bin/python -m pytest -p no:xdist -q tests/unit/models/test_dependency_reference_git_suffix.py tests/unit/marketplace/test_builder_security.py-> 27 passed. On pre-fixsrc/the same command -> 11 failed (all.git-character names, URL-form all-dot names, the round-trip property, both./.hiddencases)..venv/bin/python -m pytest -p no:xdist -q tests/integration/test_architecture_owner_rule_mutations.py -k "tooling-strip or covers_every or deterministic or report_nothing"-> 6 passed (mutationremovesuffix->rstripis caught)..venv/bin/python -m pytest -p no:xdist -q tests/unit/scripts/test_architecture_runner.py-> 72 passed..venv/bin/python -m pytest -p no:xdist -q tests/unit/test_generic_git_urls.py tests/unit/test_path_security.py tests/unit/test_reference_registry_shorthand.py tests/unit/marketplace/ tests/unit/models/-> 2325 passed, 17 xfailed.uvx [email protected] checkandformat --check(src, tests, architecture linter) -> clean; pylint R0801 -> 10.00/10;bash scripts/lint-auth-signals.sh-> clean;python scripts/lint_architecture_boundaries.py --root .-> exit 0.Spec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.