Skip to content

feat(sdk): make project context integrity explicit - #767

Merged
unbraind merged 3 commits into
mainfrom
feat/sdk-context-integrity-contracts
Jul 27, 2026
Merged

feat(sdk): make project context integrity explicit#767
unbraind merged 3 commits into
mainfrom
feat/sdk-context-integrity-contracts

Conversation

@unbraind

@unbraind unbraind commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Outcome

This broad SDK/CLI bundle turns context integrity into explicit, machine-readable contracts across five related failure surfaces:

  • certifies list corpora as complete, partial, or unchecked and adds strict fail-closed reads across CLI, SDK, and tool schemas;
  • records dependency author provenance and mutation source consistently;
  • quarantines malformed extension commands without losing healthy siblings or suggesting reinstall of an installed package;
  • constrains recovery inference to the invoked command contract and emits valid strict-close recovery;
  • fixes merge receipt path quoting and refreshes merge fences for every runtime item type.

It also updates generated contracts, the public SDK surface, token budgets, documentation, the package-generated changelog, PM histories, and focused regressions.

PM lineage

Verification

  • 377 test files / 6,452 tests
  • 100% statements, branches, functions, and lines (44,548 / 31,650 / 9,116 / 43,281)
  • static quality and 100% docstring gates
  • SDK surface, entrypoint-cost, CLI transport, token-budget, docs/skills, package-boundary, version-sync, and secret gates
  • packed npm smoke and 88-command package-first dogfood
  • fresh unrelated packed consumer through direct binary, npx, and bunx with strict completeness and dependency-provenance assertions
  • PM validation: zero history drift and zero in-progress items

Closes #752
Closes #755
Closes #757
Closes #763
Closes #764


Summary by cubic

Make context integrity explicit across the SDK and CLI. Adds truthful list completeness with strict reads, preserves dependency provenance, isolates bad extension commands, tightens recovery hints, fixes merge receipt quoting, and keeps committed merge fences extension‑independent.

  • New Features

    • List completeness: results include completeness with unreadable counts; add --strict-read to fail closed in pm list* and SDK/MCP tool contracts.
    • Dependency provenance: dependency writes set author, author_source, and source_kind (defaults to detected author and CLI source); persisted and rendered in items.
    • Extension isolation: malformed definition-based commands are quarantined per-command; valid siblings still activate; unknown-command recovery surfaces the failure without reinstall advice.
    • Structured recovery: missing-flag and retry hints are derived from the invoked command’s contract only; close --validate-close strict emits a concrete retry when required fields are missing.
  • Bug Fixes

    • List truthfulness: fixes cases where unreadable items were silently dropped while reporting complete results.
    • Merge safety: driver config now passes %P without extra quotes and receipts strip one legacy quote pair; committed fences are extension‑independent (extension-owned types stay clone‑local).
    • Guidance hygiene: suppress “install ” hints when the matching installed extension failed activation; stop mining free-form error prose for flag names.

Written for commit 943776b. Summary will update on new commits.

Review in cubic

Deliver a cohesive SDK and CLI context-management bundle across list corpus completeness, dependency provenance, extension command quarantine, structured recovery, and merge receipt safety.\n\nExpose strict fail-closed reads through CLI/SDK/tool contracts, preserve author and source provenance on dependency edges, retain healthy extension commands when siblings are malformed, constrain recovery inference to invoked-command contracts, normalize legacy merge receipt quoting, and refresh merge fences for every runtime item type.\n\nUpdate generated contracts, public surface, token budgets, package changelog, operator documentation, PM evidence, and regression coverage. Full release gates pass locally through 6452 tests at 100/100/100/100, packed npm smoke, and 88-command package-first dogfood; exact-SHA hosted analysis follows after push.
@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

Record PR #767 and implementation head ab7f41a in each of the five delivered canonical PM items before exact-head hosted review.
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 53 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: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 97638f56-621a-4517-b39b-7da873139d61

📥 Commits

Reviewing files that changed from the base of the PR and between f4817e0 and 943776b.

📒 Files selected for processing (53)
  • .agents/pm/extensions/.managed-extensions.json
  • .agents/pm/features/pm-w7mqzt.toon
  • .agents/pm/history/pm-0a24f5.jsonl
  • .agents/pm/history/pm-57ir3b.jsonl
  • .agents/pm/history/pm-9nfpwd.jsonl
  • .agents/pm/history/pm-gnowgi.jsonl
  • .agents/pm/history/pm-ikv6m0.jsonl
  • .agents/pm/history/pm-w7mqzt.jsonl
  • .agents/pm/issues/pm-0a24f5.toon
  • .agents/pm/issues/pm-57ir3b.toon
  • .agents/pm/issues/pm-9nfpwd.toon
  • .agents/pm/issues/pm-gnowgi.toon
  • .agents/pm/issues/pm-ikv6m0.toon
  • CHANGELOG.md
  • docs/COMMANDS.md
  • docs/EXTENSIONS.md
  • docs/MERGE_SAFETY.md
  • docs/SDK.md
  • scripts/release/token-budgets.json
  • sdk/public-surface.json
  • src/cli/commander-usage.ts
  • src/cli/commands/close.ts
  • src/cli/commands/create.ts
  • src/cli/commands/update.ts
  • src/cli/error-guidance.ts
  • src/cli/main.ts
  • src/cli/register-list-query.ts
  • src/cli/registration-helpers.ts
  • src/core/extensions/loader.ts
  • src/core/item/item-format.ts
  • src/sdk/cli-contracts/flag-contracts.ts
  • src/sdk/cli-contracts/tool-parameter-tables.ts
  • src/sdk/cli-contracts/tool-schema.ts
  • src/sdk/merge/install.ts
  • src/sdk/merge/receipts.ts
  • src/sdk/query/list.ts
  • src/sdk/structured-mutations.ts
  • src/types.ts
  • tests/fixtures/contracts/full.json
  • tests/integration/cli.integration.spec.ts
  • tests/integration/dependency-alias.integration.spec.ts
  • tests/integration/help-runtime.spec.ts
  • tests/integration/release-readiness-runtime.spec.ts
  • tests/unit/cli/cli-main-errors.spec.ts
  • tests/unit/cli/error-guidance.spec.ts
  • tests/unit/commands/close-command.spec.ts
  • tests/unit/commands/create-command.spec.ts
  • tests/unit/commands/list-command.spec.ts
  • tests/unit/commands/update-command.spec.ts
  • tests/unit/extensions/extension-loader-internal.spec.ts
  • tests/unit/extensions/extension-loader.spec.ts
  • tests/unit/sdk/merge-receipts.spec.ts
  • tests/unit/sdk/merge-safety.spec.ts

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 please review the complete exact head 04ddbd7. Focus on SDK/CLI contract integrity, extension quarantine, recovery scope, merge safety, and agent-token efficiency.

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
✅ 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 59 minutes.

@codspeed-hq

codspeed-hq Bot commented Jul 27, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 2.48%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 10 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
createQueryFingerprint 533.9 µs 521 µs +2.48%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing feat/sdk-context-integrity-contracts (943776b) with main (f4817e0)

Open in CodSpeed

@unbraind

Copy link
Copy Markdown
Owner Author

Gemini Code Assist sunset notice acknowledged (comment 5089182623): this provided no code review or actionable finding, so no implementation response is required. Exact-head validation remains covered by the active hosted gates and available reviewers.

@unbraind

Copy link
Copy Markdown
Owner Author

CodeRabbit rate-limit notices acknowledged (comments 5089187281 and 5089189098): they selected the full 54-file exact-head range but returned no code findings because the included review quota is unavailable. This is reviewer infrastructure unavailability, not an approval; the PR remains open for Greptile and all required hosted checks.

@unbraind

Copy link
Copy Markdown
Owner Author

Sourcery review 4785185199 acknowledged: it returned only a weekly diff-character quota notice and no code finding. This is recorded as reviewer unavailability, while exact-head CI, security scanners, and the requested Greptile review continue independently.

@codecov

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

Remove clone-local package item types written by an extension-enabled merge install. The committed fence must be reproducible under CI's --no-extensions contract while extension-owned runtime types remain clone-local.\n\nRecord the hosted failure diagnosis and exact passing merge-safety sequence in pm-9nfpwd.
@unbraind

Copy link
Copy Markdown
Owner Author

Hosted static-gate correction pushed at exact head 943776b: the committed merge fence is now reproducible under --no-extensions, and the exact CI merge-install, strict storage/history validation, and representative history verification sequence passes locally. @greptileai please review this complete exact head.

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai full review exact head 943776b

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

@unbraind: I’ll perform a full review of the PR at exact head 943776bd2687436c61e371d17cb8c847690632be, focusing on the stated SDK/CLI contract, extension quarantine, recovery, merge-safety, and token-efficiency concerns.

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

@unbraind

Copy link
Copy Markdown
Owner Author

CodSpeed report 5089210171 acknowledged and up-voted: exact head 943776b shows a measured 2.48% improvement in createQueryFingerprint with the other ten benchmarks unchanged. Because the report flags differing runtime environments, I am treating the magnitude as directional evidence only; the mandatory benchmark gate itself is green.

@unbraind

Copy link
Copy Markdown
Owner Author

Codecov report 5089221700 acknowledged and up-voted: all modified coverable lines are covered and all tests passed. This agrees with the four green hosted coverage shards and the local 44,548/31,650/9,116/43,281 100% coverage result.

@unbraind

Copy link
Copy Markdown
Owner Author

CodeRabbit exact-head response 5089237830 acknowledged and down-voted: it confirms receipt of head 943776b but again returns only fair-usage unavailability and no code finding. It is recorded as unavailable review infrastructure, not approval or evidence against the independently green gates.

@unbraind

Copy link
Copy Markdown
Owner Author

Final exact-head review inventory for 943776b: all required checks are green; all four coverage shards and the aggregate coverage gate pass; static, typecheck, compatibility, smokes, Windows/macOS/Linux runtime, docs, benchmarks, CodeQL, DeepScan, CodeFactor, Hound, Semgrep, Trivy, TruffleHog, ShellCheck, PSScriptAnalyzer, actionlint, Codecov, and CodSpeed are successful. There are zero inline review threads. Every surfaced bot comment/review has a usefulness reaction and explicit disposition. CodeRabbit and Sourcery returned quota unavailability without findings; Gemini is sunset. Greptile was explicitly requested twice, including after the final push, but exposed no check/comment/review, so it is recorded as unavailable rather than approval.

@unbraind
unbraind merged commit 868529f into main Jul 27, 2026
32 checks passed
@unbraind
unbraind deleted the feat/sdk-context-integrity-contracts branch July 27, 2026 08:54
@unbraind

unbraind commented Aug 4, 2026

Copy link
Copy Markdown
Owner Author

Tracked in PM: pm-0a24f5, pm-57ir3b, pm-9nfpwd, pm-gnowgi, pm-ikv6m0.

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