Skip to content

Refactor update mutation complexity - #413

Merged
unbraind merged 9 commits into
mainfrom
codefactor-update-register-mutation-complexity
Jul 1, 2026
Merged

unbraind merged 9 commits into
mainfrom
codefactor-update-register-mutation-complexity

Conversation

@unbraind

@unbraind unbraind commented Jul 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Linked pm item: pm-0n6p under pm-92if.

This PR finishes the CodeFactor complexity remediation for the item-mutation path:

  • Decomposes runUpdate and its update mutation callback in src/cli/commands/update.ts into focused helpers while preserving update routing, close-status routing, dependency/test/doc/file mutations, runtime fields, and changed-field behavior.
  • Decomposes large mutation registration action closures in src/cli/register-mutation.ts into named action helpers.
  • Removes the target complexity suppressions from eslint-suppressions.json.
  • Adds register-command coverage for repeatable schema role/alias handling and defensive programmatic string coercion.
  • Records implementation, verification, and Greptile evidence on pm-0n6p through the pm CLI.

Verification

  • npm install -g .
  • pm --version -> 2026.6.30
  • node -v -> v26.4.0
  • pnpm -v -> 10.33.4
  • pnpm build
  • unsuppressed ESLint for changed code/test files
  • pnpm typecheck
  • node scripts/run-tests.mjs test -- tests/unit/commands/update-command.spec.ts tests/unit/commands/register-commands.spec.ts -> 175 tests passed
  • node scripts/run-tests.mjs coverage -> 262 files / 5265 tests, 100% statements / branches / functions / lines
  • linked pm test pm-0n6p --run --progress --pm-context tracker --override-linked-pm-context -> coverage, focused tests, contracts, lint all passed
  • pnpm contracts:check
  • pnpm lint -> ESLint, jscpd, static quality gate passed
  • pnpm changelog:pm:check -> latest pm-changelog generated no CHANGELOG.md change
  • pnpm exec node scripts/check-secrets.mjs -> no credential-like secrets in tracked files
  • pnpm audit --audit-level moderate -> no known vulnerabilities
  • pm health --check-only --summary --json -> ok
  • pm validate --check-resolution --check-history-drift --check-command-references --strict-exit --json -> ok with pre-existing resolution metadata warnings; command references and history drift clean
  • git diff --check

Manual Smoke

Installed-package smoke in an isolated temp project (/tmp/tmp.3bglbDFU7O):

  • pm init --defaults --author manual-smoke
  • pm schema add-status review --role active --role blocked --alias in_review --alias needs_review --order 20
  • pm schema add-type Spike --description "Manual smoke investigation" --folder spikes --default-status open --alias Investigation
  • pm schema add-field severity_level --type string --commands create,update,list --alias severity --required-types Spike
  • created and updated a Spike item using runtime schema flags, then verified pm get, pm list, and pm health

Final smoke assertion: custom Spike item reached review, severity_level=high, tags codefactor,sdk, list count 1, health ok.

GitHub / Release / Telemetry Sweep

  • No open PRs before this one.
  • No open GitHub issues.
  • No open Dependabot alerts.
  • No open code scanning alerts.
  • Latest scheduled Auto Release run checked: success on 2026-07-01T06:52:39Z for main b2617dac.
  • npm view @unbrained/pm-cli version returned 2026.7.1 during the sweep.
  • Sentry issue list reachable; sampled unresolved PM-CLI-16 and PM-CLI-1Q were stale with lastSeen 2026-06-13, not evidence of a current regression.
  • pm telemetry status --json showed telemetry enabled with recent successful flush on 2026-07-01T08:03:07.606Z.

Greptile

Pre-push Greptile review loop:

  • ee898fbd-4a0d-48f9-9fce-5b22c99f77c5 found dead sprintReleasePolicy; fixed.
  • 3df1cc5f-6934-4d13-b26e-4a26ea2dea8a found two behavior-preservation concerns; fixed defensive schema string coercion and replace-tests empty cleanup.
  • 4cd22b0a-0678-40ee-b5e5-f24b4863ced0 returned COMMENTS=0, confidence 4, safe to merge.

Summary by cubic

