From 038352dd1135a060954688bdd93810dde4092cce Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <barracuda@macos-powerpc.org>
Date: Thu, 23 Jul 2026 03:37:26 +0000
Subject: [PATCH 20/30] minicargo: accept [workspace.metadata] and
 [workspace.package] version

- `[workspace.metadata]` is free-form tool configuration, explicitly
  ignored by cargo - stop erroring on it (seen with ruplacer 0.10.0).
- `[workspace.package] version` is now recorded and inheritable by
  members via `version.workspace = true` (seen with hyfetch 2.0.5);
  the remaining informational keys (authors, description, license, ...)
  are accepted and ignored, matching how their per-package equivalents
  behave when workspace-inherited.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013wCVW89GjmNyYviEcANPHM
---
 tools/minicargo/manifest.cpp | 50 ++++++++++++++++++++++++++++++++++--
 tools/minicargo/manifest.h   |  6 +++++
 2 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/tools/minicargo/manifest.cpp b/tools/minicargo/manifest.cpp
index c91fdb94..79fb01ee 100644
--- a/tools/minicargo/manifest.cpp
+++ b/tools/minicargo/manifest.cpp
@@ -212,16 +212,49 @@ WorkspaceManifest WorkspaceManifest::load_from_toml(const ::helpers::path& works
                 if( key == "edition" ) {
                     parse_edition(rv.m_edition, eh, key_val.value);
                 }
+                else if( key == "version" ) {
+                    // Inheritable by members via `version.workspace = true`
+                    if( key_val.value.m_type == TomlValue::Type::String )
+                    {
+                        try
+                        {
+                            rv.m_package_version = PackageVersion::from_string(key_val.value.as_string());
+                            rv.m_package_version.patch_set = true;
+                            rv.m_package_version_set = true;
+                        }
+                        catch(const ::std::invalid_argument& e)
+                        {
+                            eh.error("Unable to parse workspace package version - ", e.what());
+                        }
+                    }
+                }
                 else if( key == "rust-version" ) {
                     // Ignore, that's future-me's problem
                 }
-                else if( key == "license" || key == "homepage" || key == "repository" ) {
-                    // Documentation metdata
+                else if( key == "authors"
+                    || key == "description"
+                    || key == "documentation"
+                    || key == "readme"
+                    || key == "keywords"
+                    || key == "categories"
+                    || key == "license"
+                    || key == "license-file"
+                    || key == "homepage"
+                    || key == "repository"
+                    || key == "exclude"
+                    || key == "include"
+                    || key == "publish"
+                    ) {
+                    // Documentation/packaging metadata (inheritance of these is not
+                    // implemented - members using `<key>.workspace = true` get empty values)
                 }
                 else {
                     eh.error("Unknown item in [workspace.package] : `", key, "`");
                 }
             }
+            else if( key == "metadata" ) {
+                // `[workspace.metadata]` - explicitly ignored by cargo, free-form tool data
+            }
             else if( key == "dependencies" ) {
                 auto& dep_group = rv.m_dependencies;
                 //auto& dep_list = get_dep_list(dep_group, key);
@@ -480,6 +513,19 @@ void PackageManifest::fill_from_kv(ErrorHandler& eh, const WorkspaceManifest* wm
             }
             else if( key == "version" )
             {
+                if( key_val.path.size() == 3 && key_val.path[2] == "workspace" )
+                {
+                    if( !wm ) {
+                        eh.error("Using version.workspace with no workspace");
+                    }
+                    else if( key_val.value.as_bool() ) {
+                        if( !wm->has_package_version() ) {
+                            eh.error("`version.workspace` present, but workspace did not specify a version");
+                        }
+                        rv.m_version = wm->package_version();
+                    }
+                    return ;
+                }
                 try
                 {
                     rv.m_version = PackageVersion::from_string(key_val.value.as_string());
diff --git a/tools/minicargo/manifest.h b/tools/minicargo/manifest.h
index f88a173d..2e1fb3c0 100644
--- a/tools/minicargo/manifest.h
+++ b/tools/minicargo/manifest.h
@@ -323,6 +323,10 @@ class WorkspaceManifest
 
     ::std::vector<::std::string>    m_members;
 
+    // `[workspace.package] version`, inheritable via `version.workspace = true`
+    PackageVersion  m_package_version;
+    bool    m_package_version_set = false;
+
     Edition m_edition = Edition::Unspec;
     struct Dependencies {
         ::std::vector<PackageRef>   main;
@@ -336,6 +340,8 @@ public:
     static WorkspaceManifest load_from_toml(const ::helpers::path& workspace_manifest_path);
 
     Edition edition() const { return m_edition; }
+    bool has_package_version() const { return m_package_version_set; }
+    const PackageVersion& package_version() const { return m_package_version; }
     const ::std::vector<::std::string>& members() const { return m_members; }
     const ::std::map< ::std::string, ::helpers::path>& patches() const { return m_patches; }
     const ::std::vector<PackageRef>& dependencies() const { return m_dependencies.main; }
-- 
2.43.0

