Skip to content

Conversation

@Jason2866
Copy link
Owner

@Jason2866 Jason2866 commented Jun 26, 2025

Summary by CodeRabbit

  • Refactor

    • Improved modularity and clarity by restructuring component management into specialized classes with clear responsibilities.
    • Enhanced error handling and logging for all component operations.
    • Improved maintainability with detailed docstrings and examples for all classes and methods.
  • New Features

    • Added centralized logging for component changes.
    • Enabled detection of used components to prevent accidental removal.
    • Introduced automated backup and restoration of build scripts for Arduino projects.

@Jason2866
Copy link
Owner Author

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented Jun 26, 2025

✅ Actions performed

Full review triggered.

Repository owner deleted a comment from coderabbitai bot Jun 26, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 26, 2025

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{"name":"HttpError","status":404,"request":{"method":"PATCH","url":"https://api.github.com/repos/Jason2866/platform-espressif32/issues/comments/3008841070","headers":{"accept":"application/vnd.github.v3+json","user-agent":"octokit.js/0.0.0-development octokit-core.js/7.0.2 Node.js/24","authorization":"token [REDACTED]","content-type":"application/json; charset=utf-8"},"body":{"body":"<!-- This is an auto-generated comment: summarize by coderabbit.ai -->\n<!-- walkthrough_start -->\n\n## Walkthrough\n\nThe `component_manager.py` module has been refactored into a modular system with specialized classes for logging, YAML handling, project analysis, library mapping, and build file management. The main `ComponentManager` class now coordinates these components, providing robust component addition/removal, library ignore handling, MCU-specific build script backup/restoration, and detailed logging with improved error handling and documentation.\n\n## Changes\n\n| File(s)                                      | Change Summary                                                                                 |\n|----------------------------------------------|-----------------------------------------------------------------------------------------------|\n| builder/frameworks/component_manager.py      | Refactored into multiple specialized classes: `ComponentLogger`, `ComponentYamlHandler`, `ProjectAnalyzer`, `LibraryMapper`, `BuildFileManager`, and an updated `ComponentManager` with new methods, improved modularity, error handling, and documentation. |\n\n## Sequence Diagram(s)\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant ComponentManager\n    participant ComponentYamlHandler\n    participant ProjectAnalyzer\n    participant LibraryMapper\n    participant BuildFileManager\n    participant ComponentLogger\n\n    User->>ComponentManager: handle_component_settings(add/remove)\n    ComponentManager->>ComponentYamlHandler: Load YAML config\n    ComponentManager->>ProjectAnalyzer: Analyze used components\n    ComponentManager->>ComponentYamlHandler: Add/Remove components\n    ComponentManager->>BuildFileManager: Update build script, backup/restore if needed\n    ComponentManager->>ComponentLogger: Log changes\n\n    User->>ComponentManager: handle_lib_ignore()\n    ComponentManager->>LibraryMapper: Map library names to include paths\n    ComponentManager->>ProjectAnalyzer: Check if libraries are used\n    ComponentManager->>BuildFileManager: Remove include paths from build script\n    ComponentManager->>ComponentLogger: Log actions\n```\n\n## Poem\n\n> In the warren of code, new tunnels appear,  \n> With loggers and mappers, the path is now clear.  \n> YAMLs are handled with gentle rabbit care,  \n> Components hop in and out, with changes to share.  \n> 🐇 Modular and tidy, the garden now blooms—  \n> Each bunny has duties, in neatly swept rooms!\n\n<!-- walkthrough_end -->\n<!-- internal state start -->\n\n\n<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIAZXxuBERxBmoopmZufHIMUIB6SC94AUhYTFoijCJoyAB3NGQHAWZ1Gno5MNgPbERKSAApBuyAJgAOADZx9GRbSAxHAT6ARnGl/ixcLr8SLMR1fBceL2oAMwPmMGleaT2TgGZhjRgt2e1mZAJIMjKMBg9Njw/CrwKr8E4KTLZdjIcqFYpUCjwaR1dQIDZbXj4ERiJ4AOXw6FotHU8GyaF8SkQDER3HE2X4fCUuG0XhhAnweE6HkQ3FE8BO8AYjB+pGQBxQmQo+CkbFyyBBuCltGwf3a8k2qFmtUoHkxEngSloGnMlgAwixZbhGo5mM5XAZ3OsvPIMpb1p1UNxvL5/EEQihkCcpcwuThNgcADQDIYYMaTKO1WAE5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hs8g8ygkkqC1ooPJRSKq1IIe0sFTy+nDOTMJIaMzh1E4p2XunN6Nm7MUAc9JKjzmFLkP8q4oKKSfNGf86Zryu8sTYUPuSY+1nBm2aTfZyjsk4uuYs+5vOOkUtQF86edLtAzMisYWgZhBWsBFaSSVxzsWXMJY88lkKqW/Mjqa15exSSnGRFGW4iLxWoulbkvFtziWxleZGw1rFI5Atudmx1rykXotOf66twbNWQqxzmLWf867b2IAMpAXQXlVKqRBOoV7AAKXoXgTgIwwBIAAlN5p7UBPKqQtnPJy32zV/du6eQKXByaA90HoSA+JyAg+e55aOJA56rd6LgcQlMYe/YHESfHlWHvRXwGHSAABeSAcDySdmpSVSnkdqfsjp4z5nrISAo7AGjjHJAsdg9xxD4ob3xUkFJycQXwuoRi68rGp6qkYlxKrfgVSDz1eyDl/3e+fx6ci5A84UguATdQn+xIK35AFfo6VwYUHL2LeS4ENL6peOXXSDlw726yQADa5MAC6yvwcWo50gg3hL2CqWxcyLgMDBS4GD4qKMh9ZAh7VVT1SBBVIWq4EUZIDuRfh9UgcqPKlEAx4SwntASeU9p4oBnjAWec+c7z9rg5RekC4FL07l34O4W9Cr3HqW+uftw4n0jxUDvcAT0iM3/uiow/O+x/jgHlA1IJd1V31SxLpAoaDrX1burZ8UAd+TcvkjyUTwL0HEqtAx9yj96jx3mP19g4fzSt7Bq8fEj+BiAHCT6w4d6JwX4D6f5GTRCgRC6CSQQ5T8w0QIT0TIS0qsDsAsRoBsR2ScT4S5gqC8QkTwFkSoQfYGiIAP6Hh0CqTJDOChACRkHDB3ACAnAnAACcSwAArCcAACwCAMAMCjA8EkDcF3AkBLBoB3DcF8EnDcHDAAAMihDAHB74dw4wwwJAAgwwug8BBgZBroFBps1BSI2oz+UEehegQAA== -->\n\n<!-- internal state end -->\n<!-- finishing_touch_checkbox_start -->\n\n<details open=\"true\">\n<summary>✨ Finishing Touches</summary>\n\n- [ ] <!-- {\"checkboxId\": \"7962f53c-55bc-4827-bfbf-6a18da830691\"} --> 📝 Generate Docstrings\n\n</details>\n\n<!-- finishing_touch_checkbox_end -->\n<!-- tips_start -->\n\n---\n\nThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.\n\n<details>\n<summary>❤️ Share</summary>\n\n- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)\n- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)\n- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)\n- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)\n\n</details>\n\n<details>\n<summary>🪧 Tips</summary>\n\n### Chat\n\nThere are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=Jason2866/platform-espressif32&utm_content=161):\n\n- Review comments: Directly reply to a review comment made by CodeRabbit. Example:\n  - `I pushed a fix in commit <commit_id>, please review it.`\n  - `Explain this complex logic.`\n  - `Open a follow-up GitHub issue for this discussion.`\n- Files and specific lines of code (under the \"Files changed\" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:\n  - `@coderabbitai explain this code block.`\n  -\t`@coderabbitai modularize this function.`\n- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:\n  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`\n  - `@coderabbitai read src/utils.ts and explain its main purpose.`\n  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`\n  - `@coderabbitai help me debug CodeRabbit configuration file.`\n\n### Support\n\nNeed help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.\n\nNote: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.\n\n### CodeRabbit Commands (Invoked using PR comments)\n\n- `@coderabbitai pause` to pause the reviews on a PR.\n- `@coderabbitai resume` to resume the paused reviews.\n- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.\n- `@coderabbitai full review` to do a full review from scratch and review all the files again.\n- `@coderabbitai summary` to regenerate the summary of the PR.\n- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.\n- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.\n- `@coderabbitai resolve` resolve all the CodeRabbit review comments.\n- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.\n- `@coderabbitai help` to get help.\n\n### Other keywords and placeholders\n\n- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.\n- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.\n- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.\n\n### CodeRabbit Configuration File (`.coderabbit.yaml`)\n\n- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.\n- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.\n- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`\n\n### Documentation and Community\n\n- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.\n- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.\n- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.\n\n</details>\n\n<!-- tips_end -->"},"request":{"retryCount":1}},"response":{"url":"https://api.github.com/repos/Jason2866/platform-espressif32/issues/comments/3008841070","status":404,"headers":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","content-encoding":"gzip","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Thu, 26 Jun 2025 15:18:19 GMT","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"github.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","transfer-encoding":"chunked","vary":"Accept-Encoding, Accept, X-Requested-With","x-accepted-github-permissions":"issues=write; pull_requests=write","x-content-type-options":"nosniff","x-frame-options":"deny","x-github-api-version-selected":"2022-11-28","x-github-media-type":"github.v3; format=json","x-github-request-id":"70E1:3BF7F8:17AB0EA:2F96B1C:685D64BB","x-ratelimit-limit":"12500","x-ratelimit-remaining":"12375","x-ratelimit-reset":"1750954226","x-ratelimit-resource":"core","x-ratelimit-used":"125","x-xss-protection":"0"},"data":{"message":"Not Found","documentation_url":"https://docs.github.com/rest/issues/comments#update-an-issue-comment","status":"404"}}}

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (6)
builder/frameworks/component_manager.py (6)

