Skip to content

Take Copilot run lessons from pr_debug fix records into knowledge intake - #225

Merged
tzhouam merged 2 commits into
mainfrom
kb/bugfix-lessons-intake
Sep 28, 2026
Merged

tzhouam merged 2 commits into
mainfrom
kb/bugfix-lessons-intake

Conversation

@tzhouam

@tzhouam tzhouam commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Source 2 of the design (Copilot's own run experience) had a producer and a
consumer that never met. pr_debug drops verified fix records (bugfix-record
v1/v2) into KNOWLEDGE_INTAKE_DIR and posts them to a mailbox issue, while the
knowledge service only read its own inbox/lessons format, so no run ever
became a knowledge event.

  • collect_events (with intake.copilot_runs) now also reads fix records:
    • dropped on this host into KB_BUGFIX_DIR (default
      <state_dir>/inbox/bugfix; set it to the runs' KNOWLEDGE_INTAKE_DIR);
    • posted by runs on other hosts to the mailbox issue KB_BUGFIX_MAILBOX
      (owner/repo#N).
  • A record belongs to the repository whose full name (case-insensitive) or
    alias it names exactly. An ambiguous identity is quarantined (renamed
    .quarantined), never rewritten; a record for another configured repository
    is left for that repository's turn; a malformed one is left for inspection.
  • The mailbox is a public issue: only comments by KB_BUGFIX_AUTHORS count,
    and without that list the mailbox is not read at all. Each repository keeps
    its own comment cursor.
  • The mailbox is read from one second before the last seen comment's
    creation time (since is exclusive and second-grained; the id cursor drops
    the overlap), so a busy mailbox never pins the reader behind a fixed page
    window and a comment sharing that second is not skipped. The
    record is decoded as one JSON object after the fence opener, so a code
    fence quoted inside a root cause does not truncate it; a record whose
    files is not a list is malformed and skipped.
  • Event IDs are the records' event_id, so a record delivered twice (drop and
    mailbox, or a retry) is one event.

Tests: test/test_kb_lessons.py (6); full offline suite green; spec freshness strict clean.

🤖 Generated with Claude Code

Source 2 of the design (Copilot's own run experience) had a producer and a
consumer that never met. pr_debug drops verified fix records (bugfix-record
v1/v2) into KNOWLEDGE_INTAKE_DIR and posts them to a mailbox issue, while the
knowledge service only read its own inbox/lessons format, so no run ever
became a knowledge event.

- collect_events (with intake.copilot_runs) now also reads fix records:
  - dropped on this host into KB_BUGFIX_DIR (default
    <state_dir>/inbox/bugfix; set it to the runs' KNOWLEDGE_INTAKE_DIR);
  - posted by runs on other hosts to the mailbox issue KB_BUGFIX_MAILBOX
    (owner/repo#N).
- A record belongs to the repository whose full name (case-insensitive) or
  alias it names exactly. An ambiguous identity is quarantined (renamed
  .quarantined), never rewritten; a record for another configured repository
  is left for that repository's turn; a malformed one is left for inspection.
- The mailbox is a public issue: only comments by KB_BUGFIX_AUTHORS count,
  and without that list the mailbox is not read at all. Each repository keeps
  its own comment cursor.
- The mailbox is read from one second before the last seen comment's
  creation time (`since` is exclusive and second-grained; the id cursor drops
  the overlap), so a busy mailbox never pins the reader behind a fixed page
  window and a comment sharing that second is not skipped. The
  record is decoded as one JSON object after the fence opener, so a code
  fence quoted inside a root cause does not truncate it; a record whose
  `files` is not a list is malformed and skipped.
- Event IDs are the records' event_id, so a record delivered twice (drop and
  mailbox, or a retry) is one event.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T18:45:40.075206Z 1eff9e0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1eff9e0ab2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +318 to +319
if not isinstance(group, dict) or not isinstance(group.get("files") or [], list):
return None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject falsey non-list files values

When a dropped record or allowed mailbox comment has "files": null, omits the field, or supplies another falsey scalar, group.get("files") or [] converts it to an empty list and accepts the malformed record. collect_events then persists it and marks the drop consumed or advances the mailbox cursor, contrary to the malformed-record handling and preventing later inspection or correction; validate the original field directly as a list.

Useful? React with 👍 / 👎.

Resolve the SPEC conflict by keeping both new sections.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant