mirror of
https://github.com/eclipse-threadx/threadx.git
synced 2026-10-06 06:59:08 +08:00
* Normalized the AI disclosure line across every tracked file type The repository-wide pass covered source files only, so build files, CMake toolchain files, shell scripts and the GDB and manifest files kept the older per-edit form of the disclosure comment, which names a product and a model version. The Cortex-R52 module manager port then merged after that pass and brought the old form back into the sources as well. Replaced it with the fixed text in all of them, using the comment character each file already uses. Comment-only. 143 files, one line each. The repository now holds 601 files carrying exactly one disclosure line, none carrying the old form, and none carrying more than one. Assisted-by: Claude Code (Opus 5) <noreply@anthropic.com> * Added a check that keeps the AI disclosure comment in its one accepted form Nothing enforced the disclosure convention, so the drift it exists to prevent returned twice: once when a port merged after the normalisation pass carrying the older per-edit form, and once because that pass had covered source files only, leaving build files and scripts untouched for months. Added scripts/check_ai_disclosure.sh, which rejects the superseded per-edit form, a doubled comment marker, more than one disclosure line in a file, and any spelling of the line that is not exact. It runs from repo_checks.yml, a workflow with no path filter, because a source-path filter is what hid the build files the first time. The check passes on this branch. Each of its four rules was confirmed to fail on a tree with that defect reintroduced, and to pass once it was removed. Assisted-by: Claude Code (Opus 5) <noreply@anthropic.com> * Normalised the disclosure lines that landed after this branch Thirteen files reached dev after this branch was written, each carrying the superseded per-edit form. txm_module_manager_dispatch.h reached it with six stacked copies, naming the same product and the same model every time -- the accumulation the fixed text exists to prevent. Each of those files now carries one disclosure line in the accepted form. Where the accepted line was already present, the superseded ones are deleted rather than converted, so no file gains a second. check_ai_disclosure.sh reported eighteen hits across thirteen files before the pass and passes after it. Assisted-by: Claude Code (Opus 5) <noreply@anthropic.com> * Exempted Markdown from the near-miss disclosure check The near-miss rule flags any line carrying the phrase "AI assistance" that is not the accepted text, which is right for source but wrong for documentation. The contribution guide has to quote the accepted line and say when it applies, so the check reports two paragraphs of prose as drift and fails the build. Markdown is now exempt from that rule alone. The three rules that matter for a documentation file -- superseded form, doubled comment marker, duplicate line -- still scan it, so a stale disclosure in a Markdown file is still caught. The check passes against a tree carrying the rewritten contribution guide, and still fails when a near miss is planted in a source file. Assisted-by: Claude Code (Opus 5) <noreply@anthropic.com> * Corrected the trailer command named in the disclosure check The header comment points a reader at git's own trailer parser to find out which agents have touched a file. That parser reads trailers only from a block at the very end of a message, so a squash merge -- which concatenates a branch's messages -- buries every trailer but the last one mid-message, and an indented trailer is skipped outright. On dev it finds 122 attributions where 163 exist. The comment now names count_assisted_by.sh, which reads whole bodies. Assisted-by: Claude Code (Opus 5) <noreply@anthropic.com>
130 lines
5.1 KiB
Bash
Executable File
130 lines
5.1 KiB
Bash
Executable File
#!/bin/bash
|
|
###############################################################################
|
|
# Copyright (c) 2026 Eclipse ThreadX contributors
|
|
#
|
|
# This program and the accompanying materials are made available under the
|
|
# terms of the MIT License which is available at
|
|
# https://opensource.org/licenses/MIT.
|
|
#
|
|
# AI Disclosure: This file was largely AI-generated by Claude Code (Opus 5).
|
|
# The AI-generated portions may be considered public domain (CC0-1.0)
|
|
# and not subject to the project's licence. The human contributor has
|
|
# reviewed and verified that the code is correct.
|
|
#
|
|
# SPDX-License-Identifier: MIT and CC0-1.0
|
|
###############################################################################
|
|
#
|
|
# Fail the build if a file's AI disclosure comment has drifted from the one
|
|
# accepted form.
|
|
#
|
|
# A file that was edited with AI assistance carries exactly one line:
|
|
#
|
|
# Portions of this file were generated with AI assistance.
|
|
#
|
|
# written with the comment character that file already uses. It names no
|
|
# product, no model and no version, and a file carries at most one of it, ever.
|
|
#
|
|
# The text is fixed for a reason that is easy to miss. An earlier convention
|
|
# named the product and the model -- "Some portions generated by <product>
|
|
# (<model>)" -- and the result was not attribution but accumulation: each tool
|
|
# that touched a file failed to recognise the line another tool had left, and
|
|
# appended its own. Files reached three stacked lines, and one product ended
|
|
# up spelled four different ways across the tree, which made the record
|
|
# unusable for the one question it was meant to answer.
|
|
#
|
|
# Precise attribution lives on the commit instead, where the Assisted-by
|
|
# trailer is dated and attached to the diff it describes:
|
|
#
|
|
# scripts/count_assisted_by.sh --list <rev> -- <path>
|
|
#
|
|
# A file-level flag answers WHETHER; the history answers WHO. A header line
|
|
# cannot hold the second honestly, because the code it names gets rewritten
|
|
# and the line stays.
|
|
#
|
|
# The AI Disclosure paragraph in a new file's copyright header is different and
|
|
# is not checked here: it keeps its product and model version, because a file
|
|
# is created once and that record cannot grow.
|
|
#
|
|
# This script is excluded from its own scan. It has to spell the rejected
|
|
# forms in order to look for them.
|
|
|
|
set -euo pipefail
|
|
|
|
readonly ROOT="$(cd "$(dirname "$(realpath "$0")")/.." && pwd)"
|
|
readonly SELF='scripts/check_ai_disclosure.sh'
|
|
readonly FIXED='Portions of this file were generated with AI assistance.'
|
|
|
|
cd "${ROOT}"
|
|
|
|
# Tracked files only. A build tree is not this repository's text to police,
|
|
# and scanning one would make the check depend on whether somebody had built.
|
|
mapfile -d '' -t FILES < <(git ls-files -z | grep -zZv "^${SELF}$")
|
|
|
|
status=0
|
|
|
|
report() {
|
|
printf '%s\n\n' "$1" >&2
|
|
printf '%s\n\n' "$2" >&2
|
|
status=1
|
|
}
|
|
|
|
# 1. The superseded per-edit form, which names a product and a model.
|
|
hits="$(grep -nI 'Some portions generated by' -- "${FILES[@]}" 2>/dev/null || true)"
|
|
if [ -n "${hits}" ]; then
|
|
report "AI disclosure check FAILED: superseded per-edit form.
|
|
|
|
Replace each of these with the fixed line, keeping the file's comment
|
|
character:
|
|
|
|
${FIXED}" "${hits}"
|
|
fi
|
|
|
|
# 2. A doubled comment marker, such as '; //' or '@ //'. Assembly dialects
|
|
# differ -- armasm and IAR use ';', GNU as uses '@' or '//' -- and writing
|
|
# both is a symptom of a tool guessing rather than reading the file.
|
|
hits="$(grep -nIE '(//|[;@#])[[:space:]]*//[[:space:]]*Portions of this file were generated' \
|
|
-- "${FILES[@]}" 2>/dev/null || true)"
|
|
if [ -n "${hits}" ]; then
|
|
report "AI disclosure check FAILED: doubled comment marker.
|
|
|
|
Use the single comment character the rest of the file uses." "${hits}"
|
|
fi
|
|
|
|
# 3. More than one disclosure line in a file. This is the failure the fixed
|
|
# text exists to prevent, so it is worth catching directly rather than
|
|
# inferring it from the form.
|
|
hits="$(grep -cIF "${FIXED}" -- "${FILES[@]}" 2>/dev/null | awk -F: '$NF > 1' || true)"
|
|
if [ -n "${hits}" ]; then
|
|
report "AI disclosure check FAILED: more than one disclosure line.
|
|
|
|
A file carries at most one, ever. Keep the first and delete the rest; the
|
|
commit trailer, not the header, records which agents have touched the file." "${hits}"
|
|
fi
|
|
|
|
# 4. A near miss. A line that is clearly meant to be the disclosure but is
|
|
# not spelled exactly right defeats every deduplication that follows it.
|
|
#
|
|
# Markdown is exempt from this one check. The contribution guide has to
|
|
# quote the accepted text and explain when it applies, so matching the bare
|
|
# phrase there reports prose rather than drift. A superseded form in a
|
|
# Markdown file is still caught by check 1.
|
|
mapfile -d '' -t SOURCES < <(printf '%s\0' "${FILES[@]}" | grep -zZv '\.md$' || true)
|
|
hits=''
|
|
if [ "${#SOURCES[@]}" -gt 0 ]; then
|
|
hits="$(grep -nIF 'AI assistance' -- "${SOURCES[@]}" 2>/dev/null \
|
|
| grep -vF "${FIXED}" || true)"
|
|
fi
|
|
if [ -n "${hits}" ]; then
|
|
report "AI disclosure check FAILED: the text is not spelled exactly.
|
|
|
|
The accepted text, character for character, is:
|
|
|
|
${FIXED}" "${hits}"
|
|
fi
|
|
|
|
if [ "${status}" -eq 0 ]; then
|
|
echo "AI disclosure check passed."
|
|
fi
|
|
|
|
exit "${status}"
|