329-329: Rename unused loop variable

The loop control variable dirs is not used within the loop body.

-for root, dirs, files in os.walk(src_dir):
+for root, _, files in os.walk(src_dir):

407-428: Consider externalizing component detection patterns

The component detection patterns are hardcoded within the method, making them harder to maintain and extend. Consider moving these patterns to a configuration file or class constant for better maintainability.

Example refactor:

class ProjectAnalyzer:
    # Class constant for easier maintenance
    COMPONENT_PATTERNS = {
        'bt': ['bluetooth', 'ble', 'nimble', 'bt_', 'esp_bt', 'esp_ble'],
        'esp_wifi': ['wifi', 'esp_wifi', 'tcpip_adapter'],
        # ... rest of patterns
    }
    
    def _extract_components_from_file(self, file_path: str) -> Set[str]:
        components = set()
        
        try:
            with open(file_path, 'r', encoding='utf-8', errors='ignore') as f:
                content = f.read().lower()
                
                for component, patterns in self.COMPONENT_PATTERNS.items():
                    if any(pattern in content for pattern in patterns):
                        components.add(component)
        except Exception:
            pass
        
        return components

679-757: Consider externalizing library mappings

The extensive library mapping dictionary is hardcoded, making it difficult to update without modifying the source code. Consider moving this to an external JSON or YAML configuration file.

