Skip to content

Fix CodeFactor duplication in CLI and SDK primitives - #380

Merged
unbraind merged 2 commits into
mainfrom
fix/codefactor-sdk-duplication-primitives
Jun 26, 2026
Merged

unbraind merged 2 commits into
mainfrom
fix/codefactor-sdk-duplication-primitives

Conversation

@unbraind

@unbraind unbraind commented Jun 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Single-source create/update --unset field metadata in shared-unset-fields.ts and reuse it from both command handlers.
  • Share create/update mutation option keys and SDK bulk mutation filter contracts to remove duplicated shipped tables.
  • Keep CodeFactor focused on actionable source by excluding generated package runtime loaders, generated plugin MCP launchers, and tests enforced by repo gates; update the CodeFactor docs pointer.
  • Record PM evidence under pm-92if, pm-fmjy, and pm-arzz, including GitHub/dependency/security/changelog/Sentry/telemetry findings.

Verification

  • pnpm build
  • node scripts/run-tests.mjs test -- tests/unit/commands/create-command.spec.ts tests/unit/commands/update-command.spec.ts tests/unit/packages/runtime-loaders.spec.ts tests/unit/scripts/gen-package-runtime-loaders.spec.ts tests/unit/scripts/gen-plugin-mcp-wrappers.spec.ts tests/unit/plugins/pm-mcp-server.spec.ts tests/unit/packages/package-manifest.spec.ts (7 files, 254 tests)
  • pnpm contracts:check
  • pnpm quality:static
  • pnpm typecheck
  • pnpm security:scan
  • node scripts/run-tests.mjs coverage (256 files, 5133 tests, 100% statements/branches/functions/lines)
  • pnpm changelog:pm:check (pm-changelog 2026.6.20, CHANGELOG.md unchanged)
  • manual temp-dir smoke with isolated PM_PATH/PM_GLOBAL_PATH: init, create, update --unset, package install todos, package doctor deep, contracts, health
  • node scripts/release/sentry-telemetry-gate.mjs --json --telemetry-mode best-effort
  • pm telemetry stats --json

GitHub / release notes

  • No open Dependabot alerts and no open code scanning alerts at branch creation time.
  • Existing issue Auto Release blocked: scheduled run failed #374 remains externally blocked on missing RELEASE_PAT in the release environment; this branch does not require code changes for that failure.

Summary by Sourcery

Deduplicate shared CLI unset-field metadata and bulk mutation option/filter contracts while tightening CodeFactor analysis scope and recording associated PM evidence.

Enhancements:

  • Single-source unset-field definitions for create and update CLI commands via shared metadata.
  • Share common mutation command option key lists between create and update item type registry entries.
  • Reuse a unified bulk-mutation filter option contract across SDK update-many and close-many tool contracts.

Build:

  • Refine CodeFactor configuration to exclude generated loaders, generated plugin launchers, and tests from analysis.

Chores:

  • Add and update PM agent evidence files for the referenced product-management tasks and epics.

Summary by cubic

