Skip to content

[codex] Improve agent UX from manual pm audit#36

Merged
unbraind merged 3 commits into
mainfrom
codex/manual-agent-ux-audit-2026-05-21
May 21, 2026
Merged

[codex] Improve agent UX from manual pm audit#36
unbraind merged 3 commits into
mainfrom
codex/manual-agent-ux-audit-2026-05-21

Conversation

@unbraind
Copy link
Copy Markdown
Owner

@unbraind unbraind commented May 21, 2026

Summary

  • improves agent-facing CLI ergonomics discovered during manual temp-project dogfood
  • makes pm config default to project-scope shorthand forms
  • accepts pm cal week positional view usage and preserves dynamic extension command routing
  • improves recovery guidance for GC/reindex, invalid dependency kinds, telemetry opt-out, and parent close validation
  • deduplicates extension action schema branches while carrying richer extension flag metadata into SDK contracts
  • records audit evidence and residual backlog items in pm without adding duplicate items

Validation

  • pnpm build
  • focused unit suites for contracts, health, telemetry runtime, update, close, calendar, builtin extension entrypoints, and gc
  • pnpm quality:static
  • node scripts/check-secrets.mjs
  • node scripts/dogfood-package-first.mjs
  • PM_DOGFOOD_SEMANTIC=1 node scripts/dogfood-package-first.mjs
  • node scripts/release/run-gates.mjs --telemetry-mode required --max-sentry-critical 10 --max-sentry-high 20 --max-telemetry-error-rate 10 --json

Notes

  • No open GitHub issues, PRs, or Dependabot alerts were found before opening this PR.
  • Private telemetry operational outputs remain ignored and were not staged.

Summary by Sourcery

Improve CLI UX and telemetry controls, enrich extension contracts, and tighten validation and guidance across close, calendar, GC, and update workflows.

New Features:

  • Allow pm config to omit scope and action arguments by defaulting to project scope and list action and support action shorthands.
  • Support positional calendar view arguments for the calendar CLI while preserving option-based routing.
  • Expose richer extension flag metadata, including descriptions, repeatability, and value typing, through CLI contracts into the SDK.

Bug Fixes:

  • Ensure dynamic extension commands correctly resolve the invoked Command instance for option parsing and execution.
  • Treat PM_NO_TELEMETRY as a hard opt-out for telemetry collection and reflect it in health checks.

Enhancements:

  • Deduplicate extension schema branches by action while preserving command aliases and more precise JSON schema for extension flags.
  • Improve close command validation by detecting active child items and either warning or blocking based on validate-close mode.
  • Surface allowed enum values in update command validation errors for dependency kinds and similar options.
  • Clarify GC guidance by pointing users to install search-advanced when reindex is unavailable.
  • Strengthen telemetry runtime tests around environment overrides and no-telemetry behavior and expand tests for contracts, close, calendar, update, and GC flows.

Tests:

  • Add unit coverage for extension schema deduplication and metadata, active-child close validation, invalid dependency kind messaging, PM_NO_TELEMETRY handling, calendar positional view parsing, and updated GC guidance.

Manual temp-project dogfood and sub-agent review found several small blockers in the agent loop. This patch makes config default to project-scope shorthands, accepts calendar positional views, improves GC/reindex recovery guidance, honors PM_NO_TELEMETRY, warns when closing parents with active children, lists allowed dependency kinds, and deduplicates extension action schema branches while preserving extension flag metadata.

Verification: pnpm build; focused unit suites for contracts, health, telemetry, update, close, calendar, built-in extension entrypoints, and gc; pnpm quality:static; node scripts/check-secrets.mjs; package-first dogfood with and without semantic qwen Ollama mode; required Sentry/telemetry release gate with selected 100% coverage.
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 21, 2026

Reviewer's Guide

Improves CLI UX and telemetry/validation guidance, enriches extension flag contracts, and deduplicates extension schema branches while updating tests and docs accordingly.

Sequence diagram for close command validation with active child items

sequenceDiagram
  actor User
  participant CliCloseCommand as runClose
  participant FindActiveChildren as findActiveChildIds
  participant Mutator as mutateItem
  participant CloseValidation as close_validation_block

  User ->> CliCloseCommand: runClose(id, closeReasonText, options)
  CliCloseCommand ->> FindActiveChildren: findActiveChildIds(pmRoot, settings, id, statusRegistry)
  FindActiveChildren -->> CliCloseCommand: activeChildIds
  CliCloseCommand ->> Mutator: mutateItem({ onMutate })
  Mutator ->> CloseValidation: onMutate(document, mutationWarnings)
  CloseValidation ->> CloseValidation: findMissingCloseValidationFields(frontMatter)

  alt activeChildIds not empty and validateCloseMode strict
    CloseValidation ->> CliCloseCommand: throw PmCliError
  else activeChildIds not empty and validateCloseMode warn
    CloseValidation ->> CloseValidation: mutationWarnings.push(close_validation_active_children)
  end

  CloseValidation -->> Mutator: updated document
  Mutator -->> CliCloseCommand: result
  CliCloseCommand -->> User: result
