Skip to content

SDK mutation integrity, stale-work context, and Bun-safe release primitives - #668

Merged
unbraind merged 3 commits into
mainfrom
feat/sdk-mutation-integrity-guardrails
Jul 24, 2026
Merged

unbraind merged 3 commits into
mainfrom
feat/sdk-mutation-integrity-guardrails

Conversation

@unbraind

@unbraind unbraind commented Jul 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

This broad SDK/CLI change set strengthens the project-management-as-context-management baseline across several related acceptance surfaces:

  • introduces SDK-first mutation guardrails with redacted secret detection and advise/block/off policy adapters for CLI and MCP
  • enforces configurable author attribution and preserves audited disposition metadata in append-only workspace history
  • adds SDK stale-work detection plus health/CLI guidance for unclaimed or inactive in-progress items
  • returns typed schema-migration usage failures before strict SDK validation reaches telemetry as a high TypeError
  • keeps the persistent SQLite projection optional so the packed CLI starts under Bun and authoritative document reads remain the fallback
  • makes partial daily-release failure reporting truthful and stabilizes the real all-package acceptance under full-suite load
  • documents the SDK contracts and regenerates the package-owned changelog

pm items

Verification

  • complete coverage: 354 files, 6,212 tests, exact 100/100/100/100
  • aggregate release gates: build, types, static quality, docstrings, package boundaries, security scan, packed smoke, 88-command dogfood, npm pack, compatibility, and live Sentry/telemetry all passed
  • temporary installed-package acceptance: the packed tarball runs with bunx --bun and reports 2026.7.24
  • tracker integrity: health is clean; history drift is zero; only pm-cedo0g remains in progress pending merged release recovery
  • changelog: generated and checked through pm-changelog 2026.7.23

The local Greptile command reported the external free_reviews_limit_reached quota; hosted checks and bot review are required before merge.


Summary by cubic

Adds SDK-first mutation guardrails—author enforcement, redacted secret scanning, and stale-work health—with CLI/MCP parity. Also hardens author-acknowledgment review and keeps the optional SQLite index safe under Bun while returning typed schema migration usage errors.

  • New Features

    • Adds mutation_guard settings: require_attributed_author, secret_guard (off | advise | block), and stale_in_progress_hours.
    • CLI preflight and MCP adapters enforce author attribution and run redacted secret detection before mutations.
    • Stale in-progress detection surfaces unclaimed, inactive work in pm health without changing ownership.
    • Append-only workspace audit events allow acknowledging post-baseline unknown-author history without rewrites.
    • Docs: new Mutation Integrity guide; tests for guardrails and author parity in test tracking.
  • Bug Fixes

    • Hardens author-acknowledgment review: validates item ids, returns a typed error for unreadable history, and keeps stale-work health by falling back to metadata when a stream is corrupt.
    • Optional node:sqlite loading with fallback keeps the packed CLI working under Bun; projection stays optional.
    • Schema migration CLIs now return typed usage errors instead of high-severity SDK TypeErrors.
    • Stabilizes all-package acceptance by giving that test a local 45s budget under full-suite load.
    • Auto-release failure messages now reflect partial publications (tag/npm may exist) for clearer recovery.

Written for commit 36907aa. Summary will update on new commits.

Review in cubic

unbraind added 2 commits July 24, 2026 08:38
Deliver SDK-first secret and author guardrails, append-only workspace attribution, stale-work governance, CLI/MCP parity, typed schema migration usage errors, and Bun-safe optional SQLite indexing.

Track and verify pm-h90s, pm-pim7, pm-w8q4, pm-cedo0g, and pm-rxqcp9 with focused tests, packed acceptance evidence, and truthful partial-publication diagnostics.
Keep the optional SQLite projection capability-safe under Bun, add direct fallback coverage, and preserve typed schema-migration usage errors without redundant optional handling. Stabilize the real all-package acceptance under full-suite I/O while retaining the global timeout and exact assertions. Regenerate the pm-changelog output and record final tracker, security-fixture, coverage, Sentry, and release-gate evidence for pm-cedo0g, pm-rxqcp9, pm-7x0wqg, and pm-pim7.
@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

@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This change adds mutation-integrity controls across SDK, CLI, and MCP, including secret scanning, author enforcement, audited acknowledgments, stale-work health advisories, configurable settings, optional SQLite handling, release diagnostics, and associated tests and project records.

Changes

Mutation integrity and governance

Layer / File(s) Summary
Mutation guard configuration and adapters
src/sdk/mutation-guard.ts, src/cli/migration-gates.ts, src/mcp/server.ts, src/core/store/*, tests/unit/sdk/*, tests/unit/cli/*
Adds configurable author and secret guards, CLI schema preflight validation, MCP warnings, redacted recovery output, and mutation guard settings persistence.
Stale in-progress governance
src/sdk/governance/*, src/sdk/governance/health.ts, tests/unit/sdk/stale-work*, tests/unit/commands/health-command.spec.ts
Detects stale unclaimed work from item and history timestamps and reports it through advisory health warnings and storage details.
Audited history and author attribution
src/core/history/*, src/sdk/author-attribution.ts, src/sdk/test/batch.ts, src/types.ts, tests/unit/sdk/author-attribution.spec.ts
Adds state-preserving workspace audit events, unknown-author acknowledgments, structured history context, and explicit test-all author tracking.
Runtime compatibility and release diagnostics
src/core/store/item-metadata-query-index.ts, .github/workflows/auto-release.yml, tests/integration/ci-workflow-contract.spec.ts, tests/unit/extensions/extension-command.spec.ts
Makes SQLite index operations safe when node:sqlite is unavailable, updates post-publish release guidance, and adds a local acceptance timeout.
Documentation and delivery records
docs/MUTATION_INTEGRITY.md, CHANGELOG.md, .agents/pm/**
Documents mutation-integrity behavior and records feature, issue, task, test-run, closure, and release metadata.

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

Possibly related PRs

  • unbraind/pm-cli#565: Extends the same author-attribution and provenance functionality.
  • unbraind/pm-cli#568: Provides the governance health surface extended here with stale-work advisories.
  • unbraind/pm-cli#655: Introduces the SQLite item-metadata query-index implementation modified here for optional runtime support.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the main themes of the changeset.
Description check ✅ Passed The description is clearly related to the changeset and summarizes its main implementation and verification goals.
✨ 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.

@unbraind

Copy link
Copy Markdown
Owner Author

@greptileai review

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 24, 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 3 minutes.

@codspeed

codspeed Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Merging this PR will regress 3 benchmarks

⚠️ 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

⚡ 7 improved benchmarks
❌ 3 regressed benchmarks
✅ 1 untouched benchmark

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ decodeQueryCursor 114.2 µs 114.4 µs -0.15%
❌ encodeQueryCursor 101.1 µs 101.1 µs -0.02%
❌ tokenize + score query over 2000 docs 7.5 ms 7.5 ms 0%
⚡ createQueryFingerprint 529.1 µs 513.3 µs +3.09%
⚡ stableStringify (nested contract) 161.5 µs 161.2 µs +0.18%
⚡ jaccardSimilarity 153.4 µs 153.4 µs +0.02%
⚡ build index (2000 docs x 80 words) 161.3 ms 161.3 ms +0.01%
⚡ build index (200 docs x 40 words) 8.4 ms 8.4 ms +0.01%
⚡ tokenizeAlphaNumeric 367.4 µs 367.4 µs 0%
⚡ score query over 2000 docs 5.6 ms 5.6 ms 0%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing feat/sdk-mutation-integrity-guardrails (36907aa) with main (db1b711)

Open in CodSpeed

@codecov

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

Copy link
Copy Markdown
Owner Author

@gemini-code-assist Acknowledged the consumer-service shutdown notice; no code action is available or required for this PR.

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai Acknowledged the initial fair-usage deferral. The exact head is unchanged and all hosted checks are green; a fresh full review is requested below after the stated availability window.

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai Acknowledged the command-invocation receipt. There were no findings or threads in that cycle; please perform the substantive full review on the unchanged exact head when quota permits.

@unbraind

Copy link
Copy Markdown
Owner Author

@codspeed-hq Reviewed the report. It states 0% aggregate degradation and flags a different-runtime comparison; the listed -0.19% to 0% noise affects untouched benchmark primitives, so no code change is justified. The hosted benchmark check passed.

@unbraind

Copy link
Copy Markdown
Owner Author

@codecov Reviewed and confirmed: all modified coverable lines are covered, all tests passed, and the exact local aggregate remains 100/100/100/100.

@unbraind

Copy link
Copy Markdown
Owner Author

@sourcery-ai Acknowledged the external weekly diff-character quota. No finding was emitted and no code action is possible; repository-owned static, coverage, security, and compatibility checks passed at the exact head.

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@unbraind

Copy link
Copy Markdown
Owner Author

@greptileai review

@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

@unbraind Understood. I’ll perform a fresh substantive full review of the unchanged PR head.

✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

@unbraind: Requested a substantive full review of the unchanged PR head.

✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Jul 24, 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.

@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 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.agents/pm/history/pm-h90s.jsonl:
- Around line 12-13: The closure metadata contradicts itself about whether the
five acknowledged events are actionable. Use the PM CLI to append a correction,
updating the derived resolution/result wording to state “five acknowledged
events; zero actionable,” and synchronize the derived record without editing the
append-only JSONL history directly.

In `@src/sdk/author-attribution.ts`:
- Around line 297-310: The per-event handling around uniqueEvents must validate
event.item_id with the codebase’s canonical item-ID pattern before constructing
the history path, then move fs.readFile and JSON parsing inside the existing
try/catch so missing or unreadable files produce the same TypeError. Preserve
the current acknowledgment target context in the error message and only build
the path after validation.

In `@src/sdk/governance/stale-work.ts`:
- Around line 118-140: Handle failures from readHistoryEntries within each
item’s map callback so a corrupt or unreadable history file does not reject the
surrounding Promise.all. For the affected item, treat the failure as having no
history timestamp and preserve the existing latest-valid-timestamp behavior for
successful reads.
🪄 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: 50c8ba1e-b14d-408d-afe6-e43831945353

📥 Commits

Reviewing files that changed from the base of the PR and between db1b711 and 830c415.

📒 Files selected for processing (53)
  • .agents/pm/extensions/.managed-extensions.json
  • .agents/pm/features/pm-pim7.toon
  • .agents/pm/features/pm-w8q4.toon
  • .agents/pm/history/_workspace.jsonl
  • .agents/pm/history/pm-7x0wqg.jsonl
  • .agents/pm/history/pm-9yfo.jsonl
  • .agents/pm/history/pm-cedo0g.jsonl
  • .agents/pm/history/pm-h90s.jsonl
  • .agents/pm/history/pm-pim7.jsonl
  • .agents/pm/history/pm-rxqcp9.jsonl
  • .agents/pm/history/pm-w8q4.jsonl
  • .agents/pm/issues/pm-7x0wqg.toon
  • .agents/pm/issues/pm-cedo0g.toon
  • .agents/pm/issues/pm-h90s.toon
  • .agents/pm/issues/pm-rxqcp9.toon
  • .agents/pm/tasks/pm-9yfo.toon
  • .github/workflows/auto-release.yml
  • CHANGELOG.md
  • docs/MUTATION_INTEGRITY.md
  • docs/README.md
  • src/cli/main.ts
  • src/cli/migration-gates.ts
  • src/core/config/nested-settings.ts
  • src/core/history/history.ts
  • src/core/history/workspace-history.ts
  • src/core/shared/constants.ts
  • src/core/store/item-metadata-query-index.ts
  • src/core/store/settings-validator.ts
  • src/core/store/settings.ts
  • src/mcp/server.ts
  • src/sdk/author-attribution.ts
  • src/sdk/governance/health.ts
  • src/sdk/governance/stale-work.ts
  • src/sdk/index.ts
  • src/sdk/mutation-guard.ts
  • src/sdk/runtime-primitives.ts
  • src/sdk/test/batch.ts
  • src/types.ts
  • tests/integration/ci-workflow-contract.spec.ts
  • tests/unit/cli/migration-gates.spec.ts
  • tests/unit/commands/config-key-aliases-search.spec.ts
  • tests/unit/commands/health-command.spec.ts
  • tests/unit/core/history/workspace-history.spec.ts
  • tests/unit/core/item/item-metadata-query-index.spec.ts
  • tests/unit/core/store/settings-store.spec.ts
  • tests/unit/extensions/extension-command.spec.ts
  • tests/unit/sdk/author-attribution.spec.ts
  • tests/unit/sdk/execution-diagnostics-primitives.spec.ts
  • tests/unit/sdk/mutation-guard-adapters.spec.ts
  • tests/unit/sdk/mutation-guard.spec.ts
  • tests/unit/sdk/stale-work-health.spec.ts
  • tests/unit/sdk/stale-work.spec.ts
  • tests/unit/sdk/test-all-author.spec.ts

Comment thread .agents/pm/history/pm-h90s.jsonl Resolved
Comment thread src/sdk/author-attribution.ts Resolved
Comment thread src/sdk/governance/stale-work.ts Resolved
Validate author-acknowledgment item identifiers before path construction and normalize unreadable history targets to the typed SDK error. Keep stale-work health available when one item history stream is corrupt by falling back to metadata activity. Add direct regressions, clarify append-only disposition metadata through pm, and record review evidence.
@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@unbraind

Copy link
Copy Markdown
Owner Author

@greptileai review

@coderabbitai

coderabbitai Bot commented Jul 24, 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 38 minutes.

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai Reviewed the completed unchanged-head review invocation. Its three findings were verified, fixed in 36907aa, replied to inline, and resolved with exact 100/100/100/100 coverage.

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai Reviewed the substantive-review receipt; the resulting three actionable threads were all addressed and independently confirmed by your follow-up analysis.

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai Acknowledged the later fair-usage notice. It emitted no additional code finding; the last substantive findings are resolved at the current exact head.

@unbraind

Copy link
Copy Markdown
Owner Author

@gemini-code-assist Acknowledged the repeated service-sunset notice; no code action is available.

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai Acknowledged the final-head fair-usage receipt. It emitted no new finding; all prior threads are resolved and all hosted checks pass.

@unbraind

Copy link
Copy Markdown
Owner Author

@coderabbitai The displayed 57.45% docstring warning is not consistent with the repository-owned gate: quality:static ran at this head with min docstring, exported-docstring, and member-docstring coverage each set to 100, and passed. No suppression or threshold reduction was used.

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

@unbraind

Copy link
Copy Markdown
Owner Author

@codspeed-hq Reviewed the updated report. The -0.15% to 0% changes are on untouched pagination/BM25 benchmarks, the report flags different runtime environments, and the hosted performance job passes; this is measurement noise rather than an actionable regression.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Tip

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

@unbraind Acknowledged. The later fair-usage notice adds no new actionable finding, and the previously substantive review threads remain resolved at the current head.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Tip

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

@unbraind Thanks for confirming. The three findings are acknowledged as addressed in 36907aa7, with the inline resolutions and full coverage verification noted.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Tip

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

@unbraind Thanks for confirming. The three actionable substantive-review threads are addressed and independently verified.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Tip

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

@unbraind Acknowledged. The final fair-usage receipt introduced no new findings; prior threads remain resolved, and the reported hosted checks are green.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Tip

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- package manifests and quality script references ---'
fd -HI '^(package\.json|.*quality.*|.*static.*|.*docstring.*)$' . \
  -E node_modules -E dist -E build | sed -n '1,240p'

printf '%s\n' '--- quality:static script definitions ---'
rg -n -C 4 '"quality:static"|quality:static' \
  -g 'package.json' -g '!node_modules/**' -g '!dist/**' -g '!build/**' .

printf '%s\n' '--- docstring coverage configuration and thresholds ---'
rg -n -i -C 4 'docstring|exported-docstring|member-docstring|min.*docstring|57\.45' \
  -g '!node_modules/**' -g '!dist/**' -g '!build/**' .

Length of output: 90933


@unbraind Confirmed. The checked-in quality:static command enforces 100% minimum coverage for module, exported-declaration, and exported-member docstrings. Its implementation requires all three checks to pass, and repository tests assert the same strict command and 100% results.

A displayed 57.45% warning is therefore inconsistent with the authoritative gate and does not apply to this PR head. I’m withdrawing it.


✏️ Learnings added
Learnt from: unbraind
URL: https://github.com/unbraind/pm-cli/pull/668

Timestamp: 2026-07-24T07:55:22.477Z
Learning: In pm-cli, `package.json` defines the authoritative `quality:static` gate with `--min-docstring-coverage 100`, `--min-exported-docstring-coverage 100`, and `--min-member-docstring-coverage 100`. The implementation in `scripts/release/static-quality-gate.mts` requires all three coverage checks to pass, so external docstring-coverage warnings that conflict with this contract should not be treated as actionable without reconciling their scope or measurement.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@unbraind
unbraind merged commit 63344ee into main Jul 24, 2026
32 checks passed
@unbraind

unbraind commented Aug 4, 2026

Copy link
Copy Markdown
Owner Author

Tracked in PM: pm-7x0wqg, pm-cedo0g, pm-h90s, pm-pim7, pm-rxqcp9, pm-w8q4.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant