Skip to content

SDK context budgets, cursor-chain efficiency, and MCP mutation parity - #849

Merged
unbraind merged 5 commits into
mainfrom
feat/context-budget-chain-parity
Aug 1, 2026
Merged

unbraind merged 5 commits into
mainfrom
feat/context-budget-chain-parity

Conversation

@unbraind

@unbraind unbraind commented Aug 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

This broad SDK and CLI delivery makes project management = context management enforceable across the agent-facing read and mutation surfaces.

  • exposes token-budget controls for list, get, and search across CLI, SDK contracts, cursor semantics, and MCP tool schema 4.3.0
  • adds truthful feasibility and omission receipts, deterministic explanatory-string and row compaction, and a feasible budget-derived triage page
  • replaces repeated cursor-chain metadata with a fingerprint reference on continuation pages while preserving cursor integrity
  • aligns raw SDK and MCP mutation defaults with the CLI lean id/status/change-count envelope and keeps explicit fullChangedFields results
  • refreshes generated contracts, public SDK surface evidence, token baselines, documentation, changelog, and PM history

PM lineage

  • pm-awe3t6 — closed: CLI and MCP mutation-envelope parity
  • pm-7hbfch — delivered cross-surface controls; retained open for current-scale structural negative-control gate
  • pm-yekkvt — delivered truthful feasible receipts; retained open for dual-scale calibration gate
  • pm-sf31yl — delivered continuation compaction and paging; retained open for current-scale full-walk gate

Verification

  • pnpm release:gates: all local gates passed; hosted analysis deferred until this pushed SHA exists
  • 6,631 tests passed
  • coverage: 100% statements, branches, functions, and lines
  • token-budget gate: 28 surfaces plus unbounded and infeasible-declaration negative controls
  • packed npx smoke: 15 packages
  • package-first dogfood: 88 commands
  • isolated npm and Bun installs resolved their own packed binaries and exercised lean mutation plus bounded read receipts
  • pm health and history-drift validation: clean
  • dependency audit and GitHub Dependabot, code-scanning, and secret-scanning inventories: zero open alerts

Summary by cubic

Enforces context token budgets across CLI, SDK, and MCP with budget‑derived paging, truthful receipts, and cursor-chain amortization. Aligns MCP/SDK mutation defaults with the CLI’s lean envelope and tightens docs/tests to enforce it.

  • New Features

    • Added --token-budget to list/get/search; SDK and MCP expose tokenBudget (alias --token_budget) and bump tool schema to 4.3.0.
    • Receipts now include declaration_feasible, result_omitted, and budget_row_compaction; page sizes derive from the remaining budget.
    • Continuation pages reference cursor-chain metadata by fingerprint to cut repetition while preserving cursor integrity.
    • MCP/SDK mutations default to lean id, status, changed_field_count; pass fullChangedFields=true for full deltas, or idOnly=true for IDs only.
  • Bug Fixes

    • Validate measured output independently of receipt claims; over-budget reads fall back to receipt-only without stale counts or cursors.
    • Normalize --token-budget/--token_budget handling across CLI/SDK/MCP and scope tokenBudget parameter descriptions correctly.
    • Preserve useful rows via batch row compaction so at least one row survives before omission.
    • Enforce lean MCP envelope in smoke tests and propagate idOnly through aggregated append; include the SDK token‑budget usage error in the generated catalog.
    • Reconcile review evidence in docs by removing non-discriminating compaction assertions and noting remaining cursor-chain acceptance as open work.

Written for commit 1cb2c04. Summary will update on new commits.

Review in cubic

Summary by Sourcery

Enforce context token budgets and truthful receipts across CLI, SDK, and MCP, while reducing cursor-chain overhead and aligning mutation envelopes with the CLI’s lean defaults.

New Features:

  • Expose token-budget controls for context, list, get, next, and search intents over CLI flags, SDK contracts, cursor semantics, and MCP tool parameters.
  • Introduce declaration feasibility and result omission markers in intent receipts, plus a budget-based triage page and row-compaction degradation tier.
  • Add continuation contracts that reference cursor-chain metadata by fingerprint so subsequent pages carry only advancing rows and cursors.

