Skip to content

harden auto-triage duplicate notice formatting - #8097

Closed
iscekic wants to merge 2 commits into
mainfrom
drain/duplicate-notice-formatting
Closed

iscekic wants to merge 2 commits into
mainfrom
drain/duplicate-notice-formatting

Conversation

@iscekic

@iscekic iscekic commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Change

The auto-triage worker builds a duplicate-notice comment from the internal duplicate-check response. This change treats that response as a validated boundary and formats the quoted title with ordinary markdown semantics:

  • services/auto-triage-infra/src/types.ts: SimilarTicket and DuplicateResult are now derived from zod schemas (similarTicketSchema, duplicateResultSchema) with strict field constraints (non-empty ids, positive integer issue number, similarity in [0, 1 + 1e-6] to tolerate unclamped cosine rounding, repo full name in owner/repo shape).
  • services/auto-triage-infra/src/triage-orchestrator.ts: checkDuplicates() validates the response with duplicateResultSchema before use; an out-of-contract response throws, so the ticket is marked failed through the existing error path.
  • closeDuplicate() renders the quoted title through a new formatQuotedIssueTitle() helper: whitespace is folded so the title stays one quoted paragraph, then it renders as a single CommonMark inline code span whose delimiter is one backtick longer than the longest backtick run in the title (padded when the title starts or ends with a backtick), truncated at 280 raw characters with an ellipsis. Code span content renders literally. The issue link is built only from validated fields.

Verification

  • pnpm --filter kilo-auto-triage-worker exec vitest run: 21 passed (7 pre-existing, 14 new). New tests drive the real runTriage → checkDuplicates → closeDuplicate → postComment path with a stubbed fetch and assert the exact comment body: a title containing HTML, an @org/team mention, and a URL appears unchanged inside one code span; a backtick-only title gets a longer delimiter; a 300-character title is capped at 280 + ellipsis; embedded line breaks fold to one paragraph; an out-of-range similarity fails schema validation and marks the ticket failed; a similarity marginally above 1 validates.
  • Service typecheck (tsgo) and lint (oxlint) clean; formatted with oxfmt.
  • Limitation: GitHub-side comment rendering cannot be exercised from this VM; the code-span property (CommonMark literal rendering) is covered by the unit tests instead. No visual surface, no screenshots.

Proxy answers

  1. Question: How should the quoted issue title be rendered in the bot comment to keep its rendering predictable?
    Answer: Inline code span
    Confidence: 0.85
  2. Question: If the check-duplicates response fails schema validation, what should the orchestrator do?
    Answer: Throw, ticket marked failed
    Confidence: 0.65
  3. Question: Cap length for the quoted title?
    Answer: 280 chars + ellipsis
    Confidence: 0.50
  4. Question: Scope of zod validation on the response?
    Answer: Strict on all fields
    Confidence: 0.70
  5. Question: The 280-char cap for the quoted title: should it apply to the raw title text before wrapping in the code span, or to the final rendered span including delimiter backticks?
    Answer: 280 raw title chars + ellipsis, then wrap in code span (Recommended)
    Confidence: 0.80

Validate the internal duplicate-check response with a strict zod schema
before use, so downstream code only sees well-formed fields. Render the
quoted issue title as a single inline code span with a delimiter longer
than any backtick run in the title, capped at 280 characters with an
ellipsis. Build the issue link only from validated repo name and issue
number. Add tests covering markup, mentions, URLs, backtick-only titles,
length capping, and schema rejections.
@iscekic iscekic added drain Work item from the findings drain janitor:trust Janitor finding: trust boundary hardening labels Oct 19, 2026
Comment thread services/auto-triage-infra/src/types.ts Resolved
@kilo-code-bot

kilo-code-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the incremental commit 8c3658d0b5 (whitespace folding in the duplicate-notice title helper, epsilon tolerance on cosine similarity validation, and their tests); both previously reported findings are verified fixed and no new issues were found.

Files Reviewed (3 files)
  • services/auto-triage-infra/src/triage-orchestrator.ts
  • services/auto-triage-infra/src/types.ts
  • services/auto-triage-infra/src/triage-orchestrator.test.ts
Previous Review Summary (commit f0827ed)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit f0827ed)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
services/auto-triage-infra/src/types.ts 109 Strict max(1) on the raw Milvus cosine score can reject a near-identical duplicate (float rounding above 1) and mark the ticket failed instead of closing it.

SUGGESTION

File Line Issue
services/auto-triage-infra/src/triage-orchestrator.ts 52 issueTitle may contain a blank line, which terminates the blockquote/code span and lets the remainder render as live Markdown; normalize line breaks or reject them in the schema.
Files Reviewed (3 files)
  • services/auto-triage-infra/src/types.ts - 1 issue
  • services/auto-triage-infra/src/triage-orchestrator.ts - 1 issue
  • services/auto-triage-infra/src/triage-orchestrator.test.ts

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash-1017 · Input: 38.7K · Output: 3.2K · Cached: 152.6K

Review guidance: REVIEW.md from base branch main

Fold whitespace in the quoted title so the duplicate notice always keeps
it as one quoted paragraph inside the code span, and accept similarity
scores within a small epsilon above 1, matching unclamped cosine scores
returned by the search backend. Add tests for both.
@iscekic iscekic added the merge:human Substantive functional risk requires human review. label Oct 19, 2026
@iscekic
iscekic enabled auto-merge October 19, 2026 17:45
@iscekic

iscekic commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

bot: Closing as obsolete. main removed the auto-triage service end to end in #8151 (merged 2026-10-19) and dropped its table in #8152, so services/auto-triage-infra, its orchestrator, and the internal duplicate-check route no longer exist. Every file this branch changes is deleted upstream, which is why GitHub reports the branch as conflicting; resolving the modify/delete conflict would leave an empty diff.

The hardening this branch carried is therefore unreachable code and has no merge target. No replacement location exists on main for the affected path.

@iscekic iscekic closed this Oct 19, 2026
auto-merge was automatically disabled October 19, 2026 21:32

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

drain Work item from the findings drain janitor:trust Janitor finding: trust boundary hardening merge:human Substantive functional risk requires human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant