Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .claude/commands/pr-trim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# PR Hedge Trim

Classify, fix, and resolve CodeRabbit review threads on open PRs.

## Arguments

- `$ARGUMENTS` - PR number(s) or flags: `--batch 935,936`, `--dry-run`, `--no-trail`

## Instructions

Parse `$ARGUMENTS` and execute the hedge trim cycle.

### Single PR (default)

Trim a single PR: analyze threads, apply fixes interactively, resolve addressed threads.

1. Run `make -C pmoves pr-trim-analyze PR=<number>`
2. Read the generated classification at `pmoves/docs/logs/pr_trim_<N>_threads.json`
3. Display the classification table to the user
4. For each **actionable** thread:
- Read the file and line referenced
- Apply the fix
- Explain the change to the user
5. After all actionable threads are addressed, commit + push
6. Run `make -C pmoves pr-trim-resolve PR=<number> RESOLVE_ACTIONABLE=1`
7. Unless `--no-trail`: `make -C pmoves sign-trail SUMMARY="PR Hedge Trim: resolved K threads on PR #N"`

### Batch mode (`--batch`)

Trim multiple PRs in sequence.

1. Parse comma-separated PR numbers from `--batch`
2. Execute single-PR flow for each, in order
3. After all PRs trimmed, display summary table

### Dry-run mode (`--dry-run`)

Analyze only — classify threads but do not resolve or fix.

1. Run `make -C pmoves pr-trim-analyze PR=<number>`
2. Display classification table
3. Do not resolve threads, do not sign trail

### Report mode (`--report`)

Generate a detailed markdown report for a PR.

1. Run `make -C pmoves pr-trim-report PR=<number>`
2. Display: `pmoves/docs/logs/pr_trim_<N>_summary.md`

## Examples

```bash
# Trim a single PR
/pr-trim 934

# Batch trim multiple PRs
/pr-trim --batch 935,936,937

# Dry-run analysis only
/pr-trim 934 --dry-run

# Skip Graphiti trail signing
/pr-trim 934 --no-trail

# Generate detailed report
/pr-trim 934 --report
```

## Related

- `/pr-monitor` — Monitor PR merge readiness (read-only)
- `/chit:floos validate pr-monitor-graphiti-chit` — Validate the FlOO$ pipeline DAG
- `make -C pmoves pr-trim PR=<number>` — CLI equivalent of full cycle
27 changes: 27 additions & 0 deletions .claude/context/nats-subjects.md
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,33 @@ Example: `ingest.transcript.ready.v1`
```
- **Subscribers:** Agent Zero, SupaSerch, Discord Publisher

## Operations Subjects

**`ops.pr.trim.completed.v1`**
- **Direction:** Published by claude-code-cli (pr-hedge-trim tool) → Consumed by pr-monitor, Discord Publisher
- **Purpose:** Notify that a PR hedge trim cycle completed — review threads classified, fixed, and resolved
- **Payload:**
```json
{
"pr_number": 934,
"repo": "POWERFULMOVES/PMOVES.AI",
"agent_id": "claude-opus",
"total_threads": 12,
"actionable": 5,
"design_decision": 2,
"false_positive": 3,
"nitpick": 2,
"resolved": 10,
"commit_sha": "abc123",
"timestamp": "2026-03-15T12:00:00Z",
"trail_signed": true
}
```
- **Schema:** `pmoves/contracts/schemas/ops/pr.trim.completed.v1.schema.json`
- **Subscribers:** PR Monitor (pipeline chain), Discord Publisher
- **Delivery:** Publish/subscribe (advisory, no JetStream required)
- **Related:** Part of `pr-monitor-graphiti-chit` FlOO$ pairing chain

## Testing & Development Subjects

**`test.smoke.v1`**
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ pmoves/jellyfin-ai/
pmoves/pmoves/PR_EVIDENCE/
pmoves/docs/logs/pr_monitor_*.json
pmoves/docs/logs/pr_monitor_*.md
pmoves/docs/logs/pr_trim_*.json
pmoves/docs/logs/ci_queue_guard_latest.json
pmoves/docs/logs/branch_divergence_*.txt

Expand Down
28 changes: 28 additions & 0 deletions pmoves/config/agent_registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,34 @@ agents:
recovery_strategy: manual_handoff
description: "Hostinger KVM fleet orchestration — deploy, status, restart via MCP tools"

pr_hedge_trim:
name: "PR Hedge Trim"
class: utility
primary_type: worker
secondary_type: agent
port: null
health: null
layers: [L0, L2, L5]
evolution_stage: stage_1
nats:
publishes: ["ops.pr.trim.completed.v1"]
subscribes: ["ops.pr.monitor.completed.v1"]
chit_toggles:
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
delta_sensitive: false
kappa_sensitive: false
hz_sensitive: false
swarm_participant: false
attribution_gated: true
resilience:
context_budget: small
checkpoint_frequency: per_file
recovery_strategy: idempotent_replay
cipher_categories: []
invocation_policy:
explicit_only: true
nats_trigger_allowed: true
description: "PR review thread classifier and resolver — hedge trims CodeRabbit threads"

# --- Data infrastructure (Utility class) ---

nats:
Expand Down
15 changes: 13 additions & 2 deletions pmoves/configs/skill-pairings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,23 @@ pairings:
hooks:
on_complete: "ops.pr.monitor.completed.v1"
on_error: "ops.pr.monitor.failed.v1"
- skill: pr-learnings-encode
- skill: pr-hedge-trim
input: pr_monitor_report
output: trim_report
agent: claude-opus
depends:
services: ["nats:4222"]
skills: ["pr-monitor"]
hooks:
on_complete: "ops.pr.trim.completed.v1"
on_error: "ops.pr.monitor.failed.v1"
- skill: pr-learnings-encode
input: [pr_monitor_report, trim_report]
output: pr_learnings_packet
agent: tokenism
depends:
services: ["nats:4222"]
skills: ["pr-monitor"]
skills: ["pr-hedge-trim"]
hooks:
on_complete: "ops.pr.learnings.encoded.v1"
on_error: "ops.pr.monitor.failed.v1"
Expand Down Expand Up @@ -343,6 +353,7 @@ skill_sources:
a2ui-chart: "pmoves/services/a2ui-renderer/"
extract-worker: "pmoves/services/extract-worker/"
pr-monitor: "pmoves/tools/pr_monitor.py"
pr-hedge-trim: "pmoves/tools/pr_hedge_trim.py"
pr-learnings-encode: "pmoves/tools/chit_encode_hook.py"
graphiti-trail-sync: "docs/AGENT_TRAIL.md"
n8n-health-sync: "pmoves/integrations/health-wger/n8n/flows/"
Expand Down
60 changes: 60 additions & 0 deletions pmoves/contracts/schemas/ops/pr.trim.completed.v1.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "ops/pr.trim.completed.v1.schema.json",
"title": "PR Hedge Trim Completed",
"description": "Emitted when a PR hedge trim cycle completes — review threads classified, fixed, and resolved.",
"type": "object",
"required": ["pr_number", "repo", "agent_id", "total_threads", "resolved", "timestamp"],
"properties": {
"pr_number": {
"type": "integer",
"description": "GitHub PR number"
},
"repo": {
"type": "string",
"description": "GitHub repository in owner/name format"
},
"agent_id": {
"type": "string",
"description": "Agent that performed the trim"
},
"total_threads": {
"type": "integer",
"description": "Total review threads on the PR"
},
"actionable": {
"type": "integer",
"description": "Threads classified as actionable (fix-worthy)"
},
"design_decision": {
"type": "integer",
"description": "Threads classified as design decisions"
},
"false_positive": {
"type": "integer",
"description": "Threads classified as false positives"
},
"nitpick": {
"type": "integer",
"description": "Threads classified as nitpick/cosmetic"
},
"resolved": {
"type": "integer",
"description": "Number of threads resolved in this trim"
},
"commit_sha": {
"type": "string",
"description": "HEAD commit SHA after fixes"
},
"timestamp": {
"type": "string",
"format": "date-time",
"description": "ISO 8601 completion timestamp"
},
"trail_signed": {
"type": "boolean",
"description": "Whether a Graphiti trail entry was signed"
}
Comment thread
POWERFULMOVES marked this conversation as resolved.
Resolved
},
"additionalProperties": false
Comment thread
POWERFULMOVES marked this conversation as resolved.
Resolved
}
6 changes: 6 additions & 0 deletions pmoves/contracts/topics.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@
"shape.distillation.requested.v1": {
"schema": "schemas/shape/distillation.requested.v1.schema.json",
"description": "User requested CHIT distillation for their discovered shape"
},
"ops.pr.trim.completed.v1": {
"schema": "schemas/ops/pr.trim.completed.v1.schema.json",
"description": "PR Hedge Trim completed — review threads classified, fixed, and resolved",
"publisher": ["claude-code-cli"],
"subscriber": ["pr-monitor", "publisher-discord"]
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}
}
}
16 changes: 15 additions & 1 deletion pmoves/mk/preflight.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: env-bootstrap-lite env-setup env-check preflight flight-check flight-check-retro preflight-retro showtime bringup-showtime smoke-showtime showtime-links showtime-links-open showtime-links-strict submodule-integrity submodule-layer-validate submodule-layer-validate-one submodule-layer-validate-all submodule-layer-validate-all-strict submodule-layer-validate-strict submodule-branch-policy-check audit-layers audit-layers-static audit-layers-runtime ci-runners-check ci-runners-check-strict ci-runners-map ci-runners-map-strict ci-runners-lockdown ci-runners-lockdown-strict ci-runners-local-cert-up ci-runners-local-cert-down ci-runners-local-cert-status ci-queue-sitrep ci-queue-drain-nonpr ci-queue-drain-nonpr-apply skill-registry-validate auth-alignment auth-alignment-strict topology-chit-gate topology-chit-gate-strict pr-monitor pr-monitor-strict pr-monitor-chit-packet floos-status floos-pr-monitor-validate floos-pr-monitor-resolve floos-pr-monitor-run-dry chit-flow-pr-monitor chit-flow-pr-monitor-strict ports-resolve sign-trail
.PHONY: env-bootstrap-lite env-setup env-check preflight flight-check flight-check-retro preflight-retro showtime bringup-showtime smoke-showtime showtime-links showtime-links-open showtime-links-strict submodule-integrity submodule-layer-validate submodule-layer-validate-one submodule-layer-validate-all submodule-layer-validate-all-strict submodule-layer-validate-strict submodule-branch-policy-check audit-layers audit-layers-static audit-layers-runtime ci-runners-check ci-runners-check-strict ci-runners-map ci-runners-map-strict ci-runners-lockdown ci-runners-lockdown-strict ci-runners-local-cert-up ci-runners-local-cert-down ci-runners-local-cert-status ci-queue-sitrep ci-queue-drain-nonpr ci-queue-drain-nonpr-apply skill-registry-validate auth-alignment auth-alignment-strict topology-chit-gate topology-chit-gate-strict pr-monitor pr-monitor-strict pr-monitor-chit-packet pr-trim-analyze pr-trim-resolve pr-trim-report pr-trim floos-status floos-pr-monitor-validate floos-pr-monitor-resolve floos-pr-monitor-run-dry chit-flow-pr-monitor chit-flow-pr-monitor-strict ports-resolve sign-trail
RETRO_THEME_QUICK ?= cb
RETRO_THEME_FULL ?= galaxy
RETRO_FLAGS ?=
Expand Down Expand Up @@ -233,6 +233,20 @@ pr-monitor-chit-packet: ## Encode PR monitor learnings into CHIT packet artifact
@cat docs/logs/pr_monitor_learnings_latest.md | $(PRECHECK_PY) tools/chit_encode_hook.py --pretty > docs/logs/pr_monitor_learnings_latest.cgp.json
@echo "Wrote CHIT packet: docs/logs/pr_monitor_learnings_latest.cgp.json"

pr-trim-analyze: ## Fetch and classify unresolved review threads for a PR
@$(PRECHECK_PY) tools/pr_hedge_trim.py --repo "$${PR_TRIM_REPO:-}" analyze --pr "$${PR:-0}" $${PR_TRIM_JSON_OUT:+--json-out "$$PR_TRIM_JSON_OUT"} $(ARGS)

pr-trim-resolve: ## Resolve addressed review threads via GraphQL mutation
@$(PRECHECK_PY) tools/pr_hedge_trim.py --repo "$${PR_TRIM_REPO:-}" resolve --pr "$${PR:-0}" $${DRY_RUN:+--dry-run} $${RESOLVE_ACTIONABLE:+--include-actionable} $(ARGS)

pr-trim-report: ## Generate trim summary report for a PR
@$(PRECHECK_PY) tools/pr_hedge_trim.py --repo "$${PR_TRIM_REPO:-}" report --pr "$${PR:-0}" $(ARGS)

pr-trim: ## Full hedge trim cycle: analyze + resolve + trail sign
@$(MAKE) --no-print-directory pr-trim-analyze PR="$${PR:-0}"
@$(MAKE) --no-print-directory pr-trim-resolve PR="$${PR:-0}" RESOLVE_ACTIONABLE="$${RESOLVE_ACTIONABLE:-}"
@$(MAKE) --no-print-directory sign-trail SUMMARY="PR Hedge Trim: trimmed PR #$${PR:-0}" AGENT="$${AGENT:-claude-opus}"

floos-status: ## Show FlOO$ pairing status
@PYTHONPATH="$(CURDIR)/.." $(PRECHECK_PY) -m pmoves.tools.chit.floos_resolver status $(ARGS)

Expand Down
Loading
Loading