Skip to content

feat(antigravity): reuse a running agy language server for CLI usage - #1782

Merged
steipete merged 8 commits into
steipete:mainfrom
junmo-kim:feat/antigravity-cli-reuse-warm-agy
Jul 1, 2026
Merged

feat(antigravity): reuse a running agy language server for CLI usage#1782
steipete merged 8 commits into
steipete:mainfrom
junmo-kim:feat/antigravity-cli-reuse-warm-agy

Conversation

@junmo-kim

@junmo-kim junmo-kim commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Problem

codexbar usage --provider antigravity --source cli starts a fresh agy language server for every one-shot invocation. Fresh servers bind quickly but can take several seconds before quota endpoints become ready, leaving little margin under the existing five-second readiness deadline.

Design

Before a one-shot CLI fetch spawns agy, CodexBar spends at most two seconds looking for a reusable warm server. Reuse is deliberately bounded:

  • CLI processes only; IDE/app servers remain on their CSRF-authenticated path.
  • Same operating-system user only, because the CLI HTTPS endpoint is tokenless.
  • The resolved agy binary only, preserving explicit binary selection and multi-install behavior.
  • CodexBar-owned processes are excluded so managed-session probe/idle accounting stays balanced.
  • Automatic account selection accepts only a matching account and can continue to another candidate.
  • The two-second budget is shared across discovery, port lookup, and fetch.
  • Cancellation is rethrown and never downgraded into a fallback spawn.
  • Long-lived app/server hosts continue using AntigravityCLISession; external reuse is one-shot CLI only.

Any ordinary discovery, port, or fetch miss falls through to the existing managed spawn path.

Verification

Exact head d8170bd54d2c9ecbcb22c1610d59795f8d353778:

  • swift test --filter AntigravityWarmAgyReuseTests: 15 passed.
  • swift test --filter AntigravityCLIHTTPSFetchStrategyTests: 34 passed.
  • swift test --filter AntigravityCLISessionTests: passed.
  • make check: clean; SwiftFormat and SwiftLint reported no violations.
  • make test: all 44 shards passed.
  • ./Scripts/lint.sh lint-linux: clean.
  • Branch-level autoreview: no actionable findings.

Live macOS provider/process proof used an existing authenticated user session and the exact release helper. Three consecutive calls returned usage in 0.68–1.45 seconds, all logged warm reuse, retained the same single external PID, and cleanup left zero processes. Cold fallback was also exercised separately: it started one managed process, returned usage, and left no process behind. No account identifiers or credentials were captured in this report.

Regression coverage includes warm reuse, ordinary fallback, IDE exclusion, managed-PID exclusion, same-user isolation, selected-binary isolation, selected-account routing, shared deadline behavior, cancellation propagation, and long-lived host lifecycle preservation.

@clawsweeper

clawsweeper Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codex review: needs changes before merge. Reviewed July 1, 2026, 1:57 AM ET / 05:57 UTC.

Summary
The PR adds bounded one-shot Antigravity CLI warm-server reuse with same-user, selected-account, selected-binary, owned-PID, deadline, cancellation, docs, and tests.

Reproducibility: yes. from source inspection: current tests classify node .../antigravity-cli/... as CLI, while the PR skips warm candidates whose command line does not start with the resolved agy path. I did not run live provider probes because AGENTS.md warns against unrequested provider validation that can prompt for credentials.

Review metrics: 2 noteworthy metrics.

  • Changed surface: 6 files changed, +767/-2. The behavior is provider-scoped but touches production process discovery, docs, changelog, and tests.
  • Warm-reuse coverage: 1 new test file, 468 added lines. The added tests cover the fast path, fallback path, lifecycle exclusion, account selection, cancellation, same-user isolation, and deadline behavior.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Fix the wrapper-spawned antigravity-cli matching gap and add a focused regression test.

Risk before merge

  • [P1] Wrapper-spawned antigravity-cli servers may still fall back to cold spawn, so those users can keep seeing the readiness failures this PR is meant to avoid.

Maintainer options:

  1. Decide the mitigation before merge
    Broaden the warm-reuse identity check to cover CLI server shapes CodexBar already recognizes while preserving same-user, selected-account, owned-PID, one-shot-only, cancellation, timeout, and multi-install safety, then add a regression test.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • A narrow repair remains: broaden the wrapper-spawned CLI matching guard and test it; final merge should wait for that fix and normal maintainer review.

Security
Cleared: No concrete security or supply-chain regression was found; the diff adds local same-user process reuse without new dependencies, workflows, or broader secret handling.

Review findings

  • [P2] Accept wrapper-spawned Antigravity CLI servers — Sources/CodexBarCore/Providers/Antigravity/AntigravityProviderDescriptor.swift:256-257
Review details

Best possible solution:

Broaden the warm-reuse identity check to cover CLI server shapes CodexBar already recognizes while preserving same-user, selected-account, owned-PID, one-shot-only, cancellation, timeout, and multi-install safety, then add a regression test.

Do we have a high-confidence way to reproduce the issue?

Yes, from source inspection: current tests classify node .../antigravity-cli/... as CLI, while the PR skips warm candidates whose command line does not start with the resolved agy path. I did not run live provider probes because AGENTS.md warns against unrequested provider validation that can prompt for credentials.

Is this the best way to solve the issue?

No, not quite yet. The warm-reuse design is narrow and well bounded, but the selected-binary guard needs to account for wrapper-spawned CLI server command lines before the PR fully solves the reported reliability issue.

Full review comments:

  • [P2] Accept wrapper-spawned Antigravity CLI servers — Sources/CodexBarCore/Providers/Antigravity/AntigravityProviderDescriptor.swift:256-257
    The process scan already classifies node .../.gemini/antigravity-cli/... as .cli, but this selected-binary guard only accepts command lines equal to or starting with the resolved agy path. Wrapper installs will skip the warm server and fall back to fresh spawn, leaving the five-second readiness failures this PR is meant to avoid.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.87

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 51eeae71bad8.

Label changes

Label justifications:

  • P2: This is a normal-priority Antigravity CLI reliability improvement with a provider-specific blocker and limited blast radius.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body reports after-fix live macOS runs showing warm reuse timings, stable external PID reuse, cleanup, and cold fallback behavior with private identifiers omitted.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports after-fix live macOS runs showing warm reuse timings, stable external PID reuse, cleanup, and cold fallback behavior with private identifiers omitted.
Evidence reviewed

Acceptance criteria:

  • [P1] swift test --filter AntigravityWarmAgyReuseTests.
  • [P1] swift test --filter AntigravityCLIHTTPSFetchStrategyTests.
  • [P1] make check.

What I checked:

Likely related people:

  • steipete: Blame for the current Antigravity CLI strategy points to the v0.37.2 integration state, and this PR includes recent hardening commits from the same person in the affected Antigravity files. (role: current-main integrator and recent area contributor; confidence: high; commits: f380287041b8, 8af9a261b4a0, 5e7c3b98b4b0; files: Sources/CodexBarCore/Providers/Antigravity/AntigravityProviderDescriptor.swift, Sources/CodexBarCore/Providers/Antigravity/AntigravityStatusProbe.swift, Sources/CodexBarCore/Providers/Antigravity/AntigravityCLISession.swift)
  • enieuwy: The managed agy CLI fallback and CLI HTTPS behavior this PR extends were introduced in the Antigravity agy CLI fallback work. (role: feature introducer; confidence: high; commits: cd201b9e5035; files: Sources/CodexBarCore/Providers/Antigravity/AntigravityProviderDescriptor.swift, Sources/CodexBarCore/Providers/Antigravity/AntigravityCLISession.swift, Tests/CodexBarTests/AntigravityCLIHTTPSFetchStrategyTests.swift)
  • Yash Bans: Local history shows this contributor added Antigravity CLI process detection, including the classifier behavior involved in the wrapper-command blocker. (role: adjacent feature contributor; confidence: medium; commits: 0b7de58416e3; files: Sources/CodexBarCore/Providers/Antigravity/AntigravityStatusProbe.swift, Tests/CodexBarTests/AntigravityStatusProbeTests.swift, docs/antigravity.md)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. labels Jun 29, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c91c5cbb0f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread Sources/CodexBarCore/Providers/Antigravity/AntigravityProviderDescriptor.swift Outdated
@junmo-kim

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 29, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. labels Jun 29, 2026
junmo-kim and others added 7 commits July 1, 2026 05:53
…rmSession

Move the existing spawn logic (beginProbe / waitForSnapshot / finishProbe
with its 5s readiness deadline) into a dedicated `fetchBySpawning` method,
and route `fetchUsingWarmSession` through a `spawnFetch` seam. Behavior is
unchanged; this only isolates the spawn path so it can be substituted or
observed by callers and tests.
One-shot CLI invocations spawn a fresh `agy` language server on every
call. A fresh server binds its port quickly but `GetUserStatus` returns
transient initialization failures for a few seconds, so the 5s readiness
deadline is occasionally missed (~30% on Linux: endpoint not ready).

Before spawning, discover an already-running authenticated `agy` CLI
language server via the existing process detection and reuse its
listening ports through the token-less CLI HTTPS endpoint. When no warm
server is found (or none answers with parseable usage), fall through to
the existing spawn path unchanged. The IDE/app servers require a CSRF
token and are excluded from this reuse path.
In long-lived hosts (the app, `codexbar serve`) the warm scan could match
the very `agy` CodexBar spawned and manages via AntigravityCLISession,
reusing it through the token-less path and bypassing beginProbe/finishProbe.
That left the idle timer un-cancelled, so stopIfIdle could tear the managed
session down mid-poll. Filter the shared session's live pid out of the warm
reuse candidates so only externally owned `agy` is reused.
@steipete
steipete force-pushed the feat/antigravity-cli-reuse-warm-agy branch from ed9f79d to 9c5628c Compare July 1, 2026 05:34

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c5628c08d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 1, 2026
@steipete
steipete merged commit 46b493f into steipete:main Jul 1, 2026
10 checks passed

steipete commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Landed in 46b493f. Thanks @junmo-kim for the contribution!

Proof for exact PR head d8170bd:

  • CI run 28496170092: 10/10 checks green, including lint, both Linux CLI jobs, all four macOS shards, aggregate gate, and GitGuardian.
  • Local verification: make check clean; make test passed all 44 shards; focused warm-reuse suite passed 15 tests; CLI HTTPS strategy suite passed 34 tests; session tests passed; Linux lint clean; autoreview found no remaining actionable issue.
  • Live macOS provider/process proof: three consecutive exact release-helper calls returned usage in 0.68–1.45 seconds, reused one stable external process, and cleanup left zero processes. Separate cold fallback proof started one managed process, returned usage, and cleanup left zero processes.
  • Safety boundaries verified: same OS user, selected binary, selected account, one-shot CLI only, managed PID exclusion, shared deadline, cancellation propagation, and long-lived managed-session isolation.

No account identifiers, ports, cookies, tokens, or credentials are included in this report.

@steipete steipete mentioned this pull request Jul 1, 2026
@junmo-kim
junmo-kim deleted the feat/antigravity-cli-reuse-warm-agy branch July 1, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants