Skip to content

Atomic agent work selection, dependency integrity, and recovery primitives - #502

Merged
unbraind merged 3 commits into
mainfrom
agent/atomic-work-selection-and-recovery
Jul 10, 2026
Merged

unbraind merged 3 commits into
mainfrom
agent/atomic-work-selection-and-recovery

Conversation

@unbraind

@unbraind unbraind commented Jul 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add SDK-backed pm claim --next with bounded atomic conflict retries and --if-available
  • make pm next caller-aware, remove recommendation duplication, and preserve lifecycle/dangling blockers
  • validate dangling parent/blocker/dependency references with actionable remediation
  • make recovery suggestions arity-aware and accept token-efficient comments --body / --comment aliases
  • update completions, contracts, SDK context evaluation, docs, generated changelog, and Sentry expected-handled telemetry classification

PM lineage

Closes pm-114v, pm-l0bu, pm-yl6c, pm-hfg5, pm-ol5v, pm-6y58, pm-z32q, and regression follow-up pm-w7jq.

Verification

  • pnpm release:gates through build, typecheck, static/docstring ratchets, docs, context evaluation, security, 100/100/100/100 coverage, packed smoke, and 88-command package dogfood
  • 5,524 tests at 100% statements/branches/functions/lines
  • isolated installed-tarball acceptance: init, create, atomic claim-next, comments body alias, dangling-reference validation, SDK import
  • live Sentry/telemetry: zero blocking critical/high issues, 0.34% finish error rate, zero failures missing error codes
  • pm health --check-only --summary: all checks green; history drift zero across 1,709 items
  • pnpm changelog:pm:check

The committed Greptile gate identified an invalid synthetic dependency kind in one test; follow-up commit 4ed719c0 corrects it and proves two distinct dangling references are retained.


Summary by cubic

Adds atomic work selection for agents and hardens dependency integrity across recommendation, claim, and validate. pm claim --next now atomically selects and claims the next caller-available item; pm next is caller-aware, non-duplicating, and treats dangling references as blockers.

  • New Features

    • pm claim --next: atomic recommend+claim with bounded retries. Honors --if-available across candidates, aligns --author with ranking, enforces id/--next XOR, and returns the recommendation + attempt count; zsh completions wired.
    • pm next: excludes the recommended item from ready, reports foreign-owned work in held_by_others, and uses the same ranking data the SDK exposes.
  • Bug Fixes

    • Validation: new dependency_references check warns on dangling parent, blocked_by, and dependency ids with clear, parent-specific remediation; actionability and pm next treat them as unresolved blockers (no silent unblocks).
    • Recovery/UX: suggested retry is arity-aware (boolean flags render without a placeholder). pm comments accepts hidden --body and --comment aliases for --add; completions, contracts, and docs updated.
    • Recommendation: fixed pm next blocked summary and companion so counts and rows reflect lifecycle and dependency state.
    • Telemetry: Sentry gate now classifies starter search/context tracker-initialization errors as expected handled.

Written for commit 378dc96. Summary will update on new commits.

Review in cubic

unbraind added 2 commits July 10, 2026 22:33
Add SDK-backed claim --next with bounded ownership-conflict retries, caller-aware and non-duplicating next recommendations, truthful lifecycle and dangling-dependency blocking, and validation remediation.

Improve recovery flag arity, comments body aliases, completions, contracts, context evaluation, docs, Sentry expected-handled classification, tracker evidence, and generated changelog. Verified with strict 100/100/100/100 coverage, packed smoke, package dogfood, isolated installed-tarball acceptance, security gates, and live telemetry.
Replace an unsupported synthetic dependency kind with a valid blocked_by edge and assert both independent dangling rows. Record and close the Greptile follow-up in pm and regenerate the package-owned changelog.
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@unbraind

Copy link
Copy Markdown
Owner Author

@greptileai please review the current head

/gemini review

@coderabbitai full review

@sourcery-ai sourcery-ai 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.

Sorry @unbraind, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

@unbraind: Sure, I'll do a full review of the current head of this PR.

✅ Action performed

Full review finished.


Your plan includes PR reviews subject to rate limits. More reviews will be available in 59 minutes.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@unbraind, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 39 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: a546b033-73e5-43aa-a975-cb3461433d98

📥 Commits

Reviewing files that changed from the base of the PR and between 0f43e92 and 378dc96.

