Skip to content

SDK atomic structured mutations, lean output, and agent-first envelopes - #624

Merged
unbraind merged 6 commits into
mainfrom
feat/sdk-atomic-structured-io
Jul 20, 2026
Merged

unbraind merged 6 commits into
mainfrom
feat/sdk-atomic-structured-io

Conversation

@unbraind

@unbraind unbraind commented Jul 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

This wide SDK/CLI platform change makes structured, token-efficient project mutations a first-class primitive across CLI and MCP:

  • adds SDK-backed atomic JSON create/update/close batches through pm item mutate and pm_mutate, including dry-run, idempotent resume, compensation, and shared transport validation
  • adds full-item JSON stdin round trips for pm create and pm update, with explicit-flag precedence, facet safety, persisted-annotation deduplication, and custom-field extensibility
  • makes compact mutation envelopes the default while retaining explicit full and id-only compatibility modes
  • adds lean structured output and actionable lean error envelopes
  • promotes shared runtime/error/structured-input primitives into the public SDK and documents package-author usage
  • updates runtime contracts, MCP schemas, token budgets, generated changelog, and broad unit/integration acceptance coverage

PM items

Verification

  • full repository coverage: 322 files, 6,014 tests, exact 100% statements / branches / functions / lines
  • ESLint, jscpd, typecheck, build, contracts snapshot, docs links, SDK import boundary, token-budget, secret, and strict 100% docstring gates pass
  • latest pm-changelog (2026.7.18) generated CHANGELOG.md; reproducibility check passes
  • packed npx smoke passes; installed SDK import and isolated CLI/MCP mutation workflows pass in a temporary workspace
  • measured packed reductions: list 52.57%, context 35.42%, combined 41.06%, compact create response 87.82%
  • three local Greptile rounds completed; all actionable findings fixed; final review confidence 5/5 with no comments

Summary by cubic

Ships SDK-backed atomic structured mutations across CLI and MCP, makes compact mutation envelopes the default, and adds lean JSON/error modes to cut tokens. Also hardens runtime with a serialized, reentrant extension-activation scope and stricter input validation.

  • New Features

  • Migration

    • Scripts expecting the full mutation envelope or changed_fields must pass --full or --full-changed-fields, or read id from the compact result.
    • If you relied on verbose JSON error fields, avoid --lean for errors; lean error envelopes only apply when you opt in with --lean.

Written for commit 9838309. Summary will update on new commits.

Review in cubic

Deliver SDK-backed atomic JSON mutation batches across CLI and MCP, whole-item stdin round trips, lean structured projections, actionable errors, and compact mutation defaults. Export public runtime primitives, update contracts/docs/token budgets, preserve compatibility, and add comprehensive unit/integration coverage plus PM evidence and generated changelog.

@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, your pull request is larger than the review limit of 150000 diff characters

@unbraind

Copy link
Copy Markdown
Owner Author

@greptileai please review the full current head, including the shared SDK control validation and structured CLI/MCP parity.

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.


Your plan includes PR reviews subject to rate limits. More reviews will be available in 59 minutes.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds lean JSON/error output, compact mutation envelopes, full-item stdin JSON for create/update, atomic heterogeneous mutation batches across CLI and MCP, shared SDK parsing/runtime exports, updated contracts and documentation, and extensive unit/integration coverage.

Changes

Lean output and mutation projections

Layer / File(s) Summary
Lean JSON and error shaping
src/cli/*, src/core/output/*, src/sdk/cli-bootstrap.ts, src/sdk/cli-program.ts
Adds --lean, recursive JSON compaction, lean structured errors, and legacy --full-changed-fields compatibility.
Compact mutation envelopes
src/core/output/*
Mutation output defaults to id, status, and changed_field_count, while preserving full delta output through compatibility flags.

Structured mutation workflows

Layer / File(s) Summary
SDK parsing and document conversion
src/sdk/structured-mutations.ts, src/sdk/runtime-primitives.ts, src/sdk/index.ts
Validates mutation batches and atomic controls, suggests corrections for unknown keys, and converts full item or get-envelope JSON into mutation options.
CLI and MCP adapters
src/cli/register-structured-mutation.ts, src/cli/register-mutation.ts, src/mcp/server.ts, src/mcp/tool-definitions.ts
Adds pm item mutate, pm_mutate, dry-run handling, transaction controls, and full-item --stdin-json create/update flows.

Contracts, docs, and validation

Layer / File(s) Summary
Command and tool contracts
src/sdk/cli-contracts/*, src/cli/commands/contracts.ts, tests/fixtures/contracts/full.json
Registers new flags, commands, and the pm_mutate MCP schema.
Documentation and test coverage
docs/*, CHANGELOG.md, tests/unit/*, tests/integration/*
Documents the new input/output surfaces and validates CLI, SDK, MCP, lean output, round trips, previews, resumes, and error handling.

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

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant CLI_or_MCP
  participant StructuredMutations
  participant CommitItemMutations
  Client->>CLI_or_MCP: Submit transaction ID and mutation JSON
  CLI_or_MCP->>StructuredMutations: Validate rows and atomic controls
  StructuredMutations-->>CLI_or_MCP: Normalized mutations
  CLI_or_MCP->>CommitItemMutations: Commit or preview batch
  CommitItemMutations-->>CLI_or_MCP: Mutation result
  CLI_or_MCP-->>Client: Compact result with mutation count
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.33% 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 concisely captures the main changes: structured mutations, lean output, and compact/agent-first envelopes.
Description check ✅ Passed The description matches the changeset and summarizes the CLI, SDK, MCP, contracts, and test updates accurately.
✨ 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.

@codspeed

codspeed Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 0.03%

⚡ 5 improved benchmarks
❌ 5 regressed benchmarks
✅ 1 untouched benchmark

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ createQueryFingerprint 513 µs 514.2 µs -0.22%
❌ encodeQueryCursor 101.1 µs 101.2 µs -0.09%
❌ stableStringify (nested contract) 161.1 µs 161.2 µs -0.07%
❌ jaccardSimilarity 153.4 µs 153.4 µs 0%
❌ tokenize + score query over 2000 docs 7.5 ms 7.5 ms 0%
⚡ build index (200 docs x 40 words) 8.4 ms 8.4 ms +0.02%
⚡ decodeQueryCursor 116 µs 116 µs +0.02%
⚡ tokenizeAlphaNumeric 367.4 µs 367.3 µs +0.01%
⚡ build index (2000 docs x 80 words) 161.4 ms 161.4 ms 0%
⚡ score query over 2000 docs 5.6 ms 5.6 ms 0%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing feat/sdk-atomic-structured-io (9838309) with main (0ec9389)

Open in CodSpeed

@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 introduces several significant features to the CLI, including a lean JSON output mode for reduced token usage, support for atomic batch mutations via pm item mutate, and stdin-based item creation/updates. It also includes error handling improvements with a lean error projection mode and various internal refactorings for better command registration and output formatting. My feedback focuses on a potential vulnerability in numeric input parsing where empty strings could be incorrectly coerced to zero.

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/sdk/structured-mutations.ts Resolved
@codecov

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

@greptile-apps

greptile-apps Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR adds structured mutation workflows and leaner machine-readable output across the CLI, MCP server, and SDK. The main changes are:

  • Atomic JSON create, update, and close batches through pm item mutate and pm_mutate.
  • Full-item JSON stdin round trips for pm create and pm update.
  • Compact mutation envelopes as the default, with opt-ins for full and id-only output.
  • Lean JSON output and lean structured error envelopes.
  • Public SDK exports for structured mutations, runtime primitives, and error normalization.
  • Updated MCP schemas, Claude plugin docs, token budgets, contracts, changelog, and test coverage.

Confidence Score: 5/5

This PR appears safe to merge based on the reviewed changed paths.

The key mutation, MCP, output, parsing, and error-runtime paths use shared validation and targeted tests. The previously reported active-extension and lock-control issues are addressed in the current changes. No new verified functional bugs were found.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • The dry-run lean output was captured in the structured_mutation_cli_transcript_v2.log, showing dry_run: true and mutation_count: 4.
  • The dry-run did not persist the item pm-trex-a, as shown in the transcript section covering the non-persistence behavior.
  • The committed batch output shows status: committed with recovered: false and includes compact per-step results, and the replay recovery section indicates recovered: true.
  • The persisted item state shows pm-trex-a open with updated description and tags, and pm-trex-b closed with close_reason: verified.
  • The focused structured mutation integration spec completed successfully: 1 file, 4 tests, exit code 0.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
src/sdk/structured-mutations.ts Adds strict parsing for atomic mutation batches and full-item stdin documents; previous lock validation findings are addressed.
src/mcp/server.ts Adds pm_mutate handling with shared validation and active extension scope before committing item mutations.
src/cli/register-structured-mutation.ts Registers pm item mutate stdin JSON batch flow with dry-run, transaction id enforcement, controls, and commit output.
src/cli/register-mutation.ts Adds full-item JSON stdin support for create/update and wires structured mutation command registration.
src/core/output/mutation-projection.ts Adds compact mutation envelope projection while preserving warnings and close reason fields.
src/core/output/output.ts Makes compact mutation envelopes the default and adds lean JSON pruning support.
src/core/item/parse.ts Preserves JSON tag arrays and JSON-quoted CSV facet values during parsing.
src/sdk/runtime.ts Updates SDK runtime mutation compaction behavior and exposes active extension execution support.
src/mcp/tool-definitions.ts Adds pm_mutate schema and documents compact mutation output controls across MCP tools.
tests/integration/structured-mutation-io.integration.spec.ts Adds integration coverage for CLI/MCP structured mutation IO and stdin round trips.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Agent as CLI/MCP agent
participant Adapter as pm item mutate / pm_mutate
participant Parser as structured-mutations SDK
participant Extensions as Active extension scope
participant Tx as commitItemMutations
participant Store as pm workspace/history

Agent->>Adapter: JSON mutation batch + transaction id
Adapter->>Parser: parse/validate rows and controls
alt dry run
    Parser-->>Adapter: normalized mutations
    Adapter-->>Agent: dry_run preview envelope
else commit
    Adapter->>Extensions: activate extension context
    Extensions->>Tx: commit create/update/close steps
    Tx->>Store: journal, apply steps, compensate on failure
    Store-->>Tx: committed transaction result
    Tx-->>Adapter: status, recovered, results
    Adapter-->>Agent: compact structured envelope
end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Agent as CLI/MCP agent
participant Adapter as pm item mutate / pm_mutate
participant Parser as structured-mutations SDK
participant Extensions as Active extension scope
participant Tx as commitItemMutations
participant Store as pm workspace/history

Agent->>Adapter: JSON mutation batch + transaction id
Adapter->>Parser: parse/validate rows and controls
alt dry run
    Parser-->>Adapter: normalized mutations
    Adapter-->>Agent: dry_run preview envelope
else commit
    Adapter->>Extensions: activate extension context
    Extensions->>Tx: commit create/update/close steps
    Tx->>Store: journal, apply steps, compensate on failure
    Store-->>Tx: committed transaction result
    Tx-->>Adapter: status, recovered, results
    Adapter-->>Agent: compact structured envelope
end
Loading

Reviews (8): Last reviewed commit: "fix(sdk): harden structured mutation ext..." | Re-trigger Greptile

Comment thread src/sdk/structured-mutations.ts Resolved
@greptile-apps

greptile-apps Bot commented Jul 20, 2026

Copy link
Copy Markdown

Greptile Summary

This PR makes structured item mutations and lean output first-class across the SDK, CLI, and MCP surfaces. The main changes are:

  • Adds atomic JSON create/update/close mutation batches through pm item mutate and pm_mutate.
  • Adds full-item JSON stdin round trips for pm create and pm update.
  • Makes compact mutation envelopes the default while keeping full and id-only modes.
  • Adds lean JSON output and lean structured error envelopes.
  • Promotes shared runtime, error, and structured-input primitives into the public SDK.
  • Updates contracts, docs, token budgets, generated tracker artifacts, and mutation coverage.

Confidence Score: 5/5

Safe to merge based on the reviewed changed paths.

No verified functional, security, or contract-breaking issues were found in the structured mutation parser, CLI/MCP adapters, output projection, lean error handling, or supporting tests.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • The integration proof run completed with Vitest, showing 4 passing tests and EXIT_CODE 0.
  • The CLI smoke proof ran the smoke script and reported EXIT_CODE 0 with the full observed JSON envelopes.
  • Per-command CLI traces for init, dry-run, commit, replay, update, close, and final get were captured, with JSON payloads and envelope summaries saved.
  • Artifacts were prepared to support review, including the integration log, the CLI smoke log, and per-command traces payloads and envelopes.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
src/sdk/structured-mutations.ts Adds strict JSON batch validation and item-document-to-mutation option conversion; no issues found.
src/cli/register-structured-mutation.ts Adds pm item mutate adapter for stdin batches, dry-run, controls, and SDK commits; no issues found.
src/cli/register-mutation.ts Adds --stdin-json create/update conversion and registers structured mutation commands; no issues found.
src/mcp/server.ts Adds pm_mutate MCP handler using shared validation and atomic SDK commits; no issues found.
src/mcp/tool-definitions.ts Adds the pm_mutate tool schema and updated instructions; no issues found.
src/core/output/output.ts Makes compact mutation envelopes the default and adds lean JSON compaction; no issues found.
src/core/output/mutation-projection.ts Adds compact mutation envelope projection while retaining full and id-only modes; no issues found.
src/cli/main.ts Wires public error runtime helpers and lean/global output controls through CLI error handling; no issues found.
src/cli/error-guidance.ts Adds lean error-envelope projection while preserving full guidance path; no issues found.
tests/integration/structured-mutation-io.integration.spec.ts Adds end-to-end coverage for structured mutation IO, dry-run, and stdin JSON flows; no issues found.
tests/unit/sdk/structured-mutations.spec.ts Covers strict parser, controls, and item-document normalization paths; no issues found.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Agent as Agent/CLI user
participant CLI as pm item mutate / pm create-update
participant MCP as pm_mutate tool
participant Parser as structured-mutations SDK
participant Tx as commitItemMutations
participant Store as pm workspace store

Agent->>CLI: JSON stdin batch or item document
CLI->>Parser: parseItemMutationBatch / itemDocumentToMutationOptions
Agent->>MCP: pm_mutate(transactionId, mutations)
MCP->>Parser: validateItemMutationRows + parse controls
Parser-->>CLI: normalized mutations/options
Parser-->>MCP: normalized mutations/options
CLI->>Tx: commitItemMutations(pmRoot, transactionId, author, mutations)
MCP->>Tx: commitItemMutations(pmRoot, transactionId, author, mutations)
Tx->>Store: apply create/update/close steps under transaction lock
Store-->>Tx: committed results or compensation outcome
Tx-->>CLI: transaction result + mutation_count
Tx-->>MCP: transaction result + mutation_count
CLI-->>Agent: compact/full/id-only/lean output envelope
MCP-->>Agent: structured mutation result
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Agent as Agent/CLI user
participant CLI as pm item mutate / pm create-update
participant MCP as pm_mutate tool
participant Parser as structured-mutations SDK
participant Tx as commitItemMutations
participant Store as pm workspace store

Agent->>CLI: JSON stdin batch or item document
CLI->>Parser: parseItemMutationBatch / itemDocumentToMutationOptions
Agent->>MCP: pm_mutate(transactionId, mutations)
MCP->>Parser: validateItemMutationRows + parse controls
Parser-->>CLI: normalized mutations/options
Parser-->>MCP: normalized mutations/options
CLI->>Tx: commitItemMutations(pmRoot, transactionId, author, mutations)
MCP->>Tx: commitItemMutations(pmRoot, transactionId, author, mutations)
Tx->>Store: apply create/update/close steps under transaction lock
Store-->>Tx: committed results or compensation outcome
Tx-->>CLI: transaction result + mutation_count
Tx-->>MCP: transaction result + mutation_count
CLI-->>Agent: compact/full/id-only/lean output envelope
MCP-->>Agent: structured mutation result
Loading

Reviews (2): Last reviewed commit: "feat(sdk): add atomic structured mutatio..." | Re-trigger Greptile

Update the Claude plugin inventory and documentation for the 30-tool MCP surface, including pm_mutate and pm_graph. Keep executable smoke code compatible with the repository's static import policy and record final pm-xm7c CI evidence and closeout state.

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

🤖 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/register-mutation.ts`:
- Around line 781-787: Update the stdin handling around
runCreateAction/runUpdateAction and the --stdin-json branch to prevent mixing
--stdin-json with any other stdin-based options, including --body, --dep,
--comment, --note, --learning, --file, --test, --doc, --reminder, --event,
--type-option, and --field. Reject the invocation with a clear error when more
than one stdin mode is requested, or reuse a single resolver throughout the full
command so stdin is consumed exactly once.

In `@src/core/output/mutation-projection.ts`:
- Around line 113-134: Update projectCompactMutationEnvelope to validate that
result.item.id is a string before constructing the compact envelope; return null
when it is missing or non-string so normal projection can handle the result,
matching projectIdOnlyResult’s guard.

In `@src/mcp/server.ts`:
- Around line 170-198: Normalize the committed response in pm_mutate to expose
the transaction identifier as transaction_id, matching the dry-run response and
the envelope’s snake_case convention. Map or remove the transactionId field from
commitItemMutations without changing the existing mutation_count or other result
fields.

In `@src/sdk/cli-bootstrap.ts`:
- Line 167: Update the CLI argument parsing around the existing --json and
--quiet handling in the while loop: introduce a local lean flag, set it only
when --lean is encountered before the -- separator, and use that parsed flag
instead of argv.includes("--lean") for the lean option.
🪄 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: 979e8215-cf47-4a8e-ae45-5942be5ee2f7

📥 Commits

Reviewing files that changed from the base of the PR and between 0ec9389 and 66f0003.

📒 Files selected for processing (60)
  • .agents/pm/extensions/.managed-extensions.json
  • .agents/pm/features/pm-cfed.toon
  • .agents/pm/features/pm-g9xk.toon
  • .agents/pm/features/pm-kipd.toon
  • .agents/pm/features/pm-nilh.toon
  • .agents/pm/features/pm-xm7c.toon
  • .agents/pm/history/pm-cfed.jsonl
  • .agents/pm/history/pm-ds3b.jsonl
  • .agents/pm/history/pm-g9xk.jsonl
  • .agents/pm/history/pm-kipd.jsonl
  • .agents/pm/history/pm-mfkv92.jsonl
  • .agents/pm/history/pm-nilh.jsonl
  • .agents/pm/history/pm-xm7c.jsonl
  • .agents/pm/issues/pm-mfkv92.toon
  • .agents/pm/tasks/pm-ds3b.toon
  • CHANGELOG.md
  • docs/COMMANDS.md
  • docs/SDK.md
  • scripts/release/token-budget-gate.mjs
  • scripts/release/token-budgets.json
  • src/cli/commander-usage.ts
  • src/cli/commands/contracts.ts
  • src/cli/error-guidance.ts
  • src/cli/main.ts
  • src/cli/register-mutation.ts
  • src/cli/register-structured-mutation.ts
  • src/cli/registration-helpers.ts
  • src/core/output/mutation-projection.ts
  • src/core/output/output.ts
  • src/core/shared/command-types.ts
  • src/mcp/server.ts
  • src/mcp/tool-definitions.ts
  • src/sdk/cli-bootstrap.ts
  • src/sdk/cli-contracts.ts
  • src/sdk/cli-contracts/enum-contracts.ts
  • src/sdk/cli-contracts/flag-contracts.ts
  • src/sdk/cli-program.ts
  • src/sdk/error-runtime.ts
  • src/sdk/index.ts
  • src/sdk/runtime-primitives.ts
  • src/sdk/structured-mutations.ts
  • tests/fixtures/contracts/full.json
  • tests/helpers/mcp-context-depth.ts
  • tests/helpers/withTempPmPath.ts
  • tests/integration/extension-startup.integration.spec.ts
  • tests/integration/governance-presets.integration.spec.ts
  • tests/integration/help-runtime.spec.ts
  • tests/integration/mcp-handshake.spec.ts
  • tests/integration/structured-mutation-io.integration.spec.ts
  • tests/integration/telemetry-otel-nonblocking.spec.ts
  • tests/unit/cli/bootstrap-args.spec.ts
  • tests/unit/cli/cli-main-errors.spec.ts
  • tests/unit/cli/error-handler-projection.spec.ts
  • tests/unit/cli/registration-helpers.spec.ts
  • tests/unit/cli/structured-mutation-registration.spec.ts
  • tests/unit/commands/completion-command.spec.ts
  • tests/unit/core/output/mutation-projection.spec.ts
  • tests/unit/core/output/output.spec.ts
  • tests/unit/scripts/release/token-budget-gate.spec.ts
  • tests/unit/sdk/structured-mutations.spec.ts

Comment thread src/cli/register-mutation.ts Resolved
Comment thread src/core/output/mutation-projection.ts Resolved
Comment thread src/mcp/server.ts Resolved
Comment thread src/sdk/cli-bootstrap.ts Resolved
Encode structured item facet values as JSON strings and decode them through the shared CSV parser while retaining legacy permissive behavior. Add coverage for multiline annotations, embedded quotes, backslashes, and the fallback path, then record the Greptile disposition and final tracker closeout.
@unbraind

Copy link
Copy Markdown
Owner Author

@greptileai please review the full current head after the CI contract and lossless multiline structured-facet fixes.

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.


Your plan includes PR reviews subject to rate limits. More reviews will be available in 19 minutes.

unbraind added 2 commits July 20, 2026 13:41
Regenerate the pm-changelog 2026.7.18 output after the concurrent v2026.7.20 tag publication and record the CI root cause in pm-xm7c.
Keep JSON tag arrays intact through stdin-json round trips, including tags containing commas, while retaining legacy CSV parsing. Normalize atomic batch identifiers and close reasons and record exact 100% coverage evidence.
@unbraind

Copy link
Copy Markdown
Owner Author

@greptileai please review the full current head after preserving structured tag-array identities and syncing the v2026.7.20 release window. The compact mutation envelope remains the intentional GH-437 behavior with --full-changed-fields compatibility.

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

Comment thread src/mcp/server.ts Resolved

@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

♻️ Duplicate comments (1)
src/core/output/mutation-projection.ts (1)

113-134: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Guard result.item.id type like the sibling projectIdOnlyResult.

projectIdOnlyResult explicitly checks typeof subject.id === "string" and returns null (falling back to normal projection) otherwise. projectCompactMutationEnvelope skips that check and assigns id: result.item.id unconditionally — if id is ever missing or non-string, the compact envelope silently drops the id key entirely (since JSON.stringify omits undefined), rather than falling back gracefully.

🩹 Proposed fix
 function projectCompactMutationEnvelope(result: unknown): unknown | null {
   if (!isPlainObject(result) || !isPlainObject(result.item)) return null;
   const changedFields = result[CHANGED_FIELDS_KEY];
   if (!Array.isArray(changedFields)) return null;
+  if (typeof result.item.id !== "string") return null;
   const compact: Record<string, unknown> = {
     id: result.item.id,
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/core/output/mutation-projection.ts` around lines 113 - 134, Update
projectCompactMutationEnvelope to validate result.item.id is a string before
constructing the compact envelope, returning null when it is missing or has
another type. Preserve the existing normal-projection fallback and leave the
remaining compact-field handling unchanged.
🤖 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 `@docs/COMMANDS.md`:
- Line 418: Update the acceptance-criteria documentation to avoid a space inside
the inline code span `;`. Preserve the meaning that criteria are joined by a
semicolon followed by a space, using prose outside the code span.

---

Duplicate comments:
In `@src/core/output/mutation-projection.ts`:
- Around line 113-134: Update projectCompactMutationEnvelope to validate
result.item.id is a string before constructing the compact envelope, returning
null when it is missing or has another type. Preserve the existing
normal-projection fallback and leave the remaining compact-field handling
unchanged.
🪄 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: 4633cc2d-f641-4b49-8588-b9cdf8182160

📥 Commits

Reviewing files that changed from the base of the PR and between 0ec9389 and e4d9b5b.

📒 Files selected for processing (66)
  • .agents/pm/extensions/.managed-extensions.json
  • .agents/pm/features/pm-cfed.toon
  • .agents/pm/features/pm-g9xk.toon
  • .agents/pm/features/pm-kipd.toon
  • .agents/pm/features/pm-nilh.toon
  • .agents/pm/features/pm-xm7c.toon
  • .agents/pm/history/pm-cfed.jsonl
  • .agents/pm/history/pm-ds3b.jsonl
  • .agents/pm/history/pm-g9xk.jsonl
  • .agents/pm/history/pm-kipd.jsonl
  • .agents/pm/history/pm-mfkv92.jsonl
  • .agents/pm/history/pm-nilh.jsonl
  • .agents/pm/history/pm-xm7c.jsonl
  • .agents/pm/issues/pm-mfkv92.toon
  • .agents/pm/tasks/pm-ds3b.toon
  • CHANGELOG.md
  • docs/COMMANDS.md
  • docs/SDK.md
  • plugins/pm-claude/README.md
  • plugins/pm-claude/commands/pm-init.md
  • scripts/release/token-budget-gate.mjs
  • scripts/release/token-budgets.json
  • scripts/smoke-claude-plugin.mjs
  • src/cli/commander-usage.ts
  • src/cli/commands/contracts.ts
  • src/cli/error-guidance.ts
  • src/cli/main.ts
  • src/cli/register-mutation.ts
  • src/cli/register-structured-mutation.ts
  • src/cli/registration-helpers.ts
  • src/core/item/parse.ts
  • src/core/output/mutation-projection.ts
  • src/core/output/output.ts
  • src/core/shared/command-types.ts
  • src/mcp/server.ts
  • src/mcp/tool-definitions.ts
  • src/sdk/cli-bootstrap.ts
  • src/sdk/cli-contracts.ts
  • src/sdk/cli-contracts/enum-contracts.ts
  • src/sdk/cli-contracts/flag-contracts.ts
  • src/sdk/cli-program.ts
  • src/sdk/error-runtime.ts
  • src/sdk/index.ts
  • src/sdk/runtime-primitives.ts
  • src/sdk/structured-mutations.ts
  • tests/fixtures/contracts/full.json
  • tests/helpers/mcp-context-depth.ts
  • tests/helpers/withTempPmPath.ts
  • tests/integration/extension-startup.integration.spec.ts
  • tests/integration/governance-presets.integration.spec.ts
  • tests/integration/help-runtime.spec.ts
  • tests/integration/mcp-handshake.spec.ts
  • tests/integration/structured-mutation-io.integration.spec.ts
  • tests/integration/telemetry-otel-nonblocking.spec.ts
  • tests/unit/cli/bootstrap-args.spec.ts
  • tests/unit/cli/cli-main-errors.spec.ts
  • tests/unit/cli/error-handler-projection.spec.ts
  • tests/unit/cli/registration-helpers.spec.ts
  • tests/unit/cli/structured-mutation-registration.spec.ts
  • tests/unit/commands/completion-command.spec.ts
  • tests/unit/core/item/parse-utils.spec.ts
  • tests/unit/core/output/mutation-projection.spec.ts
  • tests/unit/core/output/output.spec.ts
  • tests/unit/scripts/release/token-budget-gate.spec.ts
  • tests/unit/scripts/smoke-claude-plugin.spec.ts
  • tests/unit/sdk/structured-mutations.spec.ts

Comment thread docs/COMMANDS.md Resolved
Resolve the final exact-head review bundle across SDK, CLI, and MCP structured mutation surfaces. Add a public serialized and reentrant extension activation scope, normalize MCP transaction envelopes, enforce positive safe integer lock controls, reject competing stdin consumers, preserve the global flag sentinel boundary, and harden compact projections. Cover every path at exact 100/100/100/100 and record the completed pm lineage.
@unbraind

Copy link
Copy Markdown
Owner Author

@greptileai please review the latest exact head 9838309. All prior findings were addressed and local Greptile reports 5/5 safe to merge with no comments.

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai full review please. Review the latest exact head 9838309; all prior inline findings have been implemented and exact local coverage is 100/100/100/100.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

@unbraind Full review requested for the latest exact head 9838309e, including the updated structured CLI/MCP and SDK mutation surfaces.

✅ Action performed

Full review finished.


Your plan includes PR reviews subject to rate limits. More reviews will be available in 8 minutes.

@unbraind

Copy link
Copy Markdown
Owner Author

Final bot-comment dispositions on exact head 9838309:

  • CodeRabbit action confirmations 5021438125, 5021762133, 5022043101, and 5022506631: acknowledged; each requested review completed, and the final run added no findings.
  • CodeRabbit walkthrough 5021438625: down-voted only because its 37.33% docstring warning is stale/incorrect for this repository gate; the exact head passed the enforced 100% source/export/member docstring thresholds. Its feature summary was otherwise reviewed.
  • CodSpeed 5021454352: down-voted because the reported -0.03% aggregate change and -0.01% to -0.06% individual deltas are below environmental noise while six meaningful paths improved; the dedicated benchmark gate passed.
  • Codecov 5021464387: acknowledged; all modified lines are covered and the final repository totals are exactly 100/100/100/100.
  • Greptile summaries 5021467821 and 5021475090: acknowledged; all actionable inline findings were implemented, replied to, and resolved. Final local Greptile was 5/5 safe-to-merge with no comments, and the remote Greptile check passed.

Every bot issue comment and every inline finding has now received an explicit reaction and disposition.

@unbraind

unbraind commented Aug 4, 2026

Copy link
Copy Markdown
Owner Author

Tracked in PM: pm-cfed, pm-ds3b, pm-g9xk, pm-kipd, pm-mfkv92, pm-nilh, pm-xm7c.

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