Skip to content
CodeLifter
Search/ Browse prompts
CodeLifter Forum

What should a provenance record for copied code include?

Staff answerWritten by CodeLifter editors · Code provenance2 repliesupdated

Short answer

Record five things beside the copied code: where it came from, who or what wrote it, its licence as an SPDX identifier, a link to the exact source with the date you copied it, and the date someone last checked it. Put the licence where tools can read it, and keep the history in your commits.

Written by CodeLifter editors · Staff, CodeLifter ·
CiteCodeLifter Forum, "What should a provenance record for copied code include?", https://codelifter.com/forum/posts/what-should-a-provenance-record-for-copied-code-include/, accessed 2026-11-12.
  1. Staff, CodeLifter ·

    The five fields

    These five fields are the convention CodeLifter uses on its own pages, not a published standard. They answer the three questions people ask about any pasted code: who made it, may I use it, and is it still right.

    Field What to write Example
    Origin Where the code came from Forum answer, library example, assistant suggestion, your own older project, or a mix
    Author type Who wrote it Human, AI-assisted or AI-generated
    Licence An SPDX short identifier or expression MIT, CC-BY-SA-4.0, CC0-1.0
    Sources A link to the exact page, answer or commit, and the date you copied it https://example.org/answer/123, copied 2026-10-16
    Last verified The date a person last checked the code still works and still matches its source 2026-10-16

    Change the last verified date only when someone actually checks. Change the author type when generated code is later rewritten by hand, and say so. Keep the source link even after heavy edits; it is the evidence of where the idea came from. The CodeLifter guide to keeping a provenance record covers each field at more length.

    Work out the licence before you paste

    The licence field is the one people get wrong, because the licence depends on where and when the code was published.

    How to write it so tools can read it

    1. Whole file copied. Put an SPDX tag in a comment at or near the top of the file. Annex E of the SPDX specification describes SPDX-License-Identifier: followed by a licence expression in a comment, and notes that the information then travels with the file. The SPDX License List gives the exact identifier for each licence.
    2. A block pasted into a bigger file. Wrap it in snippet markers. Annex H of the SPDX specification describes SPDX-SnippetBegin and SPDX-SnippetEnd; licence tags between them apply only to that snippet. The annex is informative and says a document creator may disregard file tags, so not every tool reads these, but people do. The annex's own example is a function copy-pasted from another project, with SPDX-SnippetCopyrightText and SPDX-SnippetComment lines inside the markers.
    3. The rest of the fields. Put origin, author type, source and verified date in the same comment, in plain words.
    4. The change itself. Add the source link to the commit message too. A trailer is a key and value at the end of the message after a blank line; if your team uses one for assistant help, record that there as well.

    A pasted Stack Overflow function might then carry this, in a JavaScript file:

    // SPDX-SnippetBegin
    // SPDX-License-Identifier: CC-BY-SA-4.0
    // SPDX-SnippetCopyrightText: <answer author's display name>
    // Origin: Stack Overflow answer, adapted (renamed variables, added null check)
    // Author type: human
    // Source: https://stackoverflow.com/a/<answer-id>, copied 2026-10-16
    // Last verified: 2026-10-16
    function debounce(fn, ms) { /* ... */ }
    // SPDX-SnippetEnd
    

    The angle-bracket parts are placeholders; fill them from the actual answer page.

    For a whole repository

    If many files carry copied code, follow the REUSE Specification 3.3. It says each covered file must have licensing information, usually an SPDX-FileCopyrightText line and an SPDX-License-Identifier line in a header, and the licence texts go in a LICENSES/ directory at the project root. Files that cannot hold a comment, such as images, get a neighbouring .license file, and a REUSE.toml file covers directories where headers are impractical.

    What a software bill of materials does not cover

    An SBOM records the packages a build contains. The NTIA's 2021 report sets seven baseline fields, from supplier name and component name to version, identifiers, dependency relationship, the author of the SBOM data and a timestamp. It rarely says that one function was adapted from a forum answer, which is the gap the five fields fill.

    If a reviewer questions old code, the record above is what you will reach for; see a detector flagged code written in 2019 as AI. For the commit side of the record, see enforcing an Assisted-by trailer.

    0
    ReplyLink

Plain text or simple Markdown. Links are nofollow. Your email is never shown.

  1. CodeLifter editorsStaffStaff, CodeLifter ·

    How do you attribute a Stack Overflow answer you copied? Give the credit the CC BY-SA 4.0 licence asks for, next to the code. Stack Exchange content is under that licence, and the licence deed lists what appropriate credit means: the name of the creator and attribution parties, a copyright notice, a licence notice, a disclaimer notice, and a link to the material. It also asks you to provide a link to the licence and to indicate if changes were made. In a code comment that becomes: the author's display name, a link to the specific answer, the words "CC BY-SA 4.0" with a link to the licence, and a note such as "adapted: renamed variables, added null check". The SPDX snippet block in the opening post carries most of this; add the licence URL and the change note if your copy does not already have them. The ShareAlike part is the one with consequences. The deed says that if you remix or build on the material, you must distribute your contributions under the same licence. Creative Commons recommends against its licences for software, so for anything more than a few lines, the cleaner choice is often to write your own version from the idea and record the answer as a source you read.

  2. CodeLifter editorsStaffStaff, CodeLifter ·

    Does Copilot tell you when a suggestion matches public code? It can, through a feature GitHub calls code referencing. GitHub's code referencing documentation says that when a completion matches code in a public repository, Copilot can log the match, and the log entry includes the URLs of files containing matching code and the name of the licence found there. The same page says matches to public code occur in less than one percent of Copilot suggestions. Two limits matter for a provenance record. The check looks at the suggestion as offered, so code you change after accepting it is not checked again. And the absence of a log entry means no match was found, not that the code has no source; it says nothing about patterns copied from docs or from your own older files. If a match is logged, treat it like any other copied snippet: open the linked file, read its licence, and fill in the origin, licence and source fields from the opening post, with the date. If the licence is one you cannot meet, rewrite the code rather than keep it. Other assistants document their own features differently; check your tool's documentation rather than assuming one exists.

CodeLifter

Reviewed vibe coding prompts, the JavaScript each one should produce, and sourced answers on AI-generated code: who wrote it, who owns it, and whether you can ship it. Free since 1999.

Browse the Prompt Shelf

Popular topics

© 1999 to 2026 CodeLifter

Independent. No ties to any software vendor.
Code MIT Text CC-BY-4.0 Back to top