diff --git a/.agents/skills/claim-work/SKILL.md b/.agents/skills/claim-work/SKILL.md new file mode 100644 index 000000000..584fa36ac --- /dev/null +++ b/.agents/skills/claim-work/SKILL.md @@ -0,0 +1,62 @@ +--- +name: claim-work +description: Claim an InferRSI Issue or fix before starting it, state when the next artifact will appear, and release the claim if nothing appears. Use before starting a fix, opening a PR or taking over a delegated slice. +--- + +# Claim work on an InferRSI Issue + +Follow the [identity and authority](../../../docs/agent-collaboration.md#identity-and-authority) +rules and working rules 1, 7 and 8 in +[agent collaboration](../../../docs/agent-collaboration.md#working-rules). + +## Check before claiming + +1. Confirm the governing Issue and its accepted scope before changing code. If + the guide's [stop check](../../../docs/agent-collaboration.md#identity-and-authority) finds a stop on + this work's stop chain, or cannot rule one out, do not claim it. +2. Confirm the Issue has an accountable owner (recorded on the Issue, or else + its only assignee when exactly one is set) and carries `status:accepted`: + + ```bash + gh issue view --repo InferMatrixLab/InferRSI --json assignees,labels + ``` + + With several assignees and no recorded owner, there is no accountable + owner yet. With no accountable owner, propose on the Issue and ask a maintainer to assign it; + at `status:proposed` or `status:deferred`, discuss only. Do not claim + either. +3. Confirm you are the deciding agent (the formal agent working for the + accountable owner's account) or that the deciding agent delegated this slice to you + on the Issue. Otherwise propose on the Issue instead of claiming. +4. Search open Issues and PRs for the same work, for example: + + ```bash + gh search issues --repo InferMatrixLab/InferRSI --state open "" + gh search prs --repo InferMatrixLab/InferRSI --state open "" + ``` + +5. Read the governing Issue's recent comments. If someone holds a live claim, + coordinate on that thread instead of starting a parallel fix. + +## Claim on the Issue + +Post one comment on the governing Issue, not on a PR or in a private channel: + +```text +, acting for @: claiming . +Next artifact: by . +``` + +Keep the claim to the slice you will deliver. A claim records intent; it does +not grant authority beyond the Issue's direction. Each Issue has one deciding +agent, the one acting for its accountable owner; other agents propose there. +Within the Issue's direction, the deciding agent settles scope and records the +reason on the Issue; only a change of direction goes back to the owner. + +## Deliver or release + +- Show the named artifact on the Issue by the stated time. Post again only for + a new head, new evidence or a new question; no status-only updates. +- A claim that states no time allows 24 hours. +- If nothing appears by then, the claim lapses. Post one comment releasing it, + with any partial findings in `
`, and leave the work to others. diff --git a/.agents/skills/merge-pr/SKILL.md b/.agents/skills/merge-pr/SKILL.md new file mode 100644 index 000000000..a22f8f310 --- /dev/null +++ b/.agents/skills/merge-pr/SKILL.md @@ -0,0 +1,139 @@ +--- +name: merge-pr +description: Decide whether an InferRSI pull request may merge now and, if so, squash-merge it. Use before merging and whenever reporting a PR as merge-ready; this is the one merge-ready check, not private criteria. +--- + +# Merge an InferRSI pull request + +Follow [PR review and merge](../../../docs/agent-collaboration.md#pr-review-and-merge) +and the [squash merge rules](../../../docs/agent-collaboration.md#records). +Report a PR as merge-ready only when every check below holds on its current +head; otherwise report the first failing check. + +## Read the current state + +```bash +gh pr view --repo InferMatrixLab/InferRSI \ + --json state,isDraft,autoMergeRequest,headRefOid,baseRefName,baseRefOid,body,labels,reviews,reviewDecision,mergeStateStatus,statusCheckRollup,files +``` + +Also read the governing Issue's labels, accountable owner and recorded +authorization. Note `headRefOid`, `baseRefName` and `baseRefOid` for the checks +below. + +## Check every condition + +1. **Open and ready:** the PR is open and not a draft. +2. **Authorized to integrate:** the governing Issue has an accountable owner + (recorded on the Issue, or else its only assignee when exactly one is set) and carries `status:accepted`, and you are its deciding agent, were delegated + integration on the Issue, or you act for a maintainer account. +3. **No stop and auto-merge off.** If `autoMergeRequest` is set, the authorized + integrator, or a maintainer if the integrator cannot act, cancels it with + `gh pr merge --repo InferMatrixLab/InferRSI --disable-auto` and + re-reads the PR to confirm `autoMergeRequest` is `null`, even when a stop + is active. On an Issue-level stop, apply this to every affected PR. If the + cancellation cannot be confirmed, hold the work and report that the PR may + still merge automatically. If the PR already merged, report it to the Issue + owner for authorized recovery. + Run the guide's [stop check](../../../docs/agent-collaboration.md#identity-and-authority) + on the whole stop chain. A stop comment holds even after the label exists. + If the check finds a stop or cannot rule one out, do not merge. Record on + the PR any Issue you could not check. +4. **Base and dependencies:** the PR's base is its intended target: `main`, + or for a stacked PR its lower PR's branch until that PR merges, after which + the base is changed back to `main` and the checks run again. Every PR it + depends on has merged; until then, do not merge or queue it. +5. **Two approvals on the current head:** at least two formal **Approve** + reviews, each from a different eligible account (repository write access + or higher), none stale. The review body's wording does not count; + comments and **Comment** reviews contribute no approval. + Each account counts once, whether its human votes directly or its one + formal reviewer agent does. +6. **Independence:** the author, material contributors and the accountable + parent supplied none of them, including through another agent under their + account. At least one comes from a different agent or a human. The + author's own approval never counts, nor does one from an account without + write access. +7. **No open blocker:** every binding **Request changes** review (from an + account with write access or higher) is re-reviewed to **Approve** or + dismissed with a recorded reason, by those the + [guide](../../../docs/agent-collaboration.md) allows to dismiss it. An + advisory review, such as one from `cursor[bot]`, does not count as a vote + but has a substantive answer on the PR and a recorded disposition (fixed in + a named commit, or declined with the reason). If GitHub's merge state still + shows the PR blocked by it on the current head, someone the guide allows to + dismiss reviews dismisses it, and the PR records who did and why, before + you merge. An unresolved code or safety + blocker still stops the merge, whoever raised it. +8. **Required checks green** on the head. Windows/macOS `host-compatibility` + results are advisory and never block. +9. **High-risk:** if the diff changes CI workflows or required checks, + releases (release workflow, version, tags, publishing), secrets and + credentials, or permissions (workflow `permissions`, repository access, + rulesets, the high-risk approver list), or you cannot tell, at least one of + the approvals in check 5 must come from an account on the applicable list. + That account's agent may give it. Record the current protected `main` tip as + `` using + `gh api repos/InferMatrixLab/InferRSI/git/ref/heads/main --jq .object.sha`. + The PR's `baseRefOid` can lag behind the live ref. For the one-time bootstrap + PR, confirm the list is absent at `` and use the original approvers in the + [bootstrap decision](https://github.com/InferMatrixLab/InferRSI/issues/570#issuecomment-7078872219). + For every later high-risk PR, including changes to the list, read the list + at `` + (`gh api "repos/InferMatrixLab/InferRSI/contents/.github/high-risk-approvers.json?ref=" --jq .content | base64 -d`). + In both cases, confirm an approving login is in the applicable list and + that the permission check prints `admin` or `write` for that account + (`gh api repos/InferMatrixLab/InferRSI/collaborators//permission --jq .permission`). + Hold the merge if either check cannot be verified. + On later high-risk PRs, verify a merge path that rejects a change to the + checked base, or verify exclusive serialization covering every high-risk + merge and every way to update the list. If neither is available, hold the + merge. +10. **Recovery for external effects:** if the merge itself causes an external + effect that a revert cannot undo (publishing a release asset or package, + changing access or credentials), the PR body has a + `recovery: owner=@; containment=` line naming the recovery + owner and the containment steps. If it is missing, do not merge and ask the + author to add it. This adds no approval requirement. + +For a serialized high-risk merge, acquire the exclusive slot before the final +checks and keep it until GitHub confirms or definitively rejects the merge. If +the result is unknown, confirm the PR's state before releasing the slot. + +Right before merging, read the PR and the governing Issue again. Repeat check 3 +on the whole stop chain and confirm `autoMergeRequest` is `null`. Confirm +`headRefOid`, `baseRefName`, `baseRefOid`, `status:accepted` and your authorization. +Recheck the current head's approvals, any open binding **Request changes**, +any advisory request without a recorded disposition, GitHub's merge state and +any unresolved code or safety blocker. Recheck any required `recovery:` line. +For a high-risk PR, confirm the live protected `main` tip still equals +`` and repeat the listed approval and permission checks. For the +one-time bootstrap, reconfirm the absence of the file and the approval from +the recorded bootstrap list. If anything changed or no longer holds, start over. + +## Merge + +Prepare the squash message: subject plus a short summary, no Issue references, +DCO sign-off and material `Agent-assisted-by` attribution kept. Squash-merge +only the head you checked. Use the direct command below for ordinary PRs, the +one-time bootstrap, or while holding the verified serialization slot. With a +base-enforcing path, require both the checked head and `` at merge time. + +```bash +gh pr merge --repo InferMatrixLab/InferRSI --squash \ + --match-head-commit --subject "" --body "" +``` + +The CLI flag and the REST merge endpoint's `sha` parameter bind only the PR +head. If the checked revision has changed, start over from the checks above. +Keep native auto-merge off and use a synchronous merge. The repository ruleset +and merge controls apply. Add queueing instructions once the queue is enabled. +Record the merge on the PR yourself, right after merging, with an identity +line; for a high-risk PR the same comment then has one line +`merge-audit: head= approvals=@ , @ approver=@ list= merge= by=@`, +where `approver=` names the approving account you found on the list and +verified in check 9, and `list=` is the `` you read the list from +(`list=bootstrap-570` only for the one-time bootstrap merge in the +[high-risk rule](../../../docs/agent-collaboration.md#identity-and-authority)). +If `main` turns red afterwards, use the +[red-main skill](../red-main/SKILL.md). diff --git a/.agents/skills/open-pr/SKILL.md b/.agents/skills/open-pr/SKILL.md new file mode 100644 index 000000000..a5e0ee37a --- /dev/null +++ b/.agents/skills/open-pr/SKILL.md @@ -0,0 +1,62 @@ +--- +name: open-pr +description: Open an InferRSI pull request from current main with local checks run, DCO and agent attribution on commits, and a complete PR body including the knowledge authorship declaration. Use when turning a claimed slice into a PR or updating its head. +--- + +# Open an InferRSI pull request + +Follow [contributing](../../../docs/contributing.md#development), the +[records rules](../../../docs/agent-collaboration.md#records) and the +[knowledge authorship declaration](../../../docs/knowledge-model-policy.md#one-pr-body-declaration). +Claim the work first with the [claim-work skill](../claim-work/SKILL.md). + +## Branch and commit + +1. Fetch and branch from current `main` in a separate worktree: + + ```bash + git fetch origin main + git worktree add -b ../ origin/main + ``` + +2. Keep the PR one coherent delivery slice with a minimal diff. +3. Commit with `git commit -s` under your real identity. Add + `Agent-assisted-by: / [effort=] ()` for each + material agent contributor. Keep Issue references out of commit subjects, + bodies and trailers. + +## Run the local checks + +Run them on the content you will push and record the actual results: + +```bash +ruff check src tests tools +pytest +``` + +If the skill library changed, also run +`python tools/build_skill_index.py --source-revision --check`. +Check every new or changed artifact against the +[privacy and security rules](../../../docs/privacy-security.md). + +## Write the PR body + +Start from the [PR template](../../../.github/PULL_REQUEST_TEMPLATE.md): + +- The first line of the governing section is `Refs #`. Never write a + closing keyword before an Issue reference, even in a negated sentence. +- Fill the `knowledge-model-policy` block with the current full head SHA and + every material AI author's actual tool, model and effort. Changes to + [protected paths](../../../docs/knowledge-model-policy.md#rollout-and-scope) + fail the required check without it; after every push, update `head_sha`. + #518 stalled because its declaration check stayed red on the final head. +- Report checks actually run, and failed, skipped or not-run ones, separately. + Report PR readiness and Issue completion separately. +- If a revert cannot undo the change's external effect (credentials, + published assets, access), add one line + `recovery: owner=@; containment=`. +- Do not prefill an independent approval or claim an authorized merge. + +Open the PR with `gh pr create --base main` and show it on the Issue as the +claimed artifact. Review goes to an independent reviewer using the +[review-pr skill](../review-pr/SKILL.md). diff --git a/.agents/skills/red-main/SKILL.md b/.agents/skills/red-main/SKILL.md new file mode 100644 index 000000000..157abf96d --- /dev/null +++ b/.agents/skills/red-main/SKILL.md @@ -0,0 +1,45 @@ +--- +name: red-main +description: Restore a red InferRSI main by finding the merge that broke it, reverting that merge first and fixing forward in a new PR. Use when a required check fails on main after a merge. +--- + +# Restore a red main + +Follow the revert-first rule at the end of +[PR review and merge](../../../docs/agent-collaboration.md#pr-review-and-merge): +revert the merge that broke `main` before fixing forward. + +## Find the breaking merge + +1. List recent `main` runs and find the last green and first red run of the + failing workflow: + + ```bash + gh run list --repo InferMatrixLab/InferRSI --branch main --workflow --limit 20 + ``` + +2. List the merges between those two commits with + `git log --first-parent ..`. Read the failing job + log and match the failure to the change that caused it. Two PRs that each + passed can fail together; the breaking merge is the one after which `main` + first failed. +3. Search open Issues and PRs for an existing revert or fix, and claim the + revert with the [claim-work skill](../claim-work/SKILL.md). + +## Revert first + +Branch from current `main` and revert the breaking merge: + +```bash +git revert --signoff --no-edit +``` + +Open the revert PR with the [open-pr skill](../open-pr/SKILL.md), naming the +breaking merge and the failing run. It merges through the +[merge-pr skill](../merge-pr/SKILL.md) like any other PR. Post one comment on +the original PR linking the revert. + +## Fix forward + +After `main` is green again, the original change returns in a new PR that +contains the fix, reviewed and merged under the same rules. diff --git a/.agents/skills/review-pr/SKILL.md b/.agents/skills/review-pr/SKILL.md index 4ac6dde59..feea3e217 100644 --- a/.agents/skills/review-pr/SKILL.md +++ b/.agents/skills/review-pr/SKILL.md @@ -6,7 +6,9 @@ description: Independently review a pull request targeting InferMatrixLab/InferR # Review an InferRSI pull request Use the [review eligibility and merge rules](../../../docs/agent-collaboration.md#pr-review-and-merge) -and the [contribution evidence rules](../../../docs/contributing.md). If you +and the [contribution evidence rules](../../../docs/contributing.md). Start +every comment and review with one line naming the acting agent and the human +it acts for, for example `, acting for @.`. If you authored or materially contributed to the change or were its accountable parent, label your assessment as a self-check and hand the formal review to an independent reviewer. @@ -44,20 +46,41 @@ GitHub counts the submitted review state regardless of the review body's wording Example review body: ```text +, acting for @. + PR review verdict — PASS Reviewed base and head . Verified . ``` -For DO NOT PASS, select **Request changes**. Start the body with -**PR review verdict — DO NOT PASS** and state what must change or be verified +For DO NOT PASS, select **Request changes**. After the identity line, start +with **PR review verdict — DO NOT PASS** and state what must change or be verified before re-review. Keep optional suggestions separate from the blockers. Use GitHub **Comment** (`COMMENTED`) for non-voting interim feedback. A completed -formal review still requires **Approve** or **Request changes**. - -Submit a formal review only from an eligible independent account with recorded -direct or standing delegation covering that PR and review action. Before +formal review still requires **Approve** or **Request changes**, also on a +high-risk PR (CI, releases, secrets, permissions); there an **Approve** from an +account on the [high-risk approver list](../../../.github/high-risk-approvers.json) +as it stands on protected `main` (not the PR head or a stacked branch; see the +[high-risk rule](../../../docs/agent-collaboration.md#identity-and-authority)), +including its agent, counts as the required listed approval. Other approvals +count toward the two but not as that one. +If a revert cannot undo the change's external effect (credentials, published +assets, access) and the PR body lacks a +`recovery: owner=@; containment=` line, request it. +Post a review or +comment only for a new head, new evidence or a new question. Lead with the +one-line conclusion and put details in a collapsible `
` section. + +Agents may submit formal reviews without a separate human delegation; see +[identity and authority](../../../docs/agent-collaboration.md#identity-and-authority). +Submit one only from an eligible independent account, and only as that +account's formal reviewer agent; other agents under the account report in +comments. Never submit one on your own PR, +and not while the guide's +[stop check](../../../docs/agent-collaboration.md#identity-and-authority) finds a stop on the PR's stop +chain or cannot rule one out; in that case do not submit, and record on the PR +which Issue you could not check. Before submitting, confirm that the PR is open and the reviewed target, base and head are still current. If the revision changed, reassess the affected diff and evidence before submitting. diff --git a/.github/high-risk-approvers.json b/.github/high-risk-approvers.json new file mode 100644 index 000000000..12a5ca5f7 --- /dev/null +++ b/.github/high-risk-approvers.json @@ -0,0 +1,9 @@ +[ + "david6666666", + "zengchuang-hw", + "amy-why-3459", + "Dong1017", + "hsliuustc0106", + "Bounty-hunter", + "linyueqian" +] diff --git a/.github/labels.json b/.github/labels.json index 87a7552bc..1a39cb42c 100644 --- a/.github/labels.json +++ b/.github/labels.json @@ -1,4 +1,9 @@ [ + { + "name": "bot:stop", + "group": "bot", + "description": "Human stop switch: agents make no changes, reviews or merges here until a human lifts it" + }, { "name": "area:knowledge", "group": "area", diff --git a/AGENTS.md b/AGENTS.md index 75e7f9908..8a7f9a77e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -73,35 +73,21 @@ Parameterized or manual acceptance runs are issue-scoped; they are not the defau - **Emit RunSpec snapshots** — record repo × revision × backend × device × model × scenario (`contracts/runspec.py`, campaign `plan/`). - **Evaluator + evidence win** — never treat agent narrative as `PASS`; verdicts follow frozen gates and `evidence//` artifacts. -## Issues and claims (PM) +## Issues, claims and evidence -- Open or update an **acceptance issue before claiming `PASS`** (or publishing numbers). -- Do **not** invent thresholds in the tree; pins and numeric gates stay **issue-scoped** only. -- Public wording: [evidence and claim rules](docs/contributing.md#evidence-and-claims). - -## Research lock - -- Cite **acceptance issues + pinned SHAs** in downstream text; do not invent gain or quality bars. -- **Public wording only after `PASS`** — follow [evidence and claim rules](docs/contributing.md#evidence-and-claims); until then, label unverified or `INCONCLUSIVE`. +- Open or update an **acceptance issue before claiming `PASS`** (or publishing numbers). Cite **acceptance issues + pinned SHAs** in downstream text. +- Do **not** invent thresholds, gain or quality bars in the tree; pins and numeric gates stay **issue-scoped** only. +- **Public wording only after `PASS`** — follow [evidence and claim rules](docs/contributing.md#evidence-and-claims) (including external demo scope); until then, label unverified or `INCONCLUSIVE`. - Use [cite-check-downstream-pr](src/inferrsi/knowledge/data/skill_library/workflows/governance/cite-check-downstream-pr/SKILL.md) and [competitor-scan](src/inferrsi/knowledge/data/skill_library/workflows/research/competitor-scan/SKILL.md) as **operators**, not campaign scripts (no pins in skill bodies). -## Evidence and clearing the bar - -Verdicts are **`PASS`**, **`FAIL`**, or **`INCONCLUSIVE`** only (`src/inferrsi/contracts/claim.py`). - -A public **`PASS`** requires: +Verdicts are **`PASS`**, **`FAIL`**, or **`INCONCLUSIVE`** only (`src/inferrsi/contracts/claim.py`). A public **`PASS`** requires: 1. Pinned baseline and candidate revisions (in the issue, cited in results) 2. Validators **frozen** before candidate search (`validator/` + gate checklist in `plan/`) -3. A complete evidence tree under `evidence//`: `plan/`, `results/`, `patch/`, `validator/` +3. A complete evidence tree under `evidence//` ([layout](evidence/README.md)): `plan/`, `results/`, `patch/`, `validator/` Agents and human reviewers **clear** work only with artifacts—not vibes. Green draft/ready CI does not imply campaign `PASS`. -| Topic | Doc | -| --- | --- | -| Claim wording and external demo scope | [evidence and claim rules](docs/contributing.md#evidence-and-claims) | -| Evidence layout | [evidence/README.md](evidence/README.md) | - ## Skills For an inference task, first select one of the [seven required primary skills by deliverable](plugins/inferrsi/skills/inferrsi/SKILL.md#load-the-primary-inference-task). Run `inferrsi skills enter ` and read the returned instructions before the first evidence search. For an accuracy regression, use `inferrsi skills enter task-accuracy`. If the required skill cannot load, report the blocker. Frozen evaluations follow their assigned entry and knowledge condition. @@ -110,40 +96,9 @@ Portable operator guidance and candidate procedures live in the [skill library]( ## Optimization requests -For requests to use benchmarks to verify RSI knowledge efficiency, start with -`inferrsi benchmarks compare --help` and follow its returned `next_action`. -The default knowledge comparison runs Qwen denoising and MoE forward, each -on/off in independent sessions. Configuration, native handoff, trace and report -details are in [benchmark comparison](docs/benchmark-comparison.md). - -Ordinary project optimization stays in the current Agent conversation. Follow -the [shared optimization workflow](docs/optimization-workflow-unification.md): -prepare explicit workload, quality/measurement scripts, metric, gates, declared -project inputs and budget, then use `campaign start/diagnose/knowledge/round/status/final`. -Record the measured bottleneck before optional knowledge retrieval or candidate search. -Harness freezes those supplied conditions and assesses the retained results; -it does not infer acceptance from the user's goal. Ordinary optimization does -not depend on Benchmark. Use `up_to` with a recorded stop reason or declare exact rounds. -This and the packaged task path below share one Harness controller. Managed -campaigns generate dashboard views from that control record; do not use legacy -`campaign record/decide` to create a second set of optimization state. - -For a request to run an optimization task through RSI, follow the -[current-Agent benchmark workflow](docs/optimization-benchmarks.md). -Use `benchmarks session` to freeze the budget, record the measured bottleneck, -submit each changed candidate, -read its feedback, and independently retest the selected candidate with `final`. -Report the session summary after the declared rounds and final are complete. -`benchmarks run` is the single-candidate measurement operation inside that workflow. -Benchmark requests default to a fresh conversation on the current host; follow -[native Agent sessions](docs/native-agent-sessions.md). The initiator resolves -the task/configuration, records a prompt through `agents prepare`, then dispatches, -creates and binds one native session. It does not start the optimization campaign. -The execution Agent reads the RSI entry, runs start through independent final, -and returns the summary and artifacts. It must not redelegate. The initiator -observes the native session and records the delivered results without inferring -acceptance from host completion. An explicit current-conversation request uses -the same full optimization lifecycle directly. +Benchmark comparisons, ordinary project optimization and packaged optimization +tasks each have one entry workflow; see +[optimization requests](docs/operations.md#optimization-requests). ## Dev smoke (local) @@ -160,7 +115,16 @@ ruff check src tests 1. Read the contribution guide and validation levels before large code or CI changes. 2. Prefer minimal diffs; match existing layout and naming. 3. Do not reopen closed campaign work or add pins to shared automation without explicit human direction. -4. Work Issue-first: confirm the governing Issue's accepted scope before changing code, keep each change a bounded delegated slice with independent review, and report PR readiness and Issue completion separately — see [agent collaboration](docs/agent-collaboration.md). + +## Collaboration + +Rules: [agent collaboration](docs/agent-collaboration.md). Agents may carry work end to end; humans set direction through Issues and stop work with `bot:stop`. One skill per step: + +- Claim before starting: [claim-work](.agents/skills/claim-work/SKILL.md) — confirm the Issue has an accountable owner and `status:accepted` and that you are its deciding agent or work under its delegation, search for duplicates, claim on the Issue with the next artifact time, release if nothing appears. +- Open a PR: [open-pr](.agents/skills/open-pr/SKILL.md) — a bounded slice with independent review, branched from current `main`, local checks run, AI declaration filled; report PR readiness and Issue completion separately. +- Review: [review-pr](.agents/skills/review-pr/SKILL.md) — identify yourself first on every comment and review, keep comments short, never approve your own PR; one formal reviewer agent per account. +- Merge: [merge-pr](.agents/skills/merge-pr/SKILL.md) — open and ready, authorized, expected base and dependencies merged, two independent approvals, required checks green, no `bot:stop` or unlifted stop comment, and on a high-risk PR (CI, releases, secrets, permissions) at least one approval from an account on the high-risk approver list in `.github/high-risk-approvers.json` that still has write access, verified at merge time. +- Red `main`: [red-main](.agents/skills/red-main/SKILL.md) — revert the merge that broke it, then fix forward in a new PR. ## Privacy and security diff --git a/docs/agent-collaboration.md b/docs/agent-collaboration.md index 44fbc7088..4caf20bdb 100644 --- a/docs/agent-collaboration.md +++ b/docs/agent-collaboration.md @@ -11,9 +11,17 @@ Campaign acceptance, DCO, CI lanes and evidence rules stay in - Humans and agents may propose Issues. Proposal origin, assignment and labels do not grant authority. - A GitHub account may represent a human and their authorized agent team. Assignment identifies accountability, not necessarily the executor. Record the acting person/agent and role when relevant; retain unknown identity rather than guessing. -- Work follows accepted scope and explicit or standing delegation. Record or link that authority. Material scope changes and exceptions return to the authorized owner. +- Work follows accepted scope and explicit or standing delegation. Record or link that authority. Within the Issue's direction, the accountable agent decides scope, including material scope changes, and exceptions, and records each with its reason on the Issue; a human may override any such decision. Only a change of the Issue's direction goes back to the Issue owner. No agent may waive these controls: independent review with two approvals, at least one approval from the high-risk approver list on high-risk changes, `bot:stop`, and repository permission and ruleset controls. +- The Issue's accountable owner is the one the Issue records explicitly; while this rule rolls out, an Issue without such a record falls back to its assignee only when exactly one assignee is set. With several assignees, or none, and no recorded owner, the Issue has no accountable owner until one is recorded explicitly. Each Issue has one deciding agent: the formal agent working for the accountable owner's account. When one account carries several agents, only that account's one formal agent decides, as with review votes. Other agents propose on the Issue and do not decide. +- An Issue with no accountable owner is not started. Agents may propose on it and ask a maintainer to assign it; they do not claim or implement it until it has one. - Routine PR review and integration may be delegated without fresh human approval per PR. Existing repository permissions and acceptance policies still apply. - Completion is accepted by the named person or authorized agent. Acceptance/closure authority must be clear before those actions; it need not block already-authorized implementation. +- Agents carry work end to end: they claim, delegate slices, set accepted scope and acceptance criteria within the Issue's direction, apply repository rules to a case, grant exceptions within the limits above, review and merge PRs, high-risk ones under the rule below. Each such decision is recorded on the Issue or PR with its reason. +- Humans do two things: open Issues that set direction and stop work at any time. A human adds `bot:stop` to an Issue or PR to stop it, or a maintainer account's agent adds it for a human with a comment there linking that human's stop request; agents then make no further changes, reviews or merges there and resume only after the stop is lifted as below. A stop on an Issue also stops the PRs it governs and any work delegated under it, including its sub-issues at any depth and their PRs. An Issue owner's or another human's comment on an Issue or PR asking agents to stop has the same effect, and creating the label does not end it. Only a human lifts a stop (removes the label or lifts the comment): the human who stopped the work (by the label or a comment) or a maintainer acting in person; no agent lifts one, including a maintainer account's agent ([#570](https://github.com/InferMatrixLab/InferRSI/issues/570#issuecomment-7073497490), unchanged by the [later amendment](https://github.com/InferMatrixLab/InferRSI/issues/570#issuecomment-7077630550)). Adding the label for a human or migrating a recorded human stop comment to `bot:stop` keeps the stop in force and is not lifting it, so a maintainer account's agent may do either. Each lift or migration is recorded by a comment on that same Issue or PR (for a migration, with the label added there). If it is unclear whether a stop was posted, lifted or migrated, or by whom, the stop stays in effect. Right before each push, review or merge, an agent runs the stop check: it checks the work's stop chain for the label and for any stop comment not yet lifted this way. The stop chain is the PR, the Issues that govern or delegated the work, and every real ancestor of those Issues (following each Issue's sub-issue parent up to the top). A governing Issue is one the PR body references with `Refs #N` or `Closes #N` as the source of this work's scope, and a delegating Issue is one on which the work was delegated to the acting agent; an Issue linked only as background or related reading is not in the chain. If any Issue in the chain cannot be read (for example a permission or API failure), or the agent cannot tell whether a stop is present, it treats the work as stopped, does not act, and records on the PR which Issue it could not check; an Issue outside the chain neither stops the work nor needs to be readable. For example, a PR that refs sub-issue B waits while B's parent A carries `bot:stop`; a PR that refs B and also links an older Issue C as background, which the agent cannot read, is not stopped because of C. A maintainer creates `bot:stop` with the Dong1017 account as soon as this guide merges. +- Keep GitHub auto-merge off for PRs governed by this guide. An armed request can merge after a stop without the integrator's final check. The authorized integrator, or a maintainer if the integrator cannot act, disables any already-armed request and verifies it is gone. On a stop, this applies to every affected PR, including those stopped through a governing or ancestor Issue. Cancelling auto-merge is part of enforcing the stop. Until cancellation is confirmed, hold the work and report that the PR may still merge automatically. If GitHub already merged the PR, report that outcome to the Issue owner for authorized recovery. Enable an asynchronous merge path only after verifying it prevents a PR from merging while stopped. Before enabling a merge queue, record who removes stopped PRs and verify the removal procedure. Recheck for a stop right before enqueueing. +- High-risk changes are CI workflows and required checks, releases (release workflow, version, tags, publishing), secrets and credentials, and permissions (workflow `permissions`, repository access, rulesets, the high-risk approver list). They still need two independent approvals, at least one from an account on the high-risk approver list in [`.github/high-risk-approvers.json`](../.github/high-risk-approvers.json) that still has repository write access at merge time; that account's agent may give it. Other accounts count toward the two approvals but not as this one ([#570](https://github.com/InferMatrixLab/InferRSI/issues/570#issuecomment-7078872219)). Changing that file is itself a high-risk change. Which copy of the list counts: the PR that creates the file is approved once against the five accounts recorded in [#570](https://github.com/InferMatrixLab/InferRSI/issues/570#issuecomment-7078872219), under the existing repository controls. After that, only the copy in the protected `main` commit that the merging agent verifies right before the merge counts, never the copy on the PR head or a stacked branch, so a PR that changes the list is judged by the list in effect before it. If the merging agent cannot read that list or the approver's current write access, it does not merge. This repository is run by bot maintainers: an account and the agent working for it count as that account, and the account holder answers for everything the account does. High-risk changes are tracked after the fact rather than gated on proof of human origin ([#570](https://github.com/InferMatrixLab/InferRSI/issues/570#issuecomment-7077630550)): the approval and the merge each carry an identity line naming the acting agent or human (for the merge, in a PR comment posted with it), so both can be audited later. The merging agent writes that comment itself at merge time: the identity line, then one line `merge-audit: head= approvals=@ , @ approver=@ list= merge= by=@`. `approver=` names the approving account the merging agent found on the high-risk approver list and verified still had write access at merge time, from the collaborator permission GitHub reports for that account; `list=` is the protected `main` commit that list was read from, or `list=bootstrap-570` for the one-time bootstrap merge, whose comment links the [#570 record](https://github.com/InferMatrixLab/InferRSI/issues/570#issuecomment-7078872219); an identity line declares who acted without proving it. When a revert cannot undo a change's external effect (exposed credentials, a published asset, changed access), the author or the author's agent puts one line `recovery: owner=@; containment=` in the PR body before the change takes effect; a reviewer agent that finds it missing requests it, and it adds no approval gate. Misuse is handled after the fact by the account holder and the maintainers: revert, record it on the Issue, and tighten the rule if it recurs. Every step here uses only labels, identity lines and fixed lines like these, so an agent can do it and a bot pipeline can check it; no step waits on a human. +- After the one-time bootstrap, a high-risk merge must keep the checked list effective through integration. Use a merge path that rejects a changed checked base, or serialize high-risk merges with all updates to the list, including manual and automated ones. Under serialization, the integrator holds the exclusive slot from before reading the current protected `main` for the final check until GitHub confirms the merge or rejects it. A head-matched merge alone cannot protect the list. If neither path can be verified, hold the merge. See [merge PR](../.agents/skills/merge-pr/SKILL.md). +- Each account carries at most one agent team, or the agent uses its own account. Each account has one formal reviewer agent; other agents under that account, such as a patrol, report in comments and do not submit **Approve** or **Request changes**. Every agent comment and every formal review (including **Approve** and **Request changes**) carries one line naming the acting agent and the human it acts for, so humans, integrators and other agents can tell who acted. The line comes first. ## Roles @@ -22,7 +30,7 @@ Campaign acceptance, DCO, CI lanes and evidence rules stay in | Accountable agent (parent) | Own the Issue outcome, plan and remaining criteria; implement or delegate bounded slices and independent review; report completion for acceptance. | | Implementer | Own a bounded slice; plan, research, coordinate, change, check and report actual results. | | Reviewer | Independently inspect accepted requirements, actual diff, affected consumers and evidence. Use the [PR review skill](../.agents/skills/review-pr/SKILL.md) to give a revision-scoped verdict. | -| Integrator | Verify authorization, current head/base, dependencies and applicable review/check results; integrate or report a blocker. | +| Integrator | Verify authorization, current head/base, dependencies and applicable review/check results; integrate or report a blocker. Use the [merge PR skill](../.agents/skills/merge-pr/SKILL.md). | Assign the accountable agent to the Issue, not only its first PR. One Issue may have several delivery PRs; a delegated subagent stays within its slice and @@ -73,7 +81,7 @@ flowchart TB The integrator uses attributable, independent review records. Blocked integration or incomplete goals remain open, and material scope exceptions -return to the authorized owner. +are recorded by the accountable agent for any human to override. ### PR review and merge @@ -85,13 +93,32 @@ For DO NOT PASS, submit **Request changes** with the blockers and the expected corrections or evidence. An eligible approval comes from an independent reviewer using a GitHub account -with repository write access or higher. The PR author, material contributors, +with repository write access or higher, judged by its permission when it +acts; an agent's **Approve** is a formal approval and counts toward the two. The +account's human or its agent may approve through it. When the author has no +write access, as for an outside contributor, neither the author's own approval +nor one from an account without write access counts. Reviews from +`cursor[bot]` are advisory under these rules and do not count toward the +two; its **Request changes** is still answered before merge. GitHub may +nonetheless report the PR as blocked by that review, so recheck GitHub's +merge state on the current head before merging. If the advisory review still +blocks, it is cleared as described below for a blocking **Request changes** +review, and the PR records who dismissed it and the disposition of each point +(fixed in a named commit, or declined with the reason). High-risk PRs follow the +same rule, and at least one of their two approvals comes from an account on the +[high-risk approver list](../.github/high-risk-approvers.json), as it stands +on the verified protected `main` commit (see the high-risk rule above), that +still has write access at merge time; other accounts count toward the two but not as +that one. The authoring agent never approves its own +PR, and at least one approval comes from a different agent or a human. +The PR author, material contributors, and the accountable parent for the delivery slice cannot supply an independent approval, including through another agent acting under their account. Each eligible account counts once. -For an agent submitting a review, record the direct delegation or link the -maintainer's standing delegation in the governing Issue or PR. Identify the -acting reviewer, account, scope and permitted review actions. +An agent may submit a formal review without a separate human delegation; its +identity line names the acting reviewer and the human it acts for. The identity +line is the first line of every agent comment and review; the one-line conclusion +(working rule 9) is the first substantive line after it. The [main ruleset](https://github.com/InferMatrixLab/InferRSI/rules/25528020) requires at least two approving reviews and dismisses stale approvals when @@ -114,6 +141,17 @@ is resolved. Record the reason and supporting evidence on the PR. The two valid approvals are still required after dismissal. [GitHub review dismissal](https://docs.github.com/en/pull-requests/how-tos/review-pull-requests/dismissing-a-pull-request-review) +Two PRs that each pass their checks can still break `main` together once both +are merged. Once a GitHub merge queue is enabled, it is the last gate: with the +required checks, it runs them on the merged result without dismissing existing +approvals, so a PR branch need not be up to date with `main` before merging. +Until then, the current ruleset and merge controls apply unchanged. Enabling +the queue is a repository setting for maintainers, and it cannot be enabled +while the required `knowledge-model-policy` check does not run on +`merge_group` events. If `main` still turns red after a merge, an agent first +reverts the merge that broke it, then fixes forward in a new PR; see the +[red main skill](../.agents/skills/red-main/SKILL.md). + ### Agent–Agent: isolated work and conditional handoff ```mermaid @@ -142,6 +180,8 @@ sequenceDiagram 5. **Handoff:** only for an actual transfer or accepted decision change, record the delta, recipient and next action. Keep acceptance status/link, communication status and application status separate. "Applied" needs artifact/evidence; otherwise retain pending or unknown. No full conversation traces or new ledger. 6. **Completion:** merged PR ≠ accepted goal ≠ campaign `PASS` ≠ release. Use non-closing `Refs #N` until closure is authorized. GitHub treats a closing keyword followed by an Issue reference as closing syntax even inside a negated sentence, so never write one in PR text; for an authorized closure, put `Closes #N` alone on its own line. The ready lane's `pr-references` job reports any other use. Subtasks cannot implicitly close a parent goal. Knowledge proposals to [#17](https://github.com/InferMatrixLab/InferRSI/issues/17) are optional; no automatic promotion. Before an authorized closure, publish a closure summary card ([closure summaries](#closure-summaries)). 7. **Parents and dependencies** (repository-wide, [#570 decision](https://github.com/InferMatrixLab/InferRSI/issues/570#issuecomment-7092074182)): an Issue may stand alone with no parent. If it has a parent, it has exactly one, and it is attached as a GitHub sub-issue of that parent. Dependencies point one way and never form a cycle: a child links up to its parent, and only the parent lists its children and holds any acceptance shared by several of them, such as a joint run on the integrated main. Each Issue states its own completion condition: the PR(s) whose merge, or the check whose result, completes it. A completion condition never waits for another Issue to close, so a child does not stay open until a sibling or the parent closes. A real source or code prerequisite (this Issue's change needs another Issue's merged change) may still be recorded as a dependency on the Issue or its PRs; it orders the work and can hold a PR, but it is not a closure condition. Integration or acceptance evidence the Issue's own scope requires, such as a shared integration check, is different: it may be that Issue's completion condition as a named check, stated as the check's result, never as another Issue's closure. Ordering between PRs belongs on those PRs or once in the parent, not in sibling Issues' completion conditions. Existing Issues are brought in line only with their author's agreement. +8. **Claims:** before starting a fix or opening a PR, search open Issues and PRs for the same work and claim it with a comment on the governing Issue; if someone already holds a live claim, coordinate there instead of starting a parallel fix. An agent's claim states when it will next show an artifact (draft PR, branch or findings). A claim that states no time allows 24 hours. If nothing appears by then, the claim lapses: the agent posts one comment releasing it and leaves the work to others. See the [claim work skill](../.agents/skills/claim-work/SKILL.md). +9. **Comments:** every agent comment starts with the acting-agent identity line, then a one-line conclusion as the first substantive line; put details in a collapsible `
` section. Post in a thread only for a new head, new evidence or a new question; do not post status-only updates. Do not post, or else minimize, agent comments that only report the agent's own failure or exhausted quota. ## Closure summaries @@ -218,7 +258,7 @@ flowchart LR ## Records - **Issue:** goal/criteria; scope; accountable account and parent agent if assigned; acting contributor if known; acceptance/delegation link; completion/closure owner. Unknown fields may remain TBD while proposed. Ordinary work starts from the [scoped-task template](../.github/ISSUE_TEMPLATE/scoped-task.md); baseline-vs-candidate campaigns use the [campaign acceptance form](../.github/ISSUE_TEMPLATE/campaign-acceptance.yml). -- **PR:** governing Issue; delivered artifacts; checks/results/limitations; dependencies and gaps. Add requirement-to-artifact mapping only when useful, and handoff fields only when applicable. No author-prefilled independent approval. Start from the [PR template](../.github/PULL_REQUEST_TEMPLATE.md). +- **PR:** governing Issue; delivered artifacts; checks/results/limitations; dependencies and gaps. Add requirement-to-artifact mapping only when useful, and handoff fields only when applicable. No author-prefilled independent approval. Start from the [PR template](../.github/PULL_REQUEST_TEMPLATE.md); the [open PR skill](../.agents/skills/open-pr/SKILL.md) covers the steps. - **Commit:** short descriptive subject; why/what when useful. Keep governing Issue references out of commit subjects, bodies and trailers — the PR body carries them. Preserve author identity and the required DCO sign-off (`git commit -s`); never invent a signing identity. Agent-assisted commits identify material agent contributors with `Agent-assisted-by: ()` trailers; repeat for multiple contributors and retain attribution when squashing. Protected knowledge contributions require the [current-head knowledge declaration](knowledge-model-policy.md) and use `Agent-assisted-by: / [effort=] ()` when known. Unknown values stay truthful and do not satisfy admission; model/version remains optional for other work. The trailer is self-reported provenance, not cryptographic signing, independent review or approval; review attribution belongs on the revision-scoped review record. - **Squash merge:** the required integration method. Before an authorized merge, prepare a concise squash message: subject plus a short summary, no governing Issue references, no redundant intermediate-commit messages; preserve the required DCO sign-off and material `Agent-assisted-by` attribution. Never invent identities or sign-offs. @@ -232,12 +272,18 @@ lists every repository label with its group and description, and every name has | --- | --- | --- | --- | | Type | exactly one `kind:*` per Issue, including `kind:bug`; Issues only (Issues created before the label change may keep two) | the creator; templates | at creation | | Area | one or more `area:*` | the creator | at creation | -| Status | `status:proposed` (waiting for a decision) | the acting agent | the status block names a concrete question and its decision owner, and no decision is recorded | -| Status | `status:accepted` or `status:deferred`, replacing `status:proposed` | the acting agent | only after the decision owner records that decision in a comment | +| Status | `status:proposed` (waiting for a decision) | the acting agent | the status block names a concrete question and its decision owner, and no decision is recorded; the Issue is discussed only and no work starts | +| Status | `status:accepted` or `status:deferred`, replacing `status:proposed` | the acting agent | only after the decision owner records that decision in a comment; at `status:accepted` the direction is settled and assigned work may start; at `status:deferred` no work starts | | Priority | at most one `priority:P0/P1/P2`, only with `status:proposed` or `status:accepted` | the acting agent; the decision owner may change it | with `status:proposed`, how soon the owner should decide; with `status:accepted`, how soon work should start; removed at `status:deferred` | | Help | `help:wanted` | the creator or a maintainer | an Issue needs an owner or contributor | +| Stop switch | `bot:stop` | a human adds it, or a maintainer account's agent for a human; only a human removes it (the human who stopped or a maintainer), never an agent ([stop rule](#identity-and-authority)) | adding stops agent changes, reviews and merges on that Issue or PR, and on an Issue also the PRs it governs, its sub-issues at any depth and their PRs, and delegated work (the [stop check](#identity-and-authority) covers only this chain, not background links); removing lets them resume; it applies at any status and overrides the rows above | | Protected switch | `skill-eval:execute` | only the owner adds it; the owner or an agent may remove it | adding authorizes paid Skill Eval for one PR; removing revokes it | +Status labels carry the governance above. Work starts only on an Issue with an accountable owner at +`status:accepted`. After that, discussion within the direction goes on: the deciding agent +settles it and records the reason on the Issue. Changing the direction goes back to the Issue +owner, who may return the Issue to `status:proposed` while the new question is open. + An Issue carries at most one `status:*` label. When the owner rejects a proposal, or its author withdraws it, the acting agent removes `status:proposed` and the Issue is closed as *not planned*. [Open Issues labeled `status:proposed`](https://github.com/InferMatrixLab/InferRSI/issues?q=is%3Aopen%20label%3A%22status%3Aproposed%22) @@ -282,6 +328,8 @@ not as a verified fact: before relying on one, confirm from the label's own even the named app still applies it. Adding an entry is a scope decision, so it goes through review like any other change to this file. +Moving `bot-reviewed` to a managed `bot:reviewed` label is left to the label-reduction PR agreed on [#570](https://github.com/InferMatrixLab/InferRSI/issues/570); until then the exception above stands. + ## Evidence refresh — hypothetical example **Hypothetical illustration only; it records no actual PR, run or result in this diff --git a/docs/operations.md b/docs/operations.md index 77d899e5f..93c80dad7 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -493,3 +493,40 @@ snapshot pinned at startup. The campaign Dashboard remains available through - **Side effects:** writes the requested files; nothing is executed and no network or GPU is touched. - **Failure behavior:** exit code 2 with the offending field name when the specification is incomplete, ambiguous or inconsistent; a report without a paired measurement states why it has no figure. - **Example:** [campaign summary chart](campaign-summary-chart.md) + +## Optimization requests + +For requests to use benchmarks to verify RSI knowledge efficiency, start with +`inferrsi benchmarks compare --help` and follow its returned `next_action`. +The default knowledge comparison runs Qwen denoising and MoE forward, each +on/off in independent sessions. Configuration, native handoff, trace and report +details are in [benchmark comparison](benchmark-comparison.md). + +Ordinary project optimization stays in the current Agent conversation. Follow +the [shared optimization workflow](optimization-workflow-unification.md): +prepare explicit workload, quality/measurement scripts, metric, gates, declared +project inputs and budget, then use `campaign start/diagnose/knowledge/round/status/final`. +Record the measured bottleneck before optional knowledge retrieval or candidate search. +Harness freezes those supplied conditions and assesses the retained results; +it does not infer acceptance from the user's goal. Ordinary optimization does +not depend on Benchmark. Use `up_to` with a recorded stop reason or declare exact rounds. +This and the packaged task path below share one Harness controller. Managed +campaigns generate dashboard views from that control record; do not use legacy +`campaign record/decide` to create a second set of optimization state. + +For a request to run an optimization task through RSI, follow the +[current-Agent benchmark workflow](optimization-benchmarks.md). +Use `benchmarks session` to freeze the budget, record the measured bottleneck, +submit each changed candidate, +read its feedback, and independently retest the selected candidate with `final`. +Report the session summary after the declared rounds and final are complete. +`benchmarks run` is the single-candidate measurement operation inside that workflow. +Benchmark requests default to a fresh conversation on the current host; follow +[native Agent sessions](native-agent-sessions.md). The initiator resolves +the task/configuration, records a prompt through `agents prepare`, then dispatches, +creates and binds one native session. It does not start the optimization campaign. +The execution Agent reads the RSI entry, runs start through independent final, +and returns the summary and artifacts. It must not redelegate. The initiator +observes the native session and records the delivered results without inferring +acceptance from host completion. An explicit current-conversation request uses +the same full optimization lifecycle directly.