Skip to content

feat(api): add post-merge incident reporting for already-merged PRs - #5766

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
nghetienhiep:fix/issue-5672
Jul 14, 2026
Merged

feat(api): add post-merge incident reporting for already-merged PRs#5766
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
nghetienhiep:fix/issue-5672

Conversation

@nghetienhiep

Copy link
Copy Markdown
Contributor

Adds a reporting path for the case where an already-merged rented-loop
PR is later found harmful: a repo-maintainer route
(POST /v1/repos/:owner/:repo/pulls/:number/incident-reports) and an
internal-operator route (POST /v1/app/incident-reports), both writing
a queryable audit_events row via a shared recordPostMergeIncidentReport
helper. Reports are keyed to the PR's repo#number targetKey, so the
existing agent/audit-feed ?pull=N view already surfaces them back to
maintainers with no separate table or read route needed.

Closes #5672

Adds a reporting path for the case where an already-merged rented-loop
PR is later found harmful: a repo-maintainer route
(POST /v1/repos/:owner/:repo/pulls/:number/incident-reports) and an
internal-operator route (POST /v1/app/incident-reports), both writing
a queryable audit_events row via a shared recordPostMergeIncidentReport
helper. Reports are keyed to the PR's repo#number targetKey, so the
existing agent/audit-feed ?pull=N view already surfaces them back to
maintainers with no separate table or read route needed.

Closes JSONbored#5672
@nghetienhiep
nghetienhiep requested a review from JSONbored as a code owner July 14, 2026 13:00
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.07%. Comparing base (210a8b1) to head (f6fbe0c).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5766   +/-   ##
=======================================
  Coverage   95.07%   95.07%           
=======================================
  Files         582      582           
  Lines       46183    46221   +38     
  Branches    14812    14823   +11     
=======================================
+ Hits        43907    43945   +38     
  Misses       1516     1516           
  Partials      760      760           
Flag Coverage Δ
shard-1 43.40% <18.42%> (-0.55%) ⬇️
shard-2 36.01% <94.73%> (+0.27%) ⬆️
shard-3 32.19% <18.42%> (-0.07%) ⬇️
shard-4 32.82% <18.42%> (-0.13%) ⬇️
shard-5 31.33% <15.78%> (-0.41%) ⬇️
shard-6 44.98% <21.05%> (+0.32%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/api/routes.ts 94.43% <100.00%> (+0.08%) ⬆️
src/db/repositories.ts 96.71% <100.00%> (+<0.01%) ⬆️
src/openapi/spec.ts 99.42% <100.00%> (+<0.01%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 14, 2026
@loopover-orb

loopover-orb Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-14 13:08:42 UTC

5 files · 1 AI reviewer · no blockers · readiness 95/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
Adds two new incident-reporting POST routes (customer-facing repo-scoped and internal-operator) that both persist through a shared recordPostMergeIncidentReport helper into audit_events, reusing the existing repo#number targetKey so the audit-feed already surfaces reports without a new table. The wiring is consistent end-to-end (schema validation, mergedSha regex, merged-check via pullRequest.mergedAt, session actor resolution, path added to canSessionAccessPath), openapi.json and spec.ts are kept in sync, and the test suite exercises both routes' happy paths, 400/404/409 cases, and auth boundaries against real D1-backed test env, not fabricated payloads. This is a DB-only audit_events write with no new table/columns, so no migration is needed, and the change is well-scoped to the linked issue.

Nits — 5 non-blocking
  • src/api/routes.ts: the mergedSha regex `/^[0-9a-f]{7,40}$/i` in both postMergeIncidentReportSchema and operatorPostMergeIncidentReportSchema is duplicated verbatim — consider factoring into a shared schema fragment.
  • External brief flags many numeric literals (4000, 200, 409, etc.) as unexplained magic numbers; these are self-evident HTTP status codes and field length limits and don't warrant named constants.
  • src/db/repositories.ts: recordPostMergeIncidentReport's JSDoc says 'no separate table -- this event type is the sole persistence layer,' which is accurate but worth double-checking that listAuditEventsForTarget's response shape doesn't need a severity/reporterKind-specific projection for the UI to render these usefully.
  • Consider a shared zod schema for the description/severity/mergedSha fields between postMergeIncidentReportSchema and operatorPostMergeIncidentReportSchema (src/api/routes.ts:893-916) to avoid drift if validation rules change.
  • Confirm the linked issue Post-merge incident audit-trail & reporting wiring #5672 is fully closed by this PR (external brief notes 'partial' coverage) — if there's a read-side requirement beyond the existing ?pull=N audit feed, call that out explicitly in the PR description.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #5672
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ⚠️ 20/25 Preflight is ready, but the PR body does not name the validation run.
Contributor workload ✅ 10/10 Author activity: 10 registered-repo PR(s), 4 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor nghetienhiep; Gittensor profile; 10 PR(s), 0 issue(s).
Gate result ✅ Passing No configured blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence. LLM value judgment: moderate — The PR adds a narrowly-scoped, well-tested operator/customer reporting path directly tied to issue #5672, reusing existing audit-event infrastructure rather than introducing new storage, which is a targeted and low-risk improvement to the review-engine's incident-handling surface.
Linked issue satisfaction

Addressed
The PR adds both a customer-facing route (POST /v1/repos/:owner/:repo/pulls/:number/incident-reports, gated by requireRepoMaintainer) and an internal-operator route (POST /v1/app/incident-reports, gated by operator role), both writing a complete audit_events row via a shared recordPostMergeIncidentReport helper keyed to repo#pull, with merged-state validation and extensive tests covering both path

Review context
  • Author: nghetienhiep
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 10 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Add validation command/output.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
[BETA] Chat with Gittensory

Ask Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @gittensory ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @gittensory chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @gittensory mention with a real question is routed to the closest matching read-only command automatically -- no exact syntax required.

Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands

Visual preview
Route Viewport Before (production) After (this PR's preview) Diff
/ desktop before / after /
/ mobile before / (mobile) after / (mobile)

Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb 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.

Gittensory approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit c4f662a into JSONbored:main Jul 14, 2026
16 checks passed
This was referenced Jul 14, 2026
This was referenced Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Post-merge incident audit-trail & reporting wiring

1 participant