📒 Files selected for processing (46)
  • .agents/pm/extensions/.managed-extensions.json
  • .agents/pm/features/pm-114v.toon
  • .agents/pm/history/pm-114v.jsonl
  • .agents/pm/history/pm-69nl.jsonl
  • .agents/pm/history/pm-6y58.jsonl
  • .agents/pm/history/pm-hfg5.jsonl
  • .agents/pm/history/pm-l0bu.jsonl
  • .agents/pm/history/pm-ol5v.jsonl
  • .agents/pm/history/pm-w7jq.jsonl
  • .agents/pm/history/pm-yl6c.jsonl
  • .agents/pm/history/pm-z32q.jsonl
  • .agents/pm/issues/pm-69nl.toon
  • .agents/pm/issues/pm-6y58.toon
  • .agents/pm/issues/pm-hfg5.toon
  • .agents/pm/issues/pm-l0bu.toon
  • .agents/pm/issues/pm-ol5v.toon
  • .agents/pm/issues/pm-w7jq.toon
  • .agents/pm/issues/pm-yl6c.toon
  • .agents/pm/issues/pm-z32q.toon
  • CHANGELOG.md
  • docs/COMMANDS.md
  • docs/SDK.md
  • scripts/release/sentry-telemetry-gate.mjs
  • src/cli/commands/claim.ts
  • src/cli/commands/completion.ts
  • src/cli/commands/next.ts
  • src/cli/commands/validate.ts
  • src/cli/main.ts
  • src/cli/register-mutation.ts
  • src/cli/register-operations.ts
  • src/core/item/actionability.ts
  • src/sdk/cli-contracts/flag-contracts.ts
  • src/sdk/context-relevance.ts
  • tests/fixtures/contracts/full.json
  • tests/integration/help-runtime.spec.ts
  • tests/unit/cli/cli-main-errors.spec.ts
  • tests/unit/commands/claim-command.spec.ts
  • tests/unit/commands/comments-command.spec.ts
  • tests/unit/commands/completion-command.spec.ts
  • tests/unit/commands/context-relevance-command.spec.ts
  • tests/unit/commands/next-command.spec.ts
  • tests/unit/commands/register-commands.spec.ts
  • tests/unit/commands/validate-command.spec.ts
  • tests/unit/core/item/actionability.spec.ts
  • tests/unit/scripts/release/sentry-telemetry-gate.spec.ts
  • tests/unit/sdk/context-relevance.spec.ts
📝 Walkthrough

Walkthrough

This PR adds atomic pm claim --next selection, caller-aware pm next projections, dangling-dependency validation, hidden comment aliases, arity-aware recovery suggestions, updated shell contracts, and expanded telemetry classification and documentation.

Changes

CLI work selection and reliability

