Skip to content

Fix CodeFactor generated marker handling - #381

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

unbraind merged 3 commits into
mainfrom
fix/codefactor-dedupe-sdk-primitives

Conversation

@unbraind

@unbraind unbraind commented Jun 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • mark generated package runtime loaders and plugin MCP launchers with CodeFactor-friendly auto-generated headers
  • document that CodeFactor ignore scope is managed through hosted settings while keeping the repo-local checklist aligned
  • record PM evidence on pm-fmjy and pm-arzz, including why broad command complexity refactors remain tracked separately

Validation

  • CodeFactor PR detail: 0 issues found
  • node scripts/gen-package-runtime-loaders.mjs --check
  • node scripts/gen-plugin-mcp-wrappers.mjs --check
  • focused generator/runtime tests: 4 files, 34 tests
  • pnpm build; pnpm typecheck; pnpm contracts:check; pnpm quality:static; pnpm security:scan; pnpm audit --audit-level low
  • pnpm changelog:pm:check using pm-changelog@2026.6.20, CHANGELOG.md unchanged
  • node scripts/run-tests.mjs coverage: 256 files, 5133 tests, 100% statements/branches/functions/lines
  • isolated temp smoke: init/create/claim/update/files/docs/test/close/release plus health ok 0 warnings and validate ok 0 warnings
  • Sentry/telemetry gate: ok, Sentry critical=0 high=0 total=0; telemetry finish_error_rate_pct=0.69

Review status

  • CodeRabbit, Sourcery, cubic, Hound, CodeFactor, CodeQL, Codecov, and CI are green on final head e8c3944
  • Gemini review is quota-blocked by the app; Codex connector reports account connection required

Single-source repeated SDK list/search filter contracts and tool option contracts, share list/search filter echo handling, share create/update runtime unset resolution, and reuse the canonical config key type.

Refresh generated package runtime loaders and plugin MCP launchers with explicit auto-generated markers so CodeFactor can classify generated files correctly; keep the local CodeFactor settings note aligned with hosted ignore behavior.

PM evidence: pm-fmjy records the duplication remediation, full coverage, generator checks, static gates, security scan, changelog check, and isolated PM_PATH/PM_GLOBAL_PATH smoke. pm-arzz remains open for staged complexity refactors.
@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!

@sourcery-ai

sourcery-ai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Centralizes shared item filter echo and tool option contracts, unifies runtime unset field resolution across create/update, exports the canonical config key type for reuse, and refreshes generated loaders and MCP wrappers with explicit auto-generated markers and updated CodeFactor docs/evidence.

Sequence diagram for shared item filter echo in list/search commands

sequenceDiagram
  participant ListCommand as list_command
  participant SearchCommand as search_command
  participant CommonEcho as applyCommonItemFilterEcho

  ListCommand->>CommonEcho: applyCommonItemFilterEcho(filters, options)
  CommonEcho-->>ListCommand: filters updated with common item filters

  SearchCommand->>CommonEcho: applyCommonItemFilterEcho(filters, options)
  CommonEcho-->>SearchCommand: filters updated with common item filters
Loading

File-Level Changes

Change Details Files
Introduce shared list/search item filter echo helper to eliminate duplicated filter field mapping logic.
  • Define COMMON_ITEM_FILTER_ECHO_ENTRIES constant describing option-to-summary key mappings.
  • Add applyCommonItemFilterEcho(filters, options) helper to populate compact filter summaries.
  • Replace inline filter field assignments in list and search compact summary builders with applyCommonItemFilterEcho calls.
src/cli/commands/list.ts
src/cli/commands/search.ts
Single-source item metadata-missing and content-presence flag contracts and tool option contracts for list/search CLI and MCP tools.
  • Factor shared ITEM_METADATA_MISSING_FILTER_FLAG_CONTRACTS and ITEM_CONTENT_PRESENCE_FLAG_CONTRACTS arrays out of LIST_FILTER_FLAG_CONTRACTS.
  • Reuse shared flag contract arrays in both LIST_FILTER_FLAG_CONTRACTS and SEARCH_FLAG_CONTRACTS via spread operators.
  • Factor shared TOOL_ITEM_METADATA_MISSING_FILTER_OPTION_CONTRACTS and TOOL_ITEM_CONTENT_PRESENCE_OPTION_CONTRACTS arrays out of TOOL_LIST_FILTER_OPTION_CONTRACTS.
  • Reuse shared tool option contract arrays in both TOOL_LIST_FILTER_OPTION_CONTRACTS and TOOL_SEARCH_FILTER_OPTION_CONTRACTS via spread operators.
