.factory/skills/rust-worker/SKILL.md
--- name: rust-worker description: Handles all Rust-side work: control plane, native search engine (grep crates), native GPU engine (cudarc/CUDA), routing, index subsystem, rewrite substrate, and benchmark gates. --- # rust-worker NOTE: Startup and cleanup are handled by `worker-base`. This skill defines the WORK PROCEDURE. ## When to Use This Skill Use this worker for: - Rust control plane changes (`rust_core/src/main.rs`, routing, JSON output) - Native search engine embedding (grep-searche
npx skillsauth add oimiragieo/tensor-grep .factory/skills/rust-workerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
NOTE: Startup and cleanup are handled by worker-base. This skill defines the WORK PROCEDURE.
Use this worker for:
rust_core/src/main.rs, routing, JSON output)routing.rs)backend_ast.rs)index.rstest_routing.rs)$env:PYTHONPATH = '...\src' syntax.C:\Users\oimir\.cargo\bin\cargo.exe (may not be on PATH).uv pip install -e ".[dev,ast,nlp]" instead.benchmarks/rg.zip auto-extract or benchmarks/ripgrep-14.1.0-x86_64-pc-windows-msvc/rg.exe.Read feature description and preconditions carefully. Understand what assertions this feature fulfills.
Test-Driven Development FIRST: Write a failing Rust test (in rust_core/tests/ or inline #[cfg(test)]) that asserts the new behavior. Run it and verify it fails. Only then implement.
Implement the Rust logic to make the test pass. Follow these rules:
pyo3 auto-initialize is REMOVED. Never add it back.Sync — use thread_local! or per-task allocation.AstGrep::new(source, lang), Pattern::new(pattern, lang), root.find_all(pattern).For JSON output changes: Ensure all JSON outputs include the unified envelope: version (u32), routing_backend (string), routing_reason (string), sidecar_used (bool). Test by parsing output with serde_json.
For native search engine (grep crates): Use grep-searcher for search orchestration, grep-regex for pattern compilation, grep-matcher for the Matcher trait, grep-printer for output formatting, ignore crate for .gitignore-aware parallel directory walking. Reference the grep crate docs and the ripgrep source code for usage patterns. The grep crates handle binary detection, encoding, line counting, and output formatting — leverage them instead of reimplementing.
For CUDA/GPU work:
cfg(feature = "cuda").cudarc for CUDA runtime: CudaContext::new(device_id) for device init, compile_ptx() for NVRTC kernel compilation, stream.clone_htod() for host-to-device copy, stream.clone_dtoh() for device-to-host.cargo test --features cuda and cargo build --features cuda --release..factory/research/gpu-text-search.md for kernel design patterns.For AST search speed optimizations (parallel walk, pre-filter):
ignore::WalkParallel for directory traversal. The walker threads should do everything: walk, read, pre-filter, parse, match. Use mpsc::channel to collect results, then sort by (file, line) for deterministic output.source.contains(&literal) where literal is extracted from the AST pattern. If no literal is extractable (pure metavars), skip the pre-filter and scan all files.ignore::types::TypesBuilder to register language extensions at walk time — don't post-filter.min(cpus, 12) threads, read_to_string + contains check + parse + match per file..factory/research/sg_internals_report.md for sg's exact flow.For rewrite speed optimizations (fused I/O, no fsync):
plan_and_apply, pass the file content from the planning read to the apply phase — do NOT re-read the file.sync_all() with sync_data() or remove fsync entirely. Add a code comment citing NTFS rename atomicity guarantees. sg uses plain std::fs::write() with no fsync.ensure_file_not_stale inside apply_edits_to_file when ensure_files_not_stale already ran as a batch.For index changes: Preserve TGI\x00 magic + version byte. If format changes, bump FORMAT_VERSION and handle old-format migration (rebuild with warning, not crash). Verify query result parity with uncompressed index.
Run local Rust gates:
Set-Location "C:\dev\projects\tensor-grep\rust_core"
& "C:\Users\oimir\.cargo\bin\cargo.exe" test
& "C:\Users\oimir\.cargo\bin\cargo.exe" clippy -- -D warnings
For CUDA features:
& "C:\Users\oimir\.cargo\bin\cargo.exe" test --features cuda
& "C:\Users\oimir\.cargo\bin\cargo.exe" clippy --features cuda -- -D warnings
Run local Python gates:
uv run ruff check .
uv run mypy src/tensor_grep
uv run pytest -q
{
"salientSummary": "Implemented atomic writes in apply_edits_to_file: write-to-temp (.tg_tmp_<random>) + flush + rename. Added stale-file detection with mtime check before apply. Added 5 new tests: atomic_write_success, atomic_write_cleanup_on_failure, stale_file_rejected, no_temp_files_after_success, verify_still_works_with_atomic. cargo test: 100 passed. uv run pytest -q: 510 passed.",
"whatWasImplemented": "Changed apply_edits_to_file from std::fs::write to write-temp+rename. Added file_mtime_ns field to RewriteEdit for staleness tracking. Mtime captured during plan_file_rewrites, checked in apply_edits_to_file. On mtime mismatch: returns Err with 'file modified since plan' message. Temp files cleaned up in both success and error paths.",
"whatWasLeftUndone": "",
"verification": {
"commandsRun": [
{ "command": "cargo test", "exitCode": 0, "observation": "100 passed in 0.4s" },
{ "command": "cargo clippy -- -D warnings", "exitCode": 0, "observation": "no warnings" },
{ "command": "uv run pytest -q", "exitCode": 0, "observation": "510 passed, 14 skipped" }
],
"interactiveChecks": [
{ "action": "Built release binary, ran tg run --rewrite 'lambda $$$ARGS: $EXPR' 'def $F($$$ARGS): return $EXPR' bench_data", "observed": "Plan JSON includes routing_backend=AstBackend, routing_reason=ast-native" }
]
},
"tests": {
"added": [
{ "file": "rust_core/tests/test_ast_rewrite.rs", "cases": [
{ "name": "test_atomic_write_success", "verifies": "Write-to-temp + rename produces correct file" },
{ "name": "test_atomic_write_cleanup_on_failure", "verifies": "No temp files left on write failure" },
{ "name": "test_stale_file_rejected", "verifies": "Modified file between plan and apply is rejected" },
{ "name": "test_no_temp_files_after_success", "verifies": "No .tg_tmp_* files remain after successful apply" },
{ "name": "test_verify_with_atomic_write", "verifies": "Byte-level verify still works with new write path" }
]}
]
},
"discoveredIssues": []
}
tools
--- name: backend-worker description: Handles Python-side work: sidecar IPC, benchmark scripts, corpus generators, MCP server extensions, GPU benchmarks, documentation, and compatibility tests. --- # backend-worker NOTE: Startup and cleanup are handled by `worker-base`. This skill defines the WORK PROCEDURE. ## When to Use This Skill Use this worker for: - Edit planning intelligence (`src/tensor_grep/cli/repo_map.py`) — span extraction, plan seed, context ranking, rendering - Session system
development
Use tensor-grep for repository code search, symbol lookup, blast-radius analysis, and edit planning when solving codebase tasks or preparing patches.
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.
development
Maintainer workflow for OpenClaw releases, prereleases, changelog release notes, and publish validation. Use when Codex needs to prepare or verify stable or beta release steps, align version naming, assemble release notes, check release auth requirements, or validate publish-time commands and artifacts.