Skip to content

Add broker commit trailer hook support - #1465

Open
miyaontherelay wants to merge 5 commits into
mainfrom
feat/commit-trailer-hooks
Open

Add broker commit trailer hook support#1465
miyaontherelay wants to merge 5 commits into
mainfrom
feat/commit-trailer-hooks

Conversation

@miyaontherelay

Copy link
Copy Markdown
Contributor

Adds optional spawn metadata for commit trailers and preserves repository-local prepare-commit-msg hooks.\n\nTests cover trailer injection, hook chaining, and the metadata-absent no-op path.\n\nReference: https://github.com/AgentWorkforce/sales/issues/27

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cdc8c8f8-14aa-451f-9a90-c9e0d389b589

📥 Commits

Reviewing files that changed from the base of the PR and between 165983e and de6215a.

📒 Files selected for processing (1)
  • crates/broker/src/spawner.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/broker/src/spawner.rs

📝 Walkthrough

Walkthrough

Broker spawn actions now accept optional commit attestation metadata. Complete metadata reaches spawned workers through environment variables and enables a temporary chained Git hook that appends attribution trailers.

Changes

Commit attestation

Layer / File(s) Summary
Attestation contract and payload mapping
crates/broker/src/types.rs, crates/broker/src/wrap.rs, crates/broker/src/relaycast/bridge.rs
Spawn parameters and actions support optional jti, agentId, and sponsorId metadata. Tests verify deserialization and default metadata.
Worker environment and Git hook runtime
crates/broker/src/spawner.rs
Complete attestation metadata is exported to workers. A temporary chained Git hook appends attribution trailers. The implementation preserves Git configuration and validates metadata values.
Spawn action environment wiring
crates/broker/src/wrap.rs
Spawn execution applies attestation environment variables before worker registration and launch.

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

Sequence Diagram(s)

sequenceDiagram
  participant DispatchAction
  participant SpawnAction
  participant Spawner
  participant Worker
  participant GitRepository

  DispatchAction->>SpawnAction: provide optional attestation metadata
  SpawnAction->>Spawner: map metadata to environment variables
  Spawner->>Worker: launch with metadata and temporary hooks path
  Worker->>GitRepository: create commit
  GitRepository->>Worker: append attribution trailers
Loading

Suggested reviewers: willwashburn, khaliqgant

Poem

A rabbit checks the worker start,
And packs attestation in each part.
The hook adds trailers to the line,
Then chains the repository hook.
Git settings stay, commits record.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: broker support for commit trailer hooks.
Description check ✅ Passed The description explains the change and test coverage, but it omits the template headings and checklist details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/commit-trailer-hooks

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@crates/broker/src/spawner.rs`:
- Around line 244-248: Preserve existing Git configuration in the environment
setup around attestation_env_present, commit_hooks_dir, and
add_broker_hooks_path. Capture the effective core.hooksPath and inherited
GIT_CONFIG_* count before applying the broker override, then chain the captured
hook path and retain inherited indexed configuration entries. Add integration
coverage for repository-configured hooksPath and inherited GIT_CONFIG_*
variables.
- Around line 55-87: Validate attestation.jti, attestation.agent_id, and
attestation.sponsor_id for CR, LF, and NUL characters before exporting them in
the environment-building function, returning unchanged env_vars when any value
is invalid. Apply the same validation in attestation_env_present so the hook is
not enabled when any exported attestation value contains these control
characters.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a8382708-d60d-480b-8e76-ede05e2eb46a

📥 Commits

Reviewing files that changed from the base of the PR and between 7a42f3b and 7288258.

📒 Files selected for processing (4)
  • crates/broker/src/relaycast/bridge.rs
  • crates/broker/src/spawner.rs
  • crates/broker/src/types.rs
  • crates/broker/src/wrap.rs

Comment thread crates/broker/src/spawner.rs Outdated
Comment thread crates/broker/src/spawner.rs

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread crates/broker/src/spawner.rs
Comment thread crates/broker/src/spawner.rs Outdated
Comment thread crates/broker/src/spawner.rs Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 1 file (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread crates/broker/src/spawner.rs

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 1 file (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread crates/broker/src/spawner.rs
Comment thread crates/broker/src/spawner.rs Outdated
Comment thread crates/broker/src/spawner.rs Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="crates/broker/src/spawner.rs">

<violation number="1" location="crates/broker/src/spawner.rs:54">
P2: Configured hooks using `~user/...` (or bare `~`) are still skipped: Git expands these paths, but this chain treats them as repository-relative. Resolve `core.hooksPath` with Git's `--path` mode before selecting the hook directory so all supported tilde forms chain correctly.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

if [ -n "$configured_hooks_path" ]; then
case "$configured_hooks_path" in
/*) existing_hooks_dir="$configured_hooks_path" ;;
"~/"*) existing_hooks_dir="$HOME${configured_hooks_path#\~}" ;;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: Configured hooks using ~user/... (or bare ~) are still skipped: Git expands these paths, but this chain treats them as repository-relative. Resolve core.hooksPath with Git's --path mode before selecting the hook directory so all supported tilde forms chain correctly.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/broker/src/spawner.rs, line 54:

<comment>Configured hooks using `~user/...` (or bare `~`) are still skipped: Git expands these paths, but this chain treats them as repository-relative. Resolve `core.hooksPath` with Git's `--path` mode before selecting the hook directory so all supported tilde forms chain correctly.</comment>

<file context>
@@ -51,6 +51,7 @@ configured_hooks_path="$(git config --get core.hooksPath 2>/dev/null || true)"
 if [ -n "$configured_hooks_path" ]; then
   case "$configured_hooks_path" in
     /*) existing_hooks_dir="$configured_hooks_path" ;;
+    "~/"*) existing_hooks_dir="$HOME${configured_hooks_path#\~}" ;;
     *) repo_root="$(git rev-parse --show-toplevel 2>/dev/null)" || exit 0
        existing_hooks_dir="$repo_root/$configured_hooks_path" ;;
</file context>

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