src/sdk/cli-contracts.ts
src/sdk/cli-contracts/tool-option-contracts.ts
Unify runtime unset field resolution logic for create and update commands into a shared primitive.
  • Introduce RuntimeUnsetFieldDefinition interface and resolveRuntimeUnsetFieldDefinition helper that inspects runtimeFieldRegistry definitions with allow_unset support.
  • Refactor create.ts to use RuntimeUnsetFieldDefinition type and resolveRuntimeUnsetFieldDefinition instead of a local resolveRuntimeCreateUnsetDefinition implementation.
  • Refactor update.ts to alias UpdateUnsetFieldDefinition to RuntimeUnsetFieldDefinition and reuse resolveRuntimeUnsetFieldDefinition instead of a local resolver.
  • Expose resolveRuntimeUnsetFieldDefinition through _testOnlyCreateCommand and _testOnlyUpdateCommand test-only exports for backwards compatibility.
src/cli/commands/shared-unset-fields.ts
src/cli/commands/create.ts
src/cli/commands/update.ts
Export canonical config key type for reuse by CLI config command and other modules.
  • Change CanonicalConfigKey in positional-value helper from internal type to exported type.
  • Update config.ts to type ConfigKey as CanonicalConfigKey instead of re-declaring the union.
src/core/config/positional-value.ts
src/cli/commands/config.ts
Clarify CodeFactor configuration semantics and mark generated plugin MCP wrappers and package runtime loaders as auto-generated for quality tooling.
  • Expand .codefactor.yml header comments to describe hosted ignore behavior and the role of this file as a checklist rather than a directly consumed config.
  • Update MCP server launcher headers in pm-claude and pm-codex plugins to use explicit "auto-generated" wording tied to the generator script.
  • Refresh package runtime loader files for pm-beads and pm-todos via scripts/gen-package-runtime-loaders.mjs, updating headers or structure as needed for CodeFactor classification.
  • Adjust generator scripts gen-plugin-mcp-wrappers.mjs and gen-package-runtime-loaders.mjs to emit the new auto-generated headers consistently.
.codefactor.yml
plugins/pm-claude/scripts/pm-mcp-server.mjs
plugins/pm-codex/scripts/pm-mcp-server.mjs
packages/pm-beads/extensions/beads/runtime-loader.ts
packages/pm-todos/extensions/todos/runtime-loader.ts
scripts/gen-plugin-mcp-wrappers.mjs
scripts/gen-package-runtime-loaders.mjs
Record PM evidence for CodeFactor remediation and complexity follow-up work.
  • Update managed PM extension metadata and task/history records for pm-fmjy and pm-arzz to capture this CodeFactor duplication remediation and track remaining complexity work.
.agents/pm/extensions/.managed-extensions.json
.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

@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR centralizes runtime unset-field resolution, reuses shared filter contract groups and compact filter echo logic, updates generated header text in loaders and MCP wrappers, and refreshes CodeFactor and PM tracking metadata.

Changes

CLI unset and config typing

Layer / File(s) Summary
Config typing and shared unset helper
src/core/config/positional-value.ts, src/cli/commands/config.ts, src/cli/commands/shared-unset-fields.ts
CanonicalConfigKey is exported, ConfigKey aliases it, and resolveRuntimeUnsetFieldDefinition maps unset tokens through the runtime field registry.
Create and update unset parsing
src/cli/commands/create.ts, src/cli/commands/update.ts
Both commands import the shared unset resolver, remove their local unset helpers, and route fallback --unset parsing through the shared implementation.

Shared filter contracts and echoes

Layer / File(s) Summary
Shared filter contracts
src/sdk/cli-contracts/tool-option-contracts.ts, src/sdk/cli-contracts.ts
Reusable metadata-missing and content-presence groups are added and spread into tool list filter contracts and list/search flag contracts.
Compact list and search echo
src/cli/commands/list.ts, src/cli/commands/search.ts
applyCommonItemFilterEcho replaces inline common filter echo assignments in compact list and search summaries.

Generated header wording sync

Layer / File(s) Summary
Generated header wording
scripts/gen-package-runtime-loaders.mjs, scripts/gen-plugin-mcp-wrappers.mjs, packages/pm-beads/extensions/beads/runtime-loader.ts, packages/pm-todos/extensions/todos/runtime-loader.ts, plugins/pm-claude/scripts/pm-mcp-server.mjs, plugins/pm-codex/scripts/pm-mcp-server.mjs
The runtime-loader and MCP wrapper templates change the generated header wording, and the checked-in generated files match the new text.

CodeFactor and PM metadata

Layer / File(s) Summary
CodeFactor metadata
.codefactor.yml, .agents/pm/extensions/.managed-extensions.json
/.codefactor.yml header text changes, and the managed extension timestamp updates.
pm-arzz history and task
.agents/pm/history/pm-arzz.jsonl, .agents/pm/tasks/pm-arzz.toon
pm-arzz records a new claim and follow-up comment, and the task record updates assignee, author, timestamps, and comment content.
pm-fmjy history and task
.agents/pm/history/pm-fmjy.jsonl, .agents/pm/tasks/pm-fmjy.toon
pm-fmjy history expands the claim, files, tests, and verification notes, and the task record mirrors the updated comments, files, and tests.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • unbraind/pm-cli#380: Shares the unset-field resolver and create.ts/update.ts command changes in the same code path.
  • unbraind/pm-cli#251: Touches the same list/search filter-summary and SDK filter-contract surfaces.
  • unbraind/pm-cli#147: Refactors the compact list/search filter summary logic that this PR also updates.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% 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 clearly summarizes the main change: updating handling of CodeFactor-generated markers.
Description check ✅ Passed The description matches the changeset, covering generated headers, CodeFactor notes, and PM tracking updates.
✨ 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.

@unbraind

Copy link
Copy Markdown
Owner Author

@codex review

/gemini review

@gemini-code-assist review

@coderabbitai full review

@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 a full review of this PR now.

✅ Action performed

Full review finished.

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

@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 new applyCommonItemFilterEcho helper and its callers all work on Record<string, unknown>; consider tightening these to specific option/filter types (or at least keyed string union types) so that future additions/removals to COMMON_ITEM_FILTER_ECHO_ENTRIES are checked by the type system rather than only at runtime.
  • Now that RuntimeUnsetFieldDefinition and resolveRuntimeUnsetFieldDefinition are shared between create/update, you may want to colocate or expose the common UPDATE_UNSET_ALIAS_MAP/CREATE_UNSET_ALIAS_MAP logic as well so that future changes to runtime unset behavior are less likely to diverge between commands.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `applyCommonItemFilterEcho` helper and its callers all work on `Record<string, unknown>`; consider tightening these to specific option/filter types (or at least keyed string union types) so that future additions/removals to `COMMON_ITEM_FILTER_ECHO_ENTRIES` are checked by the type system rather than only at runtime.
- Now that `RuntimeUnsetFieldDefinition` and `resolveRuntimeUnsetFieldDefinition` are shared between create/update, you may want to colocate or expose the common `UPDATE_UNSET_ALIAS_MAP`/`CREATE_UNSET_ALIAS_MAP` logic as well so that future changes to runtime unset behavior are less likely to diverge between commands.

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.

@cubic-dev-ai cubic-dev-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.

No issues found across 21 files

Re-trigger cubic

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai review

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

@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
✅ 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.

Keep the PR focused on CodeFactor generated-file classification after the PR detail page reported 16 complexity findings on large command and SDK files touched by the initial dedupe refactor.

Preserve the generator/template marker changes for package runtime loaders and plugin MCP wrappers, update PM evidence, and leave the command complexity work tracked by pm-arzz for a dedicated staged refactor.

Validation: generator drift checks, focused runtime/generator tests, pnpm build, typecheck, contracts:check, quality:static, security:scan, audit, changelog:pm:check, full 100% coverage, isolated temp smoke, PM health, and Sentry/telemetry gate.
@unbraind

Copy link
Copy Markdown
Owner Author

@codex review

/gemini review

@gemini-code-assist review

@coderabbitai full review

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

@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 a full review of this PR now.

✅ Action performed

Full review finished.

@cubic-dev-ai cubic-dev-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.

5 issues found across 18 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/cli/commands/update.ts">

<violation number="1">
P2: New local runtime-unset resolver duplicates existing create-command logic instead of sharing one primitive. Keep one shared resolver to avoid drift between create/update unset behavior.</violation>
</file>

<file name="src/sdk/cli-contracts/tool-option-contracts.ts">

<violation number="1">
P3: This reintroduces duplicated option-contract blocks across list and search arrays. Keep these options in shared constants and spread them into both arrays to avoid drift bugs.</violation>
</file>

<file name="src/cli/commands/search.ts">

<violation number="1">
P3: This block duplicates existing compact filter-echo mapping logic from list command. Duplicated mappings raise maintenance drift risk when filter keys/options change.</violation>
</file>

<file name="src/cli/commands/config.ts">

<violation number="1">
P2: `ConfigKey` is duplicated as a hard-coded literal union instead of being derived, adding another key list to maintain. Drift here can desync config command typing from positional routing key coverage.</violation>
</file>

<file name="src/sdk/cli-contracts.ts">

<violation number="1">
P3: SEARCH_FLAG_CONTRACTS duplicates filter-contract entries already declared in LIST_FILTER_FLAG_CONTRACTS. Keep these flags in a shared constant to avoid list/search contract drift.</violation>
</file>

Tip: instead of fixing issues one by one fix them all with cubic

Re-trigger cubic

Record claim release for pm-fmjy and pm-arzz after the CodeFactor PR update was validated.
@unbraind

Copy link
Copy Markdown
Owner Author

@codex review

/gemini review

@gemini-code-assist review

@coderabbitai full review

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

@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 a full review of this PR now.

✅ Action performed

Full review finished.

@unbraind unbraind changed the title Fix CodeFactor duplication with shared PM primitives Fix CodeFactor generated marker handling Jun 26, 2026
@unbraind
unbraind merged commit 241d6b8 into main Jun 26, 2026
19 checks passed
@unbraind
unbraind deleted the fix/codefactor-dedupe-sdk-primitives branch June 26, 2026 20:44
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