Skip to content

refactor: modernize Process API calls and eliminate shell injection - #24

Open
renich wants to merge 3 commits into
amberframework:mainfrom
renich:feature/modernize-process-simd
Open

renich wants to merge 3 commits into
amberframework:mainfrom
renich:feature/modernize-process-simd

Conversation

@renich

@renich renich commented Jun 11, 2026 •

Copy link
Copy Markdown

refactor: modernize Process API calls and eliminate shell injection

  • Refactored Process.run and Process.new calls in helpers.cr and process_runner.cr to eliminate shell: true and use the RFC 0025 typed Process API, preventing shell command injections.
  • Implemented LRU cache boundaries on @@cache in ai_transformer.cr with a MAX_CACHE_SIZE of 1000 to prevent memory leaks in persistent instances.
  • Removed unused shell: true flag in database.cr seed invocation.
  • Removed compile-time SIMD @[TargetFeature("+avx2")] annotations following upstream review on granite#514.

Co-developed-by: Gemini AI renich+gemini@woralelandia.com
Signed-off-by: Rénich Bon Ćirić renich@woralelandia.com

@renich

renich commented Jun 12, 2026

Copy link
Copy Markdown
Author

Hello! I have updated the PR to remove the @[TargetFeature("+avx2")] annotations.

I apologize for the oversight regarding @[TargetFeature("+avx2")] and the assumptions about LLVM's autovectorizer on heap-allocated objects and its warnings on ARM64. You are completely right, and I appreciate you calling this out. We will ensure we construct and verify benchmarks before proposing compile-time micro-optimizations in the future.

Co-developed-by: Gemini AI renich+gemini@woralelandia.com
Signed-off-by: Rénich Bon Ćirić renich@woralelandia.com

@renich renich changed the title refactor: modernize Process API and add SIMD optimizations refactor: modernize Process API calls and eliminate shell injection Sep 16, 2026
renich and others added 3 commits September 16, 2026 01:49
Phase 2:
- Refactored `Process.run` and `Process.new` calls in `helpers.cr` and
  `process_runner.cr` to eliminate `shell: true` and use the RFC 0025 typed
  Process API, preventing shell injections.
- Implemented LRU Cache boundaries on `@@cache` in `ai_transformer.cr`
  with a `MAX_CACHE_SIZE` of 1000 to prevent memory leaks in persistent instances.
- Removed unused `shell: true` flag in `database.cr` seed invocation.

Phase 3:
- Applied `@[TargetFeature("+avx2")]` to the high-frequency string
  parsing methods in `AmberCLI::Vendor::Inflector` to accelerate regex and
  string operations.

Co-developed-by: Gemini AI <renich+gemini@woralelandia.com>
Signed-off-by: Rénich Bon Ćirić <renich@woralelandia.com>
Remove unnecessary and platform-unfriendly `@[TargetFeature("+avx2")]` annotations from inflector helper methods.

Co-developed-by: Gemini AI <renich+gemini@woralelandia.com>
Signed-off-by: Rénich Bon Ćirić <renich@woralelandia.com>
- Add Mutex synchronization to AITransformer.@@cache to prevent data
  races under M:N multithreading.
- Guard Helpers.run against empty command strings.
- Add optional shell parameter to Helpers.run and retain shell: true
  for user-defined tasks in Sentry watch runner.
- Add concurrency spec for AITransformer cache.

Co-developed-by: Gemini AI <renich+gemini@woralelandia.com>
Signed-off-by: Rénich Bon Ćirić <renich@woralelandia.com>
@renich
renich force-pushed the feature/modernize-process-simd branch from 70f8298 to 506c9e5 Compare September 16, 2026 07:51

This branch has not been deployed

No deployments
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.

1 participant