Dedupes CLI and SDK primitives flagged by CodeFactor by single-sourcing unset field metadata, shared mutation option keys, and bulk filter contracts. Updates .codefactor.yml to ignore generated loaders/launchers and tests so reports focus on shipped code; no behavior changes.

  • Refactors
    • Added src/cli/commands/shared-unset-fields.ts and reused in create.ts/update.ts; replaced slice-based update ordering with named groups around close-reason; kept author placement for create.
    • Extracted COMMON_MUTATION_COMMAND_OPTION_KEYS in src/core/item/type-registry.ts and reused across create/update; documented core↔CLI alignment boundary.
    • Unified SDK bulk mutation filter contracts via TOOL_BULK_MUTATION_FILTER_OPTION_CONTRACTS, reused by update-many and close-many.
    • Updated .codefactor.yml docs link and excluded packages/**/runtime-loader.ts, plugins/**/scripts/pm-mcp-server.mjs, and tests/** from analysis.

Written for commit 4acf9af. Summary will update on new commits.

Review in cubic

Single-source create/update unset metadata, mutation option keys, and SDK bulk mutation filter contracts to remove CodeFactor-reported duplicate tables from shipped CLI/SDK code.

Scope CodeFactor away from generated package runtime loaders, generated plugin MCP launchers, and tests that are already enforced by repository gates; update the CodeFactor docs pointer to the current file-ignore documentation.

PM evidence: pm-92if, pm-fmjy, and pm-arzz record GitHub/security/changelog/Sentry/telemetry findings plus verification. Passed pnpm build, targeted 254-test suite, pnpm contracts:check, pnpm quality:static, pnpm typecheck, pnpm security:scan, pnpm changelog:pm:check, sentry-telemetry gate, manual isolated temp-dir smoke, and full coverage 100/100/100/100 across 5133 tests.
@sourcery-ai

sourcery-ai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Single-sources CLI create/update unset-field metadata and common mutation option keys, deduplicates SDK bulk mutation filter contracts, tightens CodeFactor scope to authored code, and records associated PM evidence files.

File-Level Changes

Change Details Files
Single-source unset-field metadata for create and update CLI commands using shared definitions.
  • Introduce CommandUnsetFieldDefinition and shared COMMON_UNSET_FIELD_DEFINITIONS_* arrays in a new shared-unset-fields module.
  • Refactor CREATE_UNSET_FIELD_DEFINITIONS to compose shared unset-field definitions around the author field while preserving ordering.
  • Refactor UPDATE_UNSET_FIELD_DEFINITIONS to reuse shared unset-field definitions while inserting close-reason in the correct position and maintaining alias behavior.
src/cli/commands/shared-unset-fields.ts
src/cli/commands/create.ts
src/cli/commands/update.ts
Share common mutation option keys across create and update command option policies.
  • Extract COMMON_MUTATION_COMMAND_OPTION_KEYS for fields shared between create and update mutations.
  • Refactor CREATE_COMMAND_OPTION_KEYS to prepend create-specific fields, spread common mutation keys, and append author/message and repeatables.
  • Refactor UPDATE_COMMAND_OPTION_KEYS to reuse the common mutation keys between base metadata and author/message while preserving existing behavior.
src/core/item/type-registry.ts
Deduplicate SDK bulk mutation filter contracts for update-many and close-many tools.
  • Introduce TOOL_BULK_MUTATION_FILTER_OPTION_CONTRACTS as the shared bulk mutation filter contract list.
  • Refactor TOOL_UPDATE_MANY_FILTER_OPTION_CONTRACTS to spread the shared bulk mutation filter contracts.
  • Refactor TOOL_CLOSE_MANY_FILTER_OPTION_CONTRACTS to reuse the shared bulk mutation filter contracts instead of maintaining a separate list.
src/sdk/cli-contracts/tool-option-contracts.ts
Narrow CodeFactor analysis to authored application code and document new exclusions.
  • Update CodeFactor docs link to point directly to ignoring-files documentation.
  • Exclude generated runtime loaders, generated plugin MCP launcher scripts, and the entire tests tree from CodeFactor analysis with explanatory comments.
.codefactor.yml
Record PM evidence and metadata for the tracked work items.
  • Add or update epic, task, extension, and history files for PM work items pm-92if, pm-fmjy, and pm-arzz.
  • Ensure the PM artifacts reflect the checks performed (GitHub, dependency, security, changelog, Sentry, telemetry).
.agents/pm/epics/pm-92if.toon
.agents/pm/extensions/.managed-extensions.json
.agents/pm/history/pm-92if.jsonl
.agents/pm/history/pm-arzz.jsonl
.agents/pm/history/pm-fmjy.jsonl
.agents/pm/tasks/pm-arzz.toon
.agents/pm/tasks/pm-fmjy.toon

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@unbraind

Copy link
Copy Markdown
Owner Author

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

@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Updated PM tracking artifacts and CodeFactor exclusions, then refactored shared CLI metadata for unset fields, create/update option keys, and bulk mutation filter contracts.

Changes

Shared CLI metadata and contract cleanup

Layer / File(s) Summary
PM tracking and CodeFactor config
.agents/pm/epics/pm-92if.toon, .agents/pm/history/*.jsonl, .agents/pm/tasks/*.toon, .agents/pm/extensions/.managed-extensions.json, .codefactor.yml
PM epic, history, task, and managed-extension records add assignee/status updates, evidence comments, file/test entries, and timestamp changes; .codefactor.yml extends ignore globs and updates its docs comment.
Shared unset-field definitions
src/cli/commands/shared-unset-fields.ts, src/cli/commands/create.ts, src/cli/commands/update.ts
Shared unset-field metadata is added and both create and update build their unset lists from the shared before/after definitions.
Shared mutation option keys
src/core/item/type-registry.ts
Create and update command option-key arrays now share a common mutation key list while still appending author and message explicitly.
Shared bulk filter contracts
src/sdk/cli-contracts/tool-option-contracts.ts
Bulk mutation filter option contracts now reuse a shared internal array for update-many and close-many.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing CodeFactor duplication in CLI and SDK primitives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 changeset, covering shared metadata refactors, CodeFactor scope updates, and PM evidence records.
✨ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown

@unbraind Re-running the full review for this PR now, with focus on the duplication cleanup and shared primitive changes called out in the PR objectives.

✅ Action performed

Full review finished.

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

Hey - I've left some high level feedback:

  • The use of COMMON_UNSET_FIELD_DEFINITIONS_BEFORE_AUTHOR.slice(0, 1) and .slice(1) is a bit opaque; consider replacing the magic indices with named constants or explicit arrays to make the ordering contract between create/update more obvious and less fragile to future edits.
  • Since COMMON_MUTATION_COMMAND_OPTION_KEYS and the shared unset-field definitions conceptually describe the same logical field set, consider documenting or centralizing their relationship so future changes to one can’t silently drift from the other.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The use of `COMMON_UNSET_FIELD_DEFINITIONS_BEFORE_AUTHOR.slice(0, 1)` and `.slice(1)` is a bit opaque; consider replacing the magic indices with named constants or explicit arrays to make the ordering contract between create/update more obvious and less fragile to future edits.
- Since `COMMON_MUTATION_COMMAND_OPTION_KEYS` and the shared unset-field definitions conceptually describe the same logical field set, consider documenting or centralizing their relationship so future changes to one can’t silently drift from the other.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@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 several files to address CodeFactor complexity and duplication issues. Specifically, it extracts shared unset-field metadata into a new helper module, consolidates common mutation command option keys, and deduplicates bulk mutation filter option contracts. Additionally, it updates the CodeFactor configuration to exclude generated files and tests. A review comment suggests simplifying the definition of UPDATE_UNSET_FIELD_DEFINITIONS in src/cli/commands/update.ts to avoid fragile .slice calls.

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 Resolved
@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 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 @.codefactor.yml:
- Around line 14-16: The `tests/**` ignore rule in the CodeFactor config may now
hide test-file issues from static analysis, so verify the `static-quality-gate`
path in `scripts/release/static-quality-gate.mjs` explicitly includes `tests/`
when running in CI. Update that gate or its invocation from `package.json` so it
still scans and reports on test files even though CodeFactor no longer does,
while keeping the generated artifact exclusions intact.
🪄 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: 507b9b38-8f09-4954-923f-ac38b5add976

📥 Commits

Reviewing files that changed from the base of the PR and between eaf52bc and 9f5edb5.

📒 Files selected for processing (13)
  • .agents/pm/epics/pm-92if.toon
  • .agents/pm/extensions/.managed-extensions.json
  • .agents/pm/history/pm-92if.jsonl
  • .agents/pm/history/pm-arzz.jsonl
  • .agents/pm/history/pm-fmjy.jsonl
  • .agents/pm/tasks/pm-arzz.toon
  • .agents/pm/tasks/pm-fmjy.toon
  • .codefactor.yml
  • src/cli/commands/create.ts
  • src/cli/commands/shared-unset-fields.ts
  • src/cli/commands/update.ts
  • src/core/item/type-registry.ts
  • src/sdk/cli-contracts/tool-option-contracts.ts

Comment thread .codefactor.yml Resolved
@codecov

codecov Bot commented Jun 26, 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!

Replace slice-based update unset ordering with named shared groups around close-reason and document the core/CLI alignment boundary for mutation option keys.

Addresses Sourcery and Gemini feedback on PR #380. Verified with pnpm build, pnpm quality:static, pnpm contracts:check, and targeted create/update/SDK tests.
@unbraind

Copy link
Copy Markdown
Owner Author

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

Review loop update: pushed 4acf9af addressing Sourcery/Gemini feedback by replacing slice-based unset ordering with named groups and documenting core/CLI alignment. Please review the current head.

@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!

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown

@unbraind Re-running the full review on the current head now, with attention to the latest 4acf9af9 updates around the named unset groups and the documented core/CLI alignment.

✅ Action performed

Full review finished.

@unbraind
unbraind merged commit e89d1e2 into main Jun 26, 2026
19 checks passed
@unbraind
unbraind deleted the fix/codefactor-sdk-duplication-primitives branch June 26, 2026 19:24
unbraind added a commit that referenced this pull request Jun 26, 2026
Record PR #380 merge evidence and release the active CodeFactor remediation claims after the merged current-head checks and AI review loop passed.
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