This would allow:

  • Easier updates to mappings without code changes
  • Version-specific mapping configurations
  • User-customizable mappings
  • Reduced code complexity

Example approach:

# Load from external file
with open('library_mappings.json', 'r') as f:
    extended_mapping = json.load(f)

962-962: Remove unnecessary f-string prefix

The string doesn't contain any placeholders, so the f-string prefix is unnecessary.

-self.logger.log_change(f"Cleaned up CPPPATH entries for removed components")
+self.logger.log_change("Cleaned up CPPPATH entries for removed components")

1059-1059: Fix or remove commented code

The commented line has improper formatting. Either remove it or fix the formatting if it's needed for reference.

-#self.arduino_libs_mcu = join(self.platform.get_package_dir("framework-arduinoespressif32-libs"), self.mcu)
+# self.arduino_libs_mcu = join(self.platform.get_package_dir("framework-arduinoespressif32-libs"), self.mcu)

Or simply remove the line if it's no longer needed.


996-1071: Consider decomposing the ComponentManager class

The ComponentManager class has 15 instance attributes, which exceeds the recommended limit of 7. This suggests the class has too many responsibilities and could benefit from further decomposition.

Consider extracting some responsibilities into separate classes:

  • Configuration management (env, platform, config, board, mcu)
  • Path management (project_src_dir, arduino_framework_dir, arduino_libs_mcu)
  • State tracking (removed_components, ignored_libs)

This would improve maintainability and testability while adhering to the Single Responsibility Principle.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d9c9f74 and 23bff91.

📒 Files selected for processing (1)
  • builder/frameworks/component_manager.py (6 hunks)
🧰 Additional context used
🪛 Ruff (0.11.9)
builder/frameworks/component_manager.py

329-329: Loop control variable dirs not used within loop body

Rename unused dirs to _dirs

(B007)


962-962: f-string without any placeholders

Remove extraneous f prefix

(F541)

🪛 Pylint (3.3.7)
builder/frameworks/component_manager.py

[refactor] 485-485: Too few public methods (1/2)

(R0903)


[refactor] 996-996: Too many instance attributes (15/7)

(R0902)

🪛 Flake8 (7.2.0)
builder/frameworks/component_manager.py

[error] 962-962: f-string is missing placeholders

(F541)


[error] 1059-1059: block comment should start with '# '

(E265)

⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: build (macos-15, examples/espidf-ulp-riscv)
  • GitHub Check: build (windows-latest, examples/espidf-hello-world)
  • GitHub Check: build (macos-15, examples/espidf-blink)
  • GitHub Check: build (windows-latest, examples/espidf-ulp)
  • GitHub Check: build (windows-latest, examples/espidf-peripherals-uart)
  • GitHub Check: build (windows-latest, examples/arduino-rmt-blink)
  • GitHub Check: build (windows-latest, examples/arduino-usb-keyboard)
  • GitHub Check: build (windows-latest, examples/espidf-ulp-riscv)
  • GitHub Check: build (windows-latest, examples/espidf-peripherals-usb)
  • GitHub Check: build (ubuntu-latest, examples/espidf-ulp-riscv)
  • GitHub Check: build (windows-latest, examples/espidf-coap-server)
  • GitHub Check: build (windows-latest, examples/arduino-blink)
  • GitHub Check: build (windows-latest, examples/espidf-arduino-blink)
  • GitHub Check: build (ubuntu-latest, examples/tasmota)
  • GitHub Check: build (ubuntu-latest, examples/espidf-ulp)
  • GitHub Check: build (ubuntu-latest, examples/espidf-peripherals-uart)
  • GitHub Check: build (ubuntu-latest, examples/espidf-hello-world)
  • GitHub Check: build (ubuntu-latest, examples/espidf-blink)
  • GitHub Check: build (ubuntu-latest, examples/espidf-arduino-blink)
  • GitHub Check: build (ubuntu-latest, examples/arduino-blink)
🔇 Additional comments (3)
builder/frameworks/component_manager.py (3)

113-270: Well-structured YAML handler implementation

The ComponentYamlHandler class is well-designed with clear separation of concerns, proper error handling, and comprehensive documentation. The backup functionality provides good safety measures.


1-1413: Excellent modular refactor of the component management system

This is a well-executed refactor that transforms a monolithic design into a modular system with clear separation of concerns. The code is well-documented with comprehensive docstrings and examples. The addition of specialized classes for logging, YAML handling, project analysis, library mapping, and build file management significantly improves maintainability and testability.

Key strengths:

  • Clear class responsibilities following SOLID principles
  • Comprehensive error handling and logging
  • Extensive documentation with examples
  • Safety measures (backups, validation, critical component protection)

The minor issues identified can be easily addressed in a follow-up commit.


1323-1323: ```shell
#!/bin/bash
echo "Searching for Python version specifiers in common project config files..."

Check setup.py / setup.cfg / pyproject.toml for python_requires

rg -n "python_requires" --glob="setup.py" --glob="setup.cfg" --glob="pyproject.toml" || echo "-- no python_requires found"

Check pyproject.toml for requires-python field

rg -n "requires-python" --glob="pyproject.toml" || echo "-- no requires-python found"

Check tox.ini for basepython setting

rg -n "basepython" --glob="tox.ini" || echo "-- no basepython in tox.ini"

Check for a runtime.txt (Heroku) specifying Python version

if [ -f runtime.txt ]; then
echo "-- runtime.txt found:"
sed -n '1,5p' runtime.txt
else
echo "-- no runtime.txt"
fi

Check classifiers in setup.cfg for supported Python versions

rg -n "Programming Language :: Python :: 3.[0-9]" --glob="setup.cfg" || echo "-- no Python classifiers found in setup.cfg"


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment on lines +74 to +92
def get_changes(self) -> List[str]:
"""
Get a copy of all changes made during the session.
Get all logged changes.
Returns a defensive copy of the change log to prevent external
modification while allowing access to the complete change history.
Returns a copy of all change messages that have been logged during
the current session.
Returns:
List of change messages in chronological order
"""
return self.component_changes.copy()
List[str]: List of all logged change messages
Example:
>>> logger = ComponentLogger()
>>> logger.log_change("First change")
>>> logger.log_change("Second change")
>>> changes = logger.get_changes()
>>> len(changes)
2
"""
return self.component_changes
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Return a copy to protect internal state

The get_changes method returns the internal list directly, which allows external modification of the logger's state. This violates encapsulation principles.

Apply this diff to return a copy:

 def get_changes(self) -> List[str]:
     """
     Get all logged changes.
     
     Returns a copy of all change messages that have been logged during
     the current session.
     
     Returns:
         List[str]: List of all logged change messages
         
     Example:
         >>> logger = ComponentLogger()
         >>> logger.log_change("First change")
         >>> logger.log_change("Second change")
         >>> changes = logger.get_changes()
         >>> len(changes)
         2
     """
-    return self.component_changes
+    return self.component_changes.copy()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def get_changes(self) -> List[str]:
"""
Get a copy of all changes made during the session.
Get all logged changes.
Returns a defensive copy of the change log to prevent external
modification while allowing access to the complete change history.
Returns a copy of all change messages that have been logged during
the current session.
Returns:
List of change messages in chronological order
"""
return self.component_changes.copy()
List[str]: List of all logged change messages
Example:
>>> logger = ComponentLogger()
>>> logger.log_change("First change")
>>> logger.log_change("Second change")
>>> changes = logger.get_changes()
>>> len(changes)
2
"""
return self.component_changes
def get_changes(self) -> List[str]:
"""
Get all logged changes.
Returns a copy of all change messages that have been logged during
the current session.
Returns:
List[str]: List of all logged change messages
Example:
>>> logger = ComponentLogger()
>>> logger.log_change("First change")
>>> logger.log_change("Second change")
>>> changes = logger.get_changes()
>>> len(changes)
2
"""
- return self.component_changes
+ return self.component_changes.copy()
🤖 Prompt for AI Agents
In builder/frameworks/component_manager.py around lines 74 to 92, the
get_changes method returns the internal list self.component_changes directly,
which exposes the internal state to external modification. To fix this, modify
the method to return a shallow copy of the list by returning
self.component_changes.copy() instead of the list itself, ensuring encapsulation
and protecting the internal state.

@Jason2866 Jason2866 closed this Nov 15, 2025
@Jason2866 Jason2866 deleted the soph_lib_remove branch November 15, 2025 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants