From patchwork Wed Dec 24 21:30:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1076 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766611899; bh=OGeqY3b7+8VFvMXmzcpSVu71VeEp3ueabDY0e4wbux0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ReMzLZ4W6K9nMNUFf/118VRArE4tkPozQFB0HFls7pYKjxHyAujnB33BpXf9vT5EK 6t/khsGiPRd3Cn4cQAbOwXrdil1/GKNyhu8lsaV46YPBTHzOszXBtOev3q06JAVNr1 l10l1MZyKXx271DR3d+Q5LHR0CnFa8edJ195BIiYRMGTsJ2mshOIakTkqLdXrGf6iT z3IEQnWike9DhmyPB/p4181zP3AOwdswFU+ZjL9IzvmYwKgl0FmhOlaWOd14q4sz0o 5PUa18+XdOnlXRRhiUTWAYMQWcXKUcRSFlLz+WMX9u3D/uro+Q9zFdNBIO7wNEyW17 o7oc5uLuT1QKg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 16F9364E50 for ; Wed, 24 Dec 2025 14:31:39 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id V4p8z0b8pC0U for ; Wed, 24 Dec 2025 14:31:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766611899; bh=OGeqY3b7+8VFvMXmzcpSVu71VeEp3ueabDY0e4wbux0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ReMzLZ4W6K9nMNUFf/118VRArE4tkPozQFB0HFls7pYKjxHyAujnB33BpXf9vT5EK 6t/khsGiPRd3Cn4cQAbOwXrdil1/GKNyhu8lsaV46YPBTHzOszXBtOev3q06JAVNr1 l10l1MZyKXx271DR3d+Q5LHR0CnFa8edJ195BIiYRMGTsJ2mshOIakTkqLdXrGf6iT z3IEQnWike9DhmyPB/p4181zP3AOwdswFU+ZjL9IzvmYwKgl0FmhOlaWOd14q4sz0o 5PUa18+XdOnlXRRhiUTWAYMQWcXKUcRSFlLz+WMX9u3D/uro+Q9zFdNBIO7wNEyW17 o7oc5uLuT1QKg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0255F64DF6 for ; Wed, 24 Dec 2025 14:31:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766611896; bh=2zGUAde677HLL3GUBwdIVWLm9lDzgprWyaGGH9fTfhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RM6TYTUyWdkdrum3NliZklNR1PGBI/2Ept/4H/zfe+UoWUhCK6zHgVpvuVZPUvxxh FWn15WQIlpAV7GSloHz3a88B97onEZY++3s18LKw/mPH8Nn1/ADmiQfKyJsWf0vBQw Aq1elAlrh2OrRwqwDvp7fFwWJWl74J6T60/LT8ecuxnGgu/nlzu6gYp8llNpA4IkGV VdiuCth41yjWv4sjydo19prqw4PCVd/APHVC4hthlm/UXharNxVZARKK7cNpH4V3iw ZkKgbFbGI7az+MZnbC/lyY4ftS4WcxeyVNkf8xE7il0sNyNmcwwGxQP5rRMbwi1D00 idIUeDDiKkx2A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F139864DD8; Wed, 24 Dec 2025 14:31:36 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id S-rlilqUin72; Wed, 24 Dec 2025 14:31:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766611892; bh=x3kic8ZaC9NK+cBilQrfDSaFAWeo9vYDX0vABuFuvDM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AQL60+VfbsNSpVSiNuoQuOvZP0PZwv+C2PAi+PFmU0MmcwqfxmHZlHfA/GsUS/Lbp DaWFVeNQ9eJMnaLf4NSF0l/HC6l93qaPZJKOOwgiwaIpNGsLmZV/BKwOLBw1lGAzmm q1fuKvD0AEoOibwAR3WDZuna3EL9E3YL0vg7svJFa0l5MqKA2mUxflRZqrGVFUzYDO /8e+GPkkjuHfSGwsJT4bXEAUt73VPYZEZK3j45ARJr5kXJ/YK50eDF8jLgMvr9skRS Poc8Rvg+As+nWo4dTX/vbbPr1SCOlgZug50L+vgSy+Z65k0D0QsRu9boYTLZa+x3ui 6zshWJcIKsbXg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C182664CA9; Wed, 24 Dec 2025 14:31:31 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 24 Dec 2025 14:30:39 -0700 Message-ID: <20251224213045.3010514-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251224213045.3010514-1-sjg@u-boot.org> References: <20251224213045.3010514-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: SMVXU5QJW73MYXCNQ7MMF2DGBV7QPLWS X-Message-ID-Hash: SMVXU5QJW73MYXCNQ7MMF2DGBV7QPLWS X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 8/9] pickman: Use named tuples for better code clarity List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Create an AgentCommit namedtuple for passing data to the agent to save confusing about ordering. Document CommitInfo while we are here. Co-developed-by: Claude Signed-off-by: Simon Glass --- tools/pickman/agent.py | 12 +++++++----- tools/pickman/control.py | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/tools/pickman/agent.py b/tools/pickman/agent.py index 89014df0120..1d5a3df2442 100644 --- a/tools/pickman/agent.py +++ b/tools/pickman/agent.py @@ -49,7 +49,8 @@ async def run(commits, source, branch_name, repo_path=None): """Run the Claude agent to cherry-pick commits Args: - commits (list): list of (hash, short_hash, subject) tuples + commits (list): list of AgentCommit namedtuples with fields: + hash, chash, subject source (str): source branch name branch_name (str): name for the new branch to create repo_path (str): path to repository (defaults to current directory) @@ -70,12 +71,12 @@ async def run(commits, source, branch_name, repo_path=None): # Build commit list for the prompt commit_list = '\n'.join( - f' - {short_hash}: {subject}' - for _, short_hash, subject in commits + f' - {commit.chash}: {commit.subject}' + for commit in commits ) # Get full hash of last commit for signal file - last_commit_hash = commits[-1][0] + last_commit_hash = commits[-1].hash prompt = f"""Cherry-pick the following commits from {source} branch: @@ -204,7 +205,8 @@ def cherry_pick_commits(commits, source, branch_name, repo_path=None): """Synchronous wrapper for running the cherry-pick agent Args: - commits (list): list of (hash, short_hash, subject) tuples + commits (list): list of AgentCommit namedtuples with fields: + hash, chash, subject source (str): source branch name branch_name (str): name for the new branch to create repo_path (str): path to repository (defaults to current directory) diff --git a/tools/pickman/control.py b/tools/pickman/control.py index ac9b57e10e3..4a993c72b88 100644 --- a/tools/pickman/control.py +++ b/tools/pickman/control.py @@ -72,9 +72,19 @@ CheckResult = namedtuple('CheckResult', [ ]) # Named tuple for commit with author +# hash: Full SHA-1 commit hash (40 characters) +# chash: Abbreviated commit hash (typically 7-8 characters) +# subject: First line of commit message (commit subject) +# author: Commit author name and email in format "Name " CommitInfo = namedtuple('CommitInfo', ['hash', 'chash', 'subject', 'author']) +# Named tuple for simplified commit data passed to agent +# hash: Full SHA-1 commit hash (40 characters) +# chash: Abbreviated commit hash (typically 7-8 characters) +# subject: First line of commit message (commit subject) +AgentCommit = namedtuple('AgentCommit', ['hash', 'chash', 'subject']) + # Named tuple for prepare_apply result ApplyInfo = namedtuple('ApplyInfo', ['commits', 'branch_name', 'original_branch', @@ -1213,9 +1223,9 @@ def execute_apply(dbs, source, commits, branch_name, args): # pylint: disable=t status='pending') dbs.commit() - # Convert CommitInfo to tuple format expected by agent - commit_tuples = [(c.hash, c.chash, c.subject) for c in commits] - success, conv_log = agent.cherry_pick_commits(commit_tuples, source, + # Convert CommitInfo to AgentCommit format expected by agent + agent_commits = [AgentCommit(c.hash, c.chash, c.subject) for c in commits] + success, conv_log = agent.cherry_pick_commits(agent_commits, source, branch_name) # Check for signal file from agent