Refactors the update command and mutation registration into focused helpers to lower CodeFactor complexity and complete runtime‑aware option‑policy checks. No CLI contract changes; closes pm-0n6p (under pm-92if) and removes the last ESLint complexity suppressions.

  • Bug Fixes

    • Keep canceled items unassigned even when ownership flags are provided.
    • Reject conflicting set/unset for runtime schema fields with runtime‑aware option‑policy checks.
    • Conflict errors now cite the provided runtime field CLI flag for clarity.
  • Refactors

    • Extracted helpers from runUpdate and its apply‑callback in src/cli/commands/update.ts, preserving routing, close‑status handling, dependency/test/doc/file mutations, runtime fields, and changed‑field behavior.
    • Split src/cli/register-mutation.ts actions into named helpers; switched tests to the public parse path; kept defensive string coercion and ensured repeatable schema role/alias flags route as arrays for schema add-status and add-type.

Written for commit 460f0a0. Summary will update on new commits.

Review in cubic

Greptile Summary

This PR completes CodeFactor complexity remediation by decomposing the large runUpdate function and its mutation callback in update.ts, and splitting the six large action closures in register-mutation.ts into named helpers. All existing routing, field mutation, and validation behavior is preserved, with two deliberate behavior fixes: runtime schema fields are now correctly recognised in --unset target parsing for type-policy enforcement, and cancelled items now forcibly clear their assignee even when --assignee is supplied in the same update.

  • update.ts: runUpdate decomposes into ~20 focused helpers; introduces UpdateMutationContext and UpdateClearCollectionDefinition interfaces; adds runtimeFieldRegistry to enforceUpdateOptionsByType/collectProvidedUpdatePolicyOptions to correctly detect runtime field --unset conflicts; moves cancelled-item assignee removal into mutateUpdateDocument.
  • register-mutation.ts: Extracts runCreateAction, runCloseManyAction, runPlanAction, runHistoryCompactAction, runSchemaAction, runCommentsAction plus shared utilities; removes /* c8 ignore next */ suppression on the defensive string-coercion path for alias/role, now covered by new tests.
  • Tests: New integration tests cover repeatable --role/--alias array routing, programmatic string coercion, cancellation-overrides-assignee behaviour, and --unset + runtime field conflict; ESLint complexity suppressions for the refactored functions are removed.

Confidence Score: 5/5

Safe to merge; behaviour-preserving decomposition with targeted fixes, comprehensive test coverage, and all gates passing.

The refactoring faithfully preserves routing, mutation ordering, and validation logic. The two intentional behaviour changes are each backed by new integration tests and documented in the PR description.

The cancelled-item assignee-removal block in src/cli/commands/update.ts (mutateUpdateDocument) deserves a second look to confirm the intended scope of the guard.

Important Files Changed

Filename Overview
src/cli/commands/update.ts Large refactor extracting helpers from runUpdate and its mutate callback. Adds runtimeFieldRegistry to enforceUpdateOptionsByType/collectProvidedUpdatePolicyOptions (correct fix), extracts context types, and splits mutation logic into focused helpers.
src/cli/register-mutation.ts Extracts large inline action closures into named top-level helpers. Introduces shared utilities. Logic is preserved faithfully.
tests/unit/commands/update-command.spec.ts Adds tests for collectProvidedUpdatePolicyOptions with runtime field registry, cancellation-overrides-assignee behaviour, and --unset + runtime field conflict.
tests/unit/commands/register-commands.spec.ts Adds tests for repeatable --role/--alias array routing and defensive string coercion.
eslint-suppressions.json Removes complexity suppressions for the refactored functions.
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
src/cli/commands/update.ts:2057-2065
The cancelled-item assignee removal check no longer requires `options.status !== undefined`. In the original code the guard was inside `if (options.status !== undefined)`, so it only fired when the update itself was transitioning the item to cancelled. The new placement runs unconditionally after all mutations, meaning any update to an item that is **already in cancelled state with an existing assignee** (e.g., data imported from another tool, or a re-opened-then-re-cancelled item) will silently clear the `assignee` field. Adding the original guard makes the scope explicit and prevents unintended side-effects on non-status updates.