Layer / File(s) Summary
Dependency validation and actionability
src/core/item/actionability.ts, src/cli/commands/validate.ts, tests/unit/core/*, tests/unit/commands/validate-command.spec.ts
Unknown dependency references and blocked lifecycle states remain blocked, while validation reports structured dangling-reference diagnostics and remediation hints.
Caller-aware next projections
src/cli/commands/next.ts, src/sdk/context-relevance.ts, tests/unit/commands/next-command.spec.ts, docs/COMMANDS.md, docs/SDK.md
pm next separates foreign-owned work into held_by_others, excludes the recommendation from ready, and includes recommended in ranking payloads.
Atomic claim-next flow
src/cli/commands/claim.ts, src/cli/register-operations.ts, src/sdk/cli-contracts/*, tests/unit/commands/claim-command.spec.ts
pm claim --next attempts ranked candidates sequentially, retries already_claimed_by conflicts, and supports --if-available and --next.
CLI aliases and recovery suggestions
src/cli/main.ts, src/cli/register-mutation.ts, src/cli/commands/completion.ts, tests/unit/cli/*, tests/unit/commands/comments-command.spec.ts
Hidden --body and --comment aliases map to comment addition, completions expose supported flags, and retry suggestions distinguish boolean options from value-taking options.
Telemetry and release updates
scripts/release/sentry-telemetry-gate.mjs, tests/unit/scripts/release/*, CHANGELOG.md, .agents/pm/*
Starter wrapper failures are classified as expected handled CLI errors, changelog entries are consolidated under Unreleased, and related tracking records are updated.
Estimated code review effort: 4 (Complex) ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant pmClaimNext
  participant pmNext
  participant ClaimMutation
  Caller->>pmClaimNext: invoke claim --next
  pmClaimNext->>pmNext: fetch ranked available work
  pmNext-->>pmClaimNext: recommended and ready candidates
  pmClaimNext->>ClaimMutation: atomically claim candidate
  ClaimMutation-->>pmClaimNext: success or conflict
  pmClaimNext-->>Caller: claimed result or exhaustion error
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 53.57% 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
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.
Title check ✅ Passed The title concisely summarizes the main changes: atomic work selection, dependency validation, and recovery improvements.
Description check ✅ Passed The description is clearly aligned with the changeset and accurately covers the major features, fixes, and verification work.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@greptile-apps

greptile-apps Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR adds atomic next-work claiming and hardens dependency-aware work selection. The main changes are:

  • Adds pm claim --next with bounded conflict retries and --if-available behavior.
  • Makes pm next caller-aware, removes duplicate recommendation rows, and reports held work.
  • Treats dangling parent, blocker, and dependency references as validation warnings and unresolved blockers.
  • Updates recovery suggestions, comment aliases, completions, contracts, docs, tests, and telemetry classification.

Confidence Score: 4/5

Mostly safe, with one contained bug in caller-aware next-work ranking.

The main flows are implemented and covered, but explicit --author is not used by relevance scoring, which can produce the wrong claim-next recommendation.

src/cli/commands/next.ts

T-Rex T-Rex Logs

What T-Rex did

  • The team examined the relevance verification path in the Next CLI and confirmed that src/cli/commands/next.ts:371 passes process.env.PM_AUTHOR while runClaimNext passes the explicit author as callerAuthor into runNext, but a runnable repro could not be produced because maximum steps for this agent were reached.
  • The atomic-claim installed artifact bundle was reviewed to validate the CLI contract and install flow, referencing the pack install log and subsequent after-run artifacts.
  • CLI contract discovery was verified by inspecting help outputs and the update-deps help transcript, confirming the command surface and dependency handling appeared as expected.
  • Dangling dependency validation transcripts and fixture snapshots were reviewed to ensure validation coverage and reproducibility of the install flow.
  • The collected artifacts include the pack install log, after-run logs, wrapper log, help outputs, and a continued transcript, which collectively enable runtime inspection of the claim flow.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
src/cli/commands/claim.ts Adds atomic claim-next orchestration with conflict retries and if-available exhaustion handling.
src/cli/commands/next.ts Makes next caller-aware and token-efficient, but relevance scoring still ignores the explicit caller author for author-affinity ranking.
src/core/item/actionability.ts Centralizes dependency-aware readiness and dangling blocker handling.
src/cli/commands/validate.ts Adds dangling parent, blocker, and dependency reference diagnostics with remediation hints.
src/cli/main.ts Updates recovery suggestion rendering to account for option arity.
src/cli/register-operations.ts Wires claim-next target validation and lifecycle options.
scripts/release/sentry-telemetry-gate.mjs Classifies additional expected handled telemetry failures.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
  participant Agent
  participant Claim as pm claim --next
  participant Next as runNext
  participant Action as computeActionabilityReport
  participant Store as mutateItem

  Agent->>Claim: pm claim --next --author A
  Claim->>Next: rank candidates (callerAuthor A)
  Next->>Action: classify ready/blocked with full corpus
  Action-->>Next: ready, blocked, open blockers
  Next-->>Claim: recommended + ready tail
  loop ranked candidates
    Claim->>Store: atomic claim candidate
    alt candidate free or owned by A
      Store-->>Claim: claimed item
      Claim-->>Agent: recommendation + attempts
    else already claimed by another agent
      Store-->>Claim: already_claimed_by
      Claim->>Claim: try next ranked candidate
    end
  end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
  participant Agent
  participant Claim as pm claim --next
  participant Next as runNext
  participant Action as computeActionabilityReport
  participant Store as mutateItem

  Agent->>Claim: pm claim --next --author A
  Claim->>Next: rank candidates (callerAuthor A)
  Next->>Action: classify ready/blocked with full corpus
  Action-->>Next: ready, blocked, open blockers
  Next-->>Claim: recommended + ready tail
  loop ranked candidates
    Claim->>Store: atomic claim candidate
    alt candidate free or owned by A
      Store-->>Claim: claimed item
      Claim-->>Agent: recommendation + attempts
    else already claimed by another agent
      Store-->>Claim: already_claimed_by
      Claim->>Claim: try next ranked candidate
    end
  end
Loading

Comments Outside Diff (1)

  1. src/cli/commands/next.ts, line 371 (link)

    P1 Use caller for relevance
    pm next partitions ready work with options.callerAuthor, but the relevance pass still scores author_affinity with process.env.PM_AUTHOR. When pm claim --next --author agent-b runs without that env var, open work already assigned to agent-b loses its owner boost and can be ranked behind unrelated items, so selection and mutation are not fully caller-aware. Pass the same resolved caller into buildItemContextRelevanceCandidates here.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: src/cli/commands/next.ts
    Line: 371
    
    Comment:
    **Use caller for relevance**
    `pm next` partitions ready work with `options.callerAuthor`, but the relevance pass still scores `author_affinity` with `process.env.PM_AUTHOR`. When `pm claim --next --author agent-b` runs without that env var, open work already assigned to `agent-b` loses its owner boost and can be ranked behind unrelated items, so selection and mutation are not fully caller-aware. Pass the same resolved caller into `buildItemContextRelevanceCandidates` here.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
src/cli/commands/next.ts:371
**Use caller for relevance**
`pm next` partitions ready work with `options.callerAuthor`, but the relevance pass still scores `author_affinity` with `process.env.PM_AUTHOR`. When `pm claim --next --author agent-b` runs without that env var, open work already assigned to `agent-b` loses its owner boost and can be ranked behind unrelated items, so selection and mutation are not fully caller-aware. Pass the same resolved caller into `buildItemContextRelevanceCandidates` here.

Reviews (3): Last reviewed commit: "fix(claim): honor atomic selection contr..." | Re-trigger Greptile

Comment thread src/cli/commands/claim.ts Resolved
Comment thread src/cli/commands/validate.ts Resolved
@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds atomic work selection and related recovery improvements for pm agents. The main changes are:

  • Adds SDK-backed pm claim --next with conflict retries.
  • Makes pm next caller-aware and removes duplicated recommendation output.
  • Adds validation for dangling parent, blocker, and dependency references.
  • Updates recovery retry rendering, comments aliases, completions, contracts, SDK evaluation, docs, changelog, and Sentry telemetry classification.

Confidence Score: 4/5

Mostly safe after fixing the claim-next author mismatch.

One contained bug affects the new pm claim --next --author path. Other reviewed changes are localized and have matching tests or contract updates.

src/cli/commands/claim.ts

T-Rex T-Rex Logs

What T-Rex did

  • T-Rex reviewed the forward-claim verification and determined that no real runtime repro was executed before the agent step limit was reached, so the result is blocked.
  • T-Rex ran the requested verification, but local artifact references were not uploaded.

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
src/cli/commands/claim.ts Adds atomic claim-next composition, but selection uses default/env author rather than the explicit claim author.
src/cli/commands/next.ts Refactors pm next into caller-aware ranked ready/blocked output and removes recommended duplication.
src/core/item/actionability.ts Centralizes dependency-aware ready/blocked classification, including blocked status handling and dangling blocker behavior.
src/cli/main.ts Makes recovery suggested_retry rendering respect boolean flag arity.
src/cli/commands/validate.ts Adds dependency reference validation for dangling parent, blocker, and dependency references with remediation hints.
src/cli/register-operations.ts Wires claim --next/--if-available and related operation option forwarding.
src/sdk/context-relevance.ts Extends context ranking evaluation to include next results and token-budget metrics.
scripts/release/sentry-telemetry-gate.mjs Broadens expected-handled Sentry telemetry classification for known CLI/package smoke failures.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
  participant Agent
  participant CLI as pm claim --next
  participant Next as runNext
  participant Store as Item store
  participant Claim as runClaim

  Agent->>CLI: pm claim --next [--author]
  CLI->>Next: rank actionable candidates
  Next->>Store: read candidates + full corpus
  Store-->>Next: items
  Next-->>CLI: recommended + ready tail
  loop bounded ranked candidates
    CLI->>Claim: claim(candidate)
    Claim->>Store: atomic mutateItem test-and-set
    alt candidate available
      Store-->>Claim: assignee updated
      Claim-->>CLI: ClaimNextResult
      CLI-->>Agent: claimed item + recommendation evidence
    else already claimed by other agent
      Store-->>Claim: already_claimed_by conflict
      Claim-->>CLI: retry next candidate
    end
  end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
  participant Agent
  participant CLI as pm claim --next
  participant Next as runNext
  participant Store as Item store
  participant Claim as runClaim

  Agent->>CLI: pm claim --next [--author]
  CLI->>Next: rank actionable candidates
  Next->>Store: read candidates + full corpus
  Store-->>Next: items
  Next-->>CLI: recommended + ready tail
  loop bounded ranked candidates
    CLI->>Claim: claim(candidate)
    Claim->>Store: atomic mutateItem test-and-set
    alt candidate available
      Store-->>Claim: assignee updated
      Claim-->>CLI: ClaimNextResult
      CLI-->>Agent: claimed item + recommendation evidence
    else already claimed by other agent
      Store-->>Claim: already_claimed_by conflict
      Claim-->>CLI: retry next candidate
    end
  end
Loading
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
src/cli/commands/claim.ts:162-166
**Forward claim author**
`runClaimNext` ranks candidates with `runNext` before claiming, but `runNext` derives the caller from `PM_AUTHOR` or the tracker default instead of `options.author`. When `pm claim --next --author agent-b` runs in a tracker whose default author is `agent-a`, it ranks work as `agent-a` and then claims as `agent-b`, so `agent-b` can miss its own held work and retry against items held by `agent-a`. Pass the effective claim author into selection so ranking and mutation use the same caller.

Reviews (1): Last reviewed commit: "test(validate): prove multiple dangling ..." | Re-trigger Greptile

Comment thread src/cli/commands/claim.ts Resolved

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/cli/commands/completion.ts (1)

953-977: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

--if-available/--next added to the wrong zsh subcommand.

Lines 973-974 insert --if-available and --next into the zsh update) case, but these are claim-only flags (per the fish script's correct placement at lines 2413-2414, and per register-operations.ts where only claim gets --if-available/--next). The zsh claim) case (lines 1508-1515) is unchanged and still lacks these flags, so zsh users get no completion for pm claim --next/--if-available, while pm update zsh completion now incorrectly advertises flags it doesn't support.

🐛 Proposed fix: move flags to the `claim)` case
             '--allow-audit-update[Allow non-owner metadata-only audit updates without requiring --force]' \\
             '--author[Mutation author]:author' \\
             '--message[History message]:message' \\
             '--force[Force override]' \\
-            '--if-available[Skip work held by another author]' \\
-            '--next[Atomically claim the next actionable item]' \\
             '--json[Output JSON]' \\
             '--quiet[Suppress stdout]'
           ;;
         update-many)
         claim)
           _arguments \\
             '--author[Mutation author]:author' \\
             '--message[History message]:message' \\
             '--force[Force override]' \\
+            '--if-available[Skip work held by another author]' \\
+            '--next[Atomically claim the next actionable item]' \\
             '--json[Output JSON]' \\
             '--quiet[Suppress stdout]'
           ;;

Also applies to: 1508-1515

🤖 Prompt for 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.

In `@src/cli/commands/completion.ts` around lines 953 - 977, Move the
--if-available and --next completion entries out of the zsh update) case and add
them to the zsh claim) case. Keep update aligned with the flags registered by
register-operations.ts, ensuring claim supports completion for both claim-only
options.
🤖 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 `@src/cli/commands/validate.ts`:
- Around line 1229-1247: Remediation hints in the dependency reference
validation must account for dangling references with kind "parent"; update the
hint construction near uniqueRows and summarizeList so parent rows suggest the
appropriate parent-field repair command, while dependency rows retain the
--replace-deps guidance. Ensure the generated hints use each row’s parsed kind
and identifier consistently.

In `@src/cli/register-operations.ts`:
- Around line 398-419: Update requireClaimTarget to enforce a true XOR: throw a
usage PmCliError when both an id and next are provided, while retaining the
existing error when neither is provided. Ensure runClaimAction validates before
dispatch, and add coverage for requireClaimTarget("pm-a", true) plus the
existing invalid case.

---

Outside diff comments:
In `@src/cli/commands/completion.ts`:
- Around line 953-977: Move the --if-available and --next completion entries out
of the zsh update) case and add them to the zsh claim) case. Keep update aligned
with the flags registered by register-operations.ts, ensuring claim supports
completion for both claim-only options.
🪄 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: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: e6f7fab4-331f-4295-93e6-a6913c89974f

📥 Commits

Reviewing files that changed from the base of the PR and between 0f43e92 and 4ed719c.

📒 Files selected for processing (46)
  • .agents/pm/extensions/.managed-extensions.json
  • .agents/pm/features/pm-114v.toon
  • .agents/pm/history/pm-114v.jsonl
  • .agents/pm/history/pm-69nl.jsonl
  • .agents/pm/history/pm-6y58.jsonl
  • .agents/pm/history/pm-hfg5.jsonl
  • .agents/pm/history/pm-l0bu.jsonl
  • .agents/pm/history/pm-ol5v.jsonl
  • .agents/pm/history/pm-w7jq.jsonl
  • .agents/pm/history/pm-yl6c.jsonl
  • .agents/pm/history/pm-z32q.jsonl
  • .agents/pm/issues/pm-69nl.toon
  • .agents/pm/issues/pm-6y58.toon
  • .agents/pm/issues/pm-hfg5.toon
  • .agents/pm/issues/pm-l0bu.toon
  • .agents/pm/issues/pm-ol5v.toon
  • .agents/pm/issues/pm-w7jq.toon
  • .agents/pm/issues/pm-yl6c.toon
  • .agents/pm/issues/pm-z32q.toon
  • CHANGELOG.md
  • docs/COMMANDS.md
  • docs/SDK.md
  • scripts/release/sentry-telemetry-gate.mjs
  • src/cli/commands/claim.ts
  • src/cli/commands/completion.ts
  • src/cli/commands/next.ts
  • src/cli/commands/validate.ts
  • src/cli/main.ts
  • src/cli/register-mutation.ts
  • src/cli/register-operations.ts
  • src/core/item/actionability.ts
  • src/sdk/cli-contracts/flag-contracts.ts
  • src/sdk/context-relevance.ts
  • tests/fixtures/contracts/full.json
  • tests/integration/help-runtime.spec.ts
  • tests/unit/cli/cli-main-errors.spec.ts
  • tests/unit/commands/claim-command.spec.ts
  • tests/unit/commands/comments-command.spec.ts
  • tests/unit/commands/completion-command.spec.ts
  • tests/unit/commands/context-relevance-command.spec.ts
  • tests/unit/commands/next-command.spec.ts
  • tests/unit/commands/register-commands.spec.ts
  • tests/unit/commands/validate-command.spec.ts
  • tests/unit/core/item/actionability.spec.ts
  • tests/unit/scripts/release/sentry-telemetry-gate.spec.ts
  • tests/unit/sdk/context-relevance.spec.ts

Comment thread src/cli/commands/validate.ts Resolved
Comment thread src/cli/register-operations.ts Resolved
@codecov

codecov Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Preserve if-available semantics across ranked candidates, align explicit claim authors with next-work ranking, enforce claim target XOR, place zsh flags on claim, and emit parent-specific dependency remediation. Add focused regressions and record review evidence in pm.
@unbraind

Copy link
Copy Markdown
Owner Author

Review follow-up on current head 378dc961:

  • Greptile P1 --if-available: fixed with skip advancement and all-held non-failing behavior.
  • Greptile P1 explicit --author: fixed by aligning next ranking and claim mutation identity.
  • Greptile/CodeRabbit parent remediation: fixed with --unset parent.
  • CodeRabbit XOR: fixed; id plus --next is rejected.
  • CodeRabbit zsh completion: fixed; flags moved from update to claim.
  • Full coverage: 100/100/100/100, 5,528 tests.

The generic dependency trigger suggestion is not applicable: the CLI has no generic --check <name> option; dependency_references is intentionally the named companion result of --check-lifecycle, as documented. Gemini and CodeRabbit quota notices were acknowledged; actionable CodeRabbit findings from the completed pass were implemented.

@unbraind

Copy link
Copy Markdown
Owner Author

@greptileai please review the current head 378dc961

/gemini review

@coderabbitai full review

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

@unbraind: Sure, I'll do a full review of the current head (378dc96) of this PR.

✅ Action performed

Full review finished.


Your plan includes PR reviews subject to rate limits. More reviews will be available in 39 minutes.

@unbraind

Copy link
Copy Markdown
Owner Author

Final review audit on head 378dc961:

  • all 5 inline review threads are resolved; each received an evidence reply and reaction
  • Greptile current-head check is green; its older summary text predates the explicit-author fix, which is now exercised by uses the explicit claim author for next-work ownership ranking
  • CodeRabbit current-head status is green/rate-limited after its earlier actionable findings were fixed
  • Gemini replied with quota exhaustion; no findings were available
  • every GitHub runner and security/quality integration is complete and green, including 100% coverage, Windows, CodeQL, Trivy, Semgrep, CodeFactor, Codecov, docs, static, typecheck, compatibility, and smokes

No unresolved review thread or current-head check remains.

@unbraind

unbraind commented Aug 4, 2026

Copy link
Copy Markdown
Owner Author

Tracked in PM: pm-114v, pm-6y58, pm-hfg5, pm-l0bu, pm-ol5v, pm-w7jq, pm-yl6c, pm-z32q.

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.

1 participant