Repository navigation
feat(pc-mate): send a reply once, configure the intents and open a pull request for the work - #3042
AlexStocks wants to merge 12 commits into
Conversation
3994bfb to
696aa01
Compare
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.
… 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.
…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.
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
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
[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.
|
The affected modules are pc-mate. @hidb4ai, please coordinate follow-up. pc-mate: @hidb4ai @AlexStocks. Please coordinate the review of the affected changes. |
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.
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 asunavailable, 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.The triage mode had two spellings. The configuration and the records said
response; the authority gate labelled a policyreply.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_idarrived as "scope_" followed by "id".allowedandmaintainersanswer different questions, and neither the README norsettings.example.yamlsaid 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.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.
A request the reply mode promised was never carried out.
triage.mode: responseanswered a feature request with a promise to implement it, but the work item was dropped: the code tied the write stage toautoalone, 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.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.Every reply was sent again on every round.
mark_sentwrote the sent marker but kept the queue entry, andpending()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, andstatus()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 withextract_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()returnsresponse, the name the configuration reads and the records write. The public value staysresponse; 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, andas_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 thatscope_id,ARTIFACT_ID@REVISIONandREADME_CN.mdall 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.allowedandfeishu.allowedjoin the list of settings switches.pc-mate/settings.example.yaml: bothallowedlists 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 bytriage.max_reply_chars, and the reply sends it. The summary stays the first prose paragraph, so the record still reads as one sentence.An explicit request is carried out, and one person is one conversation
pc-mate/src/supervisor/mod.rs: a triageimplementopens a work item when the request is explicit as well as whentriage.mode: autois on. An inferred request still opens one only inauto;responseanswers 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_sentremoves the queue entry after writing the sent marker, andpending()skips an entry whose marker already exists, so a crash between the two writes cannot send the message twice.The intent vocabulary is configuration
pc-mate/src/config.rs:triage.intentsnames 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 legacytriage.categoriesstill 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.IntentCategoryreads any name and maps the one it does not know toother.pc-mate/src/intent.rs: an intent this build cannot act on yet is answered likeother— 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.pullRequestcarries 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 carrypull_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 everyreviewPollSecondsthe 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?
responsemode instead of being answered with a promise and dropped.responseinstead ofreply. 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 sayspolicy_changed.triage.intentswithout a code change, and until the code handles it, it is answered likeother.github.pullRequest.enabledis on and the submitter account is named. The pull request is not a pending action: the switch and the account are the authorization.triage.intentsis a new configuration key.triage.categoriesstill loads and still narrows the intents, so an existing settings file keeps its behaviour.triage.modekeeps acceptingobserve/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 ischannels::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 commit1530d3c31in a separate worktree and failed there with the same error.cargo fmt --all --checkandcargo clippy --locked --all-targets -- -D warningsfrompc-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/answerunder the policypc-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 (22a6691is 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
sentmarkers 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_identifierswrappedone_pass, and the identifiers the model had already written inside code spans were left as they are.pc-mate/tests/settings_example.rsparses the shippedsettings.example.yamlwith the realSettingstype, so an unknown key, a removed field or a drifted mode spelling now fails incargo test --locked. The workflow needs no change because it already runs every test target.pc-mate/README.mdnow 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.mdandREADME_JP.mdnow 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 orotheris 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 warningsandcargo test --lockedon the new head: clippy clean, 228 passed, the same single Windows loopback failure. Hostedpc-mate-validation / checkis the Linux gate.AI usage statement
Codex (OpenAI) wrote the change and the tests.