Skip to content
Source
Sign inSign up
pingdotgg/t3code

Harden VCS polling and CLI shutdown handling #3573

Closedbmdavis419(GitHub profile, opens in a new tab)wants to merge 15 commits intomain fromcodex/fix-vcs-poller-lifecycleopened View on GitHub

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.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      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](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Closing in favor of #2829 (orchestration V2).

      #2829 deletes the V1 orchestration layer this PR builds on — apps/server/src/orchestration/**, provider/Layers/*Adapter.ts and provider/Services/** are removed and replaced by apps/server/src/orchestration-v2/**, with the IPC surface renamed to ORCHESTRATION_V2_WS_METHODS. The files this PR touches either no longer exist or are rewritten, so it can't be rebased — it would need reimplementing against the V2 adapters.

      This is not a judgement on the change itself. Several of these are real gaps we still want fixed; the base just moved out from under them.

      Once #2829 merges, please rebase onto main, port the change to the V2 equivalent, and reopen (or open a fresh PR). Ping me and I'll prioritise the review.

    5. juliusmarminge closed this

Sign in to join this conversation.