Context
After a miner wins the claim-ledger election for an issue (src/miner/soft-claim.ts) it hands the work to a pluggable CodingAgentDriver (claude/codex) which produces the actual patch. Nothing today tells that driver what the target repo's own merge-bar looks like before it starts writing. The maintainer-side reviewer already infers per-repo conventions from repository signals and folds them into the review prompt as repoInstructions (src/services/ai-review.ts, the REPOSITORY REVIEW INSTRUCTIONS suffix), drawing on the same document surfaces (README, CONTRIBUTING.md, AI-USAGE.md) that ai-policy-map.ts scans for ban phrases. The miner has no equivalent step: a driver invoked cold defaults to whatever scope and style it produces unprompted, which is exactly the shape of the documented number one strategic risk for an autonomous fleet — mass-producing gate-passing-but-low-value PRs (slop-at-scale) because the diff is technically valid but oversized, off-style, or mismatched to a repo that actually wants small, narrowly scoped patches.
Goal
Before invoking the CodingAgentDriver for a claimed issue, extract the target repo's observable merge-bar and conventions using the same repo-profile signal path ai-review.ts already relies on, and use it to calibrate the generated PR's scope and style.
Requirements
- Cross-reference and reuse the existing repo-profile/repoInstructions extraction path in src/services/ai-review.ts rather than standing up a second, parallel signal scan; add a miner-facing accessor if the current shape is coupled to the review-prompt call site.
- Run extraction once per target repo, cached by repo full name with a short TTL or a content hash of the source documents, not once per claimed issue.
- Derive at minimum: typical merged-PR diff-size and file-count range, small-atomic-PR versus larger-PR preference, and any explicit style or format directives already present in CONTRIBUTING.md or equivalent.
- Feed the derived profile into the CodingAgentDriver invocation as structured calibration input (prompt context and/or a scope budget the driver must respect), not as free-text bolted onto the issue description.
- When extraction yields no usable signal (empty or generic CONTRIBUTING.md), fall back to a conservative default scope budget rather than an unconstrained one.
- Add a governor-visible log/metric recording which profile was used for a given attempt, so a rejected PR can be correlated back to a miscalibrated profile.
Deliverables
Expected outcomes
- Reduction in post-submission maintainer rejections attributable to PR size/style mismatch, measured against the miner's existing reward-MERGED-net-positive tracking
- No duplicated repo-signal-extraction logic between the reviewer and miner code paths
Context
After a miner wins the claim-ledger election for an issue (src/miner/soft-claim.ts) it hands the work to a pluggable CodingAgentDriver (claude/codex) which produces the actual patch. Nothing today tells that driver what the target repo's own merge-bar looks like before it starts writing. The maintainer-side reviewer already infers per-repo conventions from repository signals and folds them into the review prompt as repoInstructions (src/services/ai-review.ts, the REPOSITORY REVIEW INSTRUCTIONS suffix), drawing on the same document surfaces (README, CONTRIBUTING.md, AI-USAGE.md) that ai-policy-map.ts scans for ban phrases. The miner has no equivalent step: a driver invoked cold defaults to whatever scope and style it produces unprompted, which is exactly the shape of the documented number one strategic risk for an autonomous fleet — mass-producing gate-passing-but-low-value PRs (slop-at-scale) because the diff is technically valid but oversized, off-style, or mismatched to a repo that actually wants small, narrowly scoped patches.
Goal
Before invoking the CodingAgentDriver for a claimed issue, extract the target repo's observable merge-bar and conventions using the same repo-profile signal path ai-review.ts already relies on, and use it to calibrate the generated PR's scope and style.
Requirements
Deliverables
Expected outcomes