Skip to content

Harden VCS polling and CLI shutdown handling#3573

Open
bmdavis419 wants to merge 15 commits into
mainfrom
codex/fix-vcs-poller-lifecycle
Open

Harden VCS polling and CLI shutdown handling#3573
bmdavis419 wants to merge 15 commits into
mainfrom
codex/fix-vcs-poller-lifecycle

Conversation

@bmdavis419

@bmdavis419 bmdavis419 commented Jun 26, 2026

Copy link
Copy Markdown

Summary

  • Bound Git/VCS refresh waiters and status broadcaster state so interrupted or stalled refreshes do not pile up.
  • Added bounded child-process shutdown and explicit CLI signal escalation so stuck shutdowns eventually force exit.
  • Tightened provider event log lifecycle and reduced tracing overhead on hot native log paths.
  • Released idle client VCS subscriptions immediately to avoid unnecessary polling work.

Testing

  • vp check
  • vp run typecheck
  • vp run lint if available, otherwise not run
  • Added/updated unit coverage for child-process shutdown, shutdown signal escalation, VCS refresh behavior, and provider event logging

Note

Harden VCS polling and CLI shutdown handling with bounded process spawning and LRU status cache

  • VCS status cache: VcsStatusBroadcaster now maintains a bounded 128-entry LRU cache; entries are evicted when the last subscriber disconnects, and active pollers protect their entries from eviction.
  • Upstream refresh: GitVcsDriverCore serializes concurrent git fetches per shared object store, uses hardened --no-write-fetch-head fetch flags, backs off 30s on failure, and surfaces fetch errors via a new refreshStatusUpstream service method on GitVcsDriver and GitWorkflowService.
  • CLI shutdown escalation: installNodeShutdownSignalEscalation installs SIGINT/SIGTERM handlers that force-exit with a conventional code on a second signal or after a 10s timeout; installed and cleaned up in bin.ts.
  • Bounded child process spawner: BoundedChildProcessSpawner wraps the existing spawner to send SIGTERM on scope close, escalate to SIGKILL after termGraceMs, and detach delegate finalizers so they don't block caller scope closure; activated via BoundedChildProcessSpawner.layer() in the CLI runtime.
  • Event NDJSON logging: EventNdjsonLogStore replaces per-stream writers with a shared store supporting retention by age/size, oversized-record omission notices, and a configurable batch window (now 1000ms); native and canonical loggers share state in ProviderEventLoggers.
  • VCS status atom: client-side VCS status subscription atom now sets idleTtlMs: 0, tearing down immediately when it has no consumers.
  • Risk: default log batch window increased from 200ms to 1000ms, which delays log flushes under light write loads.

Macroscope summarized 4a4df05.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cced1734-0611-493f-bdb1-bd2a98fcf64d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-vcs-poller-lifecycle

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XXL 1,000+ changed lines (additions + deletions). labels Jun 26, 2026
Comment thread apps/server/src/vcs/VcsStatusBroadcaster.ts
Comment thread apps/server/src/vcs/GitVcsDriverCore.ts Outdated
Comment thread apps/server/src/provider/Layers/EventNdjsonLogger.ts
Comment thread apps/server/src/vcs/GitVcsDriverCore.ts
Comment thread apps/server/src/provider/Layers/EventNdjsonLogger.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

2 blocking correctness issues found. This PR introduces new CLI shutdown handling, bounded child process spawning, significant VCS polling changes with new locking/caching mechanisms, and a major refactor of the event logging system. Two unresolved review comments identify potential bugs in the new caching and retention logic. These substantial behavioral changes warrant human review.

You can customize Macroscope's approvability policy. Learn more.

Comment thread apps/server/src/vcs/VcsStatusBroadcaster.ts
Comment thread apps/server/src/provider/Layers/EventNdjsonLogger.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant