Skip to content

SDK transaction guards and extension runtime parity - #857

Merged
unbraind merged 3 commits into
mainfrom
feat/sdk-transaction-guards-and-runtime-parity
Aug 1, 2026
Merged

unbraind merged 3 commits into
mainfrom
feat/sdk-transaction-guards-and-runtime-parity

Conversation

@unbraind

@unbraind unbraind commented Aug 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add capability-gated, fail-closed beforeMutation extension hooks with canonical before/after documents, changed fields, stable diagnostics, and a host-bound read-only SDK
  • enforce guards across create, update, annotations, close, delete, restore, and structured transactions without item/history side effects on denial
  • inject the production-shaped SDK into extension command tests and add typed override seams
  • make active extension item types resolve consistently across the complete lifecycle
  • regenerate SDK/contracts/error catalogs, performance budgets, extension documentation, and the package-owned changelog

Project management

Fixes #853
Fixes #854
Fixes #855

Verification

  • full all-source suite: 413 files, 6,666 tests, 100% statements/branches/functions/lines
  • typecheck, ESLint, jscpd, static quality/docstrings, contracts, SDK surface, performance, security secret scan, and production dependency audit pass
  • isolated packed-package consumer created an item through context.sdk.client, enforced a mutation guard, and resolved the packed executable through local, npx --no-install, and bunx --no-install paths
  • PM health and history drift checks pass; package-owned pm-changelog 2026.8.1 output is stable

Compatibility note

The production-shaped test harness intentionally loads the native PmClient service graph. Its measured cold-import cost is isolated to @unbrained/pm-cli/sdk/testing and recorded in the regenerated reviewed budget; runtime entrypoints remain unchanged.

Summary by Sourcery

Introduce transactional before-mutation extension guards with a host-bound read-only SDK, and align extension runtime, item lifecycle, and test harness behavior with production semantics.

New Features:

  • Add capability-gated fail-closed beforeMutation hooks that can approve or deny item and history mutations based on canonical before/after documents, changed fields, and a read-only SDK.
  • Expose a minimal mutation-guard SDK with item get/list tracking services to extension hooks and authoring surfaces.
  • Extend the extension blueprint, capability derivation, and define* helpers to support the new beforeMutation hook surface and related contracts.
  • Provide test-harness support for invoking mutation guards and for injecting the real host-bound SDK (or typed overrides) into command dispatch.

Bug Fixes:

  • Ensure item type resolution for close, locate, and related lifecycle operations honors extension-registered custom types across all mutation paths.

Enhancements:

  • Centralize mutation-guard decision validation and error reporting into structured, stable diagnostics in the extension runtime.
  • Wire before-mutation guards into create, update, delete, restore, annotations, and structured transaction flows so denied mutations have no item or history side effects.
  • Track beforeMutation registrations in activation summaries, capability usage attribution, rollback handling, and hook-count reporting.
  • Tighten the extension loader and testing utilities around optional hook registries and hook-kind lookups.
  • Refresh performance budgets for SDK entrypoint import costs, reflecting the updated testing harness runtime.
  • Update extension author and testing documentation to describe transactional mutation guards, the host-bound SDK in tests, and mutation-guard exercise patterns.

Documentation:

  • Document the beforeMutation lifecycle hook, its canonical context payload, and fail-closed semantics in extension authoring guides.
  • Clarify test harness behavior for command dispatch with real SDK injection and for invoking mutation guards through the production-aligned runtime.
  • Update SDK performance documentation with new entrypoint import measurements reflecting the testing harness changes.

Tests:

  • Add a comprehensive extension mutation platform test suite covering SDK injection, guard decision normalization, denial behavior, and invariants enforced across item lifecycle operations.
  • Extend existing loader, compose, and define-builder tests to account for the new beforeMutation hook surface and updated hook-count expectations.

Chores:

  • Regenerate SDK public surface, contracts fixtures, error code catalog entries, performance budgets, and PM history/issue artifacts to reflect the new mutation-guard and testing capabilities.

Summary by cubic

Adds capability-gated beforeMutation guards to enforce extension invariants across item transactions with fail‑closed, stable diagnostics and a 5s timeout. Also injects a real host-bound SDK into extension command tests, unifies extension item-type resolution, and routes mutation guard testing through a dedicated helper.

  • New Features

    • Transactional beforeMutation guard with canonical before/after docs, changed fields, and operation; exposes a host-bound read‑only SDK; denial aborts with stable error codes (extension_mutation_guard_*); guard execution is bounded to 5s and fails closed.
    • Test harness injects a real host-bound SDK by default with a typed override seam; adds defineBeforeMutationHook, blueprint beforeMutation support, ExtensionMutationGuardSdk, and clarifies tracker‑root semantics.
  • Bug Fixes

    • Core mutation locators honor extension-registered item types across create/update/annotate/close/delete/restore and structured transaction paths; delete canonicalization preserves active extension metadata.
    • Generic hook runners now reject beforeMutation; tests invoke guards via the dedicated mutation-guard helper, preserving fail‑closed behavior for both registered and legacy empty registries.

Written for commit 36f55d6. Summary will update on new commits.

Review in cubic

Add capability-gated beforeMutation hooks with host-bound read-only SDK context and fail-closed stable diagnostics across create, update, annotations, close, delete, restore, and structured transaction paths.

Bring extension command tests to production SDK parity, unify active custom item-type lifecycle lookup, expand public contracts and 100% coverage, regenerate performance budgets and changelog, and record pm-wx2lr5, pm-hx23u5, and pm-scga6k delivery 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.

@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

@unbraind

unbraind commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@greptileai please review this exact head, including the transactional boundaries, extension SDK contracts, and denial side-effect guarantees.

@coderabbitai

coderabbitai Bot commented Aug 1, 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: 24 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: b71470d9-1891-4e25-87ca-7a168de8af91

📥 Commits

Reviewing files that changed from the base of the PR and between 9cebbe1 and 36f55d6.

📒 Files selected for processing (35)
  • .agents/pm/extensions/.managed-extensions.json
  • .agents/pm/history/pm-hx23u5.jsonl
  • .agents/pm/history/pm-scga6k.jsonl
  • .agents/pm/history/pm-wx2lr5.jsonl
  • .agents/pm/issues/pm-hx23u5.toon
  • .agents/pm/issues/pm-scga6k.toon
  • .agents/pm/issues/pm-wx2lr5.toon
  • CHANGELOG.md
  • docs/EXTENSIONS.md
  • docs/performance/sdk-entrypoint-import-costs.md
  • scripts/bench/sdk-entrypoint-budgets.json
  • sdk/public-surface.json
  • src/core/extensions/activation-summary.ts
  • src/core/extensions/activation-transaction.ts
  • src/core/extensions/capability-usage.ts
  • src/core/extensions/extension-hook-runtime.ts
  • src/core/extensions/extension-registries.ts
  • src/core/extensions/extension-types.ts
  • src/core/extensions/index.ts
  • src/core/extensions/loader.ts
  • src/core/store/item-store.ts
  • src/sdk/authoring.ts
  • src/sdk/compose.ts
  • src/sdk/define.ts
  • src/sdk/generated-error-code-catalog.ts
  • src/sdk/lifecycle/close.ts
  • src/sdk/lifecycle/create.ts
  • src/sdk/lifecycle/restore.ts
  • src/sdk/runtime-primitives.ts
  • src/sdk/testing.ts
  • tests/fixtures/contracts/full.json
  • tests/unit/extensions/extension-loader.spec.ts
  • tests/unit/sdk/sdk-compose.spec.ts
  • tests/unit/sdk/sdk-define.spec.ts
  • tests/unit/sdk/sdk-extension-mutation-platform.spec.ts
📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added transactional extension mutation guards that can approve or block item creation, updates, comments, deletions, and restores.
    • Added read-only SDK access for mutation guard checks and host-bound SDK injection for extension command tests.
    • Added support for extension-registered item types across lifecycle operations.
  • Bug Fixes

    • Improved custom item-type lookup during item closure and duplicate-target handling.
    • Added stable diagnostics and fail-closed behavior when mutation guards fail or return invalid decisions.
  • Documentation

    • Expanded extension guidance and updated SDK performance baselines.

Walkthrough

This change adds transactional beforeMutation extension guards, host-bound SDK injection for command tests, and active extension custom-type resolution across mutation lifecycles. It also updates public contracts, diagnostics, documentation, tests, performance budgets, and project-management records.

Changes

Extension mutation platform

Layer / File(s) Summary
Mutation contracts and hook runtime
src/core/extensions/*, src/sdk/define.ts, src/sdk/compose.ts
Adds beforeMutation contracts, capability and policy surfaces, ordered fail-closed execution, structured diagnostics, activation counts, rollback support, and declarative authoring helpers.
Transactional lifecycle integration
src/core/store/item-store.ts, src/sdk/lifecycle/*, src/sdk/runtime-primitives.ts
Runs guards before item and history persistence with canonical mutation context and a read-only SDK. Close operations resolve active extension item types.
SDK testing and public contracts
src/sdk/testing.ts, src/sdk/authoring.ts, sdk/public-surface.json, tests/fixtures/contracts/full.json
Adds command SDK injection and factories, mutation-guard test execution, typed hook assertions, public exports, mirrored entrypoint declarations, and stable error contracts.
Validation and documentation
tests/unit/extensions/*, tests/unit/sdk/*, docs/EXTENSIONS.md, CHANGELOG.md, docs/performance/*, scripts/bench/*
Covers guard decisions, fail-closed persistence, custom-type lifecycle parity, hook registration, SDK injection, documentation, and revised import budgets.
Project records
.agents/pm/*
Records issue implementation, validation evidence, closure, and managed-extension metadata updates.

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

Sequence Diagram(s)

sequenceDiagram
  participant ExtensionCommand
  participant MutationLifecycle
  participant BeforeMutationRuntime
  participant GuardSdk
  participant ItemHistoryStore
  ExtensionCommand->>MutationLifecycle: create, update, comment, delete, or restore
  MutationLifecycle->>GuardSdk: provide host-bound read-only access
  MutationLifecycle->>BeforeMutationRuntime: runActiveBeforeMutationHooks(context)
  BeforeMutationRuntime-->>MutationLifecycle: allow or structured denial
  MutationLifecycle->>ItemHistoryStore: persist item and history after approval
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address all linked objectives for host-bound SDK injection, transactional guards, and extension item-type resolution.
Out of Scope Changes check ✅ Passed The changes are related to the linked objectives, including implementation, tests, contracts, documentation, and supporting project records.
Docstring Coverage ✅ Passed Docstring coverage is 90.91% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title clearly summarizes the main changes: SDK transaction guards and extension runtime parity.
Description check ✅ Passed The description directly and comprehensively covers the mutation guards, SDK testing changes, item-type parity, and verification.
✨ 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.

@sourcery-ai

sourcery-ai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Reviewer's Guide

Introduce capability-gated, fail-closed transactional mutation guards into the extension runtime, wire them into all item lifecycle mutations with a host-bound read-only SDK, and bring the SDK testing harness and extension item-type resolution into parity with production, with supporting docs, error catalog, and performance budget updates.

Sequence diagram for fail-closed beforeMutation guards in item lifecycle

sequenceDiagram
  actor ExtensionPackage
  participant Lifecycle as mutateItem_create_delete_restore
  participant ExtRuntime as runActiveBeforeMutationHooks
  participant HookRuntime as runBeforeMutationHooks
  participant Guard as BeforeMutationHook

  ExtensionPackage->>Lifecycle: invoke mutation (create/update/delete/restore)
  Lifecycle->>Lifecycle: canonicalDocument(before/after)
  Lifecycle->>Lifecycle: createMutationGuardSdk(params)
  Lifecycle->>ExtRuntime: runActiveBeforeMutationHooks(context)
  ExtRuntime->>HookRuntime: runBeforeMutationHooks(hooks, context)
  loop each RegisteredExtensionHook<BeforeMutationHook>
    HookRuntime->>Guard: entry.run(context)
    HookRuntime->>HookRuntime: enforceMutationGuardDecision(decision, entry, operation)
  end
  alt all guards allow or return void
    HookRuntime-->>Lifecycle: success
    Lifecycle->>Lifecycle: persist item and history
  else any guard denial or failure
    HookRuntime-->>Lifecycle: throw PmCliError (extension_mutation_guard_*)
    Lifecycle-->>ExtensionPackage: mutation blocked, no item/history side effects
  end
Loading

File-Level Changes

Change Details Files
Add transactional before-mutation hook surface with strict decision validation and integration into the active extension runtime.
  • Define BeforeMutationHook, its context, decision type, and ExtensionMutationGuardSdk in the extension types and authoring surfaces.
  • Extend ExtensionHookRegistry, activation summaries, registries, rollback, and capability-usage tracking to include beforeMutation hooks.
  • Implement runBeforeMutationHooks and enforceMutationGuardDecision with structured PmCliError failures for malformed, denied, or failed guards.
  • Expose runBeforeMutationHooks and runActiveBeforeMutationHooks from the core extension runtime and SDK runtime primitives.
src/core/extensions/extension-hook-runtime.ts
src/core/extensions/loader.ts
src/core/extensions/extension-types.ts
src/core/extensions/index.ts
src/core/extensions/activation-transaction.ts
src/core/extensions/capability-usage.ts
src/core/extensions/activation-summary.ts
src/core/extensions/extension-registries.ts
src/sdk/runtime-primitives.ts
src/sdk/authoring.ts
sdk/public-surface.json
tests/fixtures/contracts/full.json
Wire mutation guards into all relevant item lifecycle operations using canonical before/after documents, changed-field tracking, and a host-bound read-only SDK.
  • Introduce createMutationGuardSdk that exposes get and list backed by the host item store.
  • Invoke runActiveBeforeMutationHooks from create, update, delete, restore, bulk/structured commit paths before item/history persistence, passing canonical before/after documents and changed_fields.
  • Ensure metadata updated_at and canonicalization ordering keeps guard inputs stable and consistent across operations.
src/core/store/item-store.ts
src/sdk/lifecycle/create.ts
src/sdk/lifecycle/delete.ts? (implicit via mutateItem/deleteItem integration)
src/sdk/lifecycle/restore.ts
src/core/extensions/index.ts
src/sdk/runtime-primitives.ts
Update SDK testing harness to inject the production-shaped extension command SDK, add a dedicated mutation-guard test runner, and tighten hook registration assertions.
  • Extend runRegisteredCommandForTest to accept sdk and sdkFactory overrides, defaulting to a real ExtensionCommandSdk built with PmClient when pmRoot is provided.
  • Add RunRegisteredMutationGuardForTestOptions, runRegisteredMutationGuardForTest, and harness.runMutationGuard to exercise beforeMutation guards through the real runtime.
  • Make registered hooks and hook-count accessors robust to missing/empty beforeMutation arrays and centralize RegisteredHookEntry typing.
  • Update ExtensionTestHarness, related helpers, and docs to describe the SDK injection behavior and mutation-guard seams.
src/sdk/testing.ts
src/sdk/extension-command-context.ts? (used in tests, no direct diff shown)
docs/EXTENSIONS.md
tests/unit/sdk/sdk-extension-mutation-platform.spec.ts
tests/unit/sdk/sdk-compose.spec.ts
tests/unit/sdk/sdk-define.spec.ts
Extend extension blueprint and define-* builders to support beforeMutation hooks and capability inference.
  • Add beforeMutation to ExtensionBlueprintHooks, merge/derive capability helpers, and blueprint summary surfaces including hook kind mapping.
  • Register blueprint beforeMutation hooks through ExtensionApi in canonical order, and include them in empty-surface diagnostics.
  • Introduce defineBeforeMutationHook and export it from the SDK barrel, with matching unit tests.
src/sdk/compose.ts
src/sdk/define.ts
src/sdk/authoring.ts
tests/unit/sdk/sdk-compose.spec.ts
tests/unit/sdk/sdk-define.spec.ts
Align item-type resolution with active extension registrations during close and related lifecycle operations.
  • Update resolveItemTypeRegistry usages in close lifecycle code to pass getActiveExtensionRegistrations so custom extension item types are honored.
  • Verify custom types are respected across update, annotation, bulk mutations, close, delete, and restore via integration tests.
src/sdk/lifecycle/close.ts
src/sdk/runtime-primitives.ts
tests/unit/sdk/sdk-extension-mutation-platform.spec.ts
Regenerate error catalog and performance budgets to cover mutation-guard diagnostics and SDK import costs.
  • Add stable error codes for extension_mutation_guard_failed, extension_mutation_guard_invalid_decision, and extension_mutation_guard_invalid_denial with exit_code 4.
  • Update sdk-entrypoint import performance table and JSON budgets to reflect new measured costs, particularly for ./sdk/testing and runtime.
  • Ensure pm-changelog and PM history/issue artifacts reference new GH issues and PM tasks for guards and SDK parity.
src/sdk/generated-error-code-catalog.ts
docs/performance/sdk-entrypoint-import-costs.md
scripts/bench/sdk-entrypoint-budgets.json
.agents/pm/history/pm-hx23u5.jsonl
.agents/pm/history/pm-scga6k.jsonl
.agents/pm/history/pm-wx2lr5.jsonl
.agents/pm/issues/pm-hx23u5.toon
.agents/pm/issues/pm-scga6k.toon
.agents/pm/issues/pm-wx2lr5.toon
CHANGELOG.md
.agents/pm/extensions/.managed-extensions.json

Assessment against linked issues

Issue Objective Addressed Explanation
#853 Ensure the extension command test helpers (including createExtensionTestHarness().runCommand and runRegisteredCommandForTest) construct and inject a real host-bound ExtensionCommandSdk into CommandHandlerContext.sdk when a pmRoot is provided, mirroring production dispatch. ✅
#853 Expose typed options on the command testing helpers to allow explicit SDK injection via a provided sdk instance or sdkFactory function for specialized tests. ✅
#854 Add a pre-commit transactional mutation guard hook surface for extensions that receives canonical before/after item documents, changed_fields, operation, and a host-bound read-only SDK, and that can allow or deny mutations with stable codes/remediation or throw errors, running inside the same item/history transaction before persistence. ✅
#854 Integrate the mutation guard so it consistently covers all core mutation routes (CLI commands, PmClient operations, workspace/structured transactions, delete/restore/update-many/annotations) with fail-closed behavior and capability-gated registration, and add testing hooks and contracts for extensions to exercise this surface. ✅
#854 Document the new transactional mutation guard and related SDK/testing behavior in the extension and SDK documentation and error catalogs, including stable public error codes for guard failures and invalid decisions/denials. ✅
#855 Ensure all core mutation paths (close, update, comments/notes, delete/restore, batch/transactions, etc.) resolve items using the active extension item-type registry so items created with extension-registered custom types are locatable for mutations. ✅
#855 Add test coverage that simulates an installed extension registering a custom item type, creating an item via the host-injected context.sdk.client, and exercising the full read/mutation lifecycle to prevent regressions. ✅

Possibly linked issues


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

@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

@unbraind I will perform a complete review of #857. I will verify transactional boundaries, extension SDK contracts, and denial side-effect guarantees.

✅ 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

codspeed Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 11 untouched benchmarks


Comparing feat/sdk-transaction-guards-and-runtime-parity (36f55d6) with main (9cebbe1)

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!

@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

Caution

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

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

465-488: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Remove before_mutation from runRegisteredHookForTest.

before_mutation has dedicated helpers (runRegisteredMutationGuardForTest and runBeforeMutationHooks), but runRegisteredHookForTest lacks a switch branch for it. A registered mutation guard passes the registration check and then returns undefined; use assertRegisteredHook for registrations and call the mutation guard helper for invocation.

🤖 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/testing.ts` around lines 465 - 488, Remove before_mutation from the
RegisteredHookKind/HOOK_KIND_TO_REGISTRY_FIELD path used by
runRegisteredHookForTest, and update that method to reject it through the
existing assertRegisteredHook validation rather than silently returning
undefined. Keep mutation-hook invocation routed through
runRegisteredMutationGuardForTest and runBeforeMutationHooks.
🤖 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/core/extensions/extension-hook-runtime.ts`:
- Around line 132-163: Update runBeforeMutationHooks so each entry.run
invocation is bounded by the established guard-timeout mechanism or a defined
timeout race. When the timeout wins, throw a PmCliError with conflict semantics
and structured code extension_mutation_guard_timed_out, including the guard
identity and actionable next steps; preserve existing PmCliError propagation and
extension_mutation_guard_failed handling for non-timeout failures.

In `@src/core/store/item-store.ts`:
- Around line 874-888: The delete path in deleteItem currently canonicalizes
beforeDocument without active extension field names. Update the
canonicalDocument call to use the existing helper or options that collect and
pass extensionFieldNames, while preserving the schema, so extension-registered
fields remain available to mutation hooks, history, and service-override
payloads.

In `@src/sdk/testing.ts`:
- Around line 210-214: Update the documentation for sdkFactory and its pmRoot
context property to explicitly state that pmRoot is the tracker storage root,
not the workspace root, and should be used for tracker data under .agents/pm.

---

Outside diff comments:
In `@src/sdk/testing.ts`:
- Around line 465-488: Remove before_mutation from the
RegisteredHookKind/HOOK_KIND_TO_REGISTRY_FIELD path used by
runRegisteredHookForTest, and update that method to reject it through the
existing assertRegisteredHook validation rather than silently returning
undefined. Keep mutation-hook invocation routed through
runRegisteredMutationGuardForTest and runBeforeMutationHooks.
🪄 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: 3c99b966-19ce-48da-a4eb-47d544a1b4fb

📥 Commits

Reviewing files that changed from the base of the PR and between 9cebbe1 and 3a69a7e.

📒 Files selected for processing (35)
  • .agents/pm/extensions/.managed-extensions.json
  • .agents/pm/history/pm-hx23u5.jsonl
  • .agents/pm/history/pm-scga6k.jsonl
  • .agents/pm/history/pm-wx2lr5.jsonl
  • .agents/pm/issues/pm-hx23u5.toon
  • .agents/pm/issues/pm-scga6k.toon
  • .agents/pm/issues/pm-wx2lr5.toon
  • CHANGELOG.md
  • docs/EXTENSIONS.md
  • docs/performance/sdk-entrypoint-import-costs.md
  • scripts/bench/sdk-entrypoint-budgets.json
  • sdk/public-surface.json
  • src/core/extensions/activation-summary.ts
  • src/core/extensions/activation-transaction.ts
  • src/core/extensions/capability-usage.ts
  • src/core/extensions/extension-hook-runtime.ts
  • src/core/extensions/extension-registries.ts
  • src/core/extensions/extension-types.ts
  • src/core/extensions/index.ts
  • src/core/extensions/loader.ts
  • src/core/store/item-store.ts
  • src/sdk/authoring.ts
  • src/sdk/compose.ts
  • src/sdk/define.ts
  • src/sdk/generated-error-code-catalog.ts
  • src/sdk/lifecycle/close.ts
  • src/sdk/lifecycle/create.ts
  • src/sdk/lifecycle/restore.ts
  • src/sdk/runtime-primitives.ts
  • src/sdk/testing.ts
  • tests/fixtures/contracts/full.json
  • tests/unit/extensions/extension-loader.spec.ts
  • tests/unit/sdk/sdk-compose.spec.ts
  • tests/unit/sdk/sdk-define.spec.ts
  • tests/unit/sdk/sdk-extension-mutation-platform.spec.ts

Comment thread src/core/store/item-store.ts Resolved
Comment thread src/sdk/testing.ts Resolved
Fail closed stalled mutation guards after five seconds, preserve active extension metadata during delete canonicalization, and clarify tracker-root semantics in the command test harness.

Add regression coverage, regenerate public error/contracts surfaces, and append exact-head review evidence to pm-hx23u5 and pm-wx2lr5.
Keep fail-closed beforeMutation invocation on the dedicated mutation-guard helper and reject unsupported runtime input instead of silently returning undefined.

Cover registered and legacy empty registries, retain 100/100/100/100 coverage, and record the outside-diff review evidence on pm-wx2lr5.
@unbraind

unbraind commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

@codspeed-hq Acknowledged the no-regression report at #857 (comment). The reviewed SDK/testing cold-import cost is separately budgeted, while the tracked runtime benchmarks remain unchanged and passing.

@unbraind

unbraind commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

@sourcery-ai The reviewer guide at #857 (comment) accurately maps the change and was useful for cross-checking scope. The separate rate-limit review at #857 (review) contains no actionable code feedback; all repository gates remain green.

@unbraind

unbraind commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

@gemini-code-assist Acknowledged the sunset notice in #857 (comment). It contains no code finding to apply; the unavailable reviewer is therefore recorded as non-actionable.

@unbraind

unbraind commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

@codecov Acknowledged the patch report at #857 (comment). After both review-fix commits, the full local all-source gate still reports 6,666 tests and 100% statements, branches, functions, and lines.

@unbraind

unbraind commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai The walkthrough and command acknowledgement at #857 (comment) and #857 (comment) were useful. All three inline findings and the review-level outside-diff finding in #857 (review) are implemented on exact head 36f55d697: bounded fail-closed timeout, extension-field-safe delete snapshots, tracker-root docs, and rejection of mutation guards in the generic hook runner. Full coverage is 100/100/100/100.

@coderabbitai full review

@greptileai please perform a fresh review of exact head 36f55d697, including both review-fix commits and the dedicated mutation-guard test boundary.

@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

@unbraind I will perform a fresh full review of #857 at head 36f55d697. I will include the review-fix commits and the mutation-guard test boundary.

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

@unbraind

unbraind commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

@gemini-code-assist The repeated sunset notice at #857 (comment) is acknowledged as unavailable and non-actionable.

@coderabbitai The final-head request response at #857 (comment) confirms the full review was requested but unavailable under the included rate limit. We waited through the full CI/review window; all earlier findings are fixed, every finding thread is resolved, and all exact-head checks pass.

@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

Tip

For best results, initiate chat on the files or code changes.

@unbraind Acknowledged. The prior full-review request did not run because of the included review limit. You report that the exact head has all prior findings fixed, all review threads resolved, and all checks passing.

You are interacting with an AI system.

@unbraind

unbraind commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

Final bot-artifact acknowledgement: the repeated Gemini sunset notice at #857 (comment) remains unavailable/non-actionable, and the CodeRabbit response at #857 (comment) confirms the exact-head request was accepted but rate-limited. Both were reacted to by usefulness. No unresolved review threads remain, and exact head 36f55d697 is mergeable with every check successful.

@unbraind
unbraind merged commit 850c176 into main Aug 1, 2026
32 checks passed
@unbraind
unbraind deleted the feat/sdk-transaction-guards-and-runtime-parity branch August 1, 2026 15:24
@unbraind

unbraind commented Aug 4, 2026

Copy link
Copy Markdown
Owner Author

Tracked in PM: pm-hx23u5, pm-scga6k, pm-wx2lr5.

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