From 68129a59fa59805642bdbcc04f7675dbffc4cc16 Mon Sep 17 00:00:00 2001 From: fullsend-code <278716306+fullsend-ai-coder[bot]@users.noreply.github.com> Date: Thu, 3 Dec 2026 17:45:35 +0000 Subject: [PATCH 1/5] feat(#9957): fold superseded agent result comments as outdated Every agent run now appends its result (#9334), so earlier results stay fully visible and readers scroll past them. When a run posts a result comment, minimize the same author's earlier comments carrying the same marker as OUTDATED, the way post-review already minimizes stale formal reviews. - sticky: new Config.MinimizeSuperseded and MinimizeSuperseded. After the new comment is created, it lists the thread and minimizes the earlier comments whose body starts with the marker and whose author is exactly the new comment's author. The newest comment, other authors' comments and comments posted after it stay visible. It is best effort: failures are logged, never returned. - post-review folds earlier review-agent comments. The stale-head and failure notices keep their own marker and fold nothing, so a request-changes review stays visible until a later review replaces it. - post-comment folds for the risk-assessment, triage-agent and prioritize-agent markers; review-dedup folds earlier skip notes. - forge.Client gains IsCommentMinimized (GitHub GraphQL; GitLab and Forgejo return ErrNotSupported) so a behaviour scenario can assert the fold. GitLab cannot minimize: earlier comments stay visible. - New behaviour scenario re-runs review and asserts one visible review and risk-assessment comment and the earlier ones minimized. - Review, triage and prioritize docs say older results are folded. Note: pre-commit could not fetch hook repos (sandbox TLS), so hooks were run directly; all passed except semgrep, which could not download its pinned ruleset and analyzed nothing. The new behaviour scenario was not run (needs live GitHub pool repos). Closes #9957 Co-Authored-By: Claude Opus 5.5 --- docs/agents/prioritize.md | 2 +- docs/agents/review.md | 4 +- docs/agents/triage.md | 2 +- docs/guides/dev/behaviour-drivers.md | 4 +- docs/guides/dev/behaviour-testing.md | 2 + .../review/review-re-run-minimize.feature | 43 ++++ .../fixtures/review/comment-with-risk.json | 12 ++ e2e/behaviour/github-emulator/shards.txt | 2 +- internal/cli/postcomment.go | 25 ++- internal/cli/postcomment_test.go | 62 ++++++ internal/cli/postreview.go | 24 ++- internal/cli/postreview_test.go | 56 ++++++ internal/cli/reviewdedup.go | 22 ++- internal/cli/reviewdedup_test.go | 43 +++- internal/forge/fake.go | 15 ++ internal/forge/fake_test.go | 1 + internal/forge/forge.go | 5 + internal/forge/forgejo/issues.go | 6 + internal/forge/forgejo/issues_test.go | 12 ++ internal/forge/github/github.go | 35 ++++ internal/forge/github/github_comment_test.go | 64 ++++++ internal/forge/gitlab/issue.go | 6 + internal/forge/gitlab/methods_test.go | 8 + internal/sticky/minimize_superseded_test.go | 184 ++++++++++++++++++ internal/sticky/sticky.go | 59 ++++++ pkg/behaviourtest/drivers/scm/driver.go | 9 + .../drivers/scm/github/github.go | 8 + .../drivers/scm/github/github_test.go | 17 ++ pkg/behaviourtest/steps/forge_state.go | 93 +++++++++ .../steps/forge_state_feature_test.go | 30 +++ pkg/behaviourtest/steps/forge_state_test.go | 86 ++++++++ 31 files changed, 917 insertions(+), 24 deletions(-) create mode 100644 e2e/behaviour/features/review/review-re-run-minimize.feature create mode 100644 e2e/behaviour/fixtures/review/comment-with-risk.json create mode 100644 internal/sticky/minimize_superseded_test.go diff --git a/docs/agents/prioritize.md b/docs/agents/prioritize.md index ceb5bcb398..5494d6c410 100644 --- a/docs/agents/prioritize.md +++ b/docs/agents/prioritize.md @@ -12,7 +12,7 @@ Scores a GitHub issue using the RICE framework (Reach, Impact, Confidence, Effor Triggered on a schedule (the prioritize scheduler polls the project board for unscored issues) or on-demand via `/fs-prioritize`. -The prioritize agent fetches the issue and all its context, then evaluates it across the four RICE dimensions. It can invoke customer-research skills to gather additional signal about reach and impact. The output is a structured JSON result with per-dimension scores and written reasoning. The post-script always publishes the RICE reasoning comment; when a project number is supplied, it also updates the project board. +The prioritize agent fetches the issue and all its context, then evaluates it across the four RICE dimensions. It can invoke customer-research skills to gather additional signal about reach and impact. The output is a structured JSON result with per-dimension scores and written reasoning. The post-script always publishes the RICE reasoning comment; when a project number is supplied, it also updates the project board. Every run posts a new reasoning comment. On GitHub, older results are folded as outdated: the bot's earlier reasoning comments on the issue are minimized as outdated, so only the newest stays expanded. ## How it helps diff --git a/docs/agents/review.md b/docs/agents/review.md index bc4e9d6696..87be41622b 100644 --- a/docs/agents/review.md +++ b/docs/agents/review.md @@ -15,7 +15,7 @@ The review agent is triggered when a PR is opened or updated, subject to the syn 1. **Pre-script** validates inputs and fetches PR metadata. 2. **Sandbox** — the agent runs the `pr-review` orchestrator skill. The orchestrator triages the change, then dispatches specialized sub-agents in parallel — each covering a distinct review dimension (correctness, security, intent & coherence, style & conventions, docs currency, and optionally cross-repo contracts). Sub-agents run concurrently and return structured findings. The orchestrator collects, deduplicates, and synthesizes findings across dimensions, runs PR-level checks (scope authorization, protected paths), and produces a structured JSON review result. The agent cannot push files, edit code, or push — it is strictly read-only. 3. **Validation loop** — the output is checked against a schema, with up to 2 retry iterations if the output is malformed. -4. **Post-script** posts the review on the PR. Findings that include a file path and a line in the change diff are also posted as inline comments on that line (GitHub review comments; GitLab merge-request discussions). Findings that cannot be positioned — file-level notes, lines outside the diff, or a GitLab diff version whose `head_sha` no longer matches the reviewed commit — stay in the review comment, and on GitLab as general MR notes. Every run posts a new review comment at the end of the thread. Once the review comment is posted, a failure to submit the forge's native review (GitHub PR review or GitLab approval) is logged as a warning and does not fail the run — the review comment is the authoritative record of the verdict. +4. **Post-script** posts the review on the PR. Findings that include a file path and a line in the change diff are also posted as inline comments on that line (GitHub review comments; GitLab merge-request discussions). Findings that cannot be positioned — file-level notes, lines outside the diff, or a GitLab diff version whose `head_sha` no longer matches the reviewed commit — stay in the review comment, and on GitLab as general MR notes. Every run posts a new review comment at the end of the thread. On GitHub, older results are folded as outdated: once the new review comment is posted, the review bot's earlier review comments, and when the result carries a risk assessment its earlier risk-assessment comments, are minimized as outdated, so only the newest of each stays expanded. An earlier request-changes review stays visible until a later review replaces it: stale-head and failure notices fold nothing. GitLab cannot minimize a comment, so there the earlier results stay visible. Once the review comment is posted, a failure to submit the forge's native review (GitHub PR review or GitLab approval) is logged as a warning and does not fail the run — the review comment is the authoritative record of the verdict. If a prior review exists (e.g., re-review after fixes), it is injected into the sandbox so the agent can assess whether previous findings were addressed. @@ -38,7 +38,7 @@ write or higher. The `/fs-review` command does not accept arguments and always forces a review. The review agent also runs automatically on a same-repository PR when it is opened, when its effective diff changes on a synchronize event, or when it is moved out of draft by a user with triage-level repository permission or higher. On GitHub, a fork PR is reviewed automatically under the same rules (a bot author is checked like any other author), through the managed `fullsend-fork-pr.yaml` workflow (see [Fork pull requests](../guides/getting-started/repo-management.md#fork-pull-requests)); the `ready-for-review` label does not start a fork PR review. Dependabot PRs are not reviewed automatically. On either, someone with triage access or higher (or an OWNERS approver or reviewer) can comment `/fs-review`. -For GitHub `pull_request` synchronize events (and `pull_request_target` from shims that have not been upgraded), the review is skipped when the complete effective diff matches the previous app-verified approved review. The guard posts a new PR-visible `fullsend:review-skip` status comment for each skip, linking the previous approved review, and never edits an earlier skip note in place on that publish path; a later full review supersedes each skip note once, in place, naming the commit that superseded it. GitLab diff metadata uses the same normalized model, but the GitLab poller does not consume this marker yet and continues to review synchronized merge requests. +For GitHub `pull_request` synchronize events (and `pull_request_target` from shims that have not been upgraded), the review is skipped when the complete effective diff matches the previous app-verified approved review. The guard posts a new PR-visible `fullsend:review-skip` status comment for each skip, linking the previous approved review, and never edits an earlier skip note in place on that publish path, but folds the bot's earlier skip notes as outdated; a later full review supersedes each skip note once, in place, naming the commit that superseded it. GitLab diff metadata uses the same normalized model, but the GitLab poller does not consume this marker yet and continues to review synchronized merge requests. The deduplication check runs before final Bash/CEL stage selection, so CEL-selected review routes participate as well. File modes are part of the compared effective diff identity, so executable-bit changes cannot be hidden by an otherwise identical textual patch. The guard fails open and runs the review when there is no prior diff hash, the prior review cannot be verified, a required hash/head or base/head tree-mode API call fails, the file listing is incomplete or truncated, or any file has no representable patch (for example, a binary or rename-only change). diff --git a/docs/agents/triage.md b/docs/agents/triage.md index abac121a61..30dc6a40fd 100644 --- a/docs/agents/triage.md +++ b/docs/agents/triage.md @@ -12,7 +12,7 @@ Inspects a GitHub issue, assesses information sufficiency, asks clarifying quest The triage agent is triggered when a new issue is opened or when an existing issue is updated. On GitLab, opening an issue also dispatches triage when the issue author has Developer access or higher (see [Commands](#commands)). The webhook fast path starts this dispatch, and events-mode cron polling backstops it when a webhook delivery is missed. It fetches the issue content — title, body, labels, comments — and reads repository context (architecture docs, existing issues, PRs) to understand the landscape. It then decides whether the issue has enough information to act on, or whether clarification is needed. -The agent runs in a read-only sandbox. It cannot modify issues, push code, or interact with external services. Its only output is a structured JSON triage result consumed by the post-script, which applies labels and posts a summary comment. +The agent runs in a read-only sandbox. It cannot modify issues, push code, or interact with external services. Its only output is a structured JSON triage result consumed by the post-script, which applies labels and posts a summary comment. Every run posts a new comment at the end of the thread. On GitHub, older results are folded as outdated: when a run posts its triage result (the comment carrying the `fullsend:triage-agent` marker), the triage bot's earlier comments with that marker on the issue are minimized as outdated, so only the newest stays expanded. GitLab and Jira cannot minimize a comment, so there the earlier results stay visible. ## How it helps diff --git a/docs/guides/dev/behaviour-drivers.md b/docs/guides/dev/behaviour-drivers.md index f3fac49d7b..3dfa3661f6 100644 --- a/docs/guides/dev/behaviour-drivers.md +++ b/docs/guides/dev/behaviour-drivers.md @@ -119,7 +119,9 @@ Each stub error is a `*drivers.NotImplementedError` (package `pkg/behaviourtest/ 1. Implement `scm.Driver` in `pkg/behaviourtest/drivers/scm//`. Also implement the optional `scm.PullRequestHeadSHAReader` interface (`GetPullRequestHeadSHA`). Dummy-agent fixtures that use the - `` placeholder need it. + `` placeholder need it. On a forge that can minimize + comments, also implement `scm.CommentMinimizedReader` + (`IsCommentMinimized`); the minimized-comment assertion steps need it. 2. Register the driver in `behaviourtest.RunSuite` when `BEHAVIOUR_SCM=`. 3. Document the env var value here. 4. Add `@skip:` tags on scenarios that cannot run until the driver is complete. diff --git a/docs/guides/dev/behaviour-testing.md b/docs/guides/dev/behaviour-testing.md index 35c0cdf289..c249f1a55e 100644 --- a/docs/guides/dev/behaviour-testing.md +++ b/docs/guides/dev/behaviour-testing.md @@ -429,6 +429,8 @@ once `the pull request head branch matches` has found it. | `the last comment on the issue contains ""` | The last (newest) comment on the issue contains the text | | `the last comment on the issue containing "" contains ""` | The newest comment on the issue carrying the marker (an agent's result marker) contains the text | | `a comment on the issue other than the last contains ""` | Some comment before the last on the issue contains the text | +| `the pull request has visible comments containing ""` | Exactly comments on the pull request contain the text and are not minimized (`the issue has visible comments containing ""` is the issue form). Needs an SCM driver that implements the optional `scm.CommentMinimizedReader`; the GitHub driver does | +| `every comment on the pull request containing "" other than the last is minimized` | At least two comments on the pull request contain the text, every one but the newest is minimized, and the newest is not, as a re-run leaves the results it supersedes (issue form: `every comment on the issue containing ...`). Needs `scm.CommentMinimizedReader` | | `the pull request body contains ""` | The PR body contains the text. `` expands, so `"Closes #"` checks the closing reference | | `an issue with label "