Skip to content

hooks: Thread optional post-commit VCS metadata into agent traces#43

Merged
davidabram merged 2 commits into
mainfrom
feat/post-commit-vcs-metadata
May 20, 2026
Merged

hooks: Thread optional post-commit VCS metadata into agent traces#43
davidabram merged 2 commits into
mainfrom
feat/post-commit-vcs-metadata

Conversation

@stefanskoricdev
Copy link
Copy Markdown
Contributor

@stefanskoricdev stefanskoricdev commented May 19, 2026

This PR adds optional VCS metadata support to the sce hooks post-commit flow and threads it through to Agent Trace generation.
It expands the hook command surface to accept --vcs, maps supported values to a typed enum, and updates trace serialization so top-level vcs is emitted only when VCS type is provided.

  • Added optional --vcs argument to sce hooks post-commit.
  • Introduced typed VCS enum support for:
    • git
    • jj
    • hg
    • svn
  • Updated hooks command parsing and runtime routing to pass optional VCS type through post-commit flow.
  • Updated Agent Trace data model:
    • AgentTrace.vcs is now optional (Option<AgentTraceVcs>).
    • VCS type is enum-backed (schema-aligned) instead of hardcoded string.
  • Updated embedded post-commit hook template to call:
    • sce hooks post-commit --vcs git
  • Synced context documentation to reflect:
    • optional vcs emission behavior
    • updated post-commit command surface

Summary by CodeRabbit

  • New Features

    • Added a --vcs flag to the post-commit hook to explicitly specify the version control system (git, jj, hg, svn)
  • Improvements

    • VCS metadata in traces is now type-aware and optional, improving accuracy and allowing omission when unknown
    • CLI validates unsupported VCS values and reports errors instead of silently accepting them

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

Warning

Rate limit exceeded

@stefanskoricdev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 45 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0841e9ad-b9f4-4c26-9851-d11b908eb7e5

📥 Commits

Reviewing files that changed from the base of the PR and between 3251418 and 1f595c9.

⛔ Files ignored due to path filters (5)
  • context/context-map.md is excluded by !context/**/*.md
  • context/glossary.md is excluded by !context/**/*.md
  • context/sce/agent-trace-hooks-command-routing.md is excluded by !context/**/*.md
  • context/sce/agent-trace-minimal-generator.md is excluded by !context/**/*.md
  • context/sce/setup-githooks-hook-asset-packaging.md is excluded by !context/**/*.md
📒 Files selected for processing (6)
  • cli/assets/hooks/post-commit
  • cli/src/cli_schema.rs
  • cli/src/services/agent_trace.rs
  • cli/src/services/agent_trace/tests.rs
  • cli/src/services/hooks/mod.rs
  • cli/src/services/parse/command_runtime.rs
📝 Walkthrough

Walkthrough

Add an optional --vcs CLI flag to post-commit, parse it into a typed AgentTraceVcsType, make AgentTrace.vcs optional and typed, thread the typed value through hook dispatch and trace construction, and update tests and the post-commit hook script to pass --vcs git.

Changes

VCS Type Post-Commit Hook Integration

Layer / File(s) Summary
VCS Type Domain Model
cli/src/services/agent_trace.rs
Introduce AgentTraceVcsType enum; change AgentTraceVcs to r#type: AgentTraceVcsType; add vcs_type: Option<AgentTraceVcsType> to AgentTraceMetadataInput; make AgentTrace.vcs: Option<AgentTraceVcs> and conditionally serialize; build_agent_trace conditionally constructs vcs from metadata.
CLI Schema and VCS Parsing
cli/src/cli_schema.rs, cli/src/services/parse/command_runtime.rs
Add --vcs option to hooks post-commit schema (vcs: Option<String>). convert_hooks_subcommand uses parse_optional_hook_vcs_type to map supported strings (git, jj, hg, svn) to AgentTraceVcsType or return validation errors; pass vcs_type into HookSubcommand::PostCommit.
Hook Execution with VCS Type Threading
cli/src/services/hooks/mod.rs
Change HookSubcommand::PostCommit to PostCommit { vcs_type: Option<AgentTraceVcsType> }. Dispatch, run_post_commit_subcommand, and agent-trace builder functions accept and forward vcs_type; update trace naming and persistence helpers to construct PostCommit variant with vcs_type.
Tests and Post-Commit Hook Script
cli/assets/hooks/post-commit, cli/src/services/agent_trace/tests.rs
Post-commit hook now invokes sce hooks post-commit --vcs git "$@". Tests updated to set vcs_type: Some(AgentTraceVcsType::Git) in AgentTraceMetadataInput and assert on typed AgentTraceVcs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • ivke995
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: threading optional VCS metadata into agent traces for post-commit hooks.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/post-commit-vcs-metadata

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@cli/src/services/parse/command_runtime.rs`:
- Around line 407-419: parse_optional_hook_vcs_type currently swallows unknown
--vcs values by returning None; change it to return a
Result<Option<services::agent_trace::AgentTraceVcsType>, String> (or a suitable
error type) so that when vcs is None you return Ok(None), when normalized
matches "git"/"jj"/"hg"/"svn" you return Ok(Some(...)), and when it does not
match you return Err with a clear validation message about the unsupported --vcs
value; update any callers to propagate or surface that Result so providing an
unsupported --vcs yields a visible validation error instead of silently dropping
metadata.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 37f6d2c7-e1db-4e34-99cc-91d2a0dee1f7

📥 Commits

Reviewing files that changed from the base of the PR and between 615ca0b and a639bdb.

⛔ Files ignored due to path filters (5)
  • context/context-map.md is excluded by !context/**/*.md
  • context/glossary.md is excluded by !context/**/*.md
  • context/sce/agent-trace-hooks-command-routing.md is excluded by !context/**/*.md
  • context/sce/agent-trace-minimal-generator.md is excluded by !context/**/*.md
  • context/sce/setup-githooks-hook-asset-packaging.md is excluded by !context/**/*.md
📒 Files selected for processing (6)
  • cli/assets/hooks/post-commit
  • cli/src/cli_schema.rs
  • cli/src/services/agent_trace.rs
  • cli/src/services/agent_trace/tests.rs
  • cli/src/services/hooks/mod.rs
  • cli/src/services/parse/command_runtime.rs

Comment thread cli/src/services/parse/command_runtime.rs
stefanskoricdev and others added 2 commits May 19, 2026 17:07
- Add optional  to post-commit hook processed intersection: commit=615ca0bc70e0fafb659875e5e0d18bfa698ed2dc, intersection_files=91 and parse known values () into .

- Pass parsed VCS type through hook runtime into .

- Make top-level  optional and emit it only when VCS type is provided.

- Update the packaged  hook template to invoke .

- Refresh SCE context docs to reflect optional VCS emission and updated post-commit command surface.

Co-authored-by: SCE <sce@crocoder.dev>
Return a validation error when an unsupported --vcs value is provided
for hooks post-commit instead of silently treating it as unset.

This updates optional VCS parsing to return Result<Option<...>, String>
and wires the post-commit command conversion through ClassifiedError::validation.

Co-authored-by: SCE <sce@crocoder.dev>
@stefanskoricdev stefanskoricdev force-pushed the feat/post-commit-vcs-metadata branch from 3251418 to 1f595c9 Compare May 19, 2026 15:08
@davidabram davidabram merged commit 80697bb into main May 20, 2026
1 check passed
@davidabram davidabram deleted the feat/post-commit-vcs-metadata branch May 20, 2026 08:25
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.

2 participants