```suggestion
  if (
    context.options.status !== undefined &&
    normalizeStatusInput(document.metadata.status, context.statusRegistry) === context.statusRegistry.canceled_status &&
    document.metadata.assignee !== undefined
  ) {
    delete document.metadata.assignee;
    if (!changedFields.includes("assignee")) {
      changedFields.push("assignee");
    }
  }
```

### Issue 2 of 2
src/cli/register-mutation.ts:658-664
The `pm-6mit` comment explaining why `step` is intentionally absent from the alias pairs was preserved in the original inline closure but is lost in the extracted function. Without it, a future reader may assume the omission is a mistake and re-add the alias, re-introducing the regression described in `pm-6mit`.

```suggestion
function normalizePlanAliases(options: Record<string, unknown>): Record<string, unknown> {
  const planOptions: Record<string, unknown> = { ...options };
  const aliasPairs: Array<[string, string]> = [
    ["blocked_by", "blockedBy"],
    ["resume_context", "resumeContext"],
    ["from_search", "fromSearch"],
    // pm-6mit: "step" is intentionally not aliased to stepTitle here — it is a
    // first-class repeatable option normalized inside runPlan.
    ["step_title", "stepTitle"],
```

Reviews (6): Last reviewed commit: "Use runtime field CLI flag in conflict e..." | Re-trigger Greptile

Decompose the high-complexity update command flow and register-mutation action handlers into focused helpers while preserving the existing CLI behavior and command contracts.

Remove the obsolete ESLint complexity suppressions for update.ts and register-mutation.ts, add register-command coverage for repeatable schema alias and role routing, and record pm-0n6p evidence for full coverage, lint, contracts, changelog, manual temp-project smoke, GitHub, Sentry, telemetry, and release-state checks.
@unbraind

unbraind commented Jul 1, 2026

Copy link
Copy Markdown
Owner Author

@greptileai
/gemini review
@gemini-code-assist
@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

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Refactors src/cli/commands/update.ts and src/cli/register-mutation.ts into helper-based flows, removes matching ESLint complexity suppressions, adds CLI coverage for schema argument coercion, and updates PM task tracking metadata.

Changes

Complexity decomposition of update and register-mutation

Layer / File(s) Summary
Update command types, context, and validation helpers
src/cli/commands/update.ts
Adds ItemDocument, update context/type definitions, option-key constants, and validation helpers for stdin, clear/replace collections, and unset conflicts.
Update mutation extraction and routing
src/cli/commands/update.ts
Extracts legacy-token rejection, field-flag and no-op helpers, parent resolution, workflow warnings, close-status routing, and mutateUpdateDocument, then wires runUpdate to use them.
register-mutation action extraction and wiring
src/cli/register-mutation.ts
Extracts create, close-many, plan, history-compact, schema, and comments handlers into named functions and delegates Commander actions to them.
Suppression cleanup and coverage tests
eslint-suppressions.json, tests/unit/commands/register-commands.spec.ts, tests/unit/commands/update-command.spec.ts
Removes complexity suppressions for the refactored files and adds tests for schema multi-value coercion, canceled-status clearing, and runtime --unset conflicts.

PM task-tracking metadata

Layer / File(s) Summary
PM task pm-0n6p lifecycle and metadata records
.agents/pm/extensions/.managed-extensions.json, .agents/pm/history/pm-0n6p.jsonl, .agents/pm/tasks/pm-0n6p.toon, CHANGELOG.md
Updates the extension timestamp and records task status, comments, files, tests, test-run outcomes, and changelog entry for the refactor work.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • unbraind/pm-cli#412: Both PRs modify src/cli/commands/update.ts and the related ESLint suppression entry for that file.
  • unbraind/pm-cli#40: Both PRs touch the close-routing behavior in update.ts.
  • unbraind/pm-cli#389: Both PRs work in the same runtime --unset validation area of update.ts.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.76% 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
Title check ✅ Passed The title accurately summarizes the main change: refactoring update mutation complexity.
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.
Description check ✅ Passed The description matches the refactor, tests, suppression removal, and pm history updates shown in the changeset.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

@unbraind I'll kick off a full review of this PR now. The mentions to Greptile and Gemini will be handled by those respective tools independently.

✅ Action performed

Full review finished.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors the CLI codebase to address CodeFactor complexity warnings. Specifically, it decomposes the highly complex runUpdate method and its nested mutate callback in src/cli/commands/update.ts into smaller, focused helper functions. Similarly, complex action handlers in src/cli/register-mutation.ts (such as those for create, close-many, plan, history-compact, schema, and comments) have been extracted into dedicated helper functions. ESLint complexity suppressions for these files have been pruned, and unit tests in tests/unit/commands/register-commands.spec.ts have been added to cover repeatable schema alias/role routing and programmatic string coercion. There are no review comments to assess, and I have no additional feedback to provide as the changes are clean, well-structured, and fully covered by tests.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors the CLI codebase to decompose highly complex methods and action handlers, specifically targeting runUpdate and its nested mutation callback in src/cli/commands/update.ts, as well as several action handlers in src/cli/register-mutation.ts. By extracting these into smaller, focused helper functions, the ESLint complexity suppressions for these files have been successfully removed. Additionally, unit tests were added to verify repeatable schema alias/role routing and programmatic string coercion. There are no review comments to address, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

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

🤖 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/update.ts`:
- Around line 1614-1616: The canceled-status assignee cleanup in update.ts runs
too early, so applyOwnershipAndIssueMutations can reintroduce an assignee
afterward. Move the canceled-item cleanup to run after
applyOwnershipAndIssueMutations in the update flow, using the existing
statusRegistry.canceled_status check, and when deleting
document.metadata.assignee also add assignee to the tracked mutated fields so
the removal is recorded consistently.
- Around line 1981-1983: The runtime field update loop currently skips values
when a key is present in both context.runtimeFieldUpdates and
context.clearFrontMatterKeys, which hides set/unset conflicts. Update the logic
around the runtime field handling in update.ts so it mirrors the
registered-field validation below: detect the overlap for each fieldKey and
throw an explicit conflict error instead of continuing. Keep the existing
stableValueEquals behavior only for non-conflicting runtime fields.

In `@tests/unit/commands/register-commands.spec.ts`:
- Around line 2106-2115: The test is reaching into Commander internals by
calling schemaCommand._actionHandler directly, which should be avoided. Update
this case to exercise the same add-status review flow through runCliRaw or the
public parse path, and remove the private _actionHandler access while still
asserting the alias and role coercion on schemaCommand.
🪄 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: d11d9a4b-77d9-41f5-8230-af2692d82073

📥 Commits

Reviewing files that changed from the base of the PR and between a4ee2a1 and 2056739.

📒 Files selected for processing (7)
  • .agents/pm/extensions/.managed-extensions.json
  • .agents/pm/history/pm-0n6p.jsonl
  • .agents/pm/tasks/pm-0n6p.toon
  • eslint-suppressions.json
  • src/cli/commands/update.ts
  • src/cli/register-mutation.ts
  • tests/unit/commands/register-commands.spec.ts
💤 Files with no reviewable changes (1)
  • eslint-suppressions.json

Comment thread src/cli/commands/update.ts Resolved
Comment thread src/cli/commands/update.ts Resolved
@codecov

codecov Bot commented Jul 1, 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!

Resolve PR #413 CodeRabbit feedback by keeping canceled items unassigned after ownership mutations, rejecting runtime schema field set/unset conflicts with runtime-aware option-policy handling, and replacing the register-command private Commander action hook test with a public parse path.

Verification: unsuppressed focused ESLint passed; pnpm typecheck passed; focused update/register tests passed; full coverage passed at 100/100/100/100; linked pm-0n6p tests passed coverage, focused suites, contracts, and lint/static quality.
@unbraind

unbraind commented Jul 1, 2026

Copy link
Copy Markdown
Owner Author

Review-fix commit pushed for CodeRabbit findings. Please review current head 57d33b7.

@greptileai
/gemini review
@gemini-code-assist
@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

@unbraind I'll perform a full review of the current head (57d33b7) now.

✅ Action performed

Full review finished.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request performs a comprehensive refactor of the update and register-mutation commands to reduce code complexity and improve maintainability. Key changes include decomposing large functions into smaller, focused helpers, improving validation logic for command options, and removing outdated ESLint complexity suppressions. The refactor also includes updated task metadata and additional unit tests to ensure behavior preservation, particularly regarding assignee handling and runtime field conflicts. I have no feedback to provide as there were no review comments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@unbraind

unbraind commented Jul 1, 2026

Copy link
Copy Markdown
Owner Author

Merged latest main and pushed post-merge validation evidence. Please review current head dfb8d64.\n\n@greptileai\n/gemini review\n@gemini-code-assist\n@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

@unbraind I'll perform a full review of the current head (dfb8d64) now, incorporating the post-merge changes.

✅ Action performed

Full review finished.

✅ Action performed

Full review finished.

@gemini-code-assist

Copy link
Copy Markdown

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@unbraind

unbraind commented Jul 1, 2026

Copy link
Copy Markdown
Owner Author

Gemini reported a transient review creation error on current head dfb8d64. Please retry.\n\n/gemini review\n@gemini-code-assist

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors the update command (src/cli/commands/update.ts) and mutation registration handlers (src/cli/register-mutation.ts) by decomposing complex methods into focused, behavior-preserving helper functions to resolve CodeFactor complexity issues. It also removes ESLint complexity suppressions, adds unit tests covering repeatable schema alias/role routing, canceled status assignee overrides, and conflicting runtime field updates, and updates task tracking files. There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@unbraind

unbraind commented Jul 1, 2026

Copy link
Copy Markdown
Owner Author

Final pm closeout commit pushed. Please review current head 547cf16.\n\n@greptileai\n/gemini review\n@gemini-code-assist\n@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

@unbraind I'll perform a full review of the current head (547cf16) now.

✅ Action performed

Full review finished.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request implements a comprehensive complexity refactoring for the update command and the MCP mutation registration handlers. Specifically, it decomposes the highly complex runUpdate method, its nested mutate callback, and several command action handlers in register-mutation.ts into smaller, focused helper functions, allowing the removal of ESLint complexity suppressions. Additionally, it refines the behavior of the update command by explicitly handling conflicts between --unset and runtime schema fields, ensuring assignee cleanup when an item is canceled, and adding robust unit test coverage for these paths. There are no review comments provided, so I have no feedback to address.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@unbraind

unbraind commented Jul 1, 2026

Copy link
Copy Markdown
Owner Author

Changelog fix pushed after pm closeout. Please review current head ff3d774.\n\n@greptileai\n/gemini review\n@gemini-code-assist\n@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

@unbraind I'll perform a full review of the current head (ff3d774) now.

✅ Action performed

Full review finished.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request decomposes the complex runUpdate method, its nested mutation callback in src/cli/commands/update.ts, and the mutation action handlers in src/cli/register-mutation.ts into focused, behavior-preserving helper functions. These refactorings allow the removal of several CodeFactor complexity suppressions from eslint-suppressions.json. Additionally, the changes ensure that an assignee is cleared when an item is canceled, explicitly reject conflicting set/unset options for runtime schema fields, and add corresponding unit test coverage. There are no review comments provided, so I have no feedback to provide on the review itself.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@unbraind

unbraind commented Jul 1, 2026

Copy link
Copy Markdown
Owner Author

Tag-aware changelog correction pushed. Please review current head eb5f7f2.\n\n@greptileai\n/gemini review\n@gemini-code-assist\n@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

@unbraind I'll perform a full review of the current head (eb5f7f2) now, incorporating the tag-aware changelog correction.

✅ Action performed

Full review finished.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors the CLI commands by decomposing the complex runUpdate method, its nested mutation callback, and several register-mutation action handlers into smaller, focused helper functions to address CodeFactor complexity warnings. It also prunes ESLint complexity suppressions and adds robust test coverage for canceled-status assignee overrides and runtime field set/unset conflicts. The review feedback highlights a potential runtime TypeError in src/cli/commands/update.ts where a non-null assertion operator (!) is used on a .find() result, suggesting a safer fallback instead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/cli/commands/update.ts Outdated
Comment on lines +1991 to +1995
const definition = context.runtimeFieldRegistry.definitions.find((candidate) => candidate.metadata_key === fieldKey)!;
throw new PmCliError(
`Cannot combine --unset ${fieldKey.replaceAll("_", "-")} with --${definition.cli_flag}`,
EXIT_CODE.USAGE,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using a non-null assertion operator (!) on the result of .find() can lead to a runtime TypeError if the field key is not found in the registry. It is safer to handle the potential undefined case gracefully by falling back to a derived flag name.

      const definition = context.runtimeFieldRegistry.definitions.find((candidate) => candidate.metadata_key === fieldKey);
      const flagName = definition?.cli_flag ?? fieldKey.replaceAll("_", "-");
      throw new PmCliError(
        `Cannot combine --unset ${fieldKey.replaceAll("_", "-")} with --${flagName}`,
        EXIT_CODE.USAGE,
      );

@unbraind

unbraind commented Jul 1, 2026

Copy link
Copy Markdown
Owner Author

Gemini runtime-field conflict feedback fixed. Please review current head d477648.\n\n@greptileai\n/gemini review\n@gemini-code-assist\n@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

@unbraind I'll perform a full review of the current head (d477648) now, incorporating the runtime-field conflict fix. The mentions to Greptile and Gemini will be handled by those respective tools independently.

✅ Action performed

Full review finished.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors the CLI commands by decomposing the complex runUpdate method, its nested mutate callback, and several action handlers in register-mutation.ts into smaller, focused helper functions. This allows the removal of ESLint complexity suppressions for these files. Additionally, the changes address edge cases such as clearing the assignee when an item is canceled, detecting conflicts when unsetting runtime schema fields that are also being updated, and preserving defensive string-to-array coercion for programmatic schema options. Unit tests have been added to cover these new behaviors and ensure 100% coverage is maintained. There are no review comments to address, so no further feedback is provided.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

@unbraind I'll kick off a full review of the current head (d477648) now, incorporating the runtime-field conflict fix. The mentions to Greptile and Gemini will be handled by those respective tools independently.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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 `@src/cli/commands/update.ts`:
- Around line 1991-1993: The conflict error in update.ts is using the metadata
key-derived flag instead of the runtime field definition’s actual CLI flag.
Update the logic around the field conflict check in the update command to read
the registered field definition’s cli_flag and use that value for both sides of
the error message, rather than deriving it from fieldKey. Keep the change
localized to the branch that throws the PmCliError so the reported --unset/--
flag matches the command’s real update flag.
🪄 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: 3ad73a97-9c19-43cf-9f99-2920d0e6b08f

📥 Commits

Reviewing files that changed from the base of the PR and between dfb8d64 and d477648.

📒 Files selected for processing (4)
  • .agents/pm/history/pm-0n6p.jsonl
  • .agents/pm/tasks/pm-0n6p.toon
  • CHANGELOG.md
  • src/cli/commands/update.ts

Comment thread src/cli/commands/update.ts Resolved
@unbraind

unbraind commented Jul 1, 2026

Copy link
Copy Markdown
Owner Author

CodeRabbit runtime cli_flag feedback fixed. Please review current head 460f0a0.\n\n@greptileai\n/gemini review\n@gemini-code-assist\n@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

@unbraind I'll perform a full review of the current head (460f0a0) now, incorporating the runtime cli_flag fix. The mentions to Greptile and Gemini will be handled by those respective tools independently.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request decomposes the complex runUpdate function, its nested mutate callback in src/cli/commands/update.ts, and several action handlers in src/cli/register-mutation.ts into smaller, focused helper functions. This refactoring allows the removal of ESLint complexity suppressions for these files. Additionally, the update command now explicitly handles conflicts when combining --unset with runtime schema field values, and ensures that canceling an item correctly clears the assignee and records it in the changed fields. Unit tests have been added to cover these new conflict paths, assignee cleanup behaviors, and programmatic schema alias/role string coercion. There are no review comments to address, so no further feedback is provided.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@unbraind

unbraind commented Jul 1, 2026

Copy link
Copy Markdown
Owner Author

Greptile check appears stuck on current head 460f0a0 after all CI and other reviews passed. Please retry only Greptile.\n\n@greptileai

@unbraind
unbraind merged commit 7d171ef into main Jul 1, 2026
20 checks passed
@unbraind
unbraind deleted the codefactor-update-register-mutation-complexity branch July 1, 2026 13:54
unbraind added a commit that referenced this pull request Jul 1, 2026
Document the PR #413 merge, post-merge validation, GitHub/security/release checks, Sentry/telemetry evidence, temp-project smoke, and release the pm-92if claim.
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