Skip to content

feat(pc-mate): send a reply once, configure the intents and open a pull request for the work - #3042

Open
AlexStocks wants to merge 12 commits into
oceanbase:masterfrom
AlexStocks:codex/pc-mate-verdict-json
Open

AlexStocks wants to merge 12 commits into
oceanbase:masterfrom
AlexStocks:codex/pc-mate-verdict-json

Conversation

@AlexStocks

@AlexStocks AlexStocks commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Which issue or RFC does this PR close?

Closes #.

Rationale for this change

Five things a person in the chat, or a reader of the records, can feel. All five were found by running pc-mate against a real Feishu group and reading what came back.

  1. A verdict the model printed with an unescaped quote was no verdict at all. The assessment failed with expected ,or} at line 13 column 3175, the verdict was recorded as unavailable, and the person who asked received nothing. The same question read cleanly on the next run, so the failure is in the model's output, not in the input, and it recurs at random.

  2. The triage mode had two spellings. The configuration and the records said response; the authority gate labelled a policy reply.

  3. An identifier lost its underscore in the chat. Feishu renders the markdown of a message itself, and its renderer reads an underscore inside a word as the start of an emphasis: scope_id arrived as "scope_" followed by "id".

  4. allowed and maintainers answer different questions, and neither the README nor settings.example.yaml said so. A reader could not tell why a message from a listed person starts work while the same message from an unlisted person is answered and dropped.

  5. The answer reached the chat without its evidence. The read stage answered a question about the latest release with one sentence — “最新已发布版本是 v1.6.1(发布于 2026-12-01)。以下结论全部来自仓库自身记录:” — and the list of releases below it never arrived. The read stage kept only the first prose paragraph as the summary, and the summary was the whole reply.

  6. A request the reply mode promised was never carried out. triage.mode: response answered a feature request with a promise to implement it, but the work item was dropped: the code tied the write stage to auto alone, while the authority rule and the README already said an explicit request may write. The person was told the work had started when nothing had.

  7. A Feishu group had no conversation. Every message was its own conversation (chat#<message id>), so messages about one problem were separate assessments and separate work items, and an answer to a question the bot asked could not reach the work item that asked it: the answer landed in a different conversation and was never delivered.

  8. Every reply was sent again on every round. mark_sent wrote the sent marker but kept the queue entry, and pending() listed every queue entry, so each round re-sent every message that had ever been queued. In the live run the group received the same acknowledgements repeatedly, one batch every 15 seconds, and status() kept reporting a delivered message as pending.

What changes are included in this PR?

A verdict is read even when the model printed a malformed one

  • pc-mate/src/intent.rs: read the JSON object a model printed with extract_json_value, which tries the strict read and then repairs a quote inside a value's text, a raw control character, and a leftover comma before a closing bracket.
  • pc-mate/src/intent.rs: keep the model's text out of the error, so the reason that reaches the record holds no model content; the output itself goes to the local log.
  • pc-mate/src/supervisor/mod.rs: write the unreadable output to the main log when the triage cannot be read.
  • pc-mate/src/intent.rs: tell the model not to use double quotes inside the text of a value.
  • pc-mate/src/run_result.rs: read the outcome file of a run through the same reader.

The mode has one spelling

  • pc-mate/src/domain.rs: IntentMode::as_str() returns response, the name the configuration reads and the records write. The public value stays response; only the second spelling is gone.
  • pc-mate/src/domain.rs: a test holds the three together — the configuration reads the name, the record writes the name, and as_str() is that name. The test is red before the change.

An identifier survives the chat

  • pc-mate/src/channels/feishu.rs: an identifier with an underscore between two word characters is written as a code span, which is the one form Feishu's renderer keeps literal. Code, fenced blocks, link labels and URLs are left as they are, and an underscore at the edge of a word is left to the markdown, because that is a form the model may have meant.
  • pc-mate/src/intent.rs: tell the model to write an identifier that contains an underscore inside backticks.

The renderer was measured, not guessed. A probe message (om_x100b7e1cf4d8b4acdde6f94b86fcf13) showed that scope_id, ARTIFACT_ID@REVISION and README_CN.md all lose the underscore, that __init__ loses both and turns bold, that a backslash escape leaves the backslash in the text, and that a code span keeps the text exactly as written.

The lists are named

  • pc-mate/README.md: a new section "Who may start work" that states the difference between the two lists and what an empty list means.
  • pc-mate/README.md: github.allowed and feishu.allowed join the list of settings switches.
  • pc-mate/settings.example.yaml: both allowed lists carry the rule in a comment.

The answer that reaches the person is the whole answer

  • pc-mate/src/kernel/delegations.rs: a report carries the answer the person receives next to the summary the record keeps. The report itself is not persisted; the record keeps the summary.
  • pc-mate/src/supervisor/mod.rs: the read stage fills in the whole analysis, bounded by triage.max_reply_chars, and the reply sends it. The summary stays the first prose paragraph, so the record still reads as one sentence.
  • The implementation stage is unchanged: its answer is the structured outcome it wrote, and the summary is that answer.

An explicit request is carried out, and one person is one conversation

  • pc-mate/src/supervisor/mod.rs: a triage implement opens a work item when the request is explicit as well as when triage.mode: auto is on. An inferred request still opens one only in auto; response answers it.
  • pc-mate/src/domain.rs, pc-mate/src/kernel/entities.rs, pc-mate/src/case.rs: a Feishu group message carries its conversation — the person talking in the chat — so consecutive messages are one assessment, the case follows them, and the answer to a question the bot asked reaches the work item. A direct message stays keyed by the chat.
  • pc-mate/src/intent.rs: the triage prompt is told what this installation does with the ruling (observe / response / auto), so the reply no longer promises work that will not happen.
  • pc-mate/README.md, pc-mate/settings.example.yaml: the mode rule and the conversation rule are stated.

A sent message is sent once

  • pc-mate/src/supervisor/mailbox.rs: mark_sent removes the queue entry after writing the sent marker, and pending() skips an entry whose marker already exists, so a crash between the two writes cannot send the message twice.
  • Two tests cover it: a sent message leaves the queue, and a marker left by a crash keeps the message out of the queue.

The intent vocabulary is configuration

  • pc-mate/src/config.rs: triage.intents names the categories the classifier may answer with, each with the description the prompt shows the model. The vocabulary is data, not code: an operator adds an intent without a line of Rust changing. The legacy triage.categories still loads and still narrows the set.
  • pc-mate/src/intent.rs: the prompt's classification list and the output format's category list are generated from that configuration.
  • pc-mate/src/domain.rs: an intent this build does not know is not a broken verdict. IntentCategory reads any name and maps the one it does not know to other.
  • pc-mate/src/intent.rs: an intent this build cannot act on yet is answered like other — the message is read, nothing else happens — and the record says which name the model used, so a configured intent that is not handled yet and a name nobody configured stay apart.

A finished implementation opens a pull request and works through its review

  • pc-mate/src/config.rs: github.pullRequest carries the switch, the submitter account, the reviewer account, the round budget and the poll interval. The submitter and the reviewer have to be two accounts: GitHub refuses a review request from the author of a pull request, and a reviewer that is the author is no review at all, so an installation that names the same account twice is refused when the settings load.
  • pc-mate/src/channels/github.rs: open a pull request for the branch that was pushed, ask a reviewer for it, and read the reviews back. The installation may carry pull_requests: write; a submitter with a token of its own does not need it.
  • pc-mate/src/supervisor/pull_request.rs: the channel the supervisor needs, behind a trait, so the loop is tested without a network.
  • pc-mate/src/supervisor/mod.rs: the pull request is opened after the branch is pushed, the reviewer is asked, and every reviewPollSeconds the reviews are read. A review that asks for changes is a task: the implementation runs again with the findings in its prompt, on the same branch, so the push updates the pull request. The loop ends when the review is satisfied, when the round budget is spent, or when the requester is told what is left to do.
  • pc-mate/src/kernel/entities.rs: the work item carries its pull request, its round and the findings it is working on.
  • pc-mate/src/supervisor/mod.rs: a work item whose review or re-check is still pending stays open. The kernel ends a work item as soon as a run reports that the work is done, and both of those are after that point.

Are there any user-facing changes?

  • A verdict that the strict read rejected is now read instead of dropped, so a person who writes to the chat is answered more often.
  • An identifier in a Feishu reply is now shown as written.
  • A question that is answered in the read stage now reaches the chat with the whole answer, not with the first sentence of it.
  • A request from a listed person who named the agent is now carried out in response mode instead of being answered with a promise and dropped.
  • A person's messages in a Feishu group are one conversation, so a follow-up continues the work and an answer reaches the work item that asked the question.
  • A reply is sent once. Before this change every queued message was re-sent on every round.
  • The authority gate labels a policy response instead of reply. The name is part of the version a judgement records, so a judgement that was in flight across this change is re-assessed once and says policy_changed.
  • The intent vocabulary is configuration: a new intent can be added to triage.intents without a code change, and until the code handles it, it is answered like other.
  • A finished implementation can open a pull request of its own and work through the review of it, when github.pullRequest.enabled is on and the submitter account is named. The pull request is not a pending action: the switch and the account are the authorization.
  • triage.intents is a new configuration key. triage.categories still loads and still narrows the intents, so an existing settings file keeps its behaviour. triage.mode keeps accepting observe / response / auto.

How was this change tested?

  • cargo test --locked --manifest-path pc-mate/Cargo.toml — 228 passed, 1 failed (221 of 222 library tests, all 6 CLI tests, and the example-settings test). The failure is channels::github::tests::polling_a_changed_issue_keeps_unseen_human_comments_across_pages, which fails the same way on the unmodified base: the local firewall drops the test server's loopback connection (os error 10060). It was re-run on the base commit 1530d3c31 in a separate worktree and failed there with the same error.

  • cargo fmt --all --check and cargo clippy --locked --all-targets -- -D warnings from pc-mate/, the two gates the CI job runs.

  • New tests cover each of the five: a verdict that quotes a word inside its analysis, a leftover comma, an unreadable output, an outcome file that quotes a word inside its text, the three spellings of the mode, and an identifier in a reply beside code, a fenced block, a link label and a URL.

  • A test reads a read-stage answer that opens with a sentence and carries a list below it, and asserts that the list reaches the person while the record keeps the opening sentence alone.

  • Live check on Windows, with the rebuilt binary and one message sent to the Feishu group as the user: the message was queued at 19:18:46, the verdict landed at 19:20:39 as question/answer under the policy pc-mate:response:true, and the answer was delivered at 19:21 (om_x100b7e1e6a1b54acc31c13489522dc2) as 2324 characters and 21 lines, with the list of releases the opening sentence promised.

  • A test holds each new rule: an explicit request starts work in the reply mode (red before the change, green after), an inferred one does not, two group messages from one person are one assessment, an answer in a group reaches the work item that asked, a sent message leaves the queue, and a marker left by a crash keeps it out.

  • Live run on Windows against the real Feishu group, with the rebuilt binary: a group message from the listed person was stored with the conversation oc_6222.../ou_1264... (the person, not the message), the triage ask for missing information was delivered to the group at 20:34, and three write-stage runs each committed inside a worktree, pushed the branch, removed the worktree and left the shared checkout clean (22a6691 is the third).

  • The duplicate-send defect was observed in the same run: the same acknowledgement text arrived at 19:46 and again at 20:46, and the sent markers were rewritten every 15 seconds while the queue entries stayed. After the fix a sent message leaves the queue, and the two mailbox tests are red on the old code.

  • The delivered text and the mailbox text differ by one pair of backticks: protect_identifiers wrapped one_pass, and the identifiers the model had already written inside code spans were left as they are.

  • pc-mate/tests/settings_example.rs parses the shipped settings.example.yaml with the real Settings type, so an unknown key, a removed field or a drifted mode spelling now fails in cargo test --locked. The workflow needs no change because it already runs every test target.

  • pc-mate/README.md now carries the test playbook: the four automated gates, the loopback-only Windows failure, a disposable checkout plus bare remote for end-to-end runs, the four-intent message matrix, the evidence to read after each run, and each pitfall with its cause and workaround. README.md, README_CN.md and README_JP.md now link pc-mate from the project overview.

  • New tests cover the two additions: an intent the build does not know is answered like other, a configured intent that is not handled yet names itself, the prompt offers the configured intents, the vocabulary is refused when a name is unusable or listed twice or other is missing, the pull request settings are refused when the submitter is missing or the reviewer is the submitter, a finished implementation opens the pull request and asks the reviewer, a review that asks for changes runs the implementation again, an approved review answers the requester, and the findings of a review reach the implementation prompt.

  • Re-ran cargo fmt --all --check, cargo clippy --locked --all-targets -- -D warnings and cargo test --locked on the new head: clippy clean, 228 passed, the same single Windows loopback failure. Hosted pc-mate-validation / check is the Linux gate.

AI usage statement

Codex (OpenAI) wrote the change and the tests.

@AlexStocks
AlexStocks requested a review from hidb4ai as a code owner December 4, 2026 08:41
@AlexStocks
AlexStocks force-pushed the codex/pc-mate-verdict-json branch from 3994bfb to 696aa01 Compare December 4, 2026 08:52
The allowed list is read in two places with different effects: a channel drops what comes from outside it, and the authority gate turns the people on it into explicit requests. An empty list therefore takes every message in and leaves the list of explicit requesters empty, so every request is inferred, and an inferred request is accepted in triage.mode auto alone. In response mode the message is read, assessed and dropped without an answer, which is why a reply mode that serves a group needs the people it serves on the list. The maintainers list answers a different question and is described next to it.
@AlexStocks AlexStocks changed the title fix(pc-mate): read a verdict the model printed with a stray quote fix(pc-mate): repair a malformed verdict, align the mode name and protect identifiers Dec 4, 2026
@AlexStocks AlexStocks changed the title fix(pc-mate): repair a malformed verdict, align the mode name and protect identifiers fix(pc-mate): repair a malformed verdict, answer with the whole read-stage text and protect identifiers Dec 4, 2026
… per person

- response mode: an explicit request (a listed person who named the agent) starts work, as the authority rule already promised; an inferred one still starts work only in auto mode.
- Feishu: a group conversation is the person talking in the chat, so consecutive messages are one assessment and the answer to a question reaches the work that asked it.
- the triage prompt is told what the installation does with its ruling, so a reply no longer promises work that will not happen.
mark_sent wrote the sent marker but kept the queue entry, so pending() returned the message again on every round and the chat received every reply every 15 seconds. The pending entry is now removed after the marker is written, and pending() skips an entry whose marker already exists, so a crash between the two writes does not send it twice.
@AlexStocks AlexStocks changed the title fix(pc-mate): repair a malformed verdict, answer with the whole read-stage text and protect identifiers fix(pc-mate): send a reply once, carry out explicit work and keep one group conversation per person Dec 4, 2026
…work

The intent vocabulary moves into the configuration. `triage.intents` names the
categories the classifier may answer with, each with the description the
prompt shows the model, and an intent this build cannot act on yet is
answered like `other`: the message is read, nothing else happens, and the
record says which name the model used. The legacy `triage.categories` filter
still loads and still narrows the set.

A finished implementation can end at a pull request of its own.
`github.pullRequest.enabled` with a named submitter opens it for the branch
that was pushed and asks the reviewer to look at it. The reviewer has to be
another account than the submitter, because GitHub refuses a review request
from the author of a pull request. The reviews are read again, and a review
that asks for changes runs the implementation once more with the findings in
its prompt, on the same branch, until the review is satisfied or the round
budget is spent.
@AlexStocks AlexStocks changed the title fix(pc-mate): send a reply once, carry out explicit work and keep one group conversation per person feat(pc-mate): send a reply once, configure the intents and open a pull request for the work Dec 4, 2026
Remove the unreleased categories filter and use the configured intent vocabulary for routing. Document how GitHub API credentials determine the pull request author.

Tested: cargo fmt --all --check, cargo clippy --locked --all-targets -- -D warnings, and 228 passing tests with the Windows loopback timeout test excluded. The full suite reproduces the existing loopback timeout.

@hidb4ai hidb4ai 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.

The automatic review loop can restart implementation after the reviewer has approved. The inline finding reproduces this with the review parser and the supervisor workflow against an isolated local Git repository; GitHub and agent responses were controlled inputs, not live-service acceptance.

.unwrap_or_default();
// A review that asks for changes says why in its body; that is a finding of its own.
for review in reviews.iter().rev() {
if !review

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.

[P2] Do not replay superseded review findings

For the normal history CHANGES_REQUESTED("Fix X") followed by APPROVED("Fixed") from the same reviewer, this function returns state="approved" but still includes "Fix X". handle_review treats any nonempty findings as another implementation task, so it increments the round and starts another delegation instead of reporting approval. I reproduced both the parser result and the missed approval response through the supervisor with a real local Git repository. Previously resolved inline comments are also collected unconditionally. Track which review findings remain actionable (and which have already been processed for the branch head), so an approval after fixes terminates the loop and an unchanged historical review cannot consume another round.

@hireview001 hireview001 added the module:pc-mate Primary module: pc-mate community bot and experience reuse label Dec 4, 2026
@hireview001

Copy link
Copy Markdown
Collaborator

The affected modules are pc-mate. @hidb4ai, please coordinate follow-up. pc-mate: @hidb4ai @AlexStocks. Please coordinate the review of the affected changes.

This branch has not been deployed

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

Labels

module:pc-mate Primary module: pc-mate community bot and experience reuse

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants