Skip to content

feat(update): expose release check target options#96

Merged
anandh8x merged 2 commits into
mainfrom
feat/update-check-options
Jun 6, 2026
Merged

feat(update): expose release check target options#96
anandh8x merged 2 commits into
mainfrom
feat/update-check-options

Conversation

@anandh8x

@anandh8x anandh8x commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add zero update --check flags for --repo, --endpoint, and --timeout
  • pass CLI flags into the existing update.Check release metadata verifier
  • test CLI option passthrough, invalid timeout handling, help text, and endpoint precedence
  • document CLI flag/env/default precedence for release checks

Validation

  • GOCACHE=/tmp/zero-go-cache go test ./internal/update ./internal/cli -run 'TestCheck|TestResolveEndpoint|TestRunUpdate'
  • GOCACHE=/tmp/zero-go-cache go test ./...
  • GOCACHE=/tmp/zero-go-cache go run ./cmd/zero-release build
  • ./zero update --check --endpoint 'data:application/json,%7B%22tag_name%22%3A%22v0.2.0%22%2C%22html_url%22%3A%22https%3A%2F%2Fexample.test%2Frelease%22%2C%22assets%22%3A%5B%7B%22name%22%3A%22zero-v0.2.0-linux-x64.tar.gz%22%2C%22browser_download_url%22%3A%22https%3A%2F%2Fexample.test%2Fzero-v0.2.0-linux-x64.tar.gz%22%7D%2C%7B%22name%22%3A%22zero-v0.2.0-linux-x64.tar.gz.sha256%22%2C%22browser_download_url%22%3A%22https%3A%2F%2Fexample.test%2Fzero-v0.2.0-linux-x64.tar.gz.sha256%22%7D%5D%7D' --timeout=750ms --json
  • git diff --check

Coordination

This PR is in the update/release verification lane and does not touch the runtime permission decision work in #95.

Summary by CodeRabbit

  • New Features

    • Added --repo, --endpoint, and --timeout flags to the update check command for greater flexibility in specifying release sources and behavior.
  • Documentation

    • Enhanced docs with usage examples, flag descriptions, endpoint resolution precedence, timeout guidance, and exit-code expectations for check-only runs.
  • Tests

    • Added tests covering flag forwarding, invalid timeout handling, help text, and endpoint-precedence resolution.

@github-actions

github-actions Bot commented Jun 6, 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: 8d1ee8f12fd6
Changed files (5): README.md, docs/UPDATE.md, internal/cli/app_test.go, internal/cli/update.go, internal/update/update_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 6, 2026

Copy link
Copy Markdown

Too much diff to scan? Review this PR in Change Stack to start with the highest-impact changes.

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: 47ca065f-081d-4e90-bec8-bba3d22de0eb

📥 Commits

Reviewing files that changed from the base of the PR and between 7ee8f85 and 8d1ee8f.

📒 Files selected for processing (2)
  • internal/cli/app_test.go
  • internal/cli/update.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/cli/update.go
  • internal/cli/app_test.go

Walkthrough

The PR extends zero update --check to accept --repo, --endpoint, and --timeout flags alongside the existing --check and --json. The CLI now parses these arguments, forwards them to update.Options, and includes new tests verifying flag behavior, precedence, and validation. Documentation is updated with usage examples and endpoint resolution rules.

Changes

Update Check Flags

Layer / File(s) Summary
CLI flag parsing and update options
internal/cli/update.go
updateOptions struct expanded to include repository, endpoint, and timeout fields. parseUpdateArgs refactored from simple switch logic to index-based loop recognizing --repo, --endpoint, --timeout with both spaced and --flag=value forms. New parseUpdateTimeout helper validates duration via time.ParseDuration. runUpdate now passes richer update.Options with Repository, Endpoint, Timeout fields. Help text documents all new flags.
CLI tests for new update flags
internal/cli/app_test.go
New TestRunUpdatePassesCheckOptions verifies flag forwarding to update.Options and JSON stdout behavior. New TestRunUpdateRejectsInvalidTimeout ensures invalid duration fails with usage exit code and prevents checkUpdate invocation. TestRunUpdateHelpDocumentsCheckFlag extended to assert documentation of --repo, --endpoint, --timeout. time import added.
Endpoint precedence resolution test
internal/update/update_test.go
New table-driven test TestCheckResolvesEndpointPrecedence verifies endpoint resolution order: Options.EndpointZERO_UPDATE_RELEASE_URL env var → Options.Repository → default GitHub endpoint. Test stubs Fetch to reject mismatched endpoints.
Documentation updates
README.md, docs/UPDATE.md
README example updated with --repo flag. docs/UPDATE.md expanded with full CLI examples (--json, --repo, --endpoint, --timeout), clarified exit codes and timeout defaults, and documented endpoint precedence and owner/repo slug format support.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • Gitlawb/zero#84: Both PRs focus on update.Check endpoint resolution precedence; this PR adds CLI plumbing and tests for the precedence logic while the other PR updated related behavior and documentation.

Suggested reviewers

  • 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 CLI flag options (--repo, --endpoint, --timeout) to expose release check target configuration.
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 feat/update-check-options

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/cli/update.go`:
- Around line 109-116: The parseUpdateTimeout function currently allows zero or
negative durations because time.ParseDuration accepts them; after parsing the
trimmed value in parseUpdateTimeout, validate that timeout > 0 and if not return
an execUsageError with a clear message like "update timeout must be a positive
duration" (include the original value in the message). Update parseUpdateTimeout
to perform this check and return the execUsageError when timeout <= 0 so callers
get immediate, actionable feedback.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b388128b-eb89-4823-b350-1c1e89b6f0a8

📥 Commits

Reviewing files that changed from the base of the PR and between 90b3cf1 and 7ee8f85.

📒 Files selected for processing (5)
  • README.md
  • docs/UPDATE.md
  • internal/cli/app_test.go
  • internal/cli/update.go
  • internal/update/update_test.go

Comment thread internal/cli/update.go
@gnanam1990

Copy link
Copy Markdown
Collaborator

Review: PR #96 — feat(update): expose release check target options (anandh8x / Anandan)

URL: #96
State: OPEN (reviewDecision: REVIEW_REQUIRED)
Author: anandh8x (Anandan)
Branch: feat/update-check-options
Review Date: current
Reviewer context: gnanam1990 (runtime core owner per WORK_SPLIT_PRD.md)

Ownership Fit (WORK_SPLIT_PRD v3)

Strong match for Anandan's platform product owner lane:

  • "zero update verification, release metadata validation"
  • "Install/update/release trust, binary/package smoke tests, ... CI as product verification, performance and release checks"
  • Platform/release contract DRI
  • "Anandan: feat/update-release-verification"

This PR adds --repo, --endpoint, and --timeout flags to zero update --check, passes them through to the update checker, adds tests for passthrough/invalid values/help/endpoint precedence, and updates docs.

Clean boundary with runtime (Gnanam's areas):
No changes to agent, permissions, sessions, providers, stream-json, config, zerocommands, etc. Purely touches CLI surface for update (platform lane) + internal/update (which Anandan owns). The large diff stats in some views are cumulative from the branch (includes prior merged work like #82/#88 etc.); the actual PR diff is small and isolated to update + CLI update command + docs.

Fits "every PR must expose user-runnable behavior" (enhanced zero update --check with more control) and "For Anandan's PRs: user-runnable command behavior + release artifact verification."

Summary of Change

  • CLI: internal/cli/update.go — parse new flags (--repo, --endpoint, --timeout), pass update.Options with them to deps.checkUpdate.
  • Update logic: internal/update/update_test.go — new tests for Check with custom repo/endpoint/timeout, invalid timeout rejection, data: URL endpoints, asset checks, etc.
  • App tests: internal/cli/app_test.go — coverage for new flag parsing and runUpdate paths.
  • Docs: docs/UPDATE.md (expanded with flag/env/default precedence, examples, timeout guidance), small README tweak.
  • PR notes coordination: explicitly in update/release lane, no overlap with runtime permission work (feat: add runtime permission decisions #95).

Validation per PR:

  • Targeted Go tests (./internal/update ./internal/cli -run 'TestCheck|TestResolveEndpoint|TestRunUpdate')
  • Full go test ./...
  • Build + manual ./zero update --check --endpoint ... --timeout=... --json
  • git diff --check

CodeRabbit: APPROVED.

Code Quality & Tests

Positive:

  • Clean, minimal extension of existing update check flow. Flags are passed through without duplicating logic.
  • Good test coverage for new paths: endpoint resolution precedence (CLI > env > default), invalid/negative timeout rejection, data: URLs, missing assets, etc.
  • Docs updated with clear precedence table and examples — improves usability for release verification (Anandan's lane).
  • No new runtime surface or contracts touched.
  • Error handling and help text extended appropriately.
  • Fits the "platform adapter behavior" and "release metadata validation" goals.

Minor observations (not blocking):

  • The update checker itself (internal/update) already had good coverage for the core Check logic; this PR mostly adds CLI wiring + more negative/edge cases.
  • Timeout default (5s) and behavior documented — good.
  • One small thing in docs: the "M2 this command is intentionally check-only" note could be refreshed if M2 is complete, but not a PR blocker.
  • No impact on shared contracts (Gnanam-owned stream events, permissions, sessions, etc.).

Tests from PR validation pass locally. Full ./... green in the run. The new flags are exercised in both text and JSON output paths.

Alignment with PRD / WORK_SPLIT / DoD

  • Release trust & Distribution (P0/P1): Directly enhances "zero update verification" and "release metadata validation". Makes the check command more flexible for different repos/endpoints (useful for forks, testing, CI).
  • Anandan's lane: Matches "update verification", "release artifact verification", "CI that proves real installed Zero commands", "user-runnable command behavior". Produces enhanced CLI + tests + docs.
  • DoD for code PRs / Anandan's PRs: Adds/updates tests, runs go test ./..., package smoke/release checks (via the update flow), includes manual CLI output in validation. Not docs-only.
  • Continues platform cleanup (pairs with prior Anandan work like Verify update release assets #84 update verification, Replace npm wrapper with Node entrypoint #88 Node wrapper, Remove Bun installer test dependency #91 remove Bun installer tests, etc.).
  • No change to runtime contracts or Gnanam-owned areas.

Recommendation

Approve.

This is exactly the kind of platform/release verification work Anandan is supposed to own. Small, targeted, well-tested enhancement to zero update --check with clear docs and no runtime impact. CodeRabbit approved; tests pass; fits the split and DoD perfectly.

Minor future polish (not for this PR):

  • Consider whether --repo/--endpoint should also affect other release-related commands (e.g. in review automation) — but that's out of scope here.
  • The precedence documentation is a nice addition.

Great incremental improvement to release trust tooling.

(Previous Anandan platform reviews followed the same positive pattern: lane fit, boundary notes, tests/DoD check, approve rec.)


Review generated per user's request for PR 96.
Local copy: reviews/pr-96-anandan-update-check-options.md
Posted as GitHub comment + formal review action.
EOF
echo "Local review file created."

@gnanam1990 gnanam1990 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.

Formal approval following detailed review.

This is clean, targeted platform/release verification work for Anandan's lane per WORK_SPLIT_PRD v3:

  • Adds --repo/--endpoint/--timeout to zero update --check.
  • Passes through to update checker with good tests for passthrough, invalid values, precedence, help.
  • Updates docs with clear flag/env/default guidance.
  • Fits 'update verification' and 'release metadata validation' exactly.
  • Delivers user-runnable behavior + tests + smoke verification.
  • No runtime contract impact (Gnanam areas untouched).

CodeRabbit approved; tests pass locally; validation steps succeed.

LGTM. Approving.

See detailed comment for full ownership fit, code notes, and minor suggestions: #96 (comment)...

@anandh8x
anandh8x merged commit 3e4add9 into main Jun 6, 2026
6 checks passed
@Vasanthdev2004
Vasanthdev2004 deleted the feat/update-check-options 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