Skip to content

feat(sdk): govern runtime context, write safety, and verification gates - #935

Merged
unbraind merged 6 commits into
mainfrom
feat/sdk-runtime-context-gate-primitives
Aug 8, 2026
Merged

unbraind merged 6 commits into
mainfrom
feat/sdk-runtime-context-gate-primitives

Conversation

@unbraind

@unbraind unbraind commented Aug 8, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add SDK-owned project-runtime compatibility and action-aware stale mutation refusal while preserving read-only context
  • add reusable host-environment faults plus linked-test source-context write fencing and safe merge-install resolution
  • make the gate registry own the canonical local preflight receipt and strengthen refusal/surface replication governance
  • pin patched nanoid 3.3.17 to clear GHSA-2v37-7h3g-55p8 without unrelated dependency churn

PM lineage

Verification

  • 453 test files / 7,061 tests
  • exact 100/100/100/100 coverage: 50,228 statements, 36,690 branches, 10,319 functions, 48,631 lines
  • full lint/static gates: ESLint, zero clones, 100% docstrings, SDK/package parity, token/context/tracker ratchets, SDK surface and performance floors
  • typecheck, build, package artifact, secret scan, and full pnpm audit pass
  • packed npx/bunx lifecycle and temporary two-repository nested merge-install acceptance pass
  • pm validation has zero history drift; health has zero warnings; no PM items remain in progress

Closes #926
Closes #933
Refs #934

Summary by Sourcery

Enforce SDK-governed runtime compatibility and host-environment fault handling, tighten source-context write safety, and formalize local/hosted gate parity and CLI refusal ownership while pinning a patched nanoid version.

New Features:

  • Introduce project runtime compatibility primitives that classify mutating CLI invocations, detect stale executables against project pm version pins, and expose inspection/assertion APIs for packages and automation.
  • Add a host-environment error boundary that standardizes classification and redaction of filesystem and resource faults across SDK operations.
  • Expose a source-context access policy that distinguishes read-only from writable inherited coordinates and reports override status to SDK consumers.
  • Provide a registry-owned local preflight entrypoint that validates the executed gate receipt against gate-registry.json and maps hosted-only gates with explicit reasons.

Bug Fixes:

  • Prevent nested linked tests from mutating the source project by default by marking inherited source context as read-only and requiring an explicit one-shot override for writes.
  • Ensure release gate receipts cannot drift from the governed registry by rejecting missing, reordered, or undeclared local preflight steps.
  • Improve surface replication coverage by detecting untracked files and by failing when CLI refusal ownership declarations are incomplete or inconsistent.

Enhancements:

  • Refactor workspace snapshot filesystem error handling to reuse the shared host-environment fault boundary while preserving existing snapshot-specific error codes and recovery flows.
  • Extend merge-install to resolve tracker/workspace context via a reusable resolution primitive that respects source-context write policy and dry-run behavior, improving safety for linked tests.
  • Expand the surface replication gate to inventory CLI refusal rules with per-occurrence ownership metadata and to include untracked files in change discovery.
  • Strengthen gate registry validation by requiring a canonical local preflight declaration with complete gate coverage and hosted-only waivers.
  • Wire the CLI entrypoint through the new runtime-compatibility boundary so stale mutations are refused with structured guidance while non-mutating commands remain available.

Build:

  • Add a verify:preflight package script that runs the canonical local release gate selection.
  • Pin nanoid to a patched 3.3.17 range in the workspace overrides to address GHSA-2v37-7h3g-55p8 without broader dependency changes.

CI:

  • Align gate-registry.json with the new local preflight model and hosted-only gate declarations to maintain parity between local verification and CI workflows.

Documentation:

  • Document SDK runtime boundaries, including project runtime compatibility, host-environment fault handling, and CLI refusal ownership contracts.
  • Update agent runtime, testing, and releasing guides to describe source-context access controls, the verify:preflight workflow, and local/hosted gate parity governance.

Tests:

  • Add comprehensive unit tests for project runtime compatibility classification, pin discovery, CLI boundary behavior, host-environment error translation, source-context policy, gate registry local preflight validation, release gate receipt drift detection, and extended surface replication behavior.
  • Extend merge-safety and linked-test execution tests to cover source-context read-only enforcement and explicit write overrides.

Chores:

  • Record PM tracking metadata for runtime compatibility, gate parity, CLI refusal ownership, linked-test safety, and nanoid security updates in the repository agents.

Summary by cubic

Adds SDK-governed runtime safety and a registry-owned, fail-closed preflight so stale pm binaries can’t mutate projects; stale reads now warn without blocking; linked tests inherit read-only source context; host faults are classified; pins nanoid to 3.3.17.

  • New Features - New features added

    • Stale runtime guard runs before dispatch with action-aware command classification (handles equals-form flags and global value flags after the command); read-only commands remain; typed stale-read diagnostics and CLI warnings preserve stdout for --json/equals-form flags; one-shot override via PM_ALLOW_STALE_CLI=1 (Warn before a stale global pm mutates a project pinned to a newer CLI/SDK #926, pm-zjelve).
    • Linked-test source-context write fencing defaults to read-only via PM_SOURCE_CONTEXT_ACCESS=read_only; allow a single write with PM_ALLOW_SOURCE_CONTEXT_WRITES=1; resolveMergeInstallContext enables non-writing resolution and merge-install honors policy (Agent safety: nested PM writes in non-PM linked tests can mutate the source project #933).
    • Host environment fault boundary classifies capacity/permission/resource errors, redacts paths, and is applied to workspace snapshots with distinct codes; SDK exports helpers; preserves dependency-free fast --version startup (pm-dskxwf).
    • Gate registry owns the executable local preflight; pnpm verify:preflight runs the canonical plan and records explicit skipped receipts; run fails on drift or undeclared steps; stronger per-occurrence CLI refusal ownership inventory and untracked-file detection; pins nanoid 3.3.17 (pm-n41vay).
  • Migration - Steps needed for adoption

    • If a mutation is refused as stale: upgrade @unbrained/pm-cli to the project’s pin, or set PM_ALLOW_STALE_CLI=1 to proceed once; reads still work and now warn.
    • Linked tests inherit PM_SOURCE_CONTEXT_ACCESS=read_only; set PM_ALLOW_SOURCE_CONTEXT_WRITES=1 to permit a single nested write when needed.
    • Use pnpm verify:preflight to run the canonical local gates; receipts and step set are enforced at exact Git HEAD.

Written for commit 13aabce. Summary will update on new commits.

Review in cubic

Add SDK-owned stale project-runtime compatibility, action-aware mixed command classification, source-context write fencing for linked tests, and reusable host environment fault contracts.\n\nMake the gate registry own the canonical local preflight receipt, strengthen CLI refusal ownership and untracked-file replication checks, document the new runtime boundaries, and preserve exact SDK surface contracts.\n\nResolve the nanoid advisory with a narrow patched floor, regenerate the pm-changelog output, and record complete PM lineage and verification evidence.
@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added runtime compatibility checks that prevent stale CLI versions from performing project mutations, with read-only diagnostics and an explicit recovery override.
    • Added standardized host-environment errors with redacted paths, stable codes, and recovery guidance.
    • Linked tests now default to read-only source context, preventing unintended source changes.
    • Added a registry-driven local release preflight command with drift detection.
  • Bug Fixes

    • Patched a transitive security vulnerability.
    • Improved CLI and SDK refusal-code consistency.
  • Documentation

    • Expanded runtime-boundary, testing, and release guidance.

Walkthrough

The change adds runtime compatibility checks, linked-test source-write isolation, shared host filesystem error translation, registry-driven release preflight execution, refusal-parity validation, dependency remediation records, and related tests and documentation.

Changes

Runtime safety and release governance

Layer / File(s) Summary
Runtime compatibility enforcement
src/sdk/environment/project-runtime-compatibility.ts, src/cli/runtime-compatibility-boundary.ts, src/cli.ts, tests/unit/sdk/project-runtime-compatibility.spec.ts, tests/unit/cli/runtime-compatibility-boundary.spec.ts
The SDK discovers project runtime pins and classifies commands. Stale mutations fail with structured errors. Read-only commands and explicit overrides remain supported.
Linked-test source-write isolation
src/sdk/environment/source-context.ts, src/sdk/merge/install.ts, src/sdk/test/*, tests/unit/sdk/source-context.spec.ts, tests/unit/sdk/merge-safety.spec.ts
Linked tests receive read-only source context. Merge installation selects safe workspace targets unless an explicit write override is active.
Host filesystem fault boundary
src/sdk/environment/host-environment-errors.ts, src/sdk/workspace-snapshot.ts, src/sdk/generated-error-code-catalog.ts, tests/unit/sdk/host-environment-errors.spec.ts
Recognized filesystem faults produce path-redacted structured errors with stable codes and recovery guidance. Workspace snapshots use the shared boundary.
Release preflight and parity gates
scripts/release/gate-registry.json, scripts/release/gate-registry.mjs, scripts/release/run-gates.mjs, scripts/release/surface-replication-*, tests/unit/scripts/release/*, tests/integration/release-automation-contract.spec.ts, package.json
The registry defines ordered local preflight steps. Validation checks executable definitions, skip policies, hosted-only reasons, and gate coverage. Gate execution uses registry-defined commands and variables. Refusal ownership covers all occurrences.
Project records and release evidence
.agents/pm/**/*, pnpm-workspace.yaml, CHANGELOG.md, docs/*, tests/fixtures/contracts/full.json, sdk/public-surface.json
Project records document runtime, source-write, host-error, release-parity, dependency, and security work. Public surface and structured error contract fixtures include the new declarations and codes.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Agent
  participant CLI
  participant SDK
  participant Project
  participant ReleaseGates
  Agent->>CLI: invoke command
  CLI->>SDK: inspect project runtime compatibility
  SDK->>Project: read manifests and lockfiles
  SDK-->>CLI: allow read, allow override, or reject stale mutation
  CLI->>ReleaseGates: run registry-defined preflight
  ReleaseGates-->>CLI: report gate results and refusal parity
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR also includes unrelated gate-registry, host-environment, surface-replication, and nanoid-security changes beyond [#926] and [#933]. Split the unrelated gate, host-environment, surface-replication, and nanoid-security changes into separate PRs or link issues that justify their inclusion.
Docstring Coverage ⚠️ Warning Docstring coverage is 64.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The implementation addresses stale-runtime mutation refusal and read-only compatibility [#926], plus inherited linked-test write protection with explicit overrides [#933].
Title check ✅ Passed The title clearly summarizes the main SDK runtime-safety and verification-gate changes.
Description check ✅ Passed The description directly covers the runtime safety, write fencing, verification gates, security fix, tests, and documentation 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.

@sourcery-ai

sourcery-ai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR introduces SDK-level runtime compatibility enforcement and host-environment fault handling, adds a source-context write policy for linked tests and merge-install, makes the release gate registry own the canonical local preflight and receipt validation, tightens CLI refusal ownership reporting, and pins nanoid to a patched version for a security advisory.

Sequence diagram for CLI runtime compatibility enforcement

sequenceDiagram
  actor User
  participant CliEntrypoint as cli_ts
  participant RuntimeBoundary as runRuntimeCompatibleCli
  participant RuntimeCompat as assertProjectRuntimeCompatibility
  participant CliMain as runCliWithBundleIntegrity

  User->>CliEntrypoint: invoke_cli
  CliEntrypoint->>RuntimeBoundary: runRuntimeCompatibleCli(executingVersion, projectRoot, argv, allowStale)
  alt executingVersion_defined
    RuntimeBoundary->>RuntimeCompat: assertProjectRuntimeCompatibility({executingVersion, projectRoot, argv, allowStale})
    RuntimeCompat-->>RuntimeBoundary: ProjectRuntimeCompatibilityResult
  end
  alt compatible_invocation
    RuntimeBoundary->>CliMain: runCliWithBundleIntegrity(argv, cliEntrypointPath, import_cli_main, writeError)
    CliMain-->>RuntimeBoundary: ok_or_PmCliError
  else stale_mutation
    RuntimeCompat-->>RuntimeBoundary: throw PmCliError(project_runtime_stale_mutation)
  end
  alt PmCliError_thrown
    RuntimeBoundary->>RuntimeBoundary: formatPmCliErrorForDisplay_or_formatPmCliErrorForJson
    RuntimeBoundary-->>CliEntrypoint: writeError(formatted_error)
    RuntimeBoundary->>RuntimeBoundary: set_process_exitCode
  else unexpected_error
    RuntimeBoundary-->>CliEntrypoint: rethrow_error
  end
Loading

Sequence diagram for gate-registry local preflight receipt validation

sequenceDiagram
  actor Developer
  participant RunGates as run_gates_mjs
  participant RegistryFile as gate_registry_json
  participant Validator as validateGateRegistry

  Developer->>RunGates: node scripts/release/run-gates.mjs
  RunGates->>RunGates: runCheckedStep(...)
  RunGates-->>Developer: checks_array
  Developer->>RunGates: request_json_or_text_output
  RunGates->>RegistryFile: readFileSync(gate-registry.json)
  RegistryFile-->>RunGates: registry_object
  RunGates->>RunGates: assertRegistryPreflightReceipt(checks)
  RunGates->>Validator: validateGateRegistry(registry, {discovered})
  Validator-->>RunGates: violations
  alt receipt_matches_registry && violations_empty
    RunGates-->>Developer: { ok: true, checks }
  else receipt_mismatch_or_violations
    RunGates->>RunGates: fail("Local preflight drifted" or "Gate registry validation failed")
    RunGates-->>Developer: nonzero_exit
  end
Loading

File-Level Changes

Change Details Files
Introduce SDK primitives for project runtime compatibility and integrate a CLI boundary that refuses stale project mutations while preserving read-only commands.
  • Add project-runtime compatibility module that classifies mutating vs read-only invocations, discovers project-local pm version pins, and asserts compatibility via a structured PmCliError.
  • Add CLI runtime-compatibility boundary that runs the SDK guard before dispatch and renders stale-mutation refusals with existing JSON/text error formatting.
  • Expose runtime-compatibility primitives from the public SDK surface and add tests verifying version comparison, pin discovery, mutation classification, CLI integration, and error rendering.
src/sdk/environment/project-runtime-compatibility.ts
src/cli/runtime-compatibility-boundary.ts
src/cli.ts
src/sdk/index.ts
docs/SDK_RUNTIME_BOUNDARIES.md
tests/unit/sdk/project-runtime-compatibility.spec.ts
tests/unit/cli/runtime-compatibility-boundary.spec.ts
sdk/public-surface.json
Add a reusable host-environment fault boundary for filesystem/resource operations and refactor workspace snapshot error handling to use it.
  • Implement host-environment error classifier and translator that maps known errno codes to stable, path-redacted PmCliError contracts with capacity/permission/resource categories.
  • Refactor workspace snapshot filesystem guard to delegate to the shared host-environment boundary while preserving snapshot-specific error codes and recovery guidance.
  • Expose host-environment primitives from the SDK surface and add tests for classification, translation, operation label validation, and guard behavior.
  • Extend the generated error-code catalog with host-environment fault codes.
src/sdk/environment/host-environment-errors.ts
src/sdk/workspace-snapshot.ts
src/sdk/index.ts
tests/unit/sdk/host-environment-errors.spec.ts
tests/unit/sdk/workspace-snapshot.spec.ts
src/sdk/generated-error-code-catalog.ts
docs/SDK_RUNTIME_BOUNDARIES.md
Define a source-context access/write policy for linked tests and merge-install and enforce read-only source context unless explicitly overridden.
  • Introduce source-context environment contract and policy resolver that decides if inherited source coordinates may be written and records overrides.
  • Refactor merge-install to resolve tracker/workspace context via a pure context-resolution helper that incorporates source-context write policy and environment variables.
  • Update linked-test parsers and execution to protect new env keys from metadata and mark child processes as read-only source context; add tests documenting behavior.
  • Expose source-context primitives and merge-install context types from the SDK surface and extend merge-safety tests to cover nested source write fencing and override selection.
src/sdk/environment/source-context.ts
src/sdk/merge/install.ts
src/sdk/index.ts
src/sdk/merge/index.ts
src/sdk/test/parsers.ts
src/sdk/test/execution.ts
tests/unit/sdk/source-context.spec.ts
tests/unit/sdk/merge-safety.spec.ts
docs/AGENT_RUNTIME_PRIMITIVES.md
docs/SDK_RUNTIME_BOUNDARIES.md
Make the gate registry own a canonical local preflight manifest and enforce that release gate runs produce receipts matching the registry declaration.
  • Extend gate registry JSON and validator to include a local_preflight section with steps, hosted-only waivers, and validation of gate coverage and optional flags.
  • Add registry validation for local preflight and hosted-only waivers, with tests for valid/invalid declarations and unmapped gates.
  • Update run-gates script to assert that the executed gate checks receipt matches the registry’s local_preflight steps before emitting JSON or success output, and add tests for drift detection.
  • Document the verify:preflight command, registry-owned local preflight selection, and parity between local and hosted gates, and wire a verify:preflight npm script to run-gates.
scripts/release/gate-registry.json
scripts/release/gate-registry.mjs
scripts/release/run-gates.mjs
tests/unit/scripts/release/gate-registry.spec.ts
tests/unit/scripts/release/run-gates.spec.ts
package.json
docs/TESTING.md
docs/RELEASING.md
Tighten surface replication gate reporting for CLI-owned refusals and ensure Git change discovery includes untracked files.
  • Extend surface-replication gate to include untracked files via git ls-files --others and update tests to assert inclusion.
  • Augment CLI refusal inventory to count each PmCliError occurrence, attach per-rule coordinates (id, line), and propagate disposition/owner metadata from declared config.
  • Update surface-replication gate tests to validate rule metadata, ownership, and change discovery across committed, staged, unstaged, and untracked files, and add documentation describing CLI refusal ownership.
scripts/release/surface-replication-gate.mjs
scripts/release/surface-replication-sets.json
tests/unit/scripts/release/surface-replication-gate.spec.ts
docs/SDK_RUNTIME_BOUNDARIES.md
Pin nanoid to a patched version in the workspace overrides to address a security advisory without broad dependency churn.
  • Add a pnpm workspace override for nanoid to require >=3.3.17<4.0.0, aligning the dev graph with the patched version.
  • Update pnpm lockfile and PM history/issue traces to reflect the security fix and cooldown tracking.
  • Document the security fix in the changelog under the Security section.
pnpm-workspace.yaml
pnpm-lock.yaml
CHANGELOG.md
.agents/pm/history/pm-5dwz1a.jsonl
.agents/pm/issues/pm-5dwz1a.toon
.agents/pm/history/pm-8l1m5t.jsonl
.agents/pm/chores/pm-8l1m5t.toon
Add and wire PM tracking artifacts for runtime compatibility, gate parity, and source-context safety work while keeping tests aligned with new behavior.
  • Update CHANGELOG entries for runtime compatibility, stale CLI mutation warning, CLI/SDK refusal ownership, local/hosted gate parity, and nested source writes in linked tests.
  • Add or update PM issue/task/history artifacts to track the new runtime boundaries, gate contracts, and security work.
  • Refine various tests and minor formatting in release and SDK code to match new behavior and ensure full coverage.
  • Expose new SDK surfaces through the public-surface manifest.
CHANGELOG.md
.agents/pm/issues/pm-0xmajx.toon
.agents/pm/issues/pm-1eted6.toon
.agents/pm/issues/pm-3lhth4.toon
.agents/pm/issues/pm-ei6x66.toon
.agents/pm/issues/pm-alhqbz.toon
.agents/pm/issues/pm-zjelve.toon
.agents/pm/history/pm-0xmajx.jsonl
.agents/pm/history/pm-1eted6.jsonl
.agents/pm/history/pm-3lhth4.jsonl
.agents/pm/history/pm-ei6x66.jsonl
.agents/pm/history/pm-alhqbz.jsonl
.agents/pm/history/pm-zjelve.jsonl
.agents/pm/chores/pm-ksr40d.toon
.agents/pm/history/pm-ksr40d.jsonl
.agents/pm/history/pm-e70zh5.jsonl
.agents/pm/issues/pm-e70zh5.toon
sdk/public-surface.json

Assessment against linked issues

Issue Objective Addressed Explanation
#926 Introduce a project-runtime compatibility check that detects when the running pm CLI is older than the project’s pinned @unbrained/pm-cli version and refuses mutating commands by default, with an explicit one-invocation override. ✅
#926 Ensure read-only commands (e.g., pm context, pm health) remain usable while surfacing a structured warning about runtime/version mismatch, including running vs required versions and remediation guidance. ❌ The PR keeps read-only commands available and provides structured diagnostics when a stale runtime attempts a mutation, but it does not add warnings to read-only commands or integrate runtime mismatch reporting into pm context/pm health. The compatibility logic is only used to gate mutations via the CLI boundary, not to annotate read-only outputs.
#933 Prevent nested pm write commands (e.g., pm merge install) invoked from non-PM linked tests from mutating the source project by default, by treating inherited PM_SOURCE_* coordinates as read-only unless an explicit override is provided. ✅
#933 Introduce and enforce a source-context access policy for linked tests (including new environment variables and protections) so that linked test metadata cannot clear or override the read-only source context, and ensure this behavior is covered by tests and documentation. ✅

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

@codspeed

codspeed Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 11 untouched benchmarks


Comparing feat/sdk-runtime-context-gate-primitives (13aabce) with main (7ba8ed8)

Open in CodSpeed

@codecov

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

@unbraind
unbraind marked this pull request as ready for review August 8, 2026 11:22
@unbraind

unbraind commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@greptileai please review this exact head. The local Greptile gate reported free_reviews_limit_reached; please respond if GitHub review capacity is available.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Your plan includes PR reviews subject to rate limits. Reviews are available now.

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

Caution

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

⚠️ Outside diff range comments (1)
tests/unit/scripts/release/surface-replication-gate.spec.ts (1)

158-184: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add an ownership rejection test.

These assertions cover the valid all_occurrences case only. Add cases that omit rule_ownership and set it to a different value. Assert that validateSurfaceReplication returns ok: false and reports the refusal violation. This protects the fail-closed condition in scripts/release/surface-replication-gate.mjs lines 260-269.

🤖 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 `@tests/unit/scripts/release/surface-replication-gate.spec.ts` around lines 158
- 184, Add tests around the existing validateSurfaceReplication ownership case
for configurations that omit rule_ownership and that use a non-all_occurrences
value. Assert each report has ok: false and includes the expected refusal
violation, while preserving the current valid-case assertions and fixture setup.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/RELEASING.md`:
- Around line 153-158: Move the canonical pnpm verify:preflight step in the
release checklist to after the final implementation commit has been pushed and
before the hosted-analysis-dependent checks. Preserve the existing command and
ensure the documented sequence establishes the required hosted evidence first.

In `@docs/SDK_RUNTIME_BOUNDARIES.md`:
- Around line 47-54: Remove private release-operation details from
docs/SDK_RUNTIME_BOUNDARIES.md lines 47-54, replacing the release-gate
implementation description with the public CLI/SDK refusal contract. Update
CHANGELOG.md lines 13 and 31 to remove refusal counts, ownership, gate topology,
and command details; describe the user-visible consistency fix and delivered
verification outcome instead.

In `@scripts/release/gate-registry.mjs`:
- Around line 180-240: Make the registry the source of local gate execution and
ensure skipped gates cannot receive successful receipts. In
scripts/release/gate-registry.mjs lines 180-240, extend validLocalPreflightStep
and validateLocalPreflight to require executable step definitions and an
explicit skip policy; in scripts/release/run-gates.mjs lines 62-77, execute
those registry-defined steps and validate receipt status including declared
skips. Update docs/RELEASING.md lines 160-164 and docs/TESTING.md lines 38-43 to
describe the implemented registry-driven execution and selection-manifest
behavior.

In `@src/cli/runtime-compatibility-boundary.ts`:
- Around line 46-50: Update the jsonErrors detection near outputFormatIndex to
also recognize the inline --output-format=json argument, while preserving the
existing --json and separate-value checks. Ensure runtime compatibility refusal
output remains JSON for either Commander-supported output-format syntax.

In `@src/sdk/environment/project-runtime-compatibility.ts`:
- Around line 315-334: Update textLockPin to restrict parsing to the lockfile
entry beginning at the matched PACKAGE_NAME, stopping at the next package-entry
boundary rather than using a fixed 600-character window. Within that bounded
entry, prefer the explicit version field and only return a date-like version
belonging to that entry, preserving undefined when no valid pin is found.
- Around line 82-88: The argv parsing logic must recognize both separated and
equals-form options. In
src/sdk/environment/project-runtime-compatibility.ts:82-88, update hasAnyToken
to compare each argument’s portion before “=” and route the direct argv.includes
checks at lines 132, 136, 156, 179, and 389 through it; in
src/cli/runtime-compatibility-boundary.ts:46-50, update the output-format
selection to accept --output-format=json as well as --output-format json.
- Around line 279-300: Update the dependencyPin comment to describe extracting
the highest explicit pm date version, matching its descending sort and index-0
result. In dependencyPin, skip dependency specifiers beginning with “<” or
expressing exclusion (such as “!=”) before applying VERSION_PATTERN, so only
valid minimum pins are added to versions.
- Around line 384-401: Update command resolution for isProjectMutatingInvocation
and commandFromArgv to share a helper that returns the command and its resolved
index while skipping GLOBAL_VALUE_FLAGS values. Use that index when slicing
positionals, and remove the independent argv.findIndex scan so classifiers
receive only arguments after the actual command.

In `@src/sdk/environment/source-context.ts`:
- Around line 31-42: Update source-context access resolution in
src/sdk/environment/source-context.ts lines 31-42 to default to write only when
PM_SOURCE_CONTEXT_ACCESS is absent or explicitly equals the supported write
mode; resolve empty, misspelled, and other present unsupported values to
read_only so source_writes_allowed remains false. Add coverage in
tests/unit/sdk/source-context.spec.ts lines 15-39 for write, empty, and
unrecognized values, asserting unsupported values do not permit source writes.

In `@src/sdk/workspace-snapshot.ts`:
- Around line 40-44: Update SNAPSHOT_HOST_FAULT_CODES.resource so resource
faults use a resource-specific snapshot error code instead of
workspace_snapshot_storage_exhausted; leave the capacity and permission mappings
unchanged.

In `@tests/unit/cli/runtime-compatibility-boundary.spec.ts`:
- Around line 57-69: Strengthen the test “runs without a readable executable
version and returns no exit code” by explicitly asserting that the
runtime-compatible CLI path leaves process.exitCode undefined, while preserving
the existing run invocation assertion.

---

Outside diff comments:
In `@tests/unit/scripts/release/surface-replication-gate.spec.ts`:
- Around line 158-184: Add tests around the existing validateSurfaceReplication
ownership case for configurations that omit rule_ownership and that use a
non-all_occurrences value. Assert each report has ok: false and includes the
expected refusal violation, while preserving the current valid-case assertions
and fixture setup.
🪄 Autofix

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: 65a5b607-9981-4ae7-a651-72f4e97f927b

📥 Commits

Reviewing files that changed from the base of the PR and between 7ba8ed8 and a651ae6.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (55)
  • .agents/pm/chores/pm-8l1m5t.toon
  • .agents/pm/chores/pm-ksr40d.toon
  • .agents/pm/extensions/.managed-extensions.json
  • .agents/pm/history/pm-0xmajx.jsonl
  • .agents/pm/history/pm-1eted6.jsonl
  • .agents/pm/history/pm-3lhth4.jsonl
  • .agents/pm/history/pm-5dwz1a.jsonl
  • .agents/pm/history/pm-8l1m5t.jsonl
  • .agents/pm/history/pm-alhqbz.jsonl
  • .agents/pm/history/pm-e70zh5.jsonl
  • .agents/pm/history/pm-ei6x66.jsonl
  • .agents/pm/history/pm-ksr40d.jsonl
  • .agents/pm/history/pm-zjelve.jsonl
  • .agents/pm/issues/pm-0xmajx.toon
  • .agents/pm/issues/pm-1eted6.toon
  • .agents/pm/issues/pm-3lhth4.toon
  • .agents/pm/issues/pm-5dwz1a.toon
  • .agents/pm/issues/pm-alhqbz.toon
  • .agents/pm/issues/pm-e70zh5.toon
  • .agents/pm/issues/pm-zjelve.toon
  • .agents/pm/tasks/pm-ei6x66.toon
  • CHANGELOG.md
  • docs/AGENT_RUNTIME_PRIMITIVES.md
  • docs/RELEASING.md
  • docs/SDK_RUNTIME_BOUNDARIES.md
  • docs/TESTING.md
  • package.json
  • pnpm-workspace.yaml
  • scripts/release/gate-registry.json
  • scripts/release/gate-registry.mjs
  • scripts/release/run-gates.mjs
  • scripts/release/surface-replication-gate.mjs
  • scripts/release/surface-replication-sets.json
  • sdk/public-surface.json
  • src/cli.ts
  • src/cli/runtime-compatibility-boundary.ts
  • src/sdk/environment/host-environment-errors.ts
  • src/sdk/environment/project-runtime-compatibility.ts
  • src/sdk/environment/source-context.ts
  • src/sdk/generated-error-code-catalog.ts
  • src/sdk/index.ts
  • src/sdk/merge/index.ts
  • src/sdk/merge/install.ts
  • src/sdk/test/execution.ts
  • src/sdk/test/parsers.ts
  • src/sdk/workspace-snapshot.ts
  • tests/unit/cli/runtime-compatibility-boundary.spec.ts
  • tests/unit/scripts/release/gate-registry.spec.ts
  • tests/unit/scripts/release/run-gates.spec.ts
  • tests/unit/scripts/release/surface-replication-gate.spec.ts
  • tests/unit/sdk/host-environment-errors.spec.ts
  • tests/unit/sdk/merge-safety.spec.ts
  • tests/unit/sdk/project-runtime-compatibility.spec.ts
  • tests/unit/sdk/source-context.spec.ts
  • tests/unit/sdk/workspace-snapshot.spec.ts

Comment thread docs/RELEASING.md Resolved
Comment thread docs/SDK_RUNTIME_BOUNDARIES.md Resolved
Comment thread scripts/release/gate-registry.mjs Resolved
Comment thread src/sdk/environment/source-context.ts Resolved
Comment thread src/sdk/workspace-snapshot.ts Resolved
Make the release gate registry the executable source of truth, record explicit skipped receipts, harden stale-runtime flag and lockfile parsing, fail closed on inherited source access, and separate snapshot resource exhaustion from storage capacity. Regenerate public contracts and changelog wording, and add exact regression coverage for all PR #935 review findings.

@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.

Caution

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

⚠️ Outside diff range comments (1)
src/sdk/environment/project-runtime-compatibility.ts (1)

409-412: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Skip global option values after the command.

Line 411 removes --author but retains alice. For schema --author alice add-type Bug, the classifier receives alice as the first positional and returns read-only. A stale runtime can then run a mutating command.

Skip the value after every GLOBAL_VALUE_FLAGS token while building positionals. Add a regression case for a global option after schema.

Based on PR objectives: mutating commands must fail closed.

🤖 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/environment/project-runtime-compatibility.ts` around lines 409 - 412,
Update the positional-argument construction to skip both each GLOBAL_VALUE_FLAGS
token and its following value, including when the option appears after the
command; preserve unrelated positional arguments such as add-type and ensure
mutating commands fail closed. Add a regression case covering schema --author
alice add-type Bug.
🤖 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.

Outside diff comments:
In `@src/sdk/environment/project-runtime-compatibility.ts`:
- Around line 409-412: Update the positional-argument construction to skip both
each GLOBAL_VALUE_FLAGS token and its following value, including when the option
appears after the command; preserve unrelated positional arguments such as
add-type and ensure mutating commands fail closed. Add a regression case
covering schema --author alice add-type Bug.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 80aafeaf-911f-403e-a614-5d3e26714eca

📥 Commits

Reviewing files that changed from the base of the PR and between a651ae6 and 6a11aad.

📒 Files selected for processing (29)
  • .agents/pm/history/pm-0xmajx.jsonl
  • .agents/pm/history/pm-dskxwf.jsonl
  • .agents/pm/history/pm-ei6x66.jsonl
  • .agents/pm/history/pm-n41vay.jsonl
  • .agents/pm/issues/pm-0xmajx.toon
  • .agents/pm/issues/pm-dskxwf.toon
  • .agents/pm/issues/pm-n41vay.toon
  • .agents/pm/tasks/pm-ei6x66.toon
  • CHANGELOG.md
  • docs/RELEASING.md
  • docs/SDK_RUNTIME_BOUNDARIES.md
  • docs/TESTING.md
  • scripts/release/gate-registry.json
  • scripts/release/gate-registry.mjs
  • scripts/release/run-gates.mjs
  • sdk/public-surface.json
  • src/cli/runtime-compatibility-boundary.ts
  • src/sdk/environment/project-runtime-compatibility.ts
  • src/sdk/environment/source-context.ts
  • src/sdk/generated-error-code-catalog.ts
  • src/sdk/workspace-snapshot.ts
  • tests/fixtures/contracts/full.json
  • tests/integration/release-automation-contract.spec.ts
  • tests/unit/cli/runtime-compatibility-boundary.spec.ts
  • tests/unit/scripts/release/gate-registry.spec.ts
  • tests/unit/scripts/release/run-gates.spec.ts
  • tests/unit/sdk/project-runtime-compatibility.spec.ts
  • tests/unit/sdk/source-context.spec.ts
  • tests/unit/sdk/workspace-snapshot.spec.ts

Extend the public SDK compatibility result with typed stale-read diagnostics, emit machine-readable and human CLI warnings while preserving stdout, and exercise context/health/help transports through unit and packaged acceptance coverage. Refresh generated contracts, SDK surface classification, changelog, and the completed pm-1eted6 evidence trail.
Keep stale-runtime mutation classification fail closed when global value flags occur after the command, and cover schema --author alice add-type as a mutating regression. Record the exact-head CodeRabbit remediation on pm-n41vay.
@unbraind

unbraind commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

Valid fail-closed parsing finding. Fixed at f2e7775 by skipping each global value flag and its following value while deriving post-command positionals; added schema --author alice add-type Bug regression coverage. Focused SDK/CLI suite passes 76 tests.

@unbraind

unbraind commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

Useful consolidated walkthrough. This broad scope is intentional and linked to the canonical PM items in the PR description; the repository static-quality gate reports 100% docstring coverage, superseding the bot's changed-file heuristic. All actionable inline findings and the later classifier finding are fixed through f2e7775.

@unbraind

unbraind commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

The guide exposed a real GH-926 acceptance gap: stale reads were available but did not report the mismatch. pm-1eted6 was reopened, fixed at a7376c1 with typed SDK and CLI warnings, proven in an isolated context --json run and exact 100% coverage, then closed with corrected live evidence.

@unbraind

unbraind commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

CodSpeed result acknowledged. The benchmark workflow is part of the exact-head required-check inventory and will be evaluated after the current f2e7775 run settles.

@unbraind

unbraind commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

Codecov report acknowledged. Local exact coverage is 100/100/100/100 with zero uncovered counts; the exact-head hosted coverage result remains part of the merge gate.

@unbraind

unbraind commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

Acknowledged. The requested full review was completed, every actionable finding was handled, and the later outside-diff positional-classifier finding is fixed at f2e7775 with regression coverage.

@unbraind

unbraind commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

No review findings were produced because the provider reported a rate limit. This is recorded as an unavailable review signal, not approval; other exact-head reviews and required checks remain enforced.

@unbraind

unbraind commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

Actionable review acknowledged. The reported findings were validated against current code, fixed through f2e7775, covered by focused regressions and exact repository coverage, and all inline threads were resolved with commit-specific replies.

@unbraind

unbraind commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

Exact-head review request for f2e7775 after all prior findings and the stale-read acceptance gap were remediated.

@coderabbitai full review
@greptileai please review exact head f2e7775
@sourcery-ai review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

@unbraind I will perform a full review of the requested exact head f2e7775c1.

⚠️ Action not completed

Review rate limited.


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 38 minutes.

@unbraind

unbraind commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

The requested exact-head full review could not run because CodeRabbit rate-limited it. This is treated as an unavailable provider signal, not an approval. Exact-head f2e7775 has all hosted checks green, no unresolved threads, and every finding from the completed review rounds is fixed and acknowledged.

Record the fully green f2e7775 hosted check inventory, provider limitations, complete review acknowledgements, and corrected resolution/actual-result metadata for pm-n41vay. Regenerate the package-owned changelog entry and release the final active claim.
@unbraind

unbraind commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

Final exact-head review request for 13aabce. This commit contains only PM closeout history/item metadata and the package-generated changelog entry after the fully green f2e7775 inventory.

@coderabbitai full review
@greptileai please review exact head 13aabce
@sourcery-ai review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

@unbraind I will perform a full review of the requested exact head 13aabce9b.

⚠️ Action not completed

Review rate limited.


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 32 minutes.

@unbraind

unbraind commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

Final exact-head review was requested after the PM-only closeout commit, but CodeRabbit again reported rate limiting. No review ran, so this is an unavailable signal rather than approval. Exact head 13aabce is mergeable CLEAN, every hosted check is green, and the fresh thread inventory is empty.

@unbraind
unbraind merged commit 589b0d2 into main Aug 8, 2026
32 checks passed
@unbraind
unbraind deleted the feat/sdk-runtime-context-gate-primitives branch August 8, 2026 12:59
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