chore: sync core lib and CLAUDE.md from agent-core#88
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces significant security hardening for binary management, including SHA-256 checksum verification and robust archive entry validation to prevent path traversal attacks. It also adds a new module for repository intelligence queries and implements optimistic locking for workflow state management to safely handle concurrent task updates. The review feedback suggests improving the portability of the tar commands by explicitly specifying stdin as the input source using the -f - flag.
| const tar = cp.spawn('tar', ['xz', '-C', tarDest], { | ||
| stdio: ['pipe', 'pipe', 'pipe'] | ||
| }); | ||
| const tar = cp.spawn('tar', ['-tz'], { stdio: ['pipe', 'pipe', 'pipe'] }); |
There was a problem hiding this comment.
For better portability across different tar implementations (especially on Linux), it is recommended to explicitly specify that input should be read from stdin using the -f - flag. Some versions of tar do not default to stdin when no file is provided.
| const tar = cp.spawn('tar', ['-tz'], { stdio: ['pipe', 'pipe', 'pipe'] }); | |
| const tar = cp.spawn('tar', ['-tzf', '-'], { stdio: ['pipe', 'pipe', 'pipe'] }); |
|
|
||
| try { | ||
| await new Promise(function(resolve, reject) { | ||
| const tar = cp.spawn('tar', ['xz', '-C', scratch], { stdio: ['pipe', 'pipe', 'pipe'] }); |
There was a problem hiding this comment.
Similar to the listing command, adding -f - ensures that tar correctly reads the archive from stdin across various platforms and tar versions.
| const tar = cp.spawn('tar', ['xz', '-C', scratch], { stdio: ['pipe', 'pipe', 'pipe'] }); | |
| const tar = cp.spawn('tar', ['-xzf', '-', '-C', scratch], { stdio: ['pipe', 'pipe', 'pipe'] }); |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 473d265. Configure here.
| // Another writer won — retry with jitter | ||
| const jitter = Math.floor(Math.random() * 20); | ||
| const start = Date.now(); | ||
| while (Date.now() - start < jitter) { /* busy-wait for short jitter */ } |
There was a problem hiding this comment.
Busy-wait loop ignores existing sleepForRetry utility
Medium Severity
The new updateTasks retry loop uses a CPU-spinning busy-wait (while (Date.now() - start < jitter) {}) for its jitter delay, while sleepForRetry is already imported on line 19 and used by the analogous updateFlow function at line 396 for the same purpose. sleepForRetry uses Atomics.wait for a proper non-blocking synchronous sleep, avoiding needless CPU consumption. This is both inconsistent with the existing pattern and wasteful.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 473d265. Configure here.


Automated sync of lib/ and CLAUDE.md from agent-core.
Note
Medium Risk
Touches the runtime binary download/extraction path and changes
tasks.jsoncorruption handling from silent fallback to throwing/optimistic-lock updates, which could affect installs and workflow state under concurrency or bad disk data.Overview
Hardens runtime installation of the
agent-analyzerbinary by verifying each GitHub release asset against a required<asset>.sha256sidecar and refusing to install unverified/mismatched downloads (with askipChecksumdev-only escape hatch).Reworks archive extraction to be safer: extracts into an isolated scratch dir, validates archive entry paths against traversal/absolute/UNC patterns, rejects symlinks, and then copies only the expected binary into the final install location; Windows zip extraction now uses a PowerShell
-Filehelper with env-passed paths and per-entry validation.Adds
lib/repo-intel/queries.jswith typed wrappers aroundagent-analyzer repo-intel query ...(including a dedicatedRepoIntelMissingError). Updatesworkflow-statetasks.jsonstorage to a canonical schema and introduces versioned writes plus optimistic-lock helpers (updateTasks,claimTask,releaseTask), while changing corrupted JSON handling to throw/avoid overwriting instead of silently returning defaults.Reviewed by Cursor Bugbot for commit 473d265. Configure here.