Repository navigation
refactor: migrate Python package and CLI to shards_kernel - #61
Conversation
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Security | 1 minor 1 critical 1 medium |
🟢 Metrics 1045 complexity · 29 duplication
Metric Results Complexity 1045 Duplication 29
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Pull Request Overview
Three high-confidence blocking issues remain: the FastAPI adapter permits wildcard CORS by default, the async kernel relies on an optimization-strippable assertion for runtime control flow, and the Flask adapter registers duplicate policy routes. These can expose unintended API access or produce incorrect runtime behavior.
The documented async import and setup entry point are also broken. Packaging validation lacks regression coverage for legacy namespace leakage, and the release workflow lacks an automated check confirming that PyPI publishing remains disabled.
4 comments outside of the diff
shards_kernel/async_support/async_kernel.py
line 154🔴 HIGH RISK
Replace the assertion with an explicit exception so the invariant remains enforced in optimized execution.
shards_kernel/integrations/fastapi_adapter.py
line 82🔴 HIGH RISK
Make the default CORS policy deny-by-default, require explicitly configured trusted origins, and reject wildcard origins when credentials are enabled. Add tests for default and credentialed configurations.
shards_kernel/integrations/flask_adapter.py
line 104🔴 HIGH RISK
Remove the duplicate policy route or give the handlers distinct endpoints, and add an HTTP regression test confirming the intended route is registered once.
shards_kernel/integrations/langchain_adapter.py
line 162🟡 MEDIUM RISK
Suggestion: Renameinputtotool_inputorraw_inputand update internal references and callers, preserving keyword compatibility if required.
Test suggestions
- Import the public API and verify it is identical between
shards_kernelandshards_kernel.api. - Verify distribution metadata and the
shards-kernelconsole entry point. - Invoke
python -m shards_kernel --versionsuccessfully. - Build a wheel and reject missing canonical files or leaked legacy namespace members.
- Run migrated CLI validate and replay commands.
- Verify migrated integrations, SDK, async wrappers, persistence, permits, and kernel variants.
- Verify the release workflow contains no PyPI publishing job.
- Run all documented demos and smoke checks using only the new namespace.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Build a wheel and reject missing canonical files or leaked legacy namespace members.
2. Verify the release workflow contains no PyPI publishing job.
Low confidence findings
- Verify that all supported Python versions can parse and run the migrated code, particularly the newer union-type syntax, or adjust the declared support matrix accordingly.
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
|
|
||
| ```python | ||
| from kernels.async import AsyncStrictKernel | ||
| from shards_kernel.async import AsyncStrictKernel |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Replace this syntactically invalid import with the implemented shards_kernel.async_support package path.
TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.
| WorkingDirectory=/opt/kernels | ||
| Environment=KERNELS_LOG_LEVEL=INFO | ||
| ExecStart=/opt/kernels/venv/bin/python -m kernels.server | ||
| ExecStart=/opt/shards_kernel/venv/bin/python -m shards_kernel.server |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Update this command to the implemented server entry point or add the missing module so the documented deployment path is executable.
TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.
|
|
||
|
|
||
| def test_module_cli_is_invokable(): | ||
| result = subprocess.run([sys.executable, "-m", "shards_kernel", "--version"], capture_output=True, text=True, check=True) |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Suggestion: Add a narrowly scoped comment or suppression documenting that the executable and arguments are fixed test inputs and shell execution is disabled.
See Issue in Codacy
See Issue in Codacy
TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0397001bd2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| - name: Scan Python source with Bandit | ||
| run: bandit -r kernels implementations -ll | ||
| run: bandit -r shards_kernel implementations -ll |
There was a problem hiding this comment.
Update the retained Codacy scan to the new namespace
The namespace migration leaves .github/workflows/codacy.yml:38 running bandit -r kernels implementations -ll. Repository-wide search confirms that the implementation now lives exclusively under shards_kernel/, so the retained “Codacy Security Scan” no longer scans the main package on pushes, pull requests, or its weekly schedule. Updating the separate security workflow here does not update that job. Bandit's documentation defines -r as “find and process files in subdirectories”; its explicit target must also be changed to shards_kernel. See the Bandit CLI documentation.
Useful? React with 👍 / 👎.
Scope
kernels/toshards_kernel/and update Python consumers/tests/examples.shards-kerneland rename the console entrypoint toshards-kernel.Compatibility
Intentional breaking import change:
from kernels ...becomesfrom shards_kernel .... No legacykernelsimport alias is shipped because that top-level namespace collides with the unrelated Hugging Face PyPI package.Verification gates
Awaiting GitHub CI, coverage, smoke demos and wheel build. This PR remains draft until verified. No PyPI publishing authorized.