Skip to content

SDK-backed Plan contracts and truthful mutation outcomes - #644

Merged
unbraind merged 4 commits into
mainfrom
feat/sdk-plan-contracts-and-mutation-outcomes
Jul 22, 2026
Merged

unbraind merged 4 commits into
mainfrom
feat/sdk-plan-contracts-and-mutation-outcomes

Conversation

@unbraind

@unbraind unbraind commented Jul 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • route governed Plan creation through the complete shared create contract across CLI, SDK, MCP, help, and generated schemas
  • preserve implements and verifies as first-class directed relationship kinds during Plan promotion
  • initialize linked-test sandboxes non-interactively and expose truthful delete outcomes (deleted / would_delete) with previous lifecycle state
  • add focused agent-contract regressions, generated docs/changelog evidence, and tighten the static-quality suppression budget

pm items

Verification

  • pnpm release:gates repository-owned gates passed
  • 336 test files / 6,084 tests passed
  • coverage: 100% statements, branches, functions, and lines
  • packed tarball installed and exercised in an isolated temporary project
  • strict governed Plan creation, semantic relationship promotion, linked-test execution, delete preview/apply, and SDK registry behavior manually verified
  • pnpm changelog:pm:check and pnpm contracts:check passed
  • Sentry/telemetry gate: 0 critical, 0 high; telemetry error rate 0.52%; no missing error-code rows
  • pm validate --check-resolution --check-history-drift: no history drift; selected items have complete closeout metadata (277 historical resolution warnings remain outside this PR)
  • zero pm items remain in progress

Closes #635
Closes #638
Closes #641
Closes #642


Summary by cubic

Unifies Plan creation behind the shared SDK/CLI/MCP create contract and completes strict MCP metadata parity, including the canonical estimate key. Makes delete mutations report truthful outcomes and applies them only to deletion projections; also preserves implements/verifies during Plan promotion and removes interactive linked-test init.

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

Review in cubic

Forward the complete governed create contract through Plan CLI, SDK, and MCP surfaces, preserve semantic relationship kinds, make linked-test sandboxes non-interactive, and expose truthful delete outcomes.

Add strict contract regressions, generated docs/changelog evidence, and tighten the static-quality suppression budget.
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @unbraind, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR expands governed Plan creation contracts, adds semantic relationship kinds and promotion normalization, makes delete JSON results explicit, enables injectable linked-test initialization, updates documentation and changelog entries, and lowers the ESLint suppression budget.

Changes

Core CLI and SDK contract changes

Layer / File(s) Summary
Plan metadata contracts and creation flow
src/cli/commands/plan.ts, src/cli/register-mutation.ts, src/sdk/cli-contracts/*, tests/fixtures/contracts/full.json, tests/unit/sdk/agent-contract-correctness.spec.ts, docs/SDK.md, docs/COMMANDS.md
Plan creation forwards shared governance metadata, expands CLI and MCP contracts, and validates strict Plan metadata through regression coverage.
Semantic relationship promotion
src/types.ts, src/sdk/relationships.ts, src/cli/commands/plan.ts, tests/unit/sdk/agent-contract-correctness.spec.ts, docs/COMMANDS.md
implements and verifies become supported relationship kinds; promoted links preserve semantic kinds while normalizing depends_on to blocked_by.
Delete mutation outcome envelope
src/cli/commands/delete.ts, src/core/output/mutation-projection.ts, tests/unit/commands/delete-command.spec.ts, tests/unit/core/output/mutation-projection.spec.ts, tests/integration/release-readiness-runtime.spec.ts, docs/COMMANDS.md
Delete results expose deleted, outcome, and previous_status, with tests covering real deletion, dry runs, projection modes, and deterministic key ordering.
Linked-test sandbox initialization
src/sdk/test/execution.ts, tests/unit/sdk/agent-contract-correctness.spec.ts
Windows shell flags are recognized, sandbox initialization accepts an injected initializer, and tests verify non-interactive defaults.
Release tracking and quality validation
CHANGELOG.md, package.json, scripts/release/static-quality-gate.mts, eslint-suppressions.json, tests/integration/*, .agents/pm/*
Issue closeout records, changelog references, release expectations, and the ESLint suppression limit are updated for the implemented changes.

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

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant Contracts
  participant Runtime
  participant Storage
  CLI->>Contracts: submit Plan metadata and relationship options
  Contracts->>Runtime: normalize and validate inputs
  Runtime->>Storage: create Plan and persist promoted links
  Storage-->>CLI: return mutation result
Loading
sequenceDiagram
  participant DeleteCommand
  participant Projection
  participant JSONResponse
  DeleteCommand->>Projection: provide deletion outcome fields
  Projection->>JSONResponse: select outcome as status
  JSONResponse-->>DeleteCommand: emit deleted or would_delete result
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% 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 The changes align with #635, #638, #641, and #642 by expanding Plan metadata, preserving semantic links, fixing delete outcomes, and removing interactive init.
Out of Scope Changes check ✅ Passed The docs, tests, changelog, and PM metadata updates all support the stated objectives; no unrelated code changes stand out.
Title check ✅ Passed The title succinctly captures the main changes: shared Plan contracts and truthful mutation outcomes.
Description check ✅ Passed The description clearly matches the PR’s changes to Plan contracts, relationship kinds, linked-test init, delete outcomes, and validation.
✨ 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

@greptileai review this exact head

/gemini review

@coderabbitai full review

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

@unbraind: Starting a full review of the current PR head, including the complete diff and relevant contract interactions.

✅ Action performed

Full review finished.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 11 minutes.

@codspeed

codspeed Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Merging this PR will regress 5 benchmarks

⚡ 6 improved benchmarks
❌ 5 regressed benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ createQueryFingerprint 513.8 µs 514.5 µs -0.14%
❌ decodeQueryCursor 116.1 µs 116.1 µs -0.02%
❌ tokenize + score query over 2000 docs 7.5 ms 7.5 ms 0%
❌ tokenizeAlphaNumeric 367.2 µs 367.3 µs 0%
❌ score query over 2000 docs 5.6 ms 5.6 ms 0%
⚡ build index (2000 docs x 80 words) 161.4 ms 161.3 ms +0.06%
⚡ encodeQueryCursor 101.2 µs 101.1 µs +0.06%
⚡ jaccardSimilarity 153.3 µs 153.3 µs +0.04%
⚡ normalizeLowercaseWhitespace 135.8 µs 135.8 µs +0.02%
⚡ build index (200 docs x 40 words) 8.4 ms 8.4 ms +0.01%
⚡ stableStringify (nested contract) 161.3 µs 161.3 µs 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-plan-contracts-and-mutation-outcomes (b1c63da) with main (76f8618)

Open in CodSpeed

@unbraind

Copy link
Copy Markdown
Owner Author

Review-surface acknowledgement for exact head 7c0345f4:

  • Gemini: both notices were read; the consumer reviewer is retired, so no code feedback exists to action.
  • CodeRabbit: both the rate-limit notice and completed command acknowledgement were read; the service produced no inline finding or actionable review.
  • Sourcery: the weekly diff-character limit notice was read; no code finding was emitted.
  • CodSpeed: the report was reviewed. Its net 0.02% simulated delta affects untouched pagination/BM25/text-normalization benchmarks, is paired with four improvements, and is below a meaningful regression threshold; the repository benchmark workflow passed. Accepted as measurement noise, with no code change warranted.

There are currently no review threads. Greptile remains pending and will be inventoried before merge.

@unbraind

Copy link
Copy Markdown
Owner Author

@greptileai please review exact head 7c0345f433bae04688c1375676d78ad155dba397 and report any actionable findings.

Restore the canonical create required-key contract, move governed metadata to the Plan optional-key allowlist, and lock both surfaces with a regression assertion.
@unbraind

Copy link
Copy Markdown
Owner Author

@greptileai review exact head 427e444b

/gemini review

@coderabbitai full review

Correction since the prior head: restored the canonical create required-key contract, moved the complete governed metadata allowlist to the Plan action, added direct regression assertions, regenerated contracts/changelog, and reran 6,084 tests at 100/100/100/100.

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Rate Limit Exceeded

@unbraind have exceeded the limit for the number of chat messages per hour. Please wait 2 minutes and 28 seconds before sending another message.

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai full review exact head 427e444bad4d1e18e10bb26fc98c0a4d2e473acf

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

@unbraind: Starting a full review of exact head 427e444bad4d1e18e10bb26fc98c0a4d2e473acf.

✅ Action performed

Full review finished.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/sdk/cli-contracts/tool-schema.ts (1)

1-1: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Add the missing estimate property for MCP plan.

estimatedMinutes is added to the plan action’s MCP optional keys, but the generated pm_plan schema has additionalProperties: false and no estimate/estimatedMinutes property, so MCP clients validating against that contract can’t pass CLI-supported --estimate/--estimated-minutes. Define the corresponding schema property for plan and regenerate tests/fixtures/contracts/full.json.

🤖 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/sdk/cli-contracts/tool-schema.ts` at line 1, Add the missing
estimate/estimatedMinutes property to the generated pm_plan MCP schema alongside
its existing optional keys, matching the CLI-supported
--estimate/--estimated-minutes contract and preserving additionalProperties:
false. Then regenerate the full contract fixture at
tests/fixtures/contracts/full.json.
🤖 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/SDK.md`:
- Line 233: Remove the “Tracked” banner and its internal issue links from the
public SDK reference in docs/SDK.md. Preserve the surrounding documentation
content, with issue association maintained only in the PM docs collection.

In `@src/core/output/mutation-projection.ts`:
- Around line 106-110: Update both status projection paths in the mutation
projection logic to use the envelope outcome only when it is exactly "deleted"
or "would_delete"; otherwise preserve the subject/item lifecycle status. Apply
the same predicate at the primary projection and the corresponding path around
the alternate status handling, and add coverage for a non-delete outcome such as
"success" retaining the item status.

In `@src/sdk/cli-contracts/tool-schema.ts`:
- Around line 571-610: Add the Plan action’s estimate property to the contract
schema, supporting the documented estimate/estimatedMinutes option from the Plan
action options metadata while preserving additionalProperties: false. Then
regenerate or refresh the contract fixture so the exposed schema and fixture
match.

In `@tests/unit/sdk/agent-contract-correctness.spec.ts`:
- Around line 88-112: The assertions at
tests/unit/sdk/agent-contract-correctness.spec.ts:88-112 must verify the
supplied status, priority, deadline, estimate, tags, and exact linked-resource
contents instead of only checking array types; update the item contract
assertion accordingly. At
tests/unit/sdk/agent-contract-correctness.spec.ts:188-205, reload the Plan and
assert metadata.dependencies includes the promoted implements and verifies
edges, including normalization of depends_on to blocked_by.

---

Outside diff comments:
In `@src/sdk/cli-contracts/tool-schema.ts`:
- Line 1: Add the missing estimate/estimatedMinutes property to the generated
pm_plan MCP schema alongside its existing optional keys, matching the
CLI-supported --estimate/--estimated-minutes contract and preserving
additionalProperties: false. Then regenerate the full contract fixture at
tests/fixtures/contracts/full.json.
🪄 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: 7736e3b1-491a-4e61-b9c3-3776db4b40d0

📥 Commits

Reviewing files that changed from the base of the PR and between 76f8618 and 427e444.

📒 Files selected for processing (30)
  • .agents/pm/extensions/.managed-extensions.json
  • .agents/pm/history/pm-lcnk2n.jsonl
  • .agents/pm/history/pm-qd3woa.jsonl
  • .agents/pm/history/pm-tz2ikr.jsonl
  • .agents/pm/history/pm-ypuc39.jsonl
  • .agents/pm/issues/pm-lcnk2n.toon
  • .agents/pm/issues/pm-qd3woa.toon
  • .agents/pm/issues/pm-tz2ikr.toon
  • .agents/pm/issues/pm-ypuc39.toon
  • CHANGELOG.md
  • docs/COMMANDS.md
  • docs/SDK.md
  • eslint-suppressions.json
  • package.json
  • scripts/release/static-quality-gate.mts
  • src/cli/commands/delete.ts
  • src/cli/commands/plan.ts
  • src/cli/register-mutation.ts
  • src/core/output/mutation-projection.ts
  • src/sdk/cli-contracts/flag-contracts.ts
  • src/sdk/cli-contracts/tool-schema.ts
  • src/sdk/relationships.ts
  • src/sdk/test/execution.ts
  • src/types.ts
  • tests/fixtures/contracts/full.json
  • tests/integration/release-automation-contract.spec.ts
  • tests/integration/release-readiness-runtime.spec.ts
  • tests/unit/commands/delete-command.spec.ts
  • tests/unit/core/output/mutation-projection.spec.ts
  • tests/unit/sdk/agent-contract-correctness.spec.ts
💤 Files with no reviewable changes (1)
  • eslint-suppressions.json

Comment thread docs/SDK.md Resolved
Comment thread src/core/output/mutation-projection.ts Resolved
Comment thread src/sdk/cli-contracts/tool-schema.ts Resolved
Expose the canonical estimate key in the strict Plan MCP schema, strengthen persisted Plan metadata/resource and semantic dependency assertions, and prevent generic mutation outcomes from overriding lifecycle status. Record full release evidence and the advisory Greptile quota state in pm lineage.
@unbraind

Copy link
Copy Markdown
Owner Author

Exact-head review follow-up is pushed as b1c63dad3c13033dc82e669a775e182050fc3c85.

  • Fixed the three verified CodeRabbit findings and replied inline with proof.
  • Retained the credential-free repository-relative pm tracker links per AGENTS.md traceability policy and replied inline with the policy rationale.
  • Resolved all four threads after handling.
  • Local release evidence: 6,084/6,084 tests, exact 100/100/100/100 coverage, 100% docstrings, static/package/token/secrets gates, packed npm smoke, and 88-command package dogfood all pass.
  • Advisory Greptile CLI returned free_reviews_limit_reached; canonical quota lineage is updated in pm-e02lgu.

@greptileai review exact head b1c63dad3c13033dc82e669a775e182050fc3c85

/gemini review

@coderabbitai full review exact head b1c63dad3c13033dc82e669a775e182050fc3c85

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

@unbraind: Starting a full review of exact head b1c63dad3c13033dc82e669a775e182050fc3c85, including the follow-up changes and relevant contract surfaces.

✅ Action performed

Full review finished.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 30 minutes.

@unbraind

Copy link
Copy Markdown
Owner Author

Exact-head review closeout for b1c63dad3c13033dc82e669a775e182050fc3c85: all four actionable CodeRabbit findings were individually acknowledged, fixed or rejected with rationale, reacted to, replied to inline, and resolved. CodeRabbit confirmed the three code/test corrections and withdrew the documentation finding; its final exact-head pass was quota-limited and reported no new actionable finding. Gemini is retired, Sourcery/Cubic were skipped or quota-limited, and Greptile is represented by the canonical quota tracker item after both the hosted trigger and local review path could not produce a review. All repository-owned checks are green.

@unbraind

Copy link
Copy Markdown
Owner Author

Branch-protection closeout: every created required context is green on exact head b1c63dad3c13033dc82e669a775e182050fc3c85. GitHub still reports the PR blocked because main requires the legacy codecov/patch context, but that app created no check/status for this head. The repository-owned Gates (coverage) passed, and the full local suite independently reported 100% statements, branches, functions, and lines. Proceeding with the documented admin merge path solely for this absent ghost context.

@unbraind
unbraind merged commit b294f65 into main Jul 22, 2026
31 checks passed
@unbraind
unbraind deleted the feat/sdk-plan-contracts-and-mutation-outcomes branch July 22, 2026 18:12
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@unbraind

unbraind commented Aug 4, 2026

Copy link
Copy Markdown
Owner Author

Tracked in PM: pm-lcnk2n, pm-qd3woa, pm-tz2ikr, pm-ypuc39.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant