GitNexus/gitnexus/src/cli
ChamHerry 2a3d14057a
fix(analyze): prevent cache-hit native workers from aborting (#1751)
* fix(analyze): prevent cache-hit native workers from aborting

Delay parse worker startup until a cache miss requires it, fall back to sequential parsing when initial worker readiness fails, and preserve analyzer diagnostics/progress when heap respawn captures child output.

Constraint: Node 25 and tree-sitter/N-API worker initialization can abort before ready, while warm-cache analysis should not start workers at all.

Rejected: Treating status-134/SIGABRT as heap OOM unconditionally | native worker aborts require distinct recovery guidance and stderr/stdout evidence.

Rejected: cli-progress noTTYOutput for respawn progress | it appends newline frames instead of preserving one-line redraw UX.

Confidence: high

Scope-risk: moderate

Directive: Keep parse-worker creation behind confirmed cache misses and preserve TTY-style progress when respawn pipes stderr for crash classification.

Tested: GitNexus impact analysis for ensureHeap, runChunkedParseAndResolve, createWorkerPool, WorkerPool, walkRepositoryPaths; GitNexus detect_changes scoped to staged worktree; targeted vitest for analyze respawn, parse lazy cache, filesystem walker, worker pool; npx tsc --noEmit; npm run build; NODE_OPTIONS='--max-old-space-size=8192' npm test.

Not-tested: Windows terminal rendering and published npm package install path.

* ci(docker): tolerate slower arm64 TypeScript builds

Docker PR builds run gitnexus prepare under QEMU for linux/arm64, where the fixed 120s TypeScript timeout can kill otherwise healthy builds. Increase the default timeout and allow GITNEXUS_BUILD_TIMEOUT_MS to tune slower environments without changing the build steps.

Constraint: PR #1751 Docker Build & Push gitnexus failed with spawnSync /bin/sh ETIMEDOUT while running node_modules/.bin/tsc in scripts/build.js.\nRejected: Rerunning CI only | the failure was the build script's deterministic timeout boundary under arm64 emulation, not a code assertion.\nConfidence: high\nScope-risk: narrow\nDirective: Keep build timeout changes in scripts/build.js configurable; do not hide real compiler failures, only allow slower successful compiles to finish.\nTested: GitNexus impact for gitnexus/scripts/build.js reported LOW; gitnexus detect_changes reported 1 changed file, 0 affected processes, low risk; git diff --check; gitnexus npm run build.\nNot-tested: GitHub Docker arm64 build rerun before pushing; local Docker multi-platform build under QEMU.

* fix(analyze): truncate respawn progress safely

Preserve complete ANSI escape sequences and grapheme boundaries when the respawn progress terminal shim truncates wrapped output, so the shim does not emit dangling escape bytes or split surrogate pairs while keeping raw writes untouched.

Constraint: Claude review on PR #1751 flagged `s.slice(0, width)` in createAnsiPipeTerminal.write() as a latent terminal-corruption risk.
Rejected: Adding a display-width dependency | a local helper is sufficient for this narrow respawn terminal shim and avoids new dependency churn.
Rejected: Changing silent status-134 classification | current tests already document the output-less 134 fallback as heap guidance.
Confidence: high
Scope-risk: narrow
Directive: Keep respawn terminal writes ANSI-aware and preserve rawWrite bypass semantics for callers that intentionally write control sequences.
Tested: GitNexus impact for createAnsiPipeTerminal reported LOW; GitNexus detect_changes reported 2 changed files, 3 affected processes, medium risk; targeted vitest for analyze respawn progress and heap respawn; gitnexus npx tsc --noEmit; prettier check for changed files; eslint for changed files.
Not-tested: Full npm test suite; manual terminal rendering on Windows.

---------

Co-authored-by: wangxc <wangxc_a_bj@si-tech.com.cn>
2026-05-21 16:17:02 +01:00
..
ai-context.ts feat: gitnexus:keep marker preserves custom context sections (resubmit of #605) (#1508) 2026-05-14 07:40:15 +01:00
analyze.ts fix(analyze): prevent cache-hit native workers from aborting (#1751) 2026-05-21 16:17:02 +01:00
augment.ts feat(cursor): upgrade hooks to Cursor 2.4 postToolUse for Read/Grep/Shell coverage (#1467) 2026-05-10 13:29:06 +01:00
clean.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
cli-message.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
doctor.ts fix: add platform-aware semantic fallback (#1150) 2026-04-28 12:21:25 +01:00
eval-server.ts fix(eval-server): localhost now doesn't normalize into IPv4 instead lets OS decide which to bind (#1722) 2026-05-20 16:14:13 +01:00
group.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
index-repo.ts fix(cli): keep GitNexus ignores inside .gitnexus (#1248) 2026-05-01 16:46:05 +01:00
index.ts fix(workers): resilient + zero-copy ingestion worker pool — prevent analyze hangs on TS-root-scale loads (#1693) 2026-05-20 20:39:35 +01:00
lazy-action.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
list.ts feat(cli): analyze --name <alias> + duplicate-name guard for the repo registry (#955) 2026-04-19 07:23:48 +01:00
mcp.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
optional-grammars.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
publish.ts feat(cli): add gitnexus publish for opt-in understand-quickly registry (#1425) 2026-05-09 09:52:26 +01:00
remove.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
serve.ts fix(lbug): issue #1647, detect WAL corruption in schema init and surface recovery (#1650) 2026-05-17 10:46:45 +01:00
setup.ts fix(mcp): setup fallback on Windows when global gitnexus resolves to a non-spawnable shim (#1694) 2026-05-19 08:17:26 +01:00
skill-gen.ts feat: configure eslint with unused import removal (#564) 2026-03-28 15:28:09 +00:00
status.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
tool.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
wiki.ts fix(workers): resilient + zero-copy ingestion worker pool — prevent analyze hangs on TS-root-scale loads (#1693) 2026-05-20 20:39:35 +01:00