Loading

File-Level Changes

Change Details Files
Enrich extension flag contracts and deduplicate extension schema branches by action while preserving command aliases and richer metadata in JSON schema.
  • Populate CliFlagContract and extension flag contracts with description, required, repeatable, value_name, and validated value_type fields.
  • Adjust buildExtensionActionSchemaBranch to derive JSON schema types from flag value_type, support repeatable flags via array schema, mark required flags, and expose x-extension-commands metadata.
  • Introduce mergeExtensionContractsByAction to merge multiple contracts for the same action, deduplicating flags and examples while joining command aliases and wiring it into runContracts, plus adjust tests to expect richer schema and alias tracking.
src/cli/commands/contracts.ts
src/sdk/cli-contracts.ts
tests/unit/contracts-command.spec.ts
Tighten telemetry control and health reporting via PM_NO_TELEMETRY and ensure command telemetry is skipped when disabled.
  • Add PM_NO_TELEMETRY support to telemetryDisabledByEnvironment so it fully disables telemetry when set.
  • Extend telemetry runtime tests to cover PM_NO_TELEMETRY behavior and ensure no queue or network activity occurs.
  • Update health telemetry environment override reporting to reflect both PM_TELEMETRY_DISABLED and PM_NO_TELEMETRY flags and adjust tests accordingly.
src/core/telemetry/runtime.ts
src/cli/commands/health.ts
tests/unit/telemetry-runtime.spec.ts
tests/unit/health-command.spec.ts
Improve close command validation by detecting active child items on parent close and surfacing warnings or strict failures.
  • Add findActiveChildIds helper to scan for non-terminal child items for a given parent id using the runtime type/status registry.
  • Resolve active child ids when validate-close is enabled and surface either warnings or strict-mode errors when closing a parent with active children.
  • Extend close command tests and helper task creation to support parent relationships and validate warning behavior.
src/cli/commands/close.ts
tests/unit/close-command.spec.ts
Enhance calendar command ergonomics to accept positional view arguments while preserving dynamic extension routing.
  • Add an optional view positional argument to the calendar command definition with descriptive help text.
  • Update the calendar run implementation to interpret a single non-flag positional argument as view, guard against multiple positionals, and only override view when not already provided via options.
  • Apply the same behavior in both JS and TS calendar extension entrypoints.
packages/pm-calendar/extensions/calendar/index.js
packages/pm-calendar/extensions/calendar/index.ts
Make pm config ergonomics friendlier by defaulting to project scope and allowing shorthand action usage.
  • Relax config command argument definitions so scope and action become optional and can be interpreted as project-scope action shorthands.
  • Resolve effective scope/action at runtime, defaulting to project/list when omitted, and pass resolved values to runConfig.
  • Keep existing options and description while improving help text for scope/action semantics.
src/cli/register-setup.ts
Improve UX and guidance around GC, dependency kind errors, telemetry flags reporting, and dynamic extension commands.
  • Update GC guidance messaging to mention installing search-advanced if reindex is unavailable and align tests with new text.
  • Enhance ensureEnum error messages to list allowed values for invalid dependency kinds and add a unit test for this behavior.
  • Allow registerDynamicExtensionCommandPaths dynamic commands to receive flexible Commander action signatures while still resolving global options.
  • Adjust tests and fixtures to reflect the new guidance, messaging, and behavior, including pm chores/features/history audit artifacts.
src/cli/commands/gc.ts
src/cli/commands/update.ts
src/cli/main.ts
tests/unit/gc-command.spec.ts
tests/unit/update-command.spec.ts
.agents/pm/chores/pm-5k2w.toon
.agents/pm/features/pm-rnpb.toon
.agents/pm/history/pm-5k2w.jsonl
.agents/pm/history/pm-rnpb.jsonl

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

coderabbitai Bot commented May 21, 2026

Review Change Stack

Warning

Rate limit exceeded

@unbraind has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 31 minutes and 4 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: 97054ae0-17e9-4ec3-9070-4b8644bbbb34

📥 Commits

Reviewing files that changed from the base of the PR and between 5d67eb2 and c52719e.

📒 Files selected for processing (6)
  • .agents/pm/chores/pm-5k2w.toon
  • .agents/pm/history/pm-5k2w.jsonl
  • src/cli/commands/contracts.ts
  • src/cli/register-setup.ts
  • tests/integration/cli.integration.spec.ts
  • tests/unit/health-command.spec.ts
📝 Walkthrough

Walkthrough

This PR implements telemetry opt-out support via PM_NO_TELEMETRY, enhances the calendar command with optional positional view arguments, enforces validation on close for active children, consolidates extension contract schema generation with deduplication, makes config command arguments flexible with shorthand, and improves error messaging across multiple commands.

Changes

Project Management Backlog & Evidence

Layer / File(s) Summary
Chore and Feature Audit Records
.agents/pm/chores/pm-5k2w.toon, .agents/pm/features/pm-rnpb.toon
Updated chore metadata with test evidence, acceptance criteria, and file/command coverage; added feature audit block documenting manual dogfood pass status and deadline.
Task History and Release Gate Evidence
.agents/pm/history/pm-5k2w.jsonl, .agents/pm/history/pm-rnpb.jsonl
Appended task history entries documenting claim, in-progress status, file/test tracking, release gate execution with telemetry thresholds, and final release/open status transitions.

CLI Features & Improvements

Layer / File(s) Summary
Telemetry PM_NO_TELEMETRY Support
src/core/telemetry/runtime.ts, src/cli/commands/health.ts, tests/unit/telemetry-runtime.spec.ts, tests/unit/health-command.spec.ts
Added PM_NO_TELEMETRY environment variable constant and extended telemetry disabling logic to recognize it; updated health command to report the flag state and include it in env_overrides; added comprehensive test coverage including lifecycle management and disabling verification.
Calendar Command Positional View Argument
packages/pm-calendar/extensions/calendar/index.js, packages/pm-calendar/extensions/calendar/index.ts
Added optional positional view argument declaration to calendar command in both TypeScript and JavaScript, with argument parsing/validation logic that extracts positional view from args[0] (when not a flag), validates at most one positional, and conditionally merges into options only when view is not already set.
Close Command Active Children Validation
src/cli/commands/close.ts, tests/unit/close-command.spec.ts
Implemented active child detection and validation for close command: added helper to list non-terminal children filtered by parent ID, compute activeChildIds when validation is enabled, and enforce strict/warning modes based on validation setting; updated test harness to support parent field and added test case verifying warning behavior.
Extension Contract Schema Merging and Deduplication
src/sdk/cli-contracts.ts, src/cli/commands/contracts.ts, tests/unit/contracts-command.spec.ts
Extended CliFlagContract with metadata fields (description, required, repeatable, value_name, value_type); updated toExtensionFlagContract to populate these fields with fallback logic; enhanced buildExtensionActionSchemaBranch to derive JSON schema types from flag.value_type and mark required properties; introduced mergeExtensionContractsByAction to consolidate contracts sharing the same action by deduplicating flags, merging examples/hints, and combining command names into pipe-delimited strings; updated runContracts to apply merging before schema generation and populate x-extension-commands; added comprehensive test coverage including assertion tightening for flag metadata and new deduplication test.
Config Command Optional Arguments and Shorthand
src/cli/register-setup.ts
Changed pm config argument definitions from required <scope> and <action> to optional [scope] and [action]; updated handler to support action shorthand (get|set|list|export) when provided in scope position, defaulting missing scope to "project" and missing action to "list", then passing resolved values to runConfig.
Error Messages and Minor Command Improvements
src/cli/commands/update.ts, src/cli/commands/gc.ts, src/cli/main.ts, tests/unit/gc-command.spec.ts, tests/unit/update-command.spec.ts
Enhanced ensureEnum error message to include allowed values; updated gc guidance to recommend pm install search-advanced when reindex unavailable; updated dynamic extension command action handler to use variadic parameters and infer command from last argument; updated test expectations for gc guidance and added validation test for update command enum values.

Sequence Diagrams

sequenceDiagram
  participant Process as Process Environment
  participant Runtime as telemetry/runtime.ts
  participant Health as commands/health.ts
  participant Telemetry as Telemetry System
  Process->>Runtime: PM_NO_TELEMETRY set
  Runtime->>Runtime: telemetryDisabledByEnvironment checks env
  Runtime-->>Telemetry: disables collection
  Runtime-->>Health: reports env_overrides
  Health-->>Process: exposes pm_no_telemetry flag state
Loading
sequenceDiagram
  participant ExtCmd as Extension Commands
  participant ToContract as toExtensionFlagContract
  participant Merge as mergeExtensionContractsByAction
  participant BuildBranch as buildExtensionActionSchemaBranch
  participant Output as Schema Output
  ExtCmd->>ToContract: flag metadata
  ToContract-->>Merge: CliFlagContract with description/required/value_type
  Merge->>Merge: group by action, dedupe flags
  Merge-->>BuildBranch: merged contracts (pipe-delimited commands)
  BuildBranch->>BuildBranch: compute JSON schema types from flag.value_type
  BuildBranch-->>Output: schema branch with x-extension-commands
Loading

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 '[codex] Improve agent UX from manual pm audit' clearly summarizes the main objective of the changeset—improving CLI user experience based on manual audit findings.
Description check ✅ Passed The description comprehensively details the changes made, validation performed, and context for the improvements, demonstrating clear relationship to the changeset.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

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 introduces several CLI improvements, including positional view arguments for the calendar command, validation to prevent closing items with active children, and a shorthand for project-scoped configuration. It also enhances the extension contract system with richer flag metadata and deduplication logic. Review feedback highlighted a missing import for isTerminal in the close command and identified logic errors in the merging of extension command aliases, which could lead to duplicate entries in the generated schema.

Comment thread src/cli/commands/close.ts
@@ -1,10 +1,11 @@
import { pathExists } from "../../core/fs/fs-utils.js";
import { normalizeStatusInput } from "../../core/item/status.js";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The isTerminal function is used in findActiveChildIds (line 96) but is not imported in this file. It should be imported from ../../core/item/status.js along with normalizeStatusInput.

Suggested change
import { normalizeStatusInput } from "../../core/item/status.js";
import { isTerminal, normalizeStatusInput } from "../../core/item/status.js";

Comment thread src/cli/commands/contracts.ts Outdated
additionalProperties: true,
"x-extension-source": contract.source,
"x-extension-command": contract.command,
"x-extension-commands": [contract.command],
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

The x-extension-commands field should be an array of individual command names. Since contract.command can be a pipe-separated string (especially after the merge logic introduced in this PR), it should be split here. This also allows for simplifying the caller logic in runContracts.

Suggested change
"x-extension-commands": [contract.command],
"x-extension-commands": contract.command.split("|"),

Comment on lines +798 to +800
existing.command = [...new Set([existing.command, contract.command])]
.sort((left, right) => left.localeCompare(right))
.join("|");
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

The deduplication logic for existing.command is incorrect when merging multiple contracts. Since existing.command or contract.command might already be a pipe-separated string (e.g., from a previous merge), simply putting them into a Set will result in duplicates like "a|b|a". You should split the strings before deduplicating.

Suggested change
existing.command = [...new Set([existing.command, contract.command])]
.sort((left, right) => left.localeCompare(right))
.join("|");
existing.command = [...new Set([...existing.command.split("|"), ...contract.command.split("|")])]
.sort((left, right) => left.localeCompare(right))
.join("|");

Comment thread src/cli/commands/contracts.ts Outdated
Comment on lines +1556 to +1560
.map((contract) => {
const branch = buildExtensionActionSchemaBranch(contract);
branch["x-extension-commands"] = contract.command.split("|");
return branch;
});
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

With the fix to buildExtensionActionSchemaBranch to handle command splitting internally, this manual assignment and the multi-line map block become redundant. You can revert this to a concise single-line map.

    .map((contract) => buildExtensionActionSchemaBranch(contract));

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 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 @.agents/pm/chores/pm-5k2w.toon:
- Around line 9-43: This change illegally edits the system-of-record file
.agents/pm/chores/pm-5k2w.toon; revert the manual edits and regenerate the chore
via the official pm workflow/commands (use the pm CLI/operations that produce
the chore output tied to parent id pm-rnpb), then commit only the generated
artifacts that the pm workflow permits; do not directly modify any files under
.agents/pm/** — locate the chore by its filename
(.agents/pm/chores/pm-5k2w.toon) and parent reference (pm-rnpb) and run the pm
regeneration pipeline to produce an approved update.

In @.agents/pm/history/pm-rnpb.jsonl:
- Around line 419-424: This change directly edits system-of-record `.agents/pm`
history entries by applying JSON patch ops (replace/remove/add) to metadata
fields (e.g., metadata.assignee, metadata.updated_at and metadata.comments) —
revert these edits in pm-rnpb.jsonl and instead perform the same state
transitions through the pm workflow/commands (use the pm CLI or automation to
claim/release and add comments) so that the repository file is not edited
directly; specifically undo the applied patch operations (the add/replace/remove
of metadata.comments, metadata.assignee, metadata.updated_at) and re-apply the
intended claim/comment/release actions via the pm process.

In `@src/cli/commands/contracts.ts`:
- Around line 1554-1560: Validation is using unmerged extension contracts so
aliases get rejected; update the command/action validation to use the merged
results from mergeExtensionContractsByAction (or the derived extensionBranches
built by buildExtensionActionSchemaBranch) instead of the original
extensionContracts, and when matching a selected command against an action split
the stored command string into aliases (contract.command.split("|") /
extensionBranches["x-extension-commands"]) so the check is alias-aware; ensure
schemaActionSet logic still prevents duplicate actions but command matching uses
the merged alias list.
- Around line 524-529: The current fallback assigns rawValueType from
definition.value_type, definition.type, or valueName but doesn't validate that
definition.type is one of the allowed primitives, causing invalid types like
"integer" to block the valueName -> "string" fallback; change the logic around
rawValueType to validate each candidate in order (check
toOptionalTrimmedString(definition.value_type) first and accept it only if it's
"string"|"number"|"boolean", otherwise check
toOptionalTrimmedString(definition.type) and accept it only if it's one of those
three, and only if neither candidate is valid use valueName ? "string" : null),
then set contract.value_type from that validated rawValueType.

In `@src/cli/register-setup.ts`:
- Around line 401-407: The shorthand parsing moves an action into scope but
doesn't shift the subsequent arguments, so when scope matches actionShorthands
(see actionShorthands, resolvedScope, resolvedAction) the original key argument
must be pulled from the next positional parameter; update the resolution logic
before calling runConfig to set key = scope && actionShorthands.has(scope) ?
action : key (or equivalent) so runConfig(resolvedScope, resolvedAction, key,
...) receives the correct third argument when using the shorthand syntax.
🪄 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: CHILL

Plan: Pro

Run ID: 656b663b-12bd-437c-add4-772e443f3833

📥 Commits

Reviewing files that changed from the base of the PR and between cf3ef6f and 5d67eb2.

📒 Files selected for processing (21)
  • .agents/pm/chores/pm-5k2w.toon
  • .agents/pm/features/pm-rnpb.toon
  • .agents/pm/history/pm-5k2w.jsonl
  • .agents/pm/history/pm-rnpb.jsonl
  • packages/pm-calendar/extensions/calendar/index.js
  • packages/pm-calendar/extensions/calendar/index.ts
  • src/cli/commands/close.ts
  • src/cli/commands/contracts.ts
  • src/cli/commands/gc.ts
  • src/cli/commands/health.ts
  • src/cli/commands/update.ts
  • src/cli/main.ts
  • src/cli/register-setup.ts
  • src/core/telemetry/runtime.ts
  • src/sdk/cli-contracts.ts
  • tests/unit/close-command.spec.ts
  • tests/unit/contracts-command.spec.ts
  • tests/unit/gc-command.spec.ts
  • tests/unit/health-command.spec.ts
  • tests/unit/telemetry-runtime.spec.ts
  • tests/unit/update-command.spec.ts

Comment thread .agents/pm/chores/pm-5k2w.toon Outdated
Comment on lines +9 to +43
updated_at: "2026-05-21T04:42:31.292Z"
author: claude-code-agent
acceptance_criteria: Each listed sub-item is either fixed with a regression test or explicitly declined with rationale; no change drops coverage below 100%; doc/validator drift (L6) resolved; default-safety inconsistencies (L10) reviewed.
parent: pm-rnpb
comments[3]{created_at,author,text}:
"2026-05-21T04:30:32.081Z",codex-full-manual-audit,"Evidence: focused manual smoke passed config list shorthand, cal week positional view, close active-child warning, gc reindex install guidance, and PM_NO_TELEMETRY health reporting. Local checks passed so far: pnpm build; focused 7-file suite 37 tests after calendar runtime fix and 6-file suite 129 tests before that; pnpm quality:static; node scripts/check-secrets.mjs."
"2026-05-21T04:40:05.493Z",codex-full-manual-audit,"Evidence: full release gate passed after stale GC expectation update. Passed build, typecheck, docs-skills, static quality, coverage 96 files / 1399 tests at 100 percent, version policy, secret scan, npx packed smoke, package-first dogfood 84 workflows, npm pack dry-run, compatibility, and required Sentry/telemetry gate with Sentry critical=0 high=1 and telemetry finish_error_rate_pct=2.71."
"2026-05-21T04:42:28.101Z",codex-full-manual-audit,"Pause evidence: focused subset fixed and release-gated. Fixed config list shorthand, calendar positional view handling, GC missing-reindex guidance, PM_NO_TELEMETRY opt-out reporting/runtime, invalid dependency kind recovery, close active-child warning, and extension contract metadata/alias dedupe. Remaining backlog items on this chore stay open: init verbosity, help alias display bloat, create changed_fields noise, calendar include scheduled doc drift, guide install hints, priority wording drift, template starter content, broader default-safety review, and event equal-timestamp hinting. Full gate passed with run-gates telemetry-mode required and 100% selected coverage."
files[19]{path,scope,note}:
packages/pm-calendar/extensions/calendar/index.js,project,compiled calendar package entry kept in sync
packages/pm-calendar/extensions/calendar/index.ts,project,calendar positional view support
src/cli/commands/close.ts,project,close validation warns on active children
src/cli/commands/contracts.ts,project,extension action schema aliases and flag metadata
src/cli/commands/gc.ts,project,gc reindex install guidance
src/cli/commands/health.ts,project,health reports PM_NO_TELEMETRY alias
src/cli/commands/update.ts,project,dependency kind recovery lists allowed values
src/cli/main.ts,project,dynamic extension command action arg handling
src/cli/register-setup.ts,project,config action shorthand for agent UX
src/core/telemetry/runtime.ts,project,PM_NO_TELEMETRY opt-out alias
src/sdk/cli-contracts.ts,project,extension flag contract metadata
tests/unit/builtin-extension-entrypoints.spec.ts,project,Built-in extension entrypoint smoke coverage
tests/unit/calendar-command.spec.ts,project,Calendar positional view smoke coverage
tests/unit/close-command.spec.ts,project,Regression test for active-child close warning
tests/unit/contracts-command.spec.ts,project,Regression tests for extension contract metadata and alias dedupe
tests/unit/gc-command.spec.ts,project,gc guidance regression coverage
tests/unit/health-command.spec.ts,project,Regression test for telemetry env override reporting
tests/unit/telemetry-runtime.spec.ts,project,Regression test for PM_NO_TELEMETRY opt-out
tests/unit/update-command.spec.ts,project,Regression test for dependency kind guidance
tests[6]{command,path,scope,timeout_seconds,pm_context_mode,env_set,env_clear,shared_host_safe,assert_stdout_contains,assert_stdout_regex,assert_stderr_contains,assert_stderr_regex,assert_stdout_min_lines,assert_json_field_equals,assert_json_field_gte,note}:
node scripts/check-secrets.mjs,null,project,120,null,null,null,null,null,null,null,null,null,null,null,null
node scripts/release/run-gates.mjs --telemetry-mode required --max-sentry-critical 10 --max-sentry-high 20 --max-telemetry-error-rate 10 --json,null,project,420,null,null,null,null,null,null,null,null,null,null,null,null
PM_RUN_TESTS_SKIP_BUILD=1 node scripts/run-tests.mjs test -- tests/unit/contracts-command.spec.ts tests/unit/health-command.spec.ts tests/unit/telemetry-runtime.spec.ts tests/unit/update-command.spec.ts tests/unit/close-command.spec.ts tests/unit/calendar-command.spec.ts tests/unit/builtin-extension-entrypoints.spec.ts --reporter=dot,null,project,180,null,null,null,null,null,null,null,null,null,null,null,null
PM_RUN_TESTS_SKIP_BUILD=1 node scripts/run-tests.mjs test -- tests/unit/gc-command.spec.ts tests/unit/calendar-command.spec.ts --reporter=dot,null,project,120,null,null,null,null,null,null,null,null,null,null,null,null
pnpm build,null,project,120,null,null,null,null,null,null,null,null,null,null,null,null
"pnpm quality:static",null,project,120,null,null,null,null,null,null,null,null,null,null,null,null
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Blocked: direct edits to pm system-of-record files

This change directly edits .agents/pm/chores/pm-5k2w.toon. Please move these updates through the pm workflow/commands instead of committing direct file edits (e.g., regenerate records via pm operations, then commit resulting artifacts only if that workflow permits it).

As per coding guidelines, .agents/pm/**: pm is the system of record. Do not edit .agents/pm files directly.

🤖 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 @.agents/pm/chores/pm-5k2w.toon around lines 9 - 43, This change illegally
edits the system-of-record file .agents/pm/chores/pm-5k2w.toon; revert the
manual edits and regenerate the chore via the official pm workflow/commands (use
the pm CLI/operations that produce the chore output tied to parent id pm-rnpb),
then commit only the generated artifacts that the pm workflow permits; do not
directly modify any files under .agents/pm/** — locate the chore by its filename
(.agents/pm/chores/pm-5k2w.toon) and parent reference (pm-rnpb) and run the pm
regeneration pipeline to produce an approved update.

Comment on lines +419 to +424
{"ts":"2026-05-21T04:10:57.898Z","author":"codex-full-manual-audit","op":"claim","patch":[{"op":"replace","path":"/metadata/assignee","value":"codex-full-manual-audit"},{"op":"replace","path":"/metadata/updated_at","value":"2026-05-21T04:10:57.898Z"}],"before_hash":"30796ce302702e59341965498e3172f4043864d1251ec049573f392b5e5968f6","after_hash":"5e91b390a1b9c6967b7b490415564b6a1ea8cbc4f499258d97bb6a70d717d735"}
{"ts":"2026-05-21T04:11:00.194Z","author":"codex-full-manual-audit","op":"comment_add","patch":[{"op":"add","path":"/metadata/comments/155","value":{"created_at":"2026-05-21T04:11:00.194Z","author":"codex-full-manual-audit","text":"Investigation note: Reusing existing canonical audit item after duplicate check. Scope covers full latest-build manual temp-project dogfood, CLI/SDK/calendar/search/performance/security/CI review, GitHub issue/PR/dependency review, telemetry/Sentry analysis, and targeted fixes discovered during the run."}},{"op":"replace","path":"/metadata/updated_at","value":"2026-05-21T04:11:00.194Z"}],"before_hash":"5e91b390a1b9c6967b7b490415564b6a1ea8cbc4f499258d97bb6a70d717d735","after_hash":"7e8b173524da7f9af4816265f23c608168a0c242aa019957b47c88c8f76d9a27"}
{"ts":"2026-05-21T04:17:16.756Z","author":"codex-full-manual-audit","op":"comment_add","patch":[{"op":"add","path":"/metadata/comments/156","value":{"created_at":"2026-05-21T04:17:16.756Z","author":"codex-full-manual-audit","text":"Sub-agent/manual audit findings mapped without duplicate items: reuse pm-5k2w for config/calendar/telemetry/dependency/gc polish, pm-59gj for multi-package install/catalog UX, pm-rnpb for semantic provider staleness and auto-index provider parity, pm-orrl for blocked-by semantics, pm-nbht for health brevity, and pm-gt82/pm-mbdu for startup and large-file follow-ups."}},{"op":"replace","path":"/metadata/updated_at","value":"2026-05-21T04:17:16.756Z"}],"before_hash":"7e8b173524da7f9af4816265f23c608168a0c242aa019957b47c88c8f76d9a27","after_hash":"a5dc529e78b7a274c7a8cba1ac06ba14ec119c2112b57d3541ec5ec2b53c2907"}
{"ts":"2026-05-21T04:40:06.326Z","author":"codex-full-manual-audit","op":"comment_add","patch":[{"op":"add","path":"/metadata/comments/157","value":{"created_at":"2026-05-21T04:40:06.326Z","author":"codex-full-manual-audit","text":"Evidence: latest sub-agent/manual audit and fixes completed under pm-5k2w. Dogfood passed normal 84 workflows and semantic 86 workflows using qwen3-embedding:0.6b; release gate passed with coverage 96 files / 1399 tests at 100 percent and required Sentry/telemetry gate. Residual performance/coverage breadth/semantic provider-staleness findings remain mapped to existing pm-rnpb/pm-gt82/pm-mbdu/pm-59gj follow-ups, not duplicated."}},{"op":"replace","path":"/metadata/updated_at","value":"2026-05-21T04:40:06.326Z"}],"before_hash":"a5dc529e78b7a274c7a8cba1ac06ba14ec119c2112b57d3541ec5ec2b53c2907","after_hash":"8d3151783bec6150d9703bde1d6fcefc4e0e4db1933448b42f2db708fe9899a3"}
{"ts":"2026-05-21T04:42:32.110Z","author":"codex-full-manual-audit","op":"comment_add","patch":[{"op":"add","path":"/metadata/comments/158","value":{"created_at":"2026-05-21T04:42:32.110Z","author":"codex-full-manual-audit","text":"Audit closeout evidence: broad manual dogfood and sub-agent review completed for this slice. Local release gate passed with telemetry required, package-first dogfood passed including semantic qwen Ollama mode, Sentry/telemetry gate passed against current baseline, GitHub issue/PR/vulnerability scan found no open actionable GitHub items. Residuals remain tracked under existing lineage: broader read-path performance, semantic provider staleness/auto-index parity, CI duration reduction beyond current selected coverage gate, and telemetry queue backlog investigation."}},{"op":"replace","path":"/metadata/updated_at","value":"2026-05-21T04:42:32.110Z"}],"before_hash":"8d3151783bec6150d9703bde1d6fcefc4e0e4db1933448b42f2db708fe9899a3","after_hash":"e517f235a79c56993d9b37491d2aea0e5db9acfd15af3484b6463de782d66197"}
{"ts":"2026-05-21T04:42:33.995Z","author":"codex-full-manual-audit","op":"release","patch":[{"op":"remove","path":"/metadata/assignee"},{"op":"replace","path":"/metadata/updated_at","value":"2026-05-21T04:42:33.995Z"}],"before_hash":"e517f235a79c56993d9b37491d2aea0e5db9acfd15af3484b6463de782d66197","after_hash":"7bb74c15805433c505e385db88b4ed37dc5ba9be420eaf75a24683a4498f38e1"}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Do not directly edit .agents/pm history records.

Lines 419-424 directly modify .agents/pm/history/pm-rnpb.jsonl, which violates the repository rule for system-of-record data. Please apply these state transitions through the pm workflow/commands instead of committing file edits.

As per coding guidelines .agents/pm/**: pm is the system of record. Do not edit .agents/pm files directly.

🤖 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 @.agents/pm/history/pm-rnpb.jsonl around lines 419 - 424, This change
directly edits system-of-record `.agents/pm` history entries by applying JSON
patch ops (replace/remove/add) to metadata fields (e.g., metadata.assignee,
metadata.updated_at and metadata.comments) — revert these edits in pm-rnpb.jsonl
and instead perform the same state transitions through the pm workflow/commands
(use the pm CLI or automation to claim/release and add comments) so that the
repository file is not edited directly; specifically undo the applied patch
operations (the add/replace/remove of metadata.comments, metadata.assignee,
metadata.updated_at) and re-apply the intended claim/comment/release actions via
the pm process.

Comment thread src/cli/commands/contracts.ts Outdated
Comment thread src/cli/commands/contracts.ts Outdated
Comment thread src/cli/register-setup.ts Outdated
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • In mergeExtensionContractsByAction, flags are deduplicated solely by flag.flag|flag.short, so if two commands define the same flag name with differing descriptions/required/value_type metadata, one copy’s richer metadata may be silently discarded; consider either validating consistency between merged flags or explicitly defining which source takes precedence so that extension authors get predictable results.
  • The handling of PM_NO_TELEMETRY is now duplicated between telemetryDisabledByEnvironment in src/core/telemetry/runtime.ts and telemetryEnvFlagEnabled consumers in health.ts; it may be worth centralizing this environment flag resolution in a single helper to avoid drift if semantics around PM_NO_TELEMETRY change in the future.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `mergeExtensionContractsByAction`, flags are deduplicated solely by `flag.flag|flag.short`, so if two commands define the same flag name with differing descriptions/required/value_type metadata, one copy’s richer metadata may be silently discarded; consider either validating consistency between merged flags or explicitly defining which source takes precedence so that extension authors get predictable results.
- The handling of `PM_NO_TELEMETRY` is now duplicated between `telemetryDisabledByEnvironment` in `src/core/telemetry/runtime.ts` and `telemetryEnvFlagEnabled` consumers in `health.ts`; it may be worth centralizing this environment flag resolution in a single helper to avoid drift if semantics around `PM_NO_TELEMETRY` change in the future.

## Individual Comments

### Comment 1
<location path="src/cli/commands/contracts.ts" line_range="772" />
<code_context>
     additionalProperties: true,
     "x-extension-source": contract.source,
     "x-extension-command": contract.command,
+    "x-extension-commands": [contract.command],
   };
 }
</code_context>
<issue_to_address>
**suggestion:** Keep `x-extension-command` consistent with the new multi-command merge behavior.

After `mergeExtensionContractsByAction`, `contract.command` can be a `|`-joined list. `buildExtensionActionSchemaBranch` copies this into both `"x-extension-command"` and `"x-extension-commands"`, and later `runContracts` converts only `"x-extension-commands"` to an array, leaving `"x-extension-command"` as the joined string.

To avoid ambiguous semantics for consumers, consider either deriving `"x-extension-command"` from the split array (e.g., first element), removing `"x-extension-command"` in favor of `"x-extension-commands"`, or explicitly documenting that `"x-extension-command"` may be `|`-delimited.

```suggestion
  const commands =
    typeof contract.command === "string"
      ? contract.command
          .split("|")
          .map((cmd) => cmd.trim())
          .filter((cmd) => cmd.length > 0)
      : Array.isArray(contract.command)
      ? contract.command
      : [];

  return {
    additionalProperties: true,
    "x-extension-source": contract.source,
    "x-extension-command": commands[0],
    "x-extension-commands": commands,
  };
```
</issue_to_address>

### Comment 2
<location path="tests/unit/health-command.spec.ts" line_range="127-130" />
<code_context>
           attempted: false,
         },
         env_overrides: {
-          telemetry_disabled: telemetryEnvFlagEnabled("PM_TELEMETRY_DISABLED"),
+          telemetry_disabled: telemetryEnvFlagEnabled("PM_TELEMETRY_DISABLED") || telemetryEnvFlagEnabled("PM_NO_TELEMETRY"),
</code_context>
<issue_to_address>
**suggestion (testing):** Add a health check test case where PM_NO_TELEMETRY is the sole disabling flag

To cover this path, please add a test where `PM_NO_TELEMETRY` is set while `PM_TELEMETRY_DISABLED` and `PM_TELEMETRY_OTEL_DISABLED` are unset, and assert: `env_overrides.telemetry_disabled === true`, `env_overrides.pm_no_telemetry === true`, and `env_overrides.telemetry_otel_disabled === false`. This confirms `PM_NO_TELEMETRY` alone disables telemetry and is reported distinctly from the other flags in the health output.
</issue_to_address>

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.

Comment thread src/cli/commands/contracts.ts
Comment on lines 127 to 130
env_overrides: {
telemetry_disabled: true,
pm_no_telemetry: false,
telemetry_otel_disabled: true,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (testing): Add a health check test case where PM_NO_TELEMETRY is the sole disabling flag

To cover this path, please add a test where PM_NO_TELEMETRY is set while PM_TELEMETRY_DISABLED and PM_TELEMETRY_OTEL_DISABLED are unset, and assert: env_overrides.telemetry_disabled === true, env_overrides.pm_no_telemetry === true, and env_overrides.telemetry_otel_disabled === false. This confirms PM_NO_TELEMETRY alone disables telemetry and is reported distinctly from the other flags in the health output.

unbraind added 2 commits May 21, 2026 07:03
Fix config shorthand key shifting, validate extension flag value_type fallbacks before using valueName defaults, make merged extension command metadata deterministic, merge duplicate flag metadata predictably, and cover PM_NO_TELEMETRY health reporting.

Verification: pnpm exec tsc --noEmit -p tsconfig.json; PM_RUN_TESTS_SKIP_BUILD=1 node scripts/run-tests.mjs test -- tests/unit/contracts-command.spec.ts tests/unit/health-command.spec.ts tests/integration/cli.integration.spec.ts -t "extension|PM_NO_TELEMETRY|config" --reporter=dot.
Split merged extension command aliases when matching selected commands, deriving scoped command names, and resolving runtime availability. This keeps schema dedupe while preserving invocability for aliases like cal/calendar and package-provided action commands.

Verification: pnpm exec tsc --noEmit -p tsconfig.json; PM_RUN_TESTS_SKIP_BUILD=1 node scripts/run-tests.mjs test -- tests/unit/calendar-command.spec.ts tests/unit/contracts-command.spec.ts tests/unit/health-command.spec.ts --reporter=dot; node scripts/dogfood-package-first.mjs.
@unbraind unbraind merged commit 375b697 into main May 21, 2026
10 checks passed
@unbraind unbraind deleted the codex/manual-agent-ux-audit-2026-05-21 branch May 21, 2026 05:20
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