Skip to content

Define agent integration contracts - #27

Merged
krishna916 merged 2 commits into
mainfrom
feature/issue-19-agent-integration-contracts
Jul 26, 2026
Merged

Define agent integration contracts#27
krishna916 merged 2 commits into
mainfrom
feature/issue-19-agent-integration-contracts

Conversation

@krishna916

@krishna916 krishna916 commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • define versioned, adapter-neutral MCP and CLI contract schemas, errors, warnings, session validation, task DTOs, and fixtures
  • finalize the ADR and detailed MCP, CLI, and session contract references
  • guard required contract assets and document the contract from the README

Validation

  • pnpm format:check
  • pnpm lint
  • pnpm typecheck
  • pnpm test:coverage
  • pnpm build
  • pnpm validate:assets
  • npm audit --audit-level=high (0 vulnerabilities)

pnpm verify reaches its audit step but pnpm 10.2.0 running under unsupported Node 25 fails to parse the registry gzip response. The repository requires Node 24, which is not installed locally.

Closes #19

Summary by CodeRabbit

  • New Features

    • Added versioned contracts for task operations, sessions, errors, warnings, and CLI responses.
    • Standardized CLI JSON output, error codes, exit codes, validation rules, and session identifier handling.
    • Added detailed MCP tool and CLI command specifications, including mutation safety and result formats.
  • Documentation

    • Clarified the accepted agent-integration contract and future implementation boundaries.
    • Expanded session semantics and documented deterministic task and session behavior.
  • Tests

    • Added contract validation tests and representative success, warning, and error fixtures.
    • Strengthened repository asset validation for required contract documentation and assets.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@krishna916, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 18 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b72b5d62-4f5a-427e-81bc-d3a553ea8f76

📥 Commits

Reviewing files that changed from the base of the PR and between 8b3ea35 and 576eca7.

📒 Files selected for processing (11)
  • docs/cli-reference.md
  • docs/mcp-tools.md
  • scripts/validate-repository-assets.ts
  • src/interfaces/contracts/error-contract.ts
  • src/interfaces/contracts/json-value-contract.ts
  • src/interfaces/contracts/task-contract.ts
  • src/interfaces/contracts/warning-contract.ts
  • tests/fixtures/contracts/capture-duplicate-warning.json
  • tests/fixtures/contracts/capture-success.json
  • tests/unit/interfaces/contracts/agent-integration-contracts.test.ts
  • tests/unit/scripts/validate-repository-assets.test.ts
📝 Walkthrough

Walkthrough

This change defines versioned agent-integration contracts for MCP and CLI adapters, including task/session schemas, errors, warnings, envelopes, command behavior, session semantics, fixtures, and repository asset validation. Production MCP and CLI handlers remain out of scope.

Changes

Agent integration contracts

Layer / File(s) Summary
Versioned contract schemas
src/interfaces/contracts/*
Adds Zod schemas and exported constants for task, session, error, warning, result, and CLI envelope contracts.
Documented MCP, CLI, and session behavior
README.md, docs/decisions/..., docs/mcp-tools.md, docs/cli-reference.md, docs/session-semantics.md, docs/superpowers/plans/...
Documents the accepted MCP/CLI surface, JSON output and exit-code rules, session semantics, mutation constraints, and database-path precedence.
Contract fixtures and schema validation
tests/fixtures/contracts/*, tests/unit/interfaces/contracts/...
Adds representative success, warning, and error fixtures and validates schemas, identifiers, envelopes, exit codes, and fixture payloads.
Repository asset validation
scripts/validate-repository-assets.ts, tests/unit/scripts/...
Requires the new contract assets and tests validation failures for missing agent-integration documentation and fixtures.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related issues

  • Issue 2 — The contract schemas and documentation formalize the MCP/CLI integration scope of the parent epic.
  • Issue 25 — The added contracts and fixtures provide the assets for later end-to-end verification.
  • Issue 20 — The session identifier and capture-membership contracts define boundaries for later session implementation.

Possibly related PRs

  • krishna916/relay#3 — The repository asset validation changes extend checks introduced by this PR.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: defining the agent integration contracts.
Linked Issues check ✅ Passed The PR appears to satisfy issue #19 by documenting and implementing the versioned MCP, CLI, session, mutation, and error contracts with fixtures.
Out of Scope Changes check ✅ Passed No clearly unrelated changes are evident; the extra docs, tests, and asset checks support the contract work.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/issue-19-agent-integration-contracts

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.

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

🤖 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/interfaces/contracts/task-contract.ts`:
- Around line 59-81: Update editableInputFields and the shared hasEditableInput
validation so each clear flag is rejected when its corresponding value is
supplied, preventing conflicting edit directives in both mutationInputSchema and
taskEditInputSchema. Explicitly define whether null represents an MCP clear
operation, then make the corresponding field schemas and clear-flag validation
consistently accept or reject that representation.

In `@src/interfaces/contracts/warning-contract.ts`:
- Around line 15-22: The envelope payload schemas currently accept non-JSON
values, so define a shared recursive JSON-value schema and replace
cliSuccessEnvelopeSchema.data in
src/interfaces/contracts/warning-contract.ts:15-22 and
contractErrorSchema.details in src/interfaces/contracts/error-contract.ts:14-20
with it. Add tests covering accepted envelopes to verify JSON.stringify succeeds
without omission or failure.

In `@tests/unit/interfaces/contracts/agent-integration-contracts.test.ts`:
- Around line 194-206: Update the fixture validation loop in
tests/unit/interfaces/contracts/agent-integration-contracts.test.ts:194-206 to
parse each capture fixture’s CLI envelope with its existing parser, then
validate the envelope data using taskCaptureResultSchema. In
tests/fixtures/contracts/capture-success.json:4-5 and
tests/fixtures/contracts/capture-duplicate-warning.json:4-10, replace the
ID-only task data with complete public task DTOs while preserving the duplicate
warning in the latter fixture.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4f5c88d4-5e16-4dcd-a26d-d1254eacee80

📥 Commits

Reviewing files that changed from the base of the PR and between 1cd2aaa and 8b3ea35.

📒 Files selected for processing (20)
  • README.md
  • docs/cli-reference.md
  • docs/decisions/0002-agent-integration-contracts.md
  • docs/mcp-tools.md
  • docs/session-semantics.md
  • docs/superpowers/plans/2026-07-26-agent-integration-contracts.md
  • scripts/validate-repository-assets.ts
  • src/interfaces/contracts/contract-version.ts
  • src/interfaces/contracts/error-contract.ts
  • src/interfaces/contracts/session-contract.ts
  • src/interfaces/contracts/task-contract.ts
  • src/interfaces/contracts/warning-contract.ts
  • tests/fixtures/contracts/capture-duplicate-warning.json
  • tests/fixtures/contracts/capture-success.json
  • tests/fixtures/contracts/not-found-error.json
  • tests/fixtures/contracts/storage-error.json
  • tests/fixtures/contracts/transition-conflict-error.json
  • tests/fixtures/contracts/validation-error.json
  • tests/unit/interfaces/contracts/agent-integration-contracts.test.ts
  • tests/unit/scripts/validate-repository-assets.test.ts

Comment thread src/interfaces/contracts/task-contract.ts Outdated
Comment thread src/interfaces/contracts/warning-contract.ts
Comment thread tests/unit/interfaces/contracts/agent-integration-contracts.test.ts Outdated
@krishna916
krishna916 merged commit 6782536 into main Jul 26, 2026
1 of 2 checks passed
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.

Define MCP, CLI, session, and mutation contracts

1 participant