Support Grok Build CLI as a provider - #23
Conversation
d124dae to
faafeb2
Compare
|
Thanks for contributing Grok Build support! Please rebase this PR onto the latest The main priorities are:
Please include the resulting additions/deletions for runtime code, tests/fixtures, and docs, along with the verification performed and any remaining limits. |
faafeb2 to
0532f49
Compare
Read the authoritative ACP timeline under GROK_HOME through the existing provider, CLI, and rendering interfaces. Preserve real user turns, failures, stops, timestamps, and every compaction summary record. Warn about losses when falling back to chat history and honor explicit session visibility. Use sanitized real-record fixtures with focused provider and CLI tests. Keep shared conformance infrastructure out of this provider addition.
0532f49 to
2c38180
Compare
|
@wilbeibi, I updated this PR in commit The commit has I made these changes:
I also corrected three Grok behaviors:
The final changes against
The total decreased from 2,155 to 1,226 changed lines. The PR description includes the remaining code complexity. All tests, race checks, the build, and I made 19 temporary code changes that caused incorrect behavior. The tests detected all 19 changes. I then restored the correct code. I compared both versions with the same real session. All 20 compaction summaries now include the missing content. All other entries are unchanged. Upstream CI reports The PR description records the verification details and remaining limits. |
|
Merged — thanks for the thorough revision. I'll follow up in a separate commit on retained context under |
Grok Build support
Read Grok Build sessions from
$GROK_HOME/sessionsthrough catchup's existing selection, filtering, rendering, and handoff commands. The authoritativeupdates.jsonlstream preserves user turns, timestamps, tool and background-task failures, error stops, and history across compaction. A checkpoint can contain multiplecompaction_metarecords; the reader includes all of them in order so it retains the actual summary as well as injected context.chat_history.jsonlis the fallback when updates are absent, contain no readable conversation, or exceed 512 MiB. Fallback warnings name the missing timestamps, failures, stop reasons, and potentially missing pre-compaction history. Earlier parse warnings survive fallback. Real user turns withpromptIndexremain visible;hideFromScrollbackfilters injected turns. Explicithidden: falseoverrides the subagent default, while hidden sessions and unused husks remain accessible by ID.Native fork uses
grok --resume <id> --fork-session; cross-agent handoff usesgrok [-m model] <prompt>. Both argument forms were checked againstgrok 1.0.41 (4220f3b224a6) --help. This verifies the supported flags, not a newly launched interactive fork.Response to review
main,8cf6a47, including AGENTS.md.session.Failure, query/summary helpers, root resolution, and common CLI/rendering. Removed the duplicate JSON compactor and unused decoded fields. No new dependencies.docs/providers.mdis not shipped or linked as documentation.Changes against upstream, counting complete files by purpose:
The PR changed 2,155 lines before revision and now changes 1,226, a reduction of 929 lines. These are PR-to-base counts; removed unrelated additions are not credited against the Grok implementation's cost.
Complexity and evidence
Lizard measurements compare upstream, the previous PR, and this revision. The Grok event dispatcher remains at cyclomatic complexity 40 and the chat reader at 18. Fallback selection rises from 6 to 11 because it now distinguishes filesystem errors, empty/damaged streams, and preservation of warnings. The event dispatcher and chat reader remain complex. Lower line counts and passing tests do not establish that this complexity is necessary. Existing provider selection and launch switches gain only their Grok cases.
The two transcript formats require separate decoding because ACP message chunks carry content objects, tool updates carry arrays or raw output, and chat history carries model-message records. Reading only the smaller chat file would lose the timestamped failure history and earlier turns this feature is meant to recover. The 512 MiB cap remains an explicit fallback policy, tested with a sparse file.
Fixtures are sanitized excerpts from a real session inspected with Grok 1.0.41. Their source line numbers and transformations are recorded in
internal/grok/grok_test.go; ordering and relevant record shapes are retained. Visibility predicates were checked against xai-org/grok-build commitf0e3be1100ef5252488e3be8bb0e91cf68d8c305,crates/codegen/xai-grok-shell/src/session/persistence.rs. That source reference is separate from the installed binary revision.Verification
Passed on macOS arm64 with Go 1.25.0:
go test -mod=readonly ./...go test -mod=readonly -race ./...go vet -mod=readonly ./...go build -mod=readonly -o /private/tmp/catchup-pr23-after .gofmt -l .andgit diff --checkAlso passed
go build ./...on the installed Go 1.27.1 toolchain and a Windows amd64 cross-build. Windows tests were not executed locally.A read of the same unchanged 118,770,944-byte real updates log produced 426 entries, including 19 user turns, 87 failures, 20 compaction entries and 6 stops. All entries have timestamps and there are no warnings. Independent source checks match the failure/user/stop counts and all checkpoint text. All 20 previously incomplete checkpoint summaries are fixed; every non-compaction entry is identical to the previous implementation. The final Go 1.25 read took about 2.1 seconds in one run; this is not a performance benchmark.
Test review:
TestReadowns ordered parsing, fallback losses, retained context, incomplete/unknown records, streamed text and duplicate failure handling. Its literal expectations come from the sanitized records, independently of production helpers.TestListAndResolve,TestVisibility,TestIndexFallbacksandTestReadSourceErrorsown selection, source-backed visibility and read errors. Existing CLI/root test files cover the distinct integration and launch contracts.Remaining limits: compatibility with other Grok versions is unverified; oversized updates use the disclosed lossy fallback; missing/unreadable checkpoint files leave a bare compaction marker, with the existing
--since-compactwarning when applicable. Upstream CI run 36315598741 reportsaction_requiredwith zero jobs. No upstream Linux/Windows test result is available; this is separate from the passing local checks and Windows cross-build.