Skip to content

feature: add machine name in the logs#1019

Merged
3asm merged 7 commits intomainfrom
feature/add-machine-name-to-logs
May 5, 2026
Merged

feature: add machine name in the logs#1019
3asm merged 7 commits intomainfrom
feature/add-machine-name-to-logs

Conversation

@MouadAO
Copy link
Copy Markdown
Member

@MouadAO MouadAO commented May 4, 2026

feature: add machine name in the logs

@MouadAO MouadAO self-assigned this May 4, 2026
@MouadAO MouadAO requested a review from a team as a code owner May 4, 2026 13:36
@MouadAO MouadAO added the enhancement New feature or request label May 4, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 97.10145% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.71%. Comparing base (61cfcc1) to head (a3928ee).

Files with missing lines Patch % Lines
src/ostorlab/runtimes/lite_local/agent_runtime.py 0.00% 1 Missing ⚠️
src/ostorlab/runtimes/local/agent_runtime.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1019      +/-   ##
==========================================
+ Coverage   65.59%   65.71%   +0.12%     
==========================================
  Files         418      418              
  Lines       17975    18044      +69     
==========================================
+ Hits        11790    11857      +67     
- Misses       6185     6187       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/ostorlab/agent/agent.py Outdated
Comment thread src/ostorlab/agent/agent.py Outdated
Comment thread src/ostorlab/agent/agent.py Outdated
@MouadAO
Copy link
Copy Markdown
Member Author

MouadAO commented May 4, 2026

I don't like the name MACHINE_NAME. It is unclear what does it refer to.

do you think SCANNER_NAMEis better

Copy link
Copy Markdown
Contributor

@ostorlab-ai-pr-review ostorlab-ai-pr-review Bot left a comment

Choose a reason for hiding this comment

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

Code Review Summary

Total Issues Found: 3
Critical Issues: 1
Suggestions: 2

Key Findings:
The review identified 3 issues across 3 files. Two are minor import ordering suggestions in agent runtime modules, requiring socket to be placed alphabetically between random and uuid. The third is a more significant test quality issue in tests/agent/agent_test.py, where a test invokes the private agent._setup_logging method instead of the public Agent.main() interface, uses improper mocking, and violates the project's test naming convention (_internal should be removed). Key themes include code style consistency (import organization) and test architecture (public API testing, mocking hygiene, naming conventions). Overall code quality is decent but the test design issue requires attention before merge. Recommendations: adopt an automated import sorter (e.g., isort) to eliminate manual ordering issues, refactor tests to exercise public interfaces rather than private methods, and ensure test names follow the testAction_conditionCamelCase_expectedResult convention consistently.

Comment thread src/ostorlab/runtimes/lite_local/agent_runtime.py
Comment thread src/ostorlab/runtimes/local/agent_runtime.py
Comment thread tests/agent/agent_test.py Outdated
Copy link
Copy Markdown
Contributor

@ostorlab-ai-pr-review ostorlab-ai-pr-review Bot left a comment

Choose a reason for hiding this comment

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

Code Review Summary

Total Issues Found: 3
Critical Issues: 1
Suggestions: 2

Key Findings:
The review identified one critical type-safety/runtime issue and two test-quality suggestions. A notable type mismatch in src/ostorlab/agent/agent.py allows None to propagate into a string-typed parameter and potentially into GCP logging labels, which breaks strict typing and risks runtime errors. The remaining feedback focuses on test maintainability: one unit test directly invokes a private method rather than exercising the public API, and a test method name does not follow the required test[Action]_[whenConditionCamelCase]_[expectedResultCamelCase] convention. Overall, the core logic appears sound, but addressing the type-safety issue is essential before merge, and the test improvements will help long-term maintainability.

Key Themes & Patterns:

  • Type Safety & Runtime Robustness: Mishandling of Optional[str] values returned by os.getenv without defaults or proper null-checks.
  • Testing Best Practices: Direct testing of private implementation details (_setup_logging) instead of verifying behavior through public interfaces.
  • Naming Conventions: Test method names missing required contextual clauses (when condition).

General Recommendations:

  • Apply defensive defaults (e.g., os.getenv('HOST_HOSTNAME', '')) or propagate Optional types with explicit None checks to prevent invalid values from entering dictionaries or log labels.
  • Favor testing public API surface areas over private methods to reduce test fragility.
  • Enforce the project's test-naming convention consistently across the test suite.

Comment thread src/ostorlab/agent/agent.py Outdated
Comment thread tests/agent/agent_test.py
Comment thread tests/runtimes/lite_local/runtime_test.py Outdated
@3asm 3asm marked this pull request as draft May 5, 2026 01:14
@MouadAO MouadAO marked this pull request as ready for review May 5, 2026 07:56
Copy link
Copy Markdown
Contributor

@ostorlab-ai-pr-review ostorlab-ai-pr-review Bot left a comment

Choose a reason for hiding this comment

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

Code Review Summary

Total Issues Found: 3
Critical Issues: 0
Suggestions: 3

Key Findings:
The review identified 3 minor issues across the codebase, all related to style and project conventions rather than functional defects. Two files (src/ostorlab/runtimes/lite_local/agent_runtime.py and src/ostorlab/runtimes/local/agent_runtime.py) contain non-alphabetical standard library import ordering (socket and uuid need to be swapped). The third issue, in tests/agent/agent_test.py, involves directly invoking a private method (_setup_logging) in a unit test, which violates the project's convention of testing behavior through the public API surface.

Overall code quality is solid — no critical bugs, security vulnerabilities, or logic errors were found. The findings are purely hygienic and can be quickly addressed.

Comment thread src/ostorlab/runtimes/lite_local/agent_runtime.py
Comment thread src/ostorlab/runtimes/local/agent_runtime.py
Comment thread tests/agent/agent_test.py
Comment thread tests/runtimes/lite_local/runtime_test.py Outdated
Copy link
Copy Markdown
Contributor

@ostorlab-ai-pr-review ostorlab-ai-pr-review Bot left a comment

Choose a reason for hiding this comment

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

Code Review Summary

Total Issues Found: 2
Critical Issues: 0
Suggestions: 2

Key Findings:
Two minor import ordering issues were identified in similar agent runtime files. Both src/ostorlab/runtimes/lite_local/agent_runtime.py and src/ostorlab/runtimes/local/agent_runtime.py have import socket placed after import uuid, breaking alphabetical ordering within the standard library import group. The fix is straightforward: move import socket before import uuid in both files. This is a style/consistency concern with no functional impact.

Key Themes and Patterns:

  • Import ordering inconsistency within standard library import blocks
  • The same pattern appears in two related files (lite_local and local runtimes), suggesting a systemic style oversight or copy-paste inconsistency

Overall Code Quality Assessment:
The code quality is good overall. There are no functional defects, security vulnerabilities, or logic errors identified. The findings are purely stylistic and relate to PEP 8 import ordering conventions. These are trivial to fix and do not affect runtime behavior.

General Recommendations:

  1. Fix import ordering in both files to maintain alphabetical order: base64, hashlib, io, logging, random, socket, uuid
  2. Consider using an automated import formatter (e.g., isort) in the pre-commit hook or CI pipeline to catch and fix import ordering issues automatically across the codebase
  3. Review other files in the runtimes module for similar import ordering inconsistencies

Comment thread src/ostorlab/runtimes/lite_local/agent_runtime.py
Comment thread src/ostorlab/runtimes/local/agent_runtime.py
@3asm 3asm merged commit 5d8e863 into main May 5, 2026
18 checks passed
@3asm 3asm deleted the feature/add-machine-name-to-logs branch May 5, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants