xref: /linux/Documentation/process/generated-content.rst (revision c17ee635fd3a482b2ad2bf5e269755c2eae5f25e)
1*a66437c2SDave Hansen============================================
2*a66437c2SDave HansenKernel Guidelines for Tool-Generated Content
3*a66437c2SDave Hansen============================================
4*a66437c2SDave Hansen
5*a66437c2SDave HansenPurpose
6*a66437c2SDave Hansen=======
7*a66437c2SDave Hansen
8*a66437c2SDave HansenKernel contributors have been using tooling to generate contributions
9*a66437c2SDave Hansenfor a long time. These tools can increase the volume of contributions.
10*a66437c2SDave HansenAt the same time, reviewer and maintainer bandwidth is a scarce
11*a66437c2SDave Hansenresource. Understanding which portions of a contribution come from
12*a66437c2SDave Hansenhumans versus tools is helpful to maintain those resources and keep
13*a66437c2SDave Hansenkernel development healthy.
14*a66437c2SDave Hansen
15*a66437c2SDave HansenThe goal here is to clarify community expectations around tools. This
16*a66437c2SDave Hansenlets everyone become more productive while also maintaining high
17*a66437c2SDave Hansendegrees of trust between submitters and reviewers.
18*a66437c2SDave Hansen
19*a66437c2SDave HansenOut of Scope
20*a66437c2SDave Hansen============
21*a66437c2SDave Hansen
22*a66437c2SDave HansenThese guidelines do not apply to tools that make trivial tweaks to
23*a66437c2SDave Hansenpreexisting content. Nor do they pertain to tooling that helps with
24*a66437c2SDave Hansenmenial tasks. Some examples:
25*a66437c2SDave Hansen
26*a66437c2SDave Hansen - Spelling and grammar fix ups, like rephrasing to imperative voice
27*a66437c2SDave Hansen - Typing aids like identifier completion, common boilerplate or
28*a66437c2SDave Hansen   trivial pattern completion
29*a66437c2SDave Hansen - Purely mechanical transformations like variable renaming
30*a66437c2SDave Hansen - Reformatting, like running Lindent, ``clang-format`` or
31*a66437c2SDave Hansen   ``rust-fmt``
32*a66437c2SDave Hansen
33*a66437c2SDave HansenEven whenever your tool use is out of scope, you should still always
34*a66437c2SDave Hansenconsider if it would help reviewing your contribution if the reviewer
35*a66437c2SDave Hansenknows about the tool that you used.
36*a66437c2SDave Hansen
37*a66437c2SDave HansenIn Scope
38*a66437c2SDave Hansen========
39*a66437c2SDave Hansen
40*a66437c2SDave HansenThese guidelines apply when a meaningful amount of content in a kernel
41*a66437c2SDave Hansencontribution was not written by a person in the Signed-off-by chain,
42*a66437c2SDave Hansenbut was instead created by a tool.
43*a66437c2SDave Hansen
44*a66437c2SDave HansenDetection of a problem and testing the fix for it is also part of the
45*a66437c2SDave Hansendevelopment process; if a tool was used to find a problem addressed by
46*a66437c2SDave Hansena change, that should be noted in the changelog. This not only gives
47*a66437c2SDave Hansencredit where it is due, it also helps fellow developers find out about
48*a66437c2SDave Hansenthese tools.
49*a66437c2SDave Hansen
50*a66437c2SDave HansenSome examples:
51*a66437c2SDave Hansen - Any tool-suggested fix such as ``checkpatch.pl --fix``
52*a66437c2SDave Hansen - Coccinelle scripts
53*a66437c2SDave Hansen - A chatbot generated a new function in your patch to sort list entries.
54*a66437c2SDave Hansen - A .c file in the patch was originally generated by a coding
55*a66437c2SDave Hansen   assistant but cleaned up by hand.
56*a66437c2SDave Hansen - The changelog was generated by handing the patch to a generative AI
57*a66437c2SDave Hansen   tool and asking it to write the changelog.
58*a66437c2SDave Hansen - The changelog was translated from another language.
59*a66437c2SDave Hansen
60*a66437c2SDave HansenIf in doubt, choose transparency and assume these guidelines apply to
61*a66437c2SDave Hansenyour contribution.
62*a66437c2SDave Hansen
63*a66437c2SDave HansenGuidelines
64*a66437c2SDave Hansen==========
65*a66437c2SDave Hansen
66*a66437c2SDave HansenFirst, read the Developer's Certificate of Origin:
67*a66437c2SDave HansenDocumentation/process/submitting-patches.rst. Its rules are simple
68*a66437c2SDave Hansenand have been in place for a long time. They have covered many
69*a66437c2SDave Hansentool-generated contributions. Ensure that you understand your entire
70*a66437c2SDave Hansensubmission and are prepared to respond to review comments.
71*a66437c2SDave Hansen
72*a66437c2SDave HansenSecond, when making a contribution, be transparent about the origin of
73*a66437c2SDave Hansencontent in cover letters and changelogs. You can be more transparent
74*a66437c2SDave Hansenby adding information like this:
75*a66437c2SDave Hansen
76*a66437c2SDave Hansen - What tools were used?
77*a66437c2SDave Hansen - The input to the tools you used, like the Coccinelle source script.
78*a66437c2SDave Hansen - If code was largely generated from a single or short set of
79*a66437c2SDave Hansen   prompts, include those prompts. For longer sessions, include a
80*a66437c2SDave Hansen   summary of the prompts and the nature of resulting assistance.
81*a66437c2SDave Hansen - Which portions of the content were affected by that tool?
82*a66437c2SDave Hansen - How is the submission tested and what tools were used to test the
83*a66437c2SDave Hansen   fix?
84*a66437c2SDave Hansen
85*a66437c2SDave HansenAs with all contributions, individual maintainers have discretion to
86*a66437c2SDave Hansenchoose how they handle the contribution. For example, they might:
87*a66437c2SDave Hansen
88*a66437c2SDave Hansen - Treat it just like any other contribution.
89*a66437c2SDave Hansen - Reject it outright.
90*a66437c2SDave Hansen - Treat the contribution specially, for example, asking for extra
91*a66437c2SDave Hansen   testing, reviewing with extra scrutiny, or reviewing at a lower
92*a66437c2SDave Hansen   priority than human-generated content.
93*a66437c2SDave Hansen - Ask for some other special steps, like asking the contributor to
94*a66437c2SDave Hansen   elaborate on how the tool or model was trained.
95*a66437c2SDave Hansen - Ask the submitter to explain in more detail about the contribution
96*a66437c2SDave Hansen   so that the maintainer can be assured that the submitter fully
97*a66437c2SDave Hansen   understands how the code works.
98*a66437c2SDave Hansen - Suggest a better prompt instead of suggesting specific code changes.
99*a66437c2SDave Hansen
100*a66437c2SDave HansenIf tools permit you to generate a contribution automatically, expect
101*a66437c2SDave Hansenadditional scrutiny in proportion to how much of it was generated.
102*a66437c2SDave Hansen
103*a66437c2SDave HansenAs with the output of any tooling, the result may be incorrect or
104*a66437c2SDave Hanseninappropriate. You are expected to understand and to be able to defend
105*a66437c2SDave Hanseneverything you submit. If you are unable to do so, then do not submit
106*a66437c2SDave Hansenthe resulting changes.
107*a66437c2SDave Hansen
108*a66437c2SDave HansenIf you do so anyway, maintainers are entitled to reject your series
109*a66437c2SDave Hansenwithout detailed review.
110