Codex-generated pull request#16
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Hướng dẫn dành cho người review (Reviewer's Guide)Giới thiệu một helper cấu hình dùng chung để kiểm soát việc có cho phép sử dụng các stub implementation hay không, tích hợp nó vào HAIOS runtime và DR protocol loader để chúng có thể tùy chọn “fail fast” thay vì quay về stub, và thêm các bài kiểm thử để xác nhận hành vi cấu hình. Biểu đồ tuần tự cho quá trình HAIOSRuntime load với stub tùy chọnsequenceDiagram
participant Importer
participant HAIOSRuntimeModule as src_hyperai_core_haios_runtime
participant Config as hyperai_config
participant Env as OS_env
participant Impl as haios_runtime_impl
participant Stub as HAIOSRuntime_stub
Importer->>HAIOSRuntimeModule: import HAIOSRuntime
HAIOSRuntimeModule->>Config: call allow_stubs()
Config->>Env: read HYPERAI_ALLOW_STUBS
Env-->>Config: value
Config-->>HAIOSRuntimeModule: allow_stubs_result
HAIOSRuntimeModule->>Impl: import HAIOSRuntimeImpl
alt Import succeeds
Impl-->>HAIOSRuntimeModule: HAIOSRuntimeImpl
HAIOSRuntimeModule-->>Importer: HAIOSRuntime = HAIOSRuntimeImpl
else ImportError
alt allow_stubs_result is False
HAIOSRuntimeModule-->>Importer: raise ImportError
else allow_stubs_result is True
HAIOSRuntimeModule->>Stub: define stub class HAIOSRuntime
Stub-->>HAIOSRuntimeModule: HAIOSRuntime_stub
HAIOSRuntimeModule-->>Importer: HAIOSRuntime = HAIOSRuntime_stub
end
end
Biểu đồ tuần tự cho quá trình DRProtocol load với stub tùy chọnsequenceDiagram
participant Importer
participant DRProtocolModule as src_hyperai_protocols_dr_protocol
participant Config as hyperai_config
participant Env as OS_env
participant Impl as dr_protocol_impl
participant Stub as DRProtocol_stub
Importer->>DRProtocolModule: import DRProtocol
DRProtocolModule->>Config: call allow_stubs()
Config->>Env: read HYPERAI_ALLOW_STUBS
Env-->>Config: value
Config-->>DRProtocolModule: allow_stubs_result
DRProtocolModule->>Impl: import DRProtocolImpl
alt Import succeeds
Impl-->>DRProtocolModule: DRProtocolImpl
DRProtocolModule-->>Importer: DRProtocol = DRProtocolImpl
else ImportError or AttributeError
alt allow_stubs_result is False
DRProtocolModule-->>Importer: raise ImportError or AttributeError
else allow_stubs_result is True
DRProtocolModule->>Stub: define stub class DRProtocol
Stub-->>DRProtocolModule: DRProtocol_stub
DRProtocolModule-->>Importer: DRProtocol = DRProtocol_stub
end
end
Biểu đồ lớp cho config helper và các loader dùng stubclassDiagram
class hyperai_config {
+bool allow_stubs()
}
class src_hyperai_core_haios_runtime {
+HAIOSRuntime
-root_dir
-_allow_stubs()
}
class HAIOSRuntimeImpl {
}
class HAIOSRuntime_stub {
+HAIOSRuntime
}
class src_hyperai_protocols_dr_protocol {
+DRProtocol
-root_dir
-_allow_stubs()
}
class DRProtocolImpl {
}
class DRProtocol_stub {
+DRProtocol
}
hyperai_config ..> src_hyperai_core_haios_runtime : uses
hyperai_config ..> src_hyperai_protocols_dr_protocol : uses
src_hyperai_core_haios_runtime ..> HAIOSRuntimeImpl : imports
src_hyperai_core_haios_runtime ..> HAIOSRuntime_stub : falls_back_to
src_hyperai_protocols_dr_protocol ..> DRProtocolImpl : imports
src_hyperai_protocols_dr_protocol ..> DRProtocol_stub : falls_back_to
Các thay đổi ở mức file (File-Level Changes)
Tips and commandsTương tác với Sourcery
Tùy chỉnh trải nghiệm của bạnTruy cập dashboard để:
Nhận hỗ trợ
Original review guide in EnglishReviewer's GuideIntroduce a shared configuration helper to control whether stub implementations are allowed, wire it into the HAIOS runtime and DR protocol loaders so they can optionally fail fast instead of falling back to stubs, and add tests to validate the configuration behavior. Sequence diagram for HAIOSRuntime loading with optional stubssequenceDiagram
participant Importer
participant HAIOSRuntimeModule as src_hyperai_core_haios_runtime
participant Config as hyperai_config
participant Env as OS_env
participant Impl as haios_runtime_impl
participant Stub as HAIOSRuntime_stub
Importer->>HAIOSRuntimeModule: import HAIOSRuntime
HAIOSRuntimeModule->>Config: call allow_stubs()
Config->>Env: read HYPERAI_ALLOW_STUBS
Env-->>Config: value
Config-->>HAIOSRuntimeModule: allow_stubs_result
HAIOSRuntimeModule->>Impl: import HAIOSRuntimeImpl
alt Import succeeds
Impl-->>HAIOSRuntimeModule: HAIOSRuntimeImpl
HAIOSRuntimeModule-->>Importer: HAIOSRuntime = HAIOSRuntimeImpl
else ImportError
alt allow_stubs_result is False
HAIOSRuntimeModule-->>Importer: raise ImportError
else allow_stubs_result is True
HAIOSRuntimeModule->>Stub: define stub class HAIOSRuntime
Stub-->>HAIOSRuntimeModule: HAIOSRuntime_stub
HAIOSRuntimeModule-->>Importer: HAIOSRuntime = HAIOSRuntime_stub
end
end
Sequence diagram for DRProtocol loading with optional stubssequenceDiagram
participant Importer
participant DRProtocolModule as src_hyperai_protocols_dr_protocol
participant Config as hyperai_config
participant Env as OS_env
participant Impl as dr_protocol_impl
participant Stub as DRProtocol_stub
Importer->>DRProtocolModule: import DRProtocol
DRProtocolModule->>Config: call allow_stubs()
Config->>Env: read HYPERAI_ALLOW_STUBS
Env-->>Config: value
Config-->>DRProtocolModule: allow_stubs_result
DRProtocolModule->>Impl: import DRProtocolImpl
alt Import succeeds
Impl-->>DRProtocolModule: DRProtocolImpl
DRProtocolModule-->>Importer: DRProtocol = DRProtocolImpl
else ImportError or AttributeError
alt allow_stubs_result is False
DRProtocolModule-->>Importer: raise ImportError or AttributeError
else allow_stubs_result is True
DRProtocolModule->>Stub: define stub class DRProtocol
Stub-->>DRProtocolModule: DRProtocol_stub
DRProtocolModule-->>Importer: DRProtocol = DRProtocol_stub
end
end
Class diagram for config helper and stubbed loadersclassDiagram
class hyperai_config {
+bool allow_stubs()
}
class src_hyperai_core_haios_runtime {
+HAIOSRuntime
-root_dir
-_allow_stubs()
}
class HAIOSRuntimeImpl {
}
class HAIOSRuntime_stub {
+HAIOSRuntime
}
class src_hyperai_protocols_dr_protocol {
+DRProtocol
-root_dir
-_allow_stubs()
}
class DRProtocolImpl {
}
class DRProtocol_stub {
+DRProtocol
}
hyperai_config ..> src_hyperai_core_haios_runtime : uses
hyperai_config ..> src_hyperai_protocols_dr_protocol : uses
src_hyperai_core_haios_runtime ..> HAIOSRuntimeImpl : imports
src_hyperai_core_haios_runtime ..> HAIOSRuntime_stub : falls_back_to
src_hyperai_protocols_dr_protocol ..> DRProtocolImpl : imports
src_hyperai_protocols_dr_protocol ..> DRProtocol_stub : falls_back_to
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
There was a problem hiding this comment.
Hey - mình đã tìm thấy 1 vấn đề
Prompt cho AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `tests/test_config_allow_stubs.py:19` </location>
<code_context>
+allow_stubs = config_module.allow_stubs
+
+
+class TestAllowStubs(unittest.TestCase):
+ """Validate HYPERAI_ALLOW_STUBS parsing behavior."""
+
</code_context>
<issue_to_address>
**suggestion (testing):** Hãy cân nhắc bổ sung các bài test bao phủ việc `allow_stubs()` thực sự ảnh hưởng như thế nào tới các import `haios_runtime` và `dr_protocol`
Các bài test hiện tại chỉ kiểm tra việc parse `allow_stubs()`, chứ chưa kiểm tra tác động của nó lên các import. Vui lòng thêm các bài test end-to-end để xác minh:
- Khi `HYPERAI_ALLOW_STUBS` không được đặt/false, việc import `hyperai.core.haios_runtime` / `hyperai.protocols.dr_protocol` sẽ thất bại nếu thiếu các implementation thật.
- Khi `HYPERAI_ALLOW_STUBS` là true, các import này sẽ thành công và cung cấp các lớp stub.
Bạn có thể dùng `importlib.reload` hoặc chạy dưới dạng subprocess để tránh cache import khi chuyển trạng thái biến môi trường.
Gợi ý triển khai:
```python
import importlib
import importlib.util
import os
import sys
import unittest
from pathlib import Path
```
```python
spec = importlib.util.spec_from_file_location("hyperai_config", CONFIG_MODULE_PATH)
config_module = importlib.util.module_from_spec(spec)
class TestAllowStubsImports(unittest.TestCase):
"""End-to-end tests for allow_stubs() effect on haios_runtime and dr_protocol imports."""
MODULES_UNDER_TEST = (
"hyperai.core.haios_runtime",
"hyperai.protocols.dr_protocol",
)
def _set_env_allow_stubs(self, value: str | None) -> None:
"""Set or clear HYPERAI_ALLOW_STUBS, restoring it after the test."""
prev = os.environ.get("HYPERAI_ALLOW_STUBS")
if value is None:
os.environ.pop("HYPERAI_ALLOW_STUBS", None)
else:
os.environ["HYPERAI_ALLOW_STUBS"] = value
def restore() -> None:
if prev is None:
os.environ.pop("HYPERAI_ALLOW_STUBS", None)
else:
os.environ["HYPERAI_ALLOW_STUBS"] = prev
self.addCleanup(restore)
def _clear_import_caches(self) -> None:
"""Ensure subsequent imports reflect the current env var value."""
importlib.invalidate_caches()
for module_name in self.MODULES_UNDER_TEST:
sys.modules.pop(module_name, None)
def test_imports_fail_without_allow_stubs(self) -> None:
"""Without HYPERAI_ALLOW_STUBS, importing stub-only modules should fail."""
self._set_env_allow_stubs(None)
self._clear_import_caches()
for module_name in self.MODULES_UNDER_TEST:
with self.subTest(module=module_name):
with self.assertRaises(ImportError):
importlib.import_module(module_name)
def test_imports_succeed_with_allow_stubs(self) -> None:
"""With HYPERAI_ALLOW_STUBS enabled, stub modules should import successfully."""
self._set_env_allow_stubs("1")
self._clear_import_caches()
for module_name in self.MODULES_UNDER_TEST:
with self.subTest(module=module_name):
module = importlib.import_module(module_name)
# Basic sanity check that the module loaded and exposes some attributes.
# More specific assertions about stub classes can be added as needed.
self.assertIsNotNone(module)
self.assertTrue(
bool(
{
name
for name in dir(module)
if not name.startswith("_")
}
),
f"{module_name} should expose at least one public attribute when stubs are enabled",
)
```
1. Nếu các module stub của bạn cung cấp những class quen thuộc (ví dụ `HaiOSRuntimeStub`, `DeepResearchProtocolStub`, hoặc tương tự), hãy tăng độ chặt chẽ của các assert trong `test_imports_succeed_with_allow_stubs` bằng cách kiểm tra rõ ràng các thuộc tính đó thay vì check chung chung "có public attribute nào đó".
2. Nếu trong file này đã có các bài test khác cũng thao tác với `HYPERAI_ALLOW_STUBS` hoặc import `hyperai.core.haios_runtime` / `hyperai.protocols.dr_protocol`, hãy đảm bảo chúng cũng sử dụng các helper `_set_env_allow_stubs` / `_clear_import_caches` hoặc tránh can thiệp lẫn nhau với các bài test mới này.
3. Nếu implementation của bạn dùng tên biến môi trường khác hoặc có thêm flag để điều khiển hành vi stub, hãy điều chỉnh `MODULES_UNDER_TEST` và logic `_set_env_allow_stubs` cho phù hợp.
</issue_to_address>Sourcery miễn phí cho các dự án mã nguồn mở - nếu bạn thấy hữu ích, hãy cân nhắc chia sẻ ✨
Original comment in English
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `tests/test_config_allow_stubs.py:19` </location>
<code_context>
+allow_stubs = config_module.allow_stubs
+
+
+class TestAllowStubs(unittest.TestCase):
+ """Validate HYPERAI_ALLOW_STUBS parsing behavior."""
+
</code_context>
<issue_to_address>
**suggestion (testing):** Consider adding tests that cover how `allow_stubs()` actually affects `haios_runtime` and `dr_protocol` imports
Current tests only cover parsing of `allow_stubs()`, not its effect on imports. Please add end-to-end tests that verify:
- With `HYPERAI_ALLOW_STUBS` unset/false, importing `hyperai.core.haios_runtime` / `hyperai.protocols.dr_protocol` fails if real implementations are missing.
- With `HYPERAI_ALLOW_STUBS` true, the same imports succeed and expose the stub classes.
You can use `importlib.reload` or subprocesses to avoid import caching when toggling the env var.
Suggested implementation:
```python
import importlib
import importlib.util
import os
import sys
import unittest
from pathlib import Path
```
```python
spec = importlib.util.spec_from_file_location("hyperai_config", CONFIG_MODULE_PATH)
config_module = importlib.util.module_from_spec(spec)
class TestAllowStubsImports(unittest.TestCase):
"""End-to-end tests for allow_stubs() effect on haios_runtime and dr_protocol imports."""
MODULES_UNDER_TEST = (
"hyperai.core.haios_runtime",
"hyperai.protocols.dr_protocol",
)
def _set_env_allow_stubs(self, value: str | None) -> None:
"""Set or clear HYPERAI_ALLOW_STUBS, restoring it after the test."""
prev = os.environ.get("HYPERAI_ALLOW_STUBS")
if value is None:
os.environ.pop("HYPERAI_ALLOW_STUBS", None)
else:
os.environ["HYPERAI_ALLOW_STUBS"] = value
def restore() -> None:
if prev is None:
os.environ.pop("HYPERAI_ALLOW_STUBS", None)
else:
os.environ["HYPERAI_ALLOW_STUBS"] = prev
self.addCleanup(restore)
def _clear_import_caches(self) -> None:
"""Ensure subsequent imports reflect the current env var value."""
importlib.invalidate_caches()
for module_name in self.MODULES_UNDER_TEST:
sys.modules.pop(module_name, None)
def test_imports_fail_without_allow_stubs(self) -> None:
"""Without HYPERAI_ALLOW_STUBS, importing stub-only modules should fail."""
self._set_env_allow_stubs(None)
self._clear_import_caches()
for module_name in self.MODULES_UNDER_TEST:
with self.subTest(module=module_name):
with self.assertRaises(ImportError):
importlib.import_module(module_name)
def test_imports_succeed_with_allow_stubs(self) -> None:
"""With HYPERAI_ALLOW_STUBS enabled, stub modules should import successfully."""
self._set_env_allow_stubs("1")
self._clear_import_caches()
for module_name in self.MODULES_UNDER_TEST:
with self.subTest(module=module_name):
module = importlib.import_module(module_name)
# Basic sanity check that the module loaded and exposes some attributes.
# More specific assertions about stub classes can be added as needed.
self.assertIsNotNone(module)
self.assertTrue(
bool(
{
name
for name in dir(module)
if not name.startswith("_")
}
),
f"{module_name} should expose at least one public attribute when stubs are enabled",
)
```
1. If your stub modules expose well-known classes (e.g. `HaiOSRuntimeStub`, `DeepResearchProtocolStub`, or similar), strengthen the assertions in `test_imports_succeed_with_allow_stubs` to explicitly check for those attributes instead of the generic "has some public attribute" check.
2. If there are existing tests in this file that also manipulate `HYPERAI_ALLOW_STUBS` or import `hyperai.core.haios_runtime` / `hyperai.protocols.dr_protocol`, ensure they either use the `_set_env_allow_stubs` / `_clear_import_caches` helpers or otherwise avoid interference with these new tests.
3. If your implementation uses a different environment variable name or additional flags to control stub behavior, adjust the `MODULES_UNDER_TEST` and `_set_env_allow_stubs` logic accordingly.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| allow_stubs = config_module.allow_stubs | ||
|
|
||
|
|
||
| class TestAllowStubs(unittest.TestCase): |
There was a problem hiding this comment.
suggestion (testing): Hãy cân nhắc bổ sung các bài test bao phủ việc allow_stubs() thực sự ảnh hưởng như thế nào tới các import haios_runtime và dr_protocol
Các bài test hiện tại chỉ kiểm tra việc parse allow_stubs(), chứ chưa kiểm tra tác động của nó lên các import. Vui lòng thêm các bài test end-to-end để xác minh:
- Khi
HYPERAI_ALLOW_STUBSkhông được đặt/false, việc importhyperai.core.haios_runtime/hyperai.protocols.dr_protocolsẽ thất bại nếu thiếu các implementation thật. - Khi
HYPERAI_ALLOW_STUBSlà true, các import này sẽ thành công và cung cấp các lớp stub.
Bạn có thể dùng importlib.reload hoặc chạy dưới dạng subprocess để tránh cache import khi chuyển trạng thái biến môi trường.
Gợi ý triển khai:
import importlib
import importlib.util
import os
import sys
import unittest
from pathlib import Pathspec = importlib.util.spec_from_file_location("hyperai_config", CONFIG_MODULE_PATH)
config_module = importlib.util.module_from_spec(spec)
class TestAllowStubsImports(unittest.TestCase):
"""End-to-end tests for allow_stubs() effect on haios_runtime and dr_protocol imports."""
MODULES_UNDER_TEST = (
"hyperai.core.haios_runtime",
"hyperai.protocols.dr_protocol",
)
def _set_env_allow_stubs(self, value: str | None) -> None:
"""Set or clear HYPERAI_ALLOW_STUBS, restoring it after the test."""
prev = os.environ.get("HYPERAI_ALLOW_STUBS")
if value is None:
os.environ.pop("HYPERAI_ALLOW_STUBS", None)
else:
os.environ["HYPERAI_ALLOW_STUBS"] = value
def restore() -> None:
if prev is None:
os.environ.pop("HYPERAI_ALLOW_STUBS", None)
else:
os.environ["HYPERAI_ALLOW_STUBS"] = prev
self.addCleanup(restore)
def _clear_import_caches(self) -> None:
"""Ensure subsequent imports reflect the current env var value."""
importlib.invalidate_caches()
for module_name in self.MODULES_UNDER_TEST:
sys.modules.pop(module_name, None)
def test_imports_fail_without_allow_stubs(self) -> None:
"""Without HYPERAI_ALLOW_STUBS, importing stub-only modules should fail."""
self._set_env_allow_stubs(None)
self._clear_import_caches()
for module_name in self.MODULES_UNDER_TEST:
with self.subTest(module=module_name):
with self.assertRaises(ImportError):
importlib.import_module(module_name)
def test_imports_succeed_with_allow_stubs(self) -> None:
"""With HYPERAI_ALLOW_STUBS enabled, stub modules should import successfully."""
self._set_env_allow_stubs("1")
self._clear_import_caches()
for module_name in self.MODULES_UNDER_TEST:
with self.subTest(module=module_name):
module = importlib.import_module(module_name)
# Basic sanity check that the module loaded and exposes some attributes.
# More specific assertions about stub classes can be added as needed.
self.assertIsNotNone(module)
self.assertTrue(
bool(
{
name
for name in dir(module)
if not name.startswith("_")
}
),
f"{module_name} should expose at least one public attribute when stubs are enabled",
)- Nếu các module stub của bạn cung cấp những class quen thuộc (ví dụ
HaiOSRuntimeStub,DeepResearchProtocolStub, hoặc tương tự), hãy tăng độ chặt chẽ của các assert trongtest_imports_succeed_with_allow_stubsbằng cách kiểm tra rõ ràng các thuộc tính đó thay vì check chung chung "có public attribute nào đó". - Nếu trong file này đã có các bài test khác cũng thao tác với
HYPERAI_ALLOW_STUBShoặc importhyperai.core.haios_runtime/hyperai.protocols.dr_protocol, hãy đảm bảo chúng cũng sử dụng các helper_set_env_allow_stubs/_clear_import_cacheshoặc tránh can thiệp lẫn nhau với các bài test mới này. - Nếu implementation của bạn dùng tên biến môi trường khác hoặc có thêm flag để điều khiển hành vi stub, hãy điều chỉnh
MODULES_UNDER_TESTvà logic_set_env_allow_stubscho phù hợp.
Original comment in English
suggestion (testing): Consider adding tests that cover how allow_stubs() actually affects haios_runtime and dr_protocol imports
Current tests only cover parsing of allow_stubs(), not its effect on imports. Please add end-to-end tests that verify:
- With
HYPERAI_ALLOW_STUBSunset/false, importinghyperai.core.haios_runtime/hyperai.protocols.dr_protocolfails if real implementations are missing. - With
HYPERAI_ALLOW_STUBStrue, the same imports succeed and expose the stub classes.
You can use importlib.reload or subprocesses to avoid import caching when toggling the env var.
Suggested implementation:
import importlib
import importlib.util
import os
import sys
import unittest
from pathlib import Pathspec = importlib.util.spec_from_file_location("hyperai_config", CONFIG_MODULE_PATH)
config_module = importlib.util.module_from_spec(spec)
class TestAllowStubsImports(unittest.TestCase):
"""End-to-end tests for allow_stubs() effect on haios_runtime and dr_protocol imports."""
MODULES_UNDER_TEST = (
"hyperai.core.haios_runtime",
"hyperai.protocols.dr_protocol",
)
def _set_env_allow_stubs(self, value: str | None) -> None:
"""Set or clear HYPERAI_ALLOW_STUBS, restoring it after the test."""
prev = os.environ.get("HYPERAI_ALLOW_STUBS")
if value is None:
os.environ.pop("HYPERAI_ALLOW_STUBS", None)
else:
os.environ["HYPERAI_ALLOW_STUBS"] = value
def restore() -> None:
if prev is None:
os.environ.pop("HYPERAI_ALLOW_STUBS", None)
else:
os.environ["HYPERAI_ALLOW_STUBS"] = prev
self.addCleanup(restore)
def _clear_import_caches(self) -> None:
"""Ensure subsequent imports reflect the current env var value."""
importlib.invalidate_caches()
for module_name in self.MODULES_UNDER_TEST:
sys.modules.pop(module_name, None)
def test_imports_fail_without_allow_stubs(self) -> None:
"""Without HYPERAI_ALLOW_STUBS, importing stub-only modules should fail."""
self._set_env_allow_stubs(None)
self._clear_import_caches()
for module_name in self.MODULES_UNDER_TEST:
with self.subTest(module=module_name):
with self.assertRaises(ImportError):
importlib.import_module(module_name)
def test_imports_succeed_with_allow_stubs(self) -> None:
"""With HYPERAI_ALLOW_STUBS enabled, stub modules should import successfully."""
self._set_env_allow_stubs("1")
self._clear_import_caches()
for module_name in self.MODULES_UNDER_TEST:
with self.subTest(module=module_name):
module = importlib.import_module(module_name)
# Basic sanity check that the module loaded and exposes some attributes.
# More specific assertions about stub classes can be added as needed.
self.assertIsNotNone(module)
self.assertTrue(
bool(
{
name
for name in dir(module)
if not name.startswith("_")
}
),
f"{module_name} should expose at least one public attribute when stubs are enabled",
)- If your stub modules expose well-known classes (e.g.
HaiOSRuntimeStub,DeepResearchProtocolStub, or similar), strengthen the assertions intest_imports_succeed_with_allow_stubsto explicitly check for those attributes instead of the generic "has some public attribute" check. - If there are existing tests in this file that also manipulate
HYPERAI_ALLOW_STUBSor importhyperai.core.haios_runtime/hyperai.protocols.dr_protocol, ensure they either use the_set_env_allow_stubs/_clear_import_cacheshelpers or otherwise avoid interference with these new tests. - If your implementation uses a different environment variable name or additional flags to control stub behavior, adjust the
MODULES_UNDER_TESTand_set_env_allow_stubslogic accordingly.
|
Ok merge now |
User description
Codex generated this pull request, but encountered an unexpected error after generation. This is a placeholder PR message.
Codex Task
PR Type
Enhancement, Tests
Description
Add shared
allow_stubs()configuration helper functionIntegrate helper into stub fallback logic for graceful degradation
Provide comprehensive test coverage for environment variable parsing
Allow conditional stub usage via
HYPERAI_ALLOW_STUBSenvironment variableDiagram Walkthrough
File Walkthrough
config.py
Create shared allow_stubs configuration helpersrc/hyperai/config.py
allow_stubs()function that readsHYPERAI_ALLOW_STUBSenvironment variable
haios_runtime.py
Integrate allow_stubs check into HAIOSRuntimesrc/hyperai/core/haios_runtime.py
allow_stubshelper from shared config modulestubs not allowed
dr_protocol.py
Integrate allow_stubs check into DRProtocolsrc/hyperai/protocols/dr_protocol.py
allow_stubshelper from shared config moduleexception if stubs not allowed
test_config_allow_stubs.py
Add comprehensive tests for allow_stubs helpertests/test_config_allow_stubs.py
allow_stubs()function validation