Repository navigation
SDK provenance context primitives across CLI, MCP, and event streams - #874
Conversation
Add bounded automatic model and version resolvers, versioned legacy author interpretation, and patch-free provenance projections across history, activity, events, SDK, CLI, MCP, and completions. Extend settings and generated contracts, document privacy and extensibility guarantees, and prove the tranche with exact 100% repository coverage plus isolated npm and Bun consumers.\n\nTracks pm-ffz0a9, pm-v8gfi7, and pm-3yxwv5.
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
@greptileai please review the full provenance context tranche. @coderabbitai full review |
Reviewer's GuideAdds bounded, patch-free provenance projections and filters across history, activity, and mutation event streams, introduces automatic model/version resolvers with privacy-safe opt-outs, and wires these primitives consistently through CLI, SDK, MCP, settings, completion, contracts, and documentation. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis change adds bounded agent provenance probes, versioned legacy-author vocabulary, immutable provenance projections, filtering, and summaries across the SDK, CLI, MCP, settings, and event index. ChangesAgent provenance and configuration
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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. Comment |
|
✅ Action performedFull 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. |
|
@greptileai please re-review exact head 54cf280 after the canonical PM documentation-link fix. @coderabbitai full review |
|
✅ Action performedFull 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 56 minutes. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@greptileai please re-review exact head 89ffbde. @coderabbitai full review |
There was a problem hiding this comment.
Actionable comments posted: 8
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/core/store/settings.ts (1)
1146-1159: 🩺 Stability & Availability | 🔴 Critical | ⚡ Quick winBackfill missing
agent_identityfields from defaults inmergeSettings.
agent_identityis currently either the full parsed object or the full default object, so a sparsesettings.jsonthat keeps onlyagent_identity.harness_signalsdropsidentity_vocabularyandprobes_enabled.pm activity,pm history, and the mutation-events SDK then accessagent_identity.identity_vocabulary!before fallback handling and can throw.🐛 Proposed fix: backfill agent_identity sub-fields from defaults
- agent_identity: structuredClone( - settings.agent_identity ?? defaults.agent_identity, - ), + agent_identity: structuredClone({ + ...defaults.agent_identity, + ...settings.agent_identity, + }),🤖 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/core/store/settings.ts` around lines 1146 - 1159, Update mergeSettings to merge agent_identity fields with defaults rather than replacing the entire object when settings.agent_identity is sparse. Preserve explicitly provided agent_identity values while backfilling missing identity_vocabulary and probes_enabled fields from defaults before cloning the result.src/core/shared/author.ts (1)
562-597: 🚀 Performance & Scalability | 🟠 Major | ⚡ Quick winAvoid unconditional probe execution in provenance candidate resolution.
resolveAgentProvenanceObservationevaluates every candidate in thevaluesarray, soresolveProvenanceProbe(dimension, …)runs even when an earlier source already resolvedoverrideValue, session, environment, MCP client, host, orargv. For Claude, bothmodelandversionuse theclaude_session_fileresolver, so the synchronous session-file I/O inreadClaudeSessionProvenancecan execute repeatedly despite being a later fallback source. Convert this to short-circuiting candidate resolution so later sources run only when no earlier candidate returned a value.🤖 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/core/shared/author.ts` around lines 562 - 597, Update resolveAgentProvenanceObservation so candidate sources are evaluated lazily in priority order rather than precomputing the values array. Preserve the existing precedence from override through argv, and invoke resolveProvenanceProbe only if all earlier sources return undefined, preventing unnecessary claude_session_file I/O.
🤖 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/AGENT_PROVENANCE_ADR.md`:
- Around line 27-28: Update the compatibility documentation to cover the new
dimensions: in docs/AGENT_PROVENANCE_ADR.md at Lines 74-75, add topic: null and
version: null to the compatibility example or document an intentional exception;
in docs/AGENT_RUNTIME_PRIMITIVES.md at Lines 93-95, add version to the
explicit-null statement or document an intentional exception.
In `@src/core/history/event-index.ts`:
- Around line 346-350: Update the provenance clause construction around
query.provenance to validate each predicate.dimension against the shared
provenance dimension set before building SQL. Bind the complete agent_provenance
JSON path as the first parameter to json_extract instead of interpolating the
dimension, then append predicate.values after that path parameter while
preserving the existing IN placeholders.
In `@src/sdk/completion.ts`:
- Around line 1362-1371: Add the missing --strict-exit, --fail-on-warn, and
--format entries to the manual Zsh history completion block in
src/sdk/completion.ts at lines 1362-1371 and the manual Fish history completion
block at lines 2501-2508, matching the definitions in HISTORY_FLAG_CONTRACTS and
preserving each shell’s existing completion syntax.
In `@src/sdk/query/history.ts`:
- Around line 222-233: Update the compact history flow to preserve each entry’s
original version when provenance filters are applied. Change buildDiffEntries to
accept entries containing both entry and version, use version for each
HistoryDiffEntry.index, and pass selectedHistory directly from the
compactHistory construction instead of deriving a length-based start index;
leave non-compact behavior unchanged.
In `@src/types.ts`:
- Around line 1264-1272: Normalize optional agent_identity provenance fields
before use: ensure identity_vocabulary falls back to
DEFAULT_AUTHOR_IDENTITY_VOCABULARY and probes_enabled has a safe default, rather
than relying on non-null assertions. Update the affected reads in src/types.ts
(lines 1264-1272), src/sdk/query/activity.ts (lines 406-409),
src/sdk/query/history.ts (lines 209-212), and src/sdk/mutation-events.ts (lines
301-305); all sites require guarded defaults while preserving configured values.
In `@tests/fixtures/contracts/full.json`:
- Around line 14322-14335: The harness provenance filter metadata is missing its
intended description and examples. Update the source schema definitions for the
activity, events, and history action filters—not the generated fixture—to
document string and array usage with examples such as codex, claude-code,
cursor, and extension-provided identifiers, then regenerate the fixture.
In `@tests/unit/cli/register-list-query.spec.ts`:
- Around line 556-594: Update the test case “maps provenance projections,
summaries, and repeatable predicates” to pass multiple --harness,
--agent-instance, and --provenance-filter arguments, then assert the
corresponding expected arrays preserve every supplied value in order when
checking listMutationEvents.
In `@tests/unit/commands/completion-command.spec.ts`:
- Around line 442-463: Update the test named “includes patch-free provenance
reads across history, activity, and events in every shell” so each shell’s
generated script is parsed into the individual history, activity, and events
command blocks. Within each block, assert every flag from flags is present using
the shell-specific syntax, rather than checking flags against the entire script;
retain the command-presence assertions.
---
Outside diff comments:
In `@src/core/shared/author.ts`:
- Around line 562-597: Update resolveAgentProvenanceObservation so candidate
sources are evaluated lazily in priority order rather than precomputing the
values array. Preserve the existing precedence from override through argv, and
invoke resolveProvenanceProbe only if all earlier sources return undefined,
preventing unnecessary claude_session_file I/O.
In `@src/core/store/settings.ts`:
- Around line 1146-1159: Update mergeSettings to merge agent_identity fields
with defaults rather than replacing the entire object when
settings.agent_identity is sparse. Preserve explicitly provided agent_identity
values while backfilling missing identity_vocabulary and probes_enabled fields
from defaults before cloning the result.
🪄 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: 9468fde1-c91c-49d5-8d83-4c7dc0717259
📒 Files selected for processing (46)
.agents/pm/chores/pm-yds9dt.toon.agents/pm/history/pm-3yxwv5.jsonl.agents/pm/history/pm-ffz0a9.jsonl.agents/pm/history/pm-v8gfi7.jsonl.agents/pm/history/pm-yds9dt.jsonl.agents/pm/issues/pm-3yxwv5.toon.agents/pm/issues/pm-ffz0a9.toon.agents/pm/issues/pm-v8gfi7.toondocs/AGENT_PROVENANCE_ADR.mddocs/AGENT_RUNTIME_PRIMITIVES.mdsdk/public-surface.jsonsrc/cli/main.tssrc/cli/register-list-query.tssrc/core/history/event-index.tssrc/core/shared/author.tssrc/core/shared/constants.tssrc/core/store/settings-validator.tssrc/core/store/settings.tssrc/mcp/server.tssrc/sdk/cli-contracts.tssrc/sdk/cli-contracts/flag-contracts.tssrc/sdk/cli-contracts/registration-helpers.tssrc/sdk/cli-contracts/tool-option-contracts.tssrc/sdk/cli-contracts/tool-parameter-tables.tssrc/sdk/cli-contracts/tool-schema.tssrc/sdk/completion.tssrc/sdk/history-provenance.tssrc/sdk/index.tssrc/sdk/mutation-events.tssrc/sdk/output-projection.tssrc/sdk/provenance.tssrc/sdk/query/activity.tssrc/sdk/query/history.tssrc/sdk/runtime-extended-actions.tssrc/types.tstests/fixtures/contracts/full.jsontests/unit/cli/register-list-query.spec.tstests/unit/cli/registration-helpers.spec.tstests/unit/commands/completion-command.spec.tstests/unit/commands/history-activity-command.spec.tstests/unit/core/store/settings-store.spec.tstests/unit/sdk/agent-runtime-primitives.spec.tstests/unit/sdk/agent-session-context.spec.tstests/unit/sdk/history-provenance.spec.tstests/unit/sdk/mutation-events.spec.tstests/unit/sdk/provenance.spec.ts
|
✅ Action performedFull 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 45 minutes. |
|
Bot feedback disposition on exact head 0827f5d:
Local focused verification for the last change: 46/46 register-list-query tests pass. Full exact-head GitHub checks are being watched again. |
|
@greptileai please review exact head 0827f5d after the repeated-option regression test. @coderabbitai full review |
|
✅ Action performedFull 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 39 minutes. |
|
@greptileai please review exact head 3e742d4; this final push only records the already-completed exact-head review evidence in pm. @coderabbitai full review |
|
✅ Action performedFull 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 33 minutes. |
Summary
PM lineage
Verification
Summary by Sourcery
Introduce shared SDK/CLI/MCP primitives for immutable, patch-free provenance context across history, activity, and mutation event streams, backed by bounded automatic probes, versioned legacy author interpretation, and extended indexing and filtering.
New Features:
Bug Fixes:
Enhancements:
Tests:
Summary by cubic
Adds patch-free provenance reads and filtering across history, activity, and events, powered by bounded probes and a versioned legacy-author vocabulary to make identity readable and safe. CLI, SDK, and MCP share the same provenance options, with privacy opt-outs and constant-size summaries.
New Features
agent_instance, and provenance dimensions; resolve legacy authors via a versioned vocabulary.agent_identity.probes_enabledandagent_identity.identity_vocabulary { version, aliases }.agent_instance, and provenance-dimension filtering without scanning raw streams; CLI/MCP/SDK schemas and completion scripts updated with repeatable--provenance,--provenance-summary,--harness,--agent-instance, and--provenance-filter.Bug Fixes
compact,full, andprovenanceprojections as mutually exclusive and enforce CLI constraints (e.g., no provenance summaries while streaming events).invalid_provenance_predicate,unknown_provenance_dimension) and refresh public surface and token baselines.Written for commit 3e742d4. Summary will update on new commits.