← Back to Pull requests

feat: automate // Written by: annotation sync #8282

Open
unknown opened this pull request with 250 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 26, 2026 11:38 UTC
Author

What

Add tooling to automate maintenance of // Written by: annotations on Cosmos struct fields in arohcp-cosmos-client/api/.

Why

These annotations are currently maintained by hand in every PR that adds or modifies a controller's field writes. This causes merge conflicts and maintenance burden as the controller count grows (219 annotations across 16 files today). See review discussion.

How

Two new components, designed to plug into the existing hourly docs-sync cadence:

1. Generation prompt (docs/prompts/written-by-annotations.md) — instructs the AI agent to analyze every controller and frontend handler, then output a structured JSON mapping of which actors write which Cosmos struct fields. Output: docs/generated/written-by-mapping.json.

2. Codegen tool (hack/writtenby/main.go) — reads the JSON mapping, parses Go source files with go/ast, and updates or adds // Written by: comments. Writers are sorted alphabetically for deterministic output. Flags: -mapping, -api, -dry-run.

This PR also includes:

  • A seed docs/generated/written-by-mapping.json extracted from the 217 existing annotations

  • Alphabetical re-sorting of 38 writer lists across 8 source files (normalizing existing annotations)

  • go.work updated to include the new hack/writtenby module
  • Verification


  • go build ./hack/writtenby/ passes

  • go vet ./hack/writtenby/... passes

  • Idempotency: running the tool twice produces zero changes on the second run (217 fields unchanged)
  • Integration

    The intended workflow on the existing hourly bot cadence:
    1. Bot runs the written-by-annotations.md prompt → regenerates written-by-mapping.json
    2. Bot runs go run ./hack/writtenby/ → updates annotations in source
    3. If any changes → bot opens a PR (same pattern as PR #7878 for docs sync)

    ---
    AI-generated. Review for accuracy.

    @machi1990 requested from Slack

    Chai persona: ARO Engineering

    Diff: 250 lines (+187 / -63) across 3 files Reviewer: machi1990 Review duration: 6829m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 250 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.331
    Real PR Conversation Timeline
    1 comments
    "Review active on #8282"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.0% (MEDIUM) · Higher = larger blast radius
    39.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.8% · Safe to merge
    20.8%
    Repository