Repository navigation
Atomic agent work selection, dependency integrity, and recovery primitives - #502
Conversation
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.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
@greptileai please review the current head /gemini review @coderabbitai full review |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 59 minutes. |
|
Warning Review limit reached
Next review available in: 39 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (46)
📝 WalkthroughWalkthroughThis PR adds atomic ChangesCLI work selection and reliability
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
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
Greptile SummaryThis PR adds atomic next-work claiming and hardens dependency-aware work selection. The main changes are:
Confidence Score: 4/5Mostly safe, with one contained bug in caller-aware next-work ranking. The main flows are implemented and covered, but explicit src/cli/commands/next.ts
What T-Rex did
Important Files Changed
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
%%{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
|
Greptile SummaryThis PR adds atomic work selection and related recovery improvements for
Confidence Score: 4/5Mostly safe after fixing the claim-next author mismatch. One contained bug affects the new
What T-Rex did
Important Files Changed
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
%%{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
Prompt To Fix All With AIFix 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 |
There was a problem hiding this comment.
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/--nextadded to the wrong zsh subcommand.Lines 973-974 insert
--if-availableand--nextinto the zshupdate)case, but these areclaim-only flags (per the fish script's correct placement at lines 2413-2414, and perregister-operations.tswhere onlyclaimgets--if-available/--next). The zshclaim)case (lines 1508-1515) is unchanged and still lacks these flags, so zsh users get no completion forpm claim --next/--if-available, whilepm updatezsh 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
📒 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.toonCHANGELOG.mddocs/COMMANDS.mddocs/SDK.mdscripts/release/sentry-telemetry-gate.mjssrc/cli/commands/claim.tssrc/cli/commands/completion.tssrc/cli/commands/next.tssrc/cli/commands/validate.tssrc/cli/main.tssrc/cli/register-mutation.tssrc/cli/register-operations.tssrc/core/item/actionability.tssrc/sdk/cli-contracts/flag-contracts.tssrc/sdk/context-relevance.tstests/fixtures/contracts/full.jsontests/integration/help-runtime.spec.tstests/unit/cli/cli-main-errors.spec.tstests/unit/commands/claim-command.spec.tstests/unit/commands/comments-command.spec.tstests/unit/commands/completion-command.spec.tstests/unit/commands/context-relevance-command.spec.tstests/unit/commands/next-command.spec.tstests/unit/commands/register-commands.spec.tstests/unit/commands/validate-command.spec.tstests/unit/core/item/actionability.spec.tstests/unit/scripts/release/sentry-telemetry-gate.spec.tstests/unit/sdk/context-relevance.spec.ts
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 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.
|
Review follow-up on current head
The generic dependency trigger suggestion is not applicable: the CLI has no generic |
|
@greptileai please review the current head /gemini review @coderabbitai full review |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 39 minutes. |
|
Final review audit on head
No unresolved review thread or current-head check remains. |
Summary
pm claim --nextwith bounded atomic conflict retries and--if-availablepm nextcaller-aware, remove recommendation duplication, and preserve lifecycle/dangling blockerscomments --body/--commentaliasesPM 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:gatesthrough build, typecheck, static/docstring ratchets, docs, context evaluation, security, 100/100/100/100 coverage, packed smoke, and 88-command package dogfoodpm health --check-only --summary: all checks green; history drift zero across 1,709 itemspnpm changelog:pm:checkThe committed Greptile gate identified an invalid synthetic dependency kind in one test; follow-up commit
4ed719c0corrects 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 --nextnow atomically selects and claims the next caller-available item;pm nextis caller-aware, non-duplicating, and treats dangling references as blockers.New Features
pm claim --next: atomic recommend+claim with bounded retries. Honors--if-availableacross candidates, aligns--authorwith ranking, enforces id/--nextXOR, and returns the recommendation + attempt count; zsh completions wired.pm next: excludes the recommended item fromready, reports foreign-owned work inheld_by_others, and uses the same ranking data the SDK exposes.Bug Fixes
dependency_referencescheck warns on danglingparent,blocked_by, and dependency ids with clear, parent-specific remediation; actionability andpm nexttreat them as unresolved blockers (no silent unblocks).pm commentsaccepts hidden--bodyand--commentaliases for--add; completions, contracts, and docs updated.pm nextblocked summary and companion so counts and rows reflect lifecycle and dependency state.Written for commit 378dc96. Summary will update on new commits.