Bug Fixes:

  • Align MCP mutation result envelopes with the CLI default by returning lean id/status/changed_field_count unless fullChangedFields or idOnly is explicitly requested.
  • Correct intent receipts to treat infeasible declarations as omitted results, marking within-budget only for delivered projections.
  • Adjust recovery guidance for oversized positional reads to recommend increasing token budgets or narrowing requests instead of re-running unprojected commands.

Enhancements:

  • Derive default list, search, and context page sizes and activity limits from the effective token budget to keep intent declarations feasible on large trackers.
  • Add deterministic row-compaction logic that trims root collections while preserving at least one useful row before falling back to receipt-only envelopes.
  • Collapse invariant metadata from continuation pages and verify cursor pagination contracts in tests.
  • Extend the token-budget release gate to cover intent surfaces, validate feasible receipts, and normalize fixture IDs in recorded budgets.

Build:

  • Update token-budget manifests and agent token-surface baselines to reflect new intents, budgets, and measurement corpus entries.

Documentation:

  • Refresh output projection and command documentation to describe token-budget-derived paging, feasibility and omission flags, cursor continuation contracts, and MCP mutation envelope parity with the CLI.

Tests:

  • Add unit, integration, and MCP-specific tests for intent token-budget derivation, receipt feasibility semantics, cursor continuation metadata, token-budget gate negative controls, and MCP mutation envelope parity.

Expose token-budget controls across list, get, search, SDK contracts, and MCP schemas. Add truthful feasibility receipts, deterministic row compaction, budget-derived paging, and cursor-chain metadata references. Align raw SDK/MCP mutation defaults with the CLI lean envelope while retaining explicit full results. Refresh generated contracts, token baselines, changelog, docs, tests, and PM evidence.
@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 Aug 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added --token-budget controls for list, get, and search operations.
    • Results now adapt to token limits with compact rows, truthful omission receipts, and recovery guidance.
    • Continuation pages provide compact cursor metadata for reliable pagination.
    • Updated SDK and tool schemas to support token budgets and enhanced intent receipts.
  • Bug Fixes

    • Aligned CLI and MCP mutation responses with compact default envelopes.
    • Added fullChangedFields for complete mutation details and improved ID-only responses.
  • Documentation

    • Updated output contracts and changelog guidance for the new behavior.

Walkthrough

The change adds token-budget controls across CLI and SDK surfaces, derives bounded intent projections, compacts continuation metadata, strengthens release-gate validation, and aligns default CLI and MCP mutation envelopes.

Changes

Bounded output and contract updates

Layer / File(s) Summary
Token-budget contract surface
src/cli/register-list-query.ts, src/sdk/cli-contracts/*, tests/fixtures/contracts/full.json, sdk/public-surface.json
Adds token-budget options and aliases. Updates schema version 4.3.0 and intent receipt fields.
Budget-derived projections and cursors
src/sdk/context-intent-contracts.ts, docs/OUTPUT_PROJECTION_CONTRACTS.md, tests/unit/sdk/context-intent-contracts.spec.ts, tests/unit/commands/query-pagination.spec.ts
Derives limits from budgets, compacts rows, emits omission receipts, and returns continuation contracts.
Release budgets and intent gate
scripts/release/token-budget-gate.mjs, scripts/release/token-budgets.json, tests/unit/scripts/release/token-budget-gate.spec.ts
Measures five intent surfaces and validates feasible and infeasible receipts.
Compact mutation envelopes
src/sdk/runtime.ts, docs/COMMANDS.md, tests/unit/mcp/mutation-envelope-parity.spec.ts, tests/integration/*
Uses compact mutation results by default. fullChangedFields restores item and changed-field data. idOnly suppresses the changed-field count.
Supporting baselines and records
scripts/agent-token-surface-baseline.json, .agents/pm/*, CHANGELOG.md
Updates token measurements, project records, documentation, and the unreleased mutation-parity entry.

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

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant SDK
  participant MCP
  participant ReleaseGate
  CLI->>SDK: Submit intent and token budget
  SDK->>SDK: Derive limits and compact output
  SDK-->>CLI: Return bounded result or omission receipt
  SDK->>MCP: Project mutation result
  MCP-->>SDK: Return compact default or full opt-in result
  ReleaseGate->>CLI: Measure intent-aware commands
  CLI-->>ReleaseGate: Return context_intent receipt
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.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 clearly summarizes the PR's main changes: SDK context budgets, cursor-chain efficiency, and MCP mutation parity.
Description check ✅ Passed The description directly explains the token-budget, cursor-chain, mutation-parity, documentation, and verification changes.
✨ Finishing Touches 💡 1
📝 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 Aug 1, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 11 untouched benchmarks


Comparing feat/context-budget-chain-parity (1cb2c04) with main (5ed1070)

Open in CodSpeed

@codecov

codecov Bot commented Aug 1, 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!

@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

@sourcery-ai

sourcery-ai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Reviewer's Guide

Enforces token-budget-aware context intents across CLI, SDK, and MCP, adds truthful feasibility/omission receipts and deterministic row compaction, collapses continuation metadata via fingerprints, tightens token-budget gates, and aligns MCP mutation envelopes with the CLI’s lean defaults while preserving explicit full-delta options.

Sequence diagram for token-budget-aware context intents and continuation paging

sequenceDiagram
  actor User
  participant Cli as pm_cli
  participant Runtime as attachReadOutputContracts
  participant Intent as attachContextIntentReceipt
  participant Rows as compactContextIntentRows
  participant Cursor as collapseContinuationMetadata

  User->>Cli: list --for triage --token-budget 3200 --json
  Cli->>Runtime: attachReadOutputContracts(command, options, result)
  Runtime->>Intent: attachContextIntentReceipt(builtInCommand, options, result)
  Intent->>Intent: updateContextIntentEstimate(projected, receipt)
  alt estimated_tokens > token_budget
    Intent->>Rows: compactContextIntentRows(command, projected, receipt)
    alt rows compacted
      Rows-->>Intent: true
      Intent->>Intent: set degradation = budget_row_compaction
      Intent->>Intent: updateContextIntentEstimate(projected, receipt)
    else no compaction or still too large
      Rows-->>Intent: false
      Intent->>Intent: set degradation = budget_receipt_only
      Intent->>Intent: set declaration_feasible = false
      Intent->>Intent: set result_omitted = true
      Intent->>Intent: updateContextIntentEstimate(projected, receipt)
    end
  end
  Intent-->>Runtime: projectedWithIntent
  alt options.after is set
    Runtime->>Cursor: collapseContinuationMetadata(options, projectedWithIntent)
    Cursor-->>Cli: continuation page with continuation_contract
  else first page
    Runtime-->>Cli: full page with context_intent and metadata
  end
  Cli-->>User: JSON result
Loading

Sequence diagram for token-budget gate and intent negative controls

sequenceDiagram
  participant Main as main
  participant Measure as measureCorpus
  participant Budgets as compareBudgets
  participant NegCtrl as compareNegativeControls
  participant Fail as fail

  Main->>Measure: measureCorpus(cliPath)
  Measure->>Measure: runCliJson(..., args, options)
  Measure-->>Main: {measurements, negativeControl, intentNegativeControl}
  alt update manifest
    Main->>Budgets: buildManifest(measurements, multiplier)
    Budgets-->>Main: nextManifest
  else verify budgets
    Main->>Budgets: compareBudgets(measurements, manifest)
    Budgets-->>Main: budgetViolations
    Main->>NegCtrl: compareNegativeControls(negativeControl, intentNegativeControl)
    NegCtrl-->>Main: controlViolations
    Main->>Main: collect violations
    alt violations.length > 0
      Main->>Fail: fail("Token budget gate failed", violations)
    else
      Main->>Main: log "Token budget gate passed (...) infeasible intent receipt verified"
    end
  end
Loading

File-Level Changes

Change Details Files
Make context intents token-budget aware with derived limits and richer receipts, including deterministic row compaction semantics.
  • Increase triage list intent token budget and adjust default fields/limits for list, search, and context intents based on effective tokenBudget.
  • Add declaration_feasible and result_omitted flags plus new budget_row_compaction degradation to PmContextIntentReceipt and update within_budget semantics.
  • Introduce compactContextIntentRows to deterministically trim root row collections while retaining at least one useful row and respecting pagination cursors.
  • Extend attachContextIntentReceipt to use row compaction before falling back to budget_receipt_only, with updated recovery messaging and omission evidence.
src/sdk/context-intent-contracts.ts
tests/unit/sdk/context-intent-contracts.spec.ts
tests/unit/cli/context-intent-registration.spec.ts
docs/OUTPUT_PROJECTION_CONTRACTS.md
Collapse cursor-chain metadata on continuation pages into a compact fingerprint reference while keeping cursor integrity and tests aligned.
  • Add collapseContinuationMetadata and wire it into attachReadOutputContracts so after-cursor pages emit continuation_contract instead of repeating invariant metadata.
  • Strip counts, contracts, and other invariant fields from continuation results, keeping only rows, cursors, and the fingerprint reference.
  • Update pagination tests to assert presence of continuation_contract on second pages and absence of repeated metadata.
  • Document cursor-chain amortization and continuation-contract behavior in output projection docs.
src/sdk/context-intent-contracts.ts
tests/unit/sdk/context-intent-contracts.spec.ts
tests/unit/commands/query-pagination.spec.ts
docs/OUTPUT_PROJECTION_CONTRACTS.md
Expose token-budget controls and intent evidence across CLI, SDK flag contracts, MCP tool schema, and release gates.
  • Add --token-budget (and hidden --token_budget alias) to list, search, get, and context CLI commands and register them in flag contracts.
  • Map tokenBudget tool parameters to --token-budget in MCP tool option contracts and bump PM_TOOL_PARAMETERS_SCHEMA_VERSION to 4.3.0.
  • Extend token-budget gate corpus with intent-bearing commands and capture intent_receipt plus an infeasible intentNegativeControl.
  • Add measurement and negative-control checks to ensure intent receipts prove feasible delivered rows and truthful omission on infeasible declarations; update gate logs and tests accordingly.
src/cli/register-list-query.ts
src/sdk/cli-contracts/flag-contracts.ts
src/sdk/cli-contracts/tool-schema.ts
src/sdk/cli-contracts/tool-option-contracts.ts
scripts/release/token-budget-gate.mjs
tests/unit/scripts/release/token-budget-gate.spec.ts
scripts/agent-token-surface-baseline.json
scripts/release/token-budgets.json
Align MCP and SDK mutation envelopes with the CLI’s lean id/status/changed_field_count default while preserving explicit fullChangedFields and idOnly options.
  • Thread compactEnvelope into projectMutationResult calls for MCP create/copy/update/close/append/restore so default results are lean and fullChangedFields restores full item and changed_fields.
  • Update SDK and MCP integration tests to expect lean mutation results by default (id, status, changed_field_count) and full item echoes only when fullChangedFields=true.
  • Add MCP parity tests confirming pm_create returns the same default shape as CLI and only emits full envelopes when explicitly requested.
  • Refresh documentation and changelog to describe MCP mutation envelope parity and lean defaults vs fullChangedFields/idOnly escape hatches.
src/sdk/runtime.ts
tests/integration/mcp-dynamic-package-actions.spec.ts
tests/integration/sdk-cli-contract-integrity.integration.spec.ts
tests/unit/sdk/sdk-index.spec.ts
tests/unit/mcp/mutation-envelope-parity.spec.ts
docs/COMMANDS.md
CHANGELOG.md
sdk/public-surface.json
tests/fixtures/contracts/full.json
Update PM lineage, agent history, and tracking artifacts to reflect the new budget, cursor, and mutation behavior.
  • Refresh PM issue and history files to record delivery of token-budget controls, truthful receipts, cursor-chain compaction, and MCP mutation parity.
  • Adjust release baselines and public contract fixtures to match new token budgets, intent fields, and mutation envelopes.
  • Ensure coverage and health metadata remain consistent with the expanded surfaces and schema version bump.
.agents/pm/features/pm-nilh.toon
.agents/pm/history/pm-7hbfch.jsonl
.agents/pm/history/pm-awe3t6.jsonl
.agents/pm/history/pm-nilh.jsonl
.agents/pm/history/pm-sf31yl.jsonl
.agents/pm/history/pm-wv47pf.jsonl
.agents/pm/history/pm-yekkvt.jsonl
.agents/pm/issues/pm-7hbfch.toon
.agents/pm/issues/pm-awe3t6.toon
.agents/pm/issues/pm-sf31yl.toon
.agents/pm/issues/pm-wv47pf.toon
.agents/pm/issues/pm-yekkvt.toon

Tips and commands

Interacting with Sourcery

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

Customizing Your Experience

Access your dashboard to:

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

Getting Help

Update the Claude plugin acceptance workflow and unit coverage to consume and validate the default id/status/changed_field_count response. Record the exact-head CI correction and verification on pm-awe3t6.
@unbraind

unbraind commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

New exact head c14981dbd fixes the Claude plugin acceptance smoke exposed by CI and adds regression coverage for the lean MCP mutation envelope.

@greptileai please review this exact head.
@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

@unbraind I will run a full review of PR #849 at head c14981dbd. I will include the Claude plugin acceptance-smoke fix and the lean MCP mutation-envelope regression coverage.

✅ 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 50 minutes.

@unbraind

unbraind commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

Bot feedback acknowledgement for the first review head:

The only runner failure was the stale Claude smoke consumer; exact head c14981dbd fixes it and adds a strict regression assertion.

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

Caution

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

⚠️ Outside diff range comments (1)
src/sdk/runtime.ts (1)

3497-3510: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Honor idOnly for runMcpAppendAction.

withMutationCompaction can produce idOnly, but this action discards it. Therefore, pm_run append with idOnly: true still returns changed_field_count instead of the id/status-only result documented for single-item mutations.

Pass idOnly to projectMutationResult and disable compactEnvelope when it is set. Add a regression test for the append action.

Proposed fix
-  const { changedFields, runnerOptions } = withMutationCompaction(
+  const { changedFields, idOnly, runnerOptions } = withMutationCompaction(
     ctx.args,
     ctx.options,
   );
@@
-      compactEnvelope: changedFields === "compact",
+      compactEnvelope: changedFields === "compact" && !idOnly,
+      idOnly,
🤖 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/runtime.ts` around lines 3497 - 3510, Update the runMcpAppendAction
result flow around withMutationCompaction and projectMutationResult to propagate
the returned idOnly option, and ensure compactEnvelope is disabled whenever
idOnly is true. Add a regression test covering an append with idOnly: true and
verify it returns the documented id/status-only result rather than
changed_field_count.
🤖 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/issues/pm-sf31yl.toon:
- Around line 21-22: Update the pm-sf31yl issue record to link the remaining
acceptance artifacts before closure: a full-walk cost gate using a current-scale
corpus, a repeated-metadata negative control, and a before/after whole-chain
evidence table. Add PM-linked artifact paths or references to their canonical PM
owner, and retain the existing delivery evidence.

In `@src/cli/register-list-query.ts`:
- Around line 348-351: Update the option handling around
applyContextIntentProjection so --token-budget is rejected when options.for is
absent, while preserving its existing mapping when --for is provided.
Alternatively, revise the option description and contract only if token-budget
is intentionally supported without a selected intent; ensure the CLI behavior
matches the documented contract.

In `@src/sdk/context-intent-contracts.ts`:
- Around line 490-544: Optimize compactContextIntentRows by avoiding one full
updateContextIntentEstimate serialization per removed row: measure the current
payload once, estimate rows to remove using the excess token count and
representative bytes-per-row, then remove that batch while retaining at least
one row. Re-estimate after the batch and use one-at-a-time candidate.rows.pop()
removals only for the final boundary adjustment until the token budget is
satisfied.
- Around line 609-616: Remove the final duplicate receipt.within_budget
assignment and updateContextIntentEstimate(projected, receipt) call after the
compaction/fallback pipeline in the context-intent processing flow. Preserve the
earlier updateContextIntentEstimate call and all branch-specific within_budget
assignments, including budget_receipt_only behavior, then return projected
unchanged.

In `@tests/fixtures/contracts/full.json`:
- Around line 14257-14272: The shared tokenBudget description is incorrectly
deps-specific in non-deps schemas. Update the CLI contract definition that
generates tokenBudget descriptions for pm_get, pm_list, pm_search, and
list-family action branches to use generic command-output wording, while
retaining the deps-specific description exclusively for deps tool/action
schemas; regenerate the affected contract fixture ranges.

---

Outside diff comments:
In `@src/sdk/runtime.ts`:
- Around line 3497-3510: Update the runMcpAppendAction result flow around
withMutationCompaction and projectMutationResult to propagate the returned
idOnly option, and ensure compactEnvelope is disabled whenever idOnly is true.
Add a regression test covering an append with idOnly: true and verify it returns
the documented id/status-only result rather than changed_field_count.
🪄 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 Plus

Run ID: 3bac55bf-6310-4825-967c-bc6c642bffe8

📥 Commits

Reviewing files that changed from the base of the PR and between 5ed1070 and 34f5703.

📒 Files selected for processing (34)
  • .agents/pm/features/pm-nilh.toon
  • .agents/pm/history/pm-7hbfch.jsonl
  • .agents/pm/history/pm-awe3t6.jsonl
  • .agents/pm/history/pm-nilh.jsonl
  • .agents/pm/history/pm-sf31yl.jsonl
  • .agents/pm/history/pm-wv47pf.jsonl
  • .agents/pm/history/pm-yekkvt.jsonl
  • .agents/pm/issues/pm-7hbfch.toon
  • .agents/pm/issues/pm-awe3t6.toon
  • .agents/pm/issues/pm-sf31yl.toon
  • .agents/pm/issues/pm-wv47pf.toon
  • .agents/pm/issues/pm-yekkvt.toon
  • CHANGELOG.md
  • docs/COMMANDS.md
  • docs/OUTPUT_PROJECTION_CONTRACTS.md
  • scripts/agent-token-surface-baseline.json
  • scripts/release/token-budget-gate.mjs
  • scripts/release/token-budgets.json
  • sdk/public-surface.json
  • src/cli/register-list-query.ts
  • src/sdk/cli-contracts/flag-contracts.ts
  • src/sdk/cli-contracts/tool-option-contracts.ts
  • src/sdk/cli-contracts/tool-schema.ts
  • src/sdk/context-intent-contracts.ts
  • src/sdk/runtime.ts
  • tests/fixtures/contracts/full.json
  • tests/integration/mcp-dynamic-package-actions.spec.ts
  • tests/integration/sdk-cli-contract-integrity.integration.spec.ts
  • tests/unit/cli/context-intent-registration.spec.ts
  • tests/unit/commands/query-pagination.spec.ts
  • tests/unit/mcp/mutation-envelope-parity.spec.ts
  • tests/unit/scripts/release/token-budget-gate.spec.ts
  • tests/unit/sdk/context-intent-contracts.spec.ts
  • tests/unit/sdk/sdk-index.spec.ts

Comment thread .agents/pm/issues/pm-sf31yl.toon Resolved
Comment thread src/cli/register-list-query.ts Resolved
Comment thread src/sdk/context-intent-contracts.ts Resolved
Comment thread src/sdk/context-intent-contracts.ts Resolved
Comment thread tests/fixtures/contracts/full.json Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found and verified against the latest diff

Prompt for AI agents (unresolved issues)

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


<file name="src/cli/register-list-query.ts">

<violation number="1" location="src/cli/register-list-query.ts:483">
P2: `--token_budget` does not override the budget for list, search, or get: projection sets the declared default because it only reads `tokenBudget`, and the receipt also reports that default. Canonicalize this alias before applying/rendering the intent, or have the intent helpers accept `token_budget`.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread scripts/release/token-budget-gate.mjs Resolved
Comment thread src/sdk/context-intent-contracts.ts Resolved
Comment thread src/cli/register-list-query.ts Resolved
Comment thread src/cli/register-list-query.ts Resolved
Comment thread src/sdk/context-intent-contracts.ts Resolved
Comment thread src/sdk/context-intent-contracts.ts Resolved
Comment thread tests/fixtures/contracts/full.json Resolved
Validate measured output independently from receipt claims, normalize token-budget aliases, preserve recoverable read rows, and batch row compaction. Propagate idOnly through aggregated MCP append, scope parameter descriptions correctly, and add high-scale regressions. Record exact release-gate evidence while returning incomplete acceptance work to open.
@unbraind

unbraind commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

Exact review-fix head: 6b0e063d5606fd925c66357ba4c0d387716afc94. All CodeRabbit and Cubic findings have been implemented with focused regressions; the complete local release pipeline passed through 6,637 tests at 100/100/100/100, packed npx, and package-first dogfood.

@greptileai please review this exact head. The local adapter currently reports free_reviews_limit_reached, so please respond if hosted capacity is available.

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

@unbraind I will run a full review of PR #849 at head 6b0e063d5606fd925c66357ba4c0d387716afc94. I will review the Claude plugin acceptance-smoke fix and the regression coverage for the lean MCP mutation envelope.

✅ 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 4 minutes.

@unbraind

unbraind commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

Review reconciliation for exact head 6b0e063d5:

  • CodeRabbit’s outside-diff pm_run append observation was valid and is fixed: runMcpAppendAction now propagates idOnly, disables the compact envelope for that mode, and a real MCP regression asserts exactly id/status.
  • The edited CodeRabbit walkthrough’s 35.29% docstring warning is not consistent with this repository’s authoritative gate. static-quality-gate.mts passed the mandatory 100% overall, exported, and member docstring thresholds on this exact source; the full coverage suite also passed 100/100/100/100. No generated docstring PR is needed.
  • The requested exact-head CodeRabbit rerun acknowledged 6b0e063d5 but reported its included review limit reached. Greptile’s local adapter likewise reports free_reviews_limit_reached; both external capacity limits are documented rather than represented as successful reviews.

Include the SDK token-budget usage error in the generated error-code source inventory and regenerated full contract fixture. Record CI evidence and return the remaining calibration acceptance to open.
@unbraind

unbraind commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

New exact head 48c631dd61c4ca041a1c47489633b6f591e046b7 fixes the sole static CI failure by regenerating the structured error-code catalog and full contract fixture. Focused contracts, secret, lint, and regression checks pass.

@greptileai please review this exact head if review capacity is available.

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

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

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

Caution

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

⚠️ Outside diff range comments (1)
scripts/release/token-budget-gate.mjs (1)

511-518: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a comment distinguishing the two token-budget comparisons.

Line 514 (measurement.estimated_tokens > receipt.token_budget) and Line 515 (receipt.estimated_tokens > receipt.token_budget) look like a duplicated condition, but they check different things: Line 514 independently validates the actually measured output against the declared budget, Line 515 validates the receipt's internal self-consistency. Both are exercised by distinct tests in tests/unit/scripts/release/token-budget-gate.spec.ts (lines 495-546 and 548-573).

A short inline comment would prevent a future refactor from treating one of these as a redundant duplicate and removing it.

📝 Suggested clarifying comment
     if (
       !receipt ||
       receipt.declaration_feasible !== true ||
       receipt.result_omitted !== false ||
       receipt.within_budget !== true ||
       !Number.isFinite(receipt.estimated_tokens) ||
       !Number.isFinite(receipt.token_budget) ||
+      // Independently verify the actual measured output against the declared budget...
       measurement.estimated_tokens > receipt.token_budget ||
+      // ...and separately verify the receipt's own estimate is internally consistent.
       receipt.estimated_tokens > receipt.token_budget
     ) {
🤖 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 `@scripts/release/token-budget-gate.mjs` around lines 511 - 518, Add a concise
inline comment in the validation condition distinguishing
measurement.estimated_tokens > receipt.token_budget as validation of the actual
measured output against the declared budget from receipt.estimated_tokens >
receipt.token_budget as validation of the receipt’s internal consistency; leave
both comparisons and their behavior 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 @.agents/pm/history/pm-awe3t6.jsonl:
- Line 23: Update the PM record through the pm CLI, not by editing .agents/pm
files directly: append a PM update correcting the src/mcp/server.ts note to
state that the default MCP mutation envelope is lean and contains no item, then
regenerate the derived projection in .agents/pm/issues/pm-awe3t6.toon. Apply the
update at .agents/pm/history/pm-awe3t6.jsonl lines 23-23 and regenerate
.agents/pm/issues/pm-awe3t6.toon lines 34-42; do not edit the history entry
manually.

In `@tests/unit/sdk/context-intent-contracts.spec.ts`:
- Around line 395-397: Make the assertions in the test around
attachContextIntentReceipt meaningful: either include a truncated field in the
input fixture so the test verifies compaction removes stale truncation state, or
remove the ineffective truncated and next_cursor absence assertions. Do not
retain assertions that are guaranteed by the fixture or compactContextIntentRows
precondition.

---

Outside diff comments:
In `@scripts/release/token-budget-gate.mjs`:
- Around line 511-518: Add a concise inline comment in the validation condition
distinguishing measurement.estimated_tokens > receipt.token_budget as validation
of the actual measured output against the declared budget from
receipt.estimated_tokens > receipt.token_budget as validation of the receipt’s
internal consistency; leave both comparisons and their behavior 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 Plus

Run ID: befb1ec6-38d2-46ee-820a-8940aa99810a

📥 Commits

Reviewing files that changed from the base of the PR and between 34f5703 and 48c631d.

📒 Files selected for processing (17)
  • .agents/pm/history/pm-awe3t6.jsonl
  • .agents/pm/history/pm-sf31yl.jsonl
  • .agents/pm/history/pm-yekkvt.jsonl
  • .agents/pm/issues/pm-awe3t6.toon
  • .agents/pm/issues/pm-sf31yl.toon
  • .agents/pm/issues/pm-yekkvt.toon
  • scripts/release/token-budget-gate.mjs
  • scripts/smoke-claude-plugin.mjs
  • src/sdk/cli-contracts/tool-parameter-tables.ts
  • src/sdk/context-intent-contracts.ts
  • src/sdk/generated-error-code-catalog.ts
  • src/sdk/runtime.ts
  • tests/fixtures/contracts/full.json
  • tests/unit/mcp/mutation-envelope-parity.spec.ts
  • tests/unit/scripts/release/token-budget-gate.spec.ts
  • tests/unit/scripts/smoke-claude-plugin.spec.ts
  • tests/unit/sdk/context-intent-contracts.spec.ts

Comment thread .agents/pm/history/pm-awe3t6.jsonl Resolved
Correct the stale MCP linked-file note through pm, remove non-discriminating compaction assertions, and preserve unfinished cursor-chain acceptance as open work.
@unbraind

unbraind commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

Final review-fix head: 1cb2c04720f386ff1d242c170777e8a283b95831. The two new CodeRabbit findings were addressed individually with PM-safe metadata correction and focused test cleanup; both threads have evidence replies and are resolved.

@greptileai please review this exact head if capacity is available.

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

@unbraind I will run a full review of PR #849 at head 1cb2c04720f386ff1d242c170777e8a283b95831. I will verify the two review-fix changes and their focused regression coverage.

✅ 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 48 minutes.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 9 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

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


<file name=".agents/pm/history/pm-sf31yl.jsonl">

<violation number="1" location=".agents/pm/history/pm-sf31yl.jsonl:24">
P3: This PM history entry gains two back-to-back comment_add ops (comments/3 and comments/4) that are near-identical restatements of the same "Exact-head CodeRabbit cleanup" note, differing only in the trailing test-status phrase. This duplicates the same event in the append-only ledger and will surface as redundant noise in the item's evidence trail and any regenerated projection. Keep a single comment; drop the duplicate entry.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread .agents/pm/history/pm-sf31yl.jsonl Resolved
@unbraind
unbraind merged commit 0086d3c into main Aug 1, 2026
32 checks passed
@unbraind
unbraind deleted the feat/context-budget-chain-parity branch August 1, 2026 02:22
@unbraind

unbraind commented Aug 4, 2026

Copy link
Copy Markdown
Owner Author

Tracked in PM: pm-7hbfch, pm-awe3t6, pm-sf31yl, pm-yekkvt.

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