Skip to content

Add specialist lifecycle registry test - #122

Merged
anandh8x merged 1 commit into
mainfrom
specialist-lifecycle-e2e
Jun 7, 2026
Merged

Add specialist lifecycle registry test#122
anandh8x merged 1 commit into
mainfrom
specialist-lifecycle-e2e

Conversation

@anandh8x

@anandh8x anandh8x commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Summary:

  • Adds a combined specialist lifecycle regression test through specialist.RegisterTools and tools.Registry.
  • Covers Task(worker, run_in_background=true), TaskOutput, TaskStop, and Task(resume=...) sharing the same task/session id.
  • Verifies background/resume exec args, prompt-gated registry execution, output polling, kill behavior, parent lifecycle events, and resume usage rollup.

Self-review:

  • This intentionally uses fake child/background launchers so the test is deterministic and does not require a real model/network child process.
  • Runtime behavior is unchanged; this is coverage for the subagent lifecycle flow described in the specialist plan.
  • The background output uses stream-json text events while the task is running, then TaskStop transitions the task to killed before the resume path is exercised.

Tests:

  • GOCACHE=/tmp/zero-go-cache go test ./internal/specialist -run TestRegisteredSpecialistToolsLifecycle -count=1
  • GOCACHE=/tmp/zero-go-cache go test ./internal/specialist
  • GOCACHE=/tmp/zero-go-cache go test ./...
  • git diff --cached --check

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage validating the complete lifecycle of specialist tools during background execution and resumption, including process control, session persistence, and event tracking.

@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Zero automated PR review

Verdict: No blockers found

Blockers

  • None found.

Validation

  • [pass] Diff hygiene: git diff --check
  • [pass] Tests: go test ./...
  • [pass] Build: go run ./cmd/zero-release build
  • [pass] Smoke build: go run ./cmd/zero-release smoke

Scope

Head: d77009911515
Changed files (1): internal/specialist/lifecycle_test.go

This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 78a10088-c871-47df-ad7c-1d6f310583cd

📥 Commits

Reviewing files that changed from the base of the PR and between 75f15da and d770099.

📒 Files selected for processing (1)
  • internal/specialist/lifecycle_test.go

Walkthrough

Added an end-to-end test validating the complete lifecycle of background Task execution: launching a child session in background mode with tool registration, querying task output, stopping the running process, resuming execution, and asserting persisted session events and usage accounting.

Changes

Specialist Task Lifecycle

Layer / File(s) Summary
Setup and background launch
internal/specialist/lifecycle_test.go
Constructs background manager with kill-tracking, session store, specialist manifest, and executor stubs. Registers tools via RegisterTools with custom Load/LaunchBackground/RunChild behaviors. Launches Task with run_in_background: true and asserts successful launch, metadata, output, and background binary invocation with expected CLI arguments (tools, depth, tags, session IDs).
Output query and task stop
internal/specialist/lifecycle_test.go
Queries TaskOutput for the running background task, invokes TaskStop, validates killed status/exit code and that the recorded killed PID matches expected value, then re-checks TaskOutput to confirm killed state and expected output contents.
Resume and persisted event validation
internal/specialist/lifecycle_test.go
Resumes the child session via Task with resume field, asserts success and resume CLI arguments with increased depth/flags. Validates parent session store persisted exactly two EventSpecialistStart events, two EventSpecialistStop events (killed then success/resume), and one usage event with child session ID, background killed status/exit code, resume mode, and total token aggregation to 13.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Gitlawb/zero#115: Introduces the Task tool's run_in_background + resume logic and TaskOutput/TaskStop tools that this test directly exercises.
  • Gitlawb/zero#111: Provides the specialist execution foundation (exec.go helpers) that this test validates through child-launch and resume CLI argument assertions.
  • Gitlawb/zero#116: Implements the background termination/resume behavior (KillRunning/MarkExited and specialist.Runtime lifecycle) that this test verifies through killed status and shutdown cleanup assertions.

Suggested reviewers

  • gnanam1990
  • Vasanthdev2004
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding an end-to-end lifecycle test for specialist tool registration and execution.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch specialist-lifecycle-e2e

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

@Vasanthdev2004 Vasanthdev2004 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Blockers

  • None found.

Non-Blocking

  • None.

Looks Good

  • The new TestRegisteredSpecialistToolsLifecycle exercises the registered Task, TaskOutput, and TaskStop tools through the real registry path rather than only testing executor helpers directly.
  • It covers the background launch path end-to-end: child session creation, CLI args (--init-session-id, stream-json, enabled tools, depth/tag/calling IDs/cwd), background output replay, TaskStop kill behavior, and killed status/exit-code reporting.
  • It also covers resume accounting through the registered Task tool, including resume args, specialist start/stop events, and parent usage rollup from stream-json usage events.
  • Local validation passed: focused specialist lifecycle/accounting tests, go test -count=1 ./internal/specialist ./internal/background ./internal/sessions ./internal/tools, go test -count=1 -p 1 ./..., go vet ./..., go build ./cmd/zero, go run ./cmd/zero-release build, go run ./cmd/zero-release smoke, and git diff --check.
  • The PR is based on current origin/main (merge-base == origin/main), so no separate latest-main merge was needed.
  • GitHub CI is green on d770099; CodeRabbit also approved.

Verdict: Approved — this is test-only coverage for the specialist lifecycle registry path, and it passes local and CI validation.

@anandh8x
anandh8x merged commit f3463d6 into main Jun 7, 2026
6 checks passed
@Vasanthdev2004
Vasanthdev2004 deleted the specialist-lifecycle-e2e branch June 28, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants