From 5de8992039c2ed0334ea29b1ca047bcb89984037 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 20 Nov 2026 17:28:36 +0100 Subject: [PATCH] upstreaming: keep repairs automated until feedback and CI pass --- .github/workflows/upstreaming-worker.lock.yml | 2 +- .github/workflows/upstreaming-worker.md | 12 ++++++-- SESSIONLOG.md | 1 + upstreaming/INTEGRATION.md | 12 +++++++- upstreaming/ci_evidence.py | 10 +++++++ upstreaming/controller.py | 8 +++-- upstreaming/fork_publish.py | 4 +++ upstreaming/observe_ci.py | 30 +++++++++++++++++-- upstreaming/reconcile.py | 13 ++++++++ upstreaming/schemas/contribution.schema.json | 4 +++ upstreaming/tests/test_fork_publish.py | 6 ++++ upstreaming/tests/test_observation.py | 18 +++++++++++ 12 files changed, 110 insertions(+), 10 deletions(-) diff --git a/.github/workflows/upstreaming-worker.lock.yml b/.github/workflows/upstreaming-worker.lock.yml index e4639ced5531..fb01aec33d8a 100644 --- a/.github/workflows/upstreaming-worker.lock.yml +++ b/.github/workflows/upstreaming-worker.lock.yml @@ -1,4 +1,4 @@ -# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"30088af59ad86726a3c2b0b6b6076ec9463412481ddfd3a12da5d807b699c00a","body_hash":"a596ec61804e5f4064cc6dbce77502e1be93463bbf946a9b026b2dc086e4b401","compiler_version":"v1.2.2","strict":true,"agent_id":"pi","agent_model":"anthropic/claude-opus-5-5","engine_versions":{"pi":"1.5.0"}} +# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"30088af59ad86726a3c2b0b6b6076ec9463412481ddfd3a12da5d807b699c00a","body_hash":"5a293def0a4990963f181b3d7cba63e4febd7820f11490501c24a8ffc0a6184e","compiler_version":"v1.2.2","strict":true,"agent_id":"pi","agent_model":"anthropic/claude-opus-5-5","engine_versions":{"pi":"1.5.0"}} # gh-aw-manifest: {"version":1,"secrets":["ANTHROPIC_API_KEY","COPILOT_GITHUB_TOKEN","GH_AW_DEFAULT_OTLP_ENDPOINT","GH_AW_DEFAULT_OTLP_HEADERS","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN","RISEPROJECT_APP_PRIVATE_KEY","RISEPROJECT_UPSTREAMING_APP_PRIVATE_KEY"],"actions":[{"repo":"actions/checkout","sha":"3d3c42e5aac5ba805825da76410c181273ba90b1","version":"v7.0.1"},{"repo":"actions/create-github-app-token","sha":"64ab729a6294000f5aa4a4bc0b73d1f32bc45510","version":"v3.3.0"},{"repo":"actions/download-artifact","sha":"9000827ccba6bdab643e8b6fd33ac0654aef8333","version":"v8.0.2"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-node","sha":"949feb2413d6458794dcd2491c4babbbce0c15c1","version":"v7.1.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"},{"repo":"actions/upload-artifact","sha":"cf430e030ddbb5b0abf93d22962f4752f3646cd9","version":"v7.0.2"},{"repo":"astral-sh/setup-uv","sha":"20cfd1bf945f4377ade1205e4dbc17946fc9a30d","version":"v10.0.1"},{"repo":"github/gh-aw-actions/setup","sha":"53d0749e19424a918acd82b4d140264ce48f2f14","version":"v1.2.2"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.29.11","digest":"sha256:8774a73c351395b41d2ad0af4ddb4689007c67de3cd08bd9f43bb8a0e300690e","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.29.11@sha256:8774a73c351395b41d2ad0af4ddb4689007c67de3cd08bd9f43bb8a0e300690e"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.29.11","digest":"sha256:88d2d0e315a504d93fd4fb8847fd0f6b7f4469f41a6fc6047b3dc9654c56ab2c","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.29.11@sha256:88d2d0e315a504d93fd4fb8847fd0f6b7f4469f41a6fc6047b3dc9654c56ab2c"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.29.11","digest":"sha256:861739ecf924dd2db5e5fb652db2ad82aaafd1615623297ddabc8f41a36b2847","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.29.11@sha256:861739ecf924dd2db5e5fb652db2ad82aaafd1615623297ddabc8f41a36b2847"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.5.6","digest":"sha256:342cd624e1f179d91be2de7a146fc4f387092e62e6c8a47506d7932e113d2311","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.5.6@sha256:342cd624e1f179d91be2de7a146fc4f387092e62e6c8a47506d7932e113d2311"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc","pinned_image":"ghcr.io/github/gh-aw-node@sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc"},{"image":"ghcr.io/github/github-mcp-server:v2.1.0","digest":"sha256:f6056fc10bfffcc8c81a6417a2e9ca12808647e8dd6049642a4feaadee0e0f8a","pinned_image":"ghcr.io/github/github-mcp-server:v2.1.0@sha256:f6056fc10bfffcc8c81a6417a2e9ca12808647e8dd6049642a4feaadee0e0f8a"}],"mcp_servers":[{"name":"github","tools":["get_commit","get_file_contents","get_latest_release","get_me","get_pull_request","get_pull_request_comments","get_pull_request_diff","get_pull_request_files","get_pull_request_review_comments","get_pull_request_reviews","get_pull_request_status","get_release_by_tag","get_tag","issue_read","list_branches","list_commits","list_issue_types","list_issues","list_pull_requests","list_releases","list_starred_repositories","list_tags","pull_request_read","search_code","search_issues","search_pull_requests","search_repositories"]},{"name":"github-authenticated","tools":["actions_list","get_commit","get_file_contents","get_pull_request","get_pull_request_comments","get_pull_request_diff","get_pull_request_files","get_pull_request_review_comments","get_pull_request_reviews","get_pull_request_status","issue_read","list_commits","list_issues","list_pull_requests","pull_request_read","search_code","search_issues","search_pull_requests"]},{"name":"safeoutputs","tools":["noop","report_incomplete","report_missing_data","report_missing_tool","upload_artifact"]},{"name":"work-queue","tools":["work_queue_claim_finish","work_queue_dispatch_next","work_queue_explain","work_queue_read","work_queue_submit"]}],"threat_detection":{"mode":"enabled"},"admission":false,"work_queue":{"worker":true,"logical_contract":"056b332b022951fc3d1ae91c58cb202ea509dcef2a5d2c296a6cc0a9f8abc00a"},"agent_metadata":{}} # This file was automatically generated by gh-aw (v1.2.2). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md # diff --git a/.github/workflows/upstreaming-worker.md b/.github/workflows/upstreaming-worker.md index addb15910e73..27372c9699ac 100644 --- a/.github/workflows/upstreaming-worker.md +++ b/.github/workflows/upstreaming-worker.md @@ -269,8 +269,10 @@ pipeline. The trusted pre-agent step wrote the immutable task to branch in `./fork`. The task's `plan` field says what to do; `reason_ids` and `context` say why. For repair and revision tasks, read every entry in `context.reason_evidence` before researching -or editing. Treat its concrete review feedback and rejected-change descriptions -as required repair constraints, then verify them against repository history. +or editing. Treat every concrete review comment, PR conversation comment and +rejected-change description in every reason evidence record as a required +repair constraint, then verify each one against repository history. A repair is +incomplete if even one requested change is omitted. Only process the compiler-supplied `work_queue_assignment`. It has exactly one Claim; use its `handle` as `claim_handle` on every safe output and on @@ -290,7 +292,11 @@ call: `{"path": "upstreaming-out"}` (the native handler names the artifact `append` (new commits on top of `expected_head`), `rewrite` (a series on top of `base_sha`, only if `allowed_operations` contains it) or `none`. `changed_files` lists every path your series changes relative to - `expected_head` (for `rewrite`, relative to it as well). + `expected_head` (for `rewrite`, relative to it as well). For a repair or + revision task, `reason_ids` must include every task `reason_ids` entry. In + `diagnosis`, include a checklist with one item per review or CI constraint, + the exact change that addresses it, and how you verified that change. Never + claim `no_change` while required review feedback remains unresolved. `patch_digest` is the sha256 of `patches.mbox`, or null. - `patches.mbox`: for `append`, `git -C fork format-patch --stdout `; for `rewrite`, `git -C fork format-patch --stdout `. Omit it diff --git a/SESSIONLOG.md b/SESSIONLOG.md index fe7bcd40e5ef..76a643ff4551 100644 --- a/SESSIONLOG.md +++ b/SESSIONLOG.md @@ -22,3 +22,4 @@ - Updated the workflow trigger contract to assert that contribution-state-only pushes refresh only the public website and do not wake pipeline control workflows. - Updated acceptance validation so state-only pushes may trigger exactly `website.yml`, preserving the rule that they never wake pipeline control or model workflows. - Addressed PR #4989 review feedback by moving the status-page generator into `upstreaming/`, invoking it through `uv run`, and adding focused rendering coverage. +- Fixed review and CI reconciliation so pending human feedback survives head changes, every repair carries and acknowledges all feedback evidence, `fix_needed` cannot be overwritten before dispatch, and any executed build or test failure returns handoff to automated development repair. diff --git a/upstreaming/INTEGRATION.md b/upstreaming/INTEGRATION.md index 697441a47f04..b9c675484fa3 100644 --- a/upstreaming/INTEGRATION.md +++ b/upstreaming/INTEGRATION.md @@ -177,7 +177,17 @@ represented only by an opaque ID. Controller observation polls the recorded same-fork PR for current-head reviews and inline comments from configured authority actor IDs. New feedback is persisted once as `human_relay` evidence, records processed review/comment IDs, bumps the revision and automatically -requests `development_repair`. +requests `development_repair`. Pending feedback evidence survives branch-head +changes and is attached to every repair until exact-head CI is green. A repair +proposal must acknowledge every required evidence record. Observation does not +replace `fix_needed` before the controller can allocate that repair. + +Exact-head CI is green only when every executed build or test job succeeds, in +addition to the target riscv64 job and wheel contract. Failures confined to +package publishing, upload, or release-request validation remain non-blocking in +the intentionally credentialless destination organization. A build or test +failure discovered after handoff automatically returns the contribution to +revisioned development repair. Previously merged implementation: diff --git a/upstreaming/ci_evidence.py b/upstreaming/ci_evidence.py index f80da5c7202e..35472a830a57 100644 --- a/upstreaming/ci_evidence.py +++ b/upstreaming/ci_evidence.py @@ -15,6 +15,9 @@ SUCCESS = "success" NOT_EXECUTED = frozenset({"skipped", "neutral", "cancelled", "action_required", "stale", None}) +# Disposable forks intentionally lack package publishing credentials and OIDC +# trust. Those jobs may fail naturally and do not invalidate build/test CI. +CREDENTIALLESS_JOB_MARKERS = ("publish", "upload_pypi", "upload to pypi", "validate-release-request") @dataclass @@ -59,6 +62,13 @@ def evaluate(*, runs: list[dict], jobs_by_run: dict[int, list[dict]], head_sha: return v all_jobs = [j for r in relevant for j in jobs_by_run.get(r["id"], [])] pending = [j for j in all_jobs if j.get("status") != "completed"] + blocking_failures = [ + j for j in all_jobs + if job_executed(j) and j.get("conclusion") != SUCCESS + and not any(marker in j.get("name", "").lower() for marker in CREDENTIALLESS_JOB_MARKERS) + ] + for j in blocking_failures: + v.problems.append(f"job {j['name']!r} failed ({j.get('conclusion')})") # Wheel success means the wheel was built on the native runner label: a # job only matches when its name matches and it ran on that label. for pat in required_job_patterns: diff --git a/upstreaming/controller.py b/upstreaming/controller.py index c0c924fb8fdf..32b57e747a37 100644 --- a/upstreaming/controller.py +++ b/upstreaming/controller.py @@ -369,9 +369,11 @@ def tick(*, contributions: dict[str, dict], operations: dict[str, dict], consume continue slots -= 1 reason_ids = [] - if kind in ("development_repair", "upstream_revision") and c.get("last_ci_evidence_id"): - reason_ids = [c["last_ci_evidence_id"]] - elif c.get("dossier_evidence_id"): + if kind in ("development_repair", "upstream_revision"): + reason_ids = list(dict.fromkeys( + (c.get("pending_feedback_evidence_ids") or []) + + ([c["last_ci_evidence_id"]] if c.get("last_ci_evidence_id") else []))) + if not reason_ids and c.get("dossier_evidence_id"): reason_ids = [c["dossier_evidence_id"]] work = { "type": "submit_work", diff --git a/upstreaming/fork_publish.py b/upstreaming/fork_publish.py index 82aaa59b04a5..cb960132efd6 100644 --- a/upstreaming/fork_publish.py +++ b/upstreaming/fork_publish.py @@ -125,6 +125,10 @@ def check_proposal(proposal: dict, record: dict, task: dict, *, allow_no_change: raise PublishRejected("proposal/task/record contribution mismatch") if proposal["expected_revision"] != task["revision"] or proposal["expected_head"] != task["expected_head"]: raise PublishRejected("proposal does not answer the admitted task (revision/head)") + if task.get("task") in ("development_repair", "upstream_revision"): + missing_reasons = set(task.get("reason_ids") or []) - set(proposal.get("reason_ids") or []) + if missing_reasons: + raise PublishRejected(f"repair proposal did not acknowledge required evidence: {sorted(missing_reasons)}") fork = (record.get("fork") or {}).get("name") or "" if not fork.startswith(FORK_ORG + "/") or task["fork"] != fork: raise PublishRejected("task fork is not the recorded contribution fork") diff --git a/upstreaming/observe_ci.py b/upstreaming/observe_ci.py index beac03fc91b8..383f7c1d564a 100644 --- a/upstreaming/observe_ci.py +++ b/upstreaming/observe_ci.py @@ -110,7 +110,10 @@ def observe(api: collect.Api, *, contributions: dict[str, dict], operations: dic + feedback["comment_ids"])[-512:], processed_pr_conversation_comment_ids=( (cur.get("processed_pr_conversation_comment_ids") or []) - + feedback["conversation_comment_ids"])[-512:], updated_at=now) + + feedback["conversation_comment_ids"])[-512:], + pending_feedback_evidence_ids=list(dict.fromkeys( + (cur.get("pending_feedback_evidence_ids") or []) + [eid]))[-64:], + updated_at=now) schemas.validate("contribution", cur) obs.staged.extend([("evidence", ev), ("contributions", cur), ("events", lifecycle._event(before, cur, "development_review_feedback", @@ -118,6 +121,12 @@ def observe(api: collect.Api, *, contributions: dict[str, dict], operations: dic entry["review_feedback"] = eid obs.report.append(entry) continue + # A requested repair must reach the controller before another CI poll + # can reclassify the same unchanged head as waiting for a human. + if cur["activity"] == "fix_needed": + entry["note"] = "repair remains required" + obs.report.append(entry) + continue upstream_facing = cur.get("upstream_pr") is not None repo_for_ci = cur["upstream"]["full_name"] if upstream_facing else fork snap = collect.ci_snapshot(api, repo_for_ci, head["head"]) @@ -153,10 +162,27 @@ def observe(api: collect.Api, *, contributions: dict[str, dict], operations: dic if verdict.state == "passed" and cur.get("last_ci_evidence_id") != eid: cur = dict(cur, last_ci_evidence_id=eid, updated_at=now) obs.staged.append(("contributions", cur)) + if verdict.state == "failed" and cur["phase"] == "handoff": + before = cur + moved = lifecycle.transition(cur, "development", cause_type="observation", + cause_id=eid, now=now) + status = lifecycle.observe_status(moved.record, activity="fix_needed", now=now) + cur = dict(status.record, last_ci_evidence_id=eid, + pending_human_action=None, updated_at=now) + schemas.validate("contribution", cur) + obs.staged.append(("contributions", cur)) + if moved.event: + obs.staged.append(("events", moved.event)) + if status.event: + obs.staged.append(("events", status.event)) + entry["activity"] = "fix_needed" + entry["returned_to_development"] = True + obs.report.append(entry) + continue if verdict.state == "passed" and cur["phase"] == "development" and not cur.get("debug_commits"): before = cur cur = dict(cur, phase="handoff", activity="waiting_human", active_work=None, - clean_head_sha=head["head"], + clean_head_sha=head["head"], pending_feedback_evidence_ids=[], handoff_request={"command_id": f"observation-{eid}", "head": head["head"], "revision": cur["revision"]}, pending_human_action={"kind": "approve_handoff", "requested_at": now, diff --git a/upstreaming/reconcile.py b/upstreaming/reconcile.py index 03bf89273da7..afc1a2c83e3e 100644 --- a/upstreaming/reconcile.py +++ b/upstreaming/reconcile.py @@ -478,6 +478,19 @@ def numeric(value): out.report["dispatch_recovery"] = rep out.report["dispatch_relaunch"] = relaunch + # 1d. Carry durable review constraints across head changes. Older records + # predate pending_feedback_evidence_ids, so recover their already-ingested + # human relay evidence before selecting another repair. + for key, c in list(contributions.items()): + feedback_ids = sorted( + e["evidence_id"] for e in snap.evidence.values() + if e.get("kind") == "human_relay" and e.get("contribution_id") == c["contribution_id"]) + if feedback_ids and "pending_feedback_evidence_ids" not in c \ + and c["phase"] in {"development", "handoff", "upstream_review"}: + c = dict(c, pending_feedback_evidence_ids=feedback_ids[-64:]) + contributions[key] = c + out.staged.append(("contributions", c)) + # 2. Live branch and CI observation. if observe: contracts = {e["evidence_id"]: e for e in snap.evidence.values() if e.get("kind") == "target_contract"} diff --git a/upstreaming/schemas/contribution.schema.json b/upstreaming/schemas/contribution.schema.json index 3b93192941ea..95dc9918c6e4 100644 --- a/upstreaming/schemas/contribution.schema.json +++ b/upstreaming/schemas/contribution.schema.json @@ -899,6 +899,10 @@ "type": "array", "maxItems": 512, "items": {"type": "integer", "minimum": 1} }, + "pending_feedback_evidence_ids": { + "type": "array", "maxItems": 64, + "items": {"type": "string", "maxLength": 200} + }, "active_work": { "anyOf": [ { diff --git a/upstreaming/tests/test_fork_publish.py b/upstreaming/tests/test_fork_publish.py index 610062f734ff..fe3ebe6bdaf5 100644 --- a/upstreaming/tests/test_fork_publish.py +++ b/upstreaming/tests/test_fork_publish.py @@ -61,6 +61,12 @@ def proposal(self, **over): p.update(over) return p + def test_repair_must_acknowledge_every_reason_evidence_record(self): + self.task["task"] = "development_repair" + with self.assertRaisesRegex(fork_publish.PublishRejected, "did not acknowledge"): + fork_publish.check_proposal(self.proposal(reason_ids=[]), self.record, self.task) + fork_publish.check_proposal(self.proposal(reason_ids=["ci-1"]), self.record, self.task) + def fork_head(self): return git(self.fork_bare, "rev-parse", "refs/heads/riscv64") diff --git a/upstreaming/tests/test_observation.py b/upstreaming/tests/test_observation.py index 48c38e688295..fc9ea47e424e 100644 --- a/upstreaming/tests/test_observation.py +++ b/upstreaming/tests/test_observation.py @@ -51,6 +51,15 @@ def test_other_head_and_approval(self): self.assertEqual(self.ev([run(1, sha=SHA_B)], {}).state, "missing") self.assertEqual(self.ev([run(1, conclusion="action_required")], {}).state, "access_wait") + def test_any_executed_test_failure_blocks_green_but_publish_failure_does_not(self): + jobs = {1: [job(1, "wheels riscv64"), job(2, "tests (3.12)", conclusion="failure")]} + verdict = self.ev([run(1)], jobs) + self.assertEqual(verdict.state, "failed") + self.assertIn("tests (3.12)", " ".join(verdict.problems)) + publish_only = {1: [job(1, "wheels riscv64"), + job(2, "validate-release-request", conclusion="failure")]} + self.assertEqual(self.ev([run(1)], publish_only).state, "passed") + def test_rerun_uses_latest_attempt(self): runs = [run(1, attempt=1), run(1, attempt=2)] v = self.ev(runs, {1: [job(1, "wheels riscv64")]}) @@ -328,6 +337,15 @@ def test_repair_selected_with_capacity_only(self): self.assertEqual(eff["effect_contract"]["ref"], "riscv64") self.assertEqual(eff["expected_head"], SHA_A) + def test_repair_carries_pending_review_and_latest_ci_evidence(self): + rec = contribution(activity="fix_needed") + rec["pending_feedback_evidence_ids"] = ["review-1", "review-2"] + rec["last_ci_evidence_id"] = "ci-3" + res = controller.tick(contributions={"a": rec}, operations={}, consumed={}, projects={}, + policy=policy(), inputs=controller.Inputs( + now=T, pressure=capacity.Pressure(ok=True))) + self.assertEqual(res.requested_effects[0]["reason_ids"], ["review-1", "review-2", "ci-3"]) + def test_uncertain_operation_holds_work(self): rec = contribution(activity="fix_needed") op = recovery.plan(contribution_id=rec["contribution_id"], revision=0